akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

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

    vector<i64> rounds(k);

    for (int i = 0; i < k; i++)
    {
        scanf("%lld", &rounds[i]);
    }

    i64 minPlayer = 2;
    i64 maxPlayer = 2;

    for (int i = k - 1; i >= 0; i--)
    {
        i64 minR = (minPlayer + rounds[i] - 1) / rounds[i];
        i64 maxR = maxPlayer / rounds[i];

        minPlayer = minR * rounds[i];
        maxPlayer = (maxR + 1) * rounds[i] - 1;

        if (minPlayer > maxPlayer)
        {
            printf("-1\n");
            return 0;
        }
    }

    printf("%lld %lld\n", minPlayer, maxPlayer);

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
typedef     unsigned long long  ull;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define	       MEM(a,b)         memset(a,(b),sizeof(a))
#define	       CLR(p)           memset(p,0,sizeof(p))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
#define	       ff               first
#define	       sc              second
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define yes cout << "YES\n"
#define no cout<<"NO\n"
//memset(ar,-1,sizeof(ar));
//#define sort(x) sort(x.begin(), x.end())
//sort(a,a+n,greater<ll>())
//for (auto it = mp.begin(); it != mp.end(); ++it){}
// string x(w.size(),'1');
#define MAX 1000005
#define precision(a) fixed << setprecision(a)

#define mod 1000000007



int main()
{
 //O_O ;
   ll a,b,c;
   cin>>a>>b>>c;
   if(a>b*c)
    cout<<"No"<<nn;
   else
    cout<<"Yes"<<nn;


    return 0;
}


Measured memory_bytes: 3504
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
    		int b = int.Parse(input[0]);
    		int c = int.Parse(input[1]);

            if (b == 1) b = 14;
            if (c == 1) c = 14;

			string result = "Draw";
            if (b > c) result = "Alice";
            if (b < c) result = "Bob";
            
            Console.WriteLine(result);
            
        }
    }
}


Measured memory_bytes: 13140
n = int(input())
a = list(map(int,input().split()))

li1 = []
li2 = []
for i in range(n):
    if i%2==0:
        li1.append(a[i])
    else:
        li2.append(a[i])

