akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 

int solve(){
    string s;
    cin>> s;
    if(s.back() == '2'  or  s.back() == '7' or  s.back() == '4' or  s.back() == '5'  or  s.back() == '9')
    	cout<< "hon\n";
    if(s.back() == '0'  or  s.back() == '1'  or  s.back() == '6' or  s.back() == '8')
    	cout<< "pon\n";
    if(s.back() == '3')
    	cout<< "bon\n";
	return 0;
}
 
int main()
{
    fast;
    int t = 1;
   // cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/


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

using namespace std;
using ll = long long;
using IP = pair<int, int>;

const ll INF = 1LL << 62;
#define atcoder(int)1e9+7
#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back

ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

int keta(ll i) {
	int a = 0;
	while (i) {
		i /= 10;
		a++;
	}
	return a;
}

int main() {

	ll n;
	cin >> n;
	ll ans = 9999999;

	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0) {
			ll a1 = keta(i);
			ll a2 = keta(1LL * n / i);
			ans = min(max(a1,a2), ans);

		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
int main(){
  int a,b;
  cin>>a>>b;
  if(a<6) cout<<0<<endl;
  else if(a<13) cout<<b/2<<endl;
  else cout<<b<<endl;
}


Measured memory_bytes: 764
s=[]
a=[]
n=int(input())
for i in range(n):
	x=input()
	s.append(x)
	aa=[]
	for j in range(27):
		bb=x.count(chr(97+j))
		aa.append(bb)
	a.append(aa)
a.sort()
ans=0
cnt=0
for i in range(n-1):
	if a[i]==a[i+1]:
		cnt+=1
	else:
		ans+=(cnt*(cnt+1))//2
		cnt=0
ans+=(cnt*(cnt+1))//2
print(ans)








Measured memory_bytes: 45872
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int N;
	string S;
	void Solve()
	{
		N = F;
		S = Str;
		var Q = F;
		var ks = G;
		foreach (var k in ks) WriteLine(Count(k));
	}
	long Count(int k)
	{
		int d = 0, m = 0;
		long dm = 0, s = 0;
		for (var i = 0; i < N; i++)
		{
			if (i >= k)
			{
				if (S[i - k] == 'D') { d--; dm -= m; }
				else if (S[i - k] == 'M') m--;
			}
			if (S[i] == 'D') d++;
			else if (S[i] == 'M') { m++; dm += d; }
			else if (S[i] == 'C') s += dm;
		}
		return s;
	}
}


Measured memory_bytes: 14944
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll calc_dif(ll s,ll x0,ll x1){
  return (abs(s-x0)+abs(x0-x1));
}
signed main(){
  ll n,k,ans=1000000000000,tmp;
  cin >> n >> k;
  ll x[n];
  for(int i=0;i<n;i++){
    cin >> x[i];
  }
  for(int i=0;i+k-1<n;i++){
    tmp = min(calc_dif(0,x[i],x[i+k-1]),calc_dif(0,x[i+k-1],x[i]));
    ans = min(tmp,ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;
 
#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  f              first                 
#define  s              second
#define  endl           "\n"
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;            
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,pll>  um;
typedef  vector<pll>           vpll;
 
const ll   N     =  5e5+5;
const ll   mod   =  1e9+7;
const ll   INF   =  1e18;
const int  INFi  =  0x7f7f7f7f;

ll test = 1, n;
vll v;

void solve(){
    cin>>n;
    for(ll i = 2; i*i <= n; i++){
        int ct = 0;
        while(n%i == 0){
            ct++;
            n /= i;
        }
        if(ct) v.pb(ct);
    }
    if(n > 1) v.pb(1);
    ll ans = 0;
    for(auto it : v){
        int i = 1;
        while(it >= i){
            it -= i;
            i++;
        }
        ans += i-1;
    }
    deb1(ans)
}

int main(){
    fastio;
    //cin>>test;
    for(int i = 1; i <= test; i++){
        solve();
    }
}

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

int main() {
    int n,k;
    int a[200001] = {};

    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        int nn;
        cin >> nn;
        a[nn]++;
    }
    vector<int> cnt;
    for(int i = 1; i<=n; i++) {
        if(a[i] == 0)continue;
        cnt.push_back(a[i]);
    }
    sort(cnt.begin(), cnt.end());
    int rem = cnt.size() - k;
    int nums = 0;
    for(int i = 0; i < rem; ++i) {
        nums += cnt[i];
    }
    cout << nums << endl;
    return 0;
}


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

int main() {
    while (true) {
        int n, m;
        cin >> n >> m;
        if ((n | m) == 0) {
            break;
        }
        int sum[2] = {};
        set<int> taro, hanako;
        for (int i = 0; i < n; i++) {
            int s;
            cin >> s;
            taro.insert(s);
            sum[0] += s;
        }
        for (int i = 0; i < m; i++) {
            int s;
            cin >> s;
            hanako.insert(s);
            sum[1] += s;
        }
        for (set<int>::iterator itT = taro.begin(); itT != taro.end(); itT++) {
            for (set<int>::iterator itH = hanako.begin(); itH != hanako.end(); itH++) {
                if (sum[0] - *itT + *itH == sum[1] - *itH + *itT) {
                    cout << *itT << " " << *itH << endl;
                    goto end;
                }
            }
        }
        cout << -1 << endl;
    end:;
    }
}

Measured memory_bytes: 0
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let S: Vec<char> = read::<String>().chars().collect();
    let T: Vec<char> = read::<String>().chars().collect();
    use std::collections::HashMap;
    let mut map: HashMap<char, char> = HashMap::new();
    let mut rev_map: HashMap<char, char> = HashMap::new();
    for i in 0..S.len() {
        if let Some(&t) = map.get(&S[i]) {
            if t != T[i] {
                println!("No");
                return;
            }
        } else {
            map.insert(S[i], T[i]);
        }
        if let Some(&s) = rev_map.get(&T[i]) {
            if s != S[i] {
                println!("No");
                return;
            }
        } else {
            rev_map.insert(T[i], S[i]);
        }
    }
    println!("Yes");
}


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

typedef long long ll;

ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }
    return gcd(b,a%b);
}

