akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

const int M = 1e9+7;

int mul(int a, int b){
    return 1LL*a*b%M;
}

int add(int a, int b){
    return (a%M+b%M)%M;
}

int sub(int a, int b){
    return ((a%M - b%M)+M)%M;
}

int pow(int a, int b){
    int res = 1;
    while(b>0){
        if(b&1) res = mul(res,a);
        a = mul(a,a);
        b/=2;
    }
    return res%M;
}

int main(){
    int n,k;
    cin>>n>>k;

    int res = 0;
    int arr[k+1];
    for(int i = k; i >= 1; i--){
           int t = pow(k/i, n); 
           for(int j = i*2; j<=k; j+=i) t = sub(t,arr[j]);
           res = add(res,mul(t,i));
           arr[i] = t;
    }
    cout<<res;
}


Measured memory_bytes: 3908
#pragma 03
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
using namespace std;
#define int long long
#define eb emplace_back
#define ef emplace_front
#define pb push_back
#define rep(i, x, n) for (int i = x; i < n; ++i)
#define mp make_pair
#define fi first
#define se second
#define ii pair<int, int>
#define endl '\n'
#define vi vector<int>
#define vii vector<pair<int, int>>
#define reverse(s) reverse(s.begin(), s.end())
#define ld long double
#define vs vector<string>
#define inf INT_MAX
#define vc vector<char>
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define vb vector<bool>
#define lb(a, x) lower_bound(a.begin(), a.end(), x)
#define ub(a, x) upper_bound(a.begin(), a.end(), x) 
#define vvi vector<vi>
#define mine(a) min_element(a.begin(),a.end())
#define maxe(a) max_element(a.begin(), a.end())
#define iota(a,i) iota(a.begin(),a.end(),i)
int findXOR(int n)
{
    int mod = n % 4;
    if (mod == 0)
        return n;
    else if (mod == 1)
        return 1;
    else if (mod == 2)
        return n + 1;
    else if (mod == 3)
        return 0;
}
int findXOR(int l, int r){
    return (findXOR(l - 1) ^ findXOR(r));
}
signed main() {
    fastio;
    int a, b;
    cin >> a >> b;
    if (a == b) {
        cout << a;
        return 0;
    }
    a = max(a, (int)1);
    cout << findXOR(a, b);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    int a[105];
    double  sum=0;
    cin>>n>>m;
    for(int i=0;i<n;i++){
      cin>>a[i];
      sum+=a[i];
    }
    sort(a,a+n);
    for(int i=0;i<m;i++){
      if(a[n-1-i]<sum/(4*m)){
        cout<<"No"<<endl;
        return(0);
      }
    }
    cout<<"Yes"<<endl;
      return(0);
}

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



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

   
  	int n;
  	cin>>n;
  	set<int>s;
  	for(int i =0 ;i<n;i++)
  	{
  		int x;
  		cin>>x;
  		s.insert(x);
  	}
  	if(s.size()==n)
  		cout<<"YES\n";
  	else
  		cout<<"NO\n";

	
    return 0;
		
}

