akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef map<pii,set<pii> >::iterator mapit;
typedef multiset<ll>::iterator setit;

const int maxn = 5e5 + 43;
const int maxlog = 10;
const ll mod = 1e18 + 7;
const int sq = 1000 ;
const int inf = 1e9 + 43;
const ld pi = 3.1415926535897932384626433832795028841971693993751;
int cur[maxlog][2];
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout.precision(20) ;
    int n ;
    cin >> n;
    int x = sqrt(n);
    cout << x * x;
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;


int main(void){

    string s; cin>>s;
    deque<char> que;
    int Bcount=0;
    for(int i=s.size()-1;i>=0;i--){
        if(s[i]=='B')Bcount++;
        else{
            if(Bcount>0){
                Bcount--;
                continue;
            }
            que.push_front(s[i]);
        }
    }

    for(auto itr=que.begin();itr<que.end();itr++){
        cout<<*itr;
    }

    //cout<<*s.begin()<<endl;
    //cout<<*s.end()<<endl;

    return 0;

}


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


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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
#include <map>
#include <list>
#include <bitset>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

const double PI  = 3.141592653589793238463;
const int INF = 1000000007;

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

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

Int solve(Int n, Int t, V& as){
    Int ans = 0;
    Int max_a = 0;
    Int min_a = INT_MAX;
    for(int i = 0; i < n; i++){
        min_a = min(min_a, as[i]);
        if(as[i] - min_a > max_a){
            max_a = as[i] - min_a;
            ans = 1;
        }else if(as[i] - min_a == max_a){
            ans++;
        }
    }
    return ans;
}


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

    Int n, t;
    cin >> n >> t;
    V as(n);
    for(int i = 0; i < n; i++){
        cin >> as[i];
    }

    cout << solve(n, t, as) << "\n";

    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int i=0,n=0,k=0,a=0,sum1=0,t=0,l;
  int sum[10000];
  
  scanf("%d",&n);
  
  while(n != 0){
    sum1=0;
    k=n/4;

    for(i=0;i<k;i++){
      scanf("%d",&a);
      sum1=sum1+a;
    }

    sum[t]=sum1;
    t=t+1;
    
    scanf("%d",&n);
  }

  for(l=0;l<t;l++){
  printf("%d\n",sum[l]);
  }

  return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
#define re register
#define inc(i,j,k) for(re int i=head[u];i;i=e[i].nxt)
#define ll long long
using namespace std; 
ll n,x,ans;
void work(ll x,ll y){
	if(x%y==0){
		ans+=2*x-y;
		return; 
	}
	else{
		ans+=2*(x-x%y);
		work(y,x%y);
	}
}
int main(){
	scanf("%lld%lld",&n,&x);
	ans=n;
	n-=x;
	work(max(n,x),min(n,x));
	printf("%lld",ans);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
long long a, b, k;
cin >> a >> b >> k;
 
if(k <= a){
cout << a - k << ' ' << b <<endl;
}else if(k <= a+b){
cout << 0 << ' ' << b - (k-a) <<endl;
}else{
cout << 0 << ' ' << 0 <<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;
typedef long long ll;

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

  vector<int> h(n);//高さを入力する配列
  vector<bool> ok(n,true);//今の時点で条件を満たしているかの配列

  rep(i,n) cin >> h[i];//配列に登録
  //辺を読込んでいく処理
  rep(i,m) {
    int a,b;
    cin >> a >> b;
    --a; --b;//１次配列に入力するため、初期値0を考慮してaとbを-1する
    //条件を満たさない道を配列に登録
    if (h[a] <= h[b]) ok[a] = false;
    if (h[b] <= h[a]) ok[b] = false;
  }

  int ans = 0;
  rep(i,n) if (ok[i]) ans++;//最終的に条件を満たす「true」をカウントする

  cout << ans << endl;
}


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

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] A = new int[3];

    for(int i = 0; i < 3; i++){
      A[i] = sc.nextInt();
    }

    Arrays.sort(A);

    int ans = (A[1] - A[0]) + (A[2] - A[1]);
    System.out.println(ans);
  }
}


Measured memory_bytes: 21716
import functools

import os
import sys

sys.setrecursionlimit(10000)
INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def Yesif(cond):
    print('Yes' if cond else 'No')


def YESIF(cond):
    print('YES' if cond else 'NO')


def yesif(cond):
    print('yes' if cond else 'no')


print(eval(input()))


Measured memory_bytes: 3572
#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 FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  ll m, n, ans = 1, cur;
  cin >> m >> n;
  cur =  m;
  while (n != 0) {
    if (n % 2 == 1) {
      ans *= cur;
      ans %= mod;
    }
    n >>= 1;
    cur *= cur;
    cur %= mod;
  }
  
  cout << ans << endl;


  
  return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));
template <class T>
inline void chmax(T &a, T b)
{
    if (a < b)
        a = b;
}
template <class T>
inline void chmin(T &a, T b)
{
    if (a > b)
        a = b;
}

