akhauriyash/Code-Regression huggingface dataset:
#include <queue>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

#define INF (1 << 29)

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

int main()
{
	while (true)
	{
		// ------ Variable, Input ------ //

		int H, W; vector<string> MAP;

		cin >> W >> H;

		if (W == 0 && H == 0) { break; }

		MAP = vector<string>(H);

		for (int i = 0; i < H; i++)
		{
			cin >> MAP[i];
		}


		// ------ Graph Construction ------ //

		vector<pair<int, int> > Location(1);

		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				if (MAP[i][j] == 'o')
				{
					Location[0] = make_pair(j, i);
				}

				if (MAP[i][j] == '*')
				{
					Location.push_back(make_pair(j, i));
				}
			}
		}

		vector<vector<int> > Graph(Location.size(), vector<int>(Location.size(), INF));

		for (int i = 0; i < Location.size(); i++)
		{
			vector<vector<int> > distance_(H, vector<int>(W, INF)); distance_[Location[i].second][Location[i].first] = 0;

			queue<pair<int, int> > que; que.push(Location[i]);

			while (!que.empty())
			{
				pair<int, int> p1 = que.front(); que.pop();

				for (int dir = 0; dir < 4; dir++)
				{
					int px = p1.first + dx[dir];
					int py = p1.second + dy[dir];

					if (0 <= px && px < W && 0 <= py && py < H && MAP[py][px] != 'x' && distance_[py][px] == INF)
					{
						distance_[py][px] = distance_[p1.second][p1.first] + 1;

						que.push(make_pair(px, py));
					}
				}
			}

			for (int j = 0; j < Location.size(); j++)
			{
				if (i != j)
				{
					int dist = distance_[Location[j].second][Location[j].first];

					Graph[i][j] = dist;
				}
			}
		}

		// ------ Traveling Salesman Problem ------ //

		vector<vector<int> > dp(Graph.size(), vector<int>(1 << Graph.size(), INF));

		dp[0][1] = 0;

		for (int i = 2; i < (1 << Graph.size()); i++)
		{
			for (int j = 0; j < Graph.size(); j++)
			{
				for (int k = 0; k < Graph.size(); k++)
				{
					if (i & (1 << j) && i & (1 << k))
					{
						dp[k][i] = min(dp[j][i - (1 << k)] + Graph[j][k], dp[k][i]);
					}
				}
			}
		}

		int Answer = INF;

		for (int i = 0; i < Graph.size(); i++)
		{
			Answer = min(Answer, dp[i][(1 << Graph.size()) - 1]);
		}

		cout << (Answer == INF ? -1 : Answer) << endl;
	}

	return 0;
}

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

