akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <bitset>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define mp make_pair
#define pb push_back
#define off 10000
using namespace std; 
typedef long long ll; 
bitset<off * 2 + 5> xx, yy; 
char str[off + 5]; 
int main()
{
	// freopen("ARC087-D.in", "r", stdin); 
	scanf("%s", str); 
	int n = strlen(str), cnt = 0; 
	bool f = false, fst = true;
	xx.set(off); 
	yy.set(off); 
	for (int i = 0; i <= n; i++)
	{
		if (str[i] == 'F')
			cnt++; 
		else
		{
			auto &t = f ? yy : xx; 
			if (fst)
				t <<= cnt; 
			else
				t = (t << cnt) | (t >> cnt); 
			fst = false; 
			cnt = 0; 
			f ^= 1; 
		}
	}
	int x, y; 
	scanf("%d%d", &x, &y); 
	if (x < -off || y < -off || x > off || y > off)
		puts("No"); 
	else
		puts(xx.test(x + off) && yy.test(y + off) ? "Yes" : "No"); 
	return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(x.rbegin(), x.rend())
#define REVERSE(x) reverse(ALL(x))
#define MAX(x) *max_element(ALL(x))
#define MAXI(x) max_element(ALL(x)) - x.begin()
#define SUM(x) accumulate(ALL(x), 0ll)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YN YES else NO
#define yn Yes else No
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(z, v.size()) cerr << " " << v[z]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;

template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  rep(j, v.size()) i >> v[j];
  return i;
}

template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

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;
}

signed main() {
  init();
  ll N, M;
  string S;
  cin >> N >> M >> S;

  vll dp(N + 1, INF);
  dp[N] = 0;
  qll q;
  q.push(0);
  repr(i, N - 1) {
    while (1) {
      if (q.size() == 0) {
        puts("-1");
        return 0;
      }
      if (q.front() != INF and (ll) q.size() <= M) break;
      q.pop();
    }
    if (S[i] == '0') dp[i] = q.front() + 1;
    q.push(dp[i]);
  }

  vll ans;
  ll x = 0;
  ll rest = dp[0];
  while (x < N) {
    rest--;
    ll i = 1;
    while (dp[x + i] != rest) i++;
    ans.pb(i);
    x += i;
  }

  rep(i, ans.size()) {
    if (i == 0)
      cout << ans[i];
    else
      cout << " " << ans[i];
  }
  ENDL;
  return 0;
}

Measured memory_bytes: 5236
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,i,t;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)
	{
		scanf("%d",&t);
	}
	printf("%d",(n-1)/(m-1)+((n-1)%(m-1)==0?0:1));
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.util.*

fun main() = agc019b()

@OptIn(ExperimentalStdlibApi::class)
fun agc019b() = SimpleFastIOWithToken_agc019b().exec {
    val s = readString()
    val n = s.length.toLong()

    val duplicateCount = s.groupingBy { it }.eachCount().map { it.value.toLong() }
        .map { it * (it - 1) / 2 }.sum()

    val answer = 2L + (n * (n - 1) / 2 - 1) - duplicateCount

    println(answer)
}

// region kokokara template dayo (^o^)
@Suppress("unused", "HasPlatformType", "MemberVisibilityCanBePrivate", "ClassName")
private class SimpleFastIOWithToken_agc019b(private val separator: String = System.lineSeparator()) {
    private val br: BufferedReader = System.`in`.bufferedReader()
    private var st: StringTokenizer = StringTokenizer("")
    private val sb: StringBuilder = StringBuilder()
    private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }

    fun readString(): String = run { prepareNext() }.run { st.nextToken() }
    fun readStringList(size: Int): List<String> = List(size) { readString() }
    fun readInt(): Int = Integer.valueOf(readString())
    fun readIntList(size: Int): List<Int> = List(size) { readInt() }
    fun readLong(): Long = java.lang.Long.valueOf(readString())
    fun readLongList(size: Int): List<Long> = List(size) { readLong() }
    inline fun <reified T> readArray(size: Int, init: () -> T): Array<T> = Array(size) { init() }
    inline fun <T> readList(size: Int, init: () -> T): List<T> = List(size) { init() }

    fun println(): Unit = run { sb.append(separator) }
    fun print(any: Any): Unit = run { sb.append(any) }
    fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }

    fun exec(action: SimpleFastIOWithToken_agc019b.() -> Unit) = run {
        Thread(null, { action() }, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()
    }.run { kotlin.io.print(sb) }

    fun readLine(): Nothing = error("readLine is disabled.")
}
// endregion kokomade template dayo (^o^)