int main()
{
    cout << fixed << setprecision(30);
    string S, T;
    cin >> S >> T;
    ll N = S.size(), M = T.size();
    vector<vector<ll>> dp(N + 1, vector<ll>(M + 1));
    loop(i, N)
    {
        loop(j, M)
        {
            if (S[i] == T[j])
            {
                chmax(dp[i + 1][j + 1], dp[i][j] + 1);
            }
            chmax(dp[i + 1][j + 1], dp[i][j + 1]);
            chmax(dp[i + 1][j + 1], dp[i + 1][j]);
        }
    }
    string ans;
    while (N > 0 && M > 0)
    {
        if (dp[N][M] == dp[N - 1][M])
        {
            N--;
        }
        else
        {
            if (dp[N][M] == dp[N][M - 1])
            {
                M--;
            }
            else
            {
                N--;
                M--;
                ans = S[N] + ans;
            }
        }
    }
    putout(ans);
    return 0;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	int x,y;cin>>x>>y;
	y-=x*2;
	if(y>=0&&y/2<=x&&y%2==0){
		puts("Yes");
	}
	else puts("No");
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000007
//S.size()

using namespace std;


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef long long ll;


int main(void){
  int N,L;cin>>N>>L;
  VI a(N);
  VI b(N);
  bool jud = false;
  int min = 1000,num,sum = 0;
  for(int i = 0;i < N;i++){
    b[i] = L + i ;
    if(b[i] >= 0)num = b[i];
    else{

     num = -b[i];

    }
    if(num <= min){
      min = num;
      if(b[i]<=0)jud = true;
    }

  }
  for(int t = 0;t < N;t++){
    sum +=b[t];
  }
  if(jud == false)cout<<sum - min;
  else cout<<sum+min;
}


Measured memory_bytes: 256
S = list(input())
L, R = int("".join(S[:2])), int("".join(S[2:]))
if 1 <= L <= 12:
    if 1 <= R <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= R <= 12:
        print("YYMM")
    else:
        print("NA")

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

using namespace std;

#define int 		long long
#define endl		"\n"
#define mod			1000000007
#define IOS			ios::sync_with_stdio(0), cin.tie(0)

vector<int> f;

int power(int a, int n) {
	int res = 1;

	while (n) {
		if (n & 1)
			res = (res * a) % mod;

		n /= 2;

		a = (a * a) % mod;
	}

	return res;
}

int nCr(int n, int r) {
	if (n < r)
		return 0;

	int res = f[n];

	res = (res * 1ll * power(f[r], mod - 2)) % mod;
	res = (res * 1ll * power(f[n - r], mod - 2)) % mod;

	return res;
}

int32_t main() {

	IOS;

	int k;
	string s;
	cin >> k >> s;

	int n = k + s.size();

	int ans = power(26, n);

	f.assign(n + 1, 1);

	f[0] = f[1] = 1;

	for (int i = 2; i <= n; i++) {
		f[i] = (f[i - 1] * i) % mod;
	}

	vector<int> v(n + 1);
	v[0] = 1;
	v[1] = 25;

	for (int i = 2; i <= n; i++) {
		v[i] = (v[i - 1] * 25) % mod;
	}

	int x = 0;

	for (int i = 0; i < s.size(); i++) {
		x = (x + (nCr(n, i) * v[n - i])) % mod;
	}

	ans = (ans - x + mod) % mod;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 35648
n,m,x,y=map(int,input().split())
lx=list(map(int,input().split()))
ly=list(map(int,input().split()))
lx.sort()
ly.sort()
if lx[-1]>=ly[0]:
    print('War')
for i in range(lx[-1]+1,ly[0]+1):
    if x<i<=y:
        print("No War")
        break
    else:
        print('War')

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
	int n,k,l[55],m=0,t,i,j;

	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++)
		scanf("%d",&l[i]);

	for(i=0;i<n;i++)
		for(j=i+1;j<n;j++)
			if(l[i]<l[j]){
				t=l[i];
				l[i]=l[j];
				l[j]=t;
			}
	for(i=0;i<k;i++)
		m+=l[i];
	printf("%d",m);
	return 0;
}

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

char s[311],s1[311],s2[311];
int k,f[311][311][311],n,ans,ma;

int main()
{
	scanf("%s%d",s,&k),n=strlen(s);
	for (int i=0; i<n; i++) s1[i+1]=s[i],s2[i+1]=s[n-i-1];
	for (int i=0; i<=n; i++) 
		for (int j=0; j<=n; j++)
			for (int l=0; l<=k; l++) f[i][j][l]=-114514;
	for (int i=0; i<=n; i++) 
		for (int j=0; j<=k; j++) f[0][i][j]=f[i][0][j]=0;
	for (int i=1; i<=n; i++)
		for (int j=1; j<=n; j++)
			for (int l=0; l<=k; l++)
			{
				f[i][j][l]=max(f[i-1][j-1][l]+(s1[i]==s2[j]),max(f[i-1][j][l],f[i][j-1][l]));
				if (l) f[i][j][l]=max(f[i][j][l],f[i-1][j-1][l-1]+1);
			}
	ans=1;
	for (int i=0; i<n; i++) ans=max(ans,max(2*f[i][n-i][k],2*f[i][n-i-1][k]+1));
	return printf("%d\n",ans),0;
}

