akhauriyash/Code-Regression huggingface dataset:
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const ll INF = 1e18;
const int MAXN = 120000;

ll dp[MAXN];
ll h[MAXN];
int n;

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> h[i];
	fill(dp, dp + n, INF);
	dp[0] = 0;
	for (int i = 0; i < n - 1; ++i) {
		for (int j = 1; i + j < n && j <= 2; ++j) {
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}
	cout << dp[n - 1] << "\n";
	return 0;
}




Measured memory_bytes: 1792
/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n,m;
  cin >> n >> m;
  vector<int>s(m);
  vector<int>c(m);
  rep(i,m) cin >> s.at(i) >> c.at(i);
  vector<int>a(m);
  vector<int>k(n);
  int flagA=0;
  int flagB=0;
  int flagX=0;
  
  for(int i=0;i<m-1;i++){
    for(int j=1+i;j<m;j++){
      if(s.at(i) == s.at(j) && c.at(i)!=c.at(j) )  flagB=1;
    }
  }

  for(int i=0;i<m;i++){
      k.at( s.at(i) - 1) = c.at(i);
    }
 
    if(n!=1)flagX=1;
  
  	if(flagX==1){
    for(int i=0;i<m;i++){
      if( s.at(i) == 1 && c.at(i) ==0) flagA=1;
	  }
    }
   
  if(flagA==1 || flagB==1) cout << "-1" <<endl;
  else if(flagX==0){
    for(int i=0;i<n;i++){
      cout << k.at(i);
    }
    cout << endl;
  }
  else{
    if(k.at(0)==0) k.at(0)=1;
    for(int i=0;i<n;i++){
      cout << k.at(i);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;

    if(n>=400 && n<600)
    {
        cout<<"8"<<endl;

    }
    else if(n>=600 && n<800)
    {
        cout<<"7"<<endl;

    }
    else if(n>=800 && n<1000)
    {
        cout<<"6"<<endl;

    }
    else if(n>=1000 && n<1200)
    {
        cout<<"5"<<endl;

    }
    else if(n>=1200 && n<1400)
    {
        cout<<"4"<<endl;

    }
    else if(n>=1400 && n<1600)
    {

         cout<<"3"<<endl;
    }
    else if(n>=1600 && n<1800)
    {

         cout<<"2"<<endl;
    }
    else if(n>=1800 && n<2000)
    {
         cout<<"1"<<endl;

    }




    return 0;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 10000;
ll fac[MAX], finv[MAX], inv[MAX];

//最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0){
        return(b);
    }
   else{
       return(gcd(b, a%b));
    }
}
//ax+by=gcd(a,b)を満たす(x,y)
ll extgcd(ll a,ll b,ll &x,ll &y){
    ll d=a;
    if(b==0){
      x=1,y=0;
    }
    else{
      d=extgcd(b,a%b,y,x);
      y-=(a/b)*x;
    }
    return d;
}
//最小公倍数
ll lcm(ll a,ll b){
   return a * b / gcd(a, b);
}

int main (){
  ll n,m,x=1,cnt=0;cin>>n>>m;
  vll a(n);
  bool ok=false;
  rep(i,0,n){
    cin>>a[i];
    ll c=0;
    x=lcm(x,a[i]/2);

    while(a[i]%2==0){
      a[i]/=2;
      if(i==0)cnt++;
      else {
        c++;
      }
    }
    if(i!=0&&c!=cnt){ok=true;break;}
  }

  if(ok){cout<<0<<endl;return 0;}
  ll ans=m/x;
  if(ans%2)ans=(ans+1)/2;
  else ans/=2;
  cout<<ans<<endl;
}

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

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s,t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	vector<vector<int>> dp(n,vector<int>(m));
	bool ok = false;
	for (int i=0; i<n; ++i){
		if (s[i] == t[0]) ok = true;
		if (ok) dp[i][0] = 1;
	}
	ok = false;
	for (int i=0; i<m; ++i){
		if (t[i] == s[0]) ok = true;
		if (ok) dp[0][i] = 1;
	}
	for (int i=1; i<n; ++i){
		for (int j=1; j<m; ++j){
			if (s[i] == t[j]){
				dp[i][j] = dp[i-1][j-1]+1;
			}
			else{
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
/*	for (int i=0; i<n; ++i){
		for (int j=0; j<m; ++j){
			cout << dp[i][j] << ' ';
		}
		cout << '\n';
	}
*///	cout << dp[n-1][m-1] << '\n'; // ok
	// backtrack
	int x = n-1, y = m-1;
	vector<char> ans;
	while (x != 0 or y != 0){
		if (x-1 >= 0 and y-1 >= 0 and s[x] == t[y]){
			ans.emplace_back(s[x]);
			x--; y--;
		}
		else if (x-1 >= 0 and dp[x-1][y] == dp[x][y]){
			x--;
		}
		else if (y-1 >= 0 and dp[x][y-1] == dp[x][y]){
			y--;
		}
		else break;
//		cout << x << ' ' << y << endl;
	}
	if (s[x] == t[y]) ans.emplace_back(s[x]);
	reverse(ans.begin(),ans.end());
	for (char c:ans) cout << c;
	return 0;
}

Measured memory_bytes: 73616
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
	long long h;
	int n;
	cin>>h>>n;
	// vector<long long> ar(n,0ll);
	for(int i=0;i<n;i++){
		long long a;
		cin>>a;
		h-=a;
	}
	if(h<=0)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int length = sc.nextInt();
        int index = sc.nextInt();
        String str = sc.next();
        String sa = str.substring(0,index-1);
        String sb = str.substring(index-1,index).toLowerCase();
        String scc = str.substring(index);
        System.out.println(sa + sb + scc);
    }
}

