akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#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 ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j,k;
  int n;
  cin>>n;
  string s;
  cin>>s;

  string t="SW";

  rep(i,2)rep(j,2){//0:s, 1:w 

    string ans=""; //わりあて

    ans+=t[i];
    ans+=t[j];

    loop(k,1,n+2){
      if(ans[k]==t[0]){//s[k]が真
	if(s[k%n]=='o')
	  ans+=ans[k-1];
	else if(ans[k-1]=='S')
	  ans+="W";
	else
	  ans+="S";
      }else{//s[k]が偽
        if(s[k%n]=='x')
          ans+=ans[k-1];
        else if(ans[k-1]=='S')
          ans+="W";
        else
          ans+="S";
      }

    }

    //    cout<<ans<<endl;

    if(ans[0]==ans[n] && ans[1]==ans[n+1]){
      cout<<ans.substr(0,n)<<endl;
      return 0;
    }

  }

  cout<<-1<<endl;

}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int x,y;
    cin >> x >> y;
    bool ok=false;

    rp(i,x+1){
        if(4*x-2*i==y) ok=true;
    }
    Yes(ok);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1234567;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<int>h(N);
    for(int i = 0; i < N; i++) {
        cin >> h[i];
    }
    int ans = 0;
    for(int i = 1; i < N; i++) {
        if(h[i-1] <= h[i]) {
            continue;
        }
        ans+=h[i-1]-h[i];
    }
    cout << ans+h[N-1] << endl;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a=0;
        for(int i=1; i<=n; i++){
            a+=i;
        }
        System.out.println(a);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int pow(int x) {
	int a = 1;
	rep(i, x) {
		a *= 100;
	}
	return a;
}
int main() {
	int D, N; cin >> D >> N;
	cout << (N != 100 ? N * pow(D) : (N + 1) * pow(D)) << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, M, C; cin >> N >> M >> C;
    vector<int> B(M, 0);
    int cnt = 0;
    for (int i = 0; i < M; ++i) cin >> B[i];
    for (int i = 0; i < N; ++i) {
        int sum = 0;
        for (int j = 0; j < M; ++j) {
            int a; cin >> a;
            sum += a * B[j];
        }
        if (sum + C > 0) cnt++;
    }
    printf("%d\n", cnt);
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
     cout.tie(0);   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif
 
// -------------------------------------Code starts here---------------------------------------------------------------------     

   int x,y,z;
   cin>>x>>y>>z;
   swap(x,y);
   swap(x,z);
   cout<<x<<" "<<y<<" "<<z;


// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }
 

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000

int A[MAX],n;

int partition(int p,int r){
  int x,i,j,t;
  x = A[r];
  i = p-1;
  for(j= p;j<r;j++){
    if(A[j] <= x){
      i++;
      t = A[i];A[i] = A[j];A[j] = t;
    }
  }
  t = A[i + 1];A[i + 1]  = A[r];A[r] = t;
  return i+1;
}

int main(){
  int i,q;
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&A[i]);
  }
  q = partition(0,n - 1);

  for(i = 0;i < n;i++){
    if(i) printf(" ");
    if(i == q) printf("[");
    printf("%d",A[i]);
    if( i == q) printf("]");
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 2988
from math import floor,ceil,sqrt
import fractions
import collections
import itertools
from collections import deque
N,K=map(int,input().split())
A=list(map(int,input().split()))
trail=[0]*N
trail[0]=1
buf=0
firstonly=[]
loop=[]
#print(trail)
cnt=0
while True:
    nxt=A[buf]-1
    if trail[nxt]<2:
        trail[nxt]=trail[nxt]+1
        cnt=cnt+1
    else:
        break
    buf=nxt
    #print(trail)
    #input()
#print(trail)
buf=0
if trail[buf]==1:
    firstonly.append(buf)
else:
    loop.append(buf)
i=0
while i<cnt:
    nxt=A[buf]-1
    if trail[nxt]==1:
        firstonly.append(nxt)
    else:
        loop.append(nxt)
    i=i+1
    buf=nxt
    #print(firstonly, loop)
    #input()
#print(firstonly,loop)
if K+1<=len(firstonly):
    print(firstonly[K]+1)
else:
    K=K-len(firstonly)
    print(loop[K%len(loop)]+1)






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

int main() {
   int N = 0;
   cin >> N;
   int happy = 0;
   int remainder = 0; 
  happy = (N - N%500)*2 ;
  
  remainder = N % 500;
  happy += (remainder - (remainder % 5) );
  
  cout << happy <<endl;
 
 
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
	
	long long mod = 1000000007,n,ans=1,a=1,b=1,c;

	cin >> n;

	for (int i = 0;i < n;i++) {
		ans *= 10;
		ans %= mod;
		a *= 9;
		a %= mod;
		b *=8;
		b %= mod;
	}
	c = 2 * a - b;
	c %= mod;
	ans = ans - c;
	if (ans < 0) {
		ans += mod;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3628
N = int(input())
limit = 100
memo = {}

for a in range(1, limit):
  for b in range(1, limit):
    for c in range(1, limit):
      t = a**2 + b**2 + c**2 + a*b + b*c + c*a
      if not t in memo:
        memo[t] = 1
      else:
        memo[t] += 1
        
for i in range(1, N+1):
  if not i in memo:
    print(0)
  else:
    print(memo[i])

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

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

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

ll f(ll x, int c, int d){
  ll res =x;
  res -= x/c;
  res -= x/d;
  res += x/lcm(c,d);
  return res;
}

int main() {
  long a, b;
  cin >> a >> b;
  int c, d;
  cin >> c >> d;
  ll ans = f(b,c,d)-f(a-1,c,d);
  cout << ans << endl;
  return 0;
}


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

#define NUM_PROBLEMS_MAX 100
#define NUM_DRINKS_MAX   100

typedef struct
{
	unsigned int num_problems;
	unsigned int num_drinks;
	unsigned int sum_took_time_normal;
	unsigned int took_time_normal [NUM_PROBLEMS_MAX];
	unsigned int index_doped      [NUM_DRINKS_MAX  ];
	unsigned int took_time_doped  [NUM_DRINKS_MAX  ];
} abc050b_t;

void         abc050b_get_data                 (      abc050b_t       * test_data);
void         abc050b_answer                   (const abc050b_t const * test_data);
unsigned int abc050b_calc_sum_took_time_doped (const abc050b_t const * test_data, const unsigned int const index);

int main (void)
{
	// variables for `main`
	abc050b_t test_data;

	// STEP.01
	// read out the given data
	abc050b_get_data(&test_data);

	// STEP.02
	// calculate & output the points
	abc050b_answer(&test_data);

	// STEP.END
	return EXIT_SUCCESS;
}

void abc050b_get_data (abc050b_t * test_data)
{
	// local variables for this function
	int retval_scanf;

	(*test_data).sum_took_time_normal = (unsigned int)(0);

	retval_scanf = scanf( "%d", &(*test_data).num_problems );

	for (unsigned int iter = 0; iter < (*test_data).num_problems; ++iter)
	{
		retval_scanf =
			scanf(
				"%d",
				&(*test_data).took_time_normal[iter]
			);

		(*test_data).sum_took_time_normal += (*test_data).took_time_normal[iter];
	}

	retval_scanf = scanf( "%d", &(*test_data).num_drinks );

	for (unsigned int iter = 0; iter < (*test_data).num_drinks; ++iter)
	{
		retval_scanf =
			scanf(
				"%d %d",
				&(*test_data).index_doped    [iter],
				&(*test_data).took_time_doped[iter]
			);
	}
}

void abc050b_answer (const abc050b_t const * test_data)
{
	// STEP.01
	// print the answer of this task to the console
	for (unsigned int iter = 0; iter < (*test_data).num_drinks; ++iter)
	{
		printf(
			"%d\n",
			abc050b_calc_sum_took_time_doped ( test_data, iter )
		);
	}
}

unsigned int abc050b_calc_sum_took_time_doped (const abc050b_t const * test_data, const unsigned int const index)
{
	return
		(*test_data).sum_took_time_normal -
		(*test_data).took_time_normal [ (*test_data).index_doped[index] - 1 ] +
		(*test_data).took_time_doped  [ index ]
	;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int k, x;
	cin >> k >> x;
	if(k*500 >= x) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 3576
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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














int main() {
    ll a, b;
    cin >> a >> b;
    if((a + b) % 2 == 0){
        cout << (a + b) / 2 << endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
int main(){
	int h,w;
	cin>>h>>w;
	vector <string> v(h);
	REP(i,0,h-1){
		cin>>v[i];
	}
	REP(i,1,w+2){
		cout<<"#";
	}
	cout<<"\n";
	REP(i,0,h-1){
		cout<<"#"<<v[i]<<"#\n";
	}
	REP(i,1,w+2){
		cout<<"#";
	}
	return 0;

//   TimeTaken();
}


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

ans_ = (1 + s)*s / 2

num3 = s // 3
num5 = s // 5
num15 = s // 15

ans = ans_ - (3 + 3*num3)*num3/2 -(5 + 5*num5)*num5/2 + (15 + 15*num15)*num15/2

print(int(ans))

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#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), 0)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#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;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N;
  cin >> N;
  vll A(N);
  cin >> A;

  ll g = A[0];
  rep(i, N) g = gcd(g, A[i]);

  if (g != 1) {
    COUT("not coprime");
    return 0;
  }

  unordered_map<ll, ll> m;

  rep(i, N) {
    vp d = factorize(A[i]);

    for (P dd : d) {
      if (m[dd.first] != 0) {
        COUT("setwise coprime");
        return 0;
      }
      m[dd.first]++;
    }
  }

  COUT("pairwise coprime");
  return 0;
}

Measured memory_bytes: 11056
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

k = I()
s = input()
n = len(s)

fact = [1] * (n + k + 1)
for i in range(1, n+k+1):
    fact[i] = i * fact[i-1]
    fact[i] %= mod
ans = 0
for i in range(n, n + k + 1):
    ret = fact[i-1] * pow(fact[n-1], mod-2, mod) * pow(fact[i-n], mod-2, mod) % mod
    ret *= pow(25, i - n, mod)
    ret %= mod
    ret *= pow(26, k + n - i, mod)
    ret %= mod
    ans += ret
    ans %= mod
print(ans)

Measured memory_bytes: 107608
#include<iostream>
#include<cstring>
using namespace std;
int cnt;
long long a[12][50000];

int main(){
	long long nr;
	int rowcnt;
	int now=0;
	memset(a,0,sizeof(a));
	for(int i=1;i<=9;i++) a[1][i]=i;
	rowcnt=9;
	now=9;
	cin>>cnt;
	int row=2;
	int cy=1;
	int cq=1;
	if(cnt<10) cout<<cnt;
	else{
	while(now<cnt){
		if(cy>rowcnt){
			rowcnt=cq-1;
			cq=1;
			row++;
			cy=1;
		}
		nr=a[row-1][cy]*10+a[row-1][cy]%10;
		
		if(nr%10!=0) {
		a[row][cq]=nr-1;
		cq++;
		now++;
		if(now==cnt) break;} 
		
		a[row][cq]=nr;
		cq++;
		now++;
		if(now==cnt) break; 
		
		if(nr%10!=9) {
		a[row][cq]=nr+1;
		cq++;
		now++;
		if(now==cnt) break; 
	}
		cy++;	
	}
	cout<<a[row][cq-1];
    }
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,q,s[114514],t[114514],x[114514],ans[114514];
int main() {
	cin>>a>>b>>q;
	for(int i=1;i<=a;i++)cin>>s[i];
	for(int i=1;i<=b;i++)cin>>t[i];
	s[0]=t[0]=-1e15,s[a+1]=t[b+1]=1e15;
	for(int i=0;i<q;i++){
		cin>>x[i];
		ll ok=a,ng=-1;
		while((ok-ng)>1){
			ll mid=(ok+ng)/2;
			if(s[mid]>x[i])ok=mid;
			else ng=mid;
		}
		ll sn[2]={s[ok],s[ok-1]};
		ok=b,ng=-1;
		while((ok-ng)>1){
			ll mid=(ok+ng)/2;
			if(t[mid]>x[i])ok=mid;
			else ng=mid;
		}
		ll tn[2]={t[ok],t[ok-1]};
		ans[i]=1e15;
		for(int j=0;j<2;j++)for(int k=0;k<2;k++){
			ans[i]=min(ans[i],abs(sn[j]-x[i])+abs(sn[j]-tn[k]));
			ans[i]=min(ans[i],abs(tn[k]-x[i])+abs(sn[j]-tn[k]));
		}
	}
	for(int i=0;i<q;i++)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 4480
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
int n;
long long f[55][55],fir[55],inv[55];
long long ksm(long long x,long long n)
{
	long long ans=1;
	while(n)
	{
		if(n&1) ans=ans*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return ans;
}
long long C(int n,int m)
{
	if(n<m) return 0;
	return fir[n]*inv[m]%mod*inv[n-m]%mod;
}
int main()
{
	scanf("%d",&n);
	fir[0]=fir[1]=1;for(int i=2;i<=n;i++) fir[i]=fir[i-1]*i%mod;
	inv[n]=ksm(fir[n],mod-2);
	for(int i=n-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	f[1][0]=f[1][1]=n;
	for(int i=1;i<n;i++)
	for(int j=1;j<=n-i;j++)
	for(int k=0;k<=j;k++)
	{
		if((j-k)&1) continue;
		int x=(j-k)/2;
		for(int d=0;d<=j;d++)
		{
			f[i+j][abs(x-d)]=(f[i+j][abs(x-d)]+f[i][k]*C(n-i,j)%mod*C(j,d))%mod;
		}
	}
	printf("%lld",f[n][0]);
}

Measured memory_bytes: 3844
#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;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair <long long,long long> ii;
typedef complex<long double> point;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
	cin >> s;
	for (int z=0;z<s.size();z++){
		if (z & 1){
			if (s[z] == 'L' || s[z] == 'U' || s[z] == 'D') continue;
			cout << "No" << endl;
			return 0;
		} else {
			if (s[z] == 'R' || s[z] == 'U' || s[z] == 'D') continue;
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int
main(int argc, char *argv[])
{
  char s[100001];
  scanf("%s", s);

  int cnt = 0; int i = 1;
  while(s[i] != '\0'){
    if(s[i - 1] != s[i]) cnt++;
    i++;
  }
  printf("%d\n", cnt);
  return 0;
}


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

struct circle {
    int x, y, r;
    int c;
};

bool isis_cc(circle const& c1, circle const& c2) {
    return (c1.x - c2.x) * (c1.x - c2.x) + (c1.y - c2.y) * (c1.y - c2.y) < (c1.r + c2.r) * (c1.r + c2.r);
}

int main() {
    int n;
    while(cin >> n, n) {
        vector<circle> v(n);
        vector<short> dp(1 << n, -1);
        vector<int> on(n);
        for(int i=0; i<n; ++i) {
            cin >> v[i].x >> v[i].y >> v[i].r >> v[i].c;
            for(int j=0; j<i; ++j) {
                if(isis_cc(v[i], v[j])) {
                    on[i] |= (1 << j);
                }
            }
        }

        dp[0] = 0;
        short res = 0;
        for(int b=0; b<(1<<n); ++b) {
            if(dp[b] == -1) {
                continue;
            }
            res = max(res, dp[b]);

            for(int j=0; j<n; ++j) {
                if((b & (1 << j)) != 0 || (b & on[j]) != on[j]) {
                    continue;
                }
                for(int k=j+1; k<n; ++k) {
                    if(v[j].c != v[k].c || (b & (1 << k)) != 0 || (b & on[k]) != on[k]) {
                        continue;
                    }
                    int next = b | (1 << j) | (1 << k);
                    dp[next] = max((int)dp[next], dp[b]+2);
                }
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 35832
#include <iostream>

int main()
{
    int a_val,b_val,c_val;
    std::cin >> a_val >> b_val >> c_val;

    if((a_val == b_val) &&(b_val == c_val) && (c_val == a_val)){
        std::cout << "No" << std::endl;
        return 0;
    }

    if(a_val == b_val){
        std::cout << "Yes" << std::endl;
        return 0;
    }

    if(b_val == c_val){
        std::cout << "Yes" << std::endl;
        return 0;
    }

    if(c_val == a_val){
        std::cout << "Yes" << std::endl;
        return 0;
    }

    std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main(){
    int n, m;
    cin >> n >> m;
    int k[12],s[12][12],p[12],ans=0;
    REP(i, m)
    {
        cin >> k[i];
        REP(j,k[i]){
            cin >> s[i][j];
        }
    }
    REP(i,m) cin >> p[i];
    int sw[12];
    REP(i, pow(2, n))
    {
        int fl = i;
        REP(j, n)
        {
            sw[j] = fl % 2;
            fl /= 2;
        }

        REP(j,m){
            int count=0;
            REP(l, k[j])
            {
                count += sw[s[j][l] - 1];
            }
            if (count % 2 != p[j]) break;
            if (j == m-1) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
 	long n;
 	long long sum=1;
 	scanf("%d",&n);
 	while(n){
 		sum=sum*n;
 		n--;
 		if(sum>1000000007)
		 sum%=1000000007;
	 }
	 printf("%lld",sum%1000000007);
	 return 0;
 }

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

int main() {
  vector<int> v1;
  vector<int> v2;
  int a, aim;
  cin >> a >> aim;
  for(int i = 0; i < a; i++){
      int num, bonus;
      cin >> num >> bonus;
      v1.push_back(num);
      v2.push_back(bonus);
  }
  int ans =1000;
  for(int j = 0; j < (1<<a); j++){
      int sum = 0, count = 0, lest_max;
      for(int k = 0; k < a; k++){
          if(j & (1<<k)){
              sum += v1[k]*(k+1)*100 + v2[k];
              count += v1[k];
          }
          else{
              lest_max = k;
          }
      }
      if(sum < aim){
          int b = (aim - sum)/((lest_max+1)*100);
          if((aim - sum) % ((lest_max+1)*100) != 0) b++;
          if(b >= v1[lest_max]) continue;
          count += b;
      }
      ans = min(ans, count);
  }
  cout <<ans << endl;
}

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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    ll ans = 0;
    for (int i=1;i<=N;i++){
        int p = N/i;
        ans += (1LL+p)*p/2LL*i;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>

using namespace std;

struct Node {
    int no_;
    int calorie_;
    int price_;

    Node(int n, int c, int p) 
        : no_(n), calorie_(c), price_(p) {}
};

int N, A, B, C;
vector<int> calorie;

int calcBestPizza() {
    int ans = 0;

    stack<Node> st;
    st.push(Node(0, C, A));
    st.push(Node(0, calorie[0]+C, A+B));

    while(!st.empty()) {
        auto node = st.top();
        st.pop();

        int n = node.no_;
        int total_calorie = node.calorie_;
        int total_price = node.price_;
        int tmp = total_calorie / total_price;

        if ( tmp > ans ) {
            ans = tmp;
        }

        if (n < N - 1) {
            st.push(Node(n+1, total_calorie, total_price));
            st.push(Node(n+1, total_calorie + calorie[n+1], total_price+B));
        }
    }

    return ans;
}

int main(int argc, char const *argv[]) {
    cin>>N;
    cin>>A>>B;
    cin>>C;

    for (int i = 0; i < N; ++i) {
        int c;
        cin>>c;
        calorie.push_back(c);
    }

    sort(calorie.begin(), calorie.end(), greater<int>());
    int total_calorie = C;
    int total_price = A;
    int ans = C / A;
    for (int i = 0; i < N; ++i) {
        total_calorie += calorie[i];
        total_price += B;
        ans = max(ans, total_calorie/total_price);
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3160
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(13);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);
//#define Local = 1;
#ifdef Local
#define debug(x) cout << __LINE__ << " " << #x <<"..." << x << endl
#define dev(x) cout << __LINE__ << " " << #x << "..." ; for(auto &it : x) cout<< it << " "; cout << endl;
#define des(x) cout << __LINE__ << " " << #x << "..." << x << endl;
#else
#define debug(x) ;
#define dev(x);
#define des(x)
#endif

const double PI = 3.141592653589793;

void solve()
{
	int n;
	cin >> n;
	int x = n-1;
	int ans = x;
	for(int i=2;i<=1000000;i++)
	{
		if(x/i<=0) break ;
		else ans += (x/i);
	}
	cout << ans ;
}

int32_t main()
{
	FastIO;
	Fast_D;
	int T;
	T=1;
	while(T--) solve();
	return 0;
}



Measured memory_bytes: 3652
import sys
import heapq
import copy
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    pq_L = []
    pq_R = []
    for i in range(N):
        L, R = map(int, input().split())
        heapq.heappush(pq_L, (-L, i))
        heapq.heappush(pq_R, (R, i))
    pq_L2 = copy.deepcopy(pq_L)
    pq_R2 = copy.deepcopy(pq_R)

    ans1 = 0
    prev = 0
    used = [0] * N
    for i in range(N):
        if i % 2 == 0:
            while True:
                _x, j = heapq.heappop(pq_L)
                x = -_x
                if not used[j]:
                    used[j] = 1
                    break
            if prev < x:
                ans1 += x - prev
                prev = x
        else:
            while True:
                x, j = heapq.heappop(pq_R)
                if not used[j]:
                    used[j] = 1
                    break
            if prev > x:
                ans1 += prev - x
                prev = x

    ans1 += abs(prev)

    ans2 = 0
    prev = 0
    used = [0] * N
    for i in range(N):
        if i % 2 == 1:
            while True:
                _x, j = heapq.heappop(pq_L2)
                x = -_x
                if not used[j]:
                    used[j] = 1
                    break
            if prev < x:
                ans2 += x - prev
                prev = x
        else:
            while True:
                x, j = heapq.heappop(pq_R2)
                if not used[j]:
                    used[j] = 1
                    break
            if prev > x:
                ans2 += prev - x
                prev = x

    ans2 += abs(prev)

    print(max(ans1, ans2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 133172
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    int x,y;
    bool c[n]={true};
    for(int i=0;i<n;i++)
        c[i]=true;
    for(int k=0;k<m;k++)
    {
        cin>>x>>y;
        x--;
        y--;
        if(a[x]>a[y])
        {
            c[y]=false;
        }
        else if(a[x]<a[y])
        {
            c[x]=false;
        }
        else
        {
            c[x]=false;
            c[y]=false;

        }

    }
    int k=0;
    for(int i=0;i<n;i++)
    {
        if(c[i])
            k++;
    }
    cout<<k;

}


Measured memory_bytes: 4128
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> cnt(100002);
    for(int i=0; i<N; i++) {
        int a;
        cin >> a;
        cnt[a]++;
    }

    int ans = 0;
    for(int i=1; i<cnt.size()-1; i++) {
        ans = max(ans, cnt[i-1]+cnt[i]+cnt[i+1]);
    }

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


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

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

    int N, M; cin >> N >> M;
    vector<int> boxes(N), flags(N);
    for (int i = 0; i < N; i++) boxes[i] = 1;
    for (int i = 0; i < N; i++) flags[i] = 0;
    flags[0] = 1;

    for (int i = 0; i < M; i++) {
        int x, y; cin >> x >> y; x--; y--;

        if (flags[x]) {
            if (boxes[x] == 1) {
                flags[x] = 0;
                flags[y] = 1;
                boxes[x]--;
                boxes[y]++;
            } else {
                flags[y] = 1;
                boxes[x]--;
                boxes[y]++;
            }
        } else {
            boxes[x]--;
            boxes[y]++;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += flags[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
#define CEIL(A,B) ((A)+(B)-1)/(B)
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

ll N, A, B, ans;
vector<ll> h;

bool judge(ll t) {
    ll ans = 0;
    REP(i, N) {
        if(h[i] > B * t) {
            ans += CEIL(h[i] - B * t, A - B);
        }
    }
    return ans <= t;
}

int main() {
    fastio();
    cin >> N >> A >> B;
    h.resize(N);
    REP(i, N) cin >> h[i];
    ll l = 0, r = *max_element(ALL(h)) / B + 1;
    while(r - l > 1) {
        ll m = (r + l) / 2;
        if(judge(m)) r = m;
        else l = m;
    }
    cout << r << endl;
	return 0;
}

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

const int maxn=200005;
struct EDGE
{
    int v, w, next;
}e[maxn<<1];
int cnt;
int head[maxn]={};
void Add(int u, int v, int w){
    e[cnt].v = v;
    e[cnt].w = w;
    e[cnt].next = head[u];
    head[u] = cnt++;
}
int dp[2][maxn]={};
int n,ans;
void dfs(int u,int fa){
    //cout<<u<<endl;
    for(int i=head[u];i!=-1;i=e[i].next)if(e[i].v!=fa){
        int v=e[i].v,w=e[i].w;
        dfs(v,u);
        if(dp[0][v]+w>dp[0][u]){
            dp[1][u]=dp[0][u];
            dp[0][u]=dp[0][v]+w;
        }
        else if(dp[0][v]+w>dp[1][u]) dp[1][u]=dp[0][v]+w;
    }
    ans=max(ans,dp[0][u]+dp[1][u]);
    return;
}
int main()
{
    scanf("%d",&n);
    memset(dp,0,sizeof(dp));ans=0;cnt=0;
    memset(head,-1,sizeof(head));
    for(int i=0;i<n-1;i++){
        int u, v;
        scanf("%d%d",&u,&v);
        Add(u,v,1);
        Add(v,u,1);
    }
    dfs(1,-1);
    //cout<<ans<<endl;
    ans++;
    if(ans%3==0||ans%3==1)cout<<"First"<<endl;
    else cout<<"Second"<<endl;
    return 0;
}



Measured memory_bytes: 19200
<?php

fscanf(STDIN,"%d %d",$n,$m);

$tmp = 2* $n - $m;
if($n == 0){
    $ans = (int)floor($m/4);
}


else{
$ans = (int)floor (0 < $tmp ? $m/2 : $n + (($m - 2* $n)/4)) ;
}

echo $ans . PHP_EOL;



Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
const int N=4010,p=1e9+7;
int inc(int x,int y){x+=y;return x>=p?x-p:x;}
int dec(int x,int y){x-=y;return x<0?x+p:x;}
int n,m,k,dp[N][N],sum[N];
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	dp[0][0]=1;
	for (int i=1;i<=n+m-1;i++){
		sum[0]=dp[i-1][0];
		for (int j=1;j<=m;j++) sum[j]=inc(sum[j-1],dp[i-1][j]);
		for (int j=0;j<=m;j++) dp[i][j]=dec(sum[j],j>=k?sum[j-k]:0);
	}
	int ans=0;
	for (;m>0;m-=k-1) ans=inc(ans,dp[(n+m-1)/(k-1)][m]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 62080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int k, s, ans = 0;
	cin >> k >> s;
	rep(i, k + 1) {
		rep(j, k + 1) {
			if (s - i - j <= k&&i + j <= s)ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
A, B, C, X = map(int, [input() for _ in range(4)])

x = X
result = 0
for i in range(A+1):
    if 500 * i > x:
        break
    for j in range(B+1):
        if 100 * j + 500 * i > x:
            break
        for k in range(C+1):
            total = 500 * i + 100 * j + 50 * k
            if total == x:
                result += 1
            elif total > x:
                break
print(result)




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

using namespace std;

const int N = 2E5+7;
int a[N];
map<int,int> m;

int n;
int main()
{
    cin >> n;
    for(int i = 1 ; i <= n; i ++)
    {
        int  x; cin >> x;
        a[i] = x + i;
        m[i - x] ++;
    }
    long long ans = 0;
    
    for(int i = 1;  i<= n;i ++)
     ans +=m[a[i]];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 21472
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(6) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    cin >> n;
    vector<int> a = {};
    REP(i,n){
        int t;
        cin >> t;
        if(t==0){
            int x;
            cin >> x;
            a.push_back(x);
        }
        else if(t == 1){
            int x;
            cin >> x;
            print(a[x]);
        }
        else{
            a.pop_back();
        }
    }


    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



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

int main(void) {
  string stra, strb;
  string sa, sb;

  cin >> sa >> sb;

  for (int ib = 1; ib <= atoi(sb.c_str()); ib++) { stra += sa; }
  for (int ia = 1; ia <= atoi(sa.c_str()); ia++) { strb += sb; }

  cout << ((stra < strb) ? stra : strb) << endl;

  return 0;
}

Measured memory_bytes: 256
a,b,c,d,e,f=map(int,input().split())
a=100*a
b=100*b
dp1=[0]*(f+1)
dp2=[0]*(f+1)
for i in range(f+1):
    if i%a==0:
        if i+a<=f:
            dp1[i+a]=1
for i in range(f+1):
    if i==0 or dp1[i]==1:
        if i+b<=f:
            dp1[i+b]=1
for i in range(f+1):
    if i%c==0:
        if i+c<=f:
            dp2[i+c]=1
for i in range(f+1):
    if i==0 or dp2[i]==1:
        if i+d<=f:
            dp2[i+d]=1

ans=[-1,-1,-1]
for i in range(f+1):
    if dp1[i]==1:
        x=min(f-i,(i//100)*e)
        k=-1
        for j in range(x,-1,-1):
            if dp2[j]==1 or j==0:
                k=j
                if ans[0]<100*k/(i+k):
                    ans=[100*k/(i+k),i+k,k]
                break
print(str(ans[1])+" "+str(ans[2]))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int Decimal(int N){
  int num=0;
  while(N!=0){
    N=N/10;
    num++;
  }
  
  return num;
}

    
int main(){
  long N; //Nの数
  long B=1; //AとBの数の入れ物を用意
  
  /////入力部/////
  cin >> N;
  
  int ans=Decimal(N); //1の時の値
  
  for (long A=2;A*A<=N;A++){
    if(N%A == 0){
      B = N/A;
      if(ans >Decimal(B))ans = Decimal(B);
    }
  }
  cout<<ans<<endl;
}

        
  
  
  


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

using namespace std;

int main(){

	int N;
	string S;
	cin >> N >> S;
	
	
	int countW[N];//wなら１
	int countE[N];
	
	int w[N];
	int e[N];
	


	for(int i=0;i<N;i++){
		if(S[i] =='W'){
			if(i==0){
				w[i] = 1;
			}
			
			else{
				w[i] = w[i-1]+1;
			}		
		}
		
		else{
			if(i==0){
				w[i] = 0;
			}
			else{
				w[i] = w[i-1];
			}
		}
	}

	for(int i=N-1;i>=0;i--){
		if(S[i] =='E'){
			if(i==N-1){
				e[i] = 1;
			}
			
			else{
				e[i] = e[i+1]+1;
			}		
		}
		
		else{
			if(i==N-1){
				e[i] = 0;
			}
			else{
				e[i] = e[i+1];
			}
		}
	}


	int temp=0;
	int m = 100000000;
	

	for(int i=0;i<N;i++){
		if(i==0){
			temp = e[i+1];
		}
		else if(i==N-1){
			temp = w[i-1];
		}
		else{
			temp = w[i-1]+e[i+1];
		}
		
		m = min(m,temp);
	}


/*	
	for(int i=0;i<N;i++){
		temp = 0;
		for(int j=0;j<i;j++){
			if(S[j]=='W'){
				temp++;
			}
		}
		for(int j=i+1;j<N;j++){
		
			if(S[j]=='E'){
				temp++;
			}
		}
		m = min(temp,m);
	}
*/


	cout << m << endl;

	return 0;

}

Measured memory_bytes: 3076
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import qualified Data.Map.Strict as M
import qualified Data.Vector.Unboxed as VU

getInts :: IO[Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine


lambda::M.Map Int Int->Int->M.Map Int Int
lambda acc v = foldl (\acc x -> if M.member x acc then M.adjust (+1) x acc else M.insert x 1 acc) acc [v-1,v,v+1]

main = do
  n <- getLine
  an <- getInts
  print $ maximum $ M.elems . VU.foldl lambda M.empty $ VU.fromList an

Measured memory_bytes: 19836
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const int MOD = 1000000007;

int main(){
  int A,B;
  cin >> A >> B;
  cout << max(A-B,max(A*B,A+B));
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

ll power(ll a,ll b/*,ll mod*/){
    ll ret=1;
    if(b>0){
        ret = power(a,b/2/*,mod*/);
        if(b%2==0)ret = (ret*ret)/*%mod*/;
        else ret = (((ret*ret)/*%mod*/)*a)/*%mod*/;
    }
    return ret;
}


int h,w,c;

int dfs(vector<vector<int>> &v,int y,int x,vector<vector<bool>> &used){
    int ret = 1;
    int dy[]={1,0,-1,0};
    int dx[]={0,1,0,-1};

    rep(i,4){
        int ddy = y+dy[i];
        int ddx = x+dx[i];
        if(ddx<0 || ddy<0 || ddx>=w || ddy>=h)continue;
        if(used[ddy][ddx])continue;
        if(v[y][x]==v[ddy][ddx]){
            used[ddy][ddx]=true;
            ret+=dfs(v,ddy,ddx,used);
        }
    }
    return ret;
}

void paint(int y, int x, vector<vector<int>> &v, int color, int base){
    if(base==color)return ;
    v[y][x] = color;
    rep(i,4){
        int dy[]={1,0,-1,0};
        int dx[]={0,1,0,-1};
        int ddy = y+dy[i];
        int ddx = x+dx[i];
        
        if(ddx<0 || ddy<0 || ddx>=w || ddy>=h)continue;
        if(v[ddy][ddx]==base){
            v[ddy][ddx]=color;
            paint(ddy,ddx,v,color,base);
        }
    }
}

int exe(vector<vector<int>> v,vector<int> op){
    rep(i,op.size()){
        paint(0,0,v,op[i],v[0][0]);
    }
    
    vector< vector<bool> > used(h,vector<bool>(w,false));
    used[0][0]=true;
    return dfs(v,0,0,used);
    
}

int main(){
    while(cin>>h>>w>>c&&(h||w||c)){
        c--;
        vector<vector<int>> v(h,vector<int>(w));
        rep(i,h)rep(j,w)cin>>v[i][j];
        rep(i,h)rep(j,w)v[i][j]--;
        
        int ans = 0;
        int end = power(4,6);
        rep(i,end){
            vector<int> vec;
            int num = i;
            rep(j,4){
                vec.pb(num%6);
                num/=6;
            }
            vec.pb(c);
            
            ans = max(ans,exe(v,vec));
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3092
import Data.List
import Data.Char
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as BS8

main :: IO ()
main = do
  [k, n] <- unfoldr (BS8.readInteger . BS8.dropWhile isSpace) <$> BS8.getLine
  a <- unfoldr (BS8.readInteger . BS8.dropWhile isSpace) <$> BS8.getLine

  let
    d = map (\(x, y) -> y - x) $ zip a $ (tail a) ++ ([k + head a])

  print $ (sum d) - (maximum d)


Measured memory_bytes: 15740
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;
using ll  = long long;
template <typename T> T In() {
    T t;
    cin >> t;
    return t;
}
template <typename T> vector<vector<T>> Vec2(int i, int j, T ini = 0) {
    vector<vector<T>> vec(i, vector<T>(i, ini));
    return move(vec);
}
template <typename T> vector<vector<vector<T>>> Vec3(int i, int j, int k, T ini = 0) {
    vector<vector<vector<T>>> vec(i, vector<vector<T>>(j, vector<T>(k, ini)));
    return move(vec);
}

int main() {
    int N = In<int>();
    int K = In<int>();
    char prev = In<char>();
    int ans = 0;
    for(int i = 0; i < N - 1; i++) {
        char s = In<char>();
        if( s == prev) ans++;
        prev = s;
    }
    ans = min(ans + 2 * K, N-1);
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
public class Program {
  public static void Main() {
    string line = Console.ReadLine();
    int Sn = line.ToArray().Select(x => int.Parse(x.ToString())).Sum();
    int N = int.Parse(line);
    if (N % Sn == 0) {
      Console.WriteLine("Yes");
    } else {
      Console.WriteLine("No");
    }
  }
}


Measured memory_bytes: 13268
def find(l, e):
	start, end = 0, len(l)
	while True:
		mid = (start+end)//2
		if l[mid] == e: 
			return (e, e)
		elif (l[mid] > e):
			if (l[mid-1] < e):
				return (l[mid-1], l[mid])
			end = mid
			continue
		elif (l[mid] < e):
			if (l[mid+1] > e):
				return (l[mid], l[mid+1])
			start = mid

def print_sum():
	d = int(raw_input())
	if d == 0: return False
	n, m = int(raw_input()), int(raw_input())
	S = [int(raw_input()) for _ in range(n-1)]
	K = [int(raw_input()) for _ in range(m)]
	S = [0] + sorted(S) + [d]
	sum = 0
	for k in K:
		low, high = find(S, k)
		sum += min(k-low, high-k)
	print sum
	return True

while (print_sum()):
	pass

Measured memory_bytes: 13348