Measured memory_bytes: 114944
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) ((x).begin()),((x).end())
using pii = pair <int, int>;
#define int ll
#define INF 0x7f7f7f7f7f7f7f7f
const bool debug = false;
int a[202020], b[202020];
int n;
vector <int> v;
vector <int> v2;
int32_t main()
{
    usecppio
    cin >> n;
    for (int i = 1; i<=n; i++)
    {
        cin >> a[i];
        cin >> b[i];
        if (a[i]>b[i])
            v.push_back(b[i]);
        else if (a[i]<b[i])
            v2.push_back(a[i]);
    }
    if (v.empty() && v2.empty())
        cout << 0 << '\n';
    else
    {
        int ans = 0;
        for (int i = 1; i<=n; i++)
            ans += b[i];
        sort(all(v));
        ans -= v.front();
        cout << ans << '\n';
    }
}

Measured memory_bytes: 896
s = int(input())

last = s % 10

if last == 2 or last == 4 or last == 5 or last == 7 or last == 9:
  print('hon')
elif last == 0 or last == 1 or last == 6 or last == 8:
  print('pon')
else:
  print('bon')

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

int main() {
    int n; cin >> n;
    vector<vector<int>> a(2, vector<int>(n));

    rep(i, n) cin >> a[0][i];
    rep(i, n) cin >> a[1][i];

    int ans = 0;
    rep(i, n) {
        int id = 0, tmp = 0;

        rep(j, n) {
            if (i == j) {
                tmp+=a[id][j];
                id = 1;
                
            }
            tmp += a[id][j];
        }
        ans = max(ans, tmp);
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


signed main() {
  int a,b;cin>>a>>b;
  if(a <= 9 && b <= 9){
    cout << a*b << endl;
  }else{
    cout << -1 << endl;
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using namespace std;


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

    sort(A, A+N);
    sort(B, B+N);
    sort(C, C+N);

    long long count = 0;

    for(int j = 0; j < N; j++){

        long long i = distance(A,lower_bound(A,A+N,B[j]));
        long long k = distance(upper_bound(C,C+N,B[j]),C+N);

        count += i*k;
    }


    cout << count << endl;

    return 0;
}


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

#define reps(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) reps(v, 0, n)
#define lep(v, n) reps(v, 1, n + 1)
#define rreps(v, f, l) for (int v = (l), v##_ = (f); v >= v##_; --v)
#define rrep(v, n) rreps(v, 0, n - 1)
#define rlep(v, n) rreps(v, 1, n)
#define show_a(a, size) rep(a##_it, size) std::cout << a[a##_it] << " \n"[a##_it == a##_it_ - 1];
#define show_v(v) show_a(v, v.size())
#define debug(x) std::cerr << #x << " = " << (x) << "\n";

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

struct Quaternion {
  int x, y, z, w;
  Quaternion(){}
  Quaternion(int k, int j, int i, int x) : x(x), y(i), z(j), w(k) {}
  Quaternion mul(const Quaternion& q) const {
    return Quaternion(
        x * q.w + y * q.z - z * q.y + w * q.x,
        x * q.z - y * q.w + z * q.x + w * q.y,
        x * q.y + y * q.x + z * q.w - w * q.z,
        x * q.x - y * q.y - z * q.z - w * q.w
        );
  }
  void print(){
    printf("%d %d %d %d\n", x, y, z, w);
  }
};

int main()
{
  int n;
  while (n = in(), n){
    rep(i, n){
      Quaternion a(in(), in(), in(), in());
      Quaternion b(in(), in(), in(), in());
      Quaternion c = a.mul(b);
      c.print();
    }
  }
  return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int a,b,c,d; cin >> a >> b >> c >> d;
    if(d == 1) cout << 1 << endl;
    else cout << 0 << endl;
}


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

using namespace std;

int i,j,k;

int main(){
    int k,x;
    cin >>k >>x;
    string ans ="No";

    if(500*k>=x){
        ans="Yes";
    }
    
    cout<<ans<<endl;
    

    
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int *a=new int[n];
for(int i=0;i<n;i++)
cin>>a[i];

int *dp=new int[n];
dp[0]=0;
dp[1]=std::abs(a[1]-a[0]);
//dp[2]=min(dp[1]+std::abs(a[2]-a[1]),dp[0]+std::abs(a[2]-a[0]));
for(int i=2;i<n;i++)
{
dp[i]=min(dp[i-1]+std::abs(a[i]-a[i-1]),dp[i-2]+std::abs(a[i]-a[i-2]));
}
cout<<dp[n-1];
return 0;
}


Measured memory_bytes: 1024
/*
Author: Babin Dutta
*/

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define endl "\n"
#define inf 1e9

int dp[2010][2010];

void solve(){
	int n, x, y; cin>>n>>x>>y;
	for(int i=0;i<2010;i++) for(int j=0;j<2010;j++) dp[i][j] = inf;
	for(int i=1;i<n;i++){
		dp[i][i+1] = 1;
		dp[i+1][i] = 1;
		dp[i][i] = 0;
	}
	dp[n][n] = 0;
	dp[x][y] = 1;
	dp[y][x] = 1;
	vector<int> cnt(2010,0);
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			dp[i][j] = min(abs(i-j), 1+min(abs(x-i)+abs(y-j),
			abs(i-y)+abs(j-x)));
			cnt[dp[i][j]]++;
		}
	}
	for(int i=1;i<n;i++) cout<<cnt[i]<<endl;
}

int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 16000
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> P;
typedef pair<ll,pair<ll,ll> > p;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
static const int MAX_SIZE = 1 << 17; //segment tree のサイズ。この実装では2べきにする必要がある。 2^17 ≒ 1.3 * 10^5

ll dp[2][10][110000];
ll S[110000];

int main(){
    string L;
    cin>>L;
    L="0"+L;
    int N=L.size();
    ll ret=0;
    ll v=1,a=1;
    S[0]=1;
    for(int i=0;i<N;i++){
        S[i+1]=S[i];
        if(L[i]=='1') S[i+1]=S[i+1]*2%MOD;
    }

    for(int i=N-1;i>=1;i--){
        if(L[i]=='1'){
            v=v*2%MOD;
            ret+=a*S[i]%MOD;
        }
        a=a*3%MOD;
    }
    ret+=v;
    cout<<ret%MOD<<endl;
}



Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
 cin>>N;
 long long sum=0;
 int big=-10000000000000;
 int small=100000000;
 for(int i=1;i<=N;i++){
     int a;
     cin>>a;
     sum=sum+a;
     big=max(a,big);
     small=min(a,small);
 }
 cout<<small<<" "<<big<<" "<<sum<<endl;
     
 }


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

