akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #pragma comment(linker, "/stack:200000000")
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast")
  #pragma GCC optimize("unroll-loops")
    using namespace std;
  using namespace __gnu_pbds;
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define endl "\n"
    #define int long long
    #define all(v) v.begin(),v.end()
    #define rep(i,a,b) for(int i = a; i <=b; i++)
    #define rep2(i,a,b) for(int i = a; i>=b; i--)
    #define PB push_back
    #define MP make_pair
    #define db long double
    #define trace1(x)                cerr<<#x<<": "<<x<<endl
    #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
    #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
    #define trace3race4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
    #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
    #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
    #define cases int testcases;cin>>testcases; while(testcases--)
    #define INF 2000000000
    const double PI = acos(-1);
    const int N = 100005;


  int32_t main() 
  {
    IOS



       
      int ans = 0;
      int n;
      cin >> n;

      string s;
      cin >> s;

      for(int i = 0; i + 2< s.length(); i++)
      {
      	if(s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C')
      	{
      		i+=2;
      		ans++;
      	}
      }

      cout << ans;

    return 0;
      }

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

int caesar(string s)
{
	string s0 = "this";
	string s1 = "that";
	string s2 = "the";

	for (int i = 0; i < 26; i++)
	{
		if (s == s0 || s == s1 || s == s2 || s == s0 + "." || s == s1 + "." || s == s2 + ".")
		{
			return i;
		}
		for (int j = 0; j < 4; j++)
		{
			s0.at(j)++;
			if (s0.at(j) > 'z')
			{
				s0.at(j) = 'a';
			}
			s1.at(j)++;
			if (s1.at(j) > 'z')
			{
				s1.at(j) = 'a';
			}
		}
		for (int j = 0; j < 3; j++)
		{
			s2.at(j)++;
			if (s2.at(j) > 'z')
			{
				s2.at(j) = 'a';
			}
		}
	}

	return -1;
}

int main()
{
	string str;
	for (; getline(cin, str);)
	{
		stringstream ss;
		ss << str;

		vector<string> w;
		string s;
		int c = -1;
		for (; ss >> s;)
		{
			w.push_back(s);
			
			if (c == -1)
			{
				c = caesar(s);
			}
		}

		for (int i = 0; i < w.size(); i++)
		{
			if (c != -1)
			{
				for (int j = 0; j < w.at(i).size(); j++)
				{
					if (w.at(i).at(j) != '.')
					{
						char sp = w.at(i).at(j) - c;
						if (sp < 'a')
						{
							int p = 'a' - sp - 1;
							w.at(i).at(j) = 'z' - p;
						}
						else
						{
							w.at(i).at(j) = sp;
						}
					}
				}
			}

			cout << w.at(i) << (i == w.size() - 1 ? "" : " ");
		}

		cout << endl;
	}
}


Measured memory_bytes: 3232
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp14
{
    class Program
    {
        static void Main(string[] args)
        {
            var solver = new Solver();
            solver.Calc();
        }
    }

    public class Solver
    {

        double f(long x)
        {
            return x < 2 ? 1 : x * f(x - 2);
        }

        public void Calc()
        {
            var SP = Console.ReadLine().Split();


            var AB = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

            var U = Console.ReadLine();

            Console.WriteLine($"{(U == SP[0] ? AB[0] - 1 : AB[0])} {(U == SP[1] ? AB[1] - 1 : AB[1])}");

        }
    }
}

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

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner kb = new Scanner(System.in);
		int pages = kb.nextInt();
		
		if(pages%2 == 1) {
			System.out.println((pages/2)+1);
		}
		else if(pages%2 == 0) {
			System.out.println(pages/2);
		}
	}

}


Measured memory_bytes: 23764
k = int(input())
a = list(map(int, input().split()))
a.reverse()