int main() {
	int N ;
	cin >> N;
	map<int,int>A;
	map<int,int>B;
	for (int n = 0;n<N;++n) {
		int num;
		cin >> num;
		if (0 == n%2) {
			A[num]++;
		}
		else {
			B[num]++;
		}
	}
	int A0 = 0;
	int a0 = 0;
	int A1 = 0;	
	int a1 = 0;
	for (auto itr = A.begin(); itr != A.end(); ++itr) {
		if (A0 < itr->second) {
			A0 = itr->second;
			a0 = itr->first;
		}
	}	
	for (auto itr = A.begin(); itr != A.end(); ++itr) {
		if (A1 < itr->second && itr->first != a0) {
			A1 = itr->second;
			a1 = itr->first;
		}
	}
	int B0 = 0;
	int b0 = 0;
	int B1 = 0;
	int b1 = 0;
	for (auto itr = B.begin(); itr != B.end(); ++itr) {
		if (B0 < itr->second) {
			B0 = itr->second;
			b0 = itr->first;
		}
	}
	for (auto itr = B.begin(); itr != B.end(); ++itr) {
		if (B1 < itr->second && itr->first != b0) {
			B1 = itr->second;
			b1 = itr->first;
		}
	}
	int ans = 0;
	if (a0 == b0) {
		ans = min(N - A0 - B1, N - A1 - B0);
	}
	else {
		ans = N - A0 - B0;
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 8268
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)
int main(){
	long long n;
	cin >> n;
	for (long long q = 1; q <= 50000; ++q) {
		if ((q * 108)/100 == n) {
			cout << q << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
}

Measured memory_bytes: 888
/**
*    created: 04.07.2020 20:47:18
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    int sum = 0;
    rep(i,n) {
        int l, r;
        cin >> l >> r;
        sum += r - l + 1;
    }
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 3576
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
l=i2()
ls=sum(l)
s=0
for i in l:
  if ls-2*i<=0:
    s=1
if s==0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38256
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e14 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug() {
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main() {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long n; cin >> n;

    vector<long long> a(n), b(n);

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

    sort(b.rbegin(), b.rend());

    for(long long i = 0; i < n; i++) {
        if(a[i] == b[0]) {
            cout << b[1] << "\n";
        }
        else {
            cout << b[0] << "\n";
        }
    }

    return 0;
}


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

using ll = long long;
int main(){
  int n,cnt=0,k=0;
  cin >> n;
  for(int i = 1; i < n; i++){
    for(int j = 1; j*j <= n-i; j++){
      if(j*j == n-i){
        k++;
        continue;
      }
      if((n-i) % j == 0){
        cnt+=2;
      }
    }
  }
  ll ans;
  ans = cnt + k;
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;;

const int maxn = 1e2 + 5;
const int maxlen = 63244;

int n , k;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);	
	int n;cin >> n;int res = 0;
	vector<int> v(n * 2);
	for(int & c : v)cin >> c;
	sort(v.begin(),v.end());
	for(int i = 0 ; i < n * 2 ; i += 2){
		res += v[i];
	}
	cout << res;
}


Measured memory_bytes: 256
#include<stdio.h>


int main(void){
	static int a[2000000],b[2000000],c[10001];
	int n;
	int i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&(a[i]));
	}
	for(i=0;i<=10000;i++){
		c[i]=0;
	}
	for(i=0;i<n;i++){
		c[a[i]]++;
	}
	for(i=1;i<=10000;i++){
		c[i]=c[i]+c[i-1];
	}

	for(i=0;i<n;i++){
		b[c[a[i]]-1]=a[i];
		c[a[i]]--;
	}
	for(i=0;i<n;i++){
		printf("%d%c",b[i],i==n-1?'\n':' ');
	}
	return 0;
}

Measured memory_bytes: 16264
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) v.begin(),v.end()
#define endll "\n"

#define fin             freopen("input.txt","r",stdin);
#define fout            freopen("output.txt","w",stdout);


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c,d;
    cin >> a >> b >> c>> d;
    cout << max(a*b,c*d) << endl;

    return 0;
}



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

using namespace std;

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

#define rep(i, n) REP(i, 0, (n))
#define REP(i, a, n) for(int i=(a); i<(n); i++)
#define pb push_back

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << ((a<c&&c<b)||(a>c&&c>b)? "Yes":"No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    int H, W;
    cin >> H >> W;

    vs field(H + 2);
    string wall = string(W + 2, '#');
    string line;
    field[0] = wall;
    repeat (i, H) {
        cin >> line;
        field[i + 1] = "#" + line + "#";
    }
    field[field.size() - 1] = wall;

    repeat (i, field.size()) {
        cout << field[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
  public static void main(String args[]) {
     Scanner sc = new Scanner(System.in);
     int a  = sc.nextInt();
     int b = sc.nextInt();
     int x = sc.nextInt();
     if (a > x || a + b < x) {
        System.out.println("NO");
        return;
     } 
     System.out.println("YES");
  }
}

Measured memory_bytes: 21716
#include<iostream>
#include<cstdio>

#include<vector>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
const int INF = 1e9+1;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    vector<int> V;
    int i = 0;
    while (i < N) {
        int tmp = A[i];
        int k = i;
        while (A[k+1] == tmp && k+1 < N) k++;
        V.push_back(k - i + 1);
        i = k+1;
    }
    sort(V.begin(), V.end());
    int M = V.size();
    int res = 0;
    for (int i = 0; i < (M - K); i++) {
        res += V[i];
    }
    cout << res << endl;


}

Measured memory_bytes: 2168
//packages
#include <bits/stdc++.h>//C++14 GCC mode!!!
//alias and namespaces
using namespace std;
//macros
#define REP(i,O,N) for(int i=O;i<N;i++)//うーん、python同様にRange関数でも実装してしまおうかしら…？
#define rep(i,N) for(int i=0;i<N;i++)
#define all(v) v.begin(),v.end()//v.end()-i は[-i]相当
#define debug(x) cerr<< #x <<":"<<x<<endl;
#define v(type) std::vector<type>
#define v2(type)  std::vector<std::vector<type>>
#define v3(type)  std::vector<std::vector<std::vector<type>>>
//functions   



//solution
long long luca(int N){
    v(long long)lucaT(N+1);

    rep(i,N+1){
        if (i==0) lucaT.at(i)=2;
        else if (i==1) lucaT.at(i)=1;
        else{
            lucaT.at(i)=lucaT.at(i-1)+lucaT.at(i-2);
        }
    }
    return lucaT.at(N);
}
int main(void){
    //input
    int N;
    cin >>N;
    //output
    //cout<<((ans==1)?"Yes":"No")<<endl;//true to yes
    cout << luca(N)<<endl;//value
    //cout << ans<<endl;//other
    
}


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

long long int num[100001];
long long int a[100000];


int main()
{
	int N = 0;
	cin >> N;
	memset(a, 0, sizeof(a));
	memset(num, 0, sizeof(num));
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	long long int ans = 0;
	for (int i = 0; i < N; i++) {
		if (a[i]<= 100000) num[a[i]]++;
		else {
			ans++;
		}
	}
	for (int i = 1; i <= 100000; i++) {
		if (num[i] > i) ans += num[i] - i;
		else if (num[i] < i) ans += num[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;
typedef vector<long long int> vll;

int main() {
	int n;
	cin >> n;
	vi a(n);
	rep(i, 0, n) {
		cin >> a[i];
	}
	cout << (*max_element(all(a)) - *min_element(all(a))) << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

	    String S = scanner.next();
	    String T = scanner.next();
	    String al = "abcdefghijklmnopqrstuvwxyz";
	    String r = "Yes";
	    boolean flg = false;
	    for (int i = 0; i< al.length(); i++) {
	    	if (flg) {
	    		break;
	    	}
	        char target = al.charAt(i);
	        List<Integer> l = new ArrayList<Integer>();
	        for (int j = 0; j< S.length(); j++) {
	            char s = S.charAt(j);
	            if (s == target) {
	                l.add(j);
	            }
	        }
	        if (l.size() > 1) {
	        	char t0 = T.charAt(l.get(0));
	        	for (int j = 1; j< l.size(); j++) {
		            char t = T.charAt(l.get(j));
		            if (t != t0) {
                        r = "No";
                        flg = true;
                        break;
		            }
		        }
	        }
	    }

	    for (int i = 0; i< al.length(); i++) {
	    	if (flg) {
	    		break;
	    	}
	        char target = al.charAt(i);
	        List<Integer> l = new ArrayList<Integer>();
	        for (int j = 0; j< T.length(); j++) {
	            char t = T.charAt(j);
	            if (t == target) {
	                l.add(j);
	            }
	        }
	        if (l.size() > 1) {
	        	char s0 = S.charAt(l.get(0));
	        	for (int j = 1; j< l.size(); j++) {
		            char s = S.charAt(l.get(j));
		            if (s != s0) {
                        r = "No";
                        flg = true;
                        break;
		            }
		        }
	        }
	    }


        System.out.print(r);
	}
}

Measured memory_bytes: 52632
#C - Colorful Leaderboard 
N = int(input())
a = list(map(int,input().split()))

mini = 0
color_list = []
for i in a:
    if (i//400)<8 and ((i//400 in color_list) == False):
        mini += 1
        color_list.append(i//400)

maxi = mini
for j in a:
    if j >= 3200:
        maxi += 1
if mini == 0:#忘れてた
    mini = 1
print(mini,maxi)

Measured memory_bytes: 9172
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
vector<int> G[1000];
int X[1000];
int dp[1000];

int dp2[2][5001];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  for (int i=1; i<N; i++) {
    int p;
    cin >> p;
    p--;
    G[p].pb(i);
  }
  rep(i, N) cin >> X[i];

  rep(i, N) dp[i] = INF;
  for (int x=N-1; x>=0; x--) {
    rep(i, 5001) rep(k, 2) dp2[k][i] = INF;
    dp2[0][0] = 0;
    for (int t : G[x]) {
      // (dp[t], X[t])
      int a = dp[t], b = X[t];
      rep(i, 5001) dp2[1][i] = INF;
      rep(s, X[x]+1) {
        if (dp2[0][s] == INF) continue;
        if (s+a <= X[x]) dp2[1][s+a] = min(dp2[1][s+a], dp2[0][s] + b);
        if (s+b <= X[x]) dp2[1][s+b] = min(dp2[1][s+b], dp2[0][s] + a);
      }
      swap(dp2[0], dp2[1]);
    }
    int m = *min_element(dp2[0], dp2[0]+X[x]+1);
    if (m == INF) {
      cout << "IMPOSSIBLE\n";
      return 0;
    }
    //cout<<"dp["<<x<<"]="<<m<<"\n";
    dp[x] = m;
  }
  if (dp[0] == INF) cout << "IMPOSSIBLE\n";
  else cout << "POSSIBLE\n";
  return 0;
}


Measured memory_bytes: 384
n=int(input())
primes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
pcnt = [0]*len(primes)
for x in range(1,n+1):
  for pidx in range(len(primes)):
    p=primes[pidx]
    while x % p ==0:
      x//=p
      pcnt[pidx]+=1

primes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
pcnt = [0]*len(primes)
for x in range(1,n+1):
  for pidx in range(len(primes)):
    p=primes[pidx]
    while x % p ==0:
      x//=p
      pcnt[pidx]+=1
      
ret=0
#3*5*5 case
for i in range(len(pcnt)):
  for j in range(i+1,len(pcnt)):
    for k in range(len(pcnt)):
      if pcnt[i]>=4 and pcnt[j]>=4 and pcnt[k]>=2 and i!=k and j!=k:
        ret+=1
#3*25 case
for i in range(len(pcnt)):
  for j in range(len(pcnt)):
    if pcnt[i]>=24 and pcnt[j]>=2 and i!=j:
      ret+=1
#5*15 case
for i in range(len(pcnt)):
  for j in range(len(pcnt)):
    if pcnt[i]>=14 and pcnt[j]>=4 and i!=j:
      ret+=1
#75 case
for i in range(len(pcnt)):
  if pcnt[i]>=74:
    ret+=1

print(ret)

Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <cmath>
#define SIZE 305

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

char mp[SIZE][SIZE];
char nxt[SIZE][SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%s",&mp[i]);
	int ret=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<n;k++)
			{
				nxt[j][k]=mp[(j+1)%n][k];
			}
		}
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<n;k++)
			{
				mp[j][k]=nxt[j][k];
			}
		}
		bool ok=true;
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<n;k++)
			{
				if(mp[j][k]!=mp[k][j]) ok=false;
			}
		}
		if(ok) ret+=n;
	}
	printf("%d\n",ret);
	return 0;
}


Measured memory_bytes: 384
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		BigInteger ans = BigInteger.ONE;
		for (int i = 0; i < n; i++) {
			BigInteger bi = new BigInteger(sc.next());
			ans = ans.multiply(bi).divide(ans.gcd(bi));
		}
		sc.close();

		System.out.println(ans.toString());
	}
}


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

int main()
{
    char s[4];
    while(cin>>s)
    {
        if(s[0]==s[1] and s[1]==s[2])
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
long n,a,c=0;
scanf("%ld",&n);
while(n-->0){
scanf("%ld",&a);
c+=a%2;
}
if(c%2==0)puts("YES");
else if(n%2==1)puts("YES");
else puts("NO");
return 0;
}


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

vector<ll> sums,sumg;
void pre_process(vector<ll> &a,vector<ll> &s){//累積和のvector
    ll n=(ll)a.size();
    s.assign(n+1,0);
    for(ll i=0;i<n;i++){
        s[i+1]=s[i]+a[i];
    }
}

int main(){
    ll n,m,Q;cin>>n>>m>>Q;
    vector<P> pairs;

    rep(i,m){
        ll pf,ps;cin>>pf>>ps;
        pf--;ps--;
        pairs.push_back({pf,ps});
    }
    sort(pairs.begin(),pairs.end());

    vector<vector<ll>> list(510,vector<ll>(510)),sum(510);
    rep(i,m){
        list[pairs[i].fi+1][pairs[i].se]++;
    }
    rep(i,510){
        pre_process(list[i],sum[i]);
    }
/*
    rep(i,11){
        rep(j,11){
            cout<<sum[i][j]<<" ";
        }
        cout<<endl;
    }
*/
    rep(i,Q){
        ll p,q,ans=0;cin>>p>>q;
        for(ll i=p;i<=q;i++){
            ans+=sum[i][q];
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 10512
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    string S;
    cin >> N >> S;
    int cnt = 0,ans = 0;;
    for(int i = 0; i < S.size(); i++) {
        if(S[i] == '.') {
            ans++;
        }
    }
    cnt = ans;
    for(int i = 0; i < S.size(); i++) {
        if(S[i] == '.') {
            cnt--;
        }
        else {
            cnt++;
        }
        ans = min(ans,cnt);
    }
    cout << ans << endl;
}


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

int main() {
  int64_t N,A,B; cin >> N >> A >> B;  // 先頭からの数・青玉・赤玉

  // 1.A+B で割り切れる範囲
  // (N / (A+B) ) * A
  // 2.A+B で割り切れない部分
  // 2-1.余り≧Ａ→Ａ
  // 2-2.余り＜Ａ→余り

  // 1.A+B で割り切れる範囲
  // (N / (A+B) ) * A
  int64_t Ans1 = ( N / (A+B) ) * A;

  // 2.A+B で割り切れない部分
  // 2-1.余り≧Ａ→Ａ
  int64_t Ans2 = 0;
  if ( N % ( A+B ) >= A ) { Ans2 = A;}
  // 2-2.余り＜Ａ→余り
  else { Ans2 = N % ( A+B ); }

  cout << Ans1 + Ans2 << endl;
  
}


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

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

//#define int long long
#define ll long long

ll INF = (1LL << 60);
int mod = 998244353;
using P = pair<ll, ll>;

signed main() {
	int a, b; cin >> a >> b;
	if (1 <= a && a <= 9) {
		if (1 <= b && b <= 9) {
			cout << a * b << endl;
		}
		else cout << -1 << endl;
	}
	else cout << -1 << endl;
	return 0;
}



Measured memory_bytes: 3640
n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))

dict_m = {}

def dfs(idx, sum_v):
    if idx == n:
        dict_m[sum_v] = True
        return
    
    dfs(idx+1, sum_v)
    dfs(idx+1, sum_v+A[idx])

dfs(0, 0)
for m in M:
    if m in dict_m:
        print('yes')
    else:
        print('no')
    


Measured memory_bytes: 5648
using System;

class Rating{
  static void Main(){
      
      var input = Console.ReadLine().Split(' ');
      long number = long.Parse(input[0]);
      long divide = long.Parse(input[1]);
      long digit = 0;
      
      while(number != 0){
         number =  number / divide;
         digit++;
      }
    
    Console.WriteLine(digit);
  }
}

Measured memory_bytes: 11092
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var count = 0;
        for (int i = a; i <= b; i++)
            if (checkK(i)) count++;
        Console.WriteLine(count    );
    }
    public static bool checkK (int n)
    {
        var s = n.ToString();
        var sL = s.Length;
        for (int i = 0; i <= sL/2; i++)
            if (s[i] != s[sL - 1-i]) return false;
        return true;
    }
}

