akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#define MOD 1000000007
typedef long long ll;

using namespace std;

// n^(exponent)を計算 O(logN)
ll pow(ll n, ll exponent) {
    ll pow = 1;
    while(exponent > 0) {
        if((exponent & 1) == 1) {
            pow *= n;
        }
        n *= n;
        
        // 桁をずらす
        exponent >>= 1;
    }
    return pow;
}

// n^(exponent) を mod で割った余りを計算 O(logN)
ll mod_pow(ll n, ll exponent, ll mod) {
    ll pow = 1;
    while(exponent > 0) {
        if((exponent & 1) == 1) {
            pow *= n;
            pow %= mod;
        }
        n *= n;
        n %= mod;
        
        // 桁をずらす
        exponent >>= 1;
    }
    return pow;
}

// n! を計算　O(N)
ll factorial(ll n) {
    ll factorial = 1;
    for(ll i = 1; i <= n; i++) {
        factorial *= i;
    }
    return factorial;
}

// n! を mod で割った余りを計算　O(N)
ll mod_factorial(ll n, ll mod) {
    ll factorial = 1;
    for(ll i = 1; i <= n; i++) {
        factorial *= i;
        factorial %= mod;
    }
    return factorial;
}

// xCn を計算
ll conbination(ll x, ll n) {
    return factorial(x) / (factorial(n) * factorial(x - n));
}

// xCn を　mod で割った余りを計算
ll mod_conbination(ll x, ll n, ll mod) {
    ll conb = mod_factorial(x, mod);
    
    // 逆元を求める(フェールマーの小定理を参照)
    ll reverse_n = mod_pow(mod_factorial(n, mod), mod - 2, mod);
    ll reverse_difference = mod_pow(mod_factorial(x - n, mod), mod - 2, mod);
    
    return (((conb * reverse_n) % mod) * reverse_difference) % mod;
}