ll lcm(ll x,ll y){
    return x/gcd(x,y)*y;
}

int main(){
    int N;
    cin >> N;
    ll T[N];
    for(int i=0;i<N;i++){
        cin >> T[i];
    }
    ll ans=1;
    for(int i=0;i<N;i++){
        ans=lcm(ans,T[i]);
    }
    cout << ans << endl;
}

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

int main(){
  int N;
  int ans,min=200000;
  string s;
  cin>>N>>s;
  int sum1[200001],sum2[200001];
  vector<int>x(N+1,0);
  for(int i=0;i<N;i++){
    if(s[i]=='#'){
      sum1[i+1]=sum1[i]+1;
      sum2[i+1]=sum2[i];
    }
    if(s[i]=='.'){
      sum2[i+1]=sum2[i]+1;
      sum1[i+1]=sum1[i];
    }
  }
  for(int i=0;i<N+1;i++){
    x[i]=sum1[i]+sum2[N]-sum2[i];
  }
  sort(x.begin(),x.end());
  cout<<x[0]<<endl;
  return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
long long n,m;
int main()
{
	cin>>n>>m;
	if(n>0&&m>0)
	cout<<"Positive"<<endl;
	if(n*m<=0)
	cout<<"Zero"<<endl;
	if(n<0&&m<0)
	{
		if((m-n+1)%2==0)
		cout<<"Positive"<<endl;
		else
		cout<<"Negative"<<endl;
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;

int main(void){
    int r,n,left,right,height;
    double minh;
    map<int,int> s;

    while(1){
        cin>>r>>n;
        if(r==0&&n==0)break;
        rep(i,21)s[i]=s[-i]=0;
        while(n--){
            cin>>left>>right>>height;
            for(int i=left;i<right;++i){
                if(s[i]<height)s[i]=height;
            }
        }
        minh = 21;
        rep(i,r){
            minh = min(minh,min(s[i],s[-i-1])-sqrt(r*r-i*i));
        }
        printf("%.4f\n",minh+r);

    }

    return 0;
}

Measured memory_bytes: 1228
N,K=list(map(int, input().split()))
A=[0]*(N+1)
for _ in range(K):
  k=int(input())
  a=list(map(int, input().split()))
  for i in a:
    A[i]+=1
c=0
for i in range(1,N+1):
  c+=not A[i]
print(c)

Measured memory_bytes: 67032
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int n, m;
vector<int> edge[100001];

int dfs(int x, int p) {
    vector<int> child;
    for (int i : edge[x]) {
        if (i == p) continue;
        int ret = dfs(i, x);
        if (ret > m) return m + 5;
        child.push_back(ret);
    }
    if ((child.size() & 1) == 0) child.push_back(0);
    sort(child.begin(), child.end());
    int s = 0, e = child.size();
    while (s < e) {
        int md = (s + e) / 2, pos = 1;
        for (int i = 0, j = child.size() - 1; ; ++i, --j) {
            if (i == md) ++i;
            if (j == md) --j;
            if (j <= i) break;
            if (child[i] + child[j] > m) {
                pos = 0;
                break;
            }
        }
        if (pos) e = md;
        else s = md + 1;
    }
    if (s == child.size()) return m + 5;
    if (x == 1 && (edge[x].size() & 1) == 0 && s > 0) return m + 5;
    return child[s] + 1;
}

int check() {
    return dfs(1, 0) <= m + 1;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 1; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }
    int A = n - 1;
    for (int i = 1; i <= n; ++i) A -= edge[i].size() >> 1;
    int s = 1, e = n - 1;
    while (s < e) {
        m = (s + e) / 2;
        if (check()) e = m;
        else s = m + 1;
    }
    printf("%d %d\n", A, s);
    return 0;
}

Measured memory_bytes: 13696
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")




int main() {


    ll n,m; cin >> n >> m;
    ll p = 1;
    vector<pair<pair<ll,ll>,pair<ll,string>>> v(m);

    rep(i,m){
        cin >> v[i].first.first >> v[i].first.second;
        v[i].second.first = i;
    }

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

    rep(i,m){
        if(i == 0) p = 1;
        else {
            if(v[i].first.first == v[i-1].first.first) p ++;
            else p = 1;
        }
        ostringstream sout1,sout2;
        sout1 << setfill('0') << setw(6) << v[i].first.first;
        sout2 << setfill('0') << setw(6) << p;
        string s1 = sout1.str();
        string s2 = sout2.str();

        v[i].second.second = s1+s2;
    }

    rep(i,m){
        v[i].first.first = v[i].second.first;
    }

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

    rep(i,m){
        cout << v[i].second.second << endl;
    }


    return 0;
}


Measured memory_bytes: 8748
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  string S;
  int K;
  ll ans = 0;
  bool flag = false;
  cin >> S >> K;

  int left = 1, right = 1;
  for (int i = 0; i < S.size() - 1; i++) {
    if (S.at(i) != S.at(i + 1)) {
      flag = true;
      break;
    } else
      left++;
  }

  if (!flag) {
    cout << (S.size() * K) / 2 << endl;
    return 0;
  }

  for (int i = S.size() - 1; i > 0; i--) {
    if (S.at(i) != S.at(i - 1)) {
      break;
    } else
      right++;
  }

  for (int i = 0; i < S.size() - 1; i++) {
    if (S.at(i) == S.at(i + 1)) {
      S.at(i + 1) = '0';
      ans++;
    }
  }
  ans *= K;

  if (S.at(0) == S.at(S.size() - 1))
    ans -= ((left / 2) + (right / 2) - ((left + right) / 2)) * (K - 1);

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())

int bin_to_int(string s) {
    reverse(s.begin(), s.end());
    int res = 0;
    int x = 1;
    for (int i = 0; i < sz(s); i++, x *= 2) {
        if (s[i] == '1')
            res += x;
    }
    return res;
}
int smaller(string s, int k) {
    k = sz(s) - 1 - k;
    if (k < 0) {
        return 0;
    }
    int res = 0;
    if (k > 0) {
        res += bin_to_int(s.substr(0, k)) * (1ll << (sz(s) - 1 - k));
    }
    if (s[k] == '1' && k < sz(s) - 1) {
        res += bin_to_int(s.substr(k + 1));
    }
    if (s[k] == '1')
        res++;
    return res;
}

string bin(int x) {
    string s = "";
    while (x > 0) {
        if (x % 2)
            s += '1';
        else
            s += '0';
        x /= 2;
    }
    reverse(s.begin(), s.end());
    return s;
}

signed main() {
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int bit[60] = {0};
    if (b > 0) {
        for (int i = 0; i < 60; i++) {
            bit[i] = smaller(bin(b), i);
        }
    }
    if (a - 1 > 0) {
        for (int i = 0; i < 60; i++) {
            bit[i] -= smaller(bin(a - 1), i);
        }
    }
    int ans = 0;
    for (int i = 0; i < 60; i++) {
        if (bit[i] % 2)
            ans += pow(2, i);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
package main

import "fmt"

var n int
var as []int

func main() {
	fmt.Scan(&n)
	as = make([]int, n)
	for i := range as {
		fmt.Scan(&as[i])
	}
	ls := make([]int, n)
	rs := make([]int, n)

	ls[0] = as[0]
	rs[n-1] = as[n-1]
	for i := 1; i < n; i++ {
		ls[i] = gcd(as[i], ls[i-1])
		rs[n-1-i] = gcd(as[n-1-i], rs[n-i])
	}
	ans := 1
	for k := range as {
		if k == 0 {
			ans = max(ans, (rs[k+1]))
			continue
		} 
		if k == n-1 {
			ans = max(ans, (ls[k-1]))
			continue
		}
		ans = max(ans, gcd(ls[k-1], rs[k+1]))
	}
	fmt.Println(ans)
}

func gcd(a, b int) int {
	for b > 0 {
		a, b = b, a%b
	}
	return a
}

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


Measured memory_bytes: 5504
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)

int gcd(int x, int y)
{
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

int main()
{
  // 入力
  ll N;
  cin >> N;
  ll A[N];
  for (ll i = 0; i < N; ++i)
    cin >> A[i];

  // 解法
  ll num_gcd = A[0];
  rep(i, N)
  {
    num_gcd = gcd(num_gcd, A[i]);
  }
  cout << num_gcd << endl;
}

Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))
q=int(input())
#b=[0]*q
#c=[0]*q
ans=0
l=[0]*1000001
for i in range(n):
    ans+=a[i]
    l[a[i]]+=1

for i in range(q):
    b, c=map(int,input().split())
    x=c-b
    ans+=x*l[b]
    l[c]+=l[b]
    l[b]=0
    print(ans)


Measured memory_bytes: 91188
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)


