akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

vector<vector<int>> g;
vector<int> r;
vector<int> z;

int ccc = 0;

bool dfs(int x) {
//    cout << x << "\n";
    if (z[x] == ccc) return false;
    z[x] = ccc;
    for (int y : g[x]) {
        if (r[y] == -1 || dfs(r[y])) {
            r[y] = x;
            return true;
        }
    }
    return false;
}



int main() {
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    g.resize(n);
    r.assign(n, -1);
    z.resize(n);
    for (int i = 0; i < n - 1; i++) {
        int c;
        cin >> c;
        for (int j = 0; j < c; j++) {
            int x;
            cin >> x;
            x--;
            g[x].push_back(i);
        }
    }
    for (int i = 0; i < n; i++) {
        std::random_shuffle(g[i].begin(), g[i].end());
    }

    int ff = -1;
    for (int i = 0; i < n; i++) {
        ccc++;
        bool ok = false;
        for (int y : g[i]) {
            if (r[y] == -1) {
                r[y] = i;
                ok = true;
                break;
            }
        }
        if (!ok) {
            if (!dfs(i)) {
                if (ff == -1) {
                    ff = i;
                } else {
                    cout << -1 << "\n";
                    return 0;
                }
            }
        }
    }

//    for (int i = 0; i < n - 1; i++) {
//        cout << r[i] << "\n";
//    }

    vector<int> q;
    vector<bool> zz(n);
    q.push_back(ff);
    vector<pair<int, int>> res(n - 1);
    for (int i = 0; i < q.size(); i++) {
        int x = q[i];
        for (int c : g[x]) {
            if (!zz[c]) {
                zz[c] = true;
                q.push_back(r[c]);
                res[c] = {r[c], x};
            }
        }
    }

    if (q.size() < n) {
        cout << "-1\n";
    } else {
        for (int i = 0; i < n - 1; i++) {
            cout << res[i].first + 1 << " " << res[i].second + 1 << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 11896
#他の人の回答
import collections

N = int(input())
s = ["".join(sorted(input())) for _ in range(N)]
#sortedでリストになった文字列をjoinでもう一度文字列に
c = collections.Counter(s)
#cは辞書の形をとる
ans = 0

# sから重複を無くす
for si in set(s):
    n = c[si]
    ans += n * (n - 1) // 2 
    # n C 2を計算
print(ans)


Measured memory_bytes: 28228
#include<iostream>
using namespace std;
int main()
{
    int a,b,i;
    cin>>a>>b;
    if(a>b)
    {
        for(i=0;i<a;i++)
        {
            cout<<b;
        }
    }
        if(b>a)
        {


            for(i=0;i<b;i++)
        {
            cout<<a;
        }
        }
        if(a==b)
        {
            for(i=0;i<a;i++)
            {
                cout<<a;
            }
        }






}


Measured memory_bytes: 3120
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
    }

    if n == 1 {
        println!("1");
        return;
    }

    let mut divisor_num = vec![0; n + 1];
    divisor_num[1] = 1;
    divisor_num[2] = 2;
    let mut primer = vec![2];

    for i in 3..n + 1 {
        let mut target = i;
        let mut is_prime = true;
        let mut divide_num = 0;

        for p in primer.iter() {
            if p * p > target {
                break;
            }
            while target % p == 0 {
                target /= p;
                divide_num += 1;
            }
            if divide_num > 0 {
                is_prime = false;
                break;
            }
        }
        if is_prime {
            divisor_num[i] = 2;
            primer.push(i);
        } else {
            divisor_num[i] = (divide_num + 1) * divisor_num[target];
        }
    }

    let mut sum: i64 = 0;
    for i in 1..n + 1 {
        sum += i as i64 * divisor_num[i] as i64;
    }

    println!("{}", sum);
}

// 約数の数が2でnより小さい数 素数で割る
// 割れないなら次の素数を試す
// どれでも割れなかったら素数なので約数の数は２
// 割り切れたら、割った回数をmとして、割った結果の約数*(m+1)が約数の数


Measured memory_bytes: 46312
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
const int MAX = 6666;
 
int n, k;
 
int a[MAX];
 
bool pr[MAX][MAX], suf[MAX][MAX];
 
vector <int> v1, v2;
 
void init() {
    pr[0][0] = true;
    if (a[0] < MAX)
        pr[0][a[0]] = true;
    for (int i = 1; i < n; ++i) {
        for (int j = MAX - 1; j >= 0; --j) {
            if (pr[i - 1][j]) {
                if (j + a[i] < MAX)
                    pr[i][j + a[i]] = true;
                pr[i][j] = true;
            }
        }
    }
    suf[n - 1][0] = true;
    if (a[n - 1] < MAX)
        suf[n - 1][a[n - 1]] = true;
    for (int i = n - 2; i >= 0; --i) {
        for (int j = MAX - 1; j >= 0; --j) {
            if (suf[i + 1][j]) {
                if (j + a[i] < MAX)
                    suf[i][j + a[i]] = true;
                suf[i][j] = true;
            }
        }
    }
}
 
bool gg(int id) {
    int l = max(0, k - a[id]);
    v1.clear();
    v2.clear();
    if (id > 0) {
        for (int i = 0; i < MAX; ++i) {
            if (pr[id - 1][i]) {
                if (l <= i && i < k)
                    return false;
                v1.push_back(i);
            }
        }
    }
    if (id < n - 1) {
        for (int i = 0; i < MAX; ++i) {
            if (suf[id + 1][i]) {
                if (l <= i && i < k)
                    return false;
                v2.push_back(i);
            }
        }
    }
    for (int i = 0; i < (int)v1.size(); ++i) {
        vector <int>::iterator it = lower_bound(v2.begin(), v2.end(), l - v1[i]);
        if (it != v2.end() && l <= v1[i] + *it && v1[i] + *it < k)
            return false;
    }
    return true;
}
 
int main() {
#ifdef LOCAL
    freopen("xxx.in", "r", stdin);
    freopen("xxx.out", "w", stdout);    
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    if (n == 1) {
        if (a[0] < k)
            cout << 1;
        else
            cout << 0;
        return 0;
    }
    init();
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (gg(i))
            ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 67968
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<vector>
#include<stack>
#include<cmath>
#include<map>
#include<set>
using namespace std;
typedef long long LL;
const int MOD = 1e9 + 7;
int x,y;
int main(void) {
	void solve();
	solve();
	return 0;
}
LL C2(LL n,LL m) {
	if(m > n / 2) m = n - m;         // 由性质 1 得到的
	LL a = 1,b = 1;
	for(int i = 1; i <= m; i ++) {
		a = a *( n + 1 - i) % MOD;
		b = b * i % MOD;
		if(a % b == 0) {
			a /= b;
			b = 1;
		}
	}
	return a / b % MOD;
}
LL mod = 1000000007;
const int N = 1000010;
LL qpow(LL a,LL x) {
	LL ret=1;
	while (x) {
		if (x&1)
			ret = ret*a%mod;
		a=a*a%mod;
		x>>=1;
	}
	return ret;
}
//LL fac[maxn],inv[maxn];
//LL init() {
//	fac[0]=1;
//	for (int i=1; i<maxn; i++)
//		fac[i]=fac[i-1]*i%mod;
//	inv[maxn-1]=qpow(fac[maxn-1],mod-2);
//	for (int i=maxn-2; i>=0; i--)
//		inv[i]=inv[i+1]*(i+1)%mod;
//	return 0;
//}
//LL C1(LL n,LL m) {
//	if (n<m) return 0;
//	return fac[n]*inv[m]%mod*inv[n-m]%mod;
//}
//
//


LL fac[N];
void init1()
{
    LL i;
    fac[0]=1;

    for (LL i = 1; i < N; i++)

	fac[i] = fac[i - 1] * i % MOD;
}
LL exgcd(LL a, LL b, LL &x, LL &y) {
    if (!b) {x = 1; y = 0; return a;}
    LL d = exgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
LL inv(LL a, LL n) {
    LL x, y;
    exgcd(a, n, x, y);
    return (x + n) % n;
}
LL C(LL n, LL m) {

    return fac[n] * inv(fac[m] * fac[n - m] % MOD, MOD) % MOD;
}
void solve() {
	bool flag = true;
	int k,t;
	init1();
	scanf("%d%d",&x,&y);
	for(int i = 0; i <= x; i ++) {
		if(2 * y - 3 * i == x) {
			t = y - 2 * i;
			k = i;
			flag = false;
			break;
		}
	}
	
	if(flag) printf("0\n");
	else printf("%lld\n",C(k + t,k));
	return ;
}

Measured memory_bytes: 8064
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>

long sx, sy, tx, ty;

void mv(long dx, long dy){
	for(int i = 0; i < std::abs(dx); i++){
		if(dx < 0){
			printf("L");
		}else{
			printf("R");
		}
	}
	for(int i = 0; i < std::abs(dy); i++){
		if(dy < 0){
			printf("D");
		}else{
			printf("U");
		}
	}
	return;
}

void mv_2(long dx, long dy){
	if(dy < 0){
		printf("U");
		if(dx < 0){
			mv(dx-1, dy-1);
			printf("R");
		}else{
			mv(dx+1, dy-1);
			printf("L");
		}
	}else{
		printf("D");
		if(dx < 0){
			mv(dx-1, dy+1);
			printf("R");
		}else{
			mv(dx+1, dy+1);
			printf("L");
		}
	}
}
	

int main(){
	scanf("%ld%ld%ld%ld", &sx, &sy, &tx, &ty);
	mv(tx-sx, ty-sy);
	//printf("\n");
	mv(sx-tx, sy-ty);
	//printf("\n");
	mv_2(tx-sx, ty-sy);
	//printf("\n");
	mv_2(sx-tx, sy-ty);
	printf("\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <bitset>
#define MOD 998244353
std::bitset<4005> lim, res, tmp; 
int fact[4005]; 
inline int deg(std::bitset<4005> a)
{
	for (int i = 4000; i; i--)
	{
		if (a[i])
			return i; 
	}
	return 0; 
}
inline void gcd()
{
	while (true)
	{
		if (deg(tmp) > deg(res))
			std::swap(tmp, res);
		int x = deg(tmp), y = deg(res); 
		for (int i = y; i >= x; i--)
		{
			if (res[i])
				res ^= tmp << (i - x); 
		}
		if (res.none())
		{
			std::swap(tmp, res);
			break; 
		}
	}
}
int main()
{
	// freopen("ARC084-F.in", "r", stdin); 
	std::ios::sync_with_stdio(false); 
	std::cin.tie(0); 
	fact[0] = 1; 
	for (int i = 1; i < 4005; i++)
		fact[i] = fact[i - 1] * 2 % MOD; 
	int n; 
	std::cin >> n >> lim >> res; 
	for (int i = 1; i < n; i++)
	{
		std::cin >> tmp; 
		gcd(); 
	}
	int ans = 0, g = deg(res); 
	tmp.reset(); 
	for (int i = 4000; i >= g; i--)
	{
		if (lim[i])
			(ans += fact[i - g]) %= MOD; 
		if (lim[i] != tmp[i])
			tmp ^= res << (i - g); 
	}
	bool f = false; 
	for (int i = g; i >= 0; i--)
	{
		if (tmp[i] < lim[i])
			break; 
		if (tmp[i] > lim[i])
			f = true; 
	}
	printf("%d\n", (ans + !f) % MOD);
	return 0; 
}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;

void solve() {
  string S;
  cin >> S;
  int N = S.size(), cnt = 0;
  vi ans(N, 0);
  for (int i = 0; i < N; i++) {
    if (S[i] == 'R') {
      cnt++;
    } else {
      ans[i] += cnt / 2;
      ans[i - 1] += cnt - (cnt / 2);
      cnt = 0;
    }
  }
  cnt = 0;
  for (int i = N - 1; i >= 0; i--) {
    if (S[i] == 'L') {
      cnt++;
    } else {
      ans[i] += cnt / 2;
      ans[i + 1] += cnt - (cnt / 2);
      cnt = 0;
    }
  }
  for (int i = 0; i < N; i++) cout << ans[i] << ' ';
  cout << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 1104
#include<bits/stdc++.h>
using namespace std;
int main() {

  int n;
  stack<int> st;
  while( cin >> n, n != -1 ) {
    while(1) {
      if( n < 4 ) {
	st.push(n);
	break;
      }
      else {
	st.push(n % 4);
	n /= 4;
      }
    }
    while( !st.empty() ) {
      int data = st.top(); st.pop();
      cout << data;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1200
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;

signed main(){
  int l,n;
  cin>>l>>n;
  vector<int> x(n+2,0);
  for(int i=1;i<=n;i++)cin>>x[i];
  x[n+1]=l;
  vector<int> rui(n+2,0);
  for(int i=1;i<=n;i++){
    rui[i]=rui[i-1]+x[i];
  }
  int ans=0;
  for(int i=1;i<=n;i++){
    int tmp;
    int nn=n-i;
    tmp=max(nn*l+2*(rui[i+nn/2]-rui[i-1])-x[i+(nn+1)/2]-2*(rui[n]-rui[i+(nn+1)/2]),
        i*l+2*rui[(i-1)/2]+x[(i+1)/2]-2*(rui[i]-rui[i-(i+1)/2]));
    ans=max(tmp,ans);

  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
using ll = long long;
using pi = pair <ll, ll>;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < s.size(); ++i)
		s[i] = (s[i] - 'A' + n) % 26 + 'A';
	cout << s;
}


Measured memory_bytes: 256
import sys

def main():
    input = sys.stdin.readline

    a, b, m = input().split()
    a, b, m = int(a), int(b), int(m)
    alist = list(map(int, input().split()))
    blist = list(map(int, input().split()))

    waribiki = [input().split() for _ in range(m)]
    
    res = [200000] * (m + 1)
    count = 0

    for i in range(m):
        res[count] = alist[int(waribiki[i][0])-1] + blist[int(waribiki[i][1])-1] - int(waribiki[i][2])
        count += 1

    res[count] = min(alist) + min(blist)
      
    print(min(res))


if __name__ == '__main__':
    main()

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

int main() {
    int r,g,b,n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    int d = n / r;
    for(int i = 0; i <= d; i++) {
        int rest = n - r * i;
        int d2 = rest / g;
        for(int j = 0; j <= d2; j++) {
            int rest2 = rest - g * j;
            if(rest2 % b == 0) {
                ans++;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
D, G = map(int, input().split())

pt = 100
st = []
for i, (p, c) in enumerate((map(int, input().split()) for _ in range(D))):
    st.append([pt * p + c, p, 2**i, (p-1, pt)])
    pt += 100

mincnt = 10 ** 10
for i in range(pow(2,D)):

    score = G
    cnt = 0
    maxpt = (0, 1)
    for allscore, allcnt, pos, eachpt in st:
        if pos & i:
            score -= allscore
            cnt += allcnt
        else:
            maxpt = eachpt
    else:
        if score > 0:
            p, pt = maxpt
            wcnt = score // pt + bool(score % pt) * 1
            if wcnt <= p:
                cnt += wcnt
            else:
                continue
        
        mincnt = min(mincnt, cnt)

print(mincnt)


Measured memory_bytes: 3064
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpl;
typedef vector<tuple<int, int, int>> vti;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    vi l(m);
    vi r(m);
    rep(i, m) cin >> l[i] >> r[i];
    
    int left=0, right=n;
    rep(i, m){
        left = max(left, l[i]);
        right = min(right, r[i]);
    }
    cout << max(0, right - left + 1) << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#define int64 long long

const int N = (int) 1e6 + 10;
char s[N];

int main() {
	scanf("%s", s);
	int cnt_b = 0;
	int64 ans = 0;
	for (int i = 0; s[i]; ++i) {
		if (s[i] == 'W') {
			ans += cnt_b;
		} else {
			cnt_b++;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


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

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

    int a, b;
    cin >> a >> b;

    cout << (a-1) * (b-1) << endl;
}

Measured memory_bytes: 256
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n=0,d=0) Array.new(n,d)end
def na2(n=0,m=0,d=0) Array.new(n){Array.new(m,d)}end
def na3(n=0,m=0,l=0,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
while true
  n,k = inp
  break if n == 0
  a = na(n)
  i = 0
  now = k
  while true
    if(now == 0)
      if(a[i]==k)
        p i
        break
      else
        now += a[i]
        a[i] = 0
      end
    else
      now -= 1 
      a[i] += 1
    end
    i=(i+1)%n
  end
end

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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-indexか1-indexでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-index昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-index昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-index降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-index降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
using i64 = int_fast64_t;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(15);

    int h,w, k; cin >> h >> w >> k;
    vii s(h, vi(w));
    int p = 1;
    rep(i,h) {
        rep(j,w) {
            char ch; cin >> ch;
            s[i][j] = (ch=='#'? p : 0);
            if(s[i][j]==p) ++p;
        }
    }
/*
    rep(i,h) {
        rep(j,w) {
            cout << s[i][j] << (j==(w-1)? '\n': ' ');/////////
        }
    }
*/
    int d = 0;
    rep(i,h) {
        vi itigo;
        d = 0;
        bool can = 0;
        rep(j,w) { //いちごある？
            if(s[i][j]!=0) {
                can = true;
                itigo.push_back(s[i][j]);  //さいしょのいちごnumber
            }
        }

        if(can) {  //あるなら
            rep(k,w) {
                if(s[i][k] == itigo[d]) {
                    d++;
                    if(d==itigo.size()) d--;
                }
                else s[i][k] = itigo[d];
            }
        }
    } 

    vi x(w);
    bool can = 0;
    rep(i,h) {
        if(can) break;
        rep(j,w) {
            if(s[i][j]!=0) {
                can = 1;
                x = s[i];
                break;
            }
        }
    }

    rep(i,h) { 
        bool can = 0;
        rep(j,w) {
            if(s[i][j]!=0) {
                can = true;
                break;
            }
        }
        if(can) x = s[i];
        else {
            s[i] = x;
        }
    }


    rep(i,h) {
        rep(j,w) {
            cout << s[i][j] << (j!=(w-1)? ' ' : '\n');
        }
    }
}

Measured memory_bytes: 1152
n = int(input())

ans = 0
sqrt = 1

for i in range(1,n+1,2):
    if i == sqrt*sqrt:
        sqrt += 1
        continue
    elif i > sqrt*sqrt:
        sqrt += 1
    count = 0
    for j in range(1,sqrt,2):
        if i%j == 0:
            count += 1
    if count == 4:
        ans += 1

print(ans)


Measured memory_bytes: 9108
c = [list(map(int,input().split())) for _ in range(3)]

a = [0,0,0]
b = [0,0,0]
for i in range(2):
    d = [] 
    e = []
    for j in range(3):
        d.append(c[i+1][j] - c[i][j])
        e.append(c[j][i+1] - c[j][i])
    
    if len(set(d)) == 1:
        a[i+1] = d[0]
    else:
        print('No')
        exit()
    
    if len(set(e)) == 1:
        b[i+1] = e[0]
    else:
        print('No')
        exit()

else:
    if min(a) < 0:
        for i in range(3):
            a[i] += abs(min(a))
    if min(b) < 0:
        for i in range(3):
            b[i] += abs(min(b))
    
    cnt = 0
    for i in range(3):
        for j in range(3):
            if (a[i] + b[j]) <= 100:
                cnt += 1
    
    if cnt == 9:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M=2e5+5;
int c=0,a[M],dp[M],ans[M],seg[4*M];
stack<int> st[M];
multiset<int> res;
std::vector<int> vtr[M];
void update(int i,int s,int e,int x,int z)
{
	if(s==e)
	{
		seg[i]=z;
		return;
	}
	int m=(s+e)/2;
	if(x<=m)
		update(2*i,s,m,x,z);
	else
		update(2*i+1,m+1,e,x,z);
	seg[i]=max(seg[2*i],seg[2*i+1]);
}
int query(int i,int s,int e,int l,int r)
{
	if(s>r || l>e)
		return 0;
	if(s>=l && e<=r)
		return seg[i];
	int m=(s+e)/2;
	return max(query(2*i,s,m,l,r),query(2*i+1,m+1,e,l,r));
}
void dfs(int x,int p)
{
	dp[x]=query(1,1,c,1,a[x]-1)+1;
	res.insert(dp[x]);
	ans[x]=*(--res.end());
	st[a[x]].push(x);
	update(1,1,c,a[x],dp[x]);
	for(auto u:vtr[x])
	{
		if(u!=p)
		{
			dfs(u,x);
		}
	}
	auto it=res.find(dp[x]);
	res.erase(it);
	st[a[x]].pop();
	if(sz(st[a[x]]))
	{
		int	z=st[a[x]].top();
		update(1,1,c,a[x],dp[z]);
	}
	else
		update(1,1,c,a[x],0);
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	map<int,int> H;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		H[a[i]];
	}
	for(int i=1;i<n;i++)
	{
		int u,v;
		cin>>u>>v;
		vtr[u].pb(v);
		vtr[v].pb(u);
	}
	for(auto it=H.begin();it!=H.end();it++)
		it->ss = ++c;
	for(int i=1;i<=n;i++)
		a[i]=H[a[i]];
	dfs(1,-1);
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<"\n";
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int a[n];
    double count;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        count += 1.0/a[i];
    }

    double ans = 1.0/count;

    cout << setprecision(16) << ans << endl;
    
    return 0;
}

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

int main() {
  vector<int> x(3);
  cin >> x.at(0) >> x.at(1) >> x.at(2);
  sort(x.begin(), x.end());
  if (x.at(0)==5 && x.at(1)==5 && x.at(2)==7){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,q;
	while(cin>>n>>q,n) 
	{
		int dates[101];
		fill(dates,dates+101,0);

		for(int i = 0; i < n; ++i)
		{
			int m; cin>>m;
			for(int j = 0; j < m; ++j)
			{
				int tmp; cin>>tmp;
				dates[tmp]++;
			}
		}

		int mx=0,ans=0;
		for(int i = 0; i < 101; ++i)
		{
			if(q<=dates[i]&&mx<dates[i])
			{
				mx=dates[i];
				ans=i;
			}
		}
		cout<<ans<<endl;
	}
  return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
vector<int> g[100000];
int  used[100000];
int used2[100000];
int p[100000];
int c;
void dfs(int x){
    used[x]=c;
    used2[p[x]]=c;
    for(auto y:g[x]){
        if(!used[y]) dfs(y);
    }
}
int main()
{
	int n, m;
	cin>>n>>m;
    for(int i=0; i<n; i++){
        cin>>p[i]; p[i]--;
    }
    for(int i=0; i<m; i++){
        int x, y;
        cin>>x>>y;
        x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int i=0; i<n; i++){
        if(used[i]) continue;
        c++;
        dfs(i);
    }
    int ans=0;
    for(int i=0; i<n; i++){
        if(used[i]==used2[i]) ans++;
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8960
# coding=utf-8
import array
import math


def sieve_of_eratosthenes(end):
    """
    :type end: int
    :rtype: array.array
    """
    # noinspection PyUnusedLocal
    is_prime = array.array('B', (True for i in range(end+1)))
    is_prime[0] = False
    is_prime[1] = False

    primes = array.array("L")
    for i in range(2, end+1):
        if is_prime[i]:
            primes.append(i)
            for j in range(i * 2, end+1, i):
                is_prime[j] = False
    return primes


if __name__ == '__main__':
    N = int(input())
    n = N
    upper_n = int(math.sqrt(n)) + 1
    # print(upper_n)
    prime_list = sieve_of_eratosthenes(upper_n)
    # print(prime_list)
    elementary_number_list = array.array("L")
    counter = 0

    while counter < len(prime_list):
        if n % prime_list[counter] == 0:
            elementary_number_list.append(prime_list[counter])
            n //= prime_list[counter]
        else:
            counter += 1

    if n != 1:
        elementary_number_list.append(n)

    print("{0}: {1}".format(N, ' '.join(map(str, elementary_number_list))))

Measured memory_bytes: 5788
S = input()
T = input()

def hantei(S, T):
    for i in range(len(T)):
        if S == T:
            print("Yes")
            break
        l = list(S)
        l.append(l[0])
        del l[0]
        S = ''.join(l)
        if i == len(T)-1:
            print("No")
            
hantei(S, T)

Measured memory_bytes: 3060
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#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 ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
//作者:中国江苏南京丁天行
using namespace std;
int n,a[55],x;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",a+i);
    for(int i=1;i<=n;i++)if(abs(a[i])>=abs(a[x]))x=i;
    printf("%d\n",2*n-2);
    for(int i=1;i<=n;i++)if(i!=x)printf("%d %d\n",x,i);
    if(a[x]>=0){
        for(int i=1;i<n;i++)printf("%d %d\n",i,i+1);
    }
    else{
        for(int i=n-1;i;i--)printf("%d %d\n",i+1,i);
    }
//	system("pause");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll F[2100010];
int c;

ll Mul(ll a, ll b) {
	return ((a % c) * (b % c)) % c;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
ll square(ll x) {
	return (x * x) % c;
}

ll Power(ll x, ll y) {
	if (y == 0) return 1;
	else if (y == 1) return x % c;
	else if (y % 2 == 0) return square(Power(x, y / 2)) % c;
	else return square(Power(x, y / 2)) * x % c;
}

int main()
{
	int N;
	string X;
	cin >> N >> X;
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (X[i] == '1') cnt++;
	}
	int sum1 = 0;
	int sum2 = 0;
	int power = 1;
	for (int i = N - 1; i >= 0; i--) {
		if (X[i] == '1') {
			sum1 = (sum1 + power) % (cnt + 1);
		}
		power = (power * 2) % (cnt + 1);
	}
	power = 1;
	if (cnt - 1 != 0) {
		for (int i = N - 1; i >= 0; i--) {
			if (X[i] == '1') {
				sum2 = (sum2 + power) % (cnt - 1);
			}
			power = (power * 2) % (cnt - 1);
		}
	}
	for (int i = 0; i < N; i++) {
		int num = 0;
		string S = X;
		int ans = 1;
		power = 1;
		if (S[i] == '0') {
			num = sum1;
			c = cnt + 1;
			num = (num + Power(2ll, (ll)(N - i - 1))) % c;
		}
		else {
			num = sum2;
			c = cnt - 1;
			if (c != 0) {
				num = (num - Power(2ll, (ll)(N - i - 1))) % c;
			}
		}
		if (num < 0)  num += c;
		if (c == 0) {
			cout << 0 << endl;
			continue;
		}
		while (num > 0) {
			ans++;
			c = 0;
			power = 1;
			int tmp = num;
			int next = 0;
			for (int j = 0; j < 30; j++) {
				if (tmp % 2 == 1) c++;
				tmp /= 2;
			}
			for (int j = 0; j < 30; j++) {
				if (num % 2 == 1) {
					next = (next + power) % c;
				}
				power = (power * 2) % c;
				num /= 2;
			}
			num = next;
		}
		cout << ans << endl;
	}
}


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


int main(){
  ll x,k,d;
  cin >> x >> k >> d;
  if(x>d){
    ll tmp=x/d;
    if(tmp<=k){
      k=k-tmp;
      x=x%d;
    }else{
      x=x-(k*d);
      k=0;
    }
  }else if(abs(x)>d){
    ll tmp=abs(x);
    tmp=tmp/d;
    if(tmp<=k){
      k=k-tmp;
      ll cal=abs(x);
      cal=cal%d;
      x=cal*(-1);
    }else{
      x=x+(k*d);
      k=0;
    }
  }
  if(k%2==0) cout << abs(x) << endl;
  else{
    if(x>0){
      ll cal=x-d;
      cout << abs(cal) << endl;
    }else if(x<=0){
      ll cal=x+d;
      cout << abs(cal) << endl;
    }
  }
  return 0;
}


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

int main() {
    int k , a, b;
    cin >> k >> a >> b;
    bool can = false;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            can = true;
            break;
        }
    }
    if (can) cout << "OK" << endl;
    else cout << "NG" << endl;
}

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

const static long long int INF = (1LL<<32);

void warshallFloyd(int v, std::vector<std::vector<long long int>>& darray){
    for(int k = 0; k < v; k++){
        for(int i = 0; i < v; i++){
            if(darray[i][k] == INF) continue;

            for(int j = 0; j < v; j++){
                if(darray[k][j] == INF) continue;
                darray[i][j] = std::min(darray[i][j], darray[i][k] + darray[k][j]);
            }
        }
    }
}


int main(void){
    int v, e;
    std::cin >> v >> e;
    int s, t;
    long long int d;

    std::vector<std::vector<long long int>> darray;
    darray.resize(v);

    for(int i = 0; i < v; i++){
        darray[i].resize(v);
        for(int j = 0; j < v; j++){
            darray[i][j] = ( (i == j) ? 0 : INF );
        }
    }

    for(int i = 0; i < e; i++){
        std::cin >> s >> t >> d; 
        darray[s][t] = d;
    }

    warshallFloyd(v, darray);
    bool neg = false;

    for(int i = 0; i < v; i++){
        if(darray[i][i] < 0){
            std::cout << "NEGATIVE CYCLE" << std::endl;
            neg = true;
            break;
        }
    }
    if(!neg){
        for(int i = 0; i < v; i++){
            for(int j = 0; j < v; j++){
                if(j != 0){
                    std::cout << " ";
                }
                if(darray[i][j] == INF){
                    std::cout << "INF";
                }else{
                    std::cout << darray[i][j];
                }
            }
            std::cout << std::endl;
        }
    }

    return 0;

    
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pint pair<int,int>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;	cin>>n;
	int h[n+2],i,j;
	for(i=0;i<n;i++){
		cin>>h[i];
	}
	h[n+1]=h[n-1];	h[n]=h[n-1];
	int ans[n+2];
	ans[n+1]=0;
	ans[n]=0;
	for(i=n-1;i>=0;i--){
		ans[i]=min(ans[i+1]+abs(h[i+1]-h[i]), ans[i+2]+abs(h[i+2]-h[i]));
	}
	cout<<ans[0]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
  int t[100][100];
  int w, h, n, x, y, a, i, j, k;
  int s = 0;

  for (i = 0; i < 100; i++)
    for (j = 0; j < 100; j++)
      t[i][j] = 1;

  scanf("%d %d %d", &w, &h, &n);
  
  for (i = 0; i < n; i++) {
    scanf("%d %d %d", &x, &y, &a);
    if (a == 1) {
      for (j = 0; j < x; j++)
	for (k = 0; k < h; k++)
	  t[j][k] = 0;
    }
    else if (a == 2) {
      for (j = x; j < w; j++)
	for (k = 0; k < h; k++)
	  t[j][k] = 0;
    }
    else if (a == 3) {
      for (j = 0; j < w; j++)
	for (k = 0; k < y; k++)
	  t[j][k] = 0;
    }
    else {
      for (j = 0; j < w; j++)
	for (k = y; k < h; k++)
	  t[j][k] = 0;
    }

  }
  for (j = 0; j < w; j++)
    for (k = 0; k < h; k++)
      if (t[j][k])
	s++;

  printf("%d\n", s);

  return 0;
}

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

int main() {
  	int N;
  cin >> N;
	int A;
  cin >> A;

  
  if (N%500 == 0){
    cout << "Yes" << endl;}
  else if (N-A <=0){
    cout << "Yes" << endl;}
    else if (N%500 <= A){
      cout << "Yes" << endl;}
    else {
      cout << "No" << endl;}
}

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

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int[] vs = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
			int N = vs[0];
			int M = vs[1];
			int[] A = Console.ReadLine().Split().Select(p => int.Parse(p)).OrderBy(p => p).ToArray();
			int[][] op = new int[M][];
			for (int i = 0; i < M; i++) {
				op[i] = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
			}
			op = op.OrderByDescending(p => p[0]).OrderByDescending(p => p[1]).ToArray();
			int index = 0;
			for (int i = 0; i < M; i++) {
				int B = op[i][0];
				int C = op[i][1];
				while (B > 0) {
					if (A[index] < C) {
						A[index] = C;
						index++;
						B--;
						if (index >= N) {
							break;
						}
					} else {
						break;
					}
				}
				if (index >= N) {
					break;
				}
			}
			Console.WriteLine(A.Select(p => (long)p).Sum());
		}
	}
}


Measured memory_bytes: 35764
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;

int main()
{
  int x;
  cin>>x;
  string ans="ABC";
  if (x>=1200) ans="ARC";
  cout<< ans <<endl;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	auto L=vecin(N);
	sort(ALL(L));
	
	int num = 0;
	REP(i,N){
		for(int j=i+1;j<N;j++){
			int first = L[N-1-i],second = L[N-1-j];
			int v = first-second;
			auto res = upper_bound(L.begin(),L.begin()+N-j-1,v);
			num += distance(res,L.begin()+N-j-1);
		}
	}

	out(num);
	return 0;
}

Measured memory_bytes: 256
#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>;
const int INF = 1001001001;

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

int main() {
  int n;
  cin >> n;
  int ans = INF;
  for(int i = 1; i < n; i++){
    ans = min(ans, sum(i)+sum(n-i));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        x: usize,
    }
    println!("{}", x / 500 * 1000 + (x % 500) / 5 * 5);
}


Measured memory_bytes: 2164
#include <stdio.h>

int dp[50];

int fib(int n){
  if(n == 0 || n == 1)return dp[n]=1;
  if(dp[n] != -1)return dp[n];
  return dp[n] = fib(n-1) + fib(n-2);
}

int main(){
  int n,i;

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

  scanf("%d",&n);
  printf("%d\n",fib(n));

  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <string>
//#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
//#include <unordered_map>
#include <stack>

using namespace std;

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

#define max_n 100

long long N, M;
string S;


int main() {

	char A;
	cin >> A;
	A += 1;
	cout << A << endl;
	return 0;
}


Measured memory_bytes: 256
<?php /*atcoder.php*/

$at = new Atcoder();
$at->main();
unset($at);

class Atcoder{
	private function arrayIn(){
		$buf = explode(" ", fgets(STDIN));
		return $this->killNewLine($buf);
	}
	private function killNewLine($buf = null){
		$buf = str_replace("\r\n", "", $buf);
		$buf = str_replace("\n", "", $buf);
		$buf = str_replace("\r", "", $buf);
		return $buf;
	}

	public function main(){
		$s = $this->arrayIn();
		
		$ans = (($s[0] * $s[1] ) / 2);
		
		echo $ans . "\n";

	}
}
?>

Measured memory_bytes: 4856
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<set>
#include<vector>
#define INF 100000000

#define MAX_N 100

typedef long long int ll;
using namespace std;


int main(){

	int n,x;
	int ans = 0;
	while(true){
	
		scanf("%d %d", &n, &x);
		ans = 0;
		if(n == 0 && x == 0)
			break;

		for(int i = 1; i <= n; i++){
			for(int j = i+1; j <= n; j++){
				for(int k = j + 1; k <= n; k++){
					if(i+j+k == x)
						ans++;
				}
			}
		}

		printf("%d\n", ans);
	
	
	}

	return 0;

}

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

int main(){
  int n, a, b, c, d;
  cin >> n;
  a = n/1000;
  b = (n/100)%10;
  c = (n/10)%10;
  d = n%10;
  if(((a == b)&&(b == c))||((b == c)&&(c == d)) ){
//(a == b == c)||(b == c == d)ではダメ
    cout << "Yes" << endl; 
  }else{
    cout << "No" << endl; 
  }
}

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

int main() {

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

  if(A == 1 && B == 2){
    cout << "3" << endl;
  }else if(A == 1 && B == 3){
    cout << "2" << endl;
  }else if(A == 2 && B == 1){
    cout << "3" << endl;
  }else if(A == 2 && B == 3){
    cout << "1" << endl;
  }else if(A == 3 && B == 1){
    cout << "2" << endl;
  }else if(A == 3 && B == 2){
    cout << "1" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define pie M_PI
#define maxx 2147483647
#define FOR(i,a,b) for(int i=a;i<b;++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
const long long int maxs = 10000001;


ll a[maxs] = {0};

void res()
{
    for(int i = 1; i  < maxs; i++)
    {
        for(int j = i; j < maxs; j += i)
        {
            a[j] += 1;
        }
    }
    /*ll i = sqrt(maxs) - 4;
    for(; i < maxs; i++)
    {
        cout << a[i] << endl;
        if(a[i] == 1)
            a[i] += 1;
    }*/

}

int main()
{
    res();
    ll n;
    scanf("%lld", &n);
    ll result = 0;
    for(int i = 1; i <= n; i++)
    {
        result += (i * a[i]);
    }
    printf("%lld\n", result);


}


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

int main()
{

    int n,m,ans,sum;
    while(~scanf("%d %d",&n,&m))
    {
        sum=0;
        sum=n*3+m;
        ans=sum/2;
        printf("%d\n",ans);
    }

    return 0;
}


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


int main(){
    string N;
    cin >> N;
    int s = N.size() - 1;
    char str = N.at(s);
    if(str == '2' || str == '4' || str == '5'||str == '7' || str == '9') cout << "hon" << endl;
    else if(str == '3') cout << "bon" << endl;
    else cout << "pon" << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int A[100010];
int gcd(int x, int y) {
	if (x < y) swap(x, y);
	if (y == 0) return x;
	return gcd(y, x % y);
}
int main()
{
	int N, K;
	cin >> N >> K;
	int MAX = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		MAX = max(MAX, A[i]);
	}
	if (K > MAX) {
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}
	int num = A[0];
	for (int i = 1; i < N; i++) num = gcd(num, A[i]);
	if (K % num == 0) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 3892
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N;
int A[200200];
int asum[200200];

signed main() {
    cin >> N;
    int sum = 0;
    rep(i, N) {
        cin >> A[i];
        A[i] -= (i + 1);
    }
    sort(A, A + N);
    rep(i, N) {
        asum[i + 1] = asum[i] + A[i];
    }
    if (N % 2 == 1) {
        cout << asum[N] - asum[N / 2] - asum[N / 2 + 1] << endl;
    } else {
        cout << asum[N] - asum[N / 2] * 2 << endl;
    }
    return 0;
}
//C


Measured memory_bytes: 3328
X, Y = list(map(int, input().split()))

is_exist = False
for gruidaes in range(X + 1):
  turtles = X - gruidaes
  if turtles * 4 + gruidaes * 2 == Y:
    is_exist = True
    break

if is_exist:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9176
var
  k,s,x,y,iii:longint;
begin
  readln(k,s);
  for x:=0 to k do
   for y:=0 to k do
    if (s-x-y<=k) and (s-x-y>=0) then iii:=iii+1;
  writeln(iii);
end.


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

#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define ld long double
#define pb push_back
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000000

ll mulmod(ll, ll);
ll fastpower(ll, ll);
void getprime(vector<ll>&);
void getfact(vector<ll>&, vector<ll>&);
ll ncr(ll, ll, vector<ll>&, vector<ll>&);

void solve()
{
    ll n, m, k;
    for(ll i=0;i<5;i++)
    {
        cin>>n;
        if(n == 0)
            cout<<i+1;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solve();        
    }
    return 0;
}

ll mulmod(ll a, ll b)
{
    ll res = 0; 
    a = a % MOD;
    while(b > 0)
    {
        if (b % 2 == 1)
            res = (res + a) % MOD;
 
        a = (a * 2) % MOD; 
        b /= 2;
    } 
    return res % MOD; 
}

ll  fastpower(ll a, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n % 2 != 0)
        {
            res = (res * a) % MOD;
        }
        n /= 2;
        a = (a * a) % MOD;
    }
    return res;
}

void getprime(vector<bool>&prime)
{
    prime[0] = false;
    prime[1] = false;
    
    for(ll i = 2;i <= MAX; i++)
    {
        if(prime[i])
        {
            for(ll j = i*i; j <= MAX; j += i)
                prime[j] = false;
        }
    }
}

void getfact(vector<ll> &fact, vector<ll> &ifact)
{
    fact[0] = 1;
    ifact[0] = 1;
    
    for(ll i = 1; i <= MAX; i++)
    {
        fact[i] = (fact[i-1] * i)%MOD;
        ifact[i] = (ifact[i-1] * fastpower(i, MOD -2) )%MOD;
    }
}

ll ncr(ll n, ll r, vector<ll>&fact, vector<ll>&ifact)
{
    ll res;
    res = (((fact[n] * ifact[r]) % MOD) * ifact[n-r]) % MOD;
    return res;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vl;

const int N = 1e5 + 123;
int n, a[N], cnt[N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	int mn = N, mx = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
		mn = min(mn, a[i]);
		mx = max(mx, a[i]);
	}
	if (mx - mn > 1) {
		cout << "No";
		return 0;
	}
	if (mn == mx) {
		int x = mn;
		if (x == n - 1 || x <= n / 2) {
			cout << "Yes";
		}	else {
			cout << "No";
		}
		return 0;
	}
	if (cnt[mn] + 1 <= mx && cnt[mn] + cnt[mx] / 2 >= mx) {
		cout << "Yes";
	}	else {
		cout << "No";
	}
}


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

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

int main()
{

    int n,k;cin >> n >> k ;

    vector<string> v;

    for(int i=0;i<k;i++){
        int t;cin >> t;
        v.push_back(to_string(t));
    }

    int i=0;
    string ans;
    while(1){
        ans = to_string(n+i);i++;

        bool flg=true;
        for(int j=0;j<v.size();j++){
            if(ans.find(v[j])!=string::npos) flg=false;
        }
        if(flg) break; 
    }
    p(ans)
}

Measured memory_bytes: 256