int main() {
    ll n, k;
    cin >> n >> k;
    
    for(int i = 1; i <= k; i++) {
        if(i - 1 <= n - k) {
            cout << (mod_conbination(k - 1, i - 1, MOD) * mod_conbination(n - k + 1, i, MOD)) % MOD << endl;
        }
        else {
            cout << 0 << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int n,i,j;
    int card[4][13]={0};
    int num;
    char patarn;
    scanf("%d",&n);
    for(i=0;i<2*n;i++){
        scanf("%c ",&patarn);
        scanf("%d",&num);
        if(patarn=='S') {
            card[0][num-1]=1;
        }else if(patarn=='H'){
            card[1][num-1]=1;
        }else if(patarn=='C'){
            card[2][num-1]=1;
        }else if(patarn=='D'){
            card[3][num-1]=1;
        }
    }
    for(j=0;j<13;j++){
        if(card[0][j]!=1){
            printf("S %d\n",j+1);
        }
    }
    for(j=0;j<13;j++){
        if(card[1][j]!=1){
            printf("H %d\n",j+1);
        }
    }
    for(j=0;j<13;j++){
        if(card[2][j]!=1){
            printf("C %d\n",j+1);
        }
    }
    for(j=0;j<13;j++){
        if(card[3][j]!=1){
            printf("D %d\n",j+1);
        }
    }
    return 0;
}


Measured memory_bytes: 2688
#include <iostream>
using namespace std;
int main()
#define MAX_N 100 
{
    int n,m,p,x;
    cin >> n;
    int A[n];
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    cin >> m;
    for (int i=0; i<m; i++) {
        cin >> p >> x;
        int sum =0;
        for(int j=0; j<n; j++) {
            if((j+1)==p) {
            sum+=x;
            continue;
            }
            sum+=A[j];
        }
    cout<< sum <<endl;
    }
    

}

Measured memory_bytes: 256
import sys
from io import StringIO
import unittest

def resolve():
    n, m = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(n)]

    ab = sorted(ab, key= lambda x:x[0])
    # print(ab)

    ans = 0
    for a, b in ab:
        if m - b > 0:
            m -= b
            ans += a * b
        elif m - b == 0:
            m -= b
            ans += a * b
            break
        else:
            ans += a * m
            break

    print(ans)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 5
4 9
2 4"""
        output = """12"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """4 30
6 18
2 5
3 10
7 9"""
        output = """130"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """1 100000
1000000000 100000"""
        output = """100000000000000"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 32556
#include <iostream>

using namespace std;

int main(){
   int k,x;
   cin>>k>>x;
   for (int i=-1000000;i<1000001;i++){
    if(i==x){
        for (i=x-(k-1);i<x+k;i++){
            cout<< i<<" ";
        }
    }
   }
   return 0;
}




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

int main(){
    long long a, b, c, res = 0, till = 0;
    scanf("%Ld%Ld%Ld", &a, &b, &c);
    while(till < a){
        res += c;
        till += b;
    }
    printf("%Ld\n", res);
    return 0;
}


Measured memory_bytes: 3820
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#define rep(i,s,n) for(long long i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define POWT(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODI 10000
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

const pii four_Dir[4] = { 
	{ -1 ,0 },{ 0 ,1 },
	{ 1 ,0 },{0,-1}
};

class RMQ {
private:
	static const int MAX_N = 1 << 17;
	int n, dat[2 * MAX_N - 1];
	//[a,b)の最小値を返す
	//kは節点の番号l,rはその節点が[l,r)を保持している
	int rec(int a, int b, int k, int l, int r) {
		if (b <= l || r <= a) {
			return INT_MAX;
		}

		if (a <= l && r <= b) {
			return dat[k];
		}
		else {
			int rl = rec(a, b, 2 * k + 1, l, (l + r) / 2);
			int rr = rec(a, b, 2 * k + 2, (l + r) / 2, r);
			return min(rl, rr);
		}
	}

public:
	void init(int n_) {
		n = 1;
		while (n < n_) n *= 2;

		for (int i = 0; i<2 * n - 1; i++) {
			dat[i] = INT_MAX;
		}
	}

	//kをaに変更
	void update(int k, int a) {
		int reaf = k + n - 1;
		dat[reaf] = a;
		while (reaf>0) {
			reaf = (reaf - 1) / 2;
			dat[reaf] = min(dat[reaf * 2 + 1], dat[2 * reaf + 2]);
		}
	}

	//query[a,b]の範囲内の最小値を返す
	int query(int a, int b) {
		return rec(a, b + 1, 0, 0, n);
	}
};
signed main() {
	int n, t;
	RMQ rmq;
	scanf("%d %d", &n, &t);
	rmq.init(n);
	vector<int> ap(n);
	REP(i, n) {
		scanf("%d", &ap[i]);
		
		rmq.update(i,ap[i]);
	}
	int Max = -1, Maxcou = 0;
	for(int i = n-1; 0 < i; i--) {
		int cur = ap[i] - rmq.query(0, i - 1);
		if (cur > Max) {
			Max = cur;
			Maxcou = 1;
		}
		else if (cur == Max) {
			Maxcou++;
		}
	}
	printf("%d\n", Maxcou);
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int a,b,c,d;
	long long n1,n2;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	n1=a*b;
	n2=c*d;
	if(n1>n2)cout<<n1;
	else cout<<n2;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
ll power(ll x,ll y, ll mod){
  if(y<=0) return 1;
  ll z=power(x,y/2,mod);
  if(y%2) return ((z*z)%mod)*x%mod;
  return (z*z)%mod;
}
void  solve(){
  ll n;
  cin>>n;
  string s;
  cin>>s;
  ll c=0;
  rep(i,0,n) if(s[i]=='1') c++;
  if(c==0){
    rep(i,0,n) cout<<1<<endl;
    return;
  }
  // if(c==1){
  //   rep(i,0,n){
  //     if(s[i]=='0')
  //   }
  // }
  vector<ll> ans(n,0);
  vector<ll> v1={c-1,c+1};
  ll rem=0,rem1=0;
  rep(i,0,n){
    if(s[i]=='1'){
      if(v1[0]>0) rem=(rem+power(2LL,1LL*(n-i-1),v1[0]))%v1[0];
      else ans[i]--;
      rem1=(rem1+power(2LL,1LL*(n-i-1),v1[1]))%v1[1];
    }
  }

  rep(i,0,n){
    ll rem2= s[i]=='1' ? rem:rem1;
    ll div= s[i]=='1' ? v1[0]:v1[1];
    if(s[i]=='0')  rem2 =(rem2+power(2LL,1LL*(n-i-1),div))%div;
    if(s[i]=='1' && div>0)  rem2 =(rem2-power(2LL,1LL*(n-i-1),div)+div)%div;
    ans[i]++;
    if(rem2==0) continue;
    div=__builtin_popcount(rem2);
    while(rem2 >0 && div>0){
      rem2=rem2%div;
      div=__builtin_popcount(rem2);
      ans[i]++;
    }
  }
  rep(i,0,n) cout<<ans[i]<<"\n";
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 5196
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

const int maxn=1e9+7;
int a[1005];

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        memset(a,0,sizeof(a));
        int c=0;
        for(int i=2; i<=n; i++)
        {
            int l=i;
            for(int j=2; j<=l; j++)
            {
                while(l%j==0)
                {
                    a[j]++;
                    l/=j;
                }
            }

        }
        long long sum=1;
        for(int i=2; i<=n; i++)
        {
            if(a[i])
            {
                sum*=(1+a[i]);
                sum=sum%maxn;
            }
        }
        printf("%lld\n",sum%maxn);
    }
    return 0;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int N; cin >> N;
	while (N--) {
		int amax = 0;
		int amin = 0;
		int T; cin >> T;
		vector<int>vs(T);
		for (int i = 0; i < T; ++i)cin >> vs[i];
		for (int i = 0; i < T - 1; ++i) {
			if (vs[i] < vs[i + 1])amax = max(vs[i + 1] - vs[i], amax);
			else amin = max(vs[i] - vs[i + 1], amin);
		}
		cout << amax << " " << amin << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
import sys
sys.setrecursionlimit(10**6)
n, m = [int(item) for item in input().split()]
edge = [[] for _ in range(n)]

def find_single_self_loop(start, prev, n):
    if prev != -1 and len(edge[n]) != 2:
        if n == start:
            return True
        else:
            return False
    for item in edge[n]:
        if item == prev:
            continue
        ret = find_single_self_loop(start, n, item)
        if ret:
            return True
    return False

for i in range(m):
    a, b = [int(item) for item in input().split()]
    a -= 1; b -= 1
    edge[a].append(b)
    edge[b].append(a)

order = [0] * (10**5 + 10)
# Must be Euler graph
for i, line in enumerate(edge):
    o = len(line)
    order[o] += 1
    if o % 2 != 0:
        print("No")
        exit()
    if o >= 4:
        index = i

# Existance of over order-6 node means graph includes over 3 circuits
if max(order[6:]) > 0:
    print("Yes")
    exit()

# only 1 order-4 up to 2 circuit
if order[4] <= 1:
    print("No")
    exit()
# over 3 order-4 includes over 3 circuits 
elif order[4] >= 3:
    print("Yes")
    exit()
# 2 order-4
else:
    ret = find_single_self_loop(index, -1, index)
    if ret:
        print("Yes")
    else:
        print("No")

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

int main() {
	//cout << "" << endl; // prints
	int N, K;
	vector<int> h;
	cin >> N >> K;
	for(int k = 0; k < N; k++){
		int temp = 0;
		cin >> temp;
		h.push_back(temp);
	}
	sort(h.begin(), h.end());
	int ans = 0;
	ans = h.at(K-1) - h.at(0);
	for(int i = 0; i <= N - K; i++){
		int temp = 0;
		temp = h.at(K-1+i) - h.at(i);
		ans = min(ans, temp);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s;
   getline(cin,s);
   if(s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3]){
    cout<<"No";
   }
   else if(s[0]==s[1]&&s[2]==s[3]){
    cout<<"Yes";
   }
   else if(s[0]==s[2]&&s[1]==s[3]){
    cout<<"Yes";
   }
   else if(s[0]==s[3]&&s[1]==s[2]){
    cout<<"Yes";
   }
   else
   {
       cout<<"No";
   }
}


Measured memory_bytes: 256
n = int(input())
x = list(input())
p_origin = x.count('1')

def bit_count(x):
    count = 0
    while x > 0:
        if x & 1:
            count += 1
        x = x >> 1
    return count


def get_ans(i):
    ans = 1
    if x[i] == '0':
        p_first = (sum_plus + p_plus[i]) % (p_origin+1)
    else:
        if p_origin-1 == 0:
            return 0
        p_first = (sum_minus - p_minus[i]) % (p_origin-1)
    while p_first != 0:
        p_first = p_first % bit_count(p_first)
        ans += 1
    return ans

p_minus = [0]*n # x%(p-1)
p_plus = [0]*n # x%(p+1)

t1 = 1
t2 = 1
for i in range(n):
    p_minus[n-1-i] = t1
    p_plus[n-1-i] = t2
    t1 *= 2
    t2 *= 2
    if p_origin == 1:
        t1 = 0
    else:
        t1 %= p_origin-1
    t2 %= p_origin+1

sum_plus = 0
sum_minus = 0
for i in range(n):
    if x[i] == '1':
        sum_plus += p_plus[i]
        sum_minus += p_minus[i]

for i in range(n):
    print(get_ans(i))


Measured memory_bytes: 94072
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

S=get_nsp
N=S.size
a=-1
z=-1
N.times do|i|
    if S[i]=="A"
      a=i
      break
    end
end
(N-1).downto(0) do|i|
    if S[i]=="Z"
        z=i
        break
    end
end
puts z-a+1

Measured memory_bytes: 16764
def main():
    n = int(input())
    num_list = list(map(int, input().split()))

    sum = 0
    tmp = 0

    for i in range(n):
        tmp += 1 / num_list[i]

    
    result = 1 / tmp

    print(result)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include "bits/stdc++.h"
#include <random>
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vvi pos(10);
  string s; cin >> s;
  REP(i, n) {
    pos[s[i] - '0'].push_back(i);
  }
  int ans = 0;
  REP(i, 1000) {
    vi v;
    v.push_back(i / 100);
    v.push_back(i / 10 % 10);
    v.push_back(i % 10);
    int now = -1;
    bool ok = true;
    REP(i, 3) {
      auto c = upper_bound(ALL(pos[v[i]]), now);
      if (c == pos[v[i]].end()) {
        ok = false;
        break;
      }
      now = *c;
    }
    if (ok)ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int n,x,m;
int l[10],r[10],s[10];
int t[6],ans[6],maxm;
int u[6];
void check(){
  int i,j;
  u[0]=t[0];
  for(int i=1;i<n;i++){
    u[i]=u[i-1]+t[i];
  }
  if(u[n-1]<=maxm)return;
   
  for(i=0;i<m;i++){
    if(u[r[i]]-u[l[i]]+t[l[i]]!=s[i]){
      break;
    }
  }
  if(i==m){
    maxm=u[n-1];
    for(j=0;j<n;j++)ans[j]=t[j];
  }
}
 
void compute(int y){
  if(y==n)check();
  else{
    for(int i=0;i<=x;i++){
      t[y]=i;
      compute(y+1);
    }
  }
}
 
 
int main(){
  cin>>n>>x>>m;
  for(int i=0;i<m;i++){
    cin>>l[i]>>r[i]>>s[i];
    l[i]--;
    r[i]--;
  }
  maxm=-1;
  compute(0);
  if(maxm==-1){
    cout<<-1<<endl;
    return 0;
  }
  for(int i=0;i<n;i++){
    if(i)cout<<' ';
    cout<<ans[i];
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 1164
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
n = I()
S = input()
left = 0
right = 0
for i in range(n):
    if S[i] == '(':
        right += 1
    elif S[i] == ')':
        if right >= 1:
            right -=1
        else:
            left += 1
print('('*left + S + ')'*right)


Measured memory_bytes: 10340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
const ll inf=1e16+1000;
ll a[N];
int n;
int main()
{
	while(cin>>n)
	{
		ll sum=0;
		for(int i=1;i<=n;i++)
			cin>>a[i],sum+=a[i];
		ll l=sum-n*(n-1),r=sum;
		for(ll k=l;k<=r;k++)
		{
			if(k<0)	continue;
			ll res=0;
			bool ok=true;
			for(int i=1;i<=n;i++)
			{
				ll dif=max(0ll,a[i]+k-n+1);
				ll x=dif/(n+1);
				if(dif%(n+1))
					x++;
				res+=x;
			}
			if(res==k)
			{
				cout<<res<<endl;
				break;
			}
		}
	}
	return 0;
}
//25720164523
//154320986863
//500000000000000000

Measured memory_bytes: 256
import java.util.*;

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

        int N = sc.nextInt();
        int[] p = new int[N];
        for(int i = 0; i < N; i++){
            p[i] = sc.nextInt();
        }

        int count = 0;
        for(int i = 0; i < N; i++){
            if (p[i] != (i+1)){
                count++;
            }
        }

        if(count == 0 || count == 2)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll H, W;
  cin >> H >> W;
  ll ans;
  if (H==1 || W==1){
    ans = 1;
  } else {
    ans = (H/2) * (W/2) + ((H+1)/2) * ((W+1)/2); 
  }
  cout << ans << "\n";
  return 0;
}


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

int main() {
	int a, b;
	cin >> a >> b;
	int c = max (a, b);
	int d = min (a, b);
	for (int i = 0; i < c; i++) {
		cout << d;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
n, m = gets.chomp.split(" ").map(&:to_i)
arr = Array.new(n + 1,0)
wa = 0
ac = 0
m.times do |i|
	pi, si = gets.chomp.split(" ")
	pi = pi.to_i
	if si == "AC" && arr[pi] != -1 then
		ac += 1
		wa += arr[pi]
		arr[pi] = -1
	elsif arr[pi] != -1 
		arr[pi] += 1
	end
end

puts "#{ac} #{wa}"




Measured memory_bytes: 2556
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

template <class Iit>
void vout(const Iit &begin,const Iit &end,ostream &out) {
    for(auto it = begin; it != end; it++) {
        auto tmp = it;
        if (++tmp == end) out << *it << '\n';
        else out << *it << " ";
    }
}

int main(void)
{
    IOS
    int h, w;
    cin >> h >> w;
    vector<vector<int>> ss(h,vector<int>(w));
    REP(y,h) REP(x,w) cin >> ss[y][x];

    pii now{0,0},prev;

    auto move = [&](pii yx) {

        if (yx.first % 2 == 0) {
            if (yx.second == w-1) {
                // Down
                if (yx.first != h-1) yx.first++;
                return yx;
            } else {
                //right
                yx.second++;
                return yx;
            }
        } else {
            if (yx.second == 0) {
                // Down
                if (yx.first != h-1) yx.first++;
                return yx;
            } else {
                //left
                yx.second--;
                return yx;
            }
        }
    };

    vector<vector<int>> ans;
    bool odd = false;
    auto addans = [&](pii yx1,pii yx2) {ans.push_back({yx1.first+1,yx1.second+1,yx2.first+1,yx2.second+1});return;};

    do {
        if (odd) addans(prev,now);
        if (ss[now.first][now.second] % 2 != 0 ) odd = !odd;
        prev = now;
        now = move(now);
    } while (now != prev);

    OUT(ans.size());
    REP(i,ans.size()) vout(ALL(ans[i]),cout);

    return 0;
}

Measured memory_bytes: 11312
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main() {
    int t;
    cin>>t;
    rep(times,t){
        int n;
        cin>>n;
        int up=0;
        int down=0;
        
        int data[2000]={};
        rep(i,n){
            cin>>data[i];
        }
        
        for(int i=1;i<n;i++){
            up=max(data[i]-data[i-1],up);
            down=max(data[i-1]-data[i],down);
        }
        cout<<up<<" "<<down<<endl;
    }
    return 0;
}

Measured memory_bytes: 1168
#include <algorithm>
#include <iostream>

using namespace std;

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

    if ((b - a) % 2 == 0) {
        cout << (b - a) / 2 << endl;
    } else {
        cout << min(a + (b - a - 1) / 2, n - b + 1 + (n - a - (n - b + 1)) / 2) << endl;
    }
}


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

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main() {
    int N,Q; cin >> N >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}

Measured memory_bytes: 21724
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <bitset>
#include <queue>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define sqr(x) (x)*(x)
typedef long long ll;

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

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


ll DFSutils(ll nodeN, vector<ll>&pathLen, vector<vector<ll>>& adjList){
    if(pathLen[nodeN] != -1) return pathLen[nodeN];
    ll curPath = 0;
    for(ll neighNode : adjList[nodeN]){
        curPath = max(curPath, 1 + DFSutils(neighNode, pathLen, adjList));
    }
    pathLen[nodeN] = curPath;
    return curPath;
}

int main(){
	ll N, M; cin >> N >> M;
        vector<vector<ll>> adjList(N + 1);
        vector<ll> pathLen(N + 1, -1);
        for(ll rep = 0; rep < M; ++rep){
            ll from, to;
            cin >> from >> to;
            adjList[from].push_back(to);
        }
        ll maxPath = 0;
        for(ll nodeN = 1; nodeN <= N; ++nodeN){
            if(pathLen[nodeN] != -1) continue;
            maxPath = max(maxPath,DFSutils(nodeN, pathLen, adjList));
        }
        cout << maxPath << endl;
    	return 0;
}

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


using namespace std;

int main()
{
	int n; cin>>n;
	vector<int> v(n);
	for(int i = 0; i<n; i++) cin>>v[i];

	sort(v.begin(), v.end());

	double ans = v[0];
	
	for(int i = 1; i<n; i++)
	{
		ans = (ans+v[i])/2.0;
	}
	cout<<setprecision(8)<<ans;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    int h, w;
    std::cin >> h >> w;
    std::string str[h];
    for (int i = 0; (i < h); ++i) {
        std::cin >> str[i];
    }
    const int di[4] = {-1, 1,  0, 0};
    const int dj[4] = { 0, 0, -1, 1};
    for (int i = 0; (i < h); ++i) {
        for (int j = 0; (j < w); ++j) {
            if (str[i][j] == '.') continue;
            int num = 0;
            for (int k = 0; (k < 4); ++k) {
                int ii = i + di[k];
                if ((ii < 0) || (ii >= h)) continue;
                int jj = j + dj[k];
                if ((jj < 0) || (jj >= w)) continue;
                if (str[ii][jj] == '#') ++num;
            }
            if (num == 0) {
                std::cout << "No" << std::endl;
                return 0;
            }
        }
    }
    std::cout << "Yes" << std::endl;
    return 0;
}


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

int main(){
	ll n,r; cin >> n >> r;
	if(n >= 10)cout << r << endl;
	else cout << r + 100 * (10 - n) << endl;
}

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

const static int mod = 1000003;

template<typename T, T M>
struct modint {
  T a;
  constexpr modint(const T x = 0): a((x%M+M)%M){}
  constexpr modint pow(T r) const {
    modint ans(1), aa(a);
    while(r) { if(r & 1) ans *= aa; aa *= aa; r >>= 1; }
    return ans;
  }
  
  constexpr modint& operator+=(const modint r) { a += r.a; if(a >= M) a -= M; return *this; }
  constexpr modint& operator-=(const modint r) { a -= r.a; if(a < 0) a += M; return *this; }
  constexpr modint& operator*=(const modint r) { a = a * r.a % M; return *this; }
  constexpr modint& operator/=(const modint r) { return (*this) *= r.pow(M-2); }
  constexpr modint operator+(const modint r) const { return modint(a) += r; }
  constexpr modint operator-(const modint r) const { return modint(a) -= r; }
  constexpr modint operator*(const modint r) const { return modint(a) *= r; }
  constexpr modint operator/(const modint r) const { return modint(a) /= r; }
  constexpr bool operator!=(const modint r) const { return a != r.a; }
};

typedef modint<long long, mod> mi;

template<typename T>
constexpr vector<pair<T, T>> const build_factorial(int N) {
  vector<pair<T, T>> f(N);
  f[0].first = T(1);
  for(int i = 1; i < N; i++)
    f[i].first = f[i - 1].first * T(i);
  f[N - 1].second = T(1) / f[N - 1].first;
  for(int i = N - 2; i >= 0; --i)
    f[i].second = f[i + 1].second * T(i + 1);
  return move(f);
}

int main() {
  long long q, x, d, n;
  cin >> q;
  vector<pair<mi, mi>> f = build_factorial<mi>(mod);
  
  auto solve = [&](const long long& x, const long long& n) {
    return x == 0 || x + n - 1 >= mod ? mi(0) : f[x + n - 1].first * f[x - 1].second;
  };
 
  while(q--) {
    cin >> x >> d >> n;
    cout << (d ? solve((mi(x) / mi(d)).a, n) * mi(d).pow(n) : mi(x).pow(n)).a << endl;
  }
}

Measured memory_bytes: 16512
import java.util.*;
class Main
{
  public static void main(String args[])
    {
    String S;
    Scanner sc= new Scanner(System.in);
    S=sc.nextLine();
    if(S.charAt(S.length()-1)=='s')
      System.out.println(S+"es");
    else
      System.out.println(S+"s");
  }
}

Measured memory_bytes: 38472
/**
 *    author:  [itmo] enot.1.10
 *    created: 10.10.2016 06:58:50       
**/
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),a.end()
#define pw(x) (1LL<<(x))

using namespace std;

typedef long long ll;
typedef double dbl;
typedef vector<int> vi;
typedef pair<int, int> pi;

const int inf = 1.01e9;
const dbl eps = 1e-9;

/* --- main part --- */



int main()
{
    #ifdef home
        assert(freopen("1.in", "r", stdin));
        assert(freopen("1.out", "w", stdout));
    #endif
    string s = "CODEFESTIVAL2016";
    string t;
    cin >> t;
    int res = 0;
    forn(i, sz(t)) if (t[i] != s[i]) res++;
    printf("%d\n", res);
    #ifdef home
        eprintf("time = %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define Rep(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;++i)
#define Repe(i,a,b) for(register int i=(a),i##end=(b);i>=i##end;--i)
#define For(i,a,b) for(i=(a),i<=(b);++i)
#define Forward(i,a,b) for(i=(a),i>=(b);--i)
#define Chkmax(a,b) a=a>b?a:b
#define Chkmin(a,b) a=a<b?a:b
template<typename T>inline void read(T &x)
{
	T f=1;x=0;char c;
	for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=x*10+(c^48);
	x*=f;
}
using namespace std;
const int MAXN=301010;
static int n,a,b;
inline void init()
{
	read(n);read(a);read(b);
}
static int p[MAXN];
inline void solve()
{
	if(a+b>n+1||1ll*a*b<n){cout<<-1<<endl;exit(0);}
	else
	{
		static int ps,cnt=n;
		while(cnt>a)
		{
			//cout<<cnt<<' '<<a<<endl;
			ps=cnt;
			if(cnt-a+1>=b){Rep(i,cnt-b+1,cnt)p[i]=ps--;cnt-=b;}
			else Rep(i,a,cnt){p[i]=ps--;cnt=ps;}
			--a;
			//cout<<cnt<<' '<<a<<endl;
		}
		Rep(i,1,cnt)p[i]=i;
		Rep(i,1,n)cout<<p[i]<<' ';cout<<endl;;
	}
}
int main()
{
	init();
	solve();
	return 0;
}



Measured memory_bytes: 3328
class SEGTree:
    def __init__(self,n):
        self.Unit=0
        i=1
        while(i<n):
            i*=2
        self.SEG=[self.Unit]*(2*i-1)
        self.d=i
    def update(self,i,x):
        i+=self.d-1
        self.SEG[i]=x
        while i>0:
            i=(i-1)//2
            self.SEG[i]=max(self.SEG[i*2+1],self.SEG[i*2+2])
    def find(self,a,b,k,l,r):
        if r<=a or b<=l:
            return self.Unit
        if a<=l and r<=b:
            return self.SEG[k]
        else:
            c1=self.find(a,b,2*k+1,l,(l+r)//2)
            c2=self.find(a,b,2*k+2,(l+r)//2,r)
            return max(c1,c2)
    def get(self,a,b):
        return self.find(a,b,0,0,self.d)

N,T=map(int,input().split())
A=list(map(int,input().split()))
SEG=SEGTree(N)
for i in range(N):
    SEG.update(i,A[i])
li=[0]*N
for i in range(N):
    li[i]=max(li[i],SEG.get(i+1,N)-A[i])
m=max(li)
ans=0
for i in range(N):
    if li[i]==m:
        ans+=1
print(ans)

Measured memory_bytes: 87252
a, b, c = sorted(map(int, input().split()))

cnt = 0
while not (a == b == c):
    if (b - a) % 2 == 0:
        cnt = (b - a) // 2
        cnt += c - b
        print(cnt)
        exit()
    else:
        cnt = (b - a) // 2
        cnt += c - b + 2
        print(cnt)
        exit()


print(cnt)

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

#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 all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

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

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

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

    ll s = 0;
    string a;
    cin >> a;
    for(int i = 0; i < a.size(); i++) {
        s += a[i] - '0';
    }
    cout << (s % 9 == 0 ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3768
#include <cstdio>
#include <vector>
#include <map>

using namespace std;

int main() {
    int l, cnt = 0;
    scanf("%d", &l);
    int i = 1;
    vector< vector < pair<int, int> > > e(1);
    for (; (1 << i) - 1 < l; ++i) {
        e.push_back({});
        e.at(i).push_back({i + 1, 0}), e.at(i).push_back({i + 1, 1 << (i - 1)}), cnt += 2;
    }
    int n = i, prev = (1 << (n - 1));
    for (--i; i >= 1; --i) if (l > prev + (1 << (i - 1)) - 1) e.at(i).push_back({n, prev}), prev += (1 << (i - 1)), ++cnt;
    printf("%d %d\n", int(e.size()), cnt);
    for (int i = 1; i < n; ++i) for (int j = 0; j < int(e.at(i).size()); ++j) printf("%d %d %d\n", i, e.at(i).at(j).first, e.at(i).at(j).second);
    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++)
#define rp(i,n) for(int i=1;i<=(int)n;i++)
int main(){
int n;cin>>n;
int w[n];
rep(i,n) cin>>w[i];
int sum=0;
rep(i,n)sum+=w[i];
int a=0;
int b;
int c;
int ans=50000;
rep(i,n){
    a+=w[i];
    b=sum-a;
    c=abs(a-b);
    if(ans>c)ans=c;
}
cout<<ans<<endl;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

bool isPrime(int a) {
    if (a == 1) return false;
    for (int i = 2; i * i <= a; i++) {
        if(a % i == 0) return false;
    }
    return true;
}

void solve()
{
  int n;
  cin >> n;

  int ans[55] = {2, 11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361};
  for(int i = 0; i < n; ++i)
  {
    cout << ans[i] << " ";
  }
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3620
import Data.List
import qualified Data.ByteString.Char8 as B
main = breadIs >>= main' . last
    where
        main' t = breadIs >>= print . solve t 0

solve :: Int -> Int -> [Int] -> Int
solve t acc (x : y : zs)
    | y - x < t = solve t (acc + y - x) (y : zs)
    | otherwise = solve t (acc + t) (y : zs)
solve t acc (_ : _) = acc + t
solve _ acc _ = acc

breadIs :: IO [Int]
breadIs = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)


Measured memory_bytes: 4988
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int a[100001];

int main() {

	ll n;
	ll a[200002];
	ll c[200002]={};

	cin>>n;
	rep(i,n){
		cin>>a[i];
	}
	c[0]=a[0];

	for(ll i=1; i<n; i++){
		c[i]=c[i-1]+a[i];
	}
	ll x=0,y=0;
	ll total=1000000000000;
	rep(i,n-1){
		x=c[i];
		y=c[n-1]-c[i];
		total=min(total,abs(x-y));
	}
	cout<<total<<endl;
	return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
  ll h,n;
  cin>>h>>n;
  ll arr[n];
  for(ll i=0;i<n;i++){
    cin>>arr[i];
  }
  ll cnt=0;
  for(ll i=0;i<n;i++){
    cnt+=arr[i];
  }
  if(cnt>=h){
    cout<<"Yes"<<endl;}
  else{
    cout<<"No"<<endl;}
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<map>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    int a,b,cnt=0,m=1;
    cin >> a >> b;

    while(m<b){
        m = m-1+a;
        cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
//even relation
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(int argc, char const *argv[])
{
	int n,m;
	cin>>n>>m;
	UnionFind tree(n);
	int x,y,z,ans=n;
	for (int i = 0; i < m; ++i)
	{
		cin>>x>>y>>z;
		if(tree.same(x-1,y-1)){
			continue;
		}else{
			ans --;
			tree.unite(x-1,y-1);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
a, b, k = gets.split.map(&:to_i)
a_divisor = []
a_b_divisor = []
a.times do |i|
  a_divisor << i + 1 if a % (i + 1) == 0
end
a_divisor.each do |j|
  a_b_divisor << j if b % j == 0
end
puts a_b_divisor[a_b_divisor.length - k]

Measured memory_bytes: 1788
# 初期入力
import sys
#input = sys.stdin.readline  #文字列では使わない

X = int(input())
if 400 <=X <600:
    print(8)
elif 600 <=X <800:
    print(7)
elif 800 <=X <1000:
    print(6)
elif 1000 <=X < 1200:
    print(5)
elif 1200 <=X <1400:
    print(4)
elif 1400 <=X < 1600:
    print(3)
elif 1600 <=X <1800:
    print(2)
elif 1800 <=X < 2000:
    print(1)

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

namespace atcoder162
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Convert.ToInt32(Console.ReadLine());
            var r = (n % 10 == 7) ||
                (n / 10 % 10 == 7) ||
                (n / 100 % 10 == 7);
            Console.WriteLine(r ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 27552
#include<bits/stdc++.h>
#define REP(i,n) for(long long i=0;i<n;i++)
using namespace std;
int main(){
    long long n,q,su=0,L,R;cin>>n>>q;
    long long map[n+1],ans[q];
    string s;cin>>s;
    REP(i,n){
        if(i!=0&&s[i-1]=='A'&&s[i]=='C')su++;
        map[i]=su;
    }
    REP(i,q){
        cin>>L>>R;
        ans[i]=map[R-1]-map[L-1];
    }
    REP(i,q)cout<<ans[i]<<endl;
}   

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

int H, W;
vector<string> fi;

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

int main() {
    cin >> H >> W;
    fi.resize(H);
    for (int i = 0; i < H; ++i) cin >> fi[i];

    // 多点をスタートとして扱う
    vector<vector<int> > dist(H, vector<int>(W, -1));
    using pint = pair<int,int>;
    queue<pint> que;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (fi[i][j] == '#') {
                dist[i][j] = 0;
                que.push(pint(i, j));
            }
        }
    }

    // BFS
    while (!que.empty()) {
        auto cur = que.front();
        que.pop();
        for (int dir = 0; dir < 4; ++dir) {
            int nx = cur.first + dx[dir];
            int ny = cur.second + dy[dir];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if (dist[nx][ny] == -1) {
                dist[nx][ny] = dist[cur.first][cur.second] + 1;
                que.push(pint(nx, ny));
            }
        }
    }
    int res = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            res = max(res, dist[i][j]);
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 13456
#include<bits/stdc++.h>
using namespace std;
double p[3000];
double dp[3000][3000];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>p[i];
		dp[1][0]=1-p[1];
	
	for(int i=2;i<=n;i++)
	dp[i][0]= dp[i-1][0]*(1-p[i]);
	dp[1][1]= p[1];
	
	for(int i=2;i<=n;i++)
	for(int j=1;j<=n;j++)
	dp[i][j]= dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i]);
	
	double ans=0;
	for(int i=(n+1)/2;i<=n;i++)
	{
		ans+=dp[n][i];
	}
	cout<<setprecision(9)<<ans;
}

Measured memory_bytes: 70528
#include <stdio.h>
#include <algorithm>
using namespace std;

int pow(int a,int n){
	if(n <= 0){
		return 1;
	}
	return a * pow(a,n - 1);
}

int main(){
	int a,b,c;
	int ans1 = 0;
	int ans2 = 0;
	while(scanf("%d,%d,%d",&a,&b,&c) != EOF){
		if(pow(a,2) + pow(b,2) == pow(c,2)){
			ans1++;
		}
		if(a == b){
			ans2++;
		}
	}
		printf("%d\n%d\n",ans1,ans2);
	///////////////////////////////////
	//Sleep(200000);///////////////////// 提出するときは必ず外す！
	///////////////////////////////////
	return 0;

}

Measured memory_bytes: 1024
n = int(input())
str = ''
a = ord('a') - 1
while True:
  z = n % 26 if n % 26 > 0 else 26
  str = chr(a + z) + str 
  n = n // 26 if n % 26 > 0 else n // 26  -1
  if n == 0:
    print(str)
    break

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

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

using namespace std;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<ll,ll> iil;
typedef vector<vector<int> > vvi;
typedef vector<vector<ii> > vvii;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const int mod = 1e9 + 7;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

//#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_NOde_update> 

inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}



int main()
{
	#ifdef LOCAL_TEST
	freopen("in.txt","r",stdin);
	//freopen("out.txt", "w", stdout);
	#else
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	#endif
	ll n;
	cin>>n;
	vector<ll> v;
	for(int i=1;i<=n;i++)
	{
		ll t;
		cin>>t;
		v.pb(t);
	}

	ll x1 = 0;
	for(int i=1;i<=n;i++)
	{
		if(i%2)x1 += v[i-1];
		else x1 -= v[i-1];
	}

	assert(x1%2 == 0);
	x1 = x1/2;
	cout << 2*x1 << " ";
	for(int i=1;i<n;i++)
	{
		ll x = v[i-1] - x1;
		cout << 2*x << " ";
		x1 = x;
	}
	return 0;
}

Measured memory_bytes: 2292
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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 <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin >> n;
    if (n == 1) {
        cout << 1 << endl << 0 << endl;
    } else if (n == 2) {
        cout << 2 << endl << 0 << endl << 11 << endl;
    } else {
        cout << n - 1 << endl;
        for (int i = 2; i <= n; i++) {
            cout << 1;
            rep(j, i - 2) cout << 0;
            cout << 1 << endl;
        }
    }
}



Measured memory_bytes: 3112
#include<iostream>
#include<string>
#include<algorithm>
typedef long long ll;
using namespace std;
const int N=2e5+5;
int a[N];
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	string str;
	cin>>str;
	int f=0;
	for(int i=0;i<str.length();i++){
		if(str[i]=='7')f=1;
	}
	if(f)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3616