Measured memory_bytes: 15188
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,d,count=0,sum=0;
	cin>>n>>d;
	int a[n][d];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<d;j++)
	    {
	    	cin>>a[i][j];
		}
	}
	for(int i=0;i<n-1;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			for(int k=0;k<d;k++)
			{
				sum+=pow((a[i][k]-a[j][k]),2);
			}
			float f=sqrt(sum);
			int h=(int)f;
			if(h==f)
			count++;
			sum=0;
		}
	}
	cout<<count<<"\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
int main(){
  vector<string>sis(256);
  int n,m;

  cin>>n;
  rep(i,n)cin>>sis[i];

  cin>>m;
  int key=1;
  rep(i,m){
    string in;
    bool known=false;
    cin>>in;
    rep(i,n)if(sis[i]==in)known=true;
    if(known){
      if(key){cout<<"Opened by "<<in<<endl;key=0;}
      else {cout<<"Closed by "<<in<<endl;key++;}
    }else cout<<"Unknown "<<in<<endl;
  }
} 

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
#define INF 1000000007
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill( (T*)array, (T*)(array+N), val );};


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

  int n;
  cin >> n;
  vector<double> v(n);
  rep(i, n) cin >> v[i];
  sort(all(v));
  rep(i, n - 1) {
    v[i + 1] = (v[i] + v[i + 1]) / 2;
  }
  cout << fixed << v[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 256
ENV[Z='RUBY_THREAD_VM_STACK_SIZE']||exec({Z=>5e7.to_s},'ruby',$0);def f(i)r=0;H[i].map{|e|f e}.sort.map{|e|r=[r,e].max+1};r end;H=Hash.new{|h,k|h[k]=[]};2.upto(gets.to_i){|i|H[gets.to_i]<<i};p f 1

Measured memory_bytes: 224588
def bb047
    w,h,n = gets.chomp.split(/\s/).map{|x| x.to_i}

    xr = 0..w
    yr = 0..h

    for i in 1..n
        x,y,a = gets.chomp.split(/\s/).map{|z| z.to_i}
        case a
        when 1 # x < xi
            xr = x..xr.last if x > xr.first
        when 2 # x > xi
            xr = xr.first..x if x < xr.last
        when 3 # y < yi
            yr = y..yr.last if y > yr.first
        when 4 # y > yi
            yr = yr.first..y if y < yr.last
        end
    end

    if (xr.last - xr.first) < 0 or (yr.last - yr.first) < 0
        puts 0
        exit
    end

    puts (xr.last - xr.first) * (yr.last - yr.first)
end

bb047

Measured memory_bytes: 1788
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define VMAX 10000

int n,i,j;

void CountingSort(short A[],short B[],int k)
{
  int C[VMAX+1];
  for(i=0;i<=k;i++) C[i]=0;

  for(j=0;j<n;j++) C[A[j]]++;

  for(i=1;i<=k;i++) C[i]=C[i]+C[i-1];

  for(j=n-1;j>=0;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
      }
}

int main(){
  unsigned short *A, *B;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=0;i<n;i++) scanf("%d",&A[i]);
  CountingSort(A,B,VMAX);

  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    if(i==n){
      printf("\n");
    }else printf(" ");
  }
  return 0;
}