using namespace std;
using ll = long long;

int main() {
	int n, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j * i < n; j++) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * お遊び
 *
 * @author s-sugimoto
 */
public class Main {

	/**
	 * 隠蔽
	 */
	private Main() {
	}

	/**
	 * main
	 *
	 * @param args 起動引数
	 */
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String n = scanner.nextLine();

		int result = 0;

		List<Integer> a = new ArrayList<>(Integer.parseInt(n));
		for (int i = 0; i < Integer.parseInt(n); i++) {
			int first = scanner.nextInt();
			int end = scanner.nextInt();
			result += end - first + 1;
		}

		System.out.println(result);
	}

}


Measured memory_bytes: 25684
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
int d=2,h,w,n,sx,sy,gx,gy,ans=-1;
bool dp[111][111][4][11][11];
string s[111];
struct T{
    int y,x,d,l,r,cost;
    T(int a,int b,int c,int f,int e,int w){y=a,x=b,d=c,l=f,r=e,cost=w;}
};
signed main(){
    cin>>h>>w>>n;
    r(i,h)cin>>s[i];
    r(i,h)r(j,w){
        if(s[i][j]=='S')sy=i,sx=j;
        if(s[i][j]=='G')gy=i,gx=j;
    }
    deque<T>q;
    q.push_back(T(sy,sx,2,0,0,0));
    dp[sy][sx][2][0][0]=1;
    while(!q.empty()){
        T a=q.front();q.pop_front();
        d=a.d;
        if(s[a.y][a.x]=='G'){ans=a.cost;break;}
        if(d==0&&s[a.y][a.x]=='S')continue;
        int y=a.y+dy[d];
        int x=a.x+dx[d];
        if(y<0||x<0||y>=h||x>=w)continue;
        if(s[y][x]=='#')continue;
        if(1){
            T t=T(y,x,d,a.l,a.r,a.cost);
            if(dp[y][x][d][a.l][a.r+1])continue;
            dp[y][x][d][a.l][a.r+1]=1;
            q.push_front(t);
        }
        if(a.l<n){
            T t=T(y,x,3-d,a.l+1,a.r,a.cost+1);
            if(dp[y][x][3-d][a.l+1][a.r])continue;
            dp[y][x][3-d][a.l+1][a.r]=1;
            q.push_back(t);
        }
        if(a.r<n){
            T t=T(y,x,d^1,a.l,a.r+1,a.cost+1);
            if(dp[y][x][d^1][a.l][a.r+1])continue;
            dp[y][x][d^1][a.l][a.r+1]=1;
            q.push_back(t);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5556
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define gg(x) getInt(&x)
using namespace std;
typedef long long ll;
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
ll n;
ll dp[maxn];
ll a[maxn];
int main()
{
    gbtb;
    cin>>n;
    repd(i,1,n)
    {
        cin>>a[i];
    }
    dp[1]=0;
    dp[0]=0;
    dp[2]=abs(a[2]-a[1]);
    repd(i,3,n)
    {
        dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));

    }
    cout<<dp[n];
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}

Measured memory_bytes: 5124
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
using namespace std;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	int a,b,c,d[3];
	cin>>a>>b>>c;
	d[0]=a+b;
	d[1]=a+c;
	d[2]=b+c;
	sort(d,d+3);
	cout<<d[0];
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
N, K = gets.strip.split(/\s+/).map(&:to_i)
As = gets.strip.split(/\s+/).map(&:to_i)
num1bit = [0]*40
40.times{|i|
	num1bit[39-i] = As.count{|a| (a>>i)&1 == 1 }
}
f, k, w = 0, 0, 2**40
num1bit.each{|n1| w /= 2
	if N/2 < N-n1 and k+w <= K
		f += (N-n1) * w
		k += w
	else
		f += n1 * w
	end
}
puts f


Measured memory_bytes: 12164
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define DEL_F -1
#define DEL_L -2

struct Node{
  int key;
  struct Node *next;
  struct Node *prev;
};

typedef struct Node * NodePointer;

NodePointer Nil;

NodePointer make1node(int);
NodePointer search(int);
void insert(int);
void delete(int);
void listprint();

int main(){
  int n;
  char **command;
  char str[20];
  int key;
  int i;
  NodePointer head;

  Nil = make1node(-1);
  Nil->next = Nil;
  Nil->prev = Nil;

  head = Nil;

  scanf("%d ",&n);

  command = (char **)malloc(n*sizeof(char *));
  
  for(i=0; i<n; i++){
    fgets(str, 20, stdin);
    command[i] = (char *)malloc((strlen(str)+1)*sizeof(char));
    strcpy(command[i],str);
    command[i][strlen(command[i])-1] = '\0';
  }

  for(i=0; i<n; i++){
    if(!strncmp(command[i],"insert ",7)){
      key = atoi(&command[i][7]);
      insert(key);
    }
    
    else if(!strncmp(command[i],"delete ",7)){
      key = atoi(&command[i][7]);
      delete(key);
    }
    
    else if(!strcmp(command[i],"deleteFirst")){
      delete(DEL_F);
    }
    
    else if(!strcmp(command[i],"deleteLast")){
      delete(DEL_L);
    }
  }

  listprint();

  for(i=0; i<n; i++)
    free(command[i]);
  free(command);
  return 0;
}

NodePointer make1node(int key){
  NodePointer n;

  n = (NodePointer)malloc(sizeof(struct Node));

  n->key = key;

  return n;
}

NodePointer search(int key){
  NodePointer x;
  x = Nil->next;

  while(x!=Nil && x->key!=key)
    x=x->next;

  return x;
}

void insert(int key){
  NodePointer x;

  x = make1node(key);
  
  x->next = Nil->next;
  Nil->next->prev = x;
  Nil->next = x;
  x->prev = Nil;
}

void delete(int key){
  NodePointer x;

  if(key>=0){
    x = search(key);
    if(x!=Nil){
      x->prev->next = x->next;
      x->next->prev = x->prev;

      free(x);
    }
  }

  else{
    if(key==DEL_F)
      x = Nil->next;

    else if(key==DEL_L)
      x = Nil->prev;
      
    x->prev->next = x->next;
    x->next->prev = x->prev;

    free(x);
  }
}

void listprint(){
  NodePointer x;

  for(x = Nil->next; x!=Nil; x=x->next){
    printf("%d",x->key);
    if(x->next!=Nil)
      printf(" ");
  }
  printf("\n");
}



Measured memory_bytes: 110804
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		
		for (long i=1; i<=B; i++) {
			if ((A*i)%B == 0) {
				System.out.println(A * i);
				return;
			}
		}
	}
}