mn,mx = 2,2
for g in a:
    mn = g * (((mn - 1) // g) + 1)
    mx = g * (mx//g) + g - 1

    if mn > mx:
        print(-1)
        exit()

print(mn,mx)

Measured memory_bytes: 63984
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

// using namespace __gnu_pbds;
#define Init1 ios::sync_with_stdio(false)
#define Init2 cin.tie(0)
#define INF 0x3f3f3f3f
// #pragma GCC optimize(2)


const int N = 1e9;
int main(){
    Init1; Init2;
    int n, k, s;
    cin>>n>>k>>s;
    for(int i = 1; i <= k; ++i){
        cout<<s<<" ";
    }
    for(int i = k + 1; i <= n; ++i){
        if(s == N) cout<<s - 1<<" ";
        else cout<<N<<" ";
    }
    // system("pause");
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define int long long int
#define float long double
#define gif(a,b) (a/b +(a%b?1:0))
#define pi 3.14159265358
#define watch(x) cout<<(#x)<<" is "<<(x)<<"\n";
using namespace std;

int size(int n)
{
	int size=0;
	while(n)
	{
		n /= 10;
		size++;
	}
	return size;
}

int32_t main()
{   
    cin.tie(NULL);
    //std::ios::sync_with_stdio(false);
   int n, ans = 1;
   cin >> n;
   int a[n];
   int power = 0;
   float base = 1; 
   for(int i = 0; i < n; ++i)
   {
   		cin >> a[i];
   		if( a[i] == 0)
   		{	
   			cout << "0";
   			return 0;
    	}
    	int d = 1, l=size(a[i]);
    	while(--l)
    		d *= 10;
    	base *= (a[i] / (float)d);
    	power += size(a[i]) - 1;
    	ans *= a[i];
   }
   if(base > pow(10, 18 - power))
   	cout << "-1";
   else
  	cout << ans;
    return 0;
}


Measured memory_bytes: 4804
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    int ans = 0;
    for(int i=0; i<N; i++){
        int t;
        cin >> t;
        if(t < A || B <= t) ans++;
    }
    cout << ans << endl;

    return 0;
}

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

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define inf 100248012
#define mp make_pair
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)


typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> ii;
double X0;
double Y0;
const int MAXN = 5e3+3;

struct Point{
  double x;
  double y;
  Point(double a = 0, double b = 0){
    x = a,y = b;
  }
  bool operator==(const Point p)const {
    return p.x == x && p.y == y;
  }
  bool operator<(const Point &p) const{
    return y<p.y || (y == p.y && x<p.x);
  }
  bool operator<=(const Point &p) const{
    return y<p.y || (y == p.y && x<=p.x);
  }
  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 a){
	  return Point(a*x,a*y);
  }
  double operator*( Point p){
    return x*p.x + y*p.y;
  }
  double operator^( Point p){
    return x*p.y - y*p.x;
  }
  double norma2(){
    return x*x + y*y;
  }
  double norma(){
    return sqrt(this->norma2());
  }
};
struct Recta{
	Point P;
	Point V;
	Recta(Point p=Point(0,0),Point q=Point(0,0)){
		P=p;
		V=q;
		}
	Point operator *(Recta M){
		if(((M.V)^V) == 0){
			return Point(inf,inf);
			}
		else{
			double alpha;
			alpha=((M.P-P)^M.V)/(V^M.V);
			return P+V*alpha;
			}
		}
	};
struct Segmento{
	Point P;
	Point V;
	Segmento(Point p=Point(0,0),Point q=Point(0,0)){
		P=p;
		V=q;
		}
	Point operator *(Recta M){
		if(((M.V)^V) == 0){
			return Point(inf,inf);
			}
		else{
			double alpha;
			alpha=((M.P-P)^M.V)/(V^M.V);
			if((alpha<=1)&&(alpha>=0))
			{return P+V*alpha;}
			else
			{return Point(inf,inf);}
			}
		}
	};


int main(){
	int a[200000],b[100000];
	int n;
	int i,j,k;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		}
	j=n/2;
	k=1;
	double c=(double) n/2;
	
	for(i=0;i<n;i++){
		if((double)j<c){b[j]=a[i];j=j+k;k++;}
		else{b[j]=a[i];j=j-k;k++;}
		}
	for(i=0;i<n;i++){
		printf("%d",b[i]);
		if(i!=(n-1)){
			printf(" ");
			}
		}
	printf("\n");
	return 0;
	}


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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> Pair;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll N;
vector<VL> v;

ll dfs(ll a) {
    ll res = 0;
    VL now;
    FOREACH(na, v[a]) now.push_back(dfs(na));
    sort(All(now));
    REP(i, now.size()) res = max(res + 1, now[i]);
    return res + 1;
}

int main() {
    cin >> N;
    v.resize(N);
    REP(i, N - 1) {
        CINT(a);
        a--;
        v[a].emplace_back(i + 1);
    }
    cout << dfs(0) - 1 << "\n";
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define cu continue
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf LLONG_MAX
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define f first
#define s second
#define vll vector <ll>
#define dbg(n) cout<<#n<<' '<<n<<endl;

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

 	ll n,m;
 	cin>>n>>m;
 	ll ans=0;
 	ans+=(n*(n-1)/2);
 	ans+=(m*(m-1)/2);
 	cout<<ans<<'\n';
}       


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
 
 int main(){
	 int N,avr,avrsub;
	 int X[101];
	 int ans=0,anssub=0,sum=0;
	 scanf("%d", &N);
	 
	 for (int a = 0; a < N;a++){
		 scanf("%d", &X[a]);
       sum +=X[a];
	 }
      avr =sum/N;
      avrsub = sum/N +1;
			 for (int b = 0; b < N; b++)
		 {
			 ans += (X[b] - avr) * (X[b] - avr);
             anssub += (X[b] - avrsub) * (X[b] - avrsub);

	 }
   if(ans<anssub){
   printf("%d", ans);
   }else{
	 printf("%d", anssub);
   }
	 return 0;
 }

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int N;
Vi A, B;
int dp[(1 << 18) + 1][20];