Measured memory_bytes: 22228
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

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

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		int m = fs.nextInt();
		
		int[] voteArr = fs.nextIntArr(n);
		int sumOfVote = Arrays.stream(voteArr).sum();
		int border = 0;
		if(sumOfVote % (4*m) == 0){
			border = sumOfVote / (4*m);
		}else{
			border = sumOfVote / (4*m) + 1;
		}
		
		Arrays.sort(voteArr);
		
		for(int i = 1; i <= m; i++){
			int value = voteArr[n-i];
			if(value < border){
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 26580
from collections import Counter
N, K = map(int, input().split())
A = Counter(list(map(int, input().split())))

A = sorted(dict(A).items(), key=lambda x:x[1])
ans = 0
if not len(A) <= K:
  n = len(A) - K
  ans = 0
  for i in range(n):
    ans += A[i][1]
print(ans)

Measured memory_bytes: 50068
s = input()
lenlis = []

for i in range(len(s)):
    cnt = 0
    j = 0
    while (s[i+j]=="A" or s[i+j]=="T" or s[i+j]=="G" or s[i+j]=="C"):
        cnt += 1
        j += 1
        if i+j>=len(s):
            break
    lenlis += [cnt]

print(max(lenlis))

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;

int main()
{

    int x;
    cin>>x;
    int64_t sum=0;
    sum+=x/500*1000;
    sum+=(x%500)/5*5;
    cout<<sum<<endl;
    return 0;
}

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

unordered_map<long long, long long> factorization(long long n)
{
	unordered_map<long long, long long> ret;
	for (long long i = 2; i <= ceil(sqrt(n)); i++)
	{
		while (n % i == 0)
		{
			n = n / i;
			ret[i] += 1;
		}
	}

	ret[n] += 1;

	return ret;
}

int main(void)
{
	long long N, P;
	cin >> N >> P;

	auto mp= factorization(P);

	long long gcd = 1;

	for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
			

		for(int i = 0;i< itr->second / N ;i++){
			gcd *= itr->first;
		}
	}
	cout << gcd;

	return 0;
}


Measured memory_bytes: 256
import copy
if __name__ == '__main__':
    N,K=list(map(int,input().split()))
    Jewelries_org=list(map(int,input().split()))
    ans=0
    upper=min(N,K)
    for a in range(upper+1):
        for b in range(upper-a+1):
            hand=[]
            Jewelries=copy.deepcopy(Jewelries_org)
            for i in range(a):
                hand.append(Jewelries.pop(0))
            for i in range(b):
                hand.append(Jewelries.pop(-1))
            hand.sort()
            for i in range(K-(a+b)):
                if hand.__len__()>0 and hand[0]<0:
                    hand.pop(0)
            s=sum(hand)
            if s>ans:
                ans=s
    print(ans)











Measured memory_bytes: 47208
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  string s;
  cin >> s;
  if(s[0] == s[2])cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
sx,sy,tx,ty = map(int,input().split())

ans = ''

ans += 'U' * (ty - sy)
ans += 'R' * (tx - sx)
ans += 'D' * (ty - sy)
ans += 'L' * (tx - sx)

ans += 'L'
ans += 'U' * (ty - sy + 1)
ans += 'R' * (tx - sx + 1)
ans += 'D'

ans += 'R'
ans += 'D' * (ty - sy + 1)
ans += 'L' * (tx - sx + 1)
ans += 'U'

print(ans)


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int h,w; cin >> h >> w;
  string s[50];
  for(int i = 0; i < h; ++i)cin >> s[i];
  string out[50];
  for(int i = 0; i < h; ++i){
    out[i] = s[i];
    for(int j = 0; j < w; ++j){
      if(s[i][j] == '#')continue;
      int cnt = 0;
      for(int k = -1; k <= 1; ++k){
	for(int l = -1; l <= 1; ++l){
	  auto [x,y] = make_pair(j + l,i + k);
	  if(x < 0 || y < 0 || x >= w || y >= h)continue;
	  cnt += s[y][x] == '#';
	}
      }      
      out[i][j] = '0' + cnt;
    }
  }
  for(int i = 0; i < h; ++i)cout << out[i] << endl;
  return 0;
}


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