Measured memory_bytes: 21844
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 1000001
#define M 1000000007
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Y cout<<"Yes\n";
#define N cout<<"No\n";
#define print(x)                 cout<<#x<<": "<<x<<endl;
#define print2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define print3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define print4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define print5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define print6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;

void solve()
{
    lli n,k;
    cin>>n>>k;
    lli arr[n+100]={0};
    for(lli i=1;i<=n;i++)
    {
        cin>>arr[i];
    }

    for(lli i=k+1;i<=n;i++)
    {
        // print2(arr[i],arr[i-k])
        if(arr[i]>arr[i-k])
        {
            Y
        }
        else
        {
            N
        }
    }
}
int main()
{
    fast
    #ifndef ONLINE_JUDGE
     freopen("inputc.txt", "r", stdin);
     freopen("outputc.txt", "w", stdout);
    #endif    
    
    // test
    {
        solve();
        // nl
    }
}
//a+b=a?b+2?(a&b)
//__builtin_popcount(number)
//cout<<fixed<<setprecision(8)<<output<<"\n";




Measured memory_bytes: 5212
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
  int N;
  cin>>N;
  int x[N],y[N],h[N],a,b,l=0;
  for(int i=0;i<N;i++){
    cin>>x[i]>>y[i]>>h[i];
    if(h[i]!=0&&l==0){
      a=i;
      l++;
    }
    if(h[i]!=0&&l==1){
      b=i;
      l++;
     }
  }
  int c_x=0,c_y=0;
  for(int a_x=0;a_x<=100;a_x++){
    for(int a_y=0;a_y<=100;a_y++){
      bool check=true;
      if((h[a]-h[b])==(-abs(x[a]-a_x)-abs(y[a]-a_y)+abs(x[b]-a_x)+abs(y[b]-a_y))){
        int H=h[a]+abs(x[a]-a_x)+abs(y[a]-a_y);
        for(int i=0;i<N;i++){
          if(h[i]!=max((H-abs(x[i]-a_x)-abs(y[i]-a_y)),0)){
            check=false;
          }
        }
      }
      else{
        check=false;
      }

      if(check){
        c_x=a_x;
        c_y=a_y;
        break;
      }
    }
  }

  cout<<c_x<<'\t'<<c_y<<'\t'<<(h[a]+abs(x[a]-c_x)+abs(y[a]-c_y))<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, z, w;
    cin >> n >> z >> w;
    int a[n];
    for( int i = 0; i < n; ++i ) cin >> a[i];

    int res = abs( a[n - 1] - w );
    if( n >= 2 ) res = max( res, abs( a[n - 1] - a[n - 2] ) );
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
mod = 998244353
lr = [list(map(int, input().split())) for _ in range(K)]

