akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

const int MAX_N = 2000;

int N;
char c[MAX_N * 2];
int a[MAX_N * 2];

int cnt[2][MAX_N * 2][MAX_N + 1];
int plc[2][MAX_N + 1];

void count(){
  int cw[N + 1];
  int cb[N + 1];
  REP(i, N + 1) {
    cw[i] = 0;
    cb[i] = 0;
  }

  REP(i, N * 2) {
    REP(j, N + 1) {
      if(c[i] == 'W' && a[i] > j) cw[j]++;
      if(c[i] == 'B' && a[i] > j) cb[j]++;
      cnt[0][i][j] = cw[j];
      cnt[1][i][j] = cb[j];
    }
  }
}



int main(){
  cin >> N;
  REP(i, N * 2) cin >> c[i] >> a[i];

  count();

  REP(i, N * 2) {
    if(c[i] == 'W') plc[0][a[i]] = i;
    if(c[i] == 'B') plc[1][a[i]] = i;
  }

  int dp[N + 1][N + 1];
  dp[0][0] = 0;

  REP(i, N + 1) {
    REP(j, N + 1) {
      if (i == 0 && j == 0) continue;
      else if(i == 0) {
        dp[i][j] = dp[i][j - 1] + cnt[1][plc[1][j]][j] + cnt[0][plc[1][j]][i];
      } else if (j == 0) {
        dp[i][j] = dp[i - 1][j] + cnt[0][plc[0][i]][i] + cnt[1][plc[0][i]][j];

      } else {
        dp[i][j] = min(dp[i - 1][j] + cnt[0][plc[0][i]][i] + cnt[1][plc[0][i]][j], dp[i][j - 1] + cnt[1][plc[1][j]][j] + cnt[0][plc[1][j]][i]);
      }
    }
  }

  cout << dp[N][N] << endl;;


  return 0;
}


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

int main(){
    string w,t;
    int count=0;
    cin>>w;
    while(cin>>t){
        if(t=="END_OF_TEXT") break;
        else{
            for(int i=0;i<t.size();i++){
                if(t[i]>='A'&&t[i]<='Z') t[i]+=('a'-'A');
            }
            if(w==t) count++;
        }
    }cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
  using namespace std;
  #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 f first
  #define s second
  #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 trace4(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 MOD 1000000007
    

  int gcd(int a,int b)
  {
    if(b==0)
    {
      return a;
    }
    return gcd(b,a%b);
  }
  int32_t main()
  {         
    


      int a,b,c,d;
      cin>>a>>b>>c>>d;

      int ans=b-a+1;

      ans-=((b/c)-(a-1)/c);

      ans-=((b/d)-((a-1)/d));

      int z=(c*d)/gcd(c,d);

      ans+=(b/(z) - (a-1)/(z));
      
      cout<<ans;



      return 0;
  }           

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int freq[3];
int main()
{
    string s;
    cin >> s;
    for(int i = 0;i < s.length();i++)
        freq[s[i] - 'a']++;
    if(abs(freq[0] - freq[1]) <= 1 && abs(freq[0] - freq[2]) <= 1 && abs(freq[1] - freq[2]) <= 1)
    {
        cout << "YES";
        return 0;
    }
    cout << "NO";
    return 0;
}


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

int main(){
    int D; cin >> D;
    if(D == 25){
        cout << "Christmas" << endl;
    } else if (D == 24){
        cout << "Christmas Eve" << endl;
    } else if (D == 23){
        cout << "Christmas Eve Eve" << endl;
    } else if (D == 22){
        cout << "Christmas Eve Eve Eve" << endl;
    }
}

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

using namespace std;

priority_queue<long long int> que;
long long int N;

// vector<long long int> seen;

// bool check357(long long int num) {
//     long long int numm=num;
//     int counter[3]={};
//     int ref[3]={3, 5, 7};
//     bool flag=true;
//     while(numm) {
//         for(int i=0; i<3; i++) {
//             if(numm%10==ref[i]) {
//                 counter[i]++;
//                 if(counter[0]>0 && counter[1]>0 && counter[2]>0) {
//                     for(int j=0; j<seen.size(); j++) {
//                         if(seen[j]==num) {
//                             flag=false;
//                         }
//                     }
//                     if(flag) {
//                         seen.push_back(num);
//                         return true;
//                     }
//                 }
//             }
//         }
//         numm /= 10;
//     }
//     return false;
// }

// long long int calc357(int cur, long long int num357, int diglim, long long int lim) {
//     if(cur==diglim) {
//         if(check357(num357) && lim>=num357) {
//             return 1;
//         } else {
//             return 0;
//         }
//     }

    
//     long long int sum0=calc357(cur+1, num357, diglim, lim);
//     long long int sum3=calc357(cur+1, num357*10+3, diglim, lim);
//     long long int sum5=calc357(cur+1, num357*10+5, diglim, lim);
//     long long int sum7=calc357(cur+1, num357*10+7, diglim, lim);

//     return sum0+sum3+sum5+sum7;
// }

void dfs(long long int n, int flag3, int flag5, int flag7) {
    if(N>=n) {
        if(flag3 && flag5 && flag7) {
            que.push(n);
        }
        n *= 10;
        
        dfs(n+3, flag3+1, flag5, flag7);
        dfs(n+5, flag3, flag5+1, flag7);
        dfs(n+7, flag3, flag5, flag7+1);
    }
}

int main() {
    // long long int N;
    cin >> N;
    // long long int n=N;
    // int count=0;
    // while(n) {
    //     count++;
    //     n/=10;
    // }
    
    // cout << calc357(0, 0, count, N) << endl;
    
    dfs(0, 0, 0, 0);

    cout << que.size() << endl;
    
    return 0;
    
}

Measured memory_bytes: 640
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define PREP(it,array) for(vector<P>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)

#define MP       make_pair
#define PB       push_back
#define ALL(x)   (x).begin(),(x).end()

const int INF = 1<<29;
const double EPS = 1e-9;
double zero(double d){
  return d < EPS ? 0.0 : d;
}

typedef long long LL;
typedef pair<int,int> P;

void setMap( map<string,int>& m, string v, int& i ){
  if( m.find(v) == m.end() ){
    m.insert( MP(v,i++) );
  }
}

int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(7);

  int n,m;
  while( cin>>n>>m, n ){
    string s,p,g;
    cin >>s>>p>>g;

    int count = 0;

    map<string,int> tab;
    setMap(tab,s,count);
    setMap(tab,p,count);
    setMap(tab,g,count);

    int d[n+1][n+1];
    REP(i,n+1){
      fill(d[i],d[i]+n+1,INF);
      d[i][i] = 0;
    }

    REP(_t,m){
      string a,b;
      int dis,t;
      cin >> a>>b>>dis>>t;
      setMap(tab,a,count);
      setMap(tab,b,count);
      d[tab[a]][tab[b]] = d[tab[b]][tab[a]] = dis/40 + t;
    }

    REP(k,n+1){
      REP(i,n+1){
	REP(j,n+1){
	  d[i][j] = min( d[i][j], d[i][k] + d[k][j] );
	}
      }
    }

    cout << d[tab[s]][tab[p]] + d[tab[p]][tab[g]] << endl;
  }

  return 0;
}