Measured memory_bytes: 9552
n=97
def c(i,j,k):print('<',i,j,k)
def a(i,j,k):print('+',i,j,k)
def d(x,i,j):
	for t in range(30):
		a(j+t-1,j+t-1,j+t)
		a(j+t,n,j+t)
		for s in range(j+t,j+29):a(s,s,s+1)
		c(j+29,x,i+t)
		a(j+t-1,j+t-1,j+t)
		a(j+t,i+t,j+t)
print(3933)
a(0,1,n)
c(2,n,n)
a(0,n,3)
a(1,n,4)
d(3,5,36)
d(4,36,67)
for t in range(59):
	a(2,2,2)
	for s in range(t+1):
		if t-30<s<30:a(5+t-s,36+s,98);c(n,98,99);a(2,99,2)

Measured memory_bytes: 8924
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const N = parseInt(args[0][0], 10)
	const B = args[1].map(arg => parseInt(arg, 10))
	const A = new Array(N).fill(0)
	let ans = 0

	A[0] = B[0]

	for (let i = 1; i < N - 1; i++) {
		A[i] = Math.min(B[i - 1], B[i])
	}

	A[N - 1] = B[N - 2]

	for (let i = 0; i < N; i++) {
		ans += A[i]
	}

	console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
#include "bits/stdc++.h"