using namespace std;

int main()
{
    //system("chcp 65001");

    int D;
    cin >> D;

    if(D == 25)
    {
        cout << "Christmas";
    }
    else if(D == 24)
    {
        cout << "Christmas Eve";
    }
    else if(D == 23)
    {
        cout << "Christmas Eve Eve";
    }
    else if(D == 22)
    {
        cout << "Christmas Eve Eve Eve";
    }

    //cout << N;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
using namespace std;
 
typedef unsigned long long ull;
const ull M=998244353;
const ull N=1000000007; 
const ull X=99431;
const ull Y=99487;
ull R;
ull L;
const int W=1000;
 
 
ull ModPow(ull x, ull n, ull mod) {
        ull ret = 1;
        for (; n > 0; n /= 2, x = (x * x) % mod)
            if ((n & 1) == 1) ret = (ret * x) % mod;
        return ret;
    }
 
ull has=0,vec=1;
ull has2=0,vec2=1;
 
int n;
string s;
unordered_map<ull,int> B[550];
long long ans;
inline void calc(char c, ull &u,ull &p,ull &v,ull &q){
	if(c=='+'){u+=p;v+=q;}
	else if(c=='-'){u+=M-p;v+=N-q;}
	else if(c=='>'){p=(p*X)%M;q=(q*Y)%N;}
	else {p=(p*R)%M;q=(q*L)%N;}
	if(u>=M)u-=M;
	if(v>=N)v-=N;
}
int main(){
	R=ModPow(X,M-2,M);
	L=ModPow(Y,N-2,N);
	cin>>n>>s;
    //n=250000;
    //s=string(n,'+');
	for(int i=0;i<n;i++)calc(s[i],has,vec,has2,vec2);
	for(int i=0;i<n;i++){
		if(i%W==0)continue;
		ull h=0,x=1,hh=0,y=1;
		for(int j=i;j<n;j++){
			if(j%W==0)break;
			calc(s[j],h,x,hh,y);
			if(h==has&&hh==has2)ans++;
		}
		ull nh = (has+M-h)%M;
		nh = nh * ModPow(x,M-2,M)%M;
		ull nh2 = (has2+N-hh)%N;
		nh2 = nh2 * ModPow(y,N-2,N)%N;
		B[i/W+1][nh*N+nh2]++;
	}
	for(int i=0;i<n;i+=W){
		ull h=0,x=1,hh=0,y=1;
		for(int j=i;j<n;j++){
			calc(s[j],h,x,hh,y);
			if(h==has&&hh==has2)ans++;
			auto it = B[i/W].find(h*N+hh);
			if(it!=B[i/W].end())ans+=it->second;
		}
	}
	
	cout<<ans;
 
 
}

Measured memory_bytes: 15356
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <functional>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)

#define huge 1000000007
typedef long long ll;
ll gcd(ll a, ll b);

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll D = 0;
	ll M = 0;
	//ll M = 0;
	ll a[200] = {};
	ll b[200] = {};
	ll v[3] = {};
	//ll *a, *b, *x;
	string S,T,U[52];
	ll count = 0;
	ll count2 = 0;
	ll sum = 0;
	//ll min = 100000;
	ll max = 0;
	ll smax = 0;
	ll max2 = 0;
	ll smax2 = 0;
	int tmax = 0;
	int tmax2 = 0;
	int flag = 0;
	char temp,head;
	//int is = 0;
	
	
	//char p;


	

	

	//cin >> S;
	
	//a = (ll *)malloc(M * sizeof(ll));
	//b = (ll *)malloc(M * sizeof(ll));
	//vector<pair<int,int>> ch(50);

	//vector<bool> flag(N);
	
	cin >> N >> M;
	cin >> S;
	cin >> T;
	
	if (S[0] != T[0]) {
		cout << -1 << endl;
		return 0;
	}

	A = gcd(N,M);
	sum = A;
	B = A / N;
	C = A / M;

	for (int i = 0, j = 0; i < N || j < M;i+= C,j+=B) {
		//cout << i << "," << j << endl;

		if (S[i] != T[j]) {
			sum = -1;
			break;
		}

	}

	cout << sum << endl;



	/*rep(i, 0, N) {
		cin >> c[i];
	}*/


	//x = (ll *)malloc((N+1) * sizeof(ll));
	//c = (ll *)malloc((N) * sizeof(ll));
	//cin >> D >> G;
	//vector<pair<int,int>> tr(M);
	//vector<pair<int,int>> qes(Q);
	//sort(c.begin(), c.end());
	
	//cout << c[2] - c[1] << endl;



	/*A = N / 1000;
	N %= 1000;
	B = N / 100;
	N %= 100;
	C = N / 10;
	N %= 10;
	D = N;*/
	


	return 0;

}