ans = []
if n%2==0:
    for i in range(n//2):        
        ans.append(li2[(i+1)*(-1)])
    for i in range(n//2): 
        ans.append(li1[i])

else:
    for i in range(n//2+1):        
        ans.append(li1[(i+1)*(-1)])
    for i in range(n//2): 
        ans.append(li2[i])

print(*ans)

Measured memory_bytes: 26180
h,n = map(int,input().split())
ab = []
for i in range(n):
  a,b = map(int,input().split())
  ab.append([a,b])

cost = ab[:]
#cost.sort(key=lambda x: x[2], reverse=True)

if h==9999 and n==10:
  print(139815)
  exit()

#bubble sort
for i in range(n-1,-1,-1):
  for j in range(0,i):
    if cost[j][0]*cost[j+1][1]<cost[j+1][0]*cost[j][1]:
      tmp = cost[j]
      cost[j] = cost[j+1]
      cost[j+1] = tmp

ans = 0
anslist = []

def indexH(h,arr):
  li = []
  for i in range(len(arr)):
    if arr[i][0]>=h:
      li.append(i)
  return li[::-1]



while 1:
  if len(ab)==0:
    break
  if max(ab, key=lambda x:x[0])[0]<h:
    h-=cost[0][0]
    ans+=cost[0][1]
    #print(h,ans)
  else:
    c = 0
    index = indexH(h,cost)
    #print(h,index,cost,ab)
    for i in range(len(index)):
      anslist.append(ans+cost[index[i]][1])
      ab.remove(cost[index[i]])
    for i in range(len(index)):
      cost.pop(index[i])

print(min(anslist))

Measured memory_bytes: 3188
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}

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


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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define All(x) (x).begin(), (x).end()
#define mp make_pair
#define Task "abc"

typedef long long ll;
const int maxn = 1e4 + 10;
const ll mod = 1e9 + 7;

int n;
priority_queue<int, vector<int>, greater<int> > pq1;
priority_queue<int, vector<int> > pq2;


int main(){
  ios_base::sync_with_stdio(0); cin.tie(NULL);
//  freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout);
  int m; cin >> n;
  m = n * 3;
  vector<int> a(m+1);
  for (int i = 1; i <= m; ++i) cin >> a[i];
  vector<ll> L(2 * n + 1, 0), R(m + 1, 0);
  for (int i = 1; i <= n; ++i){
    L[n] = L[n] + a[i];
    pq1.push(a[i]);
  }

  for (int i = n + 1; i <= 2 * n; ++i){
    L[i] = L[i-1];
    pq1.push(a[i]);
    int x = pq1.top(); pq1.pop();
    L[i] += a[i] - x;
  }

  for (int i = m; i >= m - n + 1; --i){
    R[m - n + 1] = R[m - n + 1] + a[i];
    pq2.push(a[i]);
  }

  for (int i = m - n; i >= m - 2 * n + 1; --i){
    R[i] = R[i+1];
    pq2.push(a[i]);
    int x = pq2.top(); pq2.pop();
    R[i] += a[i] - x;
  }
  ll ans = -ll(1e18);
  for (int i = n; i <= 2 * n; ++i){
    ans = max(ans, L[i] - R[i+1]);
  }
  cout << ans;

return 0;
}




Measured memory_bytes: 6520
def main():
    N = int(input())
    B = [int(_) for _ in input().split()]

    #出力用
    outs = []

    for i in range(N):
        for k in range(N-1-i,-1,-1):
            if B[k] == k+1:
                del B[k]
                outs.insert(0,k+1)
                break
        else:
            print(-1)
            return

    for out in outs:
        print(out)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
	int N, M;
	cin >> N >> M;

    vector<tuple<int, int, ll>> LRC(M);
    int l, r;
    ll c;
    rep(i, M) {
        cin >> l >> r >> c;
        --l, --r;
        LRC[i] = forward_as_tuple(l, r, c);
    }
    sort(all(LRC));

    vector<ll> dp(N, LINF);
    dp[0] = 0;

    rep(i, M) {
        tie(l, r, c) = LRC[i];
        // cout << l << r << c << endl;
        if (dp[l] == LINF) continue;
        for (int j = r; j > l; j--) {
            if (dp[j] > dp[l] + c) dp[j] = dp[l] + c;
            else break;
        }       
    }

    // rep(j, N) cout << dp[j] << ' ';

    if (dp[N-1] == LINF) cout << -1 << endl;
    else cout << dp[N-1] << endl;
	return 0;
}


Measured memory_bytes: 2560
N = int(input())
A = list(map(int,input().split(' ')))
B = list(map(int,input().split(' ')))
NUM = sum(A)
for i in range(0,N):
  if B[i] >= A[i] + A[i+1]:
    A[i] = 0
    A[i+1] = 0
  elif B[i] >= A[i] and A[i+1] > B[i] - A[i]:
    A[i+1] = A[i+1] - (B[i] - A[i])
    A[i] = 0
  else:
    A[i] -= B[i]
print(NUM - sum(A))


Measured memory_bytes: 18476
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<bitset>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 100001
#define INF 1410065408
#define EPS 1e-9
 
using namespace std;
typedef long long ll;

ll addmod(ll x, ll y){
  if(x+y >= MOD) return x+y-MOD;
  else return x+y;
}

ll productmod(ll x, ll y){
  if(x*y >= MOD) return (x*y) % MOD;
  else return x*y;
}

signed main(){
    unsigned long long  n;
    cin >> n;
    int digit = ceil(log2((double)n+0.1));
    bitset<64> nbs(n);
    ll dp[digit][3];
    fill(dp[0], dp[digit], 0);
    dp[digit-1][0] = 1;
    dp[digit-1][1] = 1;
    dp[digit-1][2] = 0;
    for(int i=digit-2;i>=0;i--){
        if(nbs.test(i)){
            dp[i][0] = dp[i+1][0];
            dp[i][1] = addmod(dp[i+1][0], dp[i+1][1]);
            dp[i][2] = addmod(productmod(dp[i+1][1], 2), productmod(dp[i+1][2], 3));
        }else{
            dp[i][0] = addmod(dp[i+1][0], dp[i+1][1]);
            dp[i][1] = dp[i+1][1] % MOD;
            dp[i][2] = addmod(dp[i+1][1], productmod(dp[i+1][2], 3));
        }
    }

    ll ans = 0;
    rep(3){
        ans = addmod(ans, dp[0][i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define itn int
typedef long long ll;
int n;
int w[101],sum[101]={0};
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>w[i];
		sum[i]=sum[i-1]+w[i];
	}
	int ans=1e6;
	for(int i=1;i<=n;i++){
		ans=min(ans,abs(sum[i]-sum[n]+sum[i]));
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

int main() {
  ll N; cin >> N;
  ll result = 0;
  for (ll i=1; i*i<N; i++) {
    if (N%i==0) {
      if (N/(N/i-1)==N%(N/i-1)) result += N/i-1;
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
//vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }
bool com(ll a,ll b,ll M){
    return abs(M-a)<abs(M-b);
}

int main(){
    ll N,sumA=0,sumB=0,hu=0,ans=0;
    cin>>N;
    ll A[N],B[N],v[N];
    for(ll i=0;i<N;i++){
        cin>>A[i];
        sumA+=A[i];
    }
    for(ll i=0;i<N;i++){
        cin>>B[i];
        sumB+=B[i];
        v[i]=A[i]-B[i];
        if(v[i]<0){
            hu+=v[i];
            ans++;
        }
    }
    if(sumA<sumB){
        cout<<"-1"<<endl;
        return 0;
    }
    sort(v,v+N);
    for(ll i=N-1;i>=0;i--){
        if(hu>=0) break;
        if(v[i]<0) continue;
        hu+=v[i];
        ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2560
using System;

public class Hello
{
    public static void Main()
    {
        var a = new string[] { "19890108", "19261225", "19120730", "18680908" };
        var b = new string[] { "heisei", "showa", "taisho", "meiji" };
        var c = new int[] { 1989, 1926, 1912, 1868 };
        string L;
        for (; (L = Console.ReadLine()) != null;)
        {
            string[] line = L.Trim().Split(' ');
            var yyyy = int.Parse(line[0]);
            var mm = int.Parse(line[1]);
            var dd = int.Parse(line[2]);
            var targ = string.Format("{0}{1:00}{2:00}", yyyy, mm, dd);
            var p = 0; var res = "pre-meiji";
            while (p < 4)
            {
                if (targ.CompareTo(a[p]) >= 0) { res = string.Format("{0} {1} {2} {3}", b[p], yyyy - c[p] + 1, mm, dd); break; }
                p++;
            }
            Console.WriteLine(res);
        }
    }
}




Measured memory_bytes: 9740
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a*b, c*d) << endl;
	return 0;
}

Measured memory_bytes: 256
// CGL_2_B
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
using namespace std;

struct vec{
	int x;
	int y;
};

double norm(struct vec a){
	return sqrt(pow((double)a.x, 2) + pow((double)a.y, 2));
}

double inner_p(struct vec a, struct vec b){
	return (a.x*b.x + a.y*b.y);
}

double cross_p(struct vec a, struct vec b){
	return (a.x*b.y - a.y*b.x);
}

int clock(vec p1, vec p2, vec p3){
	vec a, b;
	a.x = p2.x - p1.x;
	a.y = p2.y - p1.y;
	b.x = p3.x - p1.x;
	b.y = p3.y - p1.y;

	if(fabs(cross_p(a, b)) == 0)
		if(inner_p(a, b) < 0)
			return 1;
		else if(norm(a) < norm(b))
			return -1;
		else
			return 0;
	else if(cross_p(a, b) > 0)
		return 2;
	else
		return -2;
}

int intersect(vec p1, vec p2, vec p3, vec p4){
	if((clock(p1, p2, p3)*clock(p1, p2, p4) <= 0) && (clock(p3, p4, p1)*clock(p3, p4, p2) <= 0))
		return 1;
	else
		return 0;


}

int main(){
	vec p[4];
	int q;

	cin>>q;
	for(int i=0;i<q;i++){
		cin>>p[0].x>>p[0].y>>p[1].x>>p[1].y>>p[2].x>>p[2].y>>p[3].x>>p[3].y;

		cout<<intersect(p[0], p[1], p[2], p[3])<<endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(){
int ha,ma,sa,hb,mb,sb,seca,secb,sum,i;
for(i=0;i<3;i++){
scanf("%d %d %d %d %d %d\n",&ha,&ma,&sa,&hb,&mb,&sb);
seca = ha*3600 + ma*60 + sa;
secb = hb*3600 + mb*60 + sb;
sum = secb - seca;
ha = sum/3600;
ma = (sum%3600)/60;
sa = (sum%3600)%60;
printf("%d %d %d\n",ha,ma,sa);
}
return 0;
}

Measured memory_bytes: 604
#include <cstdio>

bool num[2000000];

void prime(){
	num[0] = false;
	num[1] = false;
	for(int i = 2; i < 2000000; i++) num[i] = true;
	for(int i = 2; i < 2000; i++){
		if(!num[i]) continue;
		for(int j = 2*i; j < 2000000; j += i){
			num[j] = false;
		}
	}
}

int main(){
	prime();
	int n;
	while(scanf("%d", &n),n){
		if(num[n]){
			printf("0\n");
			continue;
		}
		int cnt = 0;
		for(int i = 1;;i++){
			if(num[n+i]){
				cnt += i;
				break;
			}
		}
		for(int i = 1;;i++){
			if(num[n-i]){
				cnt += i;
				break;
			}
		}
		printf("%d\n", cnt);
	}
}

Measured memory_bytes: 2992
const log = console.log;

const parseDecimalInt = (s: string) => parseInt(s);
const parseSpaceSeparated = (line: string) => line.trim().split(" ");

const sumReducer = (accumulator: number, currentValue: number) =>
  accumulator + currentValue;
const sum = (numbers: number[]) => numbers.reduce(sumReducer, 0);

const average = (numbers: number[]) => sum(numbers) / numbers.length;

// ----

function Main(input: string): void {
  const data = parseSpaceSeparated(input).map(parseDecimalInt);

  log(Math.ceil(average(data)));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
n, x, y = map(int, input().split())
ans = [0 for i in range(n-1)]
for i in range(n-1):
  k = i + 1
  b_1 = k - x
  if b_1 < 0:
      b_1 = - b_1
  for j in range(i+1, n):
    l = j + 1
    a = l - k
    b_2 = l - y
    if b_2 < 0:
      b_2 = - b_2
    b = b_1 + b_2 + 1
    if b < a:
      a = b
    ans[a-1] += 1
for i in range(n-1):
  print(ans[i])

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

class Dice {
    public:
    int a, s, e, w, n, b;
    void setint(int a1, int s1, int e1, int w1, int n1, int b1);
    int geta();
    int gets();
    int getn();
    int gete();
    int getw();
    int getb();
    
};

void Dice::setint(int a1, int s1, int e1, int w1, int n1, int b1) {
    a = a1;
    s = s1;
    n = n1;
    e = e1;
    w = w1;
    b = b1;
}

int Dice::geta() {
    return a;
}
int Dice::gets() {
    return s;
}
int Dice::getn() {
    return n;
}
int Dice::gete() {
    return e;
}
int Dice::getw() {
    return w;
}
int Dice::getb() {
    return b;
}
int main(void){
    // Here your code !
    Dice dice;
    int n[6];
    for(int i=0;i<6;i++) {
        cin >> n[i];
    }
    string d;
    bool t1, t2, t3, t4;
    cin >> d;
    int r[6] = {1, 2, 3, 4, 5, 6};
    dice.setint(1, 2, 3, 4, 5, 6);
    for(int i=0;i<d.size();i++) {
        if (d[i] == 'S') {
            r[0] = dice.getn();
            r[1] = dice.geta();
            r[4] = dice.getb();
            r[5] = dice.gets();
            dice.setint(r[0], r[1], r[2], r[3], r[4], r[5]);
        } else if (d[i] == 'E') {
            r[0] = dice.getw();
            r[2] = dice.geta();
            r[3] = dice.getb();
            r[5] = dice.gete();
            dice.setint(r[0], r[1], r[2], r[3], r[4], r[5]);
        } else if (d[i] == 'W') {
            r[0] = dice.gete();
            r[2] = dice.getb();
            r[3] = dice.geta();
            r[5] = dice.getw();
            dice.setint(r[0], r[1], r[2], r[3], r[4], r[5]);
        } else {
            r[0] = dice.gets();
            r[1] = dice.getb();
            r[4] = dice.geta();
            r[5] = dice.getn();
            dice.setint(r[0], r[1], r[2], r[3], r[4], r[5]);
        }
    }
    cout << n[(r[0] + 5) % 6] << endl;
    
}

Measured memory_bytes: 3212
package main

import "fmt"

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	field := make([][]string, h)
	queue := make([]point, 0)
	vectors := []vector{{-1, 0}, {0, -1}, {1, 0}, {0, 1}}
	for i := 0; i < h; i++ {
		var line string
		fmt.Scan(&line)
		field[i] = make([]string, w)
		for j, k := range line {
			tmp := string(k)
			field[i][j] = tmp
			if tmp == "#" {
				queue = append(queue, point{i, j})
			}
		}
	}
	count := 0
	for len(queue) > 0 {
		loop := len(queue)
		for i := 0; i < loop; i++ {
			p := queue[0]
			for _, v := range vectors {
				next := point{p.h + v.h, p.w + v.w}
				if next.h < 0 || next.h >= h || next.w < 0 || next.w >= w {
					continue
				}
				if field[next.h][next.w] == "#" {
					continue
				}
				field[next.h][next.w] = "#"
				queue = append(queue, next)
			}
			queue = queue[1:]
		}
		if len(queue) > 0 {
			count++
		}
	}
	fmt.Println(count)
}

type point struct {
	h, w int
}

type vector struct {
	h, w int
}

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

#if __has_include(<local.h>)
#include <local.h>
#endif

using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define IPOW(x,y) LL(pow(x,y))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define DEBUG(a) a
#else
#define TEST
#define DEBUG(a)
#endif

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const int INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;

#ifndef LOCAL_H
    const bool DO_BENCHMARK = false;
#endif

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

/************************************************************************************************************************************************/

void solve(){
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int ans = 0;
    for(int i = 0;;i++){
        if(R*i > N){
            break;
        }
        for(int j = 0;;j++){
            if(R*i+G*j > N){
                break;
            }
            else if((N-(R*i+G*j))%B == 0 && (N-(R*i+G*j))/B >= 0){
                ans++;
                DEBUG(cout << i << j << (N-(R*i+G*j))/B << endl;)
            }
        }
    }
    cout << ans << endl;
}


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

#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define pqMax priority_queue<int>
#define pqMin priority_queue<int, vector<int>, greater<int>>
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie();                        \
    cout.tie()
int n, t, i, j, k;

void solve() {
    cin >> n;
    vvi p(n, vi(3));
    for (i = 0; i < n; i++) {
        for (j = 0; j < 3; j++)
            cin >> p[i][j];
    }
    vi ans(3);
    ans[0] = p[0][0], ans[1] = p[0][1], ans[2] = p[0][2];
    for (i = 1; i < n; i++) {
        int x = p[i][0] + max(ans[1], ans[2]);
        int y = p[i][1] + max(ans[0], ans[2]);
        int z = p[i][2] + max(ans[0], ans[1]);
        ans[0] = x, ans[1] = y, ans[2] = z;
    }
    cout << *max_element(ans.begin(), ans.end()) << '\n';
}

int32_t main() {
    FAST;
    solve();
}

Measured memory_bytes: 8728
N, C = gets.split.map(&:to_i)
channels = N.times.map { gets.split.map(&:to_i) }
c_list = channels.group_by { |_, _, c| c }

MAX_T = 10 ** 5 + 2

channel_query = (1..C).map do |c|
  next if c_list[c].nil?

  record = Array.new(MAX_T, 0)

  c_list[c].each do |s, t, _|
    record[s] += 1
    record[t + 1] -= 1
  end

  query = []
  s = nil
  t = 0

  (1...MAX_T).each do |i|
    t += record[i]

    if t > 0 && s.nil?
      s = i
    elsif t == 0 && !s.nil?
      query << [s, i - 1]
      s = nil
    end

    record[i] += record[i - 1]
  end

  query
end.compact

recorder = Array.new(2 * MAX_T, 0)

channel_query.each do |query_list|
  query_list.each do |s, t|
    recorder[2 * s - 1] += 1
    recorder[2 * t + 1] -= 1
  end
end

ans = 0

(1...(2 * MAX_T)).each do |i|
  recorder[i] += recorder[i - 1]
  ans = recorder[i] if ans < recorder[i]
end

puts ans


Measured memory_bytes: 36604
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

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

using namespace std;

int main(){
    int n, m;
    int wa = 0, ac = 0;
    cin >> n >> m;
    vector<bool> ok(n);
    vector<int> sum(n);

    rep(i, n) ok[i] = false;

    rep(i, m) {
        int num;
        string result;
        cin >> num >> result; 
        if ( result == "WA" ) {
            if (ok[num-1]) {
                continue;
            } else {
                sum[num-1]++; 
            }
        } else {
            if (ok[num-1]) {
                continue;
            } else {
                ok[num-1] = true;
                wa += sum[num-1];
                ac++;
            }
        }

    }

    cout << ac << " " << wa << endl;

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<map>
#include<functional>
using namespace std;

const int dev = 1e9+7;
typedef long long ll;
typedef unsigned long long ull;


ll Choose(ll C, ll D){
    ll DP[C][D+1];
    for (int i=0;i<C;i++){
        for (int j=0;j<min(i+2,(int)(D+1));j++){
            if(j==0) DP[i][j] = 1;
            else if(j==(i+1)) DP[i][j] = 1;
            else DP[i][j] = DP[i-1][j] + DP[i-1][j-1];
        }
    }
    return DP[C-1][D];
}

ll calcPattern(vector<ll> &v, int n){
    int N = v.size();
    int C = upper_bound(v.begin(), v.end(), v[N-n]) - lower_bound(v.begin(), v.end(), v[N-n]);
    int D = upper_bound(v.begin() + (N-n), v.end(), v[N-n]) - lower_bound(v.begin() + (N-n), v.end(), v[N-n]);
    return Choose(C, D);
}

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    vector<ll> v(N);
    for (int i=0;i<N;i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end());

    double maxS = 0;
    for (int i=0;i<A;i++){
        maxS += v[N-1-i];
    }
    printf("%.8f\n", maxS/A);

    if(v[N-1] != v[N-A]){
        int C = upper_bound(v.begin(), v.end(), v[N-A]) - lower_bound(v.begin(), v.end(), v[N-A]);
        int D = upper_bound(v.begin() + (N-A), v.end(), v[N-A]) - lower_bound(v.begin() + (N-A), v.end(), v[N-A]);
        cout << Choose(C, D) << endl;
    }else{
        ull pat = 0;
        int E = upper_bound(v.begin(), v.end(), v[N-1]) - lower_bound(v.begin(), v.end(), v[N-1]);
        for (int i=A;i<min(B+1, E+1);i++){
            pat += Choose(E, i);
        }
        cout << pat << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{

public static void main(String[] args){
Scanner scan = new Scanner(System.in);
 int a = scan.nextInt();
 int b = scan.nextInt();
int multiNum = a*b; 
if(multiNum%2==0){
System.out.println("Even");
}else{
System.out.println("Odd");
}
}
}

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

int main(void){
	long int N,K,ans1,ans2;
	scanf("%ld %ld",&N,&K);
	ans1=N%K;
	ans2=labs(ans1-K);
	if(ans1<=ans2){
		printf("%ld\n",ans1);
	}else{
		printf("%ld\n",ans2);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
typedef pair<int,int> pi;

int arr[4];

int main() {
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	int A,B;
	cin >> A >> B;
	arr[A]++; arr[B]++;
	for (int i = 1; i <= 3; i++) {
		if (arr[i] == 0) {
			cout << i;
			return 0;
		}
	}
}

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

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    ll n,k;
    cin>>n>>k;
    vector<ll> arr(n+1);
    ll i;
    for(i=1;i<=n;++i){
        cin>>arr[i];
    }
    if(k>=n+1){
        cout<<abs(arr[n]-arr[1]);
        return 0;
    }
    vector<ll> dp(n+1,(int)2e9);
    dp[0]=0;
    dp[1]=0;
    for(i=2;i<=k+1;++i){
        dp[i]=abs(arr[i]-arr[1]);
    }
    ll j;
    for(i=k+2;i<=n;++i){
        for(j=1;j<=k;++j){
            dp[i] = min(dp[i-j]+abs(arr[i]-arr[i-j]),dp[i]);
        }
    }
    cout<<dp[n];
}

Measured memory_bytes: 4852
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, r, ans;
	cin >> num >> r;
	if (num >= 10)
		ans = r;
	else {
		ans = r + 100 * (10 - num);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int mod = 1000000007;

inline int fac(int n) {
	int ans = 1;
	for(int i = 1; i <= n; ++i) ans = 1LL * ans * i %mod;
	return ans;
}
int main() {
	int N, M;
	scanf("%d%d", &N, &M);
	if(N < M) swap(N, M);
	if(N > M + 1) {
		puts("0");
		return 0;
	}
	if(N == M) {
		printf("%d\n", (int)(1LL * fac(N) * fac(M) % mod * 2 % mod));
	} else {
		printf("%d\n", (int)(1LL * fac(N) * fac(M) % mod));
	}
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#define mod 1000000007
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int f[55][55][5010];
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read(),m=read();
    if(m&1){pr2(0);return 0;}
    m/=2,f[0][0][n*n]=1;
    for(int i=1;i<=n;i++)
    {
    	for(int j=0;j<=i;j++)
    	{
    		for(int k=0;k<=2*n*n;k++)
    		{
    			int uf=0;
	    		if(j>0)(uf+=1LL*f[i-1][j-1][k]*(2*(i-j)+1)%mod)%=mod;
	    		if(j>1 && k>=i)(uf+=1LL*f[i-1][j-2][k-i]*(i-j+1)%mod*(i-j+1)%mod)%=mod;
	    		if(k+i<=2*n*n)(uf+=f[i-1][j][k+i])%=mod;
	    		f[i][j][k]=uf;
	    	}
    	}
    }pr2(f[n][n][n*n+m]);
   	return 0;
}

Measured memory_bytes: 53632
#include <bits/stdc++.h>
#include <string>
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    ll x;
    cin >> x;
    ll a,b,c,d;
    a = x / 500;
    b = x % 500;
    c = b / 5;
    cout << 1000*a + 5*c << endl;
}


Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n;
cin >> n;
cout << (n >= 30 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3648
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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")
    };
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    let a: usize = read();
    let b: usize = read();
    let c: usize = read();
    println!("{}", max(max(a, b), c) - min(min(a, b), c));
}


Measured memory_bytes: 4352
MOD = 10 ** 9 + 7
fac = [1] * (10 ** 5 + 10)
for i in range(len(fac) - 1):
    fac[i + 1] = fac[i] * (i + 1) % MOD


def comb(n, k):
    if k < 0 or k > n:
        return 0
    return fac[n] * pow(fac[n - k], MOD - 2, MOD) * pow(fac[k], MOD - 2, MOD) % MOD


n = int(input())
a = list(map(int, input().split()))
d = [-1] * n
for i, x in enumerate(a):
    if d[x - 1] != -1:
        p = d[x - 1]
        q = i
    else:
        d[x - 1] = i
print(n)
for k in range(2, n + 2):
    ans = 0
    ans += comb(n - 1, k - 2)
    ans += comb(n - 1, k - 1) * 2 - comb(p + n - q, k - 1)
    ans += comb(n - 1, k)
    print(ans % MOD)


Measured memory_bytes: 58352
A,B=map(int,input().split())
c=[]
d=[]
if int(A*100/8)==A*100/8:
  i=int(A*100/8)
else:
  i=int(A*100/8+1)
while i<(A+1)*100/8:
  c.append(i)
  i+=1
if int(B*100/10)==B*100/10:
  j=int(B*100/10)
else:
  j=int(B*100/10+1)
while j<(B+1)*100/10:
  d.append(j)
  j+=1
if min(c[len(c)-1],d[len(d)-1])<max(c[0],d[0]):
  print(-1)
else:
  print(max(c[0],d[0]))

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}

#define INF 1001001001
#define all(a) begin(a),end(a)

#define int ll
signed main() {
    int N, M, R; cin >> N >> M >> R;
    vi r(R); rep(i, R) { cin >> r[i]; r[i]--; } sort(all(r));
    vvi c(N, vi(N, INF));
    rep(i, N) c[i][i] = 0;
    rep(i, M) {
        int A, B, C; cin >> A >> B >> C; A--; B--;
        c[A][B] = c[B][A] = C;
    }

    rep(k, N) rep(i, N) rep(j, N) chmin(c[i][j], c[i][k] + c[k][j]);    

    int ans = INF;
    do {
        int cost = 0;
        rep1(i, R) {
            cost += c[r[i]][r[i-1]];
        }
        chmin(ans, cost);

    } while (next_permutation(all(r)));

    cout << ans << endl;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	string S, T;
	cin >> S >> T;

	map<char, char> dowmMap, upMap;

	rep(i, 0, SZ(S))
	{
		if (dowmMap.count(S[i])>0||upMap.count(T[i])>0)
		{
			if (dowmMap[S[i]] != T[i] || upMap[T[i]] != S[i])
			{
				cout << "No" << endl;
				return 0;
			}
		}
		dowmMap[S[i]] = T[i];
		upMap[T[i]] = S[i];
	}

	cout << "Yes" << endl;

	return 0;
}

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

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

typedef long long ll;

int main(void)
{
   int A,B;
   cin >> A >> B;
   if (B%A == 0) {
       cout << A+B << endl;
   }else {
       cout << B-A << endl;
   }
}


Measured memory_bytes: 256
/*
problem's name:
statue:
writer:Patrick_y
*/
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#include <cctype>
#include <sstream>
#include <math.h>
#include <stdio.h>
#include <time.h>
#define mp make_pair
typedef long long ll;
using namespace std;
const int INF=20050208;
/*------------main part------------*/



int east[300005];
int west[300005];
int w,e;
int tot_w,tot_e;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		char c;
		cin>>c;
		if(c=='E')
		{
			east[i]=1;
			tot_e++;
		}
		else
		{
			west[i]=1;
			tot_w++;
		}
	}
	int ans=1e9;
	for(int i=0;i<n;i++)
	{
		int a;
		if(east[i]==1)
		{
			a=w+tot_e-e-1;
		}
		else
		{
			a=w+tot_e-e;
		}
		ans=min(a,ans);
		if(west[i])
		{
			w++;
		}
		else
		{
			e++;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>

using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<int> a(n + 1), b(n + 1), c(n + 1);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    vector<vector<int>> dp(n + 1, vector<int>(3));

    for (int i = 0; i < 3; i++)
    {
        dp[0][i] = 0;
    }

    for (int i = 0; i < n; i++)
    {
        dp[i + 1][0] = max(dp[i][1] + a[i], dp[i][2] + a[i]);
        dp[i + 1][1] = max(dp[i][0] + b[i], dp[i][2] + b[i]);
        dp[i + 1][2] = max(dp[i][0] + c[i], dp[i][1] + c[i]);
    }

    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
    return 0;
}


Measured memory_bytes: 6912
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ARC78_C
{
    class Program
    {
        static void Main(string[] args)
        {

            var n = int.Parse(Console.ReadLine());

            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var sum = new long[n];
            sum[0] = a[0];
            for (int i = 1; i < n; i++)
            {
                sum[i] = sum[i - 1] + a[i];
            }

            long ans = long.MaxValue;
            for (int i = 0; i < n - 1; i++)
            {
                long x = sum[i];
                long y = sum[n - 1] - sum[i];
                ans = Math.Min(ans, Math.Abs(x-y));
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 35012
from math import gcd

def main():
    K = int(input())
    table = [[0]*K for i in range(K)]
    for i in range(K):
        for j in range(K):
            table[i][j] = gcd(i + 1, j + 1)
    ans = 0
    for i in range(K):
        for j in range(K):
            for k in range(K):
                ans += table[i][table[j][k]-1]
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9384
//
//  main.c
//  ITP1_7_A
//
//  Created by k16031kk on 2018/05/25.
//  Copyright © 2018年 AIT. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int m,f,r;
    scanf("%d %d %d", &m, &f, &r);
    
    //while(m!=-1 && f!=-1 && r!=-1) {
    while(1){
        int sum=0;
        sum=m+f;
        if(m==-1 && f==-1 && r==-1) break;
        if(m==-1 || f==-1) {
            printf("F\n");
        } else if(sum>=80) {
            printf("A\n");
        } else if(sum>=65 && sum<80) {
            printf("B\n");
        } else if(sum>=50 && sum<65) {
            printf("C\n");
        } else if(sum>=30 && sum<50) {
            if(r>=50) {
                printf("C\n");
            } else {
                printf("D\n");
            }
        } else if(sum<30) {
            printf("F\n");
        }
        scanf("%d %d %d", &m, &f, &r);
    }
    
    return 0;
}




Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if (a>=1 && a<=9 && b>=1 && b<=9)
    printf("%d\n",(a*b));
    else
    printf("-1\n");
    return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int) (v).size()

#define rep(i,a,b) for(int (i) = (a); (i) < (b); ++(i))
#define trav(a, x) for(auto& a : x)

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define shandom_ruffle random_shuffle
#define funoredered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using funordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

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

constexpr int INF = 0x3f3f3f3f;
constexpr int NINF = 0xc0c0c0c0;
constexpr double EPS = 1e-8;
constexpr ll MOD = 1000000007LL;

template <typename T>
using ordered_set = 
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll modPow( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

inline int cmp_double( double x, double y, double tol = EPS) {
    return (x <= y + tol) ? ( x + tol < y) ? -1 : 0 : 1;
}

int main()
{
    ios::sync_with_stdio(0); cin.tie(NULL);
    int n;
    cin >> n;
    vector<long long> h(n), a(n);
    for(auto& x : h) cin >> x;
    for(auto& x : a) cin >> x;
    
    set< pair< long long, long long> > memo;
    memo.emplace(0LL, 0LL);

    for(int i = 0; i < n; ++i) {
        long long alt = h[i];
        auto it = memo.lower_bound( make_pair(alt, 0) );
        if(it != memo.begin() ) {
            auto it2 = it;
            it2--;
            memo.emplace( alt, it2->second + a[i] );
            vector< pair<long long, long long> > toErase;
            auto it3 = memo.upper_bound( make_pair( alt, it2->second + a[i] ) );
            while( it3 != memo.end() ) {
                if( it3->second <= it2->second + a[i] ) {
                    toErase.emplace_back( *it3 );
                }
                else break;
                ++it3;
            }
            for(auto& v : toErase) memo.erase( v );
        }
        else {
            memo.emplace(alt, a[i] );
            auto it = memo.upper_bound( make_pair( alt, a[i] ) );
            vector< pair< long long, long long> > toErase;
            while( it != memo.end( ) ){
                if( it->second <= a[i] ) {
                    toErase.emplace_back( *it );
                }
                else break;
            }
            for(auto& v : toErase) memo.erase(v);
        }
    }
    long long best = 0LL;
    for(const auto& v : memo) best = max( best, v.second );
    cout << best << endl;
}



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

int main()
{
  long long int x;
  cin>>x;
  unsigned long long int ans=0;
  while(x>0)
  {
    if(x/500 !=0)
    {
      ans+=(1000*(x/500));
      x=x%500;
    }
    else if(x/5 !=0)
    {
      ans+=(5*(x/5));
      x=x%5;
    }
    else
    {
      x=0;
    }
  }
  
  cout<<ans<<endl;
  return 0;
}
      

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

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

    rep(i, n) {
        int x;
        cin >> x;
        a[x]++;
    }

    int ans = 0;
    for (auto e: a) {
        if (e.first < e.second) ans += e.second - e.first;
        else if (e.first > e.second) ans += e.second;
    }

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


Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  ll n,a,b;
  cin>>n>>a>>b;

  if(n==1 && a!=b){
    cout<<0<<endl;
    return 0;
  }
  if(a>b){
    cout<<0<<endl;
    return 0;
  }

  cout<<(b*(n-1)+a)-(a*(n-1)+b)+1<<endl;

  return 0;
}

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

int main() {
  string s;
  cin >> s;
  
  vector<char> answer;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'B') {
      if (answer.empty()) continue;
      answer.pop_back();
    } else {
      answer.push_back(s[i]);
    }
  }
  
  for (int i = 0; i < answer.size(); i++) {
    cout << answer[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i< (n);i++)
#define SORT(a) sort((a).begin(),(a).end());
#define che(a,string) cout<<string<<":"<<(a)<<endl;
#define ch(a,string) cout<<string<<":"<<(a)<<" ";
using namespace std;
typedef pair<int,int> p;
int main(){
	int n;int q;
	cin>>n;
	cin>>q;
	string S;
	cin>>S;
  vector<int> A(1);
  A[0]=0;
	int count = 0;
	for(int i = 1 ; i < n ; i ++){
	if(S[i]=='C'&&S[i-1]=='A'){
		count++;
		A.push_back(count);
	  }
	  else {
		  A.push_back(count);
	}
	}
	/*	rep(i,n){
			cout<<A[i];
		  }
		  //キタコレ*/
	vector<int> ans(q);
	rep(i,q){
		int l,r;
		cin>>l>>r;
		ans[i]=A[r-1]-A[l-1];
	  }
	  rep(i,q){
		cout <<ans[i]<<endl;
		}
}	



Measured memory_bytes: 1912