#pragma warning(disable:4996)
using namespace std;
int main() {
	//int N,K;cin>>N>>K;
	//bool ok=N>K*2-2;
	//if (ok) {
	//	cout<<"YES"<<endl;
	//}
	//else {
	//	cout<<"NO"<<endl;
	//}

	//for (int i = 0; i < 3; ++i) {
	//	int a,b;cin>>a>>b;
	//	a--;b--;
	//	nums[a]++;
	//	nums[b]++;
	//}
	//int sum=0;
	//sort(nums.begin(),nums.end());
	//if (nums == vector<int>{ 1,1,2,2 })cout<<"YES"<<endl;
	//else cout<<"NO"<<endl;
	//return 0;

	int K,A,B;cin>>K>>A>>B;
	long long int answer=1+K;
	if (A < B) {
		long long int rest=K-(A-1);
		long long int nanswer=0;
		if (rest>0) {
			nanswer=A+(rest/2)*(B-A);
			if(rest%2)nanswer++;
		}
		answer=max(answer,nanswer);
	}
	cout<<answer<<endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
ans=0
for i in range(1,max(h)+1):
    num=0
    for j in range(n):
        if num==0 and h[j]>=i:
            ans+=1
            num=1
        if num==1 and h[j]<i:
            num=0
print(ans)


Measured memory_bytes: 8992
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <cmath>
#include <string>
using namespace std;
int main()
{
	string s;
	int i;
	cin>>s;
	for(i=0;i<19;i++)
	{
		if(s[i]==',')
		{
			cout<<' ';
		}
		else{
			cout<<s[i];
		}
	}
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int ans[] = new int[3];
    for (int i = 0; i < 3; i++){
      ans[i] = sc.nextInt();
    }
    Arrays.sort(ans);
    System.out.println(ans[0]+ans[1]);
  }
}