Measured memory_bytes: 2248
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#define MAX_N 100001
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
int main()
{
  long long int ind,N,M,a[101],b[101],c[101],d[101],m;
  cin >> N >> M;
  REP(i,N)cin >> a[i] >> b[i];
  REP(i,M)cin >> c[i] >> d[i];
  REP(i,N){
    m = 9.0E8+1;
    ind = -1;
    REP(j,M){
      if(m > abs(a[i]-c[j]) + abs(b[i]-d[j])){
        m = abs(a[i]-c[j]) + abs(b[i]-d[j]);
        ind = j+1;
      }
    }
    cout << ind << endl;
  }
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.System.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static void solve() throws Exception {
        int K = scanInt();
        String S = scanString();
        if (S.length() <= K) {
            out.print(S);
        } else {
            out.print(S.subSequence(0, K) + "...");
        }
    }

    static int scanInt() throws IOException {
        return parseInt(scanString());
    }

    static long scanLong() throws IOException {
        return parseLong(scanString());
    }

    static String scanString() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        }
        catch (Throwable e) {
            e.printStackTrace();
            exit(1);
        }
    }
}

Measured memory_bytes: 36368
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int c[][] = new int[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                c[i][j] = sc.nextInt();
            }
        }
        boolean ans = true;
        for (int i = 0; i < 2; i++) {
            int left = c[i + 1][0] - c[i][0];
            int center = c[i + 1][1] - c[i][1];
            int right = c[i + 1][2] - c[i][2];
            if (left != center || center != right || right != left) {
                ans = false;
            }
        }
        for (int j = 0; j < 2; j++) {
            int up = c[0][j + 1] - c[0][j];
            int center = c[1][j + 1] - c[1][j];
            int down = c[2][j + 1] - c[2][j];
            if (up != down || up != center || down != center) {
                ans = false;
            }
        }
        if (ans) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23124
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    int H, sum=0, tmp;
    int N;
    cin >> H >> N;
    rep(i, N) {
        cin >> tmp;
        sum += tmp;
    }
    if (sum >= H) cout << "Yes" << endl;
    else cout << "No" << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
