akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <queue>
#include <map>
using namespace std;
#define pb          emplace_back
#define fi          first
#define se          second
#define show(...)   fprintf(stderr, __VA_ARGS__ )
#define outl(x)     cout << (x) << '\n'
#define rep(i,n)    for(int i=0; i<(n); ++i)
#define inside(x,y,w,h) ((x)>=0 && (y)>=0 && (x)<(w) && (y)<(h))
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
constexpr int       INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int dx[] = {1, 0, -1, 0};
constexpr int dy[] = {0, 1, 0, -1};


int D , N;

vector<ll> a;

int f(int n) {
    int cnt = 0;
    while (n % 100 == 0) {
        ++cnt;
        n /= 100;
    }
    return (cnt);
}

signed main()
{
    cin.tie(0), ios::sync_with_stdio(false);
    cin >> D>> N;

    int p = 1;
    rep(i, D) p *= 100;

    for (int i=1; a.size() <= N; ++i) {
        if (f(i * p) == D) {
            a.push_back(i*p);
        }
    }

    outl(a[N-1]);
}



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

tmp = s
a = [s]

while True:
    if tmp % 2 == 0:
        num = (tmp // 2)
        a.append(num)
        tmp = num
    else:
        num = 3 * tmp + 1
        a.append(num)
        tmp = num
    if a.count(tmp) == 2:
        print(len(a))
        break



Measured memory_bytes: 3060
<?php
  list($n, $l) = explode(" ", trim(fgets(STDIN)));
  $a = [];
  for ($i=0; $i<$n; $i++) {
    list($a[]) = explode(" ", trim(fgets(STDIN)));
  }

  sort($a);

  for ($i=0; $i<$n; $i++) {
    echo $a[$i];
  }

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

int main(){
	int N;
	cin >> N;
	vector<int> a(N);
	vector<int> b(N);
	for(auto &i:a)cin >> i;
	
	for(int i=0;i<N;i++){
		int pos=N-1-i;
		if((N-1-pos)%2==0)b[(N-1-pos)/2]=a[pos];
		else b[N-1-(N-1-pos)/2]=a[pos];
	}
	for(int i=0;i<N-1;i++)cout << b[i] << " ";
	cout << b[N-1] << endl;
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	int a;
	while(cin>>a){
		for(int i=1;i<=39;i++){
			a--;
			if(a==0){printf("3C%02d\n",i);break;
			}
			if(i==39)i=0;
		}
	}
	return 0;
}

Measured memory_bytes: 3068
#include<cstdio>
#include<cstring>

char n[102];
int k, l, memo[101][3];

int dfs(int x, int cnt, bool f) {
    if (cnt == k) return 1;
    if (x == l) return 0;
    if (f && memo[x][cnt] != -1) return memo[x][cnt];
    int res = 0;
    if (f) {
        res += dfs(x + 1, cnt, true);
        for (int i = 1; i <= 9; i++) res += dfs(x + 1, cnt + 1, true);
    }
    else {
        res += dfs(x + 1, cnt, n[x] > '0');
        for (int i = 1; i <= n[x] - '0'; i++) res += dfs(x + 1, cnt + 1, i < n[x] - '0');
    }
    if (f) memo[x][cnt] = res;
    return res;
}

int main() {
    scanf("%s", n);
    scanf("%d", &k);
    l = strlen(n);
    memset(memo, -1, sizeof(memo));
    int ans = dfs(0, 0, false);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <vector>
using namespace std;
#define FOR(__I,__N) for (int __I = 0; __I < __N; ++__I)

typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64, int64> pll;
typedef double db;
typedef long double ldb;

const int INF = 0x3f3f3f3f;
const int64 INF64 = 0x3f3f3f3f3f3f3f3fLL;

const int dir[4][2] = {{-1,0},{1,0},{0,1},{0,-1}};

const int MOD = 1000000007;

const int MAX_H = 1000000;
const int MAX_W = 1000000;

map<int,bool> maze[MAX_W];
map<int,int> dist[MAX_W];


int H,W,K;	
pii que[5*MAX_H];

int solve(int x1,int y1,int x2,int y2){
	int qs = 0, qt = 0;
	FOR(i,H)	FOR(j,W)	dist[i][j] = INF;

	que[qt++] = pii(x1,y1);
	dist[x1][y1] = 0;
	
	while(qs < qt){
		pii p = que[qs++];
		int x = p.first, y = p.second;
		int d = dist[x][y];
		if(x == x2 && y == y2)	return d;

		FOR(k,4){
			int xx = x, yy = y;
			FOR(step,K){
				xx += dir[k][0];
				yy += dir[k][1];

				if(xx < 0 || xx > H)	break;
				if(yy < 0 || yy > W)	break;
				if(maze[xx][yy])	break;
				int &dd = dist[xx][yy];
				if(dd > d+1){
					dd = d+1;
					que[qt++] = pii(xx,yy);
				}	
				if(dd <= d){
					break;
				}
			}
		}
	}

	return -1;
}

char buff[MAX_H+1];

int main(){
	cin >> H >> W >> K;
	int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;
	--x1, --y1;
	--x2, --y2;
	FOR(i,H){
		scanf(" %s",buff);
		FOR(j,W)	maze[i][j] = buff[j]=='@';
	}

    int ans = solve(x1,y1,x2,y2);
    printf("%d\n",ans);
}





Measured memory_bytes: 252876
<?php

fscanf(STDIN, '%d', $n);

$max = -INF;
fscanf(STDIN, '%d', $min);

for ($j = 1; $j < $n; $j++) {
    fscanf(STDIN, '%d', $R);
    $max = max($max, $R - $min);
    $min = min($min, $R);
}

echo $max, PHP_EOL;

Measured memory_bytes: 6548
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf 2000000000
#define EPS 1e-6
#define MOD 998244353ll
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;

inline void solve()
{
	int k, n;
	cin >> k >> n;
	vector<int> v(n);
	fore(i, 0, n)
		cin >> v[i];

	int otv = 0;
	fore(i, 0, n - 1)
		otv = max(otv, v[i + 1] - v[i]);
	otv = max(otv, v[0] + k - v[n - 1]);

	cout << k - otv;
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	while (q--)
	{
		solve();
		cout << '\n';
	}
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int a , b ;
    char op;
    while(1){
        cin >> a >> op >> b;
    if(op == '?') break;
    
    if(op == '+') cout << a + b << endl;
    else if(op == '-') cout << a - b << endl;
    else if(op == '*') cout << a * b << endl;
    else if(op == '/') cout << a / b << endl;
        }
return 0;
}

Measured memory_bytes: 1164
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;


namespace AtCoder
{
    class AC
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;


        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();
            string S = Console.ReadLine();
            int[] c = { 0, 0, 0 };
            for(var i = 0; i < S.Length; i++)
            {
                c[S[i] - 'a']++;
            }
            Console.WriteLine(c.Max() - c.Min() <= 1 && c[0] >= S.Length / 3 && c[1] >= S.Length / 3 && c[2] >= S.Length / 3 ? "YES" : "NO");
            
            //Console.Out.Flush();
        }
       
    }
        public class Scanner
        {
            public int[] SplitReader()
            {
                int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
                return array;
            }
            public long[] SplitReaderL()
            {
                long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
                return array;
            }
        }

      


}