Measured memory_bytes: 40948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
int main(){
    int N,flag=0;
    cin >> N;
    for(int i=1; i<=9; i++){
        for(int j=1; j<=9; j++){
            if(N==i*j){
                flag=1;
            }
        }
    }

    if(flag==1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.05.16 16:54:53
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int n;
  cin >> n;
  unordered_map<string, int> w;
  string tmp;
  vector<pair<char, char> > be(n);
  REP(i,n){
    cin >> tmp;
    w[tmp]++;
    if(w[tmp] > 1){
      cout << "No" << endl;
      return 0;
    }
    be[i].first = tmp[0];
    be[i].second = tmp[tmp.size() - 1];
  }
  REP(i, n - 1){
    if(be[i + 1].first != be[i].second){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes"  << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	int N;
	string S;
	cin >> N >> S;

	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		if (!i) {
			for (int j = 1; j < N; j++) {
				if (S.at(j) == 'E') v.at(i)++;
			}
		}
		else {
			int n = v.at(i - 1);
			if (S.at(i) == 'E') n--;
			if (S.at(i - 1) == 'W') n++;
			v.at(i) = n;
		}
	}

	//for (int i = 0; i < N; i++) cout << v.at(i);
	//cout << endl;

	int ans = N;
	for (int i = 0; i < N; i++) {
		ans = min(ans, v.at(i));
	}

	cout << ans << endl;
}

Measured memory_bytes: 4812
A,B,C,K = map(int, input().split() )

if K % 2 == 0:
  ans = (A-B)
else:
  A,B,C = B+C, A+C, A+B
  ans =  (A-B)

if abs(ans) > 10**18:
  print("Unfair")
else:
  print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

struct drink
{
	int yen;
	int lim;
};

bool cmp(drink &A,drink &B){
	if(A.yen==B.yen){
		return A.lim > B.lim;
	}else{
		return A.yen < B.yen;
	}
}

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

	int N, M;cin >> N >> M;
	vector<drink> T(N);

	

	for (int i = 0; i < N; i++) {
		cin >> T[i].yen >> T[i].lim;
	}

	sort(all(T), cmp);

	int cnt = 0;
	int ans = 0;
	int i = 0;
	while(1){
		if(cnt+T[i].lim>=M){
			ans += (T[i].yen * (M - cnt));
			break;
		}else{
			cnt += T[i].lim;
			ans += (T[i].yen * T[i].lim);
		}
		i++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;

int main(){
   int h,w,d;cin>>h>>w>>d;
   vector<P> g(h*w+1);
   rep(i,h){
       rep(j,w){
           int a;cin>>a;
           g[a]={i,j};
       }
   }
   vi sum (h*w+1,0);
   rep(_,d){
       sum[_]=0;
       for(int i=_+d;i<h*w+1;i+=d){
           sum[i]=sum[i-d]+abs(g[i].first-g[i-d].first)+abs(g[i].second-g[i-d].second);
       }
   }
   int q;cin>>q;
   rep(i,q){
       int a,b;cin>>a>>b;
       cout<<sum[b]-sum[a]<<endl;
   }
}


Measured memory_bytes: 2176
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
from fractions import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)

def input():
    return sys.stdin.readline()[:-1]

def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))

    ans = n - sum(a)
    print(ans) if ans >= 0 else print(-1)

if __name__ == '__main__':
    main()



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

int calc(vector<int> V, int a, int b, int k){
    vector<int> v;
    if( a == 0){
        if (b > 0)
            v = vector<int>(V.end() - b, V.end());
        else
            return 0;
    }
    else{
        v = vector<int>(V.begin(), V.begin() + a);
        if (b > 0)
            v.insert( v.end(), V.end() - b, V.end());
    }
    sort(v.begin(), v.end());
    int res = 0;
    for(int i = 0; i < a + b; i++){
        if (v.at(i) >= 0){
            res += v.at(i);
        }else{
            if (i >= k - a - b)
                res += v.at(i);
        }
    }
    return res;
}