Measured memory_bytes: 35664
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

int n, m;
vector<int> adj[100005];
vector<int> memo(100005, -1);

int rec(int i, int pre){
    if(memo[i] != -1) return memo[i];

    int res = 0;
    for(auto nxt : adj[i]){
        if(nxt == pre) continue;
        chmax(res, rec(nxt, i)+1); 
    }
    return memo[i] = res;
}

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

    cin >> n >> m;
    rep(i, m){
        int x, y; cin >> x >> y; --x; --y;
        adj[x].push_back(y);
    }

    int ans = 0;
    rep(i, n) chmax(ans, rec(i, -1));
    cout << ans << endl;

    return 0;
}

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

using namespace std;

const int md = (int) 1e9 + 7;

inline int add(int a, int b) {
  a += b;
  if (a >= md) a -= md;
  return a;
}

inline int sub(int a, int b) {
  a -= b;
  if (a < 0) a += md;
  return a;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

const int N = 100010;

int main() {
  vector<int> fac(N), finv(N);
  fac[0] = finv[0] = 1;
  for (int i = 1; i < N; i++) {
    fac[i] = mul(fac[i - 1], i);
    finv[i] = inv(fac[i]);
  }

  auto comb = [&](int n, int m) {
    assert(n >= m);
    int res = fac[n];
    res = mul(res, finv[m]);
    res = mul(res, finv[n - m]);
    return res;
  };
  
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    if (n - k < i - 1) {
      cout << "0\n";
      continue;
    }
    cout << mul(comb(n - k + 1, i), comb(k - 1, i - 1)) << '\n';
  }
  return 0;
}


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

signed main(){
    int N,M; cin>>N>>M;
    vector<int>ans(N,-1);
    string A="";
    for(int i=0;i<M;i++){
        int s,c; cin>>s>>c;
        if(ans[s-1]==-1)ans[s-1]=c;
        if(ans[s-1]!=-1 && ans[s-1]!=c){
            A+="-1"; break;
        }
        if(s==1 && c==0 && N!=1){
            A+="-1"; break;
        }
    }
    if(A.size()==0){
        for(int i=0;i<N;i++){
            if(i==0 && ans[i]==-1 && N!=1)ans[i]=1;
            if(i==0 && ans[i]==-1 && N==1)ans[i]=0;
            if(i!=0 && ans[i]==-1)ans[i]=0;
            A+=to_string(ans[i]);
        }
    }
    cout<<A<<endl;
    
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,x[4]={0},i;
    for(i=0; i<2; i++)
    {
        scanf("%d", &a);
        x[a]=1;
    }
    for(i=1; i<4; i++)
    {
        if(x[i]==0)
        printf("%d\n", i);
    }
    
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

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

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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

    int n;
    cin >> n;
    int a[200010];
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }

    ll res =0;
    for (int i=1; i<n; i++) {
        if (a[i-1] > a[i]) {
            res += a[i-1] - a[i];
            a[i] += a[i-1] - a[i];
        }
    }
    wcout << res << "\n";

}

Measured memory_bytes: 4456
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int a,b;
		String s,t,c;

		Scanner sc = new Scanner(System.in);

		s = sc.next();
		t = sc.next();

		a = sc.nextInt();
		b = sc.nextInt();

		c = sc.next();

		if (s.equals(c) ) {
			a = a - 1;
		} else {
			b = b - 1;
		}

		System.out.println(a + " " + b);

	}

}


