akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();
        long[] buc = new long[100005];
        for(int i=1;i<=N;i++){
            int a = sc.nextInt();
            long b = sc.nextLong();
            buc[a] += b;
        }
        long cnt = 0;
        int ans = 0;
        for(int i=1;i<=100000;i++){
            cnt += buc[i];
            if(cnt>=K){
                ans = i;
                break;
            }
        }
        System.out.println(ans);
    }
}
 

Measured memory_bytes: 64528
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final int K = sc.nextInt();
		long ans = 0;
		
		for(int b = 1; b <= N; b++) {
			int temp = b - K > 0 ? b - K : 0;
			ans += (N / b) * temp;
			ans += (N % b) - K + 1 > 0 ? (N % b) - K + 1 : 0;
		}
		if(K == 0) ans -= N;
		System.out.println(ans);
	}
}


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

using namespace std;

char s[100005];

int main()
{
	int n;
	scanf("%d", &n);
	scanf("%s", s + 1);
	int Ans = 0;
	for (int i = 1 ; i <= n ; ++ i)
	 if (s[i] ^ s[i - 1])
	  ++ Ans;
	cout << Ans << endl;
    return 0;
}

Measured memory_bytes: 384
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {
  ll A,B ,K;
  cin >> A >> B >> K;
  if(A < K){
    if(B-K+A >= 0){
      cout << 0 << " " << B-K+A <<endl;
    }else{
      cout << 0 << " " << 0 <<endl;
    }
  }else{
    cout << A-K << " " << B << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String aStr = sc.next();
		String bStr = sc.next();
		String cStr = sc.next();
		int a = Integer.parseInt(aStr);
		int b = Integer.parseInt(bStr);
		int c = Integer.parseInt(cStr);
		if(a < b && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}
}

Measured memory_bytes: 26104
#include <bits/stdc++.h>
using namespace std;
string  st;
int ans;
bool flag = true;
int main()
{
    cin >> st;
    int L=0,R = st.size() - 1;
    while ( L <= R )
    {
        if ( st[L] == st[R] ) 
        {
            L++;
            R--;
            continue;
            
        }
        if ( st[L] == 'x' ) 
        {
            L++;
            ans++;
            continue;
            
        }
        if ( st[R] == 'x' ) 
        {
            R--;
            ans++;
            continue;
            
        }
        flag = false; break;
    }
    ans = flag ? ans : -1;  
    cout << ans ; 
    return(0);  
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

//=============modpow============================
ll modpow(ll a, ll n, ll mod)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//=================================================

//=============modinv============================
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
//=================================================

int main() {
  ll mod = 998244353;
  ll two_inv = modinv(2, mod);
  ll N, S;
  cin >> N >> S;
  vector<ll> A(N);
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
  }
  vector<ll> dp(S + 1);
  dp.at(0) = modpow(2, N, mod);
  for (ll i = 0; i < N; ++i) {
    vector<ll> temp = dp;
    ll a = A.at(i);
    for (ll i = 0; i <= S - a; ++i) {
      dp.at(i + a) += (temp.at(i) * two_inv) % mod;
      dp.at(i + a) %= mod;
    }
  }
  cout << dp.at(S) << "\n";
}


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

int main()
{
	string s[1001],len_max,ans;
	map<string,int> count;
	int i = 0,count_max = 1;
	while(cin >> s[i])
	{
		if(len_max.size() < s[i].size())
		{
			len_max = s[i];		
		};
		count[s[i]]++;

		if(count[s[i]] > count_max)
		{
			count_max = count[s[i]];
			ans = s[i];
		}
		i++;
	}

	cout << ans <<  " " << len_max << endl;

	return 0;
}

Measured memory_bytes: 1208
#include <iostream>

using namespace std;

int main(){
  long long n;
  std::cin >> n;

  long long ans = 0;
  for(int i = 1; i <= n; i++){
    if(i % 15 == 0){

    }else if(i % 5 == 0){

    }else if(i % 3 == 0){

    }else{
      ans += i;
    }
  }

  std::cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3164
n, k = map(int, input().split())

ans = 0
for i in range(1, n+1):
    #print(i, n-(n//i)*i - k )
    ans += max(0, n//i * (i-k))
    ans += max((n-(n//i)*i) - k + 1, 0)

if k == 0:
    print(n*n)
else:
    print(ans)


Measured memory_bytes: 2940
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by sotetsuk on 2015/07/14.
 */
public class Main {
    public static final int MAX_H = 1005;
    public static final int MAX_W = 1005;
    public static final int MAX_N = 15;
    public static int H, W, N;
    public static char[][] grid = new char[MAX_H][MAX_W];
    public static int[][] d = new int[MAX_H][MAX_W];
    public static Pair[] pos = new Pair[MAX_N];

    public static int[] dx = {-1, 0, 1, 0};
    public static int[] dy = {0, -1, 0, 1};

    public static class Pair {
        int first, second;
        public Pair(int first, int second) {
            this.first = first;
            this.second = second;
        }
    }

    public static void read() {
        Scanner sc = new Scanner(System.in);
        H = sc.nextInt(); W = sc.nextInt(); N = sc.nextInt();

        for(int i = 0; i < H; i++) {
            grid[i] = sc.next().toCharArray();
        }

        for(int i = 0; i < H; i++) {
            for(int j = 0; j < W; j++) {
                if(grid[i][j] == 'S') {
                    pos[0] = new Pair(i, j);
                }
                if('0' <= grid[i][j] && grid[i][j] <= '9') {
                    int k = Integer.valueOf(String.valueOf(grid[i][j]));
                    pos[k] = new Pair(i, j);
                }
            }
        }
    }

    public static int bfs(Pair start, Pair goal) {
        // fill 2-d array d by -1
        for(int[] arr: d) Arrays.fill(arr, -1);
        // This deque is used as queue for bfs
        ArrayDeque<Pair> q = new ArrayDeque<Pair>();
        q.add(start);
        d[start.first][start.second] = 0;
        while(!q.isEmpty()) {
            Pair now = q.pop();
            int nowX = now.first; int nowY = now.second;
            // stopping condition
            if(nowX == goal.first && nowY == goal.second) {
                return d[nowX][nowY];
            }
            // search 4 destination
            for(int i = 0; i < 4; i++) {
                Pair next = new Pair(nowX + dx[i], nowY + dy[i]);
                int nextX = next.first; int nextY = next.second;
                if(0 <= nextX && nextX < H && 0 <= nextY && nextY < W
                        && grid[nextX][nextY] != 'X' && d[nextX][nextY] == -1) {
                    q.add(next);
                    d[nextX][nextY] = d[nowX][nowY] + 1;
                }
            }
        }

        return -1; // something is wrong
    }

    public static void main(String[] args) {
            int ans = 0;
            read();
            for(int i = 0; i < N; i++) {
                ans += bfs(pos[i], pos[i + 1]);
            }
            System.out.println(ans);
    }

}

Measured memory_bytes: 104100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N;
int a[105];
int cnt[105];
int r=0;
void fail(){
	cout << "Impossible" << endl;
	exit(0);
	return;
}
int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> a[i];
		r = max(r,a[i]);
	}
	if(r&1){
		for(int i=0;i<N;i++){
			a[i]=a[i]*2-r;
			if(a[i]<0)fail();
			cnt[a[i]]++;
		}
		if(cnt[1]!=2)fail();
		for(int i=3;i<=r;i+=2){
			if(cnt[i]<2)fail();
		}
		cout << "Possible" << endl;
	}else{
		r/=2;
		for(int i=0;i<N;i++){
			a[i]-=r;
			if(a[i]<0)fail();
			cnt[a[i]]++;
		}
		if(cnt[0]!=1)fail();
		for(int i=1;i<=r;i++){
			if(cnt[i]<2)fail();
		}
		cout << "Possible" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int maxn=200005;
using namespace std;
int a[maxn],b[maxn];
int main()
{
    int n,i,x,y;
   scanf("%d",&n);
   for(i = 1;i<=n;i++)
    scanf("%d",&a[i]),b[i]=a[i];
   sort(b+1,b+1+n);
   x=b[n/2];
   y=b[n/2+1];
   for(i = 1;i<=n;i++)
   {
       if(a[i]>x||a[i]==y) printf("%d\n",x);
       else if(a[i]<y||a[i]==x) printf("%d\n",y);

   }
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	while(1){
		int n;
		cin >> n;
		if(n==0) return 0;
		V<V<int>> c(5001,V<int>(5001,0));
		V<int> x(n),y(n);
		REP(i,n) cin >> x[i] >> y[i];
		REP(i,n) c[x[i]][y[i]]++;
		int ans = 0;
		for(int i = 0; i < n; ++i) for(int j = 0; j < n; ++j) if(i!=j){
			int ux = x[j]-x[i], uy = y[j] - y[i];
			int vx = uy, vy = -ux;
			int flg1 = 0,flg2 = 0;
			if(0 <= x[i]+vx && x[i]+vx <= 5000 && 0 <= y[i]+vy && y[i]+vy <= 5000 && c[x[i]+vx][y[i]+vy]) flg1 = 1;
			if(0 <= x[i]+vx+ux && x[i]+vx+ux <= 5000 && 0 <= y[i]+uy+vy && y[i]+uy+vy <= 5000 && c[x[i]+ux+vx][y[i]+uy+vy]) flg2 = 1;
			if(flg1&&flg2) chmax(ans,ux*ux+uy*uy);
		}
		cout << ans << endl;		
	}

	return 0;
}



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

int main() {
    int N;
    cin >> N;
    int p=0, w=0, g=0, y=0;
    string s;

    for (int i=0; i<N; i++) {
        cin >> s;
        if (s=="P") p=1;
        if (s=="W") w=1;
        if (s=="G") g=1;
        if (s=="Y") y=1;
    }

    if (p+w+g+y == 4) {
        cout << "Four" << endl;
    } else if (p+w+g+y == 3) {
        cout << "Three" << endl;
    }
}


Measured memory_bytes: 3608
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include<iomanip>
using namespace std;

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

int main()
{
   int N;
   string S,T,U;
   cin>>N;
   cin>>S>>T;
   for(int i=0;i<N;i++)
   {
       U.push_back(S[i]);
       U.push_back(T[i]);
   }
   cout<<U<<endl;
}

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

using namespace std;

int main()
{ 
  string s;
  cin >> s;
  for(int i=0; i < s.length(); i++){
    if(s[i] == ',')
      cout << ' ';
    else
      cout << s[i];
  }
  cout << endl;
  return 0;
}


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


int num(int n,int pq[]){
  int count;
  int sum=0;
  for(int i=0;i<n-1;i++){
    count=0;
    for(int j=i;j<n;j++){
      if(pq[i] > pq[j]){
	count++;}}
    sum+=count;
    sum*=n-i-1;}

  return sum;
}

int main(){
  int n;
  int p[9];
  int q[9];
  int ans=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&p[i]);}
  for(int i=0;i<n;i++){
    scanf("%d",&q[i]);}
  
  int plen=num(n,p);
  int qlen=num(n,q);

  printf("%d\n",abs(plen-qlen));

  return 0;
}
  

  


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#include<functional>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;

int main(){
	ll n, m; cin >> n >> m;
	vb island(n,false);
	vvl root(n);
	rep(i, m){
		ll a, b; cin >> a >> b;
		root[a - 1].push_back(b - 1);
		root[b - 1].push_back(a - 1);
	}
	island[0] = true;
	queue<ll> q;
	q.push(0);
	bool isBreak = false;
	rep(i, 2){
		isBreak = false;
		queue<ll> next;
		while (1){
			ll index = q.front();
			q.pop();
			if (q.empty()) isBreak = true;
			for (ll temp : root[index]) if (!island[temp]) {
				island[temp] = true;
				next.push(temp);
			}if (isBreak) break;
		}q = next;
	}cout << (island[n - 1] ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return 0;
}

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

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    vector<int> v(5, 0);
    for(int i = 0; i < n; i++) {
        string s; cin >> s;
        if(s[0] == 'M') v[0]++;
        if(s[0] == 'A') v[1]++;
        if(s[0] == 'R') v[2]++;
        if(s[0] == 'C') v[3]++;
        if(s[0] == 'H') v[4]++;
    }

    int ans = 0;
    for(int i = 0; i < (1 << 5); i++) {
        if(__builtin_popcount(i) == 3) {
            int tmp = 1;
            for(int j = 0; j < 5; j++) {
                if(i & (1 << j)) tmp *= v[j];
            }
            ans += tmp;
        }
    }

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


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

int main(){
  string S;
  cin >> S;
  string T = "ATCG";
  int ans = 0;
  int now = 0;
  for(int i = 0; i < S.size(); i++){
    bool isATCG = false;
    for(int j = 0; j < T.size(); j++){
      if(S[i] == T[j]){
        isATCG = true;
      }
    }
    if(isATCG){
      now++;
    }
    else{
      now = 0;
    }
    ans = max(ans,now);
  }
   
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int N = in.i();
        int[] X = in.ii();
        int sum = 0;
        int sum2 = 0;
        for(int i = 0; i < X.length; i++){
            int xi = X[i];
            sum += xi;
            sum2 += xi*xi;
        }
        int y = sum % N * 2 < N ? sum / N : sum / N + 1;
        int ans = y * (N * y - 2 * sum) + sum2;
        out.println(ans);
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


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

int main() {
  int n;
  std::cin >> n;
  std::vector<int> as;
  for (int i = 0; i < n; ++i) {
    int a;
    std::cin >> a;
    as.push_back(a);
  }
  std::sort(as.begin(), as.end());
  int max = as[as.size()-1];
  int idx = as.size()/2-1;
  int best_i = idx;
  int gap = max;
  while(idx >= 0 && idx < as.size() - 1) {
    if (gap <= std::abs(max - as[idx] * 2))
      break;
    gap = std::abs(max - as[idx] * 2);
    best_i = idx;
    if (max - as[idx] * 2 > 0)
      ++idx;
    else
      --idx;
  }
  std::cout << max << " " << as[best_i] << std::endl;
}


Measured memory_bytes: 892
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
int main(int argc, const char * argv[]) {
    int n,x,y;
    int ans[2001]={0};
    scanf("%d%d%d",&n,&x,&y);
    for(int i=1;i<n;i++){
        for(int j=i+1;j<=n;j++){
            if(j-i>abs(i-x)+abs(j-y)+1){
                ans[abs(i-x)+abs(j-y)+1]++;
            }else{
                ans[j-i]++;
            }
        }
    }
    for(int i=1;i<n;i++){
        printf("%d\n",ans[i]);
    }
    return 0;
}


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

AC = 0
WA = 0
TLE = 0
RE = 0

for _ in range(N):
    S = input()
    if S == 'AC':
        AC += 1
    elif S == 'WA':
        WA += 1
    elif S == 'TLE':
        TLE += 1
    else:
        RE += 1

print(f'AC x {AC}')
print(f'WA x {WA}')
print(f'TLE x {TLE}')
print(f'RE x {RE}')


Measured memory_bytes: 9184
#include <iostream>

using namespace std;

int main()
{
    int n;
    int fours = 0;
    int twos = 0;

    cin >> n;

    for (int i = 0; i < n; i++)
    {
        int64_t a;
        cin >> a;
        if (a % 4 == 0)
        {
            fours++;
        }
        else if (a % 2 == 0)
        {
            twos++;
        }
    }

    int ones = n - fours - twos;
    if ((twos == 0 && fours + 1 >= ones) || (twos > 0 && fours >= ones))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int width =0, height = 0;
	int x =0 , y =0 , r = 0;
	cin >> width >> height >> x >> y >> r;

	bool result = false;
	if (x - r >= 0 && x + r <= width) {
		if (y - r >= 0 && y + r <= height) {
			result = true;
		}
	}

	if (result) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main()
{
    cin>>a>>b;
    if (b<10)
    c=a*10+b;
    else if (b>=10 && b<100)
    c=a*100+b;
    else if (b>=100 && b<1000)
    c=a*1000+b;
    else c=a*10000+b;
    for (int i=1; i<=sqrt(c)+1; ++i)
    if (i*i==c)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
N, A, B = map( int, input().split())
H = [0]*N
hmax = 0
for i in range(N):
    h = int( input())
    H[i] = h
    hmax = max( h, hmax)

L = 0
R = hmax//B + 1
add = A-B
while L != R:
    now = (L+R)//2
    need = 0
    for i in range(N):
        if H[i] > now*B:
            need += (H[i]-1-now*B)//add + 1
    if need <= now:#うまくいくとき
        R = now
    else:#うまくいかないとき
        L = now+1#うまく行かないので+1している．これがないと無限ループが発生する。
print(L)

Measured memory_bytes: 51816
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
 
int myf(int x,int y){
    if(x==y) return y;
  	while(x!=y){
        if(y>x) swap(x,y);
        if(x%y==0) return y;
        x%=y;
    }
}

signed main(){
    int N;
    int ans=1e9+7;
    cin>>N;
    int A[N];
    REP(i,N){
        cin>>A[i];
    }
    REP(i,N-1){
        int d=myf(A[i],A[i+1]);
        ans=min(ans,d);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

X, Y = MAP()

money = [0]*206
money[1] = 3*10**5
money[2] = 2*10**5
money[3] = 10**5

ans = money[X] + money[Y]
if X == Y == 1:
	ans += 4*10**5

print(ans)

Measured memory_bytes: 5592
N = int(input())
S = input().rstrip()

ans = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            num = str(i) + str(j) + str(k)
            tmp = 0

            for s in S:
                if num[tmp] == s:
                    tmp += 1

                if tmp >= 3:
                    break

            if tmp == 3:
                ans += 1

print(ans)


Measured memory_bytes: 42460
/// In The Name Of God

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

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

const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;
#define int ll

int n;
int a[N];
int32_t main() {
	#ifdef wws
		freopen ("in.txt", "r", stdin);
	#endif
	Kazakhstan
	cin >> n;
	rep(i, 1, n) cin >> a[i];
	sort (a + 1, a + 1 + n, greater<int>());
	int p = 1;
	while (p + 1 <= a[p + 1]) p++;
	int x = a[p] - p, y = 0;
	rep(i, p + 1, n) {
		if (a[i] != p) break;
		y++;
	}
	if ((x | y) & 1) cout << "First";
	else cout << "Second";
	ioi
}


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

int pow_int(int x, int n){
  if(n == 0) return 1;

  int k = 1;
  while(n > 1){
    if(n%2 != 0){
      k *= x;
    }
    x *= x;
    n /= 2;
  }
  return k*x;
}

int calc_c(int i, int K){
  int l = -1, r = 20;
  while(l+1 < r){
    int med = (l+r)/2;
    if(i * pow_int(2, med) < K){
      l = med;
    }else{
      r = med;
    }
  }
  return r;
}

int main(void){
  int N, K; cin >> N >> K;
  double ans = 0.0;
  for(int i = 1; i <= N; i++){
    int c = calc_c(i, K);
    ans += 1.0/(double)N * pow(0.5, c);
  }
  cout << fixed << setprecision(12) << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


vector<int> V;

void check(int i){
    int t = i;
    int c7 = 0;
    int c5 = 0;
    int c3 = 0;
    while(t!=0){
        if(t%10 == 7) c7++;
        if(t%10 == 5) c5++;
        if(t%10 == 3) c3++;
        t/=10;
    }
    if(c7>0 && c5>0 && c3>0) V.push_back(i);
    return;
}

void dfs(ll i){
    if(i>1e9) return;
    check(i);
    dfs(i*10 + 3);
    dfs(i*10 + 5);
    dfs(i*10 + 7);
    return;
}

int main() {
    int N; cin >> N;
    dfs(0);
    int ans = 0;
    for(int v:V){
        if(v<=N) ans++;
    }
    
    cout << ans << endl;
    return 0;
}


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

int main(){
    long long h, w, ans;
    cin >> h >> w;

    if(h == 1 || w == 1) ans = 1;
    else if((h * w) % 2 == 0) ans = h * w / 2;
    else ans = h * w / 2 + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
@count = 0
def merge(l, r)
  result = []
  l_n = l.shift
  r_n = r.shift
  loop do
    break if [l_n, r_n].all?(&:nil?)
    @count += 1
    if l_n.nil?
      result << r_n
      r_n = r.shift
      next
    end
    if r_n.nil?
      result << l_n
      l_n = l.shift
      next
    end
    if l_n <= r_n
      result << l_n
      l_n = l.shift
    else
      result << r_n
      r_n = r.shift
    end
  end
  result
end

def merge_sort(arr)
  return arr if arr.length == 1

  mid = arr.length / 2 - 1
  merge(merge_sort(arr[0..mid]), merge_sort(arr[mid+1..-1]))
end

n = gets.to_i
arr = gets.split.map(&:to_i)
result = merge_sort(arr)
puts result.map(&:to_s).join(' ')
puts @count



Measured memory_bytes: 56540
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
const ll MOD = 1e9+7;

const int MAX = 200005;
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    int h,w,a,b; cin >> h >> w >> a >> b;
    ll ans = 0;
    COMinit();
    rep(i, h-a){
        ans += (COM(b-1+i, i) * COM(w-b+h-i-2, h-i-1)) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
//1 2 3 4 100 1
/*
a bあってbは一回使うと使えない
abまとめてソートする
大きい方から取っていくaが出るまで探索
aが出るまでの和でH超えるならそこで終わり
終わらなければaを使いまくる
Nは10^5  NlogNのソートが必要

*/

#define max 2147483647

typedef struct _atk{
    char tp;
    int dam;
}atk;

//降順そーと
void merge(atk *a,int left,int mid,int right){
    int n1 = mid-left,n2 = right-mid;
    atk *L = (atk*)malloc(sizeof(atk)*(n1+1)),*R = (atk*)malloc(sizeof(atk)*(n2+1));
    int i;
    for(i=0;i<n1;i++){
        L[i].tp = a[left+i].tp;
        L[i].dam = a[left+i].dam;
    }
    for(i=0;i<n2;i++){
        R[i].tp = a[mid+i].tp;
        R[i].dam = a[mid+i].dam;
    }
    L[n1].dam = -2147483648;
    R[n2].dam = -2147483648;
    int j=0,k=0;
    for(i = left;i<right;i++){
        if(L[j].dam>R[k].dam){
            a[i].dam = L[j].dam;
            a[i].tp = L[j].tp;
            j++;
        }else{
            a[i].dam = R[k].dam;
            a[i].tp = R[k].tp;
            k++;
        }
    }
}

void merge_sort(atk *a,int left,int right){
    int middle;
    if(left + 1 < right){
        middle = (left+right)/2;
        merge_sort(a,left,middle);
        merge_sort(a,middle,right);
        merge(a,left,middle,right);
    }
}


int main(void){
    int N,H;
    scanf("%d %d",&N,&H);
    atk *a = (atk*)malloc(sizeof(atk)*2*N);
    int i;
    for(i=0;i<2*N;i+=2){
        scanf("%d %d",&a[i].dam,&a[i+1].dam);
        a[i].tp = 'a';
        a[i+1].tp = 'b';
    }
    merge_sort(a,0,2*N);
    int first_a,flag = 1,total = 0;
    for(i=0;i<2*N;i++){
        if(a[i].tp == 'a'){
            first_a = i;
            break;
        }
        total += a[i].dam;
        if(total>=H){
            printf("%d\n",i+1);
            flag = 0;
            break;
        }
    }
    if(flag){
        if((H-total)%a[first_a].dam == 0){
        printf("%d\n",first_a + (H-total)/a[first_a].dam);
        }else{
            printf("%d\n",first_a + 1 +(H-total)/a[first_a].dam);
        }
    }

    return 0;
}

Measured memory_bytes: 37760
def manhattan(n, x_v, y_v)
  d = 0.0
  for i in 0..n.to_i-1 do
    d += (x_v[i].to_f - y_v[i].to_f).abs
  end
  d
end

def euc_i(n, x_v, y_v, p)
  d = 0.0
  for i in 0..n.to_i-1 do
    d += (x_v[i].to_f - y_v[i].to_f).abs ** p
  end
  d = d ** (1/p.to_f)
end

def chebshef(n, x_v, y_v)
  d = 0.0
  for i in 0..n.to_i-1 do
    c = (x_v[i].to_f - y_v[i].to_f).abs
    d > c ? d = d : d = c
  end
  d
end

n = STDIN.gets
x = STDIN.gets
y = STDIN.gets

if n.to_i < 1 and n.to_i > 100
   exit
end

x_v = x.split
y_v = y.split

puts sprintf("%.6f", manhattan(n, x_v, y_v))
puts sprintf("%.6f", euc_i(n, x_v, y_v, 2))
puts sprintf("%.6f", euc_i(n, x_v, y_v, 3))
puts sprintf("%.6f", chebshef(n, x_v, y_v))

Measured memory_bytes: 8876
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
using namespace std;
main(){
  int m,n;
  while(cin>>m>>n,n){
    int a1[n][n],a2[n][n],q,w,e,r;
    r(i,n)r(j,n){
      if(i==j)a2[i][j]=a1[i][j]=0;
      else a2[i][j]=a1[i][j]=INF;
    }
    while(m--){
      scanf("%d%d%d%d",&q,&w,&e,&r);q--;w--;
      a1[q][w]=a1[w][q]=e;
      a2[q][w]=a2[w][q]=r;
    }
    r(k,n)r(i,n)r(j,n){
      a1[i][j]=min(a1[i][j],a1[i][k]+a1[k][j]);
      a2[i][j]=min(a2[i][j],a2[i][k]+a2[k][j]);
    }
    cin>>e;
    while(e--){
      scanf("%d%d%d",&q,&w,&r);q--;w--;
      if(r)cout<<a2[q][w]<<endl;
      else cout<<a1[q][w]<<endl;
    }
  }
}

Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>

using namespace std;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int X,Y,Z;
	cin >> X >> Y >> Z;
	X = X - Z;
	int rslt = 0;
	rslt = X / (Y + Z);
	cout << rslt << endl;
	
}

Measured memory_bytes: 256
N = int(input())
Sa = 0
Sb = 0
Sab = 0
ans = 0
for i in range(N):
    t = input()
    if t[-1] == 'A' and t[0] == 'B': Sab += 1
    elif t[-1] == 'A': Sa += 1
    elif t[0] == 'B': Sb += 1
    ans += t.count('AB')
if Sab > 0:
    ans += Sab-1
    if Sa > 0 and Sb > 0:
        ans += 2
        Sa -= 1
        Sb -= 1
    elif Sa < Sb: Sa += 1
    else: Sb += 1
ans += min(Sa,Sb)
print(ans)

Measured memory_bytes: 3188
def fact(n):
    a = 1
    for i in range(1, n+1):
        a *= i
        a %= 1000000007
    return a

def main():
    N, M = [int(x) for x in input().split()]
    if N > M:
        N, M = M, N

    if N == M - 1:
        print((fact(N) * fact(M)) % 1000000007)
        return
    elif N == M:
        print((fact(N) * fact(M) * 2) % 1000000007)
    else:
        print(0)
    
main()


Measured memory_bytes: 3064
S = list(input())
mod = 10 ** 9 + 7
n = len(S)

dp = [[0] * 4 for _ in range(n)]
dp[-1][0] = 1
# dp[i文字目までの?を確定させた][i文字目までで文字をn個選んだ]

for i, s in enumerate(S):
    if s == '?':
        dp[i][0] = dp[i - 1][0] * 3 % mod
        dp[i][1] = (dp[i - 1][0] + dp[i - 1][1] * 3) % mod
        dp[i][2] = (dp[i - 1][1] + dp[i - 1][2] * 3) % mod
        dp[i][3] = (dp[i - 1][2] + dp[i - 1][3] * 3) % mod
    elif s == 'A':
        dp[i][0] = dp[i - 1][0]
        dp[i][1] = (dp[i - 1][1] + dp[i - 1][0]) % mod
        dp[i][2] = dp[i - 1][2]
        dp[i][3] = dp[i - 1][3]
    elif s == 'B':
        dp[i][0] = dp[i - 1][0]
        dp[i][1] = dp[i - 1][1]
        dp[i][2] = (dp[i - 1][1] + dp[i - 1][2]) % mod
        dp[i][3] = dp[i - 1][3]
    else:
        dp[i][0] = dp[i - 1][0]
        dp[i][1] = dp[i - 1][1]
        dp[i][2] = dp[i - 1][2]
        dp[i][3] = (dp[i - 1][3] + dp[i - 1][2]) % mod

print(dp[-1][-1])


Measured memory_bytes: 28204
#include <iostream>
#include <vector>
#include <cstdio>
#include <cmath>
#define EPS (1e-10)
using namespace std;

struct Point {
  double x;
  double y;

  Point(double x = 0.0, double y = 0.0) : x(x), y(y) {}

  Point operator + (Point p) { return Point(x + p.x, y + p.y); }
  Point operator - (Point p) { return Point(x - p.x, y - p.y); }
  Point operator * (double k) { return Point(k * x, k * y); }
  Point operator / (double k) { return Point(x / k, y / k); }

};
/*
double dot(Point p0, Point p1, Point p2) {
  return (p1.x - p0.x) * (p2.x - p0.x) + (p1.y - p0.y) * (p2.y - p0.y);
}
*/

double dot2(Point p0, Point p1) {
  return p0.x * p1.x + p0.y * p1.y; 
}

/*
double cross(Point p0, Point p1, Point p2) {
  return ( p1.x - p0.x ) * ( p2.y - p0.y ) - ( p2.x - p0.x) * (p1.y - p0.y);
}
*/

double cross2(Point p0, Point p1) {
  return p0.x * p1.y - p0.y * p1.x;
}

int isContained(vector<Point> polygon, Point p) {
  int n = polygon.size();
  bool flag = false;
  for(int i = 0; i < n; i++) {
    Point pre = polygon[i] - p; 
    Point next = polygon[ ( i + 1 ) % n ] - p;
    if(abs(cross2(pre, next)) < EPS && dot2(pre, next) < EPS)
      return 1;
    if(pre.y > next.y) 
      swap(pre, next);
    if(pre.y < EPS && next.y > EPS && cross2(pre, next) > EPS) 
      flag = !flag;
  }
  if(flag) 
    return 2;
  return 0;
}

int main(void) {
  int n;
  cin >> n;
  vector<Point> polygon;

  for(int i = 0; i < n; i++) {
    Point pi;
    cin >> pi.x >> pi.y;
    polygon.push_back(pi);
  }

  int q;
  cin >> q;
  for(int i = 0; i < q; i++) {
    Point p;
    cin >> p.x >> p.y;
    cout << isContained(polygon, p) << endl;
  }
    
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#define debug(x) cout << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
typedef long long ll;
const int MAXN=2e5+7;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;

map<int,int>mp;

ll quick(ll x,ll n)  //快速幂 x^n
{
    ll res=1;
    while(n)
    {
        if(n&1) res=(res*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return res;
}
int a[MAXN];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=1,x;i<=n;++i)
    {
        cin>>x;
        a[x]++;
    }
    bool ok=1;
    if(n%2==0)
    {
        for(int i=1;i<=n;i+=2)
        {
            if(a[i]!=2)
            {
                ok=0;break;
            }
        }
        if(ok) cout<<quick(2,n/2)<<endl;
        else cout<<0<<endl;
    }
    else
    {
        if(a[0]!=1) ok=0;
        for(int i=2;i<=n;i+=2)
        {
            if(a[i]!=2)
            {
                ok=0;break;
            }
        }
        if(ok) cout<<quick(2,n/2)<<endl;
        else cout<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
def main():
  N, M = list(map(int, input().split()))

  p1 = []
  p2 = []

  for _ in range(N):
    x, y = list(map(int, input().split()))
    p1.append([x, y])
  
  for _ in range(M):
    c, d = list(map(int, input().split()))
    p2.append([c, d])

  for p in p1:
    x1, y1 = p
    near = 10 ** 9
    ans = 0
    
    for i, q in enumerate(p2):
      x2, y2 = q
      d = abs(x1 - x2) + abs(y1 - y2)

      if near > d:
        near = d
        ans = i
    
    print(ans + 1)

if __name__ == "__main__":
  main()

Measured memory_bytes: 67864
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0: return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y: return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def count_member_nums(self):
        return [len(self.members(r)) for r in self.roots()]
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
#======================================================#

def main():
    n, m = MII()
    group = [MIIZ() for _ in range(m)]
    uf = UnionFind(n)
    for a, b in group:
        uf.union(a, b)
    print(abs(sorted(uf.parents)[0]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 49532
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<vector>
#include<string> 
#include<queue>
#include<algorithm>
using namespace std;
int main()
{
	char s[4];
	while(scanf("%s",s)!=EOF)
	{
		int sum=700;
		for(int i=0;i<3;i++)
		{
			if(s[i]=='o')sum+=100;
			else;
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 256
AB,BC,CA=map(int,input().split())

ab=pow(AB,2)
bc=pow(BC,2)
ca=pow(CA,2)

if ab+bc==ca:
    print(int(AB*BC/2))
elif bc+ca==ab:
    print(int(BC*CA/2))
else:
    print(int(AB*CA/2))

Measured memory_bytes: 3060
import Control.Monad (mapM_)
import Text.Printf (printf)

type Point = (Double, Double)

infixl 4 |+|
(|+|) :: Point -> Point -> Point
(|+|) (x,y) (z,w) = (x+z,y+w)

infixl 4 |-|
(|-|) :: Point -> Point -> Point
(|-|) (x,y) (z,w) = (x-z,y-w)

infixl 5 |*|
(|*|) :: Point -> Double -> Point
(|*|) (x,y) k = (k*x, k*y)

infixl 5 |/|
(|/|) :: Point -> Double -> Point
(|/|) (x,y) d = (x/d, y/d)

rot :: Point -> Double -> Point
rot (x,y) theta = (x*c-y*s, y*c+x*s) 
  where
    c = cos theta
    s = sin theta

norm :: Point -> Double
norm (x,y) = sqrt $ x*x+y*y

printPt :: Point -> IO ()
printPt (x,y) = printf "%.8f %.8f\n" x y

koch :: Int -> Point -> Point -> [Point]
koch 0 _ _ = []
koch n p1 p2 = koch (n-1) p1 s ++ [s] ++ koch (n-1) s u ++ [u] ++ koch (n-1) u t ++ [t] ++ koch (n-1) t p2
  where
    v = (p2|-|p1)|/|3
    s = p1 |+| v
    t = p1 |+| v|*|2
    u = p1 |+| v |+| rot v (pi/3)

main :: IO ()
main = do
  n <- readLn
  mapM_ printPt $ (0,0): koch n (0,0) (100,0) ++ [(100,0)]

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

using namespace std;

typedef long long int64;

int main()
{
  int64 A, B, N;
  cin >> A >> B >> N;
  int64 ret = numeric_limits< int64 >::max();
  for(int i = 1; i <= N; i++) {
    for(int j = 1; j <= N; j++) {
      if(B % j != 0) continue;
      ret = min(ret, std::abs(A - B / j * i));
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 3088
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main{

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		String line;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int[] cnt = new int[26];
		
		while ((line = br.readLine()) != null) {
			line = line.toLowerCase();
			for (char c : line.toCharArray()) {
				if ('a' <= c && c <= 'z') {
					cnt[c - 'a']++;
				}
			}
		}
		
		for (int i = 0; i < 26; i++) {
			System.out.println((char)('a' + i) + " : " + cnt[i]);
		}
	}

}

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

int main()
{
    int N;
    long long X;
    std::cin >> N >> X;

    std::vector<long long> height(1, 1), patty(1, 1);
    for(int i=1; i<=N; i++){
        height.push_back(2 * height.back() + 3);
        patty.push_back(2 * patty.back() + 1);
    }

    long long sum = 0;
    for(int i=N; i>=0; i--){
        if(i == 0) sum += 1;
        if(X == 1) break;
        else if(X < height[i-1]+2) X -= 1;
        else if(X == height[i-1]+2){
            sum += patty[i-1] + 1; break;
        }
        else if(X < height[i]){
            sum += patty[i-1] + 1; X -= height[i-1]+2;
        }
        else{
            sum += patty[i]; break;
        }
    }
    // for(int i=0; i<=N; i++){
    //     std::cout << "i = " << i << ", height = " << height[i] << ", patty = " << patty[i] << std::endl;
    // }
    std::cout << sum << std::endl;
}

Measured memory_bytes: 256
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


def lcm(a, b):
	return a * b // gcd (a, b)

A,B,C,D = map(int,input().split())
if A%C !=0:
  C_left = (A//C) + 1
else:
  C_left = (A//C)
C_right = (B//C)

if A%D !=0:
  D_left = (A//D) + 1
else:
  D_left = (A//D)
D_right = (B//D)
CD = lcm(C,D)
if A%(CD) !=0:
  CD_left = (A//(CD)) + 1
else:
  CD_left = (A//(CD))
CD_right = (B//(CD))

C_=C_right - C_left +1
D_=D_right - D_left +1
CD_=CD_right - CD_left +1
print(B-A+1-C_-D_+CD_)

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

int main() {
  string s;
  cin >> s;
  
  int count = 0;
  
  for( int i=0 ; i<3 ; i++ )
  {
    if( s[i] == '1' ) count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
class WeightedUnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)
        self.weights = [0] * (n + 1)  # 親への距離を管理

    def find(self, x):
        if self.parent[x] == x:
            return x
        nx = self.find(self.parent[x])
        self.weights[x] += self.weights[self.parent[x]]
        self.parent[x] = nx
        return nx

    def unite(self, x, y, d):
        rx = self.find(x)
        ry = self.find(y)
        if rx == ry:
            return
        if self.rank[rx] < self.rank[ry]:
            self.parent[rx] = ry
            self.weights[rx] = d + self.weights[y] - self.weights[x]
        else:
            self.parent[ry] = rx
            self.weights[ry] = - d + self.weights[x] - self.weights[y]
            if self.rank[rx] == self.rank[ry]:
                # rank等しい時はどちらを親にしても良いが，この場合は統合されたxのrankが1増加することに注意する
                self.rank[rx] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def diff(self, x, y):
        return self.weights[x] - self.weights[y]


def main():
    n, m = map(int, input().split())
    wuf = WeightedUnionFind(n)
    for _ in range(m):
        l, r, d = map(int, input().split())
        l -= 1
        r -= 1
        if not wuf.same(l, r):
            wuf.unite(l, r, d)
        else:
            if wuf.diff(l, r) != d:
                print("No")
                exit()
    print("Yes")


if __name__ == "__main__":
    main()

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

//macro-----------------------------------------------------------------------------------------
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i=a;i>b;i--)
#define int long long

//constant--------------------------------------------------------------------------------------
const int inf = 100100100100000;
const int mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//general_method--------------------------------------------------------------------------------
vector<int> cs(vector<int> arr){vector<int> ret = arr;rep(i,1,arr.size()){ret[i] += ret[i-1];}return ret;}
int ceil(int a, int b){if(a%b == 0) return a/b;else return a/b + 1;}
int digitlen(int i){int t = i;int count = 0;while(t){count += 1;t /= 10;}return count;}
int gcd(int m, int n){if((0== m)||(0 == n))return 0;while(m != n){if(m > n)m = m - n;else n = n - m;}return m;}
int lcm(int n, int m){return n*m/gcd(n,m);}

//io_method-------------------------------------------------------------------------------------
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
void print(int n){cout << n << endl;}
void print(vector<int> arr){cout << arr[0];rep(i,1,arr.size()) cout << " " << arr[i];cout << endl;}
void print(string s){cout << s << endl;}
void print(pair<int, int> p){cout << p.first << " " << p.second;}
void print(vector<vector<int>> arr){rep(i,0,arr.size()){print(arr[i]);}}
void print(double n){cout << n << endl;}

//main------------------------------------------------------------------------------------------


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

    string s = raw_input();

    cout << s[0] << s.size()-2 << s.back() << endl;
    
    
}

Measured memory_bytes: 256
from itertools import product

n = int(input())
l1 = []
for _ in range(n):
    l2 = []
    for _ in range(int(input())):
        l2.append(list(map(int, input().split())))
    l1.append(l2)

ans = 0
for k in product([1, 0], repeat=n):
    check = True
    for i, j in enumerate(l1):
        if k[i] == 0:
            continue
        for x in j:
            if k[x[0] - 1] != x[1]:
                check = False
    if check:
        ans = max(ans, sum(k))
print(ans)

Measured memory_bytes: 9096
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<pair<string, int>> a(n);
	vector<P> ans(n);
	rep(i, 0, n) {
		cin >> a[i].first >> a[i].second;
		a[i].second *= -1;
	}
	rep(i, 0, n) ans[i] = { a[i].second,i };
	sort(a.begin(), a.end());
	rep(i, 0, n) {
		int idx = -1;
		rep(j, 0, n) if (ans[j].first == a[i].second) idx = ans[j].second;
		printf("%d\n",idx+1);
	}
	return 0;
}


Measured memory_bytes: 256