int main() {
    int N, K;
    cin >> N >>K;
    vector<int> V(N);
    for (int i = 0; i < N; i++){
        cin >> V[i];
    }

    int r = min(N, K);
    int ans = 0;
    for(int a = 0; a <= r; a++){
        for(int b = 0; b <= r - a; b++){
            int res = calc(V, a, b, K);
            if(ans < res)
                ans = res;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
AM = [0 for _ in range(N)]
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for j in range(d):
        AM[A[j]-1] += 1
cnt = 0
for i in range(N):
    if AM[i] == 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string s;cin >> s;
	int i = 0;
	int j = s.size() - 1;

	while(s[i] != 'A'){
		i++;
	}
	while(s[j] != 'Z'){
		j--;
	}
	cout << j - i + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
x = int(input())
if x == 1:
  print("1")
  exit()
  
ans = 0
for b in range(2,int(x**(1/2)+1)):
  for p in range(2,1000):
    tmp = pow(b,p)
    if tmp<=x:
      ans = max(ans,pow(b,p))
    else:
      break
      
print(ans)


Measured memory_bytes: 9364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

const ll mod=1e9+7;
ll mu(ll a,ll b){
  return (ll)a*b%mod;
}
ll ad(ll a,ll b){
  if((a+=b)>=mod)a-=mod;
  return a;
}
ll pw(ll a,ll b,ll c=1LL){
  for(;b;b>>=1,a=mu(a,a))if(b&1)c=mu(c,a);
  return c;
}
ll dv(ll a,ll b){
  return mu(a,pw(b,mod-2));
}

ll ans=0;
const int MAX_V=1e5+1;
vector<int> G[MAX_V];
int col[2][MAX_V];
//int used[2][MAX_V];
//int c[2]={1,1};
void add_edge(int from, int to){
  G[from].pb(to);
  G[to].pb(from);
}

void dfs(int p, int index, int K){
  col[0][index]=1;
  col[1][index]=col[0][p];
  col[0][p]+=1;
  ans = mu(ans, ((ll)(K-(col[0][index]+col[1][index]))) );
  //  cout << "ans " << ans << endl;
  rep(i, G[index].size()){
    int point = G[index][i];
    if(col[0][point]==0){
      dfs(index, point,K);
    }
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N,K;
  cin >> N >> K;
  //  int a[N],b[N];
  int at,bt;
  rep(i,N-1){
    cin >> at >> bt;
    add_edge(at-1,bt-1);
  }
  //  cout << " "<< endl;
  memset(col[0],0,sizeof(col[0]));
  memset(col[1],0,sizeof(col[1]));
  ans =K;
  //  cout << " "<< endl;
  rep(i, G[0].size()){
    dfs(0,G[0][i],K);
  }
  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 9984
// ConsoleApplication1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <iostream>
using namespace std;


int main()
{
	int R, G, B, N;
	cin >> R >> G >> B >> N;
	int sum = 0;
		for (int r = 0; r <= N; r++) {
			if (R * r > N) { break; 
			}
			else {
				for (int g = 0; g <= N-R*r; g++) {
					if (R * r + G * g > N) {
						break;
					}
					else {
						if ((N - R * r - G * g) % B == 0) {
							sum++;
						}
						
					}
				}
			}

		}
		cout << sum << endl;


}
// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int64_t, int> > vec(n);
	rep(i, n) {
		int64_t a;
		int b;
		cin >> a >> b;
		vec.at(i) = make_pair(a, b);
	}
	sort(vec.begin(), vec.end());
	int64_t res = 0;
	rep(i, n) {
		int num = min(m, vec.at(i).second);
		res += vec.at(i).first * num;
		m -= num;
	}
	cout << res << endl;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		new Main();
	}
	
	boolean ok(int x, int y){
		return x>=0 && y>=0 && x<10 && y<10;
	}
	
	public Main(){
		Scanner cin = new Scanner(System.in);
		int num[][] = new int[10][10];
		while(cin.hasNext()){
			String s = cin.nextLine();
			String[] st = s.split(",");
			int x = Integer.parseInt(st[0]);
			int y = Integer.parseInt(st[1]);
			int size = Integer.parseInt(st[2]);
			if(size==3) size=4;
			for(int i=-2;i<=2;i++){
				for(int j=-2;j<=2;j++){
					if(i*i+j*j>size) continue;
					int nextx = x + i;
					int nexty = y + j;
					if(ok(nextx,nexty)) num[nextx][nexty]++;
				}
			}
		}
		int maxnum = 0;
		int white = 0;
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				maxnum = Math.max(maxnum, num[i][j]);
				if(num[i][j]==0) white++;
			}
		}
		System.out.println(white);
		System.out.println(maxnum);
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;

int main()
{
	int N,X;
	cin>>N>>X;
	vector<int> a(N,0);
	rep(i,N) cin>>a[i];
	vector<int> b(N-1,0);
	vector<int> c(N-1,0);
	vector<int> nextA(N,0);
	ll sumOfDelta = 0;
	
	if( a[0] > X){
		nextA[0] = X;
	}else{
		nextA[0] = a[0];
	}
	for(int i = 1; i < N; i++){
		if( nextA[i-1] + a[i] <= X){
			nextA[i] = a[i];
		}else{
			nextA[i] = a[i] - ((nextA[i-1] + a[i]) - X );
		}
	}
	ll ans = 0;
	for(int i = 0; i < N; i++){
		ans += a[i] - nextA[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4396
fn main(){
    let mut sc = Scanner::new();
    let n = sc.next::<usize>()*2 - 1;
    let x:i32 = sc.next();

    if x == 1 || x == n as i32 {
        println!("No");
    } else {
        println!("Yes");
        let mut ans = vec![-1; n];
        if n == 3 {
            ans = vec![1, 2, 3];
        } else {
            let mut rem = vec![];
            let c = (n / 2) as usize;
            if x != 2 {
                ans[c-1] = x-2;
                ans[c]   = x;
                ans[c+1] = x+1;
                ans[c+2] = x-1;
                for i in 1..x-2 { rem.push(i) }
                for i in x+2..n as i32 + 1 { rem.push(i) }
            } else {
                ans[c-1] = x+2;
                ans[c]   = x;
                ans[c+1] = x-1;
                ans[c+2] = x+1;
                for i in 1..x-1 { rem.push(i) }
                for i in x+3..n as i32 + 1 { rem.push(i) }
            }
            for i in 0..n {
                if ans[i] == -1 {
                    ans[i] = rem.pop().unwrap();
                }
            }
            ans.reverse();
        }
        for i in 0..n as usize {
            println!("{}", ans[i]);
        }
    }
}

#[allow(dead_code)]
struct Scanner {
    buf: std::collections::VecDeque<String>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner { buf: std::collections::VecDeque::new() }
    }

    fn next<T: std::str::FromStr>(&mut self) -> T {
        self.wrapped::<T>().unwrap()
    }

    fn wrapped<T: std::str::FromStr>(&mut self) -> Option<T> {
        self.read();
        self.buf.pop_front().and_then(|s| s.parse::<T>().ok())
    }

    fn ok(&mut self) -> bool {
        self.read() && !self.buf.is_empty()
    }

    fn eof(&mut self) -> bool {
        !self.ok()
    }

    fn read(&mut self) -> bool {
        while self.buf.is_empty() {
            let mut st = String::new();
            while st.trim() == "" {
                match std::io::stdin().read_line(&mut st) {
                    Ok(l) if l > 0 => continue,
                    _ => return false,
                }
            }
            self.buf = st.split_whitespace().map(|x| x.to_string()).collect();
        }
        true
    }
}


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

int sumofdigits(int n) {
	int sum = 0;

	while (n > 0) {
		sum += n % 10;
		n /= 10;
	}

	return sum;
}

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

	int sum = sumofdigits(N);

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

	return 0;
}

Measured memory_bytes: 256
import sys

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return a


a,b,k=map(int, input().split())
gcd=egcd(a,b)


j=0
for i in range(gcd,0,-1):
    if gcd%i==0:
        j+=1
    if j==k:
        print(i)
        sys.exit()

Measured memory_bytes: 3064
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

struct CombMod{
    fac: Vec<u64>,
    inv: Vec<u64>,
    finv: Vec<u64>,
    mmod: u64,
}

impl CombMod{
    pub fn new(max: u64, m: u64) -> CombMod{
        let max: usize = max as usize;
        let mut fac: Vec<u64> = vec![0;max+1];
        let mut finv: Vec<u64> = vec![0;max+1];
        let mut inv: Vec<u64> = vec![0;max+1];

        fac[0] = 1;
        fac[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;

        for i in 2..max+1{
            fac[i] = fac[i-1] * i as u64 % m;
            inv[i] = m - inv[m as usize %i] * (m/(i as u64)) % m;
            finv[i] = finv[i-1] * inv[i] % m;
        }

        CombMod{
            fac: fac,
            finv: finv,
            inv: inv,
            mmod: m,
        }
    }

    fn get(&self, n: u64, m: u64) -> u64{
        assert!(n >= m && n != 0 && m != 0);
        self.fac[n as usize] * self.finv[m as usize] % self.mmod
            * self.finv[(n-m) as usize] % self.mmod
    }
}


fn main(){
    let line = read_as_vec::<u64>();
    let (x, y) = (line[0], line[1]);

    if (x+y)%3 != 0{
        println!("0");
        return;
    }


    let mut mov: (u64, u64) = (0, 0);
    // v = the number of move (2, 1)
    for v in 0..x+1{
        if (x - v)%2 != 0{
            continue;
        }

        let h = (x - v)/2;

        if y == (2*v + h) && x == (v + 2*h){
            mov = (h, v);
            break;
        }
    }

    if mov == (0, 0){
        println!("0");
        return;
    }
    let comb = CombMod::new(mov.0 + mov.1, 1_000_000_007);
    println!("{}", comb.get(mov.0 + mov.1, cmp::max(mov.0, mov.1)));
}


Measured memory_bytes: 22780
from sys import stdin


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    A_arr = list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = 1
    if 0 in A_arr:
        cnt = 0
    else:
        for A in A_arr:
            cnt *= A
            if cnt > 10**18:
                cnt = -1
                break
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


if __name__ == "__main__":
    main()


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

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::cmp::{min,max};
use std::collections::HashMap;
fn main() {
    input! {
        n:usize,
        an:[i64;n],
    }
    if an.iter().all(|&x| x==an[0]){
        println!("{}",n/2);
        return;
    }
    let mut odd_map = HashMap::new();
    let mut even_map = HashMap::new();
    for j in 0..n{
        if j % 2 == 0 {
            *odd_map.entry(&an[j]).or_insert(0) += 1;
        } else {
            *even_map.entry(&an[j]).or_insert(0) += 1;
        }
    }
    let mut odd:Vec<_> = odd_map.into_iter().collect();
    let mut even:Vec<_> = even_map.into_iter().collect();
    odd.sort_by_key(|x|x.1);
    even.sort_by_key(|x|x.1);
    let odd_max = odd.last().unwrap();
    let even_max = even.last().unwrap();
    let odd_2 = if odd.len() == 1 {
        0
    } else{
        odd[odd.len()-2].1
    };
    let even_2 = if even.len() == 1{
        0
    } else {
        even[even.len()-2].1
    };
    let ans = if odd_max.0 == even_max.0 {
        let a1 = n- odd_max.1- even_2;
        let a2 = n- even_max.1 -odd_2;
        min(a1,a2)
    } else{
        n-odd_max.1-even_max.1
    };
    println!("{}",ans);
}

Measured memory_bytes: 12540
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

/*-----<Defines>-----*/
#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     flush           fflush(stdout)

using ull=unsigned long long;
using ll=long long;
using ld=long double;
/*-----</Defines>-----*/

/*-----<Debugging Stuff>-----*/
string to_string(char s)
{   string res="'''";res[1]=s;return res; }

string to_string(string s)
{   return '"'+s+'"'; }

string to_string(const char* s)
{   return to_string((string)s); }

string to_string(bool b)
{   return (b?"true":"false"); }

template<typename A, typename B>
string to_string(pair<A, B> p)
{   return "("+to_string(p.F)+", "+to_string(p.S)+")"; }

template<typename A>
string to_string(A v)
{
    bool first=1; string res="{";
    for(const auto &x:v)
    {
        if(!first)  res+=", ";
        first=0;
        res+=to_string(x);
    }
    res+="}";
    return res;
}

void debug() { cout<<"\n"; }
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cout<<" "<<to_string(H);
    debug(T...);
}

#define show(...) cout << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
/*-----</Debugging Stuff>-----*/

/*-----<Mod Operations>-----*/
const int M=1e9+7;
inline int add(int a,int b,int p=M){ a=a+b; if(a>=p) a-=p; return a; }
inline int sub(int a,int b,int p=M){ a=a-b; if(a<0) a+=p; return a; }
inline int mul(int a,int b,int p=M){ a=(a*1ll*b)%p; return a; }
/*-----</Mod Operations>-----*/

/*-----<Constants>-----*/
const ld pi=acos(-1),eps=1e-9;
const ll inf=1e18;
const int N=1;
/*-----</Constants>-----*/

void solve()
{
    int l,r,d;
    cin>>l>>r>>d;

    int b=r/d,a=iceil(l,d);
    cout<<b-a+1;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




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

int main() {
	int x, y;

		

	while(1) {
		cin >> x >> y;
		if (x == 0 && y == 0)break;
		if (x>=y) {
			cout << y << " " << x << endl;
		}
		else if (x<y) {
			cout << x << " " << y << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cstring>
#define MOD (1000000000+7)

int cnt[100000];

long long int pow(long long int a, long long int b) {
    long long int res=1;
    while(b) {
        if(b%2) res*=a%MOD;
        a*=a%MOD;
        a%=MOD;
        b/=2;
        res%=MOD;
    }
    return res;
}

int main(void) {
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++) {
        int a;
        scanf("%d",&a);
        cnt[a]++;
    }
    bool ok = true;
    if(n%2==1) ok &= cnt[0] == 1;
    int i= n%2==1 ? 2 : 1;
    for(;i<n/2;i+=2)
        ok &= cnt[i] == 2;

    if(ok)
        printf("%lld\n", pow(2, n/2));
    else
        puts("0");
    return 0;
}

Measured memory_bytes: 512
//=============================================
// Author   :   NAVPUN31
// Name     :   Naveen Punjabi
//=============================================


#include <bits/stdc++.h>
using namespace std;
#define int     long long
#define ld      long double
#define pii     pair<int ,int>
#define pld     pair<ld ,ld>
#define F       first
#define S       second
#define mod     1000000007
#define pb      push_back
#define mp      make_pair
#define all(x)  x.begin(),x.end()
#define mset(x) memset(x, 0, sizeof(x));
#define ios     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


void run(){
    int a;
    cin >> a;

    string s;
    cin >> s;

    if(a >= 3200){
        cout << s << endl;
    }
    else{
        cout << "red" << endl;
    }
}


void setup(){
    ios;
    cout << setprecision(20);
}


signed main(){
    setup();
    int tests = 1;
    // cin >> tests;
    for(int i = 1; i <= tests; i++) run();
    return 0;
}

Measured memory_bytes: 256
n=int(input())
s1=input()
s2=input()

mod=1000000007
if s1[0]==s2[0]:
    anser=3
    p=1
else:
    anser=6
    p=2

while p<n:
    if s1[p]==s2[p]:
        if s1[p-1]==s2[p-1]:
            anser*=2
        p+=1
    else:
        if s1[p-1]==s2[p-1]:
            anser*=2
        else:
            anser*=3
        p+=2
    anser%=mod
print(anser)

Measured memory_bytes: 38512
// ABC155C - Poll

#include <bits/stdc++.h>
using namespace std;

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

	map<string, int> count;
	for (int i = 0; i < N; i++) {
		string S;
		cin >> S;
		count[S]++;
	}

	int maximum = 0;
	for (map<string, int>::iterator it = count.begin(); it != count.end(); it++) {
		pair<string, int> temp = *it;
		maximum = max(maximum, temp.second);
	}

	for (map<string, int>::iterator it = count.begin(); it != count.end(); it++) {
		pair<string, int> temp = *it;
		if (maximum == temp.second) {
			cout << temp.first << endl;
		}
	}
}


Measured memory_bytes: 25216
S = list(input())
S.pop(4)
S.pop(6)
S_list = []
H = [2019, 4, 30]
for i in range(len(S)):
  S[i] = int(S[i])
  
S_list.append(S[0] * 1000 + S[1] * 100 + S[2] * 10 + S[3])
S_list.append(S[4] * 10 + S[5])
S_list.append(S[6] * 10 + S[7])
  
for i in range(len(S_list)):
  if S_list[i] - H[i] > 0:
    print('TBD')
    break
  if i == len(S_list) - 1:
    print('Heisei')

Measured memory_bytes: 3064
#include <cstdio>
#include <queue>
using namespace std;
int k,cnt; 
queue<long long>q;
int main(){
	scanf("%d",&k);
	for(long long i=1;i<10;++i)q.push(i); 
	while(true){
		++cnt;
		long long cur=q.front();
		q.pop();
		if(cnt==k){
			printf("%lld\n",cur);
			break;
		}
		if(cur%10!=0)q.push(cur*10+cur%10-1);
		q.push(cur*10+cur%10);
		if(cur%10!=9)q.push(cur*10+cur%10+1);
	}
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
	for(int i = 0; i < s.size() ; i++){
		if(i == 3){
			cout << "8";
		}else{
			cout << s[i];
		}
	}
	cout << endl;
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> H(N, 0);

    for (int i = 0; i < N ; ++i)
    {
        cin >> H[i];
    }
    int preg = -999;
    for (int i = 0; i < N ; ++i)
    {
        if( preg <= H[i] - 1){
            preg = H[i] - 1;
        }else if( preg <= H[i] ){
            preg = H[i];
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstdio>
using namespace std;

int main(){

	long long a,b,k;
	cin >> a >> b;
	if(a>b){
		if((a-b)%2==1){
		cout<<"IMPOSSIBLE"<<endl;
		}else{
		k = (a-b)/2 + b;
		cout <<k << endl;
		}
	}else{
		if((b-a)%2==1){
		cout<<"IMPOSSIBLE"<<endl;
		}else{
		k = (b-a)/2 + a;
		cout<<k<<endl;
		}
	}
}

Measured memory_bytes: 256
#include <string>
#include <cstdio>
#include <algorithm>
using namespace std;
const int M=4;
int m[10][10];
char s0[M+2];
int chk(const string &s){
	int d=0;
	for(int i=0;i<4;i++)d=m[d][s[i]-'0'];
	return d;
}
bool correct(const string &s){
	return m[chk(s)][s[M]-'0']==0;
}
int main(){
	for(int i=0;i<10;i++)for(int j=0;j<10;j++)scanf("%d",m[i]+j);
	int r=0;
	for(int i=0;i<10000;i++){
		sprintf(s0,"%04d",i);
		string s=s0;
		s+=chk(s)+'0';
		r+=[&]{
			for(int i=0;i<M;i++)if(s[i]!=s[i+1]){
				swap(s[i],s[i+1]);
				if(correct(s))return true;
				swap(s[i],s[i+1]);
			}
			for(int i=0;i<=M;i++)for(char j='0';j<='9';j++)if(s[i]!=j){
				swap(s[i],j);
				if(correct(s))return true;
				swap(s[i],j);
			}
			return false;
		}();
	}
	printf("%d\n",r);
}

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

int main(){ 
  int n, t;
  cin >> n >> t;
  vector<P> food(n);
  rep(i,n) cin >> food[i].first >> food[i].second;

  vector<vector<ll>> dp(t+1,vector<ll>(2,0));
  
  for (int i = 0; i < n; i++) {
    int a = food[i].first, b = food[i].second;
    vector<vector<ll>> ndp(t+1,vector<ll>(2,0));
    for (int j = 0; j < t; j++) {
      ndp[j][0] = max(dp[j][0], ndp[j][0]);
      ndp[j][1] = max(dp[j][1], ndp[j][1]);
      ndp[j][1] = max(dp[j][0] + b, ndp[j][1]);
      if (j + a < t) {
        ndp[j + a][0] = max(ndp[j + a][0], dp[j][0] + b);
        ndp[j + a][1] = max(ndp[j + a][1], dp[j][1] + b);   
      }     
    }
    swap(dp, ndp);
  }
  cout << dp[t-1][1] << endl;
  return 0;  
} 

Measured memory_bytes: 652
#include <stdio.h>
#define MAX 101
int card[2][MAX],min[3];

void initialize(void)
{
    int i;
    for(i=0;i<MAX;i++)
    {
        card[0][i]=0;
        card[1][i]=0;
    }
    min[2]=2*(MAX-1);
    return;
}

int main(void)
{
    int n,m,N,M,num,d,compare,jud;
    int i;

    while(1)
    {
        scanf("%d %d",&n,&m);
        if(n==0 && m==0)
        {
            break;
        }
        initialize();
        N=0; M=0; jud=1;

        for(i=0;i<n;i++)
        {
            scanf("%d",&num);
            card[0][num]++;
            N+=num;
        }
        for(i=0;i<m;i++)
        {
            scanf("%d",&num);
            card[1][num]++;
            M+=num;
        }

        if((N-M)%2!=0)
        {
            printf("-1\n");
            continue;
        }
        else
        {
            d=(N>=M)?(N-M)/2:(M-N)/2;
        }

        compare=(N>=M)? 0:1;

        for(i=MAX-1;i>=0;i--)
        {
            if(i-d<0)
            {
                break;
            }
            if(card[compare][i]>0 && card[(compare+1)%2][i-d]>0)
            {
                if(min[2]>2*i-d)
                {
                    min[compare]=i;
                    min[(compare+1)%2]=i-d;
                    jud=0;
                }
            }
        }

        jud==0? printf("%d %d\n",min[0],min[1]) : printf("-1\n");
    }
    return 0;
}

Measured memory_bytes: 612
N=int(input())
A=list(map(int,input().split()))

cnt=0
bflag=False
sflag=False

for i in range(1,N):
  if A[i]>A[i-1]:
    if sflag==True:
      cnt+=1
      bflag=False
      sflag=False
    else:
      bflag=True
      sflag=False
  elif A[i]<A[i-1]:
    if bflag==True:
      cnt+=1
      bflag=False
      sflag=False
    else:  
      bflag=False
      sflag=True    
  else:
    pass
    
print(cnt+1)

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
const ll mo=1000000007;
ll dp[1010101][4];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	dp[0][0]=1;
	FOR(i,N) {
		FOR(j,4) {
			(dp[i+1][j|1]+=dp[i][j])%=mo;
			(dp[i+1][j|2]+=dp[i][j])%=mo;
			(dp[i+1][j]+=8*dp[i][j])%=mo;
		}
	}
	cout<<dp[N][3]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 34688
use std::collections::HashSet;

fn solve(s: &str) -> usize {
    let mut n = s.len();
    let s = s.chars().collect::<Vec<_>>();

    let mut h1 = HashSet::new();
    let mut v1 = Vec::new();

    for c in s.iter().rev() {
        h1.insert(c);
        v1.push(h1.len());
    }

    let v1 = v1.iter().rev().collect::<Vec<_>>();

    let mut h2 = HashSet::new();
    let mut ans = 0;
    let mut h3 = HashSet::new();

    for i in 0..(n - 2) {
        if !h3.contains(&s[i]) {
            for j in (i + 1)..(n - 1) {
                let k = (s[i], s[j]);

                if !h2.contains(&k) {
                    ans += *v1[j + 1];
                    h2.insert(k);
                }
            }
        }
        h3.insert(s[i]);
    }

    ans
}

#[test]
fn solve_test() {
    assert_eq!(solve("0224"), 3);
    assert_eq!(solve("123123"), 17);
    assert_eq!(solve("3141592653589793238"), 329);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let _n = parse_line!(usize);
    let s = read_line!();
    println!("{}", solve(&s));
}


Measured memory_bytes: 4352
#include<iostream>
#define MAXN 1000
using namespace std;
int main(){
	int x;
	cin>>x;
	int sum=0;
	if(x%2==0){
		 sum=0;
		sum=x/2*(x/2);
	}else{
		 sum=0;
		sum=x/2*(x/2+1);
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 256
module mod_union_find
  implicit none
  type union_find
    integer :: n = 0
    integer, pointer :: par(:), rnk(:), siz(:) => null()
  contains
    procedure :: init => inituf
    procedure :: release => releaseuf
    procedure :: find => find
    procedure :: same => same
    procedure :: unite => unite
    procedure :: size => size_of
  end type
  interface union_find
    module procedure :: newuf
  end interface union_find
contains
  function newuf(n) result(ret)
    integer, intent(in) :: n
    type(union_find) :: ret
    integer :: i
    ret%n = n
    allocate(ret%par(n),ret%rnk(n),ret%siz(n))
    ret%rnk = 0
    ret%siz = 1
    ret%par = [(i,i=1,n)]
  end
  subroutine inituf(this,n)
    class(union_find), intent(inout) :: this
    integer, intent(in) :: n
    integer :: i
    if (this%n /= n) then
      if (this%n /= 0) deallocate(this%par,this%rnk,this%siz)
      allocate(this%par(n),this%rnk(n),this%siz(n))
    end if
    this%n = n
    this%rnk = 0
    this%siz = 1
    this%par = [(i,i=1,n)]
  end
  subroutine releaseuf(this)
    class(union_find), intent(inout) :: this
    if (this%n /= 0) deallocate(this%par,this%rnk,this%siz)
    this%n = 0
  end
  recursive function find(this,i) result(ret)
    class(union_find), intent(inout) :: this
    integer, intent(in) :: i
    integer :: ret
    if (this%par(i) /= i) this%par(i) = find(this,this%par(i))
    ret = this%par(i)
  end
  logical function same(this,i,j)
    class(union_find), intent(inout) :: this
    integer, intent(in) :: i, j
    same = find(this,i) == find(this,j)
  end
  subroutine unite(this,i,j)
    class(union_find), intent(inout) :: this
    integer, intent(in) :: i, j
    integer :: x, y
    x = find(this,i)
    y = find(this,j)
    if (x == y) return
    if (this%rnk(x) < this%rnk(y)) then
      this%par(x) = y
      this%siz(y) = this%siz(y)+this%siz(x)
    else
      this%par(y) = x
      this%siz(x) = this%siz(x)+this%siz(y)
      if (this%rnk(x) == this%rnk(y)) this%rnk(x) = this%rnk(x)+1
    end if
  end
  integer function size_of(this,i)
    class(union_find), intent(inout) :: this
    integer, intent(in) :: i
    size_of = this%siz(find(this,i))
  end
end module mod_union_find
program shock
  use mod_union_find
  implicit none
  type(union_find) :: uf
  integer :: n, m, a, b, i
  integer(8) :: s, r
  read(*,*) n, m
  uf = union_find(n)
  do i = 1, m
    read(*,*) a, b
    call uf%unite(a,b)
  end do
  s = int(min(uf%size(1),uf%size(2)),8)
  r = int(n,8)-s
  write(*,'(i0)') s*(s-1_8)/2_8+r*(r-1_8)/2_8-int(m,8)
end program shock

Measured memory_bytes: 1792
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long MOD = 10^^9 + 7;

void main() {
    auto N = readln.chomp.to!int;
    auto P = readln.split.map!(to!real).array;

    auto dp = new real[][](N+1, N+1);
    foreach (i; 0..N+1) fill(dp[i], 0);
    dp[0][0] = 1;

    foreach (i; 0..N) {
        foreach (j; 0..N) {
            dp[i+1][j+1] += dp[i][j] * P[i];
            dp[i+1][j] += dp[i][j] * (1 - P[i]);
        }
    }

    real ans = 0;

    foreach (j; 0..N+1) {
        int k = N - j;
        if (j > k) {
            ans += dp[N][j];
        }
    }

    writefln("%.15f", ans);
}


Measured memory_bytes: 146044
import java.util.*;

public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new AOJ0054();
	}
	
	class AOJ0054{
		
		void doIt(int a,int b,int n){
			int result = 0;
			double f = (1.0*a/b)-(a/b);
			String f_a = Double.toString(f);
			int cnt = 0;
			for(int i=2;i<f_a.length();i++){
				if(cnt==n)break;
				result += Integer.parseInt(f_a.charAt(i)+"");
				cnt++;
			}
			System.out.println(result);
		}
		
		public AOJ0054() {
			while(in.hasNext())doIt(in.nextInt(), in.nextInt(), in.nextInt());
		}
	}
}

Measured memory_bytes: 20220
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define rvc(i,S) for(int i=0;i<S.size();++i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
inline int read()
{
	char c=getchar(); int ret=0;
	while(c<48||c>57)c=getchar();
	while(c>=48&&c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}
#define MO 998244353
#define N 1200003
int ans,cc,dd,vi[N],pp,dp[N],f[N],fl[N],n,m,nn,a[N],b[N],tt,q[N],qn,u,uu,H[N],h[N],p[N];
char s[N],t[N];
//,
void dfs(int p)
{
	fl[p]=tt;
	if(!f[p])return;
	int u=p+m;
	if(u>n)
	{
		u=(u-1)%n+1;
	}
	if(fl[u]==tt){
		puts("-1");exit(0);
	}
	if(fl[u]){
		dp[p]=dp[u]+1;
		return;
	}
	dfs(u);
	dp[p]=dp[u]+1;
}

int main()
{
	scanf("%s",s+1);
	scanf("%s",t+1);
	
	n=strlen(s+1); nn=1000050;
	m=strlen(t+1);
	for(int i=n+1;i<=1000050;++i)s[i]=s[i-n];
	
	for(int i=1;i<=m;++i)a[i]=t[i]-96;
	for(int i=1;i<=nn;++i)b[i]=s[i]-96;
	
	H[0]=1;for(int i=1;i<=1010000;++i)H[i]=(long long)H[i-1]*37%MO;
	for(int i=1;i<=nn;++i){
		h[i]=((long long)h[i-1]*37+b[i])%MO;
	} 
	for(int i=1;i<=m;++i){
		p[i]=((long long)p[i-1]*37+a[i])%MO;
	}
	pp=p[m];
	for(int i=1;i<=n;++i)if(!vi[i]){
		q[qn=1]=i; vi[i]=1;
		for(int q1=1;q1<=qn;++q1){
			u=q[q1];
			cc=(h[u+m-1]-(long long)h[u-1]*H[m]%MO+MO)%MO;
//			cerr<<cc<<' '<<dd<<' '<<u<<endl;
			//erweihash //erweishudian //two poin
			if(cc!=pp)continue;
			f[u]=1;
			uu=u+m;
			if(uu>n){
				uu=(uu-1)%n+1;
			}
			if(!vi[uu]){
				q[++qn]=uu;
				vi[uu]=1;
			}
		}
	}
	//p
	for(int i=1;i<=n;++i){
		++tt;
//		u=i-m;if(u<1)u+=n;
		if(!fl[i])dfs(i);
	}
	for(int i=1;i<=n;++i)ans=max(ans,dp[i]);
	cout<<ans;
}  //two ha  //struct  hash  //_

Measured memory_bytes: 54144
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e9;
int num[1010];
int main()
{
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k%2) cout<<(b-a)<<endl;
    else cout<<(a-b)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

typedef long long ll;
inline int Get() {
	char ch;
	while ((ch = getchar()) < '0' || ch > '9');
	int Num = ch - '0';
	while ((ch = getchar()) >= '0' && ch <= '9')
		Num = (Num << 3) + (Num << 1) + ch - '0';
	return Num;
}
const int Mod = 1e9 + 7;
const int N = 1e5 + 5;
int n, m, ans, v[N], g[N], sze;
inline int pow(int x, int k) {
	ll res = 1, r = x % Mod;
	for (; k; k >>= 1, r = r * r % Mod) 
		if (k & 1) res = res * r % Mod;
	return res;
}
int main() {
	n = Get(), m = Get();
	for (int i = 1; (ll)i * i <= n; ++i)
		if (!(n % i)) {
			v[sze++] = i;
			if (n / i != i) v[sze++] = n / i;
		}
	
	std :: sort(v, v + sze);
	for (int i = 0, x; i < sze; ++i) {
		x = v[i], g[i] = pow(m, x + (x & 1) >> 1);
		for (int j = 0; j < i; ++j)
			if (!(x % v[j])) g[i] = (g[i] - g[j] + Mod) % Mod;
	} 
	
	for (int i = 0, x; i < sze; ++i)
		x = v[i], (ans += (ll)((x & 1) ? x : x >> 1) * g[i] % Mod) %= Mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128