Measured memory_bytes: 21844
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', (chunk) => {
    let lines = chunk.toString().split('\n');
    let count = 0;
    let str = '';
    for (var s of lines) {
        count ++;
        if (s !== '0') {
            console.log(`Case ${count}: ${s}`);
        } else {
            break;
        }
    }
});


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


int main() {
  string S;
  cin >> S;
  
  int ans = 7;
  
  if(S == "SUN"){
    ans = 7;
  }else if(S == "MON"){
    ans = 6;
  }else if(S == "TUE"){
    ans = 5;
  }else if(S == "WED"){
    ans = 4;
  }else if(S == "THU"){
    ans = 3;
  }else if (S == "FRI"){
    ans = 2;
  }else if (S == "SAT"){
    ans = 1;
  }
  
  cout << ans << endl;
 
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
typedef pair<double, long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	set<ll>st;
	st.insert(a);
	st.insert(b);
	st.insert(c);
	if (st.size() == 2)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

int search(int64 *a,int n,int64 v){
  int l=0;
  int r=n;
  while(r-l>1){
    int m=(l+r)/2;
    if(a[m]<=v){
      l=m;
    } else {
      r=m;
    }
  }
  return l;
}

void run(void){
  int a,b,q;
  scanf("%d%d%d",&a,&b,&q);
  int64 *s=(int64 *)calloc(a+2,sizeof(int64));
  int64 *t=(int64 *)calloc(b+2,sizeof(int64));
  int i;
  for(i=1;i<=a;i++) scanf("%lld",s+i);
  for(i=1;i<=b;i++) scanf("%lld",t+i);
  s[0]=t[0]=-2000000000000LL;
  s[a+1]=t[b+1]=200000000000LL;
  while(q--){
    int64 x;
    scanf("%lld",&x);
    int l=search(s,a+2,x);
    int r=search(t,b+2,x);
    int64 p[2]={s[l],s[l+1]};
    int64 q[2]={t[r],t[r+1]};
    int64 min=1000000000000000LL;
    for(int i=0;i<2;i++){
      for(int j=0;j<2;j++){
	min=MIN(min,ABS(x-p[i])+ABS(p[i]-q[j]));
	min=MIN(min,ABS(x-q[j])+ABS(p[i]-q[j]));
      }
    }
    printf("%lld\n",min);
  }
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 2816
#!/usr/bin/python
# -*- coding: utf-8 -*-

n = int(raw_input())
vs = [int(x) for x in raw_input().split()]

from collections import defaultdict
v1 = defaultdict(int)
v2 = defaultdict(int)
for i in xrange(0, n, 2):
	v1[vs[i]] += 1
	v2[vs[i+1]] += 1
v1 = [(k, v) for k, v in v1.iteritems()]
v2 = [(k, v) for k, v in v2.iteritems()]
v1 = sorted(v1, key=lambda x: x[1], reverse=True)
v2 = sorted(v2, key=lambda x: x[1], reverse=True)

if v1[0][0] == v2[0][0]:
	if len(v1) == 1:
		count = n - v2[0][1]
	elif len(v2) == 1:
		count = n - v1[0][1]
	else:
		count = n - max(v1[0][1] + v2[1][1], v1[1][1] + v2[0][1])
else:
	count = n - v1[0][1] - v2[0][1]
print count

Measured memory_bytes: 16964
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

#define MOD (1000000007)
#define NONE (0)
#define VERT (1)
#define HORI (2)

int main()
{
	int N, pre = NONE, cur;
	ll ans = 0;
	string S1, S2;

	cin >> N >> S1 >> S2;

	rep(i, N) {
		if (S1[i] == S2[i]) cur = VERT;
		else {
			cur = HORI;
			i++;
		}

		if (pre == NONE && cur == HORI) ans = 6;
		else if (pre == NONE && cur == VERT) ans = 3;
		else if (pre == HORI && cur == HORI) ans = (ans * 3) % MOD;
		else if (pre == HORI && cur == VERT) ans = (ans * 1) % MOD;
		else if (pre == VERT && cur == HORI) ans = (ans * 2) % MOD;
		else if (pre == VERT && cur == VERT) ans = (ans * 2) % MOD;

		pre = cur;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n,a[105];
	cin>>n;
	for (int i=1;i<n+1;i++){
		cin>>a[i];
	}
	for (int i=n;i>1;i--){
		cout<<a[i]<<' ';
	}
	cout<<a[1]<<endl;
}


Measured memory_bytes: 3096
n,q=[int(s) for s in input().split()]
graph=[[] for _ in range(n)]
for i in range(n-1):
  a,b=[int(s) for s in input().split()]
  a-=1
  b-=1
  graph[a].append(b)
  graph[b].append(a)

ct=[0 for _ in range(n)]   #Qの累計
for i in range(q):
  p,x=[int(s) for s in input().split()]
  p-=1
  ct[p]+=x

#深さ優先探索
stack=[(0, ct[0], -1)]
ans=[0 for _ in range(n)]
while stack:
  vrt, cost, _from = stack.pop(-1)
  ans[vrt] = cost
  for _to in graph[vrt]:
    if _to ==_from:
      continue
    stack.append((_to, cost+ct[_to],vrt))
print(*ans)
  

Measured memory_bytes: 68952
class UnionFind
  def initialize
    @parent = Hash.new
    @rank = Hash.new
  end
  def make(x)
    @parent[x] = x
    @rank[x] = 0
  end
  def union(a, b)
    x, y = find(a), find(b)
    x, y = y, x if @rank[x] < @rank[y]
    @parent[y] = x
    @rank[x] += 1 if @rank[x] == @rank[y]
  end
  def find(x)
    @parent[x] == x ? x : @parent[x] = find(@parent[x])
  end
  def size
    @parent.keys.map{|k| find(k)}.sort.uniq.size
  end
end

while gets
  subset = gets.split.map{|d| d.chars.map(&:to_i)}
  disjoint_set = UnionFind.new
  degree = Hash.new{0}

  subset.flatten.sort.uniq.each do |d|
    disjoint_set.make(d)
  end

  subset.each do |d|
    degree[d.first] += 1
    degree[d.last] += 1
    disjoint_set.union(*d)
  end

  puts disjoint_set.size == 1 && degree.select{|k, v| v.odd?}.size <= 2 ? "Yes" : "No"
end

Measured memory_bytes: 6124
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
using std::swap;

// priceをキーに降順でソート
//sort(fruits.begin(), fruits.end(),
//     [](const fruit& x, const fruit& y) { return x.price > y.price;});

/*
int main() {
    long long int S;
    int r;
    std::cin >> r;
    S= 3*r*r;
    std::cout << S << std::endl;
    return 0;
}
 */

/*
int main(){
    int K, D;
    int ans;
    std::cin >> K >> D;
    ans = (K+2*D)/(2*D+1);
    std::cout << ans << std::endl;
}
 */

/*
int main(){
    int N;
    int max=0;
    int sem_max=0;
    std::cin >> N;
    int A[N];
    for(int i=0; i<N; i++){
        std::cin >> A[i];
    }
    for(int i=0; i<N; i++){
        if(A[i]>max){
            sem_max = max;
            max=A[i];
        }
        else if(A[i]>sem_max){
            sem_max=A[i];
        }
    }
    for(int i=0; i<N; i++){
        if(A[i]==max){
            std::cout << sem_max << std::endl;
        }
        else{
            std::cout << max << std::endl;
        }
    }
    return 0;
}
 */

int main(){
    int N;
    std::cin >> N;
    int a[N+1];
    int b[N+1];
    int count=0;
    for(int i=1; i<N+1; i++){
        std::cin >> a[i];
    }
    for(int i=1; i<N+1; i++){
        b[i]=0;
    }
    for(int i=0; i<N; i++){
        for(int j=1; j<N/(N-i); j++) {
            b[N - i] += b[(j+1) * (N - i)];
        }
        b[N-i]=(b[N-i]+a[N-i])%2;
    }
    for(int i=1; i<N+1; i++){
        if(b[i]==1){
            count++;
        }
    }
    std::cout << count << std::endl;
    for(int i=1; i<N+1; i++) {
        if (b[i] == 1) {
            std::cout << i << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2432
n = int(input())
a, b = map(int, input().split())
point = list(map(int, input().split()))

q = [0, 0, 0]
for p in point:
  if p <= a:
    q[0] += 1
  elif p <= b:
    q[1] += 1
  else:
    q[2] += 1

print(min(q))

Measured memory_bytes: 3064
#include <iostream>

using namespace std;
int main(void) {

    int x, y;
    cin >> x >> y;
    
    string s = "";
    
    if (x == y)
    {
        s = " == ";
    } else if (x > y) {
        s = " > ";
    } else {
        s = " < ";
    }
    
    cout << "a" << s << "b" << endl;

    return 0;
}



Measured memory_bytes: 3152
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto a = readln.split.to!(int[]);

  auto calc(int fs)
  {
    auto t = 0, ans = 0L;
    foreach (i, ai; a) {
      auto s = i % 2 == 0 ? fs : -fs;
      t += ai;
      if (t * s <= 0) {
        ans += (s - t) * s;
        t = s;
      }
    }
    return ans;
  }

  writeln(min(calc(+1), calc(-1)));
}


Measured memory_bytes: 4512
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() 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 nextInt64() int64 {
	sc.Scan()

	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextF64() float64 {
	sc.Scan()

	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	s := strings.Split(nextLine(), "")
	flag := false
	for idx, val := range s {
		for i, v := range s {
			if val == v && i != idx {
				flag = true
			}
		}
	}
	if flag {
		fmt.Println("no")
	} else {
		fmt.Println("yes")
	}

}


Measured memory_bytes: 1776