int bit_dp(int bit, int v) {
    // メモ済みならメモの値を返す
    if (dp[bit][v] != -1) {
        return dp[bit][v];
    }

    // 初期値
    if (bit == (1 << v)) {
        return dp[bit][v] = 0;
    }

    int res = I_INF;

    int prev_bit = bit & ~(1 << v);
    int v_pos = __builtin_popcount(bit) - 1;  // v番目のカードがおかれる位置
    int v_val;
    // v番目のカードの表の値を求める
    if (abs(v_pos - v) & 1) {
        v_val = B[v];
    }
    else {
        v_val = A[v];
    }

    for (int u = 0; u < N; u++) {
        // prev_bit に u が無かったら飛ばす
        if (!(prev_bit & (1 << u))) continue;

        // u番目とカードの表の値を求める
        int u_pos = v_pos - 1;
        int u_val;
        if (abs(u_pos - u) & 1) {
            u_val = B[u];
        }
        else {
            u_val = A[u];
        }
        if (u_val > v_val) continue;  // 広義単調増加出なければ飛ばす

        // v番目のカードを追加することによる転倒数の増分を求める
        int dtento = 0;
        for (int k = 0; k < N; k++) {
            if (!(prev_bit & (1 << k))) continue;
            if (k > v) ++dtento;
        }

        if (bit_dp(prev_bit, u) != I_INF)
            res = min(res, bit_dp(prev_bit, u) + dtento);
    }

    return dp[bit][v] = res;
}

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

    cin >> N;
    A.resize(N), B.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }

    for (int i = 0; i < (1 << N); i++) {
        for (int j = 0; j < N; j++) {
            dp[i][j] = -1;
        }
    }

    int ans = I_INF;
    for (int i = 0; i < N; i++) {
        ans = min(ans, bit_dp((1 << N) - 1, i));
    }

    if (ans == I_INF) {
        ans = -1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 20736
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
# map(int, input().split())
# int(input())
# input().split()
# mojiretu = ','.join(str_list)
# sorted(input())

n, d = map(int, input().split())
print(n // (2*d + 1)) if n%(2*d + 1) == 0 else print(n // (2*d + 1) + 1)

Measured memory_bytes: 5336
#include<stdio.h>
int main(){
  int num1,num2,temp;
  scanf("%d%d",&num1,&num2);

  if(num1<num2){
    num1 +=num2;
    num2= num1-num2;
    num1-=num2;
  }

  while(num2!=0){
    temp = num1%num2;
    num1=num2;
    num2=temp;
  }
    
  printf("%d\n",num1);
  return 0;
}



Measured memory_bytes: 2144
#include<iostream>
#include<algorithm>

using namespace std;

int data[3];
int ans[4];

int main(){

  
  while(cin >> data[0] >> data[1] >> data[2]){
    sort(data,data+3);
    if(data[0] + data[1] <= data[2]) break;
    ans[0]++;

    int tmp = data[0]*data[0]+data[1]*data[1];

    if(tmp > data[2]*data[2]) ans[1]++;
    if(tmp == data[2]*data[2]) ans[2]++;
    if(tmp < data[2]*data[2]) ans[3]++;
  }

  cout << ans[0] << " " << ans[2] << " " << ans[1] << " " << ans[3] << endl;
  return 0;
}

Measured memory_bytes: 1180
#include <stdio.h>
int main(){
    int a, b, c, s;
    scanf("%d %d %d",&a,&b,&c);
    if(a>b){
       s=a;
       a=b;
       b=s;
     } 
     if(a>c){
       s=c;
       c=a;
       a=s;
     } 
     if(b>c){
        s=c;
        c=b;
        b=s;
     }
     printf("%d %d %d\n",a,b,c);
     }

Measured memory_bytes: 1796
using System;
namespace ABC107
{
    class A
    {
        static void Main(string[] args)
        {
            long K = long.Parse(Console.ReadLine());
            Console.WriteLine(K % 2 == 0 ? K / 2 * K / 2 : (K / 2 + 1) * (K / 2));
        }
    }
}


Measured memory_bytes: 11092
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math

N, = map(int, sys.stdin.readline().rstrip().split())
a_list = list(map(int, sys.stdin.readline().rstrip().split()))

def score_index(score):
    if score < 400:
        return 0
    if score < 800:
        return 1
    if score < 1200:
        return 2
    if score < 1600:
        return 3
    if score < 2000:
        return 4
    if score < 2400:
        return 5
    if score < 2800:
        return 6
    if score < 3200:
        return 7
    else:
        raise Exception()



superplayers = 0
counts = set()
for a in a_list:
    if a < 3200:
        counts.add(score_index(a))
    else:
        superplayers += 1

print("{} {}".format(
    max(len(counts), 1),
    len(counts) + superplayers
))

exit(0)


Measured memory_bytes: 3064
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String A=sc.next();
		int[] al=new int[26];
		long ans=(long)A.length()*(A.length()-1)/2;
		for(int i=0; i<A.length(); i++){
			ans-=al[A.charAt(i)-'a'];
			al[A.charAt(i)-'a']++;
		}
		System.out.println(ans+1);
	}
}


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

#define mod 1000000007
using ll=long long;

