akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FASTIO
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();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N, K;
    cin >> N >> K;
    map<ll, ll> mp;
    for (ll i = 0; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        mp[a] += b;
    }

    ll cnt = 0;
    for (const auto& p : mp) {
        cnt += p.second;
        if (cnt >= K) {
            cout << p.first << endl;
            break;
        }
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse -> greater<long long>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back

ll solve(string S){
   ll res=0;
   int left=0,right=sz(S)-1;
   while(left<right){
      if(S[left]==S[right])left++,right--;
      else if(S[left]=='x' && S[right]!='x'){
         res++;
         left++;
      }
      else if(S[left]!='x' && S[right]=='x'){
         res++;
         right--;
      } 
      else if(S[left]!='x' && S[right]!='x'){
         return -1;
      }
   }
   return res;
}

int main(){
   string S;cin>>S;
   cout<<solve(S)<<endl;
   return 0;
}

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

int main() 
{
    string S, T;
    cin >> S >> T;
    int count = 0;

    if(S[0] == T[0]) count++;
    if(S[1] == T[1]) count++;
    if(S[2] == T[2]) count++;

    cout << count << endl;

    return 0;  

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(void){
    ll N;
    string a;
    cin >> N;
    
    vector<string> vec(0);
    for (ll i = 0; i < N; i++) {
        cin >> a;
        vec.push_back(a);
    }
    sort(vec.begin(),vec.end());
    vec.erase(unique(vec.begin(), vec.end()),vec.end());
    
    cout<<vec.size();
    
    
    
}

Measured memory_bytes: 11664
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll x;
  R x;
  ll ans=1;
  REP(i,2,x+1) {
    ll y=i;
    rep(j,x+1) {
      y*=i;
      if(y<=x) ans=max(ans,y);
    }
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    long long A, B, N;
    ist >> A >> B >> N;

    /* ------- 計算 ------- */
    long long  x;

    if (B == 1)
    {
        ost << "0" << endl;
        return;
    }

    if (B > N)
    {
        x = N;
    }
    else
    {
        x = B - 1;
    }

    // long long ans = ((x % B) * A) / B;
    int tmp1 = floor((double)A * x / B);
    int tmp2 = A * floor((double)x / B);
    int ans = tmp1 - tmp2;

    ost << ans << endl;
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define INF 1000000
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int N;
  scanf("%d", &N);

  int dp[MAX];
  dp[0] = 0;
  rep(i, 1, MAX) {
    dp[i] = INF;
    int pow = 1;
    while (pow <= i) {
      dp[i] = min(dp[i], dp[i - pow] + 1);
      pow *= 6;
    }
    pow = 1;
    while (pow <= i) {
      dp[i] = min(dp[i], dp[i - pow] + 1);
      pow *= 9;
    }
  }

  printf("%d\n", dp[N]);
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
//コピペするとこ



//-------------------------------------------------


int main()
{
  int a, b ;
  cin >> a >> b ;
  int ans = 0 ;
  if(a<=3){
    ans += 100000*(4-a) ;
  }
  if(b<=3){
    ans += 100000*(4-b) ;
  }
  if(a==1 && b==1){
    ans += 400000 ;
  }
  cout <<ans <<endl ;
  return 0 ;
}




Measured memory_bytes: 256
function pint(s) { return parseInt(s); }
function pfloat(s) { return parseFloat(s); }
Array.prototype.sortNumAsc  = function () { return this.sort((a, b) => (a - b)); }
Array.prototype.sortNumDesc = function () { return this.sort((a, b) => (b - a)); }
Array.prototype.sortStrAsc  = function () { return this.sort();                  }
Array.prototype.sortStrDesc = function () { return this.sort().reverse();        }
Array.prototype.without = function (itm) { return this.filter((elem) => elem !== itm); }
var input = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', chunk => input += chunk);
process.stdin.on('end', () => {
  var lines = input.split('\n').map(l => l.trim());
  if (lines[lines.length-1] === '')
    lines = lines.slice(0, -1);
  main(lines);
});
function main(lines) {
  var arr = lines[0].split(' ').map(pint);
  var N = arr[0];
  var W = arr[1];
  lines = lines.slice(1).map(l => l.split(' ').map(pint));
  var t = 0;
  var dp = [{}, {}];
  dp[t][0] = 0;
  for (var i = 0; i < N; i++) {
    t ^= 1;
    dp[t] = {};
    var w = lines[i][0];
    var v = lines[i][1];
    for (var n in dp[t ^ 1]) {
      var wt = pint(n);
      var va = dp[t ^ 1][n];
      dp[t][wt] = Math.max(dp[t][wt] || 0, va);
      if (wt + w <= W)
        dp[t][wt+w] = Math.max(dp[t][wt+w] || 0, va+v);
    }
  }
  var ans = 0;
  for (var n in dp[t]) {
    var v = dp[t][n];
    ans = Math.max(ans, v);
  }
  console.log(ans);
}

Measured memory_bytes: 21948
/* ANTHOR KUMAR DAS
KUET ECE 2K18*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sc(a) scanf("%d",&a)
#define sc1(n) scanf("%lld",&n)
#define sc2(b,c) scanf("%lld%lld",&b,&c)
#define f(a,b) for(a=0;a<b;a++)
#define pb(a) push_back(a)
#define br break
int main()
{
    int i,n,f=0;
    cin>>n;
    for(i=1;i<=9;i++)
    {
        if(n%i==0&&(n/i)<=9&&(n/i)>0)
        {
            f=1;
            break;
        }
    }
    if(f==1)
    {
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    string s, t;
    cin >> s >> t;
    map<char, int> sc, tc;
    FORE(x, s) sc[x]++;
    FORE(x, t) tc[x]++;

    vi x, y;
    FORE(p, sc) {
        x.pb(p.second);
    }
    FORE(p, tc) {
        y.pb(p.second);
    }
    sort(ALL(x)), sort(ALL(y));
    if (x == y) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return (0^_^0);
}



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

using namespace std;

int N,K;

vector<long long int> V;

int main(void) {

	cin >> N >> K;
	long long int tmp;
	for (int i = 1; i <= N; i++) {
		cin >> tmp;
		V.push_back(tmp);
	}

	sort(V.begin(), V.end());

	long long int ans = 1000000000000;

	for (int i = 0; i <= N - K; i++) {
		ans = min(ans, V[i + K - 1] - V[i]);
	}

	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 1400
using System;
using System.Linq;
using System.Collections.Generic;
class ProgramE
    {
        static void Main(string[] args)
        {
            
            //入力
            string n = Console.ReadLine();
            int num = n.Length;
            
            int[] dp_plus = new int[num];
            int[] dp = new int[num];


            //それぞれのHPで倒すために、必要な最低コストで動的計画法
            for(int i = 0; i < num;i++)
            {
                int temp = n[i] - '0';
                if(i == 0)
                {
                    dp[i] = temp;
                    dp_plus[i] = 11 - temp;
                }
                else
                {
                    dp[i] = Math.Min(dp[i-1]+temp,dp_plus[i-1]+temp);
                    dp_plus[i] = Math.Min(dp[i-1]+11-temp,dp_plus[i-1]+9-temp);
                }
            }

            Console.WriteLine(Math.Min(dp[num -1],dp_plus[num -1]));
   
        } 
    }

Measured memory_bytes: 22624
#include <iostream>
#include <cstdio>
#include <cstring>
#define MN 220

typedef long long ll;

ll d[64], a[MN];
char s[MN];

bool ins(ll x)
{
	for(int i = 62; i >= 0; i--)
	{
		if((x >> i) & 1)
		{
			if(!d[i]) {d[i] = x; return 1;}
			x ^= d[i];
		}
	}
	return 0;
}

int main()
{
	int T; scanf("%d", &T);
	while(T--)
	{
		memset(d, 0, sizeof(d));
		int n; scanf("%d", &n);
		for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
		scanf("%s", s + 1);
		bool ok = 0;
		for(int i = n; i >= 1; i--)
		{
			if(s[i] == '0') ins(a[i]);
			else if(ins(a[i])) {ok = 1; break;}
		}
		printf("%d\n", ok);
	}
}

Measured memory_bytes: 3680
#include<iostream>
#include<algorithm>
#define inf 1e9+9
using namespace std;
int a[41], b[41], c[41];
int dp[41][405][405];
int main() {
	int n, ma, mb;
	cin >> n >> ma >> mb;

	for (int i = 0; i < n; i++)cin >> a[i] >> b[i] >> c[i];

	for (int i = 0; i < 41; i++)
		for (int j = 0; j < 405; j++)
			for (int k = 0; k < 405; k++)dp[i][j][k] = inf;
	dp[0][0][0]=0;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= 400; j++) {
			for (int k = 0; k <= 400; k++) {
				if (dp[i][j][k] == inf)continue;
				dp[i + 1][j][k] = min(dp[i][j][k], dp[i + 1][j][k]);
				dp[i + 1][j + a[i]][k + b[i]] = min(dp[i][j][k]+c[i], dp[i+1][j + a[i]][k + b[i]]);
			}
		}
	}
	int ans = inf;
	for (int i = 0; i <= 401; i++) {
		for (int j = 0; j < 402; j++) {
			if (i*mb != j*ma)continue;
			if ((!i)||(!j))continue;
			ans = min(ans, dp[n][i][j]);
		}
	}
	if (ans == inf)cout << -1 << endl;
	else cout << ans << endl;
}

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

int main() {
  int N,count;
  cin >> N;
  vector<int> data(N);
  count = 1;
  int a = 1;
  for (int i = 0;i < N;i++){
    cin >> data.at(i);
  }
 count = 0;
  for (int k = 0; k < N; k++){
    count++;
    a = data.at(a-1);
   if (a == 2){
     cout << count << endl;
     return 0;
   }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

#define EPS (1e-10)
#define equals(a,b) (fabs((a) - (b)) < EPS)

class Point {
public:
    double x,y;
    Point(double x,double y):x(x),y(y){}
    Point():x(0),y(0){}

    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(x*a,y*a);}
    Point operator / (double a){return Point(x/a,y/a);}

    double abs(){return sqrt(norm());}
    double norm(){return x * x + y * y;}

    bool operator < (const Point & p) const {
      return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const {
      return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
    }

    void set(double x,double y) {
      this->x = x;
      this->y = y;
    }


};

struct Segment{
    Point p1,p2;
};

typedef Point Vector;

double dot(Vector a, Vector b){
  return a.x * b.x + a.y * b.y;
}

double cross(Vector a,Vector b){
  return a.x * b.y - a.y * b.x;
}

bool isOrthogonal(Vector a,Vector b){
  return equals(dot(a,b),0.0);
}

bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
  return isOrthogonal(a1-a2,b1-b2);
}

bool isOrthogonal(Segment s1,Segment s2){
  return equals(dot(s1.p2 - s1.p1,s2.p2-s2.p1),0.0);
}

bool isParallel(Vector a, Vector b){
  return equals(cross(a,b),0.0);
}

bool isParallel(Point a1,Point a2,Point b1,Point b2){
  return isParallel(a1-a2,b1-b2);
}

bool isParallel(Segment s1,Segment s2){
  return equals(cross(s1.p2 - s1.p1,s2.p2-s2.p1),0.0);
}

Point project(Segment s,Point p){
  Point vec1,vec2;
  vec1 = s.p2 - s.p1;
  vec2 = p - s.p1;
  return s.p1 + vec1 * dot(vec1,vec2) / vec1.norm();
}

int main(){
  double x1,x2,y1,y2,x,y;
  cin >> x1 >> y1 >> x2 >> y2;
  vector<Vector> p(3);
  p[0] = Point(x1,y1);
  p[1] = Point(x2,y2);
  Segment s;
  s.p1 = p[0];
  s.p2 = p[1];
  ll q;
  cin >> q;
  rep(i,q){
    cin >> x >> y;
    p[2] = Point(x,y);
    Point vec;
    vec = project(s,p[2]);
    printf("%.15f %.15f\n",vec.x,vec.y);
  }
}


Measured memory_bytes: 3296
import sys
sys.setrecursionlimit(10 ** 6)

n, m = map(int, input().split())

maxS = 0
vMaxS = -1
adjL = [[] for v in range(n)]
for i in range(m):
    u, v, s = map(int, input().split())
    adjL[u-1].append((v-1, s))
    adjL[v-1].append((u-1, s))
    if s > maxS:
        maxS = s
        vMaxS = u-1

# sの最大値が2の場合は、全ての頂点に1を書くケースのみが条件を満たす
if maxS == 2:
    print(1)
    exit()

#
def DFS(vNow):
    if len(zRange[vNow]) > 1: return
    zFr, zTo, dz = zRange[vNow][0]
    for v2, s in adjL[vNow]:
        # 頂点vNowの整数範囲と辺の整数sから定まる、頂点v2の整数範囲を条件リストに追加する
        zRange[v2].append((s - zFr, s - zTo, -dz))
        DFS(v2)


zRange = [[] for v in range(n)]
zRange[vMaxS].append((1, maxS-1, 1)) # 頂点vMaxSの整数範囲[1, maxS-1]、1は傾きの意
DFS(vMaxS)


# 各頂点について、課せられた整数範囲条件の共通部分を求める
iRange = [[] for v in range(n)]
for v, zR in enumerate(zRange):
    zR = list(set(zR)) # 重複を排除する
    if len(zR) > 2:
        # 3つ以上の条件が残っている場合、共通部分はない
        print(0)
        exit()
    elif len(zR) == 2:
        s1, ds = zR[0][0], zR[0][2]
        t1, dt = zR[1][0], zR[1][2]
        if ds == dt:
            # 傾きは同じだが範囲が異なる場合、共通部分はない
            print(0)
            exit()
        else:
            # 傾きが異なる場合、交点を求める
            iC = (s1 - t1) / (dt - ds)
            if iC == int(iC) and 0 <= iC <= maxS-2 and s1 + ds * iC > 0:
                iRange[v] = [int(iC), int(iC)]
            else:
                print(0)
                exit()
    else:
        # 条件が1つの場合、「正の整数」である範囲を求める
        s1, ds = zR[0][0], zR[0][2]
        if ds == 1:
            iFr, iTo = max(0, 1-s1), maxS-2
        else:
            iFr, iTo = 0, min(s1-1, maxS-2)

        if iFr <= iTo:
            iRange[v] = [iFr, iTo]
        else:
            print(0)
            exit()

# 全ての頂点の共通範囲をまとめる
iRange = list(zip(*iRange)) # 転置
iFr = max(iRange[0])
iTo = min(iRange[1])
if iFr <= iTo:
    print(iTo - iFr + 1)
else:
    print(0)


Measured memory_bytes: 158912
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=201000;
char s[N];
int cnt;
ll ans;
int main() {
	scanf("%s",s);
	int n=strlen(s);
	rep(i,0,n) {
		if (s[i]=='B') cnt++;
		else ans+=cnt;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 3010
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
#define INF 10000000
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
	int n;
    cin>>n;
    bool f=false;
    for(int i=1;i<10;i++){
        if(n%i==0&&(n/i)<10) f=true;
    }
    if(f)OUT("Yes");
    else OUT("No");
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ITP1_8_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] cnt = new int[26];
            string str;
            while ((str = Console.ReadLine()) != null)
            {
                foreach (var c in str)
                {
                    if (char.IsUpper(c)) cnt[c - 'A']++;
                    else if (char.IsLower(c)) cnt[c - 'a']++;
                }
            }
            for (int i = 0; i < 26; i++)
            {
                Console.WriteLine("{0} : {1}", (char)('a' + i), cnt[i]);
            }
        }
    }
}

Measured memory_bytes: 9052
from functools import reduce

n, a, b = map(int, input().split())

mod = 10 ** 9 + 7

def combi(c):
    numerator = reduce(lambda x, y: x * y % mod, range(n, n - c, -1))
    denominator = reduce(lambda x, y: x * y % mod, range(1, c + 1))
    return numerator * pow(denominator, mod - 2, mod) % mod

answer = pow(2, n, mod) - combi(a) - combi(b) - 1
print(answer % mod)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <deque>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    //input
    int n; cin >> n;
    vector<int> a(n + 1, 0);
    vector<int> c(n + 1, 0);
    for(int i = 1; i < n + 1; i++) cin >> a[i];
    for(int i = 1; i < n + 1; i++) c[i] = a[i];
  

    //compute
    int hit = 0;
    sort(c.begin() + 1 , c.end());
    reverse(c.begin() + 1 , c.end());
    hit = count(c.begin() + 1 , c.end(),c[1]);

    //output
    if(hit >= 2){
        for(int i = 1; i < n + 1; i++){
            cout << c[1] << endl;
        }
        }else{
            for(int i = 1; i < n + 1; i++){
            if(a[i] == c[1]){
                cout << c[2] << endl;
        }else{
	        	cout << c[1] << endl;
        }
        }
        }

}


Measured memory_bytes: 4756
#include <iostream>
#include <string>
#include <vector>

int extractNumber(const std::string& str) {
  return std::stoi(str.substr(1));
}

std::vector<std::string> bubbleSort(std::vector<std::string> c, const int& n) {
  for (int i = 0; i < n; ++i) {
    for (int j = n - 1; j > i; --j) {
      if (extractNumber(c[j]) < extractNumber(c[j - 1]))
        std::swap(c[j], c[j - 1]);
    }
  }
  return c;
}

std::vector<std::string> selectionSort(std::vector<std::string> c, const int& n) {
  for (int i = 0; i < n; ++i) {
    int minj = i;
    for (int j = i; j < n; ++j) {
      if (extractNumber(c[j]) < extractNumber(c[minj]))
        minj = j;
    }
    std::swap(c[i], c[minj]);
  }
  return c;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<std::string> c;
  for (int i = 0; i < n; ++i) {
    std::string str;
    std::cin >> str;
    c.push_back(str);
  }
  std::vector<std::string> bSorted = bubbleSort(c, n);
  for (int i = 0; i < n; ++i) {
    std::cout << bSorted[i];
    if (i == n - 1)
      std::cout << std::endl;
    else
      std::cout << " ";
  }
  std::cout << "Stable" << std::endl;

  std::vector<std::string> sSorted = selectionSort(c, n);
  bool stable = true;
  for (int i = 0; i < n; ++i) {
    std::cout << sSorted[i];
    if (i == n - 1)
      std::cout << std::endl;
    else
      std::cout << " ";
    if (sSorted[i] != bSorted[i])
      stable = false;
  }
  if (stable)
    std::cout << "Stable" << std::endl;
  else
    std::cout << "Not stable" << std::endl;
}

Measured memory_bytes: 3172
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	s = readline() |> chomp
	n = length(s)
	f = 0
	for i in 1:n
		if i%2==1&&s[i]=='L'
				f = 1
				break
		elseif i%2==0&&s[i]=='R'
			f = 1
			break
		end
	end
	println(f==0?"Yes":"No")
end

main()

Measured memory_bytes: 109684
#include<iostream>
#include<cstdio>
using namespace std;
int main(){


 
  int H,W;

  for( ; ; ){

    cin>>H>>W;

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

    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	if(i>0 && H-1>i && j>0 && W-1>j){
	cout<<".";
      }else{
	cout<<"#";
      }
    }
    
    cout<<endl;
  }

  cout<<endl;
}   
  return 0;
}

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

int main() {
    int a,b,c;
    std::cin>>a>>b>>c;
    if((a<c&&c<b)||b<c&&c<a){
        std::cout<<"Yes"<<'\n';
    }else{
        std::cout<<"No"<<'\n';
    }
    return 0;
}

Measured memory_bytes: 256
import math


def required_num_coins(x, k):
    return max(0, math.ceil(math.log(k / x, 2)))


def compute_prob(n, k):
    return sum(2 ** (-required_num_coins(x, k)) for x in range(1, n + 1)) / n


def main():
    n, k = (int(z) for z in input().split())
    res = compute_prob(n, k)
    print("{:.12f}".format(res))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<iostream>
#include <algorithm>
#include <cstdlib>
#include<string>
using namespace std;
int main(){
  int H;
  int W;
  cin >> H;
  cin >> W;
  int Orb[H];//行ごとのオーブの数
  int Gold[W];//列ごとの金塊の数
  for(int n=0;n<H;n++){
    Orb[n]=0;
  }
  for(int m=0;m<W;m++){
    Gold[m]=0;
  }
  string map[H];
  for(int n=0;n<H;n++){
    cin >> map[n];
    for(int m=0;m<W;m++){
      if(map[n][m]=='O'){
        Orb[n]++;
      }
      if(map[n][m]=='I'){
        Gold[m]++;
      }
    }
  }
  long long int point = 0;

  for(int n=0;n<H;n++){
    for(int m=0;m<W;m++){
      if(map[n][m]=='J'){
        point+=Orb[n]*Gold[m];
      }
      if(map[n][m]=='O'){
        Orb[n]--;
      }
      if(map[n][m]=='I'){
        Gold[m]--;
      }
    }
  }
  cout << point <<endl;
}




Measured memory_bytes: 24068
import sys
import itertools

class RMQ:
    def __init__(self, n):
        self.sz = 1
        self.inf = (1 << 31) - 1
        while self.sz < n: self.sz = self.sz << 1
        self.dat = [self.inf] * (2 * self.sz - 1)
    
    def update(self, idx, x):
        idx += self.sz - 1
        self.dat[idx] = x
        while idx > 0:
            idx = (idx - 1) >> 1
            self.dat[idx] = min(self.dat[idx * 2 + 1], self.dat[idx * 2 + 2])
            
    def query(self, a, b):
        return self.query_help(a, b, 0, 0, self.sz)
            
    def query_help(self, a, b, k, l, r):
        if r <= a or b <= l:
            return sys.maxint
        elif a <= l and r <= b:
            return self.dat[k]
        else:
            return min(self.query_help(a, b, 2 * k + 1, l, (l + r)>>1),
                        self.query_help(a, b, 2 * k + 2, (l + r) >> 1, r))
    
    
if __name__ == '__main__':
    line = sys.stdin.readline()
    n, q = line.split()
    n, q = int(n), int(q)
    rmq = RMQ(n)
    
    for i in range(q):
        line = sys.stdin.readline()
        op, a, b = line.split()
        op, a, b = int(op), int(a), int(b)
        if op == 0: 
            rmq.update(a, b)
        else: 
            sys.stdout.write(str(rmq.query(a, b + 1)) + '\n')
    

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

int main() {
  long long int n;
  string s;
  cin >> n >> s;

  long long int ans = 1, num = 0;
  rep(i, 2*n){
    if (s[i] == 'W' ^ num % 2 == 0) num++;
      else{
        ans *= num;
        ans %= mod;
        num--;
      }
    }
    if (num != 0) ans = 0;
    rep(i, n){
      ans *= (i + 1);
      ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include<cstdlib>
#include<cmath>
#include<string>
#include<algorithm>
#include <iomanip>
#include<iostream>
#include<stack>
#include<queue>
#include<map>
#include <set>
#include <sstream>
#define MAXN 100010
using LL=long long;
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    b%a==0&&b>=a?cout<<a+b<<endl:cout<<b-a<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>


int main(int argc, char const *argv[]) {
  int N;
  scanf("%d", &N);
  if (N < 105) {
    printf("0\n");
    return 0;
  }
  int r = 0;
  for (int i = 105; i <= N; i++) {
    int y = 2;
    for (int k = 3; k < i; k++) {
      if (k % 2 == 0) {
        continue;
      }
      if (i % k == 0) {
        y++;
        // printf("k %d\n", k);
      }
    }
    if (y == 8) {
      r++;
    }
  }
  printf("%d\n", r);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<long long>;

const string YES = "Yes";
const string NO = "No";

void solve(std::string S, std::string T){
    map<char, vll > rs, rt;
    ll N = S.size();
    for(ll i=0; i< N; i++){
        char s = S.at(i), t = T.at(i);

        if(!rs.count(s)) rs[s] = vll(1, i);
        else rs[s].push_back(i);

        if(!rt.count(t)) rt[t] = vll(1, i);
        else rt[t].push_back(i);
    }
    map<char, vll >::iterator it, it2;
    for(it=rs.begin(); it != rs.end(); it++){
        char s = it->first;
        vll v = it->second;
        bool isGood=false;
        for(it2=rt.begin(); it2 != rt.end(); it2++){
            if(it2->second == v) {
                isGood = true;
                break;
            }
        }
        if(isGood) rt.erase(it2);
        else {
            cout << NO << endl;
            return;
        }

    }
    cout << YES << endl;
    return;

}

int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 5268
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<limits>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int main()
{
    int64_t a,b,c;
    cin>>a>>b>>c;
    if (c<=b+a)
    {
        cout<<c+b<<endl;
    }else
    {
        cout<<2*b+a+1<<endl;
    }
    
    

    return 0;
}

Measured memory_bytes: 3644
n = int(input())
a = list()

for i in range(n):
    x,y = map(int,input().split())
    a.append((x,y))
    
a.sort(key = lambda x : (x[1],x[0]))
    
c = 0
ch = 1
for i in range(n):
    if(c+a[i][0]>a[i][1]):
        ch = 0
        break
    else:
        c += a[i][0]
    
if(ch==0):
    print("No")
else:
    print("Yes")

Measured memory_bytes: 74712
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
ll n,m;
vector<ll> v[22];
ll p[22];
int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
      ll k;cin>>k;
      for(int j=0;j<k;j++){
	  ll x;cin>>x;
	  v[i].push_back(x-1);
      }
  }
  for(int i=0;i<m;i++)cin>>p[i];
  ll ans=0;
  for(int i=0;i<(1<<n);i++){
      bool ok=1;
      for(int j=0;j<m;j++){
	  ll cnt=0;
	  for(auto t:v[j]){
	      if((1<<t)&i)cnt++;
	  }
	  if(cnt%2!=p[j])ok=0;
      }
      ans+=ok;
  }
  cout<<ans<<endl;
  return 0;
}


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


using namespace std;

vector<int> v;
int main(){
  int a,b,k;
  cin >> a >> b >> k;
  for(int i = 1; i < 200; i++){
    if((a % i) == 0 && (b % i) == 0) v.push_back(i);
  }
  reverse(begin(v),end(v));


  cout << v[k-1];
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
ll k;
ll nd = 0;
vll num;
void perform(int i, int prev)
{
    if(i == nd)
    {
        k--;
        return;
    }
    if(!i)
    {
        int j = 0;
        FOR(j, 1, 10)
        {
            num.pb(j);
            perform(i+1, j);
            if(!k) return;
            num.pop_back();
        }
    }
    else 
    {
        int m = MAX2(0, prev-1);
        int M = MIN2(prev+1, 9);
        int j;
        FOR(j, m, M+1)
        {
            num.pb(j);
            perform(i+1, j);
            if(!k) return;
            num.pop_back();
        }
    }
}
int main()
{
    she_told_me_dont_worry
    cin>>k;
    int i;
    nd = 0;
    while(k > 0)
    {
        nd++;
        perform(0, 0);
    }
    int si = num.size();
    FOR0(i, si) cout<<num[i];
    cout<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 256
import collections
n = int(input())
s = 10**2
A = []
for i in range(1,s+1):
    for j in range(1,s+1):
        for k in range(1,s+1):
            A.append(i**2 + j**2 + k**2 + i*j + j*k + k*i)
Ac = collections.Counter(A)

for i in range(1,n+1):
    print(Ac[i])

Measured memory_bytes: 50652
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()

using namespace std;

typedef long long ll;

int N;
int c1, c2;

int main() {
  scanf("%d", &N);
  rep(i, 0, N) {
    int a;
    scanf("%d", &a);
    if (a%4 == 0) c1++;
    else if (a%2 == 0) c2++;
  }
  if (c1*2+1 >= N) puts("Yes");
  else if ( c1*2 + c2 >= N) puts("Yes");
  else puts("No");
  
  return 0;

}

Measured memory_bytes: 256
N, P = map(int, input().split())
A = list(map(int, input().split()))

odd = [a % 2 == 1 for a in A].count(True)
even = N - odd

C = [[0] * 51 for i in range(51)]
C[0][0] = 1
for i in range(1, 51):
    C[i][0] = 1
    for j in range(1, i + 1):
        C[i][j] = C[i - 1][j - 1] + C[i - 1][j]

if P == 1 and odd == 0:
    print(0)
else:
    x = 2 ** even
    y = 0
    i = P
    while i <= odd:
        y += C[odd][i]
        i += 2
    print(x * y)

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm> 
#include<cstring>
#define LL long long
using namespace std;
const int N=2e4+5;
int n,t[N];
int main()
{
	scanf("%d",&n);
	if(n==3){printf("2 5 63");return 0;}
	if(n&1)
	{
		t[1]=6;t[2]=2;t[3]=10;t[4]=3;
		t[5]=9;t[6]=4;t[7]=8;t[8]=12;
	}
	else
	{
		t[1]=2;t[2]=10;t[3]=3;t[4]=9;
		t[5]=4;t[6]=8;t[7]=6;t[8]=12;
	}
	for(int i=9;i<=n;i++)t[i]=t[i-8]+12;
	for(int i=1;i<=n;i++)printf("%d ",t[i]);
	return 0;
}

Measured memory_bytes: 384
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=1e5+5;
priority_queue<int>q;int n,k,x;ll res;
int main(){
	scanf("%d%d",&n,&k);
	fp(i,1,n)scanf("%d",&x),q.push(x);
	while(k--)x=q.top(),q.pop(),q.push(x>>1);
	while(!q.empty())res+=q.top(),q.pop();
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 892
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

kk = ["AC", "WA", "TLE", "RE"]
kkx = map (++" x ") kk

main = interact $ printer . solver . parser
parser = tail . words
printer = unlines . zipWith (++) kkx . map show

mp key = length . filter (==key) 
solver xs = map (flip mp xs) kk

Measured memory_bytes: 22560
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

int main() {
  string str;
  cin >> str;

  int r;
  if (str == "SUN") {
    r = 7;
  }
  if (str == "MON") {
    r = 6;
  }
  if (str == "TUE") {
    r = 5;
  }
  if (str == "WED") {
    r = 4;
  }
  if (str == "THU") {
    r = 3;
  }
  if (str == "FRI") {
    r = 2;
  }
  if (str == "SAT") {
    r = 1;
  }

  cout << r << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt(),k = scanner.nextInt();
		int[] l = new int[n];
		for(int i=0;i<n;i++){
			l[i] = scanner.nextInt();
		}
		Arrays.sort(l);
		int sum = 0;
		for(int i=(n-1);i>(n-1-k);i--){
			sum += l[i];
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 22740
# AtCoder Regular Contest 065
# D - 連結 / Connectivity
# https://atcoder.jp/contests/arc065/tasks/arc065_b
import sys
from collections import defaultdict

class UnionFind:
    def __init__(self, n):
        self.parent = [i for i in range(n)]
    def find(self, x):
        if self.parent[x] == x:
            return x
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        self.parent[x] = y

def main():
    N, *KL = map(int, input().split())
    uf = [UnionFind(N) for _ in range(2)]
    for i in range(2):
        for j in range(KL[i]):
            p, q = map(int, input().split())
            uf[i].union(p-1, q-1)

    d = defaultdict(int)
    for i in range(N):
        d[(uf[0].find(i), uf[1].find(i))] += 1

    print(*[d[(uf[0].find(i), uf[1].find(i))] for i in range(N)])

if __name__ == "__main__":
    sys.setrecursionlimit(10**6)
    main()


Measured memory_bytes: 53116
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		int[] a = new int[N];
		long sum = 0;
		for(int i=0;i<N;i++) {
			a[i] = sc.nextInt();
			sum += a[i];
		}

		long min = Integer.MAX_VALUE;
		long sum_order = 0;
		for(int i=0;i<N-1;i++) {
			sum_order += a[i];
			sum -= a[i];
			long diff = Math.abs(sum_order - sum);

			if(min > diff) {
				min = diff;
			}
		}
		System.out.println(min);
	}

}


Measured memory_bytes: 77216
#include <cstdio>
#include <vector>

using namespace std;

typedef long long ll;

vector<ll> a;
int N;
ll now=2;
ll ans;

int main()
{
  scanf("%d", &N);
  for (int i = 0; i < N; i++)
  {
    ll b;
    scanf("%lld", &b);
    a.push_back(b);
  }
  
  ans = a[0] - 1;
  for (int i = 1; i < N; i++)
  {
    if (a[i] == now) {
      now++;
    } else if (a[i] % now == 0) {
      ans = ans + (a[i]/now - 1);
    } else {
      ans += a[i]/now;
    }
  }

  printf("%lld\n", ans);
    
  return 0;
}

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

#define int long long
#define test int t; cin >> t; while (t--)
#define deb(x) cerr << "[" << #x  << " : "<< x << "]\n";
#define debb(x, y) cerr << "\t[" << #x << " : " << x << ", " << #y << " : " << y << "]\n";
#define debv(v) { cerr << #v << " : "; for (auto x : v) cerr << x << ' '; cerr << "\n"; }
#define deb3(x, y, z) cerr << "[ " << #x << ": " << x << " " << #y << ": " << y << " " << #z << ": " << z << " ]\n";
#define pb push_back
#define pp pop_back
#define mkp make_pair 
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define MAX 50000
 
typedef long double ld;
const int N = 1e5 + 10;
const int maxn = 2e6 + 10;

signed main() {
						
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n;
	cin >> n;
	
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

  int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if (a[i] != a[j] && a[j] != a[k] && a[k] != a[i] && a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[k] + a[j] > a[i]) {\
					//deb3 (i+1, j+1, k+1) 
					ans++;
				}
			}
		}
	}
	
	cout << ans;
	
	return 0;
}


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

long long b[60][60];

long long con(int p, int q){
	long long r;
	if (b[p][q] != 0)return b[p][q];
	if (q == 0 || q == p)return 1;
	if (p == 1)return 1;
	r=con(p - 1, q - 1) + con(p - 1, q);
	b[p][q] = r;
	return r;
}
int main(void){
	for (int i = 0; i < 60; i++){
	for (int j = 0; j < 60; j++){
		b[i][j] = 0;
	}
}
	vector<double> a;
	int k;
	int n, m;
	int s, t;
	double x, y, z;
	long long ans;
	s = 100;

	scanf("%d %d %d", &n,&s,&t);
	for (int i = 0; i < n; i++){
		scanf("%lf", &x);
		a.push_back(x);
	}
	z = 0;
	sort(a.begin(), a.end());
	x = 0;
	for (int i = n - s; i < n; i++){
		x = x + a[i];
	}
	x = x / s;
	printf("%f\n", x);
	m = 0;
	for (int i = 0; i < n; i++){
		if (a[i] == a[n - s])m++;
		if (a[i] > a[n - s])k++;
	}
	s = s - k;
	t = t - k;
	ans = 0;
	if (k > 0){
		ans = con(m, s);
	}
	else{
		if (m < t)t = m;
		for (int i = s; i <=t; i++){
			ans = ans + con(m, i);
		}
	}


	printf("%lld\n", ans);


	return 0;
}

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

using namespace std;

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
    if(ch == 'A') return 1;
    else if(ch == 'C') return 2;
    else if(ch == 'G') return 3;
    else if(ch == 'T') return 4;
    else return 0;
}

long long getKey(char str[]){
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++)
    {
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key){return key % M;}
int h2(int key){return 1 + (key % (M-1));}

int find(char str[]){
    long long key, i, h;
    key = getKey(str);
    for ( i = 0;; i++)
    {
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h], str) == 0) return 1;
        else if(strlen(H[h]) == 0) return 0;
    }
    return 0;
}

int insert(char str[]){
    long long key, i, h;
    key = getKey(str);
    for(i = 0; ; i++){
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h], str) == 0 ) return 1;
        else if(strlen(H[h]) == 0){
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for(i = 0; i < n; i++){
        H[i][0] = '\0';
    }
    cin >> n;
    for(i = 0; i < n; i++){
        cin >> com;
        cin >> str;

        if(com[0] == 'i'){
            insert(str);
        }else
        {
            if(find(str)){
                cout << "yes" << endl;
            }else
            {
                cout << "no" << endl;
            }
        }
    }
}


Measured memory_bytes: 17396
import math
s = int(input())
mod = 10**9+7
ans = 0
for i in range(1, s//3+1):
    t = s-3*i
    u = i-1
    v = t+u
    ans += (math.factorial(v)//(math.factorial(t) * math.factorial(u)))%mod
print(int(ans%mod))


Measured memory_bytes: 9176
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include<climits>
using namespace std;

#define MOD 1000000007
#define INF LONG_MAX

int main(){
  int n;
  string S[2];
  cin >> n;
  cin >> S[0];
  cin >> S[1];
  bool pattern,prevPattern;
  long long ans ;
  for(int i = 0; i < S[0].size(); i++){
    if(i+1 < S[0].size() && S[0][i] == S[0][i+1]){
      pattern = true;
      i++;
    }else{
      pattern = false;
    }
    if((!pattern && i == 0) || (pattern && i == 1)){
      if(pattern) ans = 6;
      else        ans = 3;
      prevPattern = pattern;
      continue;
    }else{
      if(!prevPattern){
        ans = ans * 2 % MOD;
      }else if(prevPattern && pattern){
        ans = ans * 3 % MOD;
      }
      prevPattern = pattern;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

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

	ll n = (K - A) / t;
	if (n*t < K - A)n++;
	cout << 2 * n + 1 << endl;
	return 0;
}

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

using namespace std;

int main() {
	int n;
	int suretu[100];
	int counter = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> suretu[i];
	}

	for (int i = 0; i < n; i++) {
		for (int j = n-1; j > i; j--) {
			if (suretu[j] < suretu[j-1]) {
				swap(suretu[j], suretu[j-1]);
				counter++;
			}
		}
	}

	cout << suretu[0] << flush;

	for (int i = 1; i < n; i++) {
		cout << ' ' << suretu[i];
	}

	cout << endl << counter << endl;

	return 0;
}

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

int main() {
  string n;
  cin >> n;
  for(int i = 0; i < 3; i++){
    if(n.at(i) == '1')
      n.at(i) = '9';
    else
      n.at(i) = '1';
  }
  cout << n << endl;
}

Measured memory_bytes: 256
n = int(input())
for i in range(1,n+1):
    if i % 3 == 0 or i % 10 == 3:
        print(" {}".format(i), end='')
    else:
        x = i
        while True:
            x = x // 10
            if x == 0:
                break
            elif x % 10 == 3:
                print(" {}".format(i), end='')
                break
print("")

Measured memory_bytes: 7928