//#define int long long
const int mod=998244353;
const int N=1035;
int n,m,ans,p,a[N],L[N],R[N],sum[N][N];
char s[N][N];
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	n=read();m=read();p=read();
	for(int i=1;i<=n;i++)
		scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+(s[i][j]=='1');
	ans=1e9;
	for(int i=0;i<(1<<(n-1));i++)
	{
		int gs=0,res=0;
		for(int j=1;j<n;j++)
			if(i&(1<<(j-1)))a[++gs]=j;
		L[1]=1;
		for(int j=1;j<=gs;j++)
		{
			R[j]=a[j];
			L[j+1]=a[j]+1;
		}
		res=gs;
		R[++gs]=n;
		int lst=0;
		for(int j=1;j<=m;j++)
		{
			for(int k=1;k<=gs;k++)
			{
				if(sum[R[k]][j]-sum[L[k]-1][j]-sum[R[k]][j-1]+sum[L[k]-1][j-1]>p)
				{
					goto wcy;
				}
			}
			for(int k=1;k<=gs;k++)
			{
				if(sum[R[k]][j]-sum[L[k]-1][j]-sum[R[k]][lst]+sum[L[k]-1][lst]>p)
				{
					res++;
					lst=j-1;
					goto xjh;
				}
			}
			xjh:;
		}
		ans=min(ans,res);
		wcy:;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int N=sc.nextInt();
		int player[][]=new int[N][3]; //ゲーム数,何人目
		int point[][]=new int[N][3];
		int result[]=new int[N];
		for(int i=0;i<N;i++){
			for(int j=0;j<3;j++){
				int input =sc.nextInt();
				player[i][j]=input;//書いた数を得点としておく
				point[i][j] = input;//書いた数を得点としておく
			}
		}
		for(int i=0;i<3;i++){//３回分
			for(int j=0;j<N;j++){//j人目を決定
				for(int k=j+1;k<N;k++){//j人目以降で同じ人を探す。
					if(player[j][i]==player[k][i]){
						point[j][i]=0;
						point[k][i]=0;
						break;
				}
				}
			}
		}
		for(int i=0;i<N;i++){//３回分のポイントを出力
			for(int j=0;j<3;j++){
				result[i]+=point[i][j];
			}
		}
		for(int i=0;i<N;i++){//Nこ出力
			System.out.println(result[i]);
		}
	}
}

Measured memory_bytes: 21256
#include <iostream>
#include <cmath>
#include <limits>
#include <vector>
#include <iomanip>
using namespace std;

int num;
vector<pair<double, double>> vec;
double sumOfDis;


void recursive(vector<int> flag, double sum, int current){
  bool flagIsFull = true;
  for(int i=0; i<num; i++){
    if(flag[i] == 0){
      double copySum = sum;
      double dis = sqrt(pow((vec[current].first - vec[i].first), 2)+pow((vec[current].second - vec[i].second), 2));
      copySum += dis;
      flag[i] = 1;
      recursive(flag, copySum, i);
      flag[i] = 0;
      flagIsFull = false;
    }
  }
  if(flagIsFull){
    sumOfDis += sum;
  }
}
 

int main() {
  sumOfDis = 0;
  cin >> num;
  for(int j=0; j<num; j++){
  	double a, b;
    cin >> a >> b;
    vec.push_back(make_pair(a, b));
  }
  for(int j=0; j<num; j++){
    vector<int> flag(num, 0);
    flag[j] = 1;
    recursive(flag, 0, j);
  }
  double roots = num;
  for(int j=num-1; j>0; j--){
    roots *= j;
  }
  cout << std::fixed << std::setprecision(10) << (sumOfDis / roots) << endl;
  return 0;
}   



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

using namespace std;
using ll = long long;

int main() {
	
	int K, X;
	cin >> K >> X;
	
	for(int i=-1000000; i<=1000000; i++){
		if(abs(X-i) <= K-1) printf("%d ", i);
	}
	
	return 0;
}


Measured memory_bytes: 256
a=input()
a=a.split()
b=0
while b==0:
    
    a[2]=int(a[2])-int(a[1])
    if int(a[2])<=0:
        print("Yes")
        break
    a[0]=int(a[0])-int(a[3])
    if int(a[0])<=0:
        print("No")
        break


Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


vector<P> vp;
ll dp[2010][2010];

int main(){
    ll n;
    cin >> n;
    rep(i, n){
        ll a;
        cin >> a;
        vp.push_back({a,i});
    }
    sort(vp.begin(), vp.end());
    reverse(vp.begin(), vp.end());
    
    rep(i, n + 1){
        for (int j = 0; j + i <= n; j++){
            ll cl = vp[i+j].first * (vp[i+j].second - i);
            ll cr = vp[i+j].first * (n - j - 1 - vp[i+j].second);
            dp[i+1][j] = max(dp[i+1][j], dp[i][j] + cl);
            dp[i][j+1] = max(dp[i][j+1], dp[i][j] + cr);
        }
    }

    ll ans = 0;
    rep(i, n) ans = max(ans, dp[i][n-i]);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 26264
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
#define MOD (int)1e9+7
int dx4[]={1,0,-1,0};
int dy4[]={0,-1,0,1};
typedef long long int ll;
typedef unsigned long long int ull;
ll gcd(ll x,ll y){if(!y)return x;return gcd(y,x%y);}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
void swap(ll *x,ll *y){ll tmp=*x;*x=*y;*y=tmp;}
int asc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}
typedef struct pair_{
    int x;
    int y;
}pair_t;