ll gcd(ll a, ll b) {
	ll x = a * b;

	/* 自然数 a > b を確認・入替 */
	if (a<b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}


	return x/b;
}



Measured memory_bytes: 512
#include<stdio.h>

int main() {
    int n, q, S[10000], T[500];
    int C = 0;

    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &S[i]);
    }

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

    for (int i = 0; i < q; ++i) {
        for (int j = 0; j < n; ++j) {
            if (T[i] == S[j]) {
                ++C;
                break;
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 2736
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define NUM 1000000007
#define MAX 100001
#define INF LLONG_MAX
ll dp[MAX][2];
void dfs(ll a, ll par, vector<ll> v[]){
    dp[a][0]=dp[a][1]=1;
    for(auto x : v[a]){
        if(x==par)
            continue;
        dfs(x,a,v);
        dp[a][0]=dp[a][0]*(dp[x][0]+dp[x][1])%NUM;
        dp[a][1]=dp[a][1]*dp[x][0]%NUM;
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,a,b;
    cin>>n;
    vector<ll> v[n+1];
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        a--;
        b--;
        v[a].pb(b);
        v[b].pb(a);
    }
    dfs(0,-1,v);
    cout<<(dp[0][0]%NUM+dp[0][1]%NUM)%NUM<<endl;
    return 0;
}


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

int main()
{
    int m, d;
    cin >> m >> d;
    int count = 0;
    rep(i, m) {
        rep(j, d) {
            int d10 = (j + 1) / 10;
            int d1 = (j + 1) % 10;
            if(d10 >= 2 && d1 >= 2) {
                if(i + 1 == d10 * d1) count++;
            } 
        }
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;

int main()
{
	int vals = 0;

	cin >> vals;
	int count = 0;
	while (cin >> vals)
	{
		int i = 2;
		for (; i*i <= vals; ++i)
		{
			if (vals % i == 0) break;
		}
		if (i * i > vals || vals == 2)  count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<long long> L(N);
    for (int i = 0; i < N; i++)
    {
        cin >> L[i];
    }
    sort(L.begin(), L.end());

    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])
                    ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3180
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9+7;



int main() {
  int n;
  int c[1000], s[1000], f[1000];
  int a[1000];
  
  cin >> n;
  for (int i = 1; i < n; i++)
    cin >> c[i] >> s[i] >> f[i];

  for (int i = 1; i < n; i++) {
    for (int j = i; j < n; j++) {
      if (i == j) a[i] = s[i] + c[i];
      else if (a[i] < s[j]) {
        a[i] = s[j];
        a[i] += c[j];
      } else {
        int t = a[i] % f[j];
        if (t==0) {
          a[i] += c[j];
        } else {
          t = f[j] - t;
          a[i] += t + c[j];
        }
      }
    }
    printf("%d\n", a[i]);
  }
    
  printf("0\n");
  
  
  return 0;
}


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

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

int H, W;
ll A[2005][2005];
ll MIN, MAX;
vector< vector<ll> > B[4];

bool check(ll val, ll idx){

	int max_j = 0;

	for (int i = 0;i < B[idx].size();i++){
		for (int j = 0;j < B[idx][i].size();j++){
			if(B[idx][i][j] < MAX-val)max_j = max(max_j,j+1);
		}
		for (int j = 0;j < B[idx][i].size();j++){
			if(B[idx][i][j] > MIN+val && j < max_j) return false;
		}
	}
	return true;
}

void rot(){
	for (int k = 1;k < 4;k++){
		vector< vector<ll> > tmp(B[k-1][0].size(), vector<ll>(B[k-1].size()));
		for (int i = 0;i < B[k-1].size();i++){
			for (int j = 0;j < B[k-1][0].size();j++){
				tmp[B[k-1][i].size()-1-j][i] = B[k-1][i][j];
			}
		}
		B[k] = tmp;
	}
}

bool search(ll val){
	
	for (int i = 0;i < 4;i++){
		if(check(val, i)) return true;
	}
	
	return false;
}

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

	cin >> H >> W;

	MIN = LLONG_MAX;
	MAX = -1;

	for (int i = 0;i < H;i++){
		for (int j = 0; j < W; j++){
			cin >> A[i][j];
			MIN = min(MIN, A[i][j]);
			MAX = max(MAX, A[i][j]);
		}
	}
	
	B[0].resize(H, vector<ll>(W));
	for (int i = 0;i < H;i++){
		for (int j = 0;j < W;j++){
			B[0][i][j] = A[i][j];
		}
	}

	rot();

	ll low = 0, high = MAX-MIN;

	while(low < high){
		ll mid = (low+high)/2;
		if(search(mid)) high = mid;
		else low = mid+1;
	}

	cout << low << endl;

	return 0;

}



Measured memory_bytes: 190664
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int c = 0;
		for(int i = 1; i <= n; i++) {
			int x = sc.nextInt();
			if(i % 2 == 1 && x % 2 == 1)
				c++;
		}
		pw.println(c);
		pw.flush();
	}

	public static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();
			return array;
		}

		public Integer[] nextIntegerArray(int n) throws IOException {
			Integer[] array = new Integer[n];
			for (int i = 0; i < n; i++)
				array[i] = new Integer(nextInt());
			return array;
		}

		public long[] nextLongArray(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();
			return array;
		}

		public double[] nextDoubleArray(int n) throws IOException {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		public static int[] shuffle(int[] a) {
			int n = a.length;
			Random rand = new Random();
			for (int i = 0; i < n; i++) {
				int tmpIdx = rand.nextInt(n);
				int tmp = a[i];
				a[i] = a[tmpIdx];
				a[tmpIdx] = tmp;
			}
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


Measured memory_bytes: 32888
#include <stdio.h>

int main(){
  int n,h,w;
  int i;
  int count=0;
  int h_temp,w_temp;
  
  scanf("%d %d %d",&n,&h,&w);
  
  for(i=0;i<n;i++){
    scanf("%d %d",&h_temp,&w_temp);
    if(h<=h_temp && w<=w_temp){
      count++;
    }
  }
  printf("%d",count);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define x real()
#define y imag()
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int n;
	cin >> n;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (i * j == n) {
				cout << "Yes\n";
				return 0;
			}
		}
	}
	cout << "No\n";
}



Measured memory_bytes: 256
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    string s;
    cin >> s;
    if (s[0]== '9' || s[1] == '9') cout << "Yes" << endl;
    else cout << "No" << endl;
    //cout << ans << endl;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

use std::cmp::min;

fn main() {
    let abc: Vec<u32> = read_vec();
    let a = abc[0];
    let b = abc[1];
    let c = abc[2];
    println!("{}", min(b / a, c));
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <new>
#include <sstream>
#include <complex>
#define BIT(nr) (1ULL << (nr))
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	
#define LL_HALFMAX 9223372036854775807 / 2	
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }

using namespace std;

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;

	// libalgo のものに追加、メンバを追加するだけなので互換性は崩さないはず、逆辺のG[e.dstの]インデックスを保持
	int rev;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
	bool operator<(const Edge& right) const {
		return dst < right.dst;
	}
};

using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph& g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph& g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

signed main() {
	int n;
	cin >> n;
	vector<int> dist(n + 1, -1);

	Graph G(n + 1);
	rep(i, n) {

		int u, k;
		cin >> u >> k;
		rep(j, k) {
			int v;
			cin >> v;
			add_arc(G, u, v);
		}
	}

	queue<int> q;
	q.push(1);
	dist[1] = 0;
	while (!q.empty())
	{
		int node = q.front();
		q.pop();
		for (Edge e : G[node]) {
			if (dist[e.dst] == -1) {
				dist[e.dst] = dist[e.src] + 1;
				q.push(e.dst);
			}
		}
	}

	REPS(i, n) {
		cout << i << " " << dist[i] << "\n";
	}

	return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

// #define MOD 1000000007;


long long func(long long n, long long s);

int main(void)
{
  long long S,nmax;
  long long ans,mod;
  mod = 1000000007;
  cin >> S;
  nmax = (S / 3);
  vector<vector<long long>> dp(700,vector<long long>(2001));
  for (int s=0;s<S+1;s++)
  {
    for(int n=0;n<nmax+1;n++)
    {
      if (n==0) dp.at(n).at(s) = 0;
      if (s == 0) dp.at(n).at(s) = 1;
      if (n!= 0 && s!=0) dp.at(n).at(s) = (dp.at(n-1).at(s) + dp.at(n).at(s-1)) % mod;
    }
  }

  ans = 0;
  long long n=nmax;
  while(n > 0)
  {
    ans = (ans + dp[n][S-3*n]) % mod;
    n--;
  }
  cout << ans << endl;;
  return 0;
}


long long func(long long n, long long s)
{

}


Measured memory_bytes: 14312
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ll n,m,k;
  while(cin>>n>>m>>k,n||m||k) {
    ll dp[n+1][n*m+1]; CLR(dp);
    dp[0][0] = 1;
    FOR(i,0,n) {
      FOR(j,0,m*i+1) {
        FOR(t,1,m+1) {
          dp[i+1][j+t] += dp[i][j];
        }
      }
    }
    double ans = 0;
    ll waru = pow(m, n);
    FOR(i,0,n*m+1) {
      ans += (double)dp[n][i] * max(1LL, i-k) / waru;
    }
    printf("%.10lf\n", ans);
  }
}

Measured memory_bytes: 3484
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

n=I()
beki=[]
for k in range(2,11):
    for i in range(1,100):
        if i**k<=n:
            beki.append(i**k)
print(max(beki))

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

int main(){
    string s;
    cin >> s;
    // int a=s.size(), z=0;
    // bool f = false;
    // rep(i, s.size()){
    //     if(!f && s[i]=='A'){
    //         a = i;
    //         f = true;
    //     }
    //     if(s[i]=='Z'){
    //         z = max(z, i);
    //     }
    // }
    // printf("%d\n", z-a+1);

    cout << s.rfind("Z") - s.find("A") +1 << endl; 
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
  long long n, a, b;
  scanf("%lld%lld%lld", &n, &a, &b);
  if (a > b) {
    printf("0\n");
    return 0;
  }
  if (n == 1 && a != b) {
    printf("0\n");
    return 0;
  }
  long long minsum = (n - 1) * a + b;
  long long maxsum = (n - 1) * b + a;
  printf("%lld\n", maxsum - minsum + 1);
  return 0;
}

Measured memory_bytes: 128
if __name__ == "__main__":
    n = int(input())
    items = []  # type: ignore

    for _ in range(n):
        v, w, t, d, s = input().split()
        v, w, d = map(lambda x: int(x), [v, w, d])  # type: ignore
        items.append((v, w, t, d, s))

    items = sorted(items, key=lambda x: (x[0], x[1], x[2], x[3], x[4]))

    for elem in items:
        print(f"{elem[0]} {elem[1]} {elem[2]} {elem[3]} {elem[4]}")



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

using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    ll n, m;
    cin >> n >> m;
    vector<int> a(n + 1);
    ll sum = 0;
    for (int i = 1; i <= m; i++)
    {
        ll t;
        cin >> t;
        sum += t;
    }
    if (n >= sum)
        cout << n - sum << "\n";
    else
        cout << -1 << "\n";
    return 0;
}