Measured memory_bytes: 13268
#!python3.8
# -*- coding: utf-8 -*-
# abc174/abc174_c
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    K = i2n()
    a = 0
    if K % 7:
        L = 9 * K
    else:
        L = 9 * K // 7
    a = 1
    for i in range(1, K + 10):
        a = (a * 10) % L
        if a == 1:
            print(i)
            return
    print('-1')
    return
 
main()


Measured memory_bytes: 9232
#include <cstdio>
int N, M, f[100001], w[100001], b[100001], d[100001];
int F(int x)
{
	if (f[x] == x)
		return x;
	F(f[x]);
	w[x] ^= w[f[x]];
	return f[x] = f[f[x]];
}
int main()
{
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= N; i++)
		f[i] = i;
	for (int i = 1, u, v; i <= M; i++)
	{
		scanf("%d%d", &u, &v);
		d[u]++;
		d[v]++;
		int fu = F(u), fv = F(v);
		if (fu == fv)
		{
			if (w[u] == w[v])
				b[fu] = 1;
		}
		else
		{
			b[fu] |= b[fv];
			w[fv] = w[u] ^ w[v] ^ 1;
			f[fv] = fu;
		}
	}
	int c1 = 0, ce = 0, c = 0;
	for (int i = 1; i <= N; i++)
		if (!d[i])
			c1++;
		else if (F(i) == i)
		{
			c++;
			if (!b[i])
				ce++;
		}
	printf("%lld\n", (long long)c * c + (long long)ce * ce + (long long)N * N - (long long)(N - c1) * (N - c1));
	return 0;
}


Measured memory_bytes: 1664
n,k = (int(i) for i in input().split())
fn,fk,mod = [1]*n,[1]*n,10**9+7
for i in range(n-1): fn[i+1] = (fn[i]*(i+2))%mod
def power(n,k):
    if k==1: return n
    elif k%2==0: return power((n**2)%mod,k//2)
    else: return (n*power(n,k-1))%mod
def comb(n,k):
    if n<k: return 0
    elif n==0 or k==0 or n==k: return 1
    else: return (((fn[n-1]*fk[n-k-1])%mod)*fk[k-1])%mod
fk[-1] = power(fn[-1],mod-2)
for i in range(2,n+1): fk[-i] = (fk[-i+1]*(n+2-i))%mod
for i in range(k): print((comb(k-1,i)*comb(n-k+1,i+1))%mod)

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	long long int a[n];
	for(int i=0;i<n;i++)
	 cin>>a[i];
	long long int sum=0;
	map<long long int ,long long int> mp;
	for(int i=0;i<n;i++)
	 {
	 	mp[a[i]]++;
	    sum+=a[i];
	 }
	int q;
	cin>>q;
	while(q--)
	 {
	 	long long int bi,ci;
	 	cin>>bi>>ci;
	 	if(mp.find(bi)==mp.end())
	 	 cout<<sum<<endl;
	 	else 
	 	 {
	 	    sum+=ci*mp[bi]-bi*mp[bi];
	 	    mp[ci]+=mp[bi];
	 	    mp.erase(bi);
	 	    cout<<sum<<endl;
	 	 }
	 }
	return 0;
}

Measured memory_bytes: 8368
#include <iostream>