dp = [0]*(N+1)
tmp = 1
imos = [0]*(N+1)
imos[0] = 0

for i in range(N):
    imos[i] += dp[i]
    if i != 0:
        tmp = imos[i]+tmp
    for k in range(K):
        l, r = lr[k]
        if l+i > N: continue
        dp[l+i] = (dp[l+i]+tmp)%mod
        dp[min(N, r+i+1)] = (dp[min(N, r+i+1)]-tmp)%mod
print(imos[N-1]%mod)

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



int main()
{
//	freopen("D:\\patin.txt","r",stdin);
	int N;
	int* num = new int[1000000];
	int* data = new int[1000000];
	int sum = 0;

	scanf("%d",&N);
	for(int i = 0;i < N;++i){
		scanf("%d",&num[i]);

	}
	sort(num,num+N);
	int len = 0;
	int pre = num[0];
	while(len < N){
		int tmp = 0;
		while(num[len] == pre && len < N){
			++tmp;
			++len;
		}
		if(tmp%2)
			++sum;
		pre = num[len];	
	}
	cout << sum << endl;
	return 0;	
} 

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

using namespace std;


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

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


int main() {
  int N; cin >> N;
  ll a[N];
  ll b[N];
  ll c[N];
  rep(i,N) cin >> a[i] >> b[i] >> c[i];

  ll aa[N]={a[0]};
  ll bb[N]={b[0]};
  ll cc[N]={c[0]};
  //cout <<aa[0] << bb[0] << cc[0] << endl;
  for(int i=1;i<N;i++){
    aa[i] = max(bb[i-1]+a[i], cc[i-1]+a[i]);
    bb[i] = max(cc[i-1]+b[i], aa[i-1]+b[i]);
    cc[i] = max(aa[i-1]+c[i], bb[i-1]+c[i]);
    //cout <<aa[i] << bb[i] << cc[i] << endl;
  }


  ll result= max(max(aa[N-1],bb[N-1]),cc[N-1]);
  cout << result << endl;

}

Measured memory_bytes: 4992
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int N;
    cin >> N;
    vs32 c(N - 1);
    vs32 s(N - 1);
    vs32 f(N - 1);

    rep (i, N - 1)
    {
        cin >> c[i] >> s[i] >> f[i];
    }

    vs32 t(N - 1);
    for (int j = 0; j < N - 1; ++j)
    {
        t[j] = s[j];
        for (int i = j + 1; i < N  - 1; ++i)
        {
            t[i] = max(0, CEIL(t[i - 1] + c[i - 1] - s[i], f[i])) * f[i] + s[i];
        }
        cout << t[N - 2] + c[N - 2] << "\n";
    }
    cout << "0\n";
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    long long int n,i=0;
    scanf("%lld",&n);
    char arr[1000000];
    while(n>26){
        if(n%26!=0){
        arr[i]=n%26+96;
        n=n/26;
        }
        else{
        arr[i]='z';
        n=n/26;
        n--;
        }
        i++;
    }
    if(n%26!=0)
        arr[i]=n+96;
        else
        arr[i]='z';
    for(int j=i;j>=0;j--)
    printf("%c",arr[j]);
}

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