Measured memory_bytes: 7164
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	string S;
	cin >> S;
	int cnt = 0;

	for (int i = 1; i < S.size(); i++) {
		if (S.at(i) != S.at(i - 1)) cnt++;
	}

	cout << cnt << endl;

	return 0;
}

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

using namespace std;
using ll = long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
constexpr int MOD = mod;
constexpr ll inf = 1e9+5;
const int MAX=510000;
int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    int n;
    cin>>n;
    vector<ll> a(n);
    map<ll,int> m;
    for(auto & b : a) cin>>b,m[b]++;
    vector<ll> v;
    v.push_back(0);
    for(int i=0;i<n;++i){
        if(a[v.back()] < a[i]) v.push_back(i);
    }
    vector<ll> ret(n);
    for(int i=v.size()-2;i>=0;i--){
        while(m.rbegin() -> first > a[v[i]]){
            auto e = *m.rbegin();
            m.erase(e.first);
            ret[v[i+1]] += 1LL*(e.first - a[v[i]])*e.second;
            m[a[v[i]]] += e.second;
        }
    }
    for(auto e : m)ret[0] += 1LL*e.first * e.second;
    for(auto r : ret) cout << r << endl;
    return 0;
}



Measured memory_bytes: 9848
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
constexpr long long int NINF = std::numeric_limits<long long int>::min();
#define int long long int