int main(){

    int a, b, k;
    cin >> a >> b >> k;
    bool takahashi_flag = true;
    for (; k;--k){
        if(takahashi_flag){
            a /= 2;
            b += a;

        }else{
            b /= 2;

            a += b;
        }
        takahashi_flag = !takahashi_flag;

    }

    cout << a << " " << b << endl;

    return 0;
}

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

int main(){
	int n;
  	cin >> n;
  	int mt[n];
  	
  	for(int i=0; i<n; i++){
      cin >> mt[i];
    }
  
  	int cnt = 0, mx=0;
  	for(int i=0; i<n; i++){
      	if(mt[i] >= mx) cnt++;   	
		mx = max(mt[i], mx);
    }
	
  	cout << cnt << endl;
  	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int W, H, T, P;
int A[2][101][101];
//---------------------------------------------------------------------------------------------------
void _main() {
    while (cin >> W >> H >> T >> P) {
        if (W == 0) return;
        
        rep(t, 0, 2) rep(y, 0, 101) rep(x, 0, 101) A[t][y][x] = 0;
        rep(y, 0, H) rep(x, 0, W) A[0][y][x] = 1;

        rep(t, 0, T) {
            int d, c; cin >> d >> c;
            rep(y, 0, 101) rep(x, 0, 101) A[(t + 1) % 2][y][x] = 0;

            if (d == 1) {
                rep(y, 0, H) rep(x, 0, W) A[(t + 1) % 2][y][x] = A[t % 2][y][x + c];
                rep(x, 0, c) rep(y, 0, H) A[(t + 1) % 2][y][x] += A[t % 2][y][c - 1 - x];
            } else {
                rep(y, 0, H) rep(x, 0, W) A[(t + 1) % 2][y][x] = A[t % 2][y + c][x];
                rep(x, 0, W) rep(y, 0, c) A[(t + 1) % 2][y][x] += A[t % 2][c - 1 - y][x];
            }
        }

        rep(p, 0, P) {
            int x, y; cin >> x >> y;
            printf("%d\n", A[T % 2][y][x]);
        }
    }
}



Measured memory_bytes: 3300
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

class Program

{
    public Program() { }
    public static int Main()
    {
        cin = new Scanner();
        new Program().calc();
        return 0;
    }
    static Scanner cin;

    void calc()
    {
        string S;
        S = cin.next();
        Console.WriteLine(S=="ARC"?"ABC":"ARC");


    }



}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


class XRand
{
    uint x, y, z, w;


    public XRand()
    {
        init();
    }

    public XRand(uint s)
    {
        init();
        init_xor128(s);
    }

    void init()
    {
        x = 314159265; y = 358979323; z = 846264338; w = 327950288;

    }

    public void init_xor128(uint s)
    {
        z ^= s;
        z ^= z >> 21; z ^= z << 35; z ^= z >> 4;
        z *= 736338717;
    }

    uint next()
    {
        uint t = x ^ x << 11; x = y; y = z; z = w; return w = w ^ w >> 19 ^ t ^ t >> 8;
    }

    public long nextLong(long m)
    {
        return (long)((((ulong)next() << 32) + next()) % (ulong)m);
    }

    public int nextInt(int m)
    {
        return (int)(next() % m);
    }

    public int nextIntP(int a)
    {
        return (int)Math.Pow(a, nextDouble());
    }

    public int nextInt(int min, int max)
    {
        return min + nextInt(max - min + 1);
    }


    public double nextDouble()
    {
        return (double)next() / uint.MaxValue;
    }

    public double nextDoubleP(double a)
    {
        return Math.Pow(a, nextDouble());
    }
}

Measured memory_bytes: 25584
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
using namespace std;

typedef long long ll;
const int maxn=1e2+10;
int n,dep[maxn],f[maxn],len;
vector<int> g[maxn];

void dfs(int pos,int fa,int forbit){
	dep[pos]=dep[fa]+1;
	f[pos]=fa;
	for(int i=0;i<g[pos].size();++i)
		if(g[pos][i]!=fa&&g[pos][i]!=forbit)
			dfs(g[pos][i],pos,forbit);
}
inline void init(){
	dfs(1,0,0);
	dfs(max_element(dep+1,dep+n+1)-dep,0,0);
	len=*max_element(dep+1,dep+n+1);
	cout<<(len+1)/2<<' ';
}
inline ll calc(ll base,ll maxdep){
	for(int i=1;i<maxdep;++i){
		int res=0;
		for(int j=1;j<=n;++j)
			if(dep[j]==i)
				if(g[j].size()>res)
					res=g[j].size();
		if(i==1&&base==1)
			base*=res;
		else
			base*=res-1;
	}
	return base;
}
inline void work_even(){
	int pos=max_element(dep+1,dep+n+1)-dep;
	while(dep[pos]!=len/2+1)
		pos=f[pos];
	dfs(f[pos],0,pos);
	dfs(pos,0,f[pos]);
	cout<<calc(2,len/2)<<endl;
}
inline void work_odd(){
	int pos=max_element(dep+1,dep+n+1)-dep;
	while(dep[pos]!=len/2+1)
		pos=f[pos];
	ll ans=~(1ll<<63);
	dfs(pos,0,0);
	ans=min(ans,calc(1,len/2+1));
	for(int i=0;i<g[pos].size();++i){
		dfs(pos,0,g[pos][i]);
		dfs(g[pos][i],0,pos);
		ans=min(ans,calc(2,len/2+1));
	}
	cout<<ans<<endl;
}

int main(){
	cin>>n;
	for(int i=1,u,v;i<n;++i){
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	init();
	if(len&1)
		work_odd();
	else
		work_even();
	return 0;
}


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

int main(){
    int r;
    cin>>r;
    if(r<1200){
        cout<<"ABC";
        return 0;
    }
    if(r<2800){
        cout<<"ARC";
        return 0;
    }
    cout<<"AGC";
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main(){
  s:= [][]int{}
  n :=0
var k int
  fmt.Scanf("%d",&k)
  
  for i:=1; i<k;i++{
    for  j:=i+1;j<=k;j++ {
      t:=[]int{i,j}
      s = append(s,t)
    }
  }
  for _,v :=range s {
    if v[0]%2==0 && v[1]%2==0 {
    } else if v[0]%2 !=0 && v[1]%2 !=0{
    } else {
    n = n+1
    }
  }
  fmt.Println(n)
}

Measured memory_bytes: 1152
fun main(args: Array<String>) {
    readLine()!!.toInt()
    val a = readLine()!!.split(" ").map(String::toLong)
    val sum = a.map { Math.abs(it) }.sum()
    val min = Math.abs(a.minBy { Math.abs(it) }!!)
    val hasMinus = a.count { it < 0 } % 2 == 1
    println(if (hasMinus) sum - min * 2 else sum)
}


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

using namespace std;

#define maxn 300005
#define ll long long

int n,m,k;
int a[maxn];

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    cout<<a[n/2+1]-a[n/2];
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll x;
    cin >> x;
    for( ll a = -300;a<=300;a++){
        for(ll b = -300;b<=300;b++){
            if(pow(a,5) - pow(b,5) == x ){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4056
fun main(args: Array<String>) {
    val input1 = readLine()!!.split(" ")
    var takahashiCookieCount = input1[0].toLong()
    var aokiCookieCount = input1[1].toLong()
    val operationCount = input1[2].toLong()

    val takahashiCookieCount2: Long
    val aokiCookieCount2: Long
    if (operationCount >= (takahashiCookieCount + aokiCookieCount)) {
        takahashiCookieCount2 = 0
        aokiCookieCount2 = 0
    } else if (takahashiCookieCount > operationCount) {
        takahashiCookieCount2 = takahashiCookieCount - operationCount
        aokiCookieCount2 = aokiCookieCount
    } else {
        takahashiCookieCount2 = 0
        aokiCookieCount2 = aokiCookieCount - (operationCount - takahashiCookieCount)
    }

    println("$takahashiCookieCount2 $aokiCookieCount2")
}


Measured memory_bytes: 36184
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
#define SIZE 100000

ll Alist[SIZE] = {0};
pair<int, ll> BC[SIZE];
ll Dlist[SIZE] = {0};

int compare(pair<int, ll> &p1, pair<int, ll> &p2){
    return p1.second > p2.second;
}

int main(){
    int N, M;
    cin >> N >> M;
    for(int i=0; i<N; i++){
        cin >> Alist[i];
    }
    for(int j=0; j<M; j++){
        int B;
        ll C;
        cin >> B >> C;
        BC[j] = pair<int, ll>(B, C);
    }
    sort(Alist, Alist+N);
    sort(BC, BC+M, compare);
    int i=0, j=0;
    while(true){
        pair<int, ll> p = BC[j];
        for(int k=0;k<p.first;k++){
            Dlist[i] = p.second;
            i++;
            if(i >= N) break;
        }
        j++;
        if(j >= M) break;
    }
    for(int i=0; i<N; i++){
        if(Alist[i] >= Dlist[i]) break;
        Alist[i] = Dlist[i];   
    }
    ll sum = 0;
    for(int i=0; i<N; i++){
        sum += Alist[i];
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=105;

int N,M,X,Y;
char mp[MAXN][MAXN];
short dp[MAXN][MAXN][MAXN][MAXN];
short sum[MAXN][MAXN];

short CountRect(int u,int l,int d,int r)
{
	return sum[d][r]-sum[d][l-1]-sum[u-1][r]+sum[u-1][l-1];
}

int main()
{
    scanf("%d%d",&N,&M);
    for(int i=1;i<=N;i++)
	{
		scanf("%s",mp[i]+1);
		for(int j=1;j<=M;j++)
			if(mp[i][j]=='E')
				X=i,Y=j;
	}
	for(int i=1;i<=N;i++)
		for(int j=1;j<=M;j++)
			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+(mp[i][j]=='o');
	int ans=0;
	for(int u=X;u>0;u--)
		for(int l=Y;l>0;l--)
			for(int d=X;d<=N;d++)
				for(int r=Y;r<=M;r++)
				{
					ans=max(ans,(int)dp[u][l][d][r]);
					//printf("dp[(%d,%d),(%d,%d)]=%d ",u,l,d,r,(int)dp[u][l][d][r]);
					int U=d-X+1,L=r-Y+1,D=N-(X-u),R=M-(Y-l);
					//printf("Area:(%d,%d),(%d,%d)\n",U,L,D,R);
					if(u>U)
						dp[u-1][l][d][r]=max((int)dp[u-1][l][d][r],dp[u][l][d][r]+CountRect(u-1,max(L,l),u-1,min(R,r)));
					if(l>L)
						dp[u][l-1][d][r]=max((int)dp[u][l-1][d][r],dp[u][l][d][r]+CountRect(max(U,u),l-1,min(D,d),l-1));
					if(d<D)
						dp[u][l][d+1][r]=max((int)dp[u][l][d+1][r],dp[u][l][d][r]+CountRect(d+1,max(L,l),d+1,min(R,r)));
					if(r<R)
						dp[u][l][d][r+1]=max((int)dp[u][l][d][r+1],dp[u][l][d][r]+CountRect(max(U,u),r+1,min(D,d),r+1));
				}
	printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 227584
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,M;

LL ans = 0;

vector<LL> calc_divisor(LL x){
	vector<LL> ret;
	for(int i=1;i*i<=x;i++){
		if(x%i==0){
			ret.push_back(i);
			if(i!=x/i)ret.push_back(x/i);
		}
	}
	sort(ret.begin(),ret.end(),greater<LL>());
	return ret;
}

void solve(){
	vector<LL> divisor = calc_divisor(M);
	for(int i=0;i<divisor.size();i++){
		if(M/N>=divisor[i]){
			ans = divisor[i];
			return;
		}
	}
}
 
int main(){
    cin >> N >> M;

    solve();

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

Measured memory_bytes: 256
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int D = sc.nextInt();
    System.out.println(N/(1+(2*D)) + (N%(1+(2*D)) == 0 ? 0 : 1));
  }
}

Measured memory_bytes: 22996
#include<stdio.h>

#define NUM 9999

int main(void)
{
        char a[NUM];
        scanf("%s",a);

        int i,num;
        num=0;

        for(i=0;a[i]!='\n';i++)         if(a[i]=='1')   num++;

        printf("%d",num);

        return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

const long double pi = 3.141592653589793;

#define debug(x) cerr << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

ll N, A, B;
vector<ll> Z(1<<20);
vector<ll> X(1<<20);
vector<ll> Y(1<<20);

int main() {

    //freopen("lazy_loading.txt","r",stdin);
    //freopen("output_file_name.txt","w",stdout);

    cin>>N>>A>>B;
    rep(i, N) cin>>Z[i+1];
    X[0] = Y[0] = 1;
    int j = 0, k = 0;
    for(int i = 1;i < N;i++) {
        Y[i] = X[upper_bound(Z.begin()+1, Z.begin()+i, Z[i+1]-B) - Z.begin() - 1];
        X[i] = Y[upper_bound(Z.begin()+1, Z.begin()+i, Z[i+1]-A) - Z.begin() - 1];

        if(Z[i+1]-Z[i] < A) while(j < i) X[j++] = 0;
        if(Z[i+1]-Z[i] < B) while(k < i) Y[k++] = 0;

        X[i] = (X[i] + X[i-1]) % mod;
        Y[i] = (Y[i] + Y[i-1]) % mod;
    }

    cout<<(X[N-1] + Y[N-1]) % mod<<endl;

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> card;
  
  for(int i=0; i<N; i++)
  {
    int s;
    cin >> s;
    card.push_back(s);
  }
  
//  sort(card.begin(), card.end() );
  sort(card.begin(), card.end(), std::greater<int>() );
  
  int A = 0;
  int B = 0;
  
  for(int i=0; i<N; i++)
  {
    if(i%2==0)
    {
      A += card[i];
    }else{
      B += card[i];
    }
    
  }
  
  cout << A - B << endl;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    n=I()
    lis=LI()
    sm=list(accumulate(lis))
    u=sum(lis)
    ans=inf
    for i in range(n):
        ans=min(ans,abs(u-sm[i]-sm[i]))
    print(ans)
        
        



        
        
        
        
        
    
if __name__=="__main__":
    main()



Measured memory_bytes: 110324
import std.stdio, std.conv, std.string, std.array, std.algorithm, std.range,
    std.math, std.numeric, std.typecons;

void main()
{
    long n, m;
    readf("%d %d\n", &n, &m);

    long[] as = [];
    long[] cs = [];

    foreach (i; 0 .. m)
    {
        long a, b;
        readf("%d %d\n", &a, &b);
        as ~= a;
        cs ~= readln.strip
            .split
            .to!(long[])
            .map!(c => 1 << (c - 1))
            .reduce!((a, b) => a | b);
    }

    const target = (1 << n) - 1;
    auto dp = new long[](1 << n);
    const inf = long.max / 4;
    foreach (ref d; dp)
    {
        d = inf;
    }
    dp[0] = 0;
    foreach (i; 0 .. m)
    {
        foreach (j; 0 .. (1 << n))
        {
            dp[j | cs[i]] = min(dp[j | cs[i]], dp[j] + as[i]);
        }
    }

    if (dp[target] == inf)
    {
        writeln(-1);
    }
    else
    {
        writeln(dp[target]);
    }

}


Measured memory_bytes: 2556
#include <bits/stdc++.h> 
using namespace std; 
int gi() { 
	int res = 0, w = 1; 
	char ch = getchar(); 
	while (ch != '-' && !isdigit(ch)) ch = getchar(); 
	if (ch == '-') w = -1, ch = getchar(); 
	while (isdigit(ch)) res = res * 10 + ch - '0', ch = getchar(); 
	return res * w; 
} 
const int MAX_N = 3e5 + 5; 
int N, M, Q; 
vector<int> G[MAX_N]; 
struct node { int v, d, c; } a[MAX_N]; 
int A[11][MAX_N]; 
#define fi first
#define se second
void bfs(int d, int s, int c) { 
	queue<pair<int, int> > que; que.push({s, d}); 
	while (!que.empty()) { 
		pair<int, int> p = que.front(); que.pop(); 
		int x = p.fi, dep = p.se; 
		if (A[dep][x]) continue; 
		A[dep][x] = c; 
		if (!dep) continue; 
		que.push({x, dep - 1}); 
		for (int v : G[x]) que.push({v, dep - 1}); 
	} 
} 
int main () { 
#ifndef ONLINE_JUDGE 
    freopen("cpp.in", "r", stdin); 
#endif 
	N = gi(), M = gi(); 
	for (int i = 1; i <= M; i++) { 
		int u = gi(), v = gi(); 
		G[u].push_back(v), G[v].push_back(u); 
	}
	Q = gi(); 
	for (int i = 1; i <= Q; i++) a[i] = (node){gi(), gi(), gi()}; 
	for (int i = Q; i; i--) bfs(a[i].d, a[i].v, a[i].c); 
	for (int i = 1; i <= N; i++) printf("%d\n", A[0][i]); 
    return 0; 
} 

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

#define eps 1e-8
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)

typedef long long LL;

int main(){
    FAST_IO;
    int n,m;
    cin>>n>>m;
    int ans=n-1;
    if(m>=n) ans++;
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
/*#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e9 + 7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.setf(ios::fixed);
	cout.precision(20);

	vs v;
	string s1, s2;
	vs cs1, cs2;
	while (true) {
		cin >> s1;
		if (s1 == ".") break;
		cin >> s2;
		ll sum = 0;
		if (s1 == s2) v.pb("IDENTICAL");
		else {
			rep(i, s1.size()) {
				rep(j, s1.size()) {
					if (i != j && s1[i] == '"' && s1[j] == '"') {
						cs1.pb(s1.substr(i + 1, j - 1));
						s1[i] = '0'; s1[j] = '0';
					}

				}
			}
			rep(i, s2.size()) {
				rep(j, s2.size()) {
					if (i != j && s2[i] == '"' && s2[j] == '"') {
						cs2.pb(s2.substr(i + 1, j - 1));
						s2[i] = '0'; s2[j] = '0';
					}

				}
			}
			rep(i, cs1.size()) {
				cout << cs1[i] << " " << cs2[i] << endl;
				if (cs1[i] != cs2[i]) sum++;
				if (sum == 2) break;
			}
			if (sum == 1) v.pb("CLOSE");
			else v.pb("DIFFERENT");
		}
	}
	rep(i, v.size()) cout << v[i] << endl;
	return 0;
}*/
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e9 + 7;

int main()
{
	ios_base::sync_with_stdio(false);

	string s;
	ll w;
	cin >> s >> w;
	ll i = 0;
	while (true) {
		cout << s[i];
		i += (w);
		if (i > s.size() - 1)break;
	}


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  string S, T;
  cin >> S >> T;
  int cnt = 0;
  rep(i, 3)
    if(S[i] == T[i])
      cnt++;
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    for (int i = 1; i < n+1; i++) {
        ans += n / i * max(i - k, 0);
        ans += max(n % i - max(k-1,0), 0);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3544
//----------ACCIDENTAL COMPETITIVE PROGRAMMER---------------------

#include<bits/stdc++.h>

/*
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/
using namespace std;

#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair


const LL MOD = (1e9) + 7 ;
const LD EPS = 0.0000001 ;

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int x, y, z, k; cin >> x >> y >> z >> k;
    LL arr[x], brr[y], crr[z];
    for (int i = 0; i < x; i++)
    	cin >> arr[i];
    for (int i = 0; i < y; i++)
    	cin >> brr[i];
    for (int i = 0; i < z; i++)
    	cin >> crr[i];
   	vector<LL> v;
   	for (int i = 0; i < x; i++){
   		for (int j = 0; j < y; j++)
   			v.PB(arr[i] + brr[j]);
   	}
   	sort(v.begin(), v.end());
   	reverse(v.begin(), v.end());
   	vector<LL> newV;
   	for (int i = 0; i < min(x * y, 3000); i++){
   		newV.PB(v[i]);
   	}

   	v.clear();

   	for (int i = 0; i < z; i++){
   		for (int j = 0; j < newV.size(); j++)
   			v.PB(crr[i] + newV[j]);
   	}

   	sort(v.begin(), v.end());
   	reverse(v.begin(), v.end());
   	for (int i = 0; i < k; i++)
   		cout << v[i] << endl;

	return 0;
}

Measured memory_bytes: 35172
import math

def divisors(n):
    s = set()
    for x in range(2, math.ceil(n ** 0.5) + 1):
        while n % x == 0:
            s.add(x)
            n /= x
            if n == 1:
                break
    if n > 1:
        s.add(n)
    return s
 
a, b = map(int, input().split())
d = divisors(a) & divisors(b)
print(len(d) + 1)

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

using namespace std;
const int INF =  10e9 + 5;
int main() {
	int n;
	cin>>n;
	vector<int> h(n);
	
	for(int &x: h) {
		cin>>x;
	}
	
	vector<int> dp(n, INF);
	dp[0] = 0;
	for(int i = 0;i<n;i++) {
		for(int j: {i+1, i+2}) {
			if(j < n) {
				dp[j] = min(dp[i] + abs(h[i] - h[j]), dp[j]);
			}
		}
	}
	
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
/*
PROG: arc085c
LANG: C++
    _____
  .'     '.
 /  0   0  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
*/
#include <bits/stdc++.h>
 
using namespace std;
 
long long readi()
{
	long long input = 0;
	char c = ' ';
	while (c < '-')
	{
		c = getchar();
	}
	bool negative = false;
	if (c == '-')
	{
		negative = true;
		c = getchar();
	}
	while (c >= '0')
	{
		input = 10 * input + (c - '0');
		c = getchar();
	}
	if (negative)
	{
		input = -input;
	}
	return input;
}
void printi(long long output)
{
	if (output == 0)
	{
		putchar('0');
		return;
	}
	if (output < 0)
	{
		putchar('-');
		output = -output;
	}
	int aout[20];
	int ilen = 0;
	while(output)
	{
		aout[ilen] = ((output % 10));
		output /= 10;
		ilen++;
	}
	for (int i = ilen - 1; i >= 0; i--)
	{
		putchar(aout[i] + '0');
	}
	return;
}
string reads()
{
	string input = "";
	char c = ' ';
	while (c <= ' ')
	{
		c = getchar();
	}
	while (c > ' ')
	{
		input += c;
		c = getchar();
	}
	return input;
}
void prints(string output)
{
	for (int i = 0; i < output.length(); i++)
	{		
		putchar(output[i]);
	}
	return;
}
int sgn(long long x)
{
	if (x < 0) 
	{
		return -1;
	}
	if (x > 0) 
	{
		return 1;
	}
	return 0;
}

#define MP make_pair
#define PB push_back
#define PF push_front
#define MT make_tuple
#define LB lower_bound
#define UB upper_bound

#define SINF 10007
#define MOD 1000000007
#define INF 1000000861
#define LLINF 1000000000000000861ll
#define CO 1000861
#define EPS 0.000000000000001
#define PI 3.141592653589793

typedef int64_t ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int N, M, F, T;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	srand(time(NULL));
	//	cout << fixed << setprecision(10);	
	//	cerr << fixed << setprecision(10);
	//	if (fopen("arc085c.in", "r"))
	//	{	
	//		freopen ("arc085c.in", "r", stdin);
	//		freopen ("arc085c.out", "w", stdout);
	//	}
	cin >> N >> M;
	F = N - M;
	T = 100 * F + (1900) * (M);
	T *= (1 << M);
	cout << T << '\n';
	return 0;
}


Measured memory_bytes: 256