Measured memory_bytes: 13048
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int curH = h[n-1];
    for(int i = n-2; i >= 0; i--){
        if(h[i] > curH+1){
            cout << "No" << endl;
            return 0;
        }
        else if (h[i] != curH+1){
            curH = h[i];
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3760
H, W, N = map( int, input().split())
V = [H-1]*W
X = [ tuple( map( int, input().split())) for _ in range(N)]
X.sort()
d = 0
for i in range(N):
    x, y = X[i]
    x, y = x-1, y-1
    if x == y+d:
        d += 1
    elif x > y+d:
        V[y] = min( V[y], x-1)
print( min(V)+1)

Measured memory_bytes: 32504
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))
P before[3240][3240];
Int dp[3240][3240];
string s, t;
int main(){
  cin >> s >> t;
  for(int i = 1;i <= s.size();i++){
    for(int j = 1;j <= t.size();j++){
      dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      if(s[i-1] == t[j-1]){
	dp[i][j] = max(dp[i-1][j-1] + 1, dp[i][j]);
      }
      if(dp[i][j] == dp[i-1][j-1] + 1)before[i][j] = P(i-1,j-1);
      if(dp[i][j] == dp[i-1][j])before[i][j] = P(i-1,j);
      if(dp[i][j] == dp[i][j-1])before[i][j] = P(i,j-1);
    }
  }

  string ans;
  Int a = s.size(), b = t.size();
  while(a > 0 && b > 0){
    P bef = before[a][b];
    if(bef.first != a && bef.second != b)ans = s[a-1] + ans;
    a = bef.first;
    b = bef.second;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 231680
import fractions
from functools import reduce

n = int(input())
a = list(map(int,input().split()))

left = [0] * (n+1)
right = [0] * (n+1)

for i in range(n):
    left[i+1] = (fractions.gcd(left[i],a[i]))
    right[n-i-1] = (fractions.gcd(right[n-i],a[n-i-1]))

ans = 0
for i in range(n):
    ans = max(ans,fractions.gcd(left[i],right[i+1]))
print(ans)

Measured memory_bytes: 16144
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

alias sread = () => readln.chomp();

void main()
{
    auto s = sread();
    if (s == "1")
    {
        writeln("Hello World");
    }
    else
    {
        writeln(lread + lread);
    }
}


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

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

const int MOD = 1e+9 + 7;

template <typename T>
T pow_mod( T n, T p )  // n^p % m
{
    if( p == 0 ) return 1;
    if( p%2 == 1 ) return pow_mod(n, p-1) * n % MOD;
    else{
        T tmp = pow_mod(n, p/2) % MOD;
        return tmp*tmp % MOD;
    }
}

template <typename T>
T nCk_mod( T n, T k )
{
    if( n < 0 or k < 0 || n < k ) return 0;
    T numerator = 1, denominator = 1;
    for( int i = 1; i <= min(k, n-k); ++i ){
        numerator = numerator*(n-i+1) % MOD;
        denominator = denominator*i %MOD;
    }
    return numerator * pow_mod<T>(denominator, MOD-2) % MOD;
}

int main()
{
    int X, Y;
    cin >> X >> Y;

    long long ans = 0;
    if((2*X-Y)%3 == 0 and (2*Y-X)%3 == 0){
        long long n = (2*Y-X)/3 % MOD;
        long long m = (2*X-Y)/3 % MOD;
        ans = nCk_mod<long long>(n+m, min(n, m));
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws IOException {

		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		//????????????????????\???
		String first_lines = input.readLine();

		//??????????????????????????????????????????????????????????????????????????§?????????
		Dice_two insdice = new Dice_two(first_lines.split(" "));

		//????????°??\???
		String second_lines = input.readLine();

		int instruction_num=Integer.parseInt(second_lines);


	    	for(int instruction_spot=0; instruction_spot<instruction_num; instruction_spot++){

	    	String third_lines=input.readLine();

	    	String []array_num=third_lines.split(" ");

	    	int input_top=Integer.parseInt(array_num[0]);

	    	int input_front=Integer.parseInt(array_num[1]);


	    	insdice.dice_roll(input_top,input_front);

	    	System.out.println(insdice.get_right());



	    	}



	}
}

class Dice_two {

	int[] array_dice = new int[6];

	int top = 0;

	int bottom = 0;

	int front = 0;

	int back = 0;

	int right = 0;

	int left = 0;

	int num;

	int num_front;

	int right_answer;


	// ????????????????????????????????£????????????????????\????????????????????§???????????§?????????
	Dice_two(String[] strings) {

			this.top=Integer.parseInt(strings[0]);

			this.front=Integer.parseInt(strings[1]);

			this.right=Integer.parseInt(strings[2]);

			this.left=Integer.parseInt(strings[3]);

			this.back=Integer.parseInt(strings[4]);

			this.bottom=Integer.parseInt(strings[5]);

	}



	//1?????????????????°??¨????????????????????????????????¶???????????????
	void dice_roll(int top_side,int front_side ){


		for(int East_roll=0; East_roll<2; East_roll++){

			for(int South_roll=0; South_roll<4; South_roll++){

				for(int horizontal_roll=0; horizontal_roll<4; horizontal_roll++){

					num=front;

					front=right;

					right=back;

					back=left;

					left=num;

					if(top==top_side&&front==front_side){

						right_answer=right;

					}
				}

				  num=top;

	    		  top=back;

	    		  back=bottom;

	    		  bottom=front;

	    		  front=num;
			}

			 num=top;

   		  top=left;

   		  left=bottom;

   		  bottom=right;

   		  right=num;

		}
	}




	int get_right(){

		return right_answer;

	}
}

Measured memory_bytes: 24160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    
    double prob[N + 1];
    double dp[N + 1][N + 1], res = 0;
    
    for(int i = 1; i <= N; ++i)
        cin>>prob[i];
        
    for(int i = 0; i <= N; ++i) {
        for(int j = 0; j <= N; ++j)
            dp[i][j] = 0;
    }    
    
    // first set up the answer for getting 0 heads, for getting 0 heads using 
    // first i coins, it is simply the product of (1 - p1) * (1 - p2) * .. * (1 - pi)
    dp[1][0] = 1.0 - prob[1];
    for(int i = 2; i <= N; ++i)
        dp[i][0] = dp[i - 1][0] * (1.0 - prob[i]);
        
    // next the proability of getting x heads using x coins is simply the product
    // of all pi(s) till here
    dp[1][1] = prob[1];
    for(int i = 2; i <= N; ++i)
        dp[i][i] = dp[i - 1][i - 1] * prob[i];
        
    // now solve for any general dp[i][j], i.e. probability of getting j heads 
    // using the first i coins only. For this, at each index i and some heads j,
    // we can either select a head for the coin at this index or select a tail
    // so, the total result will be -
    // probability of selecting head from this coin * probability of getting j - 1
    // heads from all the previous coins + probability of selecting a tail here
    // * probability of getting j heads from all the previous coins
    
    // note - as getting heads j from first i coins when j > i is impossible, so,
    // we set this probability to 0. Also, since we also computed answers for i == j
    // so, we do not compute it back again
    for(int i = 1; i <= N; ++i) {
        for(int j = 1; j < i; ++j)
            dp[i][j] = dp[i - 1][j] * (1.0 - prob[i]) + dp[i - 1][j - 1] * prob[i];
    }
    
    // now add to res the probability of any heads > N/2 using all the coins
    for(int i = N / 2 + 1; i <= N; ++i)
        res += dp[N][i];
    
    // print answer to the 10th precision
    cout << fixed << setprecision(10) << res;
    
  return 0;
}

Measured memory_bytes: 70528
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <bitset>
#include <algorithm>

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

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

vector<pair<long long, long long>> prime_factorize(long long n) {
    // =====================
    // condition
    // ---------------------
    // n > 0
    // =====================
    vector<pair<long long, long long>> res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        long long exp = 0;
        while (n % p == 0) {
            ++exp;
            n /= p;
        }
        res.push_back({n, exp});
    }
    if (n != 1) res.push_back({n, 1});
    return res;
}

int main() {
    ll n;
    cin >> n;

    int ans = 0;
    vector<pair<long long, long long>> pf = prime_factorize(n);
    for (PLL pe : pf) {
        ll exp = pe.second;
        for (int i = 1; i*i <= 2*exp; ++i) {
            if (i*(i+1) <= 2*exp && 2*exp < (i+1)*(i+2)) {
                ans += i;
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
  int a, b, m;
  cin >> a >> b >> m;
  vector<int> cost_a(a), cost_b(b);
  for (int i = 0; i < a; i++) cin >> cost_a.at(i);
  for (int i = 0; i < b; i++) cin >> cost_b.at(i);
  int ans = *min_element(cost_a.begin(), cost_a.end())
    + *min_element(cost_b.begin(), cost_b.end());
  for (int i = 0; i < m; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    x--; y--;
    int n = cost_a.at(x) + cost_b.at(y) - c;
    ans = min(ans, n);
  }
  cout << ans << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main()
{
    string s;
    cin >> s;

    int a = 0, b = 0;
    rep(i, s.size()){
        if(s[i] == 'A') a++;
        if(s[i] == 'B') b++;
    }

    if(a >= 1 && b >= 1) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define rall(c) c.rbegin(), c.rend()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
#define init(a, x) memset(a,x,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=1e6+7;
map<ll,ll> counter;

ll a[L];
ll fastexpo(ll x,ll y,ll m)
{
	ll temp=1;
	while(y>0)
	{
		if(y&1)temp = ((temp%m)*(x%m))%m;
		x = ((x%m)*(x%m))%m;
		y>>=1;
	}return temp;
}
void fff()
{
	ll n, m, sumis = 0;
	cin >> n >> m;
	FOR(i,1,n+1)
	{
		cin >> a[i];
		sumis += a[i];
	}
	int co = 0;
	FOR(i,1,n+1)
	{
		if(a[i]*4*m >= sumis)co++;
	}
	if(co >=m)cout<<"Yes\n";
	else cout<<"No\n";

}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//int t;cin >> t;while(t--)
	fff();
	return 0;
}

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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

long long stint(string str) {
	long long ret;
	stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

void solve() {
	int w, a, b;
	cin >> w >> a >> b;
	if (a <= b) {
		if (a + w >= b) {
			P(0);
		}
		else {
			P(abs(a + w - b));
		}
	}
	else {
		if (b + w >= a) {
			P(0);
		}
		else {
			P(a - b - w);
		}
	}
}

int main() {
	solve();
	return 0;
}


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

unsigned GetDigit(unsigned num)
{
  unsigned digit = 0;
  while (num != 0)
  {
    num /= 10;
    digit++;
  }
  return digit;
}

bool is_include_num(vector<int> num_list, int num)
{
  while (num != 0)
  {
    int a = num % 10;
    rep(i, num_list.size())
    {
      if (num_list[i] == a)
        return true;
    }

    num /= 10;
  }
  return false;
}

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> dislike_num;

  rep(i, K)
  {
    int D;
    cin >> D;
    dislike_num.push_back(D);
  }
  int digit = GetDigit(N);

  for (int price = N;; price++)
  {
    if (!is_include_num(dislike_num, price))
    {
      cout << price << endl;
      return 0;
    }
  }
}

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

using namespace std;

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

    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> ab(N);
    for (int i = 0; i < N; ++i) {
        cin >> ab[i].first >> ab[i].second;
    }
    // sort by reward B, but do task as late as possible
    sort(begin(ab), end(ab), [](const auto &lhs, const auto &rhs) {
        return lhs.second > rhs.second 
                || (lhs.second == rhs.second && lhs.first < rhs.first);
    });
    int res = 0;
    set<int> avail;
    for (int i = 0; i < M; ++i) {
        avail.insert(i);
    }
    for (const auto p : ab) {
        int last_day = M - p.first;
        auto it = avail.upper_bound(last_day);
        if (it != begin(avail)) {
            --it;
            avail.erase(it);
            res += p.second;
        }
    }
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 5760
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main(void) {
	ll n, k, ans = 0;
	cin >> n >> k;
	rep(i, 1, n + 1) {
		ans += max(i - k, 0ll) * (n / i) + max(n % i - k + 1, 0ll);
		if (k == 0)ans--;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    char in[201], tmp[201];
    int m, n, i, j;
    while (1) {
        scanf("%200s ", in);
        if (in[0] == '-')
            break;
        scanf("%d ", &m);
        while (m--) {
            scanf("%d ", &n);
            for (i = 0; in[i+n] != '\0'; i++) {
                tmp[i] = in[i+n];
            }
            for (j = 0; j < n; j++) {
                tmp[i+j] = in[j];
            }
            tmp[i+j] = '\0';
            for (i = 0; tmp[i] != '\0'; i++) {
                in[i] = tmp[i];
            }
        }
        puts(in);
    }
    return 0;
}


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

cumsum = [a[0]]
for i in range(1, n):
    cumsum.append(cumsum[i-1]+a[i])

i, k = 0, 2
ans = 10**18
for j in range(1, n-2):
    while True:
        p = cumsum[i]
        q = cumsum[j] - cumsum[i]
        p_new = cumsum[i+1]
        q_new = cumsum[j] - cumsum[i+1]
        if abs(p_new-q_new) < abs(p-q):
            i += 1
        else:
            break

    while True:
        r = cumsum[k] - cumsum[j]
        s = cumsum[-1] - cumsum[k]
        r_new = cumsum[k+1] - cumsum[j]
        s_new = cumsum[-1] - cumsum[k+1]
        if abs(r_new-s_new) < abs(r-s):
            k += 1
        else:
            break

    ans = min(ans, max([p, q, r, s]) - min([p, q, r, s]))
    # print(ans, ':', i, j, k, ':', p, q, r, s)
print(ans)


Measured memory_bytes: 25804
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef double DB;
const int MAXN = 100005;

int n, a[MAXN], b[MAXN], c[MAXN], ord[MAXN], actual[MAXN], bit[MAXN];
DB val[MAXN]; LL N;

inline bool cmp(const int &x, const int &y){
	return val[x] < val[y];
}
inline void update(int p){
	for(; p <= n; p += p & -p)
		++ bit[p];
}
inline int query(int p){
	int ret = 0;
	for(; p; p -= p & -p)
		ret += bit[p];
	return ret;
}
int main(){
	int i, T; DB l, r, mid, curPos; LL inv;
	scanf("%d", &n);
	N = n * LL(n - 1) / 2;
	for(i = 1; i <= n; ++ i)
		scanf("%d%d%d", &a[i], &b[i], &c[i]);

	curPos = -1e9;
	for(i = 1; i <= n; ++ i){
		ord[i] = i;
		val[i] = (- a[i] * curPos + c[i]) / b[i];
	} sort(ord + 1, ord + 1 + n, cmp);
	for(i = 1; i <= n; ++ i)
		actual[ord[i]] = i;
	l = -1e9, r = 1e9;
	for(T = 1; T <= 60; ++ T){
		curPos = mid = (l + r) / 2.0;
		for(i = 1; i <= n; ++ i){
			ord[i] = i;
			val[i] = (- a[i] * curPos + c[i]) / b[i];
		} sort(ord + 1, ord + 1 + n, cmp);
		for(i = 1; i <= n; ++ i)
			ord[i] = actual[ord[i]];
		memset(bit, 0, sizeof(bit));
		for(i = 1, inv = 0; i <= n; ++ i){
			inv += (i - 1) - query(ord[i]);
			update(ord[i]);
		}
		if(inv >= ((N + 1) >> 1))
			r = mid;
		else l = mid;
	} printf("%.15lf ", double((l + r) / 2.0));

	curPos = -1e9;
	for(i = 1; i <= n; ++ i){
		ord[i] = i;
		val[i] = (- b[i] * curPos + c[i]) / a[i];
	} sort(ord + 1, ord + 1 + n, cmp);
	for(i = 1; i <= n; ++ i)
		actual[ord[i]] = i;
	l = -1e9, r = 1e9;
	for(T = 1; T <= 60; ++ T){
		curPos = mid = (l + r) / 2.0;
		for(i = 1; i <= n; ++ i){
			ord[i] = i;
			val[i] = (- b[i] * curPos + c[i]) / a[i];
		} sort(ord + 1, ord + 1 + n, cmp);
		for(i = 1; i <= n; ++ i)
			ord[i] = actual[ord[i]];
		memset(bit, 0, sizeof(bit));
		for(i = 1, inv = 0; i <= n; ++ i){
			inv += (i - 1) - query(ord[i]);
			update(ord[i]);
		}
		if(inv >= ((N + 1) >> 1))
			r = mid;
		else l = mid;
	} printf("%.15lf\n", double((l + r) / 2.0));
	return 0;
}

Measured memory_bytes: 2048
using System;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		int a = int.Parse(Console.ReadLine());
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
		int b = int.Parse(input[0]);
		int c = int.Parse(input[1]);
      
      int i=0;
      bool d = false;
      
      while(a*i <= c){
        if(a*i >= b && a*i <= c){
          d = true;
          break;
        }
        i++;
      }
		//出力
      	if(d){
        	Console.WriteLine("OK");
      	}
      	else{
        	Console.WriteLine("NG");
      	}
	}
}

Measured memory_bytes: 27476
#include "bits/stdc++.h"
using namespace std;
int main(void){
	char s[10];
	int i,cnt=0;
	cin >> s;
	for(i=0; i<3; i++){
		if(s[i]=='1'){
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

using namespace std;

int N, L;


int main(void) {

	cin >> N >> L;

	int I = 0;
	int min_num = 9999;

	int sum = 0;

	for (int i = 1; i <= N; i++) {
		int tmp = L + i - 1;
		sum += tmp;
	}

	int ans = 0;
	int val = 99999;

	for (int i = 1; i <= N; i++) {
		int tmp = L + i - 1;
		if (abs(sum - (sum - tmp)) < val) {
			val = abs(sum - (sum - tmp));
			ans = sum - tmp;
		}
		
	}

	

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,k,h[100005],f[100005];
void u(int &x,int y){
    if(y<x)x=y;
}
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;++i)scanf("%d",h+i);
    for(int i=2;i<=n;++i){
        f[i]=f[i-1]+abs(h[i]-h[i-1]);
        for(int j=2;j<=k;++j){
            if(j>=i) break;
            u(f[i],f[i-j]+abs(h[i]-h[i-j]));
        }
    }
    printf("%d\n",f[n]);
	//system("pause");
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vi vector<int>
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pi 3.14159265359


ll gcd(ll a, ll b)
{
	ll c;
	while (a != 0) {
		c = a; a = b % a;  b = c;
	}
	return b;
}

int main() {
	ll N, M, X, Y;
	ll x[200];
	ll y[200];
	cin >> N >> M >> X >> Y;
	REP(i, N) {
		cin >> x[i];
	}
	REP(i, M) {
		cin >> y[i];
	}
	x[N] = X;
	y[M] = Y;
	sort(x, x + N + 1);
	sort(y, y + M + 1);
	if (x[N] >= y[0]) {
		cout << "War";
	}
	else cout << "No War";

	return 0;



}

Measured memory_bytes: 256
from collections import deque
import copy
H, W = map(int, input().split())
A = tuple(tuple(input()) for _ in range(H))
L=[[0]*W for _ in range(H)]
next_q=deque()

for i in range(H):
    for j in range(W):
        if A[i][j]=='#':
            L[i][j]=1
            next_q.append((i,j))

q=deque()

res = 0
while len(next_q) != 0:
    q=copy.copy(next_q)
    next_q.clear()
    while q:
        y, x = q.popleft()
        if y > 0 and L[y - 1][x] == 0:
            L[y - 1][x] = 1
            next_q.append((y - 1, x))
        if y < H - 1 and L[y + 1][x] == 0:
            L[y + 1][x] = 1
            next_q.append((y + 1, x))
        if x > 0 and L[y][x - 1] == 0:
            L[y][x - 1] = 1
            next_q.append((y, x - 1))
        if x < W - 1 and L[y][x + 1] == 0:
            L[y][x + 1] = 1
            next_q.append((y, x + 1))
    if len(next_q)==0: break
    res += 1
print(res)


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

typedef   long long  int ll;
typedef  long double ld;
typedef std::vector<ll> vi;
typedef std::vector<std::vector<ll> > vv;

#define MOD 998244353
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,b) for(i=a;i<b;i++)
#define mp make_pair
#define pb(x) push_back(x)
#define fi first
#define se second
#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" ";cout<<"\n";
#define all(a) a.begin(),a.end()
#define input(vec,a,b) for(ll i = a;i<b;i++) cin>>vec[i];
#define ms(a,val) memset(a,val,sizeof(a))
using namespace std;

const int N = 1e5 + 5;


void solve(){
            ll i,j,n,x,m,k;
            cin>>n>>k;
            vector<pair<ll,ll> > edge;
            fo(i,0,k)
             {
                 ll a,b;
                 cin>>a>>b;
                 edge.pb(mp(a,b));

             }
             ll dp[n+1]={0},pre[n+1]={0};
             dp[1] = 1;
             pre[1] = 1;
            fo(i,2,n+1)
             {

                 for(auto it : edge)
                 {
                     if(i - it.fi>=1)

                     {
                         dp[i] = (dp[i] + (pre[i - it.fi]%MOD- pre[max(0LL,i - it.se-1)]%MOD + MOD)%MOD)%MOD;;
                     }

                 }
                 pre[i] = (pre[i-1] + dp[i])%MOD;
             }
             cout<<dp[n]<<endl;






}

int main()
{

      ll t=1,i;
      //cin>>t;

            while(t--)
      {

          solve();
      }
    return 0;
}


Measured memory_bytes: 6728
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
#define INF 1000000000

class Node{//普通の木用のデータ
//ノードはポインタでもっておこう
public:
  ///ノードの番号
  int num;
  //そのノードの親
  //Node* p;(親の情報が必要ない)
  //そのノードの子(ここ、vectorで管理してる場合はintの方が扱いやすい)
  vector<int> v;
  //探索済みかどうか
  bool visit=false;
};

void breadth_search(queue<int> vs,vector<Node>& vn,vector<int>& vd){
  int d=0;//vsにすでに格納しているものは距離が決定している前提
  int l=vs.size();
  while(l!=0){
    d++;
    l=vs.size();
    for(int i=0;i<l;i++){
      int x=vs.front();
      int l_sub=vn[x].v.size();
      for(int j=0;j<l_sub;j++){
        if(vn[vn[x].v[j]].visit==false){
          vs.push(vn[x].v[j]);
          vn[vn[x].v[j]].visit=true;
          vd[vn[x].v[j]]=d;
        }
      }
      vs.pop();
    }
  }
}


int main(){
  int n;cin >> n;
  vector<Node> vn(n);for(int i=0;i<n;i++){vn[i].num=i;}
  vector<int> vd(n,-1);//深さを保存(辿れないと-1)
  queue<int> vs;//今見ているNodeのnumを入れておく

  for(int i=0;i<n;i++){
    int k;cin >> k >> k;
    for(int j=0;j<k;j++){
      int l;cin >>l;l-=1;
      //vn[l].p=&vn[i];
      vn[i].v.push_back(l);
    }
  }

  vn[0].visit=true;
  vd[0]=0;
  vs.push(0);
  breadth_search(vs,vn,vd);
  for(int i=0;i<n;i++){
    cout << i+1 << " " << vd[i] << endl;
  }



}



Measured memory_bytes: 3156
//agc023_a.cpp
//Sat Nov 10 15:50:22 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll a[n+1];
	ll total = 0;
	for (int i=0;i<n;i++){
		ll temp; 
		cin >> temp;
		total += temp;
		a[i] = total;
	}
	a[n] = 0;

	sort(a,a+n+1);

	ll temp = 1;
	ll ans = 0;
	for (int i=1;i<n+1;i++){
		if(a[i]==a[i-1]){
			temp++;
		}else{
			ans += temp*(temp-1)/2;
			temp = 1;
		}
	}
	ans += temp*(temp-1)/2;
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
vector<int> product(const vector<int> &A, const vector<int> &B) {
  const int n = A.size();
  vector<int> res(n);
  REP(i,n) {
    res[i] = B[A[i]];
  }
  return res;
}
vector<int> power(vector<int> x, int y) {
  int n = x.size();
  vector<int> res(n);
  REP(i,n) res[i] = i;
  for (; y > 0; y >>= 1, x = product(x, x)) {
    if (y & 1) res = product(res, x);
  }
  return res;
}
signed main() {
  int N, K; cin >> N >> K;
  vector<int> A(N);
  REP(i,N) {
    cin >> A[i];
    A[i]--;
  }
  vector<int> B = power(A, K);
  cout << B[0] + 1 << endl;
}


Measured memory_bytes: 9220
/*|In The Name Of Allah|*/
//This Month Will Be Expert ISA
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

const int mod = 1e9+7;

int n;
long long k;
int a[N];
int f[N];

int main(){
    scanf("%d%lld" , &n , &k);
    for(int i = 1; i <= n; i++){
        scanf("%d" , &a[i]);
    }
    for(int i = 1; i <= n; i++){
        scanf("%d" , &f[i]);
    }
    sort(a + 1 , a + n + 1);
    sort(f + 1 , f + n + 1);
    reverse(f + 1 , f + n + 1);
    long long l = 0 , r = 1e12;
    while(l < r){
        long long mid = (l + r) / 2;
        long long cntUSED = 0;
        for(int i = 1; i <= n; i++){
            cntUSED += max(0ll , a[i] - mid / f[i]);
        }
        if(cntUSED <= k){
            r = mid;
        } else {
            l = mid + 1;
        }
    }
    printf("%lld\n" , r);
}


Measured memory_bytes: 1792
S = input()
L = set([x for x in S])

ans = 101
for t in L:
    N = S
    T = ""
    c = 0
    while len(set([x for x in N])) > 1:
        c += 1
        for k in range(len(N)-1):
            if N[k] == t or N[k+1] == t:
                T += t
            else:
                T += S[k]
        N = T
        T = ""
    ans = min(ans,c)

print(ans)

Measured memory_bytes: 3064
A, B, C, D, E, F = map(int, input().split())

w = []
for i in range(F // (100 * A) + 1):
    for j in range(F // (100 * B) + 1):
        a = (A * i + B * j) * 100
        if a < F:
            w.append(a)

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for i in range((F - a) // C + 1):
        for j in range((F - a) // D + 1):
            b = C * i + D * j
            if a + b > F:
                continue
            if b > E * a // 100:
                continue
            if a + b == 0:
                continue
            concentration = 100 * b / (a + b)
            if concentration > best_concentration:
                best_concentration = concentration
                best_a = a
                best_b = b
print(best_a + best_b, best_b)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define pi pair<int, int>
#define l first
#define r second
#define all(x) x.begin(), x.end()
#define int long long

const int maxn = 5e5 + 1;

using namespace std;

int n;
string s;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    cout << (a - b) * (k % 2 ? -1 : 1) << '\n';
    return 0;
}


Measured memory_bytes: 3572
MOD = 998244353
N = gets.to_i
robots = Array.new N 
N.times do |i|
  robots[i] = gets.split.map(&:to_i)
end
robots.sort_by!{|x| x[0] }
notouched = Array.new N

class MaxSegmentTree
  def initialize n, init
    @n = n 
    @init = init
    @offset = 2 ** (Math.log2(n).to_i + 1)
    @tree = Array.new(2*@offset, @init )
  end

  def update pos, val
    pos += @offset
    @tree[pos] = val
    while pos > 1
      pos = pos / 2
      @tree[pos] = max(@tree[2*pos], @tree[2*pos+1])
      break if @tree[pos] > val
    end
  end

  def query l,r 
    l += @offset
    r += @offset
    ret = @init
    while l<=r && ret != N
      ret = max(ret, max(@tree[r], @tree[l]))
      r = (r-1) / 2
      l = (l+1) / 2
    end
    return ret
  end
end

def max a, b 
  a > b ? a : b
end

segtree = MaxSegmentTree.new(N, 0)
dp = Array.new(N + 1)
dp[N] = 1
N.times do |i|
  x = N - 1 - i
  d = robots[x][0] + robots[x][1]
  l = x
  r = N
  unless robots[N-1][0] < d
    while l + 1 < r do
      c = ( l + r ) / 2
      if robots[c][0] >= d
        r = c
      else
        l = c
      end
    end
  end
  ro = r
  if ro  != N
    xro = segtree.query(x+1,ro-1)
    ro = xro if xro > ro
    notouched[x] = ro
    dp[x] = ( dp[x+1] + dp[notouched[x]] ) % MOD
  else
    dp[x] = ( dp[x+1] + 1 )
  end
  segtree.update(x, ro)
end

puts dp[0] % MOD

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

using namespace std;

#define INF 210000000
#define int long long

int gcd(int a, int b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

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

signed main() {
		int a,b;
		cin >> a >> b;
		if(a == 1 && b == 1) cout << "Draw" << endl;
		else if(a == 1) cout << "Alice" << endl;
		else if(b == 1) cout << "Bob" << endl;
		else if(a > b) cout << "Alice" << endl;
		else if(b > a) cout << "Bob" <<endl;
		else if(a == b) cout << "Draw" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
  float d, t, s, tin;
  cin >> d >> t >> s;
  tin = d / s;
  if(t >= tin)printf("Yes\n");
  else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 3680
n, m = map(int, input().split())

ans = [''] * m

cities = []
for i in range(m):
    p, y = map(int, input().split())
    cities.append((p, y, i))

sc = sorted(cities, key=lambda x: x[1])
cities_sorted = sorted(sc, key=lambda x: x[0])


lc = 0
pref_count = 0
city_count = 0
for i in range(m):
    c = cities_sorted[i]

    if c[0] != lc:
        lc = c[0]
        pref_count += 1
        city_count = 0

    city_count += 1

    ans[c[2]] = str(c[0]).zfill(6) + str(city_count).zfill(6)

for i in range(m):
    print(ans[i])


Measured memory_bytes: 31212
a=input()
d=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
c=0
t=len(a)
if a[0]=="A":
    p=a[2:-1]
    if "C" in p:
        k=a[1:]
        t-=1
        q=0
        for i in range(t):
            if k[i]in d:
                q+=1
        if t-1==q:
            c=1
print("WA"if c!=1else"AC")

Measured memory_bytes: 3064
using System;
using System.IO;
using System.Collections.Generic;

namespace ARC091
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var H = ss.Next(Long);
            var W = ss.Next(Long);

            if (H == 1 && W == 1)
            {
                sw.WriteLine(1);
                return;
            }

            if (H == 1)
            {
                sw.WriteLine(W - 2);
                return;
            }

            if (W == 1)
            {
                sw.WriteLine(H - 2);
                return;
            }

            sw.WriteLine((H - 2) * (W - 2));
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
        static readonly Func<string, int> Int = int.Parse;
        static readonly Func<string, long> Long = long.Parse;
        static readonly Func<string, double> Double = double.Parse;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  string r="yuiophjklnm",l="qwertasdfgzxcvb";
  while(1){
    int c=0;
    cin>>s;
    if(s[0]=='#')break;
    bool f=0;
    for(int i=0;i<r.size();i++)if(s[0]==r[i])f=1;
    for(int i=1;i<s.size();i++){
      int f1=0;
      for(int j=0;j<r.size();j++)if(s[i]==r[j])f1=1;
      if(f!=f1)c++,f=f1;
    }
    cout<<c<<endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
    int n,A[100],B[101],sum=0;
    cin >> n;
    for(int i=1;i<n;i++){
        cin >> B[i];
    }
    B[0] = B[1];B[n] = B[n-1];
    rep(i,n) sum += min(B[i],B[i+1]);
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int n,count = 0,ans = 0;
    char s;

    scanf("%d",&n);
    for (int i = 0; i < n; i++)
    {
        scanf("%c",&s);
        if(s == 'Y')
        {
            count = 1;
        }
        
    }
    printf(count == 1 ? "Four" : "Three");
}

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

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

    ll ans = 0;

    rep(i, n) {
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }

    cout << ans << endl;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

int n, m, a, b;

bool read () {
	if (scanf("%d%d%d%d", &n, &m, &a, &b) != 4)
		return false;
	return true;
}

void solve() {
	forn(i, n){
		forn(j, m)
			printf("%d", (j < a) ^ (i < b));
		puts("");
	}
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef _DEBUG
	while(read()) {	
#else
	if(read()) {
#endif
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

Measured memory_bytes: 1280
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
int a;
int main() {
#ifdef LOCAL
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
#endif
    scanf("%d", &a);
    printf("%d", a + a * a + a * a * a);
    return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define rep(i,e) for(int i=0;i<(e);++i)

struct edge{int to, cap, rev;};
int INF = (1<<30);

int m, n;
int b[500], r[500];

vector<edge> G[1010];
int level[1010];
int iter[1010];

void add_edge(int from, int to, int cap){
  G[from].push_back((edge){to, cap, (int)G[to].size()});
  G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
}

void bfs(int s){
  memset(level, -1, sizeof(level));
  queue<int> que;
  level[s] = 0;
  que.push(s);
  while(!que.empty()){
    int v = que.front(); que.pop();
    for(int i=0; i<(int)G[v].size(); i++){
      edge &e = G[v][i];
      if(e.cap>0 && level[e.to]<0){
        level[e.to] = level[v] + 1;
        que.push(e.to);
      }
    }
  }
}

int dfs(int v, int t, int f){
  if(v==t) return f;
  for(int &i = iter[v]; i<(int)G[v].size(); i++){
    edge &e = G[v][i];
    if(e.cap>0 && level[v]<level[e.to]){
      int d=dfs(e.to, t, min(f, e.cap));
      if(d>0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s, int t){
  int flow = 0;
  for(;;){
    bfs(s);
    if(level[t]<0) return flow;
    memset(iter, 0, sizeof(iter));
    int f;
    while((f=dfs(s, t, INF)) > 0){
      flow += f;
    }
  }
}

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

int main(){
  while(true){
    cin>>m>>n;
    if(m==0) break;

    int s=m+n, t=s+1;
    memset(G, 0, sizeof(G));
    memset(level, 0, sizeof(level));
    memset(iter, 0, sizeof(iter));

    rep(i,m) cin>>b[i];
    rep(j,n) cin>>r[j];

    rep(i,m) add_edge(s, i, 1);
    rep(j,n) add_edge(m+j, t, 1);

    rep(i,m)rep(j,n){
      if(gcd(b[i], r[j])>1){
        add_edge(i, m+j, 1);
      }
    }

    int ans = max_flow(s, t);
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 63156
let () =
  let n = Scanf.sscanf (input_line stdin) "%d" (fun a -> a) in
  let rec loop i =
    if i * i > n then []
    else if n mod i == 0 then
      (i, n / i) :: loop (i + 1)
    else
      loop (i + 1)
  in 
  let ans = List.fold_left (fun c (a, b) -> min c (a + b - 2)) 100000000000000 (loop 1)
  in
  print_int ans;
  print_newline ()


Measured memory_bytes: 2432