#define LIM 100010

vector<vector<int>> to;

void dist(vector<int> &v, int start) {
  queue<int> q;
  q.push(start);
  v[start] = 0;

  while (!q.empty()) {
    int n = q.front();
    q.pop();

    int l = v[n];
    for (int i : to[n]) {
      if (v[i] == -1) {
        v[i] = l + 1;
        q.push(i);
      }
    }
  }
}

void solve() {
  int N;
  cin >> N;
  vector<int> sunuke(N + 1);
  vector<int> fe(N + 1);
  to.resize(N + 1);

  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;

    to[a].push_back(b);
    to[b].push_back(a);
  }

  fill(sunuke.begin(), sunuke.end(), -1);
  fill(fe.begin(), fe.end(), -1);

  dist(sunuke, 1);
  dist(fe, N);

  int n_snu = 0;
  int n_fe = 0;
  for (int i = 1; i <= N; i++) {
    if (fe[i] >= sunuke[i]) {
      n_fe++;
    } else {
      n_snu++;
    }
  }

  if (n_fe > n_snu) {
    cout << "Fennec" << endl;
  } else {
    cout << "Snuke" << endl;
  }
}

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


Measured memory_bytes: 7936
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    cout << (n+1)/2;

    return 0;
}

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF ((1LL<<62)-1)
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME ((1ll<<61)-1)

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

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

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