using namespace std;

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

  int a, b, c;
  cin >> a >> b >> c;
  if (b - a == c - b) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


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

const ll mod = 1e9;
const int INF = 1<<29;

int main(){
    int x;
    cin >> x;
    if (x < 100) cout << 0 << endl;
    else{
        int num = x / 100;
        x %= 100;
        for (int i=5;i>0;i--){
            num -= x / i;
            x %= i;
        }
        if (num >= 0) cout << 1 << endl;
        else cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;using std::queue;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;using std::swap;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::vector<int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}

namespace ndifix{
template<class T> void sort(T &v){std::sort(v.begin(),v.end());}
template<class T> void rsort(T &v){std::sort(v.rbegin(),v.rend());}
}

int main(){
  int n;cin>>n;
  vector<int> a(n);for(int i=0;i<n;i++)cin>>a[i];
  vector<int> m(n);
  m[0]=2000000000;
  LL buf=0;
  int sgn[2]={-1,1};
  for(int i=0;i<n-1;i++)buf+=a[i]*sgn[i%2];
  m[0]=a[n-1]-buf;m[0]*2;
  for(int i=1;i<n;i++){
    m[i]=a[i-1]-m[i-1]/2;m[i]*=2;
  }
  for(int i=0;i<n;i++)cout<<m[i]<<(i==n-1?"\n":" ");
  
  return 0;
}


Measured memory_bytes: 2048
/*
Aoj CGL_2_A
题意 T组数据 每次给出4个点 p1,p2,p3,p4
p1与p2的向量是p_1
p3与p4的向量是p_2;
当p_1与p_2平行时输出2，正交输出1，其他输出0
可以用向量的内积和外积做这题  
*/
#include<bits/stdc++.h>
#define eps (1e-10)
using namespace std;
class Point
{
	public:
	double x,y;
	Point(double _x=0,double _y=0):x(_x),y(_y){}
	Point operator -(Point p){
		return Point(x-p.x,y-p.y);
	}
};
//判断是否正交 向量内积：a*b=|a||b|*cos(Y) 当cos为0时正交(90,-90垂直) 
//a*b=a.x*b.x+a.y*b.y;
bool solve1(Point a,Point b)
{
	double f=a.x*b.x+a.y*b.y; 
	if(fabs(f-0.0)<eps) return true;
	else return false;
}
//判断是否平行  向量外积：|a*b|=|a||b|sin(Y) 当sin为0时平行(180,0平行)
//|a*b|=|a|*|b|*sin(Y) 
bool solve2(Point a,Point b)
{
	double f=a.x*b.y-a.y*b.x;
	if(fabs(f-0.0)<eps) return true;
	else return false;
}
int main()
{
	int T;scanf("%d",&T);
	while(T--){
		double p1_x,p1_y,p2_x,p2_y,p3_x,p3_y,p4_x,p4_y;
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&p1_x,&p1_y,&p2_x,&p2_y,&p3_x,&p3_y,&p4_x,&p4_y);
		Point a1(p1_x,p1_y),a2(p2_x,p2_y),b1(p3_x,p3_y),b2(p4_x,p4_y);
		if(solve1(a1-a2,b1-b2)) printf("1\n");
		else if(solve2(a1-a2,b1-b2)) printf("2\n");
		else printf("0\n");
		
	}
	return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(){
    map<int,int> a;
    int n, m;
    cin >> n;
    vector<int>d(n);
    for(int i=0; i<n; i++){
        cin >> d[i];
        a[d[i]]++;
    }
    cin >> m;
    if(n<m){
        puts("NO");
        return 0;
    }
    vector<int>t(m);
    for(int i=0; i<m; i++){
        cin >> t[i];
        if(a[t[i]]) a[t[i]]--;
        else{
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    return 0;
}

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

int main() {
    int64_t n, tt;
    cin >> n >> tt;
    vector<int64_t> t(n);
    for (auto& e : t) cin >> e;
    int64_t ans = 0;
    for (int64_t i = 0; i+1 < n; i++) ans += min(tt, t[i+1]-t[i]);
    cout << ans+tt << endl;
}


Measured memory_bytes: 1792
S = input()
Q = int(input())
cnt = 0
l = ''
r = ''
for i in range(Q):
    tmp = list(map(str,input().split()))
    if len(tmp) == 1:
        cnt += 1
    else:
        if cnt % 2 == 0:
            if tmp[1] == '1':
                l = l + tmp[2]
            else:
                r = r + tmp[2]
        else:
            if tmp[1] == '1':
                r = r + tmp[2]
            else:
                l = l + tmp[2]
if cnt % 2 == 0:
    ans = l[::-1] + S + r
else:
    ans = r[::-1] + S[::-1] + l
print(ans)

Measured memory_bytes: 4468
#include<bits/stdc++.h>
using namespace std;
int main()
{     
  int a,b[100]={0},i,sum=0,j;
  scanf("%d",&a);
  for(i=1;i<=a;i++)
  scanf("%d",&b[i]);
  for(i=1;i<=a;i++)
  { int t=i,m;
  	for(j=i;j<=a;j++)
  	{  
  	if(b[t]>b[j])
  	t=j;
	  }
	  if(t!=i)
	  {
	  m=b[t];
	  b[t]=b[i];
	  b[i]=m;
	  sum++;	
	  }
	  if(sum>1)
	  break;
  }
  if(sum>1)
  printf("NO");
  else
  printf("YES");
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
    int N,K;
    cin >> N >> K;
    int a=1;
    REP(i,N){
        if(a<K){
            a *= 2;
        }else{
            a += K;
        }
    }
    cout << a;
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self, N):
        self.N = N  # ノード数
        # 親ノードを示す。負は自身が親ということ。親だった場合は−(その集合のサイズ)
        self.parent = [-1] * N

    def root(self, A):
        # Aがどのグループに属しているか調べる
        # ノード番号を受けとって一番上の親ノードの番号を返す
        # print(A)
        if self.parent[A] < 0:
            return A
        self.parent[A] = self.root(self.parent[A])
        return self.parent[A]

    def size(self, A):
        # 自分のいるグループの頂点数を調べる
        return -self.parent[self.root(A)]

    def unite(self, A, B):
        # AとBをくっつける
        # AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = self.root(A)
        B = self.root(B)

        if A == B:
            return False  # すでにくっついてるからくっつけない

        if self.size(A) < self.size(B):
            # 大きい方(A)に小さいほう(B)をくっ付けたい
            # 大小が逆だったらひっくり返しちゃう。
            A, B = B, A

        # Aのサイズを更新する
        self.parent[A] += self.parent[B]
        # Bの親をAに変更する
        self.parent[B] = A

        return True

    def same(self, A, B):
        return self.root(A) == self.root(B)


N, M = map(int, input().split())

uf = UnionFind(N)

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.unite(a, b)

fri = [0] * N
for i in range(N):
    fri[i] = uf.size(i)
# print(fri)
print(max(fri))


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

int main()
{
    string s;
    cin>>s;
    map<char,int>mp;
    int i,count = 0;
        for(i=0; i<s.size(); i++)
    {
        mp[s[i]]++;
    }
    for(i=97; i<=122; i++)
    {
        if(mp[i]>1)
            count = 1;
    }
    if(count==0)
        cout<< "yes"<<endl;
    else
        cout<< "no"<<endl;
    return 0;
}

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

main(){
 int ans=0;
 char s[3];
 cin >> s[0] >> s[1] >> s[2];
 if (s[0]== '1') ans++;
 if (s[1]== '1') ans++;
 if (s[2]== '1') ans++;
 cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

A = [0]*N

for i in range(N-1):
    if H[i] >= H[i+1]:
        A[i] += 1

for i in range(1,N):
    if A[i-1] != 0 and A[i] >= 1:
        A[i] += A[i-1]

print(max(A))

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

int main(){
    int N,K;
    cin >> N >> K;
    int ans = 1;
    for (int i = 0; i < N; i++){
        
        if ((ans + K) < 2*ans){
            ans += K;
        }
        else{
            ans *= 2;
        }

    }
    cout << ans << endl;
}

Measured memory_bytes: 3568
import sys, math
input = sys.stdin.readline
n = int(input())
a = [int(x) for x in input().split()]

m = max(a)
primes = list(range(m+1))
primes[1] = 0
for i in range(2, m+1, 2): primes[i] = 2

for i in range(3, int(m ** 0.5)+1):
    if primes[i] < i: continue
    for j in range(i, m+1, i):
        primes[j] = i

b = [0] * (m + 1)
jdg_p = True
for aa in a:
    aset = set()
    while aa != 1:
        aset.add(primes[aa])
        aa //= primes[aa]
    for aaset in aset:
        b[aaset] += 1
        if b[aaset] >= 2:
            jdg_p = False
            break
        else:
            b[aaset] += 1
    if not jdg_p: break

x = a[0]
jdg_s = True
for aa in a[1:]:
    x = math.gcd(x, aa)
if x != 1: 
    jdg_s = False

if jdg_p: print('pairwise coprime')
elif jdg_s: print('setwise coprime')
else: print('not coprime')

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

int root(int a, vector<int>& v){
  if(v[a] == a) return a;
  return (v[a] = root(v[a], v));
}

bool same(int a, int b, vector<int>& v){
  return root(a,v) == root(b,v);
}

void unite(int a, int b, vector<int>& v){
  v[root(a,v)] = root(b,v);
}

int main(){
  int n,q;
  cin >> n >> q;
  vector<int> v(n);
  for(int i = 0; i < n; i++){
    v[i] = i;
  }
  int c,x,y;
  for(int i = 0; i < q; i++){
    cin >> c >> x >> y;
    if(c == 0) unite(x,y,v);
    else{
      if(same(x,y,v)) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
cs int N = 2e6 + 50;
int n, p[N]; char S[N];
int ch[N][3], tag[N], vl[N], nd, pw[20];
int build(int d, int v){
	if(!d) return vl[++nd]=v, nd; int x=++nd;
	ch[x][0]=build(d-1, v);
	ch[x][1]=build(d-1, v + pw[n-d]);
	ch[x][2]=build(d-1, v + 2 * pw[n-d]); return x;
}
void put(int x){ if(!x) return; tag[x] ^= 1; swap(ch[x][1],ch[x][2]); }
void down(int x){ if(tag[x]) put(ch[x][0]),put(ch[x][1]),put(ch[x][2]),tag[x]=0; }
void work(int x, int d){
	if(!d) return;
	down(x); int v = ch[x][2]; ch[x][2] = ch[x][1]; 
	ch[x][1] = ch[x][0]; ch[x][0] = v; 
	work(v,d-1);
}
void dfs(int x, int d, int v=0){
	if(!d) return p[vl[x]] = v, void();
	down(x); dfs(ch[x][0],d-1,v);
	dfs(ch[x][1],d-1,v + pw[n-d]);
	dfs(ch[x][2],d-1,v + 2 * pw[n-d]);
}
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%d",&n); pw[0]=1;
	for(int i=1; i<=n; i++) pw[i]=pw[i-1]*3;
	scanf("%s",S); int m=strlen(S);
	build(n,0);
	for(int i=0; i<m; i++){
		if(S[i]=='R') work(1,n);
		if(S[i]=='S') put(1);
	} dfs(1,n); 
	for(int i=0; i<pw[n]; i++) cout << p[i] << " ";
	return 0; 
}

Measured memory_bytes: 21900
#include<iostream>
#include<algorithm>
#include <array>
int main(void){
	int x,y,temp;

		while(1){
		std::cin >>x>>y;
		if (x == 0&&y == 0){
			break;
		}
		if (x > y){
			std::swap(x, y);
		}
		std::cout << x <<" "<< y << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll A, B, N;
  cin >> A >> B >> N;
  cout << A*min(B-1, N) / B << endl;

  return 0;
}

Measured memory_bytes: 3592
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(int n, int K) {
        const int MOD = 1e9 + 7;
        auto norm = [&](long long a) {
            a %= MOD;
            if (a < 0) {
                a += MOD;
            }
            if (a >= MOD) {
                a -= MOD;
            }
            return a;
        };

        auto power = [&](long long x, long long e) {
            long long res = 1;
            while (e > 0) {
                if (e & 1) {
                    res = (res * x) % MOD;
                }
                e >>= 1;
                x = (x * x) % MOD;
            } 
            return res;
        };
        auto inverse = [&](long long a) {
            long long b = MOD;
            long long u = 0, v = 1;
            a = norm(a);
            while (a != 0) {    
                long long d = b / a;
                b -= d * a;
                u -= d * v;
                swap(a, b);
                swap(u, v);
            }

            u = norm(u);
            return u;
        };

        const int N = n + 100;
        vector<long long> F(N + 1, 1);
        vector<long long> IF(N + 1, 1);
        for (int i = 1; i <= N; ++i) {
            F[i] = F[i - 1] * i % MOD;
        }
        IF[N] = inverse(F[N]);
        for (int i = N - 1; i > 0; --i) {
            IF[i] = IF[i + 1] * (i + 1) % MOD;
        }

        auto nCr = [&](int n, int r) -> long long {
            long long res = F[n] * IF[r] % MOD * IF[n - r] % MOD;
            return res;
        };

        auto ok = [&](int m) {
            if (n - m <= K) {
                return true;
            }
            return false;
        };

        long long res = 0;
        for (int i = 1; i <= n; ++i) {
            if (ok(i)) {
                res += (nCr(n, i) * nCr(n - 1, i - 1)) % MOD;
                res %= MOD; 
            }
        }
        return res;
    }
};

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

    int n, k;
    cin >> n >> k;
    Solution sol;

    cout << sol.solve(n, k) << "\n";

    return 0;
}

Measured memory_bytes: 3328
#!/usr/bin/env python3
from itertools import combinations
import sys
input = sys.stdin.readline
MOD = 10**9 + 7

t1, t2 = [int(item) for item in input().split()]
a1, a2 = [int(item) for item in input().split()]
b1, b2 = [int(item) for item in input().split()]
a1 *= t1
b1 *= t1
a2 *= t2
b2 *= t2

if a1 + a2 == b1 + b2:
    print("infinity")
    exit()
if a1 + a2 > b1 + b2:
    a1, a2, b1, b2 = b1, b2, a1, a2

diff = (b1 + b2) - (a1 + a2)
mid_diff = b1 - a1
if mid_diff > 0:
    print(0)
else:
    ans = (abs(mid_diff) + diff - 1) // diff * 2
    if abs(mid_diff) % diff == 0:
        ans += 1
    print(ans - 1)

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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};




int main(){
	string a; cin >> a;
	for(int i = 0; i < a.size(); i+=2){
		cout << a[i];
	}
	cout << endl;

	return 0;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    int a,b;cin>>a>>b;
    if(a-(b*2)<0){
        cout<<0<<endl;
    }
    else{
        cout<<a-(b*2)<<endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <memory.h>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <queue>
#include <complex>
#include <cstring>

using namespace std;

#define FILE_PREFIX "../../../../../../../../CompetitiveProgramming/CF/CF/"
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR((i), 0, (n))
#define ll unsigned int
#define pb push_back

const int N = 3e5*32;
const int MOD = 1e9 + 7;

long long n, m;

int main() {
//        freopen(FILE_PREFIX"input.txt", "r", stdin);
    ios :: sync_with_stdio(false);

    cin >> n >> m;
    if (n > m) swap(n, m);
    if (n == 1) {
        if (m == 1) cout << 1 << endl;
        else cout << m - 2 << endl;
        return 0;
    }
    
    long long res = (n - 2) * (m - 2);
    cout << res << endl;
    
//    n = 10;
//    k = 10;
//    for (int k0 = 1; k0 <= k; ++k0) {
//        go[k0][0] = 0;
//        for (int i = 1; i <= n; ++i) {
//            int vals = floor(i / k0);
//            set<int> grandi;
//
//            for (int take = 1; take <= vals; ++take) {
//                grandi.insert(go[k0][i - take]);
//            }
//
//
//            int res = 0;
//            while (grandi.find(res) != grandi.end()) res++;
//            go[k0][i] = res;
//        }
//        for (int i = 0; i <= n; ++i) cout << go[k0][i] << " ";
//        cout << endl;
//    }
    
    return 0;
}


Measured memory_bytes: 256
# import math
# import collections
# from pprint import pprint

# n = int(input())
n, m = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))
a = []
for i in range(n):
    a.append(list(input()))
b = []
for i in range(m):
    b.append(list(input()))

judge = False
for offset_i in range(n - m + 1):
    for offset_j in range(n - m + 1):

        flg = 0
        for i in range(m):
            for j in range(m):
                if a[i + offset_i][j + offset_j] == b[i][j]:
                    flg += 1

        if flg == m * m:
            judge = True
            # print('find', offset_i, offset_j)

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


Measured memory_bytes: 9080
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    a, b = map(int, input().split())

    print(max(a + b, a - b, a * b))


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


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

int a[100005];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s == "E869120")
            ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3224
#include <stdio.h>

int main(){

    int i=0;
    int x[3000];
    int y[3000];


    do{
        scanf("%d %d",&x[i],&y[i]);
        
        if(x[i] == 0 && y[i] == 0){
            break;
        }

        i++;

    }while(i < 3000);

    i = 0;
    do{
        if(!(x[i] == 0 && y[i] == 0)){
            if(x[i] > y[i]){
                printf("%d %d\n",y[i],x[i]);
            }else{
                printf("%d %d\n",x[i],y[i]);
            }
        }else{
            break;
        }

        i++;

    }while(i < 3000);

    return 0;
}

Measured memory_bytes: 1816
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
	int N, M;
	cin >> N >> M;
	int X;
	X = 1900 * M + 100 * (N - M);
	for (int i = 0; i < M; i++) {
		X *= 2;
	}
	cout << X << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

const ll INF = LONG_LONG_MAX / 2;
const ll MAX_COST = 1000 * 1000 * 1000;

static ll do_solve(map<ll, ll> &dp, const ll n, const ll A, const ll B, const ll C, const ll D) {
    if (dp.find(n) != dp.end()) {
        return dp[n];
    }

    ll ans = INF;

    vector<ll> muls = {2, 3, 5};
    vector<ll> costs = {A, B, C};
    for (int i = 0; i < (int) muls.size(); i++) {
        const ll mul = muls[i];
        {
            const ll next = n / mul;
            if (next == 0) continue;
            ll cand = 0;
            cand += D * (abs(next * mul - n));
            cand += costs[i];
            cand += do_solve(dp, next, A, B, C, D);
            chmin(ans, cand);
        }
        {
            ll next = (n + mul - 1) / mul;
            ll cand = 0;
            cand += D * (abs(next * mul - n));
            cand += costs[i];
            cand += do_solve(dp, next, A, B, C, D);
            chmin(ans, cand);
        }
    }

    // When n > 2 * MAX_COST, it is always better to apply x2, x3, or x3 even if D == 1 and A, B, C == 10 ^ 9.
    if (n <= 2 * MAX_COST) {
        chmin(ans, n * D);
    }

    dp[n] = ans;
    return ans;
}

ll solve(const ll N, const ll A, const ll B, const ll C, const ll D) {
    map<ll, ll> dp;
    dp[0] = 0;
    dp[1] = D;
    return do_solve(dp, N, A, B, C, D);
}

int main(void) {
    int T;
    cin >> T;

    while (T-- > 0) {
        ll N, A, B, C, D;
        cin >> N >> A >> B >> C >> D;

        cout << solve(N, A, B, C, D) << endl;
    }

    return 0;
}


Measured memory_bytes: 4472
#include <bits/stdc++.h>
#define INF 1000000000000000001
#define ll long long
using namespace std;
using pll = pair<ll, ll>;


int main()
{
  ll N, K;
  cin >> N >> K;
  ll ans = N % K;
  ans = min(ans, abs(K - ans));
  cout << ans << endl;

}


Measured memory_bytes: 384
#include <iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)

using namespace std;

int main() {
    long n,a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e;
    
    long min_move=min({a,b,c,d,e});
    long ans=((n+min_move-1)/min_move)+4;

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

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
 
using namespace std;
 
int main()
{
    char res[6][9] = {"..rr....",
                      "..rr....",
                      "ggyybbww",
                      "ggyybbww",
                      "..oo....",
                      "..oo...."};
    char q[128];
     
    scanf("%s", q);
     
    for (int i = 0; q[i]; i++){
        char next[6][9];
        memcpy(next, res, sizeof(res));
        if (q[i] == 'U'){
            next[0][2] = res[1][2]; next[0][3] = res[0][2];
            next[1][3] = res[0][3]; next[1][2] = res[1][3];
            for (int i = 0; i < 8; i++)
                next[2][i] = res[2][(i + 2) % 8];
        }
        if (q[i] == 'D'){
            next[4][2] = res[5][2]; next[4][3] = res[4][2];
            next[5][3] = res[4][3]; next[5][2] = res[5][3];
            for (int i = 0; i < 8; i++)
                next[3][(i + 2) % 8] = res[3][i];
        }
        if (q[i] == 'R'){
            next[2][4] = res[3][4]; next[2][5] = res[2][4];
            next[3][5] = res[2][5]; next[3][4] = res[3][5];
            for (int i = 0; i < 4; i++)
                next[i][3] = res[i + 2][3];
            next[4][3] = res[3][6]; next[5][3] = res[2][6];
            next[2][6] = res[1][3]; next[3][6] = res[0][3];
        }
        if (q[i] == 'L'){
            next[2][0] = res[3][0]; next[2][1] = res[2][0];
            next[3][1] = res[2][1]; next[3][0] = res[3][1];
            for (int i = 0; i < 4; i++)
                next[(i + 2)][2] = res[i][2];
            next[3][7] = res[4][2]; next[2][7] = res[5][2];
            next[0][2] = res[3][7]; next[1][2] = res[2][7];
        }
        if (q[i] == 'F'){
            next[2][2] = res[3][2]; next[2][3] = res[2][2];
            next[3][3] = res[2][3]; next[3][2] = res[3][3];
            next[1][2] = res[3][1]; next[1][3] = res[2][1];
            next[2][4] = res[1][2]; next[3][4] = res[1][3];
            next[4][3] = res[2][4]; next[4][2] = res[3][4];
            next[3][1] = res[4][3]; next[2][1] = res[4][2];
        }
        if (q[i] == 'B'){
            next[2][6] = res[3][6]; next[2][7] = res[2][6];
            next[3][7] = res[2][7]; next[3][6] = res[3][7];
            next[3][5] = res[5][2]; next[2][5] = res[5][3];
            next[5][2] = res[2][0]; next[5][3] = res[3][0];
            next[3][0] = res[0][2]; next[2][0] = res[0][3];
            next[0][2] = res[2][5]; next[0][3] = res[3][5];
        }
         
        memcpy(res, next, sizeof(next));
    }
     
    for (int i = 0; i < 6; i++) printf("%s\n", res[i]);
     
    return (0);
}

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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

#define int long long

typedef long long ll;

const int P = 1e9 + 7;
int n;

typedef pair <ll, ll> pr;

map <pr, pr> cnt;

ll abso(ll x) {
  return x < 0 ? -x : x;
}

ll gcd(ll a, ll b) {
  return b ? gcd(b, a % b) : a;
}

int qp(int a, int k) {
  int res = 1;
  for (; k; k >>= 1, a = 1ll * a * a % P) {
    if (k & 1) res = 1ll * res * a % P;
  }
  return res;
}

void solve() {
  cin >> n;
  int res = 1, tot = 0;
  rep(i, 1, n) {
    ll x, y;
    scanf("%lld %lld", &x, &y);
    int sign = (x < 0) ^ (y < 0);
    x = abso(x), y = abso(y);
    if (!x && !y) {
      tot++; continue;
    }
    ll g = gcd(x, y);
    x /= g, y /= g;
    if (!x) {
      cnt[pr(0, abso(y))].first++; continue;
    }
    if (!y) {
      cnt[pr(0, abso(x))].second++; continue;
    }
    if (sign) {
      cnt[pr(y, x)].second++;
    } else {
      cnt[pr(x, y)].first++;
    }
  }
  for (auto p : cnt) {
    int x = p.second.first, y = p.second.second;
    res = 1ll * res * (qp(2, x) + qp(2, y) - 1) % P;
  }
  cout << (1ll * res + tot + P - 1) % P << endl;
}

signed main() {
//  int T = read();
//  while (T--) solve();
  solve();
  return 0;
}

Measured memory_bytes: 19280
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    ans=1
    for i in range(N):
        ans*=(i+1)
        ans%=mod
        
    print(ans)

main()


Measured memory_bytes: 38512
<?php
fscanf(STDIN, "%d %d", $n, $m);
for ($i = 0; $i < $n; $i++) {
	fscanf(STDIN, "%d %d", $a[], $b[]);
}
for ($j = 0; $j < $m; $j++) {
	fscanf(STDIN, "%d %d", $c[], $d[]);
}
for ($i = 0; $i < $n; $i++) {
	$min = PHP_INT_MAX;
	for ($j = 0; $j < $m; $j++) {
		$k = abs($a[$i] - $c[$j]) + abs($b[$i] - $d[$j]);
		if (!$k) {
			$p = $j + 1;
			break;
		} elseif ($k < $min) {
			$min = $k;
			$p = $j + 1;
		}
	}
	$x[] = $p;
}
echo implode("\n", $x);

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


def check(l):
    cnt = 0
    for i in range(n):
        cnt += a[i] // mid
        if a[i] % mid != 0:
            cnt += 1
        cnt -= 1

    return cnt <= k


lb, ub = 0, max(a)
while ub - lb > 1:
    mid = (ub + lb) // 2

    if check(mid):
        ub = mid
    else:
        lb = mid

print(ub)


Measured memory_bytes: 30672
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    vector<int> A(5); for (auto &a : A) cin >> a;
    for (int i = 0; i < 5; i++) {
        if (A[i] == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3644
n, k = map(int, input().split())
p = list(map(int, input().split()))

def cumsum(s):
    n = len(s)
    cs = [0] * (n+1)
    for i in range(n):
        cs[i+1] = cs[i] + s[i]
    return cs

pc = cumsum(p)
nc = cumsum(range(1, 1001))
mx = 0
s = 0

for i in range(n-k+1):
    sm = pc[i+k] - pc[i]
    if mx < sm:
        s = i
        mx = sm

ans = 0
for i in range(k):
    x = p[s+i]
    ans += nc[x] / x

print(ans)


Measured memory_bytes: 71792
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
 
  int64_t n,d;
  cin>>n>>d;

  int64_t cnt=0;
  for(int i=0;i<n;i++){
    int64_t x,y;
    cin>>x>>y;

    if(sqrt(x*x+y*y)<=d)
      cnt++;
  }

  cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 3676
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
/*        string[] input = ReadLine().Split(' ');
        long a = long.Parse(input[0]);
        long b = long.Parse(input[1]);
        long x = long.Parse(input[2]);
        
        long ans = 0;
        ans += b/x;
        if(a>x){
        if(a%x == 0){
            ans -= (a/x)-1;
        }else{
            ans -= a/x;
        }
        }
        if(a==0){
            ans++;
        }
        WriteLine(ans);*/
        string[] inp = ReadLine().Split(' ');
        int a = int.Parse(inp[0]);
        int b = int.Parse(inp[2]);
        if(inp[1] == "+"){
            WriteLine(a+b);
        }else{
            WriteLine(a-b);
        }
    }
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl);
#define cop(a) for(auto x:(a)){cout << x << endl;}


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){

    ll n, T;
    cin >> n >> T;
    ll a, b;
    ll ans = n*T;
    scanf("%lld", &a);
    rep(i, n-1) {
        scanf("%lld", &b);
        ans -= max(0ll, T-b+a);
        a = b;
    }
    ppp(ans);

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
a,b,c,x = [int(input()) for i in range(4)]
ans = 0
for i in range(a+1):
    for j in range(b+1):
        if 0 <= x - (500*i) - (100*j) <= (50*c):
            ans += 1
print(ans)

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

int n, k;
vector<int> nums;

long dp[100][256][100];

long factorial(int base){
    if(base){
        return long(base) * factorial(base - 1) % long(1e9 + 7);
    }else{
        return 1;
    }
}

long make_sequence(int now, int all, int choose_count){
    if(now == n){
        return (all == k) * factorial(choose_count);
    }else if(dp[now][all][choose_count] != -1){
        return dp[now][all][choose_count];
    }else{
        return dp[now][all][choose_count] = (make_sequence(now + 1, all, choose_count) + make_sequence(now + 1, (all ^ nums[now]), choose_count + 1)) % long(1e9 + 7);
    }
}

int main(){
    cin >> n >> k;
    nums.resize(n);
    for(int i = 0; i < n; i++){
        cin >> nums[i];
    }
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 256; j++){
            for(int k = 0; k < 100; k++){
                dp[i][j][k] = -1;
            }
        }
    }
    cout << make_sequence(0, 0, 0) << endl;
}


Measured memory_bytes: 20224
H,W,M = map(int, input().split())
hs = [0] * H
ws = [0] * W
s = set()
for i in range(M):
  h,w = map(int, input().split())
  h -= 1
  w -= 1
  s.add((h,w))
  hs[h] += 1
  ws[w] += 1
  
mh = 0
mw = 0
for i in range(H):
  mh = max(mh, hs[i])
for j in range(W):
  mw = max(mw, ws[j])
  
i_s = list()
j_s = list()
for i in range(H):
  if mh == hs[i]:
    i_s.append(i)
for j in range(W):
  if mw == ws[j]:
    j_s.append(j)
ans = mh + mw
for i in i_s:
  for j in j_s:
    if (i,j) in s:
      continue
    print(ans)
    exit()
ans -= 1
print(ans)

Measured memory_bytes: 157232
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b;
    cin >> a >> b;
    string s;
    cin >> s;
    bool ok=true;
    rep(i,a+b+1){
        if(i==a&&s[i]!='-')ok=false;
        else if(i!=a&&s[i]=='-')ok=false;
    }
    cout << ( ok ? "Yes" : "No" ) << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 3664
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line;
        
        while(true) {
            int count = 0;
            try {
                line = sc.nextLine();
            }catch(Exception e) {
                break;
            }
            int n = Integer.parseInt(line);
            for(int num = 1; num <= n; num++) {
                if (num < 2) {
                    continue;
                }else if (num == 2) {
                    count++;
                    continue;
                }else if (num % 2 == 0) {
                    continue; // 偶数はあらかじめ除く
                }
                double sqrtNum = Math.sqrt(num);
                boolean sosuu = true;
                for (int i = 3; i <= sqrtNum; i += 2) {
                    if (num % i == 0) {
                        sosuu = false;
                        break;
                    }
                }
                if(sosuu) {
                    count++;
                }
                    
            }
            System.out.println(count);
        }
        
    }
 } 


Measured memory_bytes: 26628