int main(){
    ll x;scanf("%lld",&x);

    ll a,b;
    a=x/500;
    x%=500;
    b=x/5;

    printf("%lld\n",a*1000+b*5);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
int num[4 + 1][3 + 1][10 + 1];
int main() {
    int b, f, r, v, n;
    cin >> n;
    while (n--) {
        cin >> b >> f >> r >> v;
        num[b][f][r] += v;
    }
    for (int i = 1; i <= 4; i++) {
        for (int j = 1; j <= 3; j++) {
            for (int k = 1; k <= 10; k++) {
                cout << " " << num[i][j][k];
            }
            cout << endl;
        }
        if (i != 4) cout << string(20, '#') << endl;
    }
    return 0;
}


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

const int inf = 1e9 + 35;

signed main () {
    int n, m;
    cin >> n >> m;
    int g[n + 1][n + 1];
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) 
            g[i][j] = inf;
        g[i][i] = 0;
    }
    int a[m], b[m], c[m];
    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i] >> c[i];
        g[a[i]][b[i]] = c[i];
        g[b[i]][a[i]] = c[i];
    }
    for (int k = 1; k <= n; ++k) {
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= n; ++j)
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
        }
    }
    int ans = m;
    for (int i = 0; i < m; ++i) {
        for (int j = 1; j <= n; ++j) {
            if (c[i] + g[j][a[i]] == g[j][b[i]]) {
                --ans;
                break;
            }
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

// #define int ll
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'
#define hyphen() cerr << "--\n"

#define fst first
#define pb push_back

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

int bigger(int a, int b) {
    return a >= b ? a : b;
}

int smaller(int a, int b) {
    return a >= b ? b : a;
}


signed main() {
    int N, A, B;

    cin >> N >> A >> B;

    int max = 0;
    int min = 101;
    FORE(c, 0, N) {
        int cand = A + B + c - N;
        debug(cand);

        if (cand >= 0 && cand <= smaller(A,B)) {
            if (cand > max) {
                max = cand;
            }

            if (cand < min) {
                min = cand;
            }
        }
    }

    cout << max << " " << min << endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a[15],b;
  for(int i=0;i<10;i++){;
    cin>>b;
    if(i==3){
      cout<<"8";
    }
    else{
      cout<<b;
    }
  }
  cout<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF=INT_MAX;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

int rd(int num){
	return min(255,max(0,num));
}

int dp[20002][256];
int main(){
	int N,M;
	while(cin>>N>>M){
		if(N==0)return 0;
		vector<int>C(M),x(N);
		REP(i,M)cin>>C[i];
		REP(i,N){
			cin>>x[i];
		}
		REP(i,20002)REP(j,256)dp[i][j]=INT_MAX;
		dp[0][128]=0;
		REP(i,N){
			REP(j,256){
				if(dp[i][j]==INT_MAX)continue;
				REP(k,M){
					int yn=rd(C[k]+j);
					//cout<<yn<<endl;
					int sum2=(x[i]-yn)*(x[i]-yn);
					dp[i+1][yn]=min(dp[i+1][yn],dp[i][j]+sum2);
				}
			}
		}
		int res=INT_MAX;
		REP(i,256)res=min(res,dp[N][i]);
		cout<<res<<endl;
	}
	return 0;
}
/*
1 -100 4
-1,1,2
*/

Measured memory_bytes: 21272
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <map>

#define AS(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
long long int MOD = 1000000007;
long long int INF = 10000000007;

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

int main() {
  int N;
  cin >> N;
  int A[N];
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<int> v;
  map<int,bool> m;
  for(int i = 0; i < N; i++) {
    auto it = m.find(A[i]);
    if(it != m.end()) {
      m[A[i]] = !m[A[i]];
    } else {
      v.push_back(A[i]);
      m[A[i]] = true;
    }
  }
  int ans = 0;
  for(int i = 0; i < v.size(); i++) {
    if(m[v.at(i)]) ans++;
    m[v.at(i)] = false;
  }
  cout << ans << endl;
}


Measured memory_bytes: 5752
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        s: u64,
        p: [(u64, u64); n],
    }
    if p[0].0 > s {
        let ans = p[n - 1].0 - s;
        println!("{}", ans);
        return;
    }
    if p[n - 1].0 < s {
        let ans = s - p[0].0;
        println!("{}", ans);
        return;
    }
    let k = p.iter().position(|p| p.0 > s).unwrap();
    let mut x = p;
    let mut y = x.split_off(k);
    x.reverse();
    let mut ans = y.last().unwrap().0 - x.last().unwrap().0;
    let mut pos = if x.last().unwrap().1 >= y.last().unwrap().1 {
        x.last_mut().unwrap().1 += y.pop().unwrap().1;
        true
    } else {
        y.last_mut().unwrap().1 += x.pop().unwrap().1;
        false
    };
    while x.len() > 0 && y.len() > 0 {
        let &(a, b) = x.last().unwrap();
        let &(c, d) = y.last().unwrap();
        if b >= d {
            x.last_mut().unwrap().1 += y.pop().unwrap().1;
            if !pos {
                ans += c - a;
                pos ^= true;
            }
        } else {
            y.last_mut().unwrap().1 += x.pop().unwrap().1;
            if pos {
                ans += c - a;
                pos ^= true;
            }
        }
    }
    if let Some((x, _)) = x.pop() {
        ans += s - x;
    }
    if let Some((y, _)) = y.pop() {
        ans += y - s;
    }
    println!("{}", ans);
}

fn main() {
    run();
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n,k;cin >> n>>k;
    vector<lint> v(3*n);
    //REP(i, n) { cin >> v[i]; }
    lint ans=0;

    FOR(i,k,k+3*n){
        //cout <<i<<  " ";
        v[i - k] = i;
    }

    //cout<< n * (2 * k + 2 * n - 1) << "\n"; //a+b
    //cout << n * (2 * k + 5 * n - 1) / 2 << "\n";

    lint a_b = n * (2 * k + 2 * n - 1);
    lint csum = n * (2 * k + 5 * n - 1) / 2;
    if(a_b>csum){
        cout << -1 << "\n";
        return 0;
    }
   

    REP(i,3*n){
       // cout << v[i] << " ";
    }
    //cout << "\n";
    vector<lint> a(n),b(n),c(n);
    REP(i,n){
        a[i] = v[i];
        b[i] = v[i+n];
        c[i] = v[i+2*n];
    }
    /*
    REP(i, n)cout << a[i]<<" ";
    cout << "\n";
    REP(i, n)
    cout << b[i] << " ";
    cout << "\n";
    REP(i, n)
    cout << c[i] << " ";
    cout << "\n";
    */
    

        lint num = 0;
        IREP(i, n)
        {
            if (a[0] + b[i] <= c[0])
            {
                num = i;
                break;
            }
    }
    //cout << num <<"\n";
    vector<pair<lint, plint>> p(n);
    //vector<vector<lint>> p(n,vector<lint>(3));
    vector<lint> used(100000000);

    REP(i,n){
        lint index = i + num;
        if(index>=n){
            index -= n;
        }
        lint c_index = i * 2;
        if (c_index >= n)
        {
            c_index -= n;
        }
        while(true){
            
        if (used[c[c_index]]==0){
            p[i].first = c[c_index];
            used[c[c_index]] = 1;
            break;
        }else{
            c_index++;
        }
                }
        p[i].second.first = a[i];
        p[i].second.second = b[index];

       // cout << a[i]<<" " <<b[index]<<"  "<<a[i]+b[index]<< "\n";
    }
    sort(ALL(p));
    REP(i,n){
        cout << p[i].second.first << " " << p[i].second.second<<
        " "<< p[i].first << "\n";
    }

        return 0;
}

Measured memory_bytes: 790656
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  vector<ll> vec(n, 0);
  rep(i, n) cin >> vec.at(i);
  ll ans =0;
  rep(i, n) {
    reps(j,i+1, n) {
      reps(k, j+1, n) {
        if (vec.at(i) == vec.at(j)) continue;
        if (vec.at(i) == vec.at(k)) continue;
        if (vec.at(j) == vec.at(k)) continue;
        bool a = vec.at(i) - vec.at(j) < vec.at(k) && vec.at(i) + vec.at(j) > vec.at(k);
        bool b = vec.at(j) - vec.at(k) < vec.at(i) && vec.at(j) + vec.at(k) > vec.at(i);
        bool c = vec.at(k) - vec.at(i) < vec.at(j) && vec.at(k) + vec.at(i) > vec.at(j);
        if (a && b && c) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
# include <iostream>
#include <math.h>
#include <string>

using namespace std;

typedef long long ll;



int main() {
	ll n, x, t;
	cin >> n >> x >> t;

	if (n % x == 0) {
		cout << (ll)(n / x) * t;
	}
	else {
		cout << (ll)(n / x + 1) * t;
	}
}


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

const ll maxs = 1e6 + 7;




int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   ll n,i,tmp;
    set<ll>S;
    cin >> n;
    for(i = 0;i < n;++i)
    {
        cin >> tmp;
        S.insert(tmp);
    }
    
    if(S.size() == n)
        cout << "YES";
    else
        cout << "NO";
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
 
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double eps = 1e-8;
 
#define INF 2147483647
#define X first
#define Y second
#define SZ(a) ((int)a.size())
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define FILL(v,n) memset(v,n,sizeof(v))
#define EB emplace_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep1n(i,n)	for(int i=1;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie();cout.tie();
 
#define MXN 1000000 //10^6

int main(){
	int n;
	cin>>n;
	for(double i=1;i<=50000;i++){
		if(int(i*1.08) == n){
			cout<<i;
			return 0;
		}
	}
	cout<<":(";
}







Measured memory_bytes: 256
// AcCepted

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

string s;

int main() {
    cin >> s;
    bool cond1 = false;
    bool cond2 = false;
    bool cond3 = false;

    if (s[0] == 'A') {
        cond1 = true;
    }
    int capitals[26];
    for (int i = 0; i < 26; i++) {
        capitals[i] = 0;
    }


    for (int i = 2; i < s.size() - 1; i++) {
        if (0 <= s[i] - 'a' && s[i] - 'a' <= 25) {
            continue;
        }
        if (0 <= s[i] - 'A' && s[i] - 'A' <= 25) {
            capitals[s[i] - 'A']++;
        }
    }

    if (capitals[2] == 1 && 0 <= s[1]-'a' && s[1] - 'a' <= 25 && 0 <= s[s.size()-1] - 'a' && s[s.size()-1] - 'a' <= 25) {
        cond2 = true;
    }

    int count = 0;
    for (int i = 0; i < 26; i++) {
        count += capitals[i];
    }
    if (count == 1) {
        cond3 = true;
    }

    if (cond1 && cond2 && cond3) {
        cout << "AC" << endl;
    } else {
        cout << "WA" << endl;
    }

    return 0;
}


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

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  int ans = 0;
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  rep(i, n - 1) {
    x -= a[i];
    if (x < 0) break;
    ans++;
  }
  if (x == a[n - 1]) ans++;

  cout << ans << endl;
}

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

const int INF = 1e9;
int A[200009];

int main() {
    int N; scanf("%d",&N);
    for(int i=1; i<=2*N-1; i++) scanf("%d",&A[i]);
    int l = 1, r = 2*N-1;
    while(l <= r) {
        int m = l+r >> 1;
        int xl = INF, yl = INF;
        for(int i=N; i>=2; i--) {
            if(A[i] <= m && A[i-1] <= m) xl = N-i;
            if(A[i] > m && A[i-1] > m) xl = N-i;
            if(xl != INF) break;
        }
        for(int i=N; i<=2*N-2; i++) {
            if(A[i] <= m && A[i+1] <= m) yl = i-N;
            if(A[i] > m && A[i+1] > m) yl = i-N;
            if(yl != INF) break;
        }
        char res;
        if(min(xl, yl) == INF) {
            if((A[N] <= m) ^ (N%2)) res = 'U';
            else res = 'D';
        }
        else if(xl < yl) {
            if(A[N-xl] <= m) res = 'D';
            else res = 'U';
        }
        else {
            if(A[N+yl] <= m) res = 'D';
            else res = 'U';
        }
        if(res == 'D') r = m-1;
        else l = m+1;
    }
    printf("%d", r+1);
    return 0;
}

Measured memory_bytes: 1024
import bisect
n = int(input())
l_li = list(map(int,input().split()))
l_li.sort()
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        ind = bisect.bisect_left(l_li,l_li[i]+l_li[j])
        num = ind-1 - j
        if num > 0:
            ans += num
print(ans)


Measured memory_bytes: 43244
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using pint=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define el '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define ceil_div(a,b) ((a+(b-1))/b)
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
#define $in(v,n) ;rep(II,0,n)cin>>v[II]
inline void IN(void){return;}
template<typename F,typename... R>inline void IN(F& f, R&... r){cin>>f;IN(r...);}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}


int main(){
    int a, b; IN(a, b);
    cout << max(0, a-(2*b)) << el;
    return 0;
}


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

using namespace std;


// union findの構造体による実装
// spaghetti-source(github)のunion_find.ccから
struct UnionFind {
    vector<int> parent; // parent[root] is the negative of the size.

    explicit UnionFind(int n) : parent(n, -1) {
    };                                       //初期化

    bool unite(int u, int v) {//ノードx,yが属する木を併合
        u = root(u);
        v = root(v);
        if (u == v) return false;
        if (parent[u] > parent[v]) swap(u, v);
        parent[u] += parent[v];
        parent[v] = u;
        return true;
    }

    bool find(int u, int v) {//ノードx,yが同じ木に属するかどうか
        return root(u) == root(v);
    }

    int root(int u) {//ノードuが属する木の根
        return parent[u] < 0 ? u : parent[u] = root(parent[u]);
    }

    int size(int u) {//ノードiを含む木の大きさ
        return -parent[root(u)];
    }
};


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

    vector<pair<int, int>> vt(m);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        vt[i] = make_pair(a - 1, b - 1);
    }

    vector<pair<int, int>> tmp_vt;
    int ans = 0;
    for (int i = 0; i < m; ++i) {
        //辺を1つ減らしてunion-find木を作成
        auto uf = UnionFind(n);
        for (int j = 0; j < m; ++j) {
            if (j != i) uf.unite(vt[j].first, vt[j].second);
        }

        //連結性のチェック
        if (uf.size(0) != n) ans++;
    }

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


Measured memory_bytes: 256
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for s in range(n):
  for g in range(n):
    b = 0
    for via in range(n):
      if A[s][g] > A[s][via] + A[via][g]:
        print(-1)
        exit()
      if A[s][g] == A[s][via] + A[via][g]:
        b += 1
    if b == 2:
      ans += A[s][g]
print(ans//2)

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

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

    int N;
    cin >> N;
    vector<int> X(N);
    for (int i = 0; i < N; i++)
        cin >> X[i];
    sort(X.begin(), X.end());
    int minPoints = INT_MAX;
    for (int P = X.front(); P <= X.back(); P++) {
        int points = 0;
        for (int Xi : X)
            points += (Xi - P) * (Xi - P);
        minPoints = min(minPoints, points);
    }
    cout << minPoints << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <ctime>
#include <map>
#include <queue>
#include <cstdlib>
#include <string>
#include <climits>
#include <set>
#include <vector>
using namespace std;
inline int read(){
	int k=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}
	return k*f;
}
inline void write(int x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
inline void writeln(int x){
	write(x);puts("");
}
int a[2010][2010][2],n,k;
inline int gs(int op,int sx,int sy,int dx,int dy){
	return a[dx][dy][op]-a[sx-1][dy][op]-a[dx][sy-1][op]+a[sx-1][sy-1][op];
}
int main()
{
	n=read();k=read();int K=k*2;
	char c[5];
	for(int i=1;i<=n;i++){
		int x=read(),y=read();scanf("%s",c);
		if(c[0]=='W')a[x%K+1][y%K+1][0]++;else a[x%K+1][y%K+1][1]++;
	}
	for(int i=1;i<=K;i++)
		for(int j=1;j<=K;j++){
			a[i][j][0]=a[i][j][0]+a[i-1][j][0]+a[i][j-1][0]-a[i-1][j-1][0];
			a[i][j][1]=a[i][j][1]+a[i-1][j][1]+a[i][j-1][1]-a[i-1][j-1][1];
		}
	int ans=0;
	for(int i=1;i<=k;i++)
		for(int j=1;j<=k;j++){
			int S1=gs(0,1,1,i-1,j-1)+gs(0,i,j,i+k-1,j+k-1)+gs(0,i+k,j+k,K,K);
			int S2=gs(1,1,1,i-1,j-1)+gs(1,i,j,i+k-1,j+k-1)+gs(1,i+k,j+k,K,K);
			S1+=gs(0,i+k,1,K,j-1)+gs(0,1,j+k,i-1,K);
			S2+=gs(1,i+k,1,K,j-1)+gs(1,1,j+k,i-1,K);
			ans=max(ans,S1+a[K][K][1]-S2);
			ans=max(ans,a[K][K][0]-S1+S2);
		}
	writeln(ans);
	return 0;
}

Measured memory_bytes: 31616
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 20;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
//#define Se second
#define Fi first

int dis[155][155][155];
vector <pair<pii, int>> Vu;
void updated(int a, int b, int c, int d) {
	if (a > 150 || b > 150 || c > 150) return;
	if (dis[a][b][c] == INF) {
		dis[a][b][c] = d;
		Vu.emplace_back(pii(a, b), c);
	}
}
int main() {
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);

	memset(dis, 0x3f, sizeof(dis));
	dis[A][B][C] = 0;
	Vu.emplace_back(pii(A, B), C);

	int ans = INF;
	for (int i = 0; i < Vu.size(); i++) {
		int a = Vu[i].first.first, b = Vu[i].first.second, c = Vu[i].second;
		if (a == b && b == c) return !printf("%d\n", dis[a][b][c]);

		int d = dis[a][b][c] + 1;

		updated(a, b + 1, c + 1, d);
		updated(a + 1, b, c + 1, d);
		updated(a + 1, b + 1, c, d);
		updated(a, b, c + 2, d);
		updated(a, b + 2, c, d);
		updated(a + 2, b, c, d);
	}
	return 0;
}

Measured memory_bytes: 16504
def bubbleSort(A: list, N:int) -> list:
    """
    A[N]	サイズがNの整数型配列。
    i	未ソートの部分の先頭を指すループ変数で、配列の先頭から末尾に向かって移動します。
    j	未ソートの部分の隣り合う要素を比較するためのループ変数で、Aの末尾であるN-1 から開始しi+1 まで減少します。
    """
    has_finished = True
    i = 0
    count = 0
    while has_finished and len(A) > 1:
        has_finished = False
        for j in reversed(range(i + 1, N)):
            if A[j] < A[j - 1]:
                # alter position
                a, b = A[j - 1], A[j]
                A[j - 1], A[j] = b, a
                has_finished = True
                count += 1
        i += 1
    return A, count

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

print(*A)
print(count)



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

int main() {
    while(true) {
    int H,W;
    cin >> H >> W;
    
    if(H == 0 && W == 0) {
        break;
    }
    
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            cout << "#";
        }
        cout << '\n';
    }
    cout << '\n';
    }
}