bool isout(int h, int w, int H, int W) {
	return ( h<0 || h>=H || w<0 || w>=W );
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int N;

void input() {
	cin>>N;
}

void solve() {
	cout<<"ABC"<<setfill('0')<<right<<setw(3)<<N<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	int a, b, c;
	cin >> a >> b >> c;
	if((a == b && a != c) || (a == c && a != b) || (a != b && b == c)){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

const int N = 200100;
int n, a[N], ans;
map <int, int> m;

int main() {
	ios_base::sync_with_stdio(false);

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

	sort(a + 1, a  + n + 1);

	for(int i = n; i > 0; i--) {
		if(m[a[i]] == 0) continue;
		m[a[i]]--;
		// dbg(i, m);

		for(int j = 30; j >= 0; j--) {
			int p2 = (1 << j);
			if(p2 < a[i]) break;
			if(m.count(p2 - a[i]) && m[p2 - a[i]] > 0) {
				ans++;
				// dbg(a[i], p2);
				m[p2 - a[i]]--;
			}
		}
	}
	cout << ans << '\n';
}	

	

Measured memory_bytes: 11004
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
using namespace std;
int main(){
    int n, h, w;
    cin >> n >> h >> w;
    vector<vector<int>> a(1100, vector<int>(2));
    for(int i = 0; i < n; i++) cin >> a.at(i).at(0) >> a.at(i).at(1);

    int count = 0;
    for(int i = 0; i < n; i++){
        if(a.at(i).at(0) >= h && a.at(i).at(1) >= w) count++;
    }

    cout << count << endl;
}


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

int main() {
    int T[50000];
    int coin[20];
    int n;
    int m;
    int INF = 99999;

    cin >> n >> m;

    for (int i = 0; i < m; i++)
        cin >> coin[i];

    for (int j = 0; j <= n; j++)
        T[j] = INF;

    T[0] = 0;


    for (int i = 0; i <= n; i++){
        T[i] = i;
    }

    //for (int i = 0; i <= n; i++){
    //    T[0][i] = 0;
    //}

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

    //cout << "---------------------------------------" << endl;

    for (int i = 2; i <= m; i++){
       for (int j = 1; j <= n; j++){
           if (j-coin[i-1] < 0) T[j] = T[j];
           else {T[j] = min(T[j], T[j-coin[i-1]] + 1);}
      }
    }

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

    cout << T[n] << endl;
    return 0;
}

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

def calc_digits_sum(n):
    return sum([int(i) for i in list(str(n))])

ans = float('inf')
for i in range(1, N):
    A = i
    B = N - i
    # print(A, B)
    a_sum = calc_digits_sum(A)
    b_sum = calc_digits_sum(B)
    # print(a_sum, b_sum)
    ans = min(ans, a_sum + b_sum)
    
print(ans)

Measured memory_bytes: 43752
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        List<Integer> list = new ArrayList<>();
        for(int i = min(a, b); i > 0; i--) {
            if(a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        System.out.println(list.get(k-1));
    }
    
    public static int min(int a, int b) {
        if(a <= b) {
            return a;
        }else {
            return b;
        }
    }
}


Measured memory_bytes: 23764
// ※※※ 解答不能 ※※※
// ksun48氏.
// https://atcoder.jp/contests/cf17-final/submissions/1804620
#include <bits/stdc++.h>
using namespace std;
#define repx(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)

int dp[42][42][42][42];
// x1, x2, y1, y2

int psums[41][41];

int q(int a1, int a2, int b1, int b2){
    return psums[a2][b2] - psums[a1][b2] - psums[a2][b1] + psums[a1][b1];
}
int main(){
    int h, w;
    scanf("%d %d", &h, &w);
    string g[h];
    rep(i, h){
        char c[50];
        scanf("%s", c);
        g[i] = c;
    }
    int px, py;
    rep(i, h){
        rep(j, w){
            if(g[i][j] == 'P'){
                g[i][j] = '+';
                px = i;
                py = j;
            }
        }
    }
    rep(i, h + 1){
        rep(j, w + 1){
            psums[i][j] = 0;
            if(i == 0 || j == 0) continue;
            psums[i][j] = psums[i][j - 1] + psums[i - 1][j] - psums[i - 1][j - 1];
            if(g[i - 1][j - 1] == '#') psums[i][j]++;
        }
    }
    
    repr(a1, h, 0){
        repx(a2, a1, h + 1){
            repr(b1, w, 0){
                repx(b2, b1, w + 1){
                    dp[a1][a2][b1][b2] = 1000000;
                    int k = 1000000;
                    repx(am, a1, a2 + 1){
                        repx(bm, b1, b2 + 1){
                            int al = a1;
                            int ar = a2;
                            int bl = b1;
                            int br = b2;
                            if(px >= am) al = am;
                            if(px < am)  ar = am;
                            if(py >= bm) bl = bm;
                            if(py < bm)  br = bm;
                            k = min(k, q(al, ar, bl, br));
                            int ans2 = dp[al][ar][bl][br];
                            ans2 += q(al, ar, b1 + bm - bl, bm + b2 - br);
                            ans2 += q(a1 + am - al, am + a2 - ar, bl, br);
                            k = min(k, ans2);
                        }
                    }
                    dp[a1][a2][b1][b2] = min(dp[a1][a2][b1][b2], k);
                }
            }
        }
    }
    printf("%d\n", dp[0][h][0][w]);
    return 0;
}

Measured memory_bytes: 10496
import sys
from collections import Counter

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

mod = 10 ** 9 + 7

n = ni()
aaa = na()
c = Counter(aaa)
ct = 0
ans = 0
if n % 2 == 0:
    for k, v in c.items():
        if k % 2 != 1:
            ct = 0
            break
        if v == 2:
            ct += 1
        else:
            ct = 0
            break
else:
    for k, v in c.items():
        if k % 2 != 0:
            ct = 0
            break
        if k == 0:
            if v != 1:
                ct = 0
                break
        elif v == 2:
            ct += 1
        else:
            ct = 0
            break
if n == 1 and aaa[0] == 0:
    print(1)
elif ct == 0:
    print(0)
else:
    ans = 2 ** ct
    print(ans % mod)




Measured memory_bytes: 14748
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int sum;
	int count;
	
	while (scanf("%d %d", &a, &b) != EOF){
		count = 0;
		sum = a + b;
		do {
			sum /= 10;
			count++;
		}while (sum != 0);
		
		printf("%d\n", count);
	}
	return (0);
}

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

int extras = 0;
set<int> there, not_there;

int main(){
    for(int i = 0; i < 8; ++i) not_there.insert(i);
    int n;
    cin >> n;
    for(int i = 0, x; i < n; ++i){
        cin >> x;
        x /= 400;
        if(x >= 8) ++extras;
        else there.insert(x), not_there.erase(x); }
    cout << max<int>(there.size(), 1) << ' ' <<
        (there.size() + extras) << endl;
    return 0; }


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

int main()
{
  int H, W;
  cin >> H >> W;
  char c;
  vector<vector<int>> G(H + 2, vector<int>(W + 2, 0));
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cin >> c;
      if (c == '#')
        G[i + 1][j + 1] = 9;
    }
  }
  int dh[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
  int dw[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
  for (int i = 1; i <= H; i++)
  {
    for (int j = 1; j <= W; j++)
    {
      if (G[i][j] == 9)
      {
        cout << '#';
        continue;
      }
      int tmp = 0;
      for (int k = 0; k < 8; k++)
        tmp += (G[i + dh[k]][j + dw[k]] == 9);
      cout << tmp;
    }
    cout << endl;
  }
}

Measured memory_bytes: 3632