akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int a,b,c;
int main () {
	cin >> a >> b >> c;
	if (a!=b && a!=c) {
		cout << a << endl;
	} else if (b!=a && b!=c) {
		cout << b << endl;
	} else {
		cout << c << endl;
	}

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

/* ?????¬????´? */
typedef complex<double> Point;
typedef pair<Point, Point> Line;
typedef vector<Point> VP;
const double EPS = 1e-6; // ?¨±?????????^2
const double INF = 1e9;
#define X real()
#define Y imag()
// #define LE(n,m) ((n) < (m) + EPS)
#define LE(n,m) ((n) - (m) < EPS)
// #define GE(n,m) ((n) + EPS > (m))
#define GE(n,m) (EPS > (m) - (n))
#define EQ(n,m) (abs((n)-(m)) < EPS)

// ?????????dot(a,b) = |a||b|cos??
double dot(Point a, Point b) {
  return a.X*b.X + a.Y*b.Y;
}

// ?????????cross(a,b) = |a||b|sin??
double cross(Point a, Point b) {
  return a.X*b.Y - a.Y*b.X;
}

// ??????????????????
int ccw(Point a, Point b, Point c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

// ??´?????¨??????
bool isecLS(Point a1, Point a2, Point b1, Point b2) {
  return cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS;
}

// 2??´????????????
Point crosspointLL(Point a1, Point a2, Point b1, Point b2) {
  double d1 = cross(b2-b1, b1-a1);
  double d2 = cross(b2-b1, a2-a1);
  if (EQ(d1, 0) && EQ(d2, 0)) return a1;  // same line
  assert(!EQ(d2, 0)); // ???????????????
  return a1 + d1/d2 * (a2-a1);
}

// ????§???¢????¬?????????¢???
double area(const VP& ps) {
  double a = 0;
  rep (i, ps.size()) a += cross(ps[i], ps[(i+1) % ps.size()]);
  return a / 2;
}

using pd = pair<double,double>;

int main()
{
    int n;
    cin >>n;
    vector<int> x(n),y(n);
    rep(i,n) cin >>x[i] >>y[i];

    int minx = 100000;
    rep(i,n) minx = min(minx,x[i]);

    rep(i,n)
    {
        x[i] -= minx;
        x[i] *= 2;
    }

    VP p(n);
    rep(i,n) p[i] = Point(x[i],y[i]);

    double whole = abs(area(p));
    double s = 0;
    for(int i=0; i<=4002; i+=2)
    {
        vector<pd> seg;
        rep(j,n)if(x[j]!=x[(j+1)%n] && isecLS(Point(i,-1001),Point(i,1001),p[j],p[(j+1)%n]) && isecLS(Point(i+1,-1001),Point(i+1,1001),p[j],p[(j+1)%n]))
        {
            seg.pb({crosspointLL(p[j], p[(j+1)%n], Point(i,-1001), Point(i,1001)).Y, crosspointLL(p[j], p[(j+1)%n], Point(i+1,-1001), Point(i+1,1001)).Y});
        }

        sort(all(seg));
        reverse(all(seg));
        int SZ = seg.size();
        assert(SZ%2==0);
        for(int j=0; j<SZ; j+=2)
        {
            double a = seg[j].fi - seg[j+1].fi;
            double b = seg[j].se - seg[j+1].se;
            s += (a+b)/2;
        }

    }

    printf("%.10f\n", max(s,whole-s)/2);
    return 0;
}

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) { cin1(x[i]); }
#define ncin2(n, x, y)      REP(i, 0, n) { cin2(x[i], y[i]); }
#define ncin3(n, x, y, z)   REP(i, 0, n) { cin3(x[i], y[i], z[i]); }
#define ncinp(n, p)         REP(i, 0, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }
#define ncin1_1(n, x)       REPE(i, 1, n) { cin1(x[i]); }
#define ncin2_1(n, x, y)    REPE(i, 1, n) { cin2(x[i], y[i]); }
#define ncin3_1(n, x, y, z) REPE(i, 1, n) { cin3(x[i], y[i], z[i]); }
#define ncinp_1(n, p)       REPE(i, 1, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

int main() {
    lli a,b;
    cin2(a,b);

    // true => 白(aの方)
    bool up[50][100];
    bool down[50][100];
    REP(i,0,50) {
        REP(j,0,100) {
            up[i][j] = false;
            down[i][j] = true;
        }
    }

    lli row = 0;
    lli col = 0;
    REP(i,0,a-1) {
        up[row][col] = true;
        col += 2;
        if (col >= 100) {
            row += 2;
            col = 0;
        }
    }
    row = 0;
    col = 0;
    REP(i,0,b-1) {
        down[row][col] = false;
        col += 2;
        if (col >= 100) {
            row += 2;
            col = 0;
        }
    }

    cout << "100 100" << endl;
    REP(i,0,50) {
        REP(j,0,100) {
            if (up[i][j]) {
                cout << '.';
            }
            else {
                cout << '#';
            }
        }
        cout << endl;
    }
    REPE_R(i,49,0) {
        REPE_R(j,99,0) {
            if (down[i][j]) {
                cout << '.';
            }
            else {
                cout << '#';
            }
        }
        cout << endl;
    }
}


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


int main(){
  int n,k;
  char* s;
  scanf("%d",&n);
  s = malloc(sizeof(char)*(n+1));
  scanf("%s %d",s,&k);
  for(int i=0;i<n;i++){
    if(s[i] != s[k-1]){
      s[i] = '*';
    }
    printf("%c",s[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	char a[100010];
	int ans=0;
	cin>>a;
	for(int i=1;i<=strlen(a);i++){
		if(a[i]!=a[i-1]) ans++;
	}
	cout<<ans-1;
	return 0;
}


Measured memory_bytes: 384
var
    n,i: Integer;
    s: Char;
    flag:Boolean;
begin
    readln(n);
    flag:=false;
    for i := 1 to n do
    begin
        read(s);
        if s='Y' then
        begin
            flag:=true;
        end;
    end;
    if flag then 
    begin
        writeln('Four');
    end
    else 
    begin
        writeln('Three');
    end;
end.

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

struct LazySegmentTree {
private:
    int n;
    vector<ll> node,lazy;
    vector<bool> upd;
public:
    LazySegmentTree(vector<ll> v) {
        int sz = v.size();
        n = 1;
        while (n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1,1e9);
        upd.resize(2*n-1,false);
        for (int i = 0;i < sz;++i) node[i+n-1] = v[i];
        for (int i = n-2;i >= 0;--i) node[i] = min(node[i*2+1],node[i*2+2]);
    }

    void eval(int k,int l,int r) {
        if (upd[k]) {
            node[k] = min(node[k],lazy[k]);
            if (r-l > 1) {
                lazy[2*k+1] = min(lazy[2*k+1],lazy[k]);
                lazy[2*k+2] = min(lazy[2*k+2],lazy[k]);
                upd[2*k+1] = upd[2*k+2] = true;
            }
            lazy[k] = 1e9;
            upd[k] = false;
        }
    }

    void update(int a,int b,ll x,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        eval(k,l,r);
        if (b <= l || r <= a) return;
        if (a <= l && r <= b) {
            lazy[k] = min(lazy[k],x);
            upd[k] = true;
            eval(k,l,r);
        } else {
            update(a,b,x,2*k+1,l,(l+r)/2);
            update(a,b,x,2*k+2,(l+r)/2,r);
            node[k] = min(node[2*k+1],node[2*k+2]);
        }
    }

    ll getmin(int a,int b,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        if (b <= l || r <= a) return INT64_MAX;
        eval(k,l,r);
        if (a <= l && r <= b) return node[k];
        ll vl = getmin(a,b,k*2+1,l,(l+r)/2);
        ll vr = getmin(a,b,2*k+2,(l+r)/2,r);
        return min(vl,vr);
    }
};

int main() {
    ll n;
    int q;
    cin >> n >> q;
    ll ans = (n-2)*(n-2);
    LazySegmentTree segx(vector<ll>(n+1,n)),segy(vector<ll>(n+1,n));
    while (q--) {
        int c,d;
        cin >> c >> d;
        if (c == 1) {
            ll x = segx.getmin(d,d+1);
            ans -= x-2;
            segy.update(0,x,d);
        } else {
            ll y = segy.getmin(d,d+1);
            ans -= y-2;
            segx.update(0,y,d);
        }
        // for (int i = 0;i < n;++i) cout << segy.getmin(i,i+1) << " ";
        // cout << ans << newl;
    }
    cout << ans << newl;
}

Measured memory_bytes: 21352
visited, g = ([], [])

def dfs(i):
    visited[i] = True
    ans = 0
    if all(visited):
        visited[i] = False
        return 1
    for j, b in enumerate(g[i]):
        if b and not visited[j]:
            ans += dfs(j)
    visited[i] = False
    return ans


def main():
    global visited, g
    n, m = [int(i) for i in input().split()]
    visited = [False for i in range(n)]
    g = [[False for i in range(n)] for j in range(n)]
    for i in range(m):
        t, f = [int(j)-1 for j in input().split()]
        g[t][f] = True
        g[f][t] = True
    print(dfs(0))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = a + a * a + a * a * a;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 35672
# coding: utf-8
# Your code here!
N,M=map(int,input().split())
ans=1
MOD=10**9+7
for i in range(1,N+1):
    ans*=i
    ans=ans%MOD
for j in range(1,M+1):
    ans*=j
    ans=ans%MOD

if abs(N-M)>=2:
    print(0)
elif abs(N-M)==1:
    print(ans%MOD)
else:
    print(ans*2%MOD)

Measured memory_bytes: 38640
#include<bits/stdc++.h>
#define gc getchar()
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define Rep(i,v) rep(i,0,(int)v.size()-1)
#define lint long long
#define mod 1000000007
#define db double
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
typedef pair<int,int> pii;
typedef set<int>::iterator sit;
inline int inn()
{
    int x,ch;while((ch=gc)<'0'||ch>'9');
    x=ch^'0';while((ch=gc)>='0'&&ch<='9')
        x=(x<<1)+(x<<3)+(ch^'0');return x;
}
#define P(x) (x>=mod?x-=mod:0)
const int N=1000010;int f[N],s[N],ss[N];
int main()
{
    int n=inn(),ans=1,m=(n-1ll)*n%mod;
    rep(i,1,n) f[i]=(i>=3?ss[i-3]:0)+1,P(f[i]),s[i]=s[i-1]+f[i],P(s[i]),ss[i]=ss[i-1]+s[i],P(ss[i]);
    ans+=(n-1ll)*f[n]%mod,P(ans);rep(i,1,n-1) ans+=(lint)m*f[i]%mod,P(ans);return !printf("%d\n",ans);
}



Measured memory_bytes: 11904
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a%b)

n = int(input())
lst = list(map(int,input().split()))
ans = lst.pop(0)
for i in range(n-1):
    b = lst.pop(0)
    ans = gcd(ans,b)
print(ans)

Measured memory_bytes: 14228
// reference : editorial

#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
typedef pair<int, int > Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize 
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(),(a).end()
const long long int mod = 1e9 + 7;

ll cnt_digits(ll N){
    ll digits = 0;
    while(N>0){
        N/=10;
        digits++;
    }
    return digits;
}

int main(){
    ll N, ans=0;
    cin >> N;
    ans = cnt_digits(N);
    for(ll i=2; i*i<=N; i++){
        if(N%i!=0) continue;
        ll j = N/i;
        ll temp = max(cnt_digits(i),cnt_digits(j));
        if(ans>temp) ans = temp;
    }
    COUT(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
main()
{
    ll n;
    cin >> n;
    switch(n){
        case 22: cout << "Christmas Eve Eve Eve\n";break;
        case 23: cout << "Christmas Eve Eve\n";break;
        case 24: cout << "Christmas Eve\n";break;
        case 25: cout << "Christmas\n";break;
    }
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


#define mod 1000000007
#define ll long long int
#define mk make_pair
#define pb push_back
#define xx first
#define yy second


double pi=3.141592653589793238;
const int M = 1e9+7;
const int Nmax=5005;
const int MM = 1e7+1;
const int N=200010;

int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int T=1;
//cin>>T;
while(T--){
ll n,ww;
cin>>n>>ww;
ll w[n+1],v[n+1];
for(int i=1;i<=n;i++)cin>>w[i]>>v[i];
vector<vector<ll> > dp(n+1,vector<ll>(3e5+1,1e18));
int ans=0;
dp[0][0]=0;
for(int i=1;i<=n;i++){
    for(int j=0;j<=300000;j++){
        if(j==0){
            dp[i][j]=0;continue;
        }
        dp[i][j]=dp[i-1][j];
        if(j-v[i]>=0)dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
    }
}
for(int i=300000;i>=1;i--){
    if(dp[n][i]<=ww){
        ans=i;
        break;
    }
}
cout<<ans<<"\n";
}
return 0;
}


Measured memory_bytes: 242388
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int area = a * b;
		int length = 2 * a + 2 * b;
		System.out.println(area + " " + length);
	}
}

Measured memory_bytes: 25908
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;

int main()
{
	int N; cin >> N;
	for (int i = 1; i < 50000; ++i)
	{
		if ((int)(i*1.08) == N)
		{
			cout << i << endl;
			return 0;
		}
	}

	cout << ":(" << endl;

	return 0;
}

Measured memory_bytes: 256
let n = stdin.ReadLine() |> int
let ab = [| for i in 1..n -> stdin.ReadLine().Split() |> Array.map int |]

let sorted = ab |> Array.sortBy(fun [| _; y; |] -> y) 
let doesSuccess =
    let rec f i xTotal =
        let xTotal = xTotal + sorted.[i].[0]
        match n - i - 1,sorted.[i].[1] - xTotal >= 0 with
        | 0, true -> "Yes"
        | _, false -> "No"
        | _, true -> f (i + 1) xTotal
    f 0 0

doesSuccess |> stdout.WriteLine 


Measured memory_bytes: 36008
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int N=1e6+9;
ll y[N];
ll sum[N];
int main()
{
    FASTINOUT;
    ll x,k;
    cin>>x>>k;
    int c=0;
    for (int i=1; i<=x; i++)
    {
        cin>>y[i];
        if (y[i])
            c++;
    }
    if (k>=x-1)
    {
        for (int i=1; i<=x; i++)
            cout<<x<<" ";
        return 0;
    }
    for (int j=1; j<=k; j++)
    {
        memset(sum,0,sizeof sum);
        for (ll i=1; i<=x; i++)
        {
            sum[max(i-y[i],1LL)]++;
            sum[min(i+y[i]+1,x+1)]--;
        }
        int cnt=0;
        for (int i=1; i<=x; i++)
        {
            sum[i]+=sum[i-1];
            y[i]=sum[i];
            if (y[i]<x)
                cnt++;
        }
        if (!cnt)
            break;
    }
    for (int i=1; i<=x; i++)
        cout<<sum[i]<<" ";
    return 0;
}


Measured memory_bytes: 12976
#include<cstdio>

int main(){
    long A,B;
    
    scanf("%ld",&A);
    scanf("%ld",&B);
    
    int first,second,forth,fifth;
    long ans=0;
    while(A<=B){
        first = A/10000;
        second = (A%10000)/1000;
        forth = (A%100)/10;
        fifth = A%10;
        if(first==fifth && second==forth){
            ans++;
        }
        A++;
    }

    printf("%ld",ans);

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define loop(vals,times) for(vals=0;vals<times;vals++)
using namespace std;


int main()
{
    int n,i,j,I,J;
    long long max=-10000000000;
    cin>>n;
    int a[n][n];
    int s[n][n];

    loop(j,n){
    loop(i,n){
    cin>>a[j][i];
    }
    }
    
    loop(j,n)s[j][0]=a[j][0];
    
    loop(i,n)s[0][i]=a[0][i];
    
    loop(j,n){
    loop(i,n-1)s[j][i+1]=s[j][i]+a[j][i+1];
    }
    
    loop(i,n){
    loop(j,n-1)s[j+1][i]=s[j][i]+s[j+1][i];
    }
    
    loop(i,n){
    loop(j,n){
       
    loop(I,n){
        if(i<=I){
    loop(J,n){
        if(j<=J){
            
    if(i!=0&&j!=0){
    if(max<=s[J][I]-s[J][i-1]-s[j-1][I]+s[j-1][i-1])max=s[J][I]-s[J][i-1]-s[j-1][I]+s[j-1][i-1];
    }else if(i==0&&j!=0){if(max<=s[J][I]-s[j-1][I])max=s[J][I]-s[j-1][I];
    }else if(j==0&&i!=0){if(max<=s[J][I]-s[J][i-1])max=s[J][I]-s[J][i-1];
    }else if(i==0&&j==0){if(max<=s[J][I])max=s[J][I];}     
    }
    }
            
    }
    }
        
    }
    }
    cout<<max<<endl;
}



Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


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

	cout << s[0] << t[0] << u[0] << endl;



	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
	public static int max = 0;
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[][] str = new String[n][2];
		ArrayList<String> list = new ArrayList<String>();
		for (int i = 0; i<n ; i++) {
			String line = br.readLine();
			list.add(line);
			str[i] = line.split(" ");
		}
		String[] mark = new String[n];
		int[] num = new int[n];

		for (int i = 0; i<n ; i++ ) {
			mark[i] = str[i][0];
			num[i] = Integer.parseInt(str[i][1]);	
		}

		quicksort(mark,num,0,n-1);


		int i = 1;
		while( i <= num[n-1] ){
			int search = 0;
			for (int j = 0; j<n ; j++ ) {
				if (num[j] == i) {
					int r = list.indexOf(mark[j] + " " + num[j]);
					if (search > r) {
						System.out.println("Not stable");
						i = num[n-1] + 1;
						break;
					}else{
						search = r;
					}
				}
			}
			i++;
			if ( i == num[n-1] + 1) {
				System.out.println("Stable");
			}
		}
		for (int k = 0; k<n ; k++ ) {
			System.out.println(mark[k] + " " + num[k]);
		}

	}

	public static void quicksort(String[] st,int[] a,int p,int r){
		if(p < r){
			int q = partition(st,a,p,r);
			quicksort(st,a,p,q-1);
			quicksort(st,a,q+1,r);
		}
	}

	public static int partition(String[] st,int[] a ,int p,int r){
		int x = a[r];
		int i = p-1;
		for (int j = p; j<r ; j++ ) {
			if (a[j] <= x)  {
				i++;
				int work = a[i];
				a[i] = a[j];
				a[j] = work;

				String workst = st[i];
				st[i] = st[j];
				st[j] = workst;
			}
		}
		int num = a[i+1];
		a[i+1] = a[r];
		a[r] = num;

		String str = st[i+1];
		st[i+1] = st[r];
		st[r] = str;
		return i+1;
	}

	public static void printing(int[] a){
		for (int i = 0; i<a.length ; i++ ) {
			if (i == a.length-1) {
				System.out.println(a[i]);
			}else{
				System.out.print(a[i] + " ");
			}
		}
	}
}

Measured memory_bytes: 82900
#include <iostream>
#include <random>
#include <algorithm>
using namespace std;

#define NM_MAX 12

class Book
{
private:
    unsigned int price;
    vector<int> progress;
    
public:
    unsigned int total_val;
    
    void set_price(unsigned int p){
        price = p;
    }
    
    void set_progress(vector<int> vec){
        progress = vec;
    }

    void calc_total_val(){
        total_val = accumulate(progress.begin(), progress.end(), 0);
    }

    unsigned int get_price(){
        return price;
    }
    unsigned int get_progress(unsigned int i){
        return progress[i];
    }

    bool operator<( const Book& right ) const {
        return total_val < right.total_val;
    }
};



int is_possible(vector<Book> books, unsigned int n, unsigned int m, unsigned int x){
    unsigned int i, j;

    vector<int> sum(m, 0);

    for( j=0; j < m; j++ ){
        unsigned int sum = 0;
        for ( i=0; i < n; i++){
            sum += books[i].get_progress(j);
        }

        if( sum < x ){
            return -1;
        }
    }
    return 1;
}

bool check_progress(vector<unsigned int> vec, unsigned int m, unsigned int x)
{
    unsigned int i;
    for( i=0; i < m; i++){
        if( vec[i] < x ){
            return false;
        }
    }
    return true;
}

int main(){
    unsigned int N, M, X;
    cin >> N >> M >> X;
    
    unsigned int i;
    vector<Book> books(N);
    for( i=0; i < N; i++){
        vector<int> vec(M+1);

        for (unsigned int j = 0; j < M+1; j++) {
            cin >> vec.at(j);
        }

        books[i].set_price(vec[0]);
        vec.erase(vec.begin());
        books[i].set_progress(vec);
        books[i].calc_total_val();
    }

    if( is_possible(books, N, M, X) == -1 ){
        cout << -1 << endl;
        return 0;
    }

    unsigned int case_num = 1 << N;
    unsigned int cheapest_fee = 100000000;

    for( i=0; i < case_num; i++){

        unsigned int j;
        vector<unsigned int> scores(M);
        unsigned int fee = 0;

        for( j=0; j < N; j++){
            if( ((i>>j) & 1) == 0 ){
                continue;
            }

            unsigned int k;
            for( k=0; k < M; k++){
                scores[k] += books[j].get_progress(k);
            }
            fee += books[j].get_price();
        }

        if( check_progress(scores, M, X) == true && cheapest_fee > fee ){
            cheapest_fee = fee;
        }

    }
    cout << cheapest_fee << endl;
    return 0;
}

Measured memory_bytes: 3636
k, n = map(int,input().split())
al = list(map(int,input().split()))

dtlst = [al[0]]
for i in range(1,n):
  dtlst.append(al[i]-al[i-1])
dtlst.append(k - al[-1]+al[0])

print(k - max(dtlst))


Measured memory_bytes: 32300
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n=0,m,k,i=0,s=1;
    cin>>n>>k;
    int a[100005]={0};
    for(i=0;i<n;i++)
        cin>>a[i];
    n-=k;
    k--;
    //cout<<n<<endl;
    while(n>0)
    {
        n-=k;
        s++;
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 640
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

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

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int x, y;
ll a, b, c;

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> a >> b >> c >> x >> y;
	ll ans = a * x + b * y;
	for (int i = 0; i <= 2 * max(x, y); ++i) {
		int nx = max(0, x - i / 2);
		int ny = max(0, y - i / 2);
		ans = min(ans, a * nx + b * ny + c * i);
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 256
//long long -> ll
//http://web.mit.edu/~ecprice/acm/acm08/notebook.html#file12
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include<bits/stdc++.h>
typedef long long ll;
#define x first
#define y second
#define REP(i,sss,eee) for(long long i=sss;i<=eee;++i)
#define pb push_back
#define pii pair<long long,long long>
#define vi vector<long long>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define N 1000000007
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}
typedef tree<
long long,
null_type,
less<long long>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
long long ex(long long a, long long b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	long long tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
long long inv(long long k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
int main(){
	long long n,k;cin>>n>>k;
	vector<long long>inp(n,0);
	REP(i,0,n-1){cin>>inp[i];}
	std::vector<std::vector<long long>> dp(n+1,std::vector<long long>(k+1,0));
	for(long long i=0;(i<=inp[0])&&i<=k;++i){dp[0][i]=1;}
	std::vector<long long> pre(k+1,0);
	for (long long i = 1; i < n; ++i)
	{
		long long sum=0;
		REP(j,0,k)
		{
			sum+=dp[i-1][j];sum%=N;
			pre[j]=sum;
		}
		REP(j,0,k)
		{
			long long s=j-inp[i];
			long long e=j;
			dp[i][j]=(pre[e]-(s<=0?0:pre[s-1]));
			dp[i][j]=(((dp[i][j]%N)+N)%N);
		}
	}
	cout<<dp[n-1][k]<<"\n";
}

Measured memory_bytes: 80256
object Main extends App {
  val scan = new java.util.Scanner(System.in)
  val n    = scan.next().toInt
  val ns   = (1 to n*3).map(_ => scan.next().toLong).toArray

  val p    = collection.mutable.PriorityQueue[Long]()(Ordering.Long.reverse);
  val f    = Array.fill(n+1)(0L)
  var fsum = 0L
  for (i <- 0 until n) {
    p    += ns(i)
    fsum += ns(i)
  }
  f(0) = fsum
  for (i <- (0+n) until (n+n)) {
    p      += ns(i)
    fsum   += ns(i)
    fsum   -= p.dequeue
    f(i-n+1)  = fsum
  }

  val q = collection.mutable.PriorityQueue[Long]();
  val r = Array.fill(n+1)(0L)
  var rsum = 0L
  for (i <- (3*n-1) to (2*n) by -1) {
    q    += ns(i)
    rsum += ns(i)
  }
  r(n) = rsum
  for (i <- (2*n-1) to n by -1) {
    q      += ns(i)
    rsum   += ns(i)
    rsum   -= q.dequeue
    r(i-n)  = rsum
  }

  println(f.zip(r).toList.map(t => t._1 - t._2).max)
}

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

using ll = long long; 
using P = pair<int,int>;

int main() {

  int A, B, K;
  cin >> A >> B >> K;

  int N = __gcd(A, B);
  int count;
  int ans;
  for (int i=N; i>0; i--){
    if(N%(i)==0){
      count++;
      if (count==K){
        ans = i;
        break;
      }
    }
  }

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



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

int main(){
  int n;
  cin>>n;
  int a[111111];
  for(int i=1;i<=n;i++)cin>>a[i];
  int cnt=0;
  for(int i=1;i<=n;i++)if(a[a[i]]==i)cnt++;
  cout<<cnt/2<<endl;
  return 0;
}


Measured memory_bytes: 640
a,b,c,d = map(int,input().split())
e = c // b
f = a // d
g = c % b
h = a % d
if e < f:
    print("Yes")
if e > f+1:
    print("No")
if e == f+1:
    if g == 0 and h !=0:
        print("Yes")
    else:
        print("No")
if e == f:
    if g != 0 and h ==0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 9128
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, K = map(int, readline().split())
    H = [0] + list(map(int, readline().split())) + [0]

    dp = [[INF] * (N + 1) for _ in range(N + 1)]

    for i in range(N + 1):
        dp[i][0] = 0

    for i in range(1, N + 1):
        dp[i][1] = H[i]
        for j in range(2, i + 1):
            for k in range(1, i):
                dp[i][j] = min(dp[i][j], dp[k][j - 1] + max(0, H[i] - H[k]))

    ans = INF
    for i in range(1, N + 1):
        ans = min(ans, dp[i][N - K])
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 77332
from collections import defaultdict

mat = defaultdict(lambda: defaultdict(int))
mat[0][1] = 0

ans = 0
_ = input()

for i, a in enumerate(map(lambda x: int(x), input().split())):
    mat[a-1][i] += 1
    mat[i][a-1] += 1

for i, vec in mat.items():
    for j, val in vec.items():
        ans += val // 2

print(ans // 2)


Measured memory_bytes: 54376
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;

const int inf=2147483647;

int N;
vector<int> val;
void init(int sz){
   N=1; while(N<sz)N<<=1;
   val.resize(2*N,inf);
}
void upd(int a,int b){
   a+=(N-1); val[a]=b;
   while(a){
      a=(a-1)/2;
      val[a]=min(val[a*2+1],val[a*2+2]);
   }
}
int que(int a,int b,int k=0,int l=0,int r=N){
   if(r<=a||b<=l)return inf;
   if(a<=l&&r<=b)return val[k];
   int lb=que(a,b,2*k+1,l,(l+r)/2);
   int rb=que(a,b,2*k+2,(l+r)/2,r);
   return min(lb,rb);
}

int main(){
   int n,q; scanf("%d%d",&n,&q);
   init(n);
   rep(i,0,q){
      int tmp; scanf("%d",&tmp);
      int x,y; scanf("%d%d",&x,&y);
      if(tmp==0)upd(x,y);
      else{y++; printf("%d\n",que(x,y));}
   }
   return 0;
}


Measured memory_bytes: 3828
use proconio::input;

fn main() {
    input! {
        h: usize,
        n: usize,
        v: [(usize,usize); n]
    }

    let dp = {
        let mut dp = vec![vec![100_000_000; h+1]; n+1];
        for i in 0..n {
            dp[i][0] = 0;
            let (a,b) = v[i];
            for x in 0..=h {
                dp[i+1][x] = dp[i][x].min(dp[i+1][if x>a {x-a} else {0}]+b);
            }
        }
        dp
    };

    println!("{}",dp[n][h])
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

template<typename T> bool chmax(T &a,const T b){if(a < b){a=b; return true;} return false;}
template<typename T> bool chmin(T &a,const T b){if(a > b){a=b; return true;} return false;}

int main(){
    int H, W, M; cin >> H >> W >> M;
    vi h(M), w(M);
    map<int, int> mph, mpw;
    set<pii> st;
    int hmaxval=0, wmaxval=0;
    for(int i=0; i<M; i++){
        cin >> h[i] >> w[i];
        h[i]--, w[i]--;
        chmax(hmaxval, ++mph[h[i]]);
        chmax(wmaxval, ++mpw[w[i]]);
        st.insert({h[i], w[i]});
    }

    vi hmax, wmax;
    for(auto p : mph){
        if(p.second == hmaxval) hmax.push_back(p.first);
    }
    for(auto p : mpw){
        if(p.second == wmaxval) wmax.push_back(p.first);
    }
    int ans=hmaxval+wmaxval-1;
    for(auto h : hmax){
        for(auto w : wmax){
            if(!st.count({h, w})){
                ans++;
                goto FIN;
            }
        }
    }
    FIN:
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 51848
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    vector< vector<int> > adj(n);
    for(int i=0; i<k; i++)
    {
        int d;
        cin>>d;
        for(int j=0; j<d; j++)
        {
            int s;
            cin>>s;
            // cout<<s<<'\n';
            adj[s-1].push_back(d);
        }
    }
    int size = adj.size();
    int ans = 0;
    for(int i=0; i<size; i++)
    {
        if(adj[i].size() == 0)
            ans++;
    }
    cout<<ans<<'\n';
}

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

int main()
{
    int n;

    int ans;

    cin >> n;

    if (n == 0)
    {
        ans = 1;
    }
    else
    {
        ans = 0;
    }


    cout << ans << endl;
}



Measured memory_bytes: 3592
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;

struct P {
  int i, j, cost;
};

int main() {
  int l;
  cin >> l;
  if (l == 2) {
    cout << 2 << " " << 2 << endl;
    cout << 1 << " " << 2 << " " << 1 << endl;
    cout << 1 << " " << 2 << " " << 0 << endl;
    return 0;
  }
  int k = 0;
  while (l > (1 << (k + 1)))
    k++;
  vector<P> ps(2 * k);
  for (int i = 0; i < k; i++) {
    ps[2 * i].i = i + 1;
    ps[2 * i].j = i + 2;
    ps[2 * i].cost = 1 << (k - 1 - i);
    ps[2 * i + 1].i = i + 1;
    ps[2 * i + 1].j = i + 2;
    ps[2 * i + 1].cost = 0;
  }
  l -= (1 << k);
  int sum = (1 << k);
  while (l > 1) {
    int k2 = 0;
    while (l > (1 << (k2 + 1)))
      k2++;
    ps.push_back(P{1, k + 1 - k2, sum});
    sum += (1 << k2);
    l -= (1 << k2);
  }
  if (l == 1) {
    ps.push_back(P{1, k + 1, sum});
  }
  cout << k + 1 << " " << ps.size() << endl;
  for (int i = 0; i < ps.size(); i++) {
    cout << ps[i].i << " " << ps[i].j << " " << ps[i].cost << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int A,B,C,D,P;
	cin>>A>>B>>C>>D>>P;
	if(P<=C){
		if(P*A<B){
			cout<<P*A<<endl;
		}else{
			cout<<B<<endl;}
	}else{
		if(P*A<(P-C)*D+B){
			cout<<P*A<<endl;
		}else{
			cout<<(P-C)*D+B<<endl;
		}
	}
		
}


Measured memory_bytes: 3080
#
# Keitai Message
#

class Cellular < Hash
  def initialize
    @buf=[]
    @ptr=['0', -1]
    self.store('1', %w". , ! ?"+[' '])
    self.store('2', %w"a b c")
    self.store('3', %w"d e f")
    self.store('4', %w"g h i")
    self.store('5', %w"j k l")
    self.store('6', %w"m n o")
    self.store('7', %w"p q r s")
    self.store('8', %w"t u v")
    self.store('9', %w"w x y z")
  end

  def push(b)
    if b=='0'
      enter
    else
      @ptr[0]=b
      @ptr[1]=@ptr[1]+1
      @ptr[1]-=self[@ptr[0]].size if @ptr[1]==self[@ptr[0]].size
    end
  end

  def enter
    @buf<<self[@ptr[0]][@ptr[1]] if @ptr[0]!='0'
    @ptr=['0', -1]
  end

  def message
    @buf.join('')
  end

end

gets.to_i.times do

  cell = Cellular.new
  gets.chomp.chars { |c| cell.push(c) }
  puts cell.message

end

Measured memory_bytes: 6104
#include <iostream>
 
using namespace std;
 
int main(int argc, const char *argv[]) {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  while(1){
    C -= B;
    if(C  <= 0){
      cout << "Yes" << endl;
      return 0;
    }
    A -= D;
    if(A  <= 0){
      cout << "No" << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;
const int maxn = 1000;
int a[maxn];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	int ans=0;
	for(int i=n-k;i<n;i++)
	{
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
} 

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

int main(void){
    ll a;
    string s;
    cin >> a >> s;
    int b = 100*(s[0]-'0') + 10*(s[2]-'0') + (s[3]-'0');
    cout << a*b/100 << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.io.*;
 
class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s=br.readLine();
        String p=br.readLine();
        s=s+s;
        if(s.indexOf(p)!=-1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 24568
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0, i##_len=(lli)(n); i<i##_len; i++)
#define repf(i, n) for(lli i=1, i##_len=(lli)(n+1); i<i##_len; i++)
#define per(i, n) for(lli i=((lli)(n))-1; i>=0; i--)
#define perf(i, n) for(lli i=((lli)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    lli n = s.size();
    vi ans(n, 0);

    for(lli i=0; i<n;){
        lli cntr = 0;
        lli cntl = 0;
        lli pos;
        char chkc = 'R';
        while(i<n){
            if(s[i] == chkc){
                if(chkc == 'R') cntr++;
                if(chkc == 'L') cntl++;
                i++;
            }
            else{
                if(chkc == 'R'){
                    chkc = 'L';
                    pos = i;
                }
                else if(chkc == 'L') break;
            }
        }
        if((cntr+cntl)%2 == 0){
            // 偶数長の場合
            ans[pos] = ans[pos-1] = (cntr+cntl)/2;
        }
        else{
            // 奇数長の場合
            if(cntr%2 == 0){
                ans[pos] = ceil((cntr+cntl)/2.0);
                ans[pos-1] = floor((cntr+cntl)/2.0);
            }
            else{
                ans[pos] = floor((cntr+cntl)/2.0);
                ans[pos-1] = ceil((cntr+cntl)/2.0);
            }
        }
    }
    rep(i, n) cout << ans[i] << ((i == n-1) ? endl : " ");
}

Measured memory_bytes: 1488
#include<stdio.h>

int main(void) {
   int A, B;

   scanf("%d %d", &A, &B);
   if((A*B)%2==0) {
      printf("No\n");
   } else if((A*B)%2==1){
      printf("Yes\n");
   }

   return 0;
}

Measured memory_bytes: 1616
import java.util.*;
public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt(),l=sc.nextInt();
        sc.close();
        int a=Math.abs(l),b=l,c=l,gt=l;
        for(int i=1;i<n;i++){
            gt+=(l+i);
            a=Math.min(a,Math.abs(c+i));
            if(a==Math.abs(c+i))b=c+i;
        }
        System.out.println(gt-b +"\n");
    }
}

Measured memory_bytes: 25044
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

int N;
vector<vector<pair<int, int>>> v;

bool judge(int bit) {
	for (int i = 0; i < N; i++) {
		if (!(bit & (1 << i))) continue; // i人目が不親切なら無視

		for (auto xy : v.at(i)) {
			int x = xy.first; // i番目の人はxの人が
			int y = xy.second; // y = (0, 1)で(不親切, 正直)だと述べている.

			// y = 1なのに不親切
			if (y == 1 && !(bit & (1 << x))) return false;

			// y = 0なのに正直
			if (y == 0 && (bit & (1 << x))) return false;
		}
	}
	return true;
}

int main() {
	cin >> N;
	v.resize(N);
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		v.at(i).resize(A);
		for (int j = 0; j < A; j++) {
			cin >> v.at(i).at(j).first >> v.at(i).at(j).second;
			--v.at(i).at(j).first;
		}
	}

	int ans = 0;
	for (int bit = 0; bit < (1 << N); bit++) {
		if (judge(bit)) {

			// bit に含まれる人数を数える
			int cnt = 0;
			for (int i = 0; i < N; i++) {
				if (bit & (1 << i)) cnt++;
			}
			ans = max(ans, cnt);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
#include<string>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pair;
#define MM 1000000000
#define MOD MM+7
#define MAX 10000
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
int R,C;
char c[100][100];
int shortest_load;
int dist[100][100];
Pair s, g;
int main(){
    string s; cin >> s;
    int a = s[0] - '0';
    int b = s[1] - '0';
    int c = s[2] - '0';
    int d = s[3] - '0';
    if(a+b+c+d == 7){
        cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
        return 0;
    }
    if(a+b+c-d == 7){
        cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
        return 0;
    }
    if(a+b-c+d == 7){
        cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
        return 0;
    }
    if(a-b+c+d == 7){
        cout << a << "-" << b << "+" << c << "+" << d << "=7" <<  endl;
        return 0;
    }
    if(a+b-c-d == 7){
        cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
        return 0;
    }
    if(a-b+c-d == 7){
        cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
        return 0;
    }
    if(a-b-c+d == 7){
        cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
        return 0;
    }
    if(a-b-c-d == 7){
        cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
        return 0;
    }
}


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

using namespace std;

int main(){
  map<long long, int> stk;
  vector<long long> k;
  long long max_l = 0;
  long long e1 = 0;
  long long e2 = 0;
  int n;
  cin >> n;
  for (int i=0;i<n;i++) {
    long long a;
    cin >> a;
    if (stk.find(a)==stk.end()) {
      stk[a] = 1;
    } else {
      stk[a]++;
    }
    if (max_l < a) {
      max_l = a;
    }
  }
  for (auto it = stk.begin();it!=stk.end();it++) {
    k.push_back(it->first);
  }
  sort(k.begin(), k.end());
  reverse(k.begin(), k.end());
  for (auto it = k.begin();it!=k.end();it++) {
    if (stk[*it] >= 2) {
      if (e1 > 0) {
	e2 = *it;
	cout << e1*e2 << endl;
	return(0);
      } else {
	e1 = *it;
	if (stk[*it] >= 4) {
	  cout << e1*e1 << endl;
	  return(0);
	}
      }
    }
  }
  cout << 0 << endl;
}


Measured memory_bytes: 7676
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        
        if (x < a) {
            System.out.println(0);
        } else {
            System.out.println(10);
        }
    }
}


Measured memory_bytes: 21716
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MOD = (int)1e9 + 7;
int ADD(int a, int b) { return (a + b) % MOD; }
int SUB(int a, int b) { return (a - b + MOD) % MOD; }

vector<int> a;
vector<vector<int>> memo;

int dp(int i, int j) {
    if (j == 0) return 1;
    if (j < 0) return 0;
    if (i == -1) return 0;
    if (memo[i][j] != -1) return memo[i][j];
    int res = SUB(ADD(dp(i-1, j), dp(i, j-1)), dp(i-1, j-1-a[i]));
    return memo[i][j] = res;
}

int main() {
    int N, K; cin >> N >> K;
    a.resize(N + 1);
    for (int i = 1; i <= N; i++) cin >> a[i];
    memo.assign(N + 1, vector<int>(K + 1, -1));
    cout << dp(N, K) << endl;
    return 0;
}

Measured memory_bytes: 47608
import java.util.*;

// ABC 18-C
// http://abc018.contest.atcoder.jp/tasks/abc018_3
 
public class Main {

	public static void main (String[] args) throws java.lang.Exception {
		Scanner in = new Scanner(System.in);
		
		int x = in.nextInt();
		int y = in.nextInt();
		
		System.out.println(group(x) == group(y) ? "Yes" : "No");
	}
	
	public static int group(int n) {
		switch(n) {
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			return 1;
		case 4:
		case 6:
		case 9:
		case 11:
			return 2;
		default: 
			return 3;
		}
	}
}

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

int main() {
    for (int i = 0; i < 5; ++i) {
        int x; cin >> x;
        if (x == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
int a[100000],p[100000]={1,1},Q,i=1,j;int main(){for(;++i<100000;)if(!p[i])for(j=i;(j+=i)<100000;p[j]=1);for(i=0;++i<100000;)a[i]=a[i-1]+!(p[i]|p[(i+1)/2]);std::cin>>Q;while(Q--){std::cin>>i>>j;std::cout<<a[j]-a[i-1]<<'\n';}return 0;}

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

using ll=long long; 

void solve(){
	int w,a,b;
	cin>>w>>a>>b;
	if(a+w<b || b+w<a){
		cout<<min(abs(a+w-b),abs(b+w-a))<<endl;
	}else{
		cout<<0<<endl;
	}
}

signed main(){
	//while(1)
	solve();
}

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

static const int N = 1000;

int max(int a,int b){
  if(a>b) return a;
  return b;
}

int lcs(char *X,char *Y){
  int c[N+1][N+1];
  int m = strlen(X);
  int n = strlen(Y);
  int maxl=0;
  int i,j;
  for(i=m;i>=0;i--){
    X[i+1]=X[i];
  }
   for(i=n;i>=0;i--){
    Y[i+1]=Y[i];
  }
  X[0]=' ';
  Y[0]=' ';
  for(i=1;i<=m;i++)c[i][0]=0;
  for(j=1;j<=n;j++)c[0][j]=0;

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(X[i]==Y[j]){
	c[i][j]=c[i-1][j-1]+1;
      }else{
	c[i][j]=max(c[i-1][j],c[i][j-1]);
      }
      maxl = max(maxl,c[i][j]);
    }
  }
  
  return maxl;
}
    

int main(){
  char s1[N+1],s2[N+1];
  int i,num;
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%s%s",s1,s2);
    printf("%d\n",lcs(s1,s2));
  }
  return 0;
}

Measured memory_bytes: 4524
#include<stdio.h>
#include<math.h>

int main(){
    int n,i,j;
    int max=0;
    int min=101;
    scanf("%d",&n);

    int x[n+1];
    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
        if(max<x[i]){
            max = x[i];
        }
        if(min>x[i]){
            min = x[i];
        }
    }




    int sum;
    int dmin=1000001;

    for(j=min;j<=max;j++){
        sum=0;
        for(i=0;i<n;i++){
            sum += pow((x[i]-j),2.0);
        } 
        if(sum<=dmin){
            dmin = sum;
        }
    }

    printf("%d",dmin);
    return 0;
}


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

int main() {
	int n;

	cin >> n  ;
	
	bool flg = false;

	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		if (s == "Y") {
			flg = true;
		}
	}
	
	if (flg) {
		cout << "Four" << endl;
	}
	else {
		cout << "Three" << endl;
	}
}

Measured memory_bytes: 256