Measured memory_bytes: 3052
import math
n=int(input())
a=list(map(int,input().split()))
l=[0]*n
r=[0]*n
l[0]=a[0]
r[-1]=a[-1]
for i in range(n-1):
  l[i+1]=math.gcd(l[i],a[i+1])
for i in reversed(range(n-1)):
  r[i] = math.gcd(r[i+1],a[i])

ans=max(l[-2],r[1])
for i in range(1,n-1):
  ans = max(ans, math.gcd(l[i-1],r[i+1]))
print(ans)

Measured memory_bytes: 21248
# 約数を列挙する。配列形式で返す。
def divisors(n)
    ret = []
    i = 1
    while i*i <= n do
        if n % i == 0
            ret.push i
            ret.push n/i unless i*i == n
        end
        i += 1
    end
    ret.sort
end

# nの桁数を数える。 n<=0のときは0を返す。
def digits_cnt(n)
    cnt = 0
    ni = n
    while ni > 0 do
        ni /= 10
        cnt += 1
    end
    return cnt
end

# p divisors(gets.to_i)
# p digits_cnt(gets.to_i)

N = gets.to_i
i = 1
min_fab = 9999
while i*i <= N do
    if N % i == 0
        a = i
        b = N/i
        fab = [digits_cnt(a), digits_cnt(b)].max
        min_fab = fab if min_fab > fab
    end
    i += 1