int main() {
  string S;
  cin >> S;
  S = '0' + S;
  cout << ((S[3] == S[4] && S[5] == S[6]) ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    alpha = "abcdefghijklmnopqrstuvwxyz"

    l = 0
    for i in range(1, 12):
        if N - 26 ** i > 0:
            N -= 26 ** i
            l = i
        else:
            break

    l += 1
    N -= 1

    if N == -1:
        N = 26**l - 1

    digi = list()
    for i in range(1, l + 1):
        r, m = divmod(N, 26)
        digi.append(m)
        N = r

    ans = ""
    for d in digi:
        ans += alpha[d]

    print(ans[::-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 9160
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b)
    {
        a=a^b;
        b=a^b;
        a=a^b;
    }
    if(a>c)
    {
        a=a^c;
        c=a^c;
        a=a^c;
    }
    if(b>c)
    {
        b=b^c;
        c=b^c;
        b=b^c;
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,b,c;
  	ci(a>>b>>c);
  ll ans=+a+b+c;
  co(ans-max({a,b,c}))
}

Measured memory_bytes: 256
def rev(s, t):
    xa, ya = s
    xb, yb = t
    X = xb - xa
    Y = yb - ya

    return (X - (3 ** 0.5) * Y) / 2 + xa, (Y + (3 ** 0.5) * X) / 2 + ya


def f(n):
    print(0, 0)
    _f((0, 0), (100, 0), 0, n - 1)
    print(100, 0)


def _f(p1, p2, n, end):

    if n > end:
        return
    xa, ya = p1
    xb, yb = p2
    s = xa + (xb - xa) / 3, ya + (yb - ya) / 3
    t = xa + (xb - xa) * 2 / 3, ya + (yb - ya) * 2 / 3
    u = rev(s, t)
    _f(p1, s, n + 1, end)
    print(s[0], s[1])
    _f(s, u, n + 1, end)
    print(u[0], u[1])
    _f(u, t, n + 1, end)
    print(t[0], t[1])
    _f(t, p2, n + 1, end)


def main():
    f(int(input()))


if __name__ == '__main__':
    main()



Measured memory_bytes: 5712
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define maxn 200010
using namespace std;
typedef long long ll;
ll read()
{
    ll x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
ll m;
ll a[maxn];
ll f[maxn];
int main()
{
    n=read();m=read();
    for(int i=1;i<=n;i++)  a[i]=read();
    ll ans=0;
    for(int i=1;i<n;i++)
    {
        ll l=a[i],r=a[i+1];
        if(l>r)  r+=m;
        ans+=r-l;
        l+=2;
        if(l>r)  continue;
        f[l]++;f[r+1]-=r-l+2;f[r+2]+=r-l+1;
    }
    for(int i=1;i<=m*2;i++)  f[i]+=f[i-1];
    for(int i=1;i<=m*2;i++)  f[i]+=f[i-1];
    for(int i=1;i<=m;i++)  f[i]+=f[i+m];
    ll res=0;
    for(int i=1;i<=m;i++) res=max(res,f[i]);
    printf("%lld\n",ans-res);
    return 0;
}

Measured memory_bytes: 2560
#!python3

import copy

LI = lambda: list(map(int, input().split()))

# input
N, Ma, Mb = LI()
ABC = [LI() for _ in range(N)]

INF = 10 ** 5


def main():
    w = [[INF] * 401 for _ in range(401)]
    w[0][0] = 0
    for a, b, c in ABC:
        l = copy.deepcopy(w)
        for j in range(a, 401):
            for k in range(b, 401):
                l[j][k] = min(w[j][k], w[j - a][k - b] + c)
        w = l

    ans = INF
    n = 400 // max(Ma, Mb) + 1
    for i in range(1, n):
        ans = min(ans, w[Ma * i][Mb * i])
    ans = -1 if ans == INF else ans
    print(ans)


if __name__ == "__main__":
    main()


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

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N;
	static int[] P = new int[42];
	static int[] T = new int[42];

	public static void main(String[] args) {
		while (true) {
			N = sc.nextInt();
			if (N == 0) break;
			for (int i = 0; i < N; ++i) {
				P[i + 1] = sc.nextInt();
				T[i + 1] = sc.nextInt();
			}
			P[N + 1] = 0;
			T[N + 1] = 200000;
			System.out.println(solve());
		}
	}

	static String solve() {
		int[][] dp = new int[N + 2][4];
		int INF = 1 << 28;
		for (int[] a : dp) {
			Arrays.fill(a, INF);
		}
		dp[0][0] = 0;
		for (int i = 1; i <= N + 1; ++i) {
			boolean ok = false;
			for (int j = 0; j < 4; ++j) {
				if (dp[i - 1][j] == INF) continue;
				ok = true;
				if (j != 3 && Math.abs(P[i] - P[i - 1]) * (j + 1) <= T[i] - T[i - 1]) {
					dp[i][j + 1] = Math.min(dp[i][j + 1], dp[i - 1][j] + Math.abs(P[i] - P[i - 1]));
				}
				if (P[i - 1] * (j + 1) + P[i] <= T[i] - T[i - 1]) {
					dp[i][1] = Math.min(dp[i][1], dp[i - 1][j] + P[i - 1] + P[i]);
				}
			}
			if (!ok) {
				return "NG " + (i - 1);
			}
		}
		int min = INF;
		for (int i = 0; i < 4; ++i) {
			min = Math.min(min, dp[N + 1][i]);
		}
		return "OK " + min;
	}
}

Measured memory_bytes: 25396
from functools import reduce
import fractions

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input().rstrip())
    T = []
    for i in range(N):
        T.append(int(input().rstrip()))    
    print(lcm_list(T))
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 5768
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
A_min = min(A)
index = A.index(A_min)
ans = 0
left = index
right = N - 1 - index
if left % (K - 1) != 0:
    right -= K - 1 - left % (K - 1)
elif right % (K - 1) != 0:
    left -= K - 1 - right % (K - 1)
ans += math.ceil(left / (K - 1))
ans += math.ceil(right / (K - 1))   
print(ans)

Measured memory_bytes: 13940
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1001001001
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

const int mod = 998244353;

/*
数直線上にN台のロボットがあり、X_iの位置に存在する
このロボットを動かすとD_i動き、他のロボットと接触するとそのロボットも動く。
動いていないロボットの組み合わせ数を求める。
1 <= N <=2*10^5
-10^9 <= X <= 10^9
1 <= D <= 10^9


ロボットを頂点、影響範囲を有効辺とした有向グラフとして扱える？
辺の数が最大N^2個。厳しそう。
Union Found Treeでは？　頂点間の依存関係が消失する。
たとえば、
1=>2=>3=>4のように波及していくパターンと、
1=>2,3, 3=>4のように波及していくパターンで区別がつかない。

位置をソート⇒縮約し、
x[i]: i番のロボットがi+1 からx[i]番のロボットまでを直接動かす。
のように変換することは容易

そこから、i番のロボットから間接的にどこまで動かすか？を議論するためには、
Segment Treeを使い、[i, x[i]+1)の区間のmaxを後ろから求めていくことで実現される。

y[i]: i番のロボットがy[i]番のロボットまでを間接的に動かす。

dp[i] : i番目以降のロボットの取り得る組み合わせ数とすると、

dp[n] = 2  (最後のロボットを動かすか否か)
dp[i] = dp[i+1] + dp[y[i]+1]
のようにして、
dp[1](コード上ではdp[0])が答えとなる。

依存関係がデータ間にあるときは、依存関係の先のほうからもとめると上手くいくかも。


*/

struct SegmentTree {
private:
    int n;
    vector<int> node;
public:
    SegmentTree(vector<int> v){
        int sz = v.size();
        n = 1; while(n < sz) n*=2;
        node.resize(2*n-1, -1);
        for (int i = 0; i < sz; i++) node[i+n-1] = v[i];
        for (int i = n-2; i>=0; i--) node[i] =max(node[2*i+1], node[2*i+2]);
    }
    void update(int x, int val){
        x += (n-1);
        node[x] = val;
        while(x>0){
            x = (x-1)/2;
            node[x] = max(node[2*x+1], node[2*x+2]);
        }
    }
    int getmax(int a, int b, int k=0, int l=0, int r=-1){
        if (r < 0) r=n;
        if (r <= a || b <= l) return -1;
        if (a <= l && r <= b) return node[k];
        int vl = getmax(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmax(a, b, 2*k+2, (l+r)/2, r);
        return max(vl, vr);
    }
    int getval(int x){
        x += (n-1);
        return node[x];
    }
};


struct Robot{
    ll x;
    ll range;
    Robot(ll x=0, ll range=0) : x(x), range(range){}
};

//例えば、a < bとしたとき昇順ソートとなる
bool cmp(const Robot &a, const Robot &b){
    return a.x < b.x;
}

int main(){
    int n; cin >> n;
    vector<Robot> rb(n);
    rep(i,n) {
        ll x, d; cin >> x >> d;
        rb[i] = {x, d};
    }
    sort(rb.begin(), rb.end(), cmp);

    vector<int> pos(n);
    rep(i, n) pos[i] = rb[i].x;

    vector<int> r(n);
    rep(i, n){
        r[i] = lower_bound(pos.begin(), pos.end(), pos[i] + rb[i].range) - pos.begin();
        r[i] -= 1;
    }

    //show(r);

    SegmentTree st(r);

    for (int i = n-1; i >= 0; i--)
    {
        int tmp = st.getmax(i, st.getval(i)+1);
        st.update(i, tmp);
    }
    
    // rep(i, n){
    //     cout <<i << "::" << st.getval(i) << endl;
    // }

    vector<ll> dp(n+1);
    dp[n] = 1;
    for (int i = n-1; i >= 0; i--)
    {
        dp[i] = dp[i+1] + dp[st.getval(i)+1];
        dp[i] %= mod;
        //cout << i << ":" << dp[i] << endl;
    }
    
    cout << dp[0] << endl;
}


Measured memory_bytes: 8560
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)

	sc.Scan()
	numbers := strings.Split(sc.Text(), " ")
	number1, _ := strconv.Atoi(numbers[0])
	number2, _ := strconv.Atoi(numbers[1])

	if number1*number2%2 == 0 {
		fmt.Println("Even")
	} else {
		fmt.Println("Odd")
	}
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

int main_() {
	char c;
	cin >> c;
	string v = "aeiou";
	string ans = v.find(c)==string::npos ? "consonant" : "vowel";

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


Measured memory_bytes: 256