ll modpow(ll n,ll m=mod-2){
  ll r=1;
  while(m){
    r=r*((m%2)?n:1)%mod,n=n*n%mod,m>>=1;
  }
  return r;
}

int main(){
	
	int n;
	cin >> n;

	ll ans = modpow(10,n)+modpow(8,n)-modpow(9,n)-modpow(9,n);
    ans%=mod;
	ans=(ans+mod)%mod;
	cout << ans << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    cin >> v.at(i);
  }
  sort(v.begin(), v.end());
  double ans = (v.at(0) + v.at(1) + 0.0) / 2;
  for (int i = 2; i < N; i++) {
    ans = (ans + v.at(i) + 0.0) / 2;
  }
  cout << fixed << setprecision(16);
  cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int n;
stack<string> st;

int main(){
	cin.sync_with_stdio(false);
  bool ok=true;
  cin>>n;
  rep(i,n){
    string tmp;
    cin>>tmp;
    if(tmp=="Un"){
      if(st.size()==0)ok=false;
      else st.pop();
    }else st.push(tmp);
  }
  if(ok&&st.size()==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int main(){
	long long N, M;
	while(cin >> N >> M){
		long long res = 0;
		long long a1 = min(N, M/2);
		res += a1;
		M -= 2*a1;
		res += M/4;
		cout << res << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int I[40000],n,m,H[20],a[20][20],x,y,ans,f[20][35000],w[35000];
int main(){
	scanf("%d%d",&n,&m);
	I[1]=H[1]=1; for (int i=2;i<=n+1;++i) H[i]=H[i-1]<<1,I[H[i]]=i;
	for (int i=1;i<=m;++i){
		scanf("%d%d",&x,&y);
		scanf("%d",&a[x][y]);
		a[y][x]=a[x][y];
		for (int j=1;j<H[n+1];++j)
		if (j&H[x]&&j&H[y]) w[j]+=a[x][y];
	}
	for (int i=1;i<=n;++i)
	for (int j=0;j<H[n+1];++j) f[i][j]=-1;
	for (int s=1;s<H[n];s+=2) f[1][s]=w[s];
	for (int s=1;s<H[n];s+=2){
		for (int i=2;i<n;++i)
		if (H[i]&s){
			int S=s^H[i];
			for (int o=S;o;o=o-1&S)
			if (o&1){
				for (int j=o;j;j-=j&-j)
				if (a[i][I[j&-j]])
					f[i][s]=max(f[i][s],a[i][I[j&-j]]+f[I[j&-j]][o]+w[s-o]);
			}
		}
	}
	for (int i=1;i<n;++i)
	if (a[i][n])
	for (int s=1;s<H[n];s+=2)
	if (f[i][s]>-1)
	ans=max(ans,f[i][s]+a[i][n]+w[H[n+1]-1-s]);
	printf("%d\n",w[H[n+1]-1]-ans);
	return 0;
}

Measured memory_bytes: 2432
// Code for C - Count Order
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;

uint fact(uint n){
	if(n == 0) return 1;
	return n * fact(n-1);
}

list<uint> convert(const list<uint>& in){
	list<uint> ret(in.size()-1);
	const auto rem = in.front();
	auto nitr = in.begin();
	nitr++;
	transform(nitr,in.end(),ret.begin(),[&rem](const uint& v){return v - (v > rem ? 1 : 0);});
	return ret;
}

int compare(const list<uint>& a, const list<uint>& b){
	const uint len = a.size();
	if(len==1){
		return 0;
	}else{
		const int a_head = a.front();
		const int b_head = b.front();
		const auto a_next = convert(a);
		const auto b_next = convert(b);
		return (a_head - b_head)*fact(len-1) + compare(a_next,b_next);
	}
}


int main() {
	uint n;
	cin >> n;
	list<uint> atest(n);
	list<uint> btest(n);
	for (auto aitr = atest.begin(); aitr != atest.end(); aitr++) {
		uint in;
    	cin >> in;
		*aitr = in;
	}
	for (auto bitr = btest.begin(); bitr != btest.end(); bitr++) {
		uint in;
    	cin >> in;
		*bitr = in;
	}
	const int result = compare(atest,btest);
	uint test = abs(result);
	cout << test;
	return 0;
}


Measured memory_bytes: 256
// "include" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>
// }}}
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c;
	cin >> a >> b >> c;
	if(b / a >= c) cout << c << '\n';
	else cout << b / a << '\n';
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;

int main()
{
    int A, B, C, D;
    if (scanf("%d%d%d%d", &A, &B, &C, &D) < 4) return 0;

    printf("%d\n", A * B < C * D ? C * D : A * B);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  ll N,A,B;
  cin >> N >> A >> B;
  ll C = A-B;
  vl h(N);
  rep(i,N) {
    cin >> h[i];
  }
  int l = 0,r = INF;
  while(l+1<r) {
    int m = (l+r)/2;
    ll k = 0;
    rep(i,N) {
      ll r = h[i] - B*m;
      if(r>0) {
        k += (r+C-1)/C;
      }
    }
    if(k<=m) {
      r = m;
    } else {
      l = m;
    }
  }
  
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 1024
from queue import Queue

n, q_time = map(int, input().split())
qu = Queue()
for i in range(n):
    p_name, p_time = input().split()
    p_time = int(p_time)
    qu.put((p_name, p_time))

t = 0
while True:
    if qu.empty():
        break
    p_name, p_time = qu.get()
    if p_time <= q_time:
        t += p_time
        print(f'{p_name} {t}')
    else:
        t += q_time
        qu.put((p_name, p_time - q_time))



Measured memory_bytes: 13388
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        var hw = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var grid = new List<string>();
        grid.Add(new string('.', hw[1] + 2));
        for (int i = 0; i < hw[0]; i++) grid.Add("." + Console.ReadLine() + ".");
        grid.Add(new string('.', hw[1] + 2));
        bool judge = true;
        for (int i = 0; i < grid.Count(); i++)
        {
            for (int j = 0; j < grid[0].Length; j++)
            {
                if (grid[i][j] == '#')
                {
                    if (!new char[4] { grid[i - 1][j], grid[i][j - 1], grid[i + 1][j], grid[i][j + 1] }.Contains('#')) judge = false;
                }
            }
        }
        Console.WriteLine(judge ? "Yes" : "No");
    }
}

Measured memory_bytes: 13268
n,k,q = map(int,input().split())
a = [0]*n
for i in range (q):
    c = input()
    c = int(c)
    a[c-1] += 1
m = k-q
for j in a:
    if m+j > 0:
        print("Yes")
    else:
        print("No")


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

int main(){
    
    while(1){
        int n, m, t, p; cin >> n >> m >> t >> p;
        if(!n) break;
        vector<int> d(t);
        vector<int> c(t);
        vector<int> x(p);                                             
        vector<int> y(p);                                             //  y
                                                                      //  ^
        for(int i = 0; i < t; i++) cin >> d[i] >> c[i];               //  |
        for(int i = 0; i < p; i++) cin >> x[i] >> y[i];               //  |
                                                                      //  |
        vector<vector<vector<int> > > dp(t + 1);                      //  |
        dp[0].resize(n, vector<int> (m, 1));                          //  |          dp[x][y]
                                                                      //  |
        for(int i = 0; i < t; i++){                                   //  |
                                                                      //  |
            int now_x = (int)dp[i].size();                            //  |
            int now_y = (int)dp[i][0].size();                         //  O----------------------------> x
            
            if(d[i] == 2){

                //下から上へ折りたたむ
                
                //次の折り紙のサイズを計算
                int next_x = now_x;
                int next_y = now_y - c[i] + max(0, (2*c[i] - now_y));
                dp[i + 1].resize(next_x, vector<int> (next_y, 0));
                //ここ dp じゃね?
                for(int x = 0; x < now_x; x++){
                    for(int y = 0; y < now_y; y++){
                        int nx = x;
                        int ny = y - c[i];
                        if(ny < 0){
                            ny = -ny - 1;
                        }
                        dp[i + 1][nx][ny] += dp[i][x][y];
                    }
                }

            }else{

                //左から右へ折りたたむ

                //次の折り紙のサイズを計算
                int next_x = now_x - c[i] + max(0, (2*c[i] - now_x));
                int next_y = now_y;
                dp[i + 1].resize(next_x, vector<int> (next_y, 0));
                //ここ dp じゃね?
                for(int x = 0; x < now_x; x++){
                    for(int y = 0; y < now_y; y++){
                        int nx = x - c[i];
                        int ny = y;
                        if(nx < 0){
                            nx = -nx - 1;
                        }

                        dp[i + 1][nx][ny] += dp[i][x][y];
                    }
                }
            }
            
            /*cout << endl;
            cout << i << endl;
            for(int x = 0; x < now_x; x++){
                for(int y = 0; y < now_y; y++){
                    cout << dp[i][x][y] <<  " ";
                }
                cout << endl;
            }*/
        
        }

        for(int i = 0; i < p; i++){
            cout << dp[t][x[i]][y[i]] << endl;
        }
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    ll q;cin>>q;
    priority_queue<ll> q1;
    priority_queue<ll,vector<ll>,greater<ll>> q2;
    ll sum1=0,sum2=0;
    ll sb=0;
    rep(i,0,q){
        ll e;cin>>e;
        if(e==1){
            ll a,b;cin>>a>>b;
            sb+=b;
            if(q1.size()==0){
                q1.push(a);
                sum1+=a;
                continue;
            }
            if(q2.size()==0){
                ll u=q1.top();
                if(a<=u){
                    q1.pop();
                    q1.push(a);
                    sum1=a;
                    sum2=u;
                    q2.push(u);
                    continue;
                }
                else{
                q2.push(a);
                sum2+=a;
                continue;
                }
            }
            ll s=q1.top(),t=q2.top();
            if(a<=s){
                q1.push(a);
                sum1+=a;
                if(q1.size()==q2.size()+2){
                    ll ss=q1.top();q1.pop();
                    sum1-=ss;
                    q2.push(ss);
                    sum2+=ss;
                }
            }
            else if(a>=t){
                q2.push(a);
                sum2+=a;
                if(q2.size()==q1.size()+1){
                    ll ss=q2.top();q2.pop();
                    sum2-=ss;
                    q1.push(ss);
                    sum1+=ss;
                }
            
            }
            else{
                if(q1.size()==q2.size()){
                    q1.push(a);
                    sum1+=a;
                }
                else if(q1.size()==q2.size()+1){
                    q2.push(a);
                    sum2+=a;
                }
            }
        }
        else if(e==2){
            ll r=q1.top();
            //cout<<r<<" "<<sum1<<" "<<sum2<<endl;
            ll ans=0;
            ans+=sum2-(sum1-r);
            if(q1.size()==q2.size())ans-=r;
            ans+=sb;
            cout<<r<<" "<<ans<<endl;
        }
        //cout<<q1.top()<<" "<<q2.top()<<endl;
    }
    
    
}


Measured memory_bytes: 3828
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>

using namespace std;
using ll = long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n, m; cin >> n >> m;
  cout << n * (n-1) / 2 + m * (m-1) / 2 << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	string s;
	cin>>s;
	if (n>=3200)
		cout<<s;
	else
		cout<<"red";
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<double,P> PP;
struct edge { int to; int cost; };
double beki[100006];
signed main() {
	int n, k; cin >> n >> k;
	beki[0] = 1;
	rep(i, 100004)beki[i + 1] = beki[i] * 0.5;
	double ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i < k) {
			int ni = i, cnt = 0;
			while (ni < k) {
				ni *= 2; cnt++;
			}
			ans += beki[cnt];
		}
		else ans += 1;
	}
	printf("%.11lf\n", ans / n);
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
    std::string s,t;
    cin >> s;
    cin >> t;


    for(int i=0; i<s.size(); i++){
        if(s[i]!=t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

unsigned long long power(int a,int b){
    unsigned long long r = 1;
    for(int i=0;i < b;i++){
        r *= a;
    }
    return r;
}

int main()
{
    unsigned long long h,m,n;
    cin >> h;
    int i = 0;
    n = h;
    while(n != 0){
        n /= 2;
        i++;
    }
    n = i;
    m = power(2,n) - 1;
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 256
import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.Integer.parseInt;

public class Main {

  final int MIN = Integer.MIN_VALUE;
  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = parseInt(in.readLine());

      pxPoint[] reds  = new pxPoint[n];
      pxPoint[] blues = new pxPoint[n];
      String[] lines;
      for(int i=0, x=0, y=0; i<n; i++) {
        lines = in.readLine().split(" ");
        x = parseInt(lines[0]);
        y = parseInt(lines[1]);
        reds[i] = new pxPoint(x, y); 
      }
      for(int i=0, x=0, y=0; i<n; i++) {
        lines = in.readLine().split(" ");
        x = parseInt(lines[0]);
        y = parseInt(lines[1]);
        blues[i] = new pxPoint(x, y); 
      }

      Arrays.parallelSort(reds);
      Arrays.parallelSort(blues);

      boolean[] isDone = new boolean[n];

      int ans = 0;
      pxPoint p = new pxPoint(MIN,MIN);
      int maxJ = MIN;
      for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
          if(!isDone[j] && reds[j].x < blues[i].x && reds[j].y < blues[i].y) {
            if(reds[j].y > p.y) {
              p.x = reds[j].x;
              p.y = reds[j].y;
              maxJ = j;
            }
          }
        }
        if(maxJ != MIN) {
          ans++;
          isDone[maxJ] = true;
          p.x = MIN; p.y = MIN; maxJ = MIN;
        }
      }

      System.out.println(ans);
      // for (pxPoint p : reds) {
      //   System.out.println(p.x + " " + p.y);
      // }
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  class pxPoint extends Point implements Comparable<pxPoint> {

    private static final long serialVersionUID = 1L;

    public pxPoint() {
      super();
    }
    public pxPoint(int x, int y) {
      super(x, y);
    }

    // @Override
    public int compareTo(pxPoint obj) {
      if(this.x == obj.x) return 0;
      return this.x > obj.x ? 1 : -1;
    }
  }
}

Measured memory_bytes: 23252
// D - Wide Flip
#include <bits/stdc++.h>
using namespace std;

int main(){
	char S[100000+1]; scanf("%s",S);
	int K = strlen(S);
	for(int N=K, i=1; i<N; ++i)
		if(S[i-1] != S[i]) K = min(K, max(i, N-i));
	printf("%d\n",K);
}

Measured memory_bytes: 384
using System;
using System.Linq;
using System.Reflection.Metadata.Ecma335;

namespace ABC170_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();

            if (char.IsUpper(a,0)) {
                Console.WriteLine('A');
            }else if (char.IsLower(a,0)) {
                Console.WriteLine('a');
            }
        }
    }
}


Measured memory_bytes: 25624
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
int arr[505][505], enp[505];
bool app[100005];
int main()
{
	// freopen("TPC2018-D.in", "r", stdin);
	int n, k = 1;
	scanf("%d", &n);
	while (k * (k - 1) < 2 * n) {
		k++;
	}
	if (k * (k - 1) != 2 * n) {
		puts("No");
		return 0;
	}
	puts("Yes");
	printf("%d\n", k);
	int cur = 0;
	for (int i = 0; i < k; i++) {
		printf("%d ", k - 1);
		for (int j = 0; j < i; j++) {
			while (app[arr[j][enp[j]]]) {
				enp[j]++;
			}
			arr[i][j] = arr[j][enp[j]];
			app[arr[i][j]] = true;
		}
		for (int j = i; j < k - 1; j++) {
			arr[i][j] = ++cur;
		}
		for (int j = 0; j < k - 1; j++) {
			printf("%d%c", arr[i][j], " \n"[j + 1 == k - 1]);
		}
	}
	return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
   T res = 1;
   for(;n;n>>=1) {
      if (n & 1) res = res * a;
      a = a * a;
   }
   return res;
}

//cin.tie(0);ios::sync_with_stdio(false);



signed main(){
    int n;cin>>n;
    ll ans=0;
    vector<ll> v(n);rep(i,0,n)cin>>v[i];

    sort(all(v));

    rep(i,0,n-2){
        rep(j,i+1,n-1){
            ll a=v[i],b=v[j];
            ans+=(lb(all(v),a+b)-v.begin())-1-j;
        }
    }
    cout<<ans<<endl;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int h, w, n; cin >> h >> w >> n;
	if(h < w) swap(h, w);
	cout << (n + h - 1) / h << "\n";
}

Measured memory_bytes: 892
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

char a[100][2];

int main() {
	int n,m;
	while(n=in()){
		int i;
		for(i=0;i<n;i++){
			cin>>a[i][0]>>a[i][1];
		}
		m=in();
		for(i=0;i<m;i++){
			char ch;
			int j;
			cin>>ch;
			for(j=0;j<n;j++){
				if(a[j][0]==ch){
					cout<<a[j][1];
					break;
				}
			}
			if(j==n)cout<<ch;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 884
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 ff=unix


def dist(X, P):
    d = 0
    for x in X:
        d += (x-P)*(x-P)
    return d


def solv(N, X):
    ans = 100*100*100 + 1
    for P in range(1, 101):
        d = dist(X, P)
        if ans > d:
            ans = d
    return ans


if __name__ == "__main__":
    N = int(input())
    X = list(sorted(map(int, input().split())))
    ans = solv(N, X)
    print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		int i = Integer.parseInt(a + b);
		int root = (int)Math.sqrt(i);
		System.out.println(root * root == i ? "Yes" : "No");
	}
}


Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(LL i = (a); i < (LL)(n); ++i)
#define REM(i,a,n) for(LL i = ((n) - 1); i >= (a); --i)
#define FLOAT fixed << setprecision(16)
#define SPEEDUP {cin.tie(0); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }
// all_of
// partial_sum, adjacent_difference

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#include "Geometry.h"
#include "Matrix.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

int H, W;

PP Ch(LL h, LL w) {
	LL a = max(h / 2 * w, w / 2 * h);
	return PP(a, h * w - a);
}
int main() {
	cin >> H >> W;
	LL mn = INFLL;
	REP(i, 1, H) {
		LL a[3];
		PP p = Ch(H - i, W);
		a[0] = i * W;
		a[1] = p.first;
		a[2] = p.second;
		sort(a, a + 3);
		mn = min(mn, a[2] - a[0]);
	}
	REP(j, 1, W) {
		LL a[3];
		PP p = Ch(H, W - j);
		a[0] = j * H;
		a[1] = p.first;
		a[2] = p.second;
		sort(a, a + 3);
		mn = min(mn, a[2] - a[0]);
	}

	cout << mn << endl;
	return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S)
MOD = 10**9 + 7

dp = [[0] * 13 for i in range(N+1)]
dp[0][0] = 1
for i in range(N):
    for j in range(13):
        for k in range(10):
            if S[i] == str(k) or S[i] == '?':
                dp[i+1][(j*10+k) % 13] += dp[i][j]
                dp[i+1][(j*10+k) % 13] %= MOD
#print(dp)
print(dp[N][5])
                


Measured memory_bytes: 95716
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
int main(void){
    ll N, ANS=300005, L[300005], R[300005]; char S[300005];
    scanf("%lld\n%s", &N, S);
    ll countl=0, countr=0;
    rep(i, 0, N){
        L[i] = countl;
        if(S[i]=='W') countl++;
        R[N-1-i] = countr;
        if(S[N-1-i]=='E') countr++;
    }
    rep(i, 0, N) ANS = min(ANS, L[i]+R[i]);
    printf("%lld\n", ANS);
    return 0;
}
int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 5248
#include <stdio.h>
#define MAX 10000
#define NIL -1

struct Node { int parent ,left ,right;};

struct Node T[MAX];
int n , D[MAX] , H[MAX];

void setDepth(int u , int d)
{
	if( u == NIL) return;
	D[u] = d;
	setDepth(T[u].left,d+1);
	setDepth(T[u].right,d+1);
}

int setHeight(int u)
{
	int h1 = 0 , h2 = 0;
	if(T[u].left != NIL)
	h1 = setHeight(T[u].left)+1;
	if(T[u].right != NIL)
	h2 = setHeight(T[u].right)+1;
	return H[u] = (h1 > h2 ? h1 : h2);
}

//節点uの兄弟を返す
int getSibling(int u)
{
	if( T[u].parent == NIL) return NIL;
	if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
	return T[T[u].parent].left;
	if(T[T[u].parent].right!=u && T[T[u].parent].right!= NIL)
	return T[T[u].parent].right;
	return NIL;
}

void print(int u)
{
	printf("node %d: ",u);
	printf("parent = %d, ",T[u].parent);
	printf("sibling = %d, ",getSibling(u));
	int deg = 0;
	if(T[u].left != NIL) deg++;
	if(T[u].right != NIL) deg++;
	printf("degree = %d, ",deg);
	printf("depth = %d, ",D[u]);
	printf("height = %d, ",H[u]);
	
	if(T[u].parent == NIL)
	{
		printf("root\n");
	}
	else if(T[u].left == NIL && T[u].right == NIL)
	{
		printf("leaf\n");
	}
	else{
		printf("internal node\n");
	}
}

int main()
{
	int v , l , r , root = 0;
	scanf("%d",&n);
	
	for( int i = 0;i < n; i++) T[i].parent = NIL;
	
	for( int i = 0; i < n; i++)
	{
		scanf("%d %d %d",&v,&l,&r);
		T[v].left = l;
		T[v].right = r;
		if(l != NIL) T[l].parent = v;
		if(r != NIL) T[r].parent = v;
	}
	
	for( int i = 0; i < n; i++) if(T[i].parent == NIL) root = i;
	
	setDepth(root,0);
	setHeight(root);
	
	for(int i = 0; i < n; i++) print(i);

	return 0;
}





Measured memory_bytes: 2104
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

sum = 0
c = Counter(A)
for i in c.values():
    sum += i * (i - 1) // 2

for a in A:
    print(sum - (c[a] * (c[a] - 1) // 2) + (c[a] - 1) * (c[a] - 2) // 2)

Measured memory_bytes: 87884
#include <iostream>
#include <map>
#include <vector>


#define ALL(obj) begin(obj), end(obj)
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
int main() {
    ll N, P;
    P = 2019;
    string S;
    cin >> S;
    
    N = S.length();
 
    // P が 2 でも 5 でも無い時
        vector<ll> sum(N + 1, 0), ten(N + 1, 1);
        for (int i = N - 1; i >= 0; i--) {  // ten の前計算
            ten[i] = ten[i + 1] * 10 % P;
        }
        for (int i = N - 1; i >= 0; i--) {  // sum の計算
            sum[i] = ((ll)(S[i] - '0') * ten[i + 1] % P + sum[i + 1]) % P;
        }
     
        map<ll, ll> m;  // 剰余が同じものを数える
        for (auto i : sum) {
            m[i]++;
        }
     
        ll ans = 0;
        for (auto i : m) {
            ans += i.second * (i.second - 1) / 2;
        }
        cout << ans << endl;
     
        return 0;
    }


Measured memory_bytes: 6760
#include <iostream>

using namespace std;

int gcd(int x, int y) {
	int z = x%y;
	if(z==0) return y;
	return gcd(y,z);
}

int main() {
	int x,y;
	cin >> x >> y;
	cout << gcd(x,y) << endl;
	return 0;
}



Measured memory_bytes: 3108
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

if n == 0:
  print(0)

capa = [a,b,c,d,e]
min_capa = min(capa)

if n % min_capa == 0:
	print(n//min_capa + 4)
else:
	print(n//min_capa + 5)



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

#define int long long

using namespace std;

int pw[200005];

int ciclos(int x){
	if(x == 0) return 0;
	int bits = __builtin_popcount(x);
	return 1 + ciclos(x % bits);
}

signed main(){
	int n;
	string s;
	cin >> n >> s;
	reverse(s.begin(), s.end());
	int unos = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == '1') unos++;
	}
	int mod = unos + 1;
	if(unos - 1 > 0) mod *= (unos - 1);
	pw[0] = 1;
	for(int i = 1; i < n; i++) pw[i] = (pw[i - 1] * 2) % mod;
	int tot = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == '1'){
			tot = (tot + pw[i]) % mod;
		}
	}

	for(int i = n - 1; i >= 0; i--){
		if(s[i] == '1'){
			if(unos == 1){
				cout << 0 << '\n';
			}else{
				int queda = (tot - pw[i] + mod) % (unos - 1);
				cout << 1 + ciclos(queda) << '\n';
			}
		}else{
			int queda = (tot + pw[i] + mod) % (unos + 1);
			cout << 1 + ciclos(queda) << '\n';
		}
	}
}


Measured memory_bytes: 5288