end
puts min_fab

Measured memory_bytes: 3836
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G ((c=A[a]+A[P[a]]+C[a])%k?c:0)+M(
typedef long long L;using namespace std;map<L,L>T U;L P U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f){return f?B[f]+M(f^f&-f):0;}L S(L a,L i){for(a=G i++)-M(i);i<2e5;i+=i&-i)B[i]+=a;}L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,d-P[f]?P[d]=f,C[d]=I->second,D(d),n=Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}L K(L f){return Z[a=X[f]]>Z[n=X[b]]?n=b,b=f,K(n):abs(M(O[f])-(a-n?-G O[a])-K(P[a]):M(O[b])));}main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(0);Z[a=H[P[++n]]-n?n:0];)for(;!O[a];S(a=H[a],*Z=O[a]=++b))X[a]=n;for(cin>>a;cin>>s>>a>>b;S(H[a],b=O[a]),S(a,b-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}

Measured memory_bytes: 37296
// atcoder/jsc2019-qual/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n, k;
  while (cin >> n >> k) {
    vector<int> a(n);
    cin >> a;

    const lli mod = 1e9 + 7;
    const int N = 2000 + 5;

    static lli same[N];
    fill(same, same + N, 0);
    for (int i = 0; i < a.size(); ++i) {
      for (int j = i + 1; j < a.size(); ++j) {
        same[i] += (a[i] > a[j]);
      }
    }

    static lli small[N];
    fill(small, small + N, 0);
    for (int i = 0; i < a.size(); ++i) {
      for (int j = 0; j < a.size(); ++j) {
        small[i] += (a[i] > a[j]);
      }
    }

    lli y = 0;
    for (int i = 0; i < a.size(); ++i) {
      small[i] %= mod;
      same[i] %= mod;

      lli z = small[i];
      z *= (k * (k - 1) / 2) % mod;
      z %= mod;
      lli p = (same[i] * k) % mod;
      y += (z + p) % mod;
      y %= mod;
    }
    cout << y % mod << endl;
  }

  return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

class QuickFind {
private:
	int n;
	vector< vector< int > > group;
	vector< int > mapping;
	
public:
	QuickFind(int __n) : n(__n), group(__n, vector< int >()), mapping(__n) {
		for_(i,0,n) {
			group[i].push_back(i);
			mapping[i] = i;
		}
	}
	
	void merge(int x, int y) {
		int xi = mapping[x], yi = mapping[y];
		if (group[xi].size() > group[yi].size()) swap(xi, yi);
		for (int i : group[xi]) {
			group[yi].push_back(i);
			mapping[i] = yi;
		}
		group[xi] = vector< int >();
	}
	
	bool same(int x, int y) { return mapping[x] == mapping[y]; }
};

struct Edge {
	int u, v, c;
	bool operator < (const Edge& e) const { return c < e.c; }
};

int main() {
	int n, m;
	while (cin >> n >> m, n > 0) {
		vector< Edge > edge;
		for_(i,0,m) {
			int u, v, c;
			cin >> u >> v >> c;
			--u; --v;
			edge.push_back(Edge{u, v, c});
		}
		
		sort(edge.begin(), edge.end());
		
		QuickFind qf(n);
		
		int cnt = n / 2;
		for_(i,0,m) {
			Edge e = edge[i];
			if (qf.same(e.u, e.v)) continue;
			qf.merge(e.u, e.v);
			--cnt;
			if (cnt == 0) {
				cout << e.c << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 3312
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	memo := make([]bool, 26)

	for _, c := range s {
		memo[c-'a'] = true
	}

	for i, b := range memo {
		if !b {
			fmt.Println("abcdefghijklmnopqrstuvwxyz"[i : i+1])
			return
		}
	}
	fmt.Println("None")
}


Measured memory_bytes: 1280
import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

# available on Google, not available on Codeforces
# import numpy as np
# import scipy


def solve(lst):  # fix inputs here
    console("----- solving ------")

    res = 0

    lst = sorted(lst)
    for i,x in enumerate(lst):
        for j,y in enumerate(lst[i+1:], start=i+1):
            for _,z in enumerate(lst[j+1:], start=j+1):
                if x == y or y == z or x == z:
                    continue
                if x+y > z:
                    res += 1

    # return a string (i.e. not a list or matrix)
    return res


def console(*args):  # the judge will not read these print statement
    print('\033[36m', *args, '\033[0m', file=sys.stderr)
    return

# fast read all
# sys.stdin.readlines()

for case_num in [1]:
    # read line as a string
    # strr = input()

    # read line as an integer
    k = int(input())
    
    # read one line and parse each word as a string
    # lst = input().split()

    # read one line and parse each word as an integer
    lst = list(map(int,input().split()))

    # read matrix and parse as integers (after reading read nrows)
    # lst = list(map(int,input().split()))
    # nrows = lst[0]  # index containing information, please change
    # grid = []
    # for _ in range(nrows):
    #     grid.append(list(map(int,input().split())))

    res = solve(lst)  # please change
    
    # Google - case number required
    # print("Case #{}: {}".format(case_num+1, res))

    # Codeforces - no case number required
    print(res)


Measured memory_bytes: 77700