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

void fst()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
int nxt()
{
    int x;
    cin >> x;
    return x;
}
int nex_l()
{
    long long x;
    cin >> x;
    return x;
}

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define binary(n) cout << bitset<31>(n) << "\n";
#define FOR(i, n) for (int i = 0; i < n; i++)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define input_arr(a, n)         \
    for (int i = 0; i < n; i++) \
        cin >> a[i];
#define print_arr(a, n)         \
    for (int i = 0; i < n; i++) \
        cout << a[i] << " ";
#define deb(n) cerr << #n << "=" << n << "\n";

int main()
{
    ll n;
    cin>>n;
    string ans;
    while(n>0){
        n--;
        ans+='a'+ n%26;
        n/=26;
    }
    reverse(all(ans));
    cout<<ans;

}


Measured memory_bytes: 3632
#include <stdio.h>

int main(void)
{
  int n;
  int d[200];
  int i, flag = 0, tmp = 0;

  scanf(" %d", &n);
  tmp = n;
  for(i = 0;0 != n--; i+=2)
    scanf(" %d %d", &d[i], &d[i + 1]);
  i = 0;
  while (tmp--)
  {
    if (d[i] == d[i + 1])
      flag++;
    else
      flag = 0;
    if (flag == 3)
    {
      printf("Yes\n");
      return (0) ;
    }
    i += 2;
  }
  printf("No\n");
  return (0);
}

Measured memory_bytes: 1664
H,W = gets.split.map(&:to_i)
N = gets.to_i
a = gets.split.map(&:to_i)

masu = H.times.map{Array.new(W, 0)}
aa = []
N.times{|i|
  a[i].times{aa<<(i+1)}
}

masu = aa.each_slice(W).to_a

(H/2).times{|i|
  masu[i*2+1].reverse!
}

H.times{|i| puts masu[i].join(" ") }

Measured memory_bytes: 2556
#include<stdio.h>
int main(){
  int a,i,cou,j;
  while(1){
    scanf("%d",&a);
    if(a==0)break;
    cou=0;
    for(i=a+1;i<=a*2;i++){
      for(j=2;j*j<=i;j++){
	if(i%j==0)break;
      }
      if(j*j>i)cou++;
    }
    printf("%d\n",cou);
  }
  return 0;
}

Measured memory_bytes: 1032
#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 n;
  cin>>n;
  int ans=0;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
      for(int k=1;k<=n;k++)
      {
        ans+=__gcd(i,__gcd(j,k));
      }

    cout<<ans;

// -------------------------------------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: 3804
#include<bits/stdc++.h>
using namespace std;

int StoInt(string &s) {
    int res = 0;
    for(int i = 0; i < s.size(); ++i) {
        res*=10;
        res += s[i]-'0';
    }
    return res;
}

int main()
{
    vector<int> res;
    while(true){
        string num1, num2, op;
        cin >> num1 >> op >> num2;
        int a = StoInt(num1), b = StoInt(num2);
        if(op == "+") {res.push_back(a+b);}
        else if(op == "*") {res.push_back(a*b);}
        else if(op == "-") {res.push_back(a-b);}
        else if(op == "/") {res.push_back(a/b);}
        else {break;}
    }
    for(int i = 0; i < res.size(); ++i){
        cout << res[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3192
s = input().split(" ")
N = int(s[0])
M = int(s[1])

s = input().split(" ")
sum = 0
l = []
for i in range(N):
    sum += int(s[i])
    l.append(int(s[i]))

l = sorted(l, reverse=True)
yes = True

for i in range(M):
    if int(l[i]) < sum / (4 * M):
        yes = False
if yes:
    print("Yes")
else:
    print("No")

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

int main() {
  int n;
  cin>>n;
  string s;
  cin>>s;
  for (int i=0; i<8; i++) {
    bool i0 = (i >> 2) & 1;
    bool i1 = (i >> 1) & 1;
    bool i2 = i & 1;

    if (i1) {
      if (s[1] == 'o') {
        if (i0 != i2) {
          continue;
        }
      } else {
        if (i0 == i2) {
          continue;
        }
      }
    } else {
      if (s[1] == 'o') {
        if (i0 == i2) {
          continue;
        }
      } else {
        if (i0 != i2) {
          continue;
        }
      }
    }
    vector<bool> is_sheep(n);
    is_sheep[0] = i0;
    is_sheep[1] = i1;
    is_sheep[2] = i2;

    for (int j=3; j<n; j++) {
      if (is_sheep[j-1]) {
        if (s[j-1] == 'o') {
          is_sheep[j] = is_sheep[j-2];
        } else {
          is_sheep[j] = !is_sheep[j-2];
        }
      } else {
        if (s[j-1] == 'o') {
          is_sheep[j] = !is_sheep[j-2];
        } else {
          is_sheep[j] = is_sheep[j-2];
        }
      }
    }
    if (is_sheep[n-1]) {
      if (s[n-1] == 'o' && is_sheep[n-2] != is_sheep[0]) {
        continue;
      } else if (s[n-1] == 'x' && is_sheep[n-2] == is_sheep[0]) {
        continue;
      }
    } else {
      if (s[n-1] == 'o' && is_sheep[n-2] == is_sheep[0]) {
        continue;
      } else if (s[n-1] == 'x' && is_sheep[n-2] != is_sheep[0]) {
        continue;
      }
    }
    if (is_sheep[0]) {
      if (s[0] == 'o' && is_sheep[n-1] != is_sheep[1]) {
        continue;
      } else if (s[0] == 'x' && is_sheep[n-1] == is_sheep[1]) {
        continue;
      }
    } else {
      if (s[0] == 'o' && is_sheep[n-1] == is_sheep[1]) {
        continue;
      } else if (s[0] == 'x' && is_sheep[n-1] != is_sheep[1]) {
        continue;
      }
    }
    for (int j=0; j<n; j++) {
      if (is_sheep[j]) {
        cout<<"S";
      } else {
        cout<<"W";
      }
    }
    cout<<endl;
    return 0;
  }
  cout<<-1<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int n,m;

int main(){
	while(1){
		cin>>n>>m;
		if(!n) break;
		vi a(n),b(m);
		for(int i=0;i<n;i++) cin>>a[i];
		for(int i=0;i<m;i++) cin>>b[i];
		int now=0;
		for(int i=0;i<m;i++){
			now+=b[i];
			if(now<n) now+=a[now];
			if(now>=n-1){
				cout<<i+1<<endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 3016
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N,M = LI()

if N%2:
    count = 0
    for i in range(1,(N+1)//2):
        if count < M:
            print(i,N+1-i)
            count += 1
else:
    count = 0
    if M == 1:
        print(1,N)
        exit()
    for i in range(1,N//2+1):
        if count < M:
            print(i,N//2+1-i)
            count += 1
        if count < M:
            print(i+N//2,N-i)
            count += 1

Measured memory_bytes: 70252
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++) 
#define ALL(n) (n).begin,(n).end
/*???????±±?????????3?????????*/
int main()
{
    vector<int> vc;
    int N;
    while( cin >> N )
    {
        vc.push_back( N );
    }
    sort( vc.begin(), vc.end(), greater<int>() );
    REP( i, 3 )
    {
        cout << vc[ i ] << endl;
    }
    return 0;
}

Measured memory_bytes: 3128
# Your code here!

a1,b1 = gets.split.map &:to_i
a2,b2 = gets.split.map &:to_i
a3,b3 = gets.split.map &:to_i

c = [a1,a2,a3,b1,b2,b3]

d = [
    c.count(1),
    c.count(2),
    c.count(3),
    c.count(4)
]

if d.max == 2 && d.min == 1
    puts "YES"
else
    puts "NO"
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//	freopen("output.txt", "w", stdout);
int main ()
{
    unsigned ll int c=0,i,j,x,a=100;
    scanf("%llu",&x);
    while(a<x)
    {
        a+=(a/100);
        c++;
    }
    printf("%llu\n",c);
    return 0;
}



Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int v[] = {-1,1,3,1,2,1,2,1,1,2,1,2,1,};
int main(){
    int a,b;
    cin >> a >> b;
    cout << ((v[a] == v[b]) ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << ", ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << " ]" ;
}

#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
#define sz(a) (ll)(a).size()
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)
#define pi 3.141592653589793238462643

void solve(){
    ll n;
    cin >> n;
    ll a[n];
    loop(i,0,n) cin >> a[i]
;    ll ans = 0;
    ll sum = 0;
    for(ll i = n - 1; i >= 0; i--){
        ans = (ans + (a[i] * sum) % mod) % mod;
        sum = (sum + a[i]) % mod;
    }
    print(ans);
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        start_routine();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    #ifndef ONLINE_JUDGE
        end_routine();
    #endif
}


Measured memory_bytes: 5172
N = int(input())

A = []
max1 = 0
max2 = 0
for _ in range(N):
    ai = int(input())
    A.append(ai)


A2 = sorted(A)

max1 = A2[len(A2)-1]
max2 = A2[len(A2)-2]

for i in range(N):
    if max1 == A[i]:
        print(max2)
    else:
        print(max1)

Measured memory_bytes: 14132
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
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; }
const long long INF = 1LL<<60;

int main(){
    string s;cin >> s;
    int ans = 0;
    for(int i=1;i<s.size();i++){
        if(s[i]!=s[i-1]) ans++;
    }
    cout << (ans==0?"No":"Yes") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <functional>
#include <string>
#include <cmath>
using namespace std;
#pragma warning (disable: 4996)

long long N, A[1 << 18], S;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> A[i];
	for (int i = 0; i <= N; i++) S += abs(A[i] - A[i + 1]);
	cout << S / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

int h, w;
char a[400][400];
int dp[400][400];
int lc[400][400];


ll solve(char *a, char *b) {
	for (int i = h - 1; i >= 0; --i)
		for (int j = h - 1; j >= 0; --j) {
			lc[i][j] = lc[i + 1][j + 1];
			if (a[i] == b[j])
				++lc[i][j];
		}
	for (int i = h - 1; i >= 0; --i)
		for (int j = h - 1; j >= 0; --j) {
			dp[i][j] = lc[i][j] + min(dp[i + 1][j], dp[i][j + 1]);
		}
	return dp[0][0];
}

int main() {
	cin >> h >> w;
	for (int i = h - 1; i >= 0; --i)
		for (int j = 0; j < w; ++j)
			cin >> a[j][i];
	ll ans = 0;
	for (int i = 0; i < w - 1; ++i)
		ans += solve(a[i], a[i + 1]);
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main(){
int n,a,b,c,d,e,f,g,x;
cin >> n;

for (x = 3;x <= n;x++){
    
    a = x % 1000;
    b = x - a;
    b = b /1000;
    c = a % 100;
    d = a - c;
    d = d / 100;
    e = c % 10;
    f = c - e;
    f = f / 10;
    g = x % 3;

    if (b == 3 || d == 3 || e == 3 || f == 3 || g == 0){
        cout << " " << x;
    }

}
    cout << endl;

    return 0;
} 

Measured memory_bytes: 3092
#include<stdio.h>
int main()
{
    int a, b, k,i, j=1, x[101];

    scanf("%d %d %d", &a, &b, &k);

    if(a<b){
        for(i=a; i>=1; --i){

            if(a%i==0 && b%i==0){
                x[j] = i;
                j++;
            }

        }
    }else if(a>b){
        for(i=b; i>=1; i--){

            if(a%i==0 && b%i==0){
                x[j] = i;
                j++;
            }

        }
    }else if(a==b){
        for(i=a; i>=1; i--){

            if(a%i==0){
                x[j] = i;
                j++;
            }

        }
    }


    printf("%d\n", x[k]);

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
         int num;
		 int n[3];
		 scanf("%d",&num);
		 for(int i=0;i<num;i++){
			 scanf("%d %d %d", &n[0],&n[1],&n[2]);
			 sort(n,n+3);
			 if(n[0]*n[0]+n[1]*n[1] == n[2]*n[2]){
				 puts("YES");
			 }else{
				 puts("NO");
			 }
		 }
		 return 0;
}

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

int v[1001], w[1001], dp[1001][1001], n;


int serch(int u)
{
  for (int i = 0; i <= u; i++) dp[n][i] = 0;

  for (int i = n - 1; i >= 0; i--){
    for (int j = 0; j <= u; j++){
      if (j < w[i]){
        dp[i][j] = dp[i + 1][j];
      }
      else {
        dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
      }
    }
  }
  return (dp[0][u]);
}

int main()
{
  int u;

  cin >> n >> u;
  
  for (int i = 0; i < n; i++){    
    cin >> v[i] >> w[i];
  }

  int res = serch(u);
  cout << res << endl;
}

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

using namespace std;

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

ll gcd(ll a, ll b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}
template <typename T>
T lcm(T x, T y) {
    return x / gcd(max(x,y), min(x,y)) * y;
}

int main() {
    ll n, m, i, j, k;
    cin >> n >> m;
    vector<ll> a(n);
    ll l = 1;
    for(auto &x : a) {
        cin >> x;
        l=lcm(l,x/2);
    }
    ll ret = 0;
    //cout << l << endl;
    for(auto &x:a){
        if(l%x==0){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (m/l+1)/2 << endl;
    return 0;
}


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

int a[110], b[110];

int main(void){
	int i, j, n, m;
	int sum_a, sum_b, l;
	int ans[2];
	while(cin >> n >> m, n){
		memset(a, 0, sizeof(0));
		memset(b, 0, sizeof(0));
		ans[0] = 200; ans[1] = 200;
		sum_a = 0; sum_b = 0;
		for(i = 0; i < n; i++){
			cin >> a[i];
			sum_a += a[i];
		}
		for(i = 0; i < m; i++){
			cin >> b[i];
			sum_b += b[i];
		}

		l = sum_b - sum_a;

		if(l % 2){
			cout << "-1" << endl;
			continue;
		}

		for(i = 0; i < n; i++){
			for(j = 0; j < m; j++){
				if((b[j] - a[i] == l/2) && (a[i] - b[j] == -l/2)){
					if(ans[0] + ans[1]  > a[i] + b[j]){
						ans[0] = a[i];
						ans[1] = b[j];
					}
				}
			}
		}
		if(ans[0] == 200) cout << "-1" << endl;
		else cout << ans[0] << " " << ans[1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", ";
        a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);


    for (;;) {
        string s; cin >> s;
        if (s == "#") break;

        s += '/';
        vector<string> board;
        string row;
        REP(k, s.size()) {
            if (s[k] == '/') {
                board.push_back(row);
                row = "";
                continue;
            }
            if (s[k] == 'b') {
                row += 'b';
                continue;
            }
            REP(i, s[k] - '0') {
                row += '.';
            }
        }

        int a, b, c, d; cin >> a >> b >> c >> d;
        --a, --b, --c, --d;
        swap(board[a][b], board[c][d]);

        string ans;
        REP(i, board.size()) {
            int cnt = 0;
            REP(j, board[i].size()) {
                if (board[i][j] == 'b') {
                    if (cnt > 0) ans += to_string(cnt);
                    ans += 'b';
                    cnt = 0;
                } else {
                    ++cnt;
                }
            }
            if (cnt > 0) ans += to_string(cnt);
            if (i < SZ(board)-1) ans += '/';
        }
        cout << ans << endl;
    }


    return 0;
}



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

#define ll long long int
#define ull unsigned long long int
#define IO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


using namespace std;

const int INF = 1e9 + 7;
const int N = 1e5+5;

int main() {

	IO; 

	int p, n;
	cin >> p >> n;
	
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	if (p>= n) {
		cout << 0 << endl;
		return 0;
	}
	
	sort(a.begin(), a.end());
	vector<int> s;
	
	for (int i = 1; i < n; ++i) {
		s.push_back(abs(a[i] - a[i-1]));
	}
	sort(s.rbegin(), s.rend());
	ll ans = 0;
	for (int i = p-1; i < (int) s.size(); ++i) {
		ans += s[i];
	}
	
	cout << ans << endl;
	
	
}



Measured memory_bytes: 4132
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {
		int n = sc.nextInt();
		int a[] = new int[n];
		int b[] = new int[n];

		for(int i =0 ; i< n ;i++){
			a[i] = sc.nextInt();
		}
		for(int i = 0; i < n ; i++){
			b[i] = sc.nextInt();
		}
		
		PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
		
		long loss = 0;
		int ans = 0;
		
		for(int i = 0; i < n ; i++ ){
			if(a[i] < b[i]){
				ans++;
				loss += b[i]-a[i];
			}else{
				pq.add(b[i]-a[i]);
			}
		}
		if(ans == 0){
			System.out.println(0);
			return;
			
		}
		
		for(;!pq.isEmpty();){
			ans++;
			loss += pq.poll();
			if(loss <= 0){
				System.out.println(ans);
				return;
			}
		}
		System.out.println(-1);
		
	}
}


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

int main() {
    int N; cin >> N;
    int W[100];
    int S1, S2, diff, min_diff; S1 = S2 = 0;
    for (int i = 0; i < N; i++) {
        cin >> W[i];
        S2 += W[i];
    }
    min_diff = S2;

    for (int i = 0; i < N; i++) {
        S1 += W[i];
        S2 -= W[i];
        diff = (S1 - S2 < 0) ? -(S1 - S2) : (S1 - S2);
        if (diff < min_diff) min_diff = diff;
    }

    cout << min_diff << endl;
    return 0;
}

Measured memory_bytes: 256
arr = []
0.upto(9999){|i|
    if i % 1111 != 0
        arr2 = sprintf("%04d", i).split("")
        arr3 = arr2.sort
        arr[i] = arr3.reverse.join.to_i - arr3.join.to_i
    end
}

while true
    n = gets.to_i
    break if n == 0
    if arr[n].nil?
        puts "NA"
    else
        count = 0
        until n == 6174
            n = arr[n]
            count += 1
        end
        puts count
    end
end


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

void trace(int *a, int n) {
    for (int i = 0; i < n - 1; i++) {
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
}


int main() {
    int n, a[100];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int flag = 0;
    int cnt = 0;
    for (int i = 0; i < n - 1; i++) {
        if (flag) {
            break;
        }
        flag = 1;
        for (int j = n - 1; j > i; j--) {
            if (a[j] < a[j-1]) {
                int tmp = a[j];
                a[j] = a[j - 1];
                a[j - 1] = tmp;
                flag = 0;
                cnt++;
            }
        }
    }

    trace(a, n);
    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 3088
import math
I=int
q=I(input())
for i in[0]*q:
	a,b=map(I,input().split())
	c=I(math.sqrt(a*b))
	if c*(c+1)<a*b:print(2*c-1)
	elif (a*b==c*c)*(a!=b):print(2*c-3)
	else:print(2*c-2)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
vector<vector<vector<int>>>memo;
vector<int>base;
constexpr int MOD = 1000000007;
int N;
string s;
int solver(int digit,int num,int cmod){
    if( memo[digit][num][cmod] != -1LL) return memo[digit][num][cmod];
    memo[digit][num][cmod] = 0;
    int temp =  ( base[digit] * num ) % 13;
    int nmod =  (cmod - temp <= 0 ? cmod - temp + 13 : cmod - temp) % 13;
    int nidx = digit;
    if(s[nidx] == '?'){
        for(int i = 0; i < 10; ++i){
            memo[digit][num][cmod] += solver(digit + 1, i, nmod);
            memo[digit][num][cmod] %= MOD;
        }
    } else {
        memo[digit][num][cmod] += solver(digit + 1,s[nidx] - '0',nmod);
        memo[digit][num][cmod] %= MOD;
    }
    return memo[digit][num][cmod];
};
signed main(){
    char ts[1000000];
    scanf("%s",ts);
    s = ts;
    N = s.size();
    memo = std::move(vectors(s.size() + 1, 10,13,-1LL));
    vector<int>tbase(N + 1,0LL);
    tbase[s.size()] = 1;
    
    for(int i = N- 1; i >= 0; --i)
        tbase[i] = (9 * tbase[i + 1] + tbase[i + 1]) % 13;
    base = tbase;
    for(int i = 0; i < 13; ++i)
        for(int j = 0; j < 10; ++j)
            memo[s.size()][j][i] = (i == j ? 1 : 0);
    int ans = 0;
    if(s.front() == '?'){
        for(int i = 0; i < 10; ++i)
            ans += solver(1,i,5), ans %= MOD;
    } else {
        ans += solver(1,s.front() - '0',5);
    }
    cout << ans % MOD << endl;
}





Measured memory_bytes: 146560
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int dp[3003][3003]={0};

int main() {
    string s, t;
    cin >> s >> t;
    rep(i,s.size()){
        rep(j,t.size()){
            if(s[i]==t[j]) chmax(dp[i+1][j+1], dp[i][j]+1);
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1],dp[i][j+1]);
        }
    }
    
    string ans = "";
    int i = s.size(), j = t.size(); 
    
    while(i > 0 && j > 0) {
        if(dp[i][j]==dp[i-1][j]) --i;
        else if(dp[i][j]==dp[i][j-1]) --j;
        else {
            ans = s[i-1] + ans;
            --i, --j;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35456
import java.util.*;

class Main{

	public static void main(String[] args){
	
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int min = 200000;
		int cnt = 0;
		
		for(int i =0; i<N; i++){
			int P = sc.nextInt();
			
			min = Math.min(min,P);
			
			if(min == P)
			cnt++;
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 63784
#ifndef __cplusplus
    cat << EOF
#endif
#include <bits/stdc++.h>
using namespace std;

#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define overload_rep(arg0, arg1, arg2, name, ...) name
#define all(box) box.begin(), box.end()

template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if(lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if(lhs > rhs) { lhs = rhs; return 1; } return 0; }

int main() {

    double a, b, p, q, r;
    cin >> a >> b >> p >> q >> r;

    double sq = (b - a) * q;
    double e8 = b * p;

    cout << fixed << setprecision(30) << b + (e8 - sq) / (q + r) << '\n';

}



Measured memory_bytes: 3280
using System;
using System.Linq;

namespace ProblemA
{
    class Program
    {
        static void Main()
        {
            string ch = Console.ReadLine();

            if(ch[0] >= 'A' && ch[0] <= 'Z')
            {
                Console.WriteLine("A");
            }
            else
            {
                Console.WriteLine("a");
            }
        }

        public static int GetInt() => int.Parse(Console.ReadLine());
        public static int[] GetIntArray() => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static double[] GetDoubleArray() => Console.ReadLine().Split().Select(double.Parse).ToArray();
        public static long GetLong() => long.Parse(Console.ReadLine());
        public static long[] GetLongArray() => Console.ReadLine().Split().Select(long.Parse).ToArray();

    }
}


Measured memory_bytes: 25784
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string.h>

#define rep(i,n) for(long long i=0;i<(n);i++)
#define INT(n) int n;scanf("%d",&n);
#define LL(n) long long n;scanf("%lld",&n);
#define pint(n) printf("%d",n);
#define pll(n) printf("%lld",n);
#define psp printf(" ");
#define pln puts("");

int main(){
	INT(N)
	std::vector<int> D(N);
	rep(i,N){
		std::cin >> D[i]; 
	}
	INT(M)
	std::vector<int> T(M);
	rep(i,M){
		std::cin >> T[i];
	}
	std::sort(D.begin(),D.end());
	std::sort(T.begin(),T.end());
	int d=0,t=0;
	bool ans=0;
	for (;;){
		if (D[d]<T[t]){
			d++;
		}
		if (D[d]>T[t]){
			break;
		}
		if (D[d]==T[t]){
			t++;
			d++;
			if(t==M){
				ans=1;
				break;
			}
		}
	}
	if(ans)std::cout<<"YES"<<"\n";
	else std::cout<<"NO"<<"\n";
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

int main(){
	ll n;
	while(scanf("%lld",&n),n){
		ll a[110][110]={};
		ll b[110]={};
		rep(i,0,n){
			ll m;
			scanf("%lld",&m);
			rep(_,0,m){
				ll t;
				scanf("%lld",&t);
				a[i][t]=1;
			}
		}
		ll k;
		scanf("%lld",&k);
		rep(i,0,k)scanf("%lld",b+i);
		ll idx=-1;
		rep(i,0,n){
			int flag=1;
			rep(j,0,k)flag&=a[i][b[j]];
			if(flag){
				if(idx==-1)idx=i+1;
				else idx=-2;
			}
		}
		printf("%lld\n",idx>0?idx:-1);
	}
}




Measured memory_bytes: 2104
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    int sum=0;
    for(int i=0;i<n;i++){
      if(a[i]!=i+1){
        sum++;
      }
    }
    System.out.println( (sum==2||sum==0)?"YES":"NO");
  }
}


Measured memory_bytes: 23124
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define vint vector<int>


int main(){
	int n;
	cin >> n;
	vint a(n);
	vector<pair<int, int>> aa;
	bool b[(int)1e6];
	fill(b, b+(int)1e6, true);
	REP(i,n) cin >> a[i];
	
	sort(a.begin(),a.end());
	
	int ans=0;
	REP(i,n){
		if(b[a[i]-1]==false) continue;
		int j=a[i]*2;
		while(j <= (int)1e6){
			b[j-1]=false;
			j += a[i];
		}
		if(i!=0 && a[i]==a[i-1]) b[a[i]-1]=false;
	}
	
	REP(i,n){
		if(b[a[i]-1]) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}

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

namespace RangeMinimumQuery {
  template<typename T, std::size_t N>
  void Init(T (&xs)[N], T max_value) {
    static_assert( (N & (~(N - 1))) == N, "N != 2^n");
    for(int i = 0; i < (int)N; ++i) {
      xs[i] = max_value;
    }
  }
  template<typename T, std::size_t N>
  void Update2(T (&xs)[N], int index) {
    if( index <= 1 ) return;
    int parent = index >> 1;
    int brother = index ^ 0x01;
    if( xs[index] < xs[brother] ) {
      xs[parent] = xs[index];
    }
    else {
      xs[parent] = xs[brother];
    }
    Update2(xs, parent);
  }
  template<typename T, std::size_t N>
  void Update(T (&xs)[N], int index0, const T& value) {
    xs[(N >> 1) + index0] = value;
    Update2(xs, (N >> 1) + index0);
  }
  template<typename T, std::size_t N>
  T Query2(T (&xs)[N], int left, int right, int rl, int rr, int id) {
    if( rr <= left or right <= rl ) return xs[0];
    if( left <= rl and rr <= right ) return xs[id];
    int rm = (rl + rr) / 2;
    return std::min(Query2(xs, left, right, rl, rm, (id << 1) + 0),
                    Query2(xs, left, right, rm, rr, (id << 1) + 1));
  }
  // [left0, right0)
  template<typename T, std::size_t N>
  T Query(T (&xs)[N], int left0, int right0) {
    return Query2(xs, left0, right0, 0, N >> 1, 1);
  }
};
using namespace RangeMinimumQuery;

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A
// 
void Verify_1() {
  int n, q;
  int xs[131072 * 2];
  //int xs[16];
  scanf("%d %d", &n, &q);
  Init(xs, (int)((1U << 31) - 1));
  for(int i = 0; i < q; ++i) {
    int com, x, y;
    scanf("%d %d %d", &com, &x, &y);
    if( com == 0 ) {
      Update(xs, x, y);
    }
    else {
      y += 1;
      printf("%d\n", Query(xs, x, y));
    }
    for(int i = 0; i < 16; ++i) {
      //printf(" %d", xs[i]);
    }
    //printf("\n");
  }
}

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

Measured memory_bytes: 4200
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    char s = sc.next().charAt(0);
    if(Character.isUpperCase(s)){
      System.out.println("A");
    }
    else{
      System.out.println("a");
    }
  }
}

Measured memory_bytes: 35680
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def combi(n, r):
  if n - r < r: r = n - r
  if r == 0: return 1
  if r == 1: return n
  numerator = [n - r + k + 1 for k in range(r)]
  denominator = [k + 1 for k in range(r)]
  for p in range(2,r+1):
    pivot = denominator[p - 1]
    if pivot > 1:
      offset = (n - r) % p
      for k in range(p-1,r,p):
        numerator[k - offset] /= pivot
        denominator[k] /= pivot
  result = 1
  for k in range(r):
    if numerator[k] > 1:
      result *= int(numerator[k])
  return result

N = I()
data = []

for _ in range(N):
  s = [i for i in S()]
  s.sort()
  data.append("".join(map(str,s)))

data.sort()
#print(data)

tmp = ""
cnt = 0
num = 1
for i in range(N):
  #print(tmp)
  if tmp == data[i]:
    num += 1
    continue
  else:
    if num != 1:
      cnt += combi(num,2)
    tmp = data[i]
    num = 1
  #print(cnt)
else:
  if num != 1:
    cnt += combi(num,2)
  tmp = data[i]
  num = 1

print(cnt)

Measured memory_bytes: 64728
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
l=[0]*(10**4+1)
for x in range(1,10**2+1):
    for y in range(1,10**2+1):
        for z in range(1,10**2+1):
            if x**2+y**2+z**2+x*y+y*z+z*x<=10**4:
                l[x**2+y**2+z**2+x*y+y*z+z*x]+=1
for i in range(1,n+1):
    print(l[i])

Measured memory_bytes: 73604
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
int main()
{
    int N,k;
    scanf("%d %d",&N,&k);
    if(k==1&&N>=k)
    {
        printf("0\n");
    }
    else if(N<k)
    {
        printf("1\n");
    }
    else
    {
        printf("%d\n",abs(N-k));
    }
    return 0;
}

Measured memory_bytes: 128
M = 1299710
isPrime = [1]*M
isPrime[0],isPrime[1] = 0,0
lp = [0]*M; p = []
b = 2
for i in xrange(2,M):
    if isPrime[i]:
        for j in range(i*i,M,i):
            isPrime[j] = 0
        p.append(i)
        b = i
    lp[i] = b
while 1:
    n = input()
    if n==0: break
    print p[p.index(lp[n])+1]-lp[n] if lp[n]!=n else "0"
    

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

int main() {
    int X, Y, Z;
    cin >> X >> Y >> Z;
    if (((X/(Y+Z))*(Y+Z))+Z <= X) cout << X/(Y+Z) << "\n";
    else cout << X/(Y+Z)-1 << "\n";
}

Measured memory_bytes: 256
from math import ceil
from collections import deque
n,d,a = map(int, input().split())

monster = [list(map(int,input().split())) for i in range(n)]

monster.sort()

damage = 0

finish = deque()

ans = 0

for i in range(n):
    x,h = monster[i]
    while finish:
        if finish[0][0]<x:
            damage -= finish.popleft()[1]
        else:
            break
    if h<=damage:
        continue
    else:
        b = ceil((h-damage)/a)
        ans += b
        damage += b*a
        finish.append([x+2*d,b*a])

print(ans)


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

int main(void){
    int s = 0, w = 0;

    scanf("%d%d", &s, &w);

    if(s <= w){
        printf("unsafe\n");
    }else{
        printf("safe\n");
    }


    return 0;

} 


Measured memory_bytes: 3768
use proconio::input;

fn main() {
    input! {
        n:usize,a: [i64;n]
    }

    let mut ans = 0;
    const MOD: i64 = 1e09 as i64 + 7;
    let mut sum = a.iter().fold(0, |sum, a| sum + a);
    sum %= MOD;

    for i in 0..n {
        sum -= a[i];
        if sum < 0 {
            sum += MOD
        }
        ans += sum * a[i];
        ans %= MOD;
    }
    println!("{}", ans);
}


Measured memory_bytes: 5604
x = int(input())

number = 1000

minus = False
end = False

a = 0
b = 0

for i in range(number):
    a = i + 1
    a5 = pow(a, 5)
    if a5 < x:
        minus = True
        surplus = x - a5
    else:
        minus = False
        surplus = a5 - x
    if surplus == 0:
        b = 0
        break
    elif a == 1:
        continue
    for j in range(i):
        b = j + 1
        b5 = pow(b, 5)
        if b5 == surplus:
            if minus:
                b = -b
            end = True
            break
    if end:
        break

print("{} {}".format(a,b))


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)

static const ll INF = 1e18;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

template<typename T> class SegmentTree {
private:
	typedef function<T(T, T)> F;
	int n;
	T d0;
	vector<T> vertex;
	F f;
	F g;
public:

	SegmentTree(int sourceN, F f, F g, T d = 0) :d0(d), f(f), g(g) {
		init(sourceN);
	}
	void init(int sourceN) {
		n = 1;
		while (n < sourceN) n *= 2;
		vertex.resize(2 * n - 1, d0);
	}
	void update(int i, T x) {
		int k = i + n - 1;
		vertex[k] = g(vertex[k], x);
		while (k > 0) {
			k = (k - 1) / 2;
			vertex[k] = f(vertex[2 * k + 1], vertex[2 * k + 2]);
		}
		return;
	}
	T query(int l, int r) {
		T vl = d0, vr = d0;
		l += n - 1;
		r += n - 1;
		for (; l <= r; l /= 2, r = r / 2 - 1) {
			if (l % 2 == 0) vl = f(vl, vertex[l]);
			if (r & 1) vr = f(vr, vertex[r]);
		}
		return f(vl, vr);
	}
};


static SegmentTree<ll> SegmentTreeMax(int n) {
	SegmentTree<ll> t(n, [=](ll left, ll right) {return max(left, right); },
		[=](ll _, ll value) {return value; });
	return t;
}

static SegmentTree<ll> SegmentTreeRangeMinimumQuery(int n) {
	SegmentTree<ll> t(n, [=](ll left, ll right) {return min(left, right); },
		[=](ll _, ll value) {return value; },
		1e18);
	return t;
}

int main() {
	ll n, x;
	cin >> n >> x;
	vector<ll> as(n);
	rep(i, n) {
		cin >> as[i];
	}
	as.insert(as.end(), as.begin(), as.end());
	auto t = SegmentTreeRangeMinimumQuery(n * 2);
	for (int i = 0; i < n * 2; i++) {
		t.update(i, as[i]);
	}

	ll lower = INF;
	rep(i, n) {
		ll sum = x * i;
		rep(j, n) {
			auto l = t.query(j, j + i);
			sum += l;
		}
		chmin(lower, sum);
	}
	cout << lower << endl;
	return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int MOD = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 素数
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){
        IsPrime.resize(max+1,true);
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i){
        if(IsPrime[i]){
            for(size_t j=2; i*j<=max; ++j){
                IsPrime[i*j] = false;
            }
        }
    }
}

// べき乗の余り
ll modpow(ll a, ll n, ll mod){
    ll res = 1;
    while(n){
        if(n & 1){
            (res *= a) %= mod;
        }else{
            (a *= a) %= mod;
        }
        n >>= 1;
    }
    return res;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> l(n);
    for(ll i=0;i<n;++i){
        cin>>l[i];
    }
    sort(l.begin(), l.end());

    ll ans = 0;
    for(ll i=0;i<n;++i){
        for(ll j=i+1;j<n;++j){
            for(ll k=j+1;k<n;++k){
                if(l[i] < l[j] + l[k] and l[j] < l[k] + l[i] and l[k] < l[i] + l[j]){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

int main()
{
 int n;
 cin>>n;
 string s;
 cin>>s;
 int cnt =0;
 int i=0,j=n-1;
 while(i <= j){
 	if(s[j]=='W'){
 		--j;
	 }else if(s[i]=='R'){
	 	++i;
	 }else if(s[i]=='W' && s[j]=='R'){
	 	--j;
	 	++i;
	 	cnt+=1;
	 }
 }
 cout<<cnt<<endl;
return 0;
}



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

int main() {
  ll n;
  ll a = 0, b = 0;
  ll ans = 100000000000000000;
  cin >> n;
  for (int i = 1; i <= sqrt(n); i++) {
    if(n % i == 0) {
      a = i;
      b = n / a;
      ans = min(a + b - 2, ans);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=[0]*n
    for i,x in enumerate(map(int,input().split())):
        A[i]=[x,i]
    A.sort()

    l=A[n//2-1][0]
    h=A[n//2][0]
    for i in range(n//2):
        A[i][0]=h
    for i in range(n//2):
        A[n//2+i][0]=l

    A.sort(lambda x:x[1])
    for i in range(n):
        print(A[i][0])
resolve()

Measured memory_bytes: 109780
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s,t;
	cin>>n>>s>>t;
	int now=1,slen=s.length(),tlen=t.length();
	if(n>=slen+tlen){
		cout<<n;
		return 0;
	}
	int ans=slen+tlen;
	while(now<=min(slen,tlen)&&slen+tlen-now>=n){
		string s1=s.substr(slen-now),t1=t.substr(0,now);
		if(s1==t1)ans=slen+tlen-now;
		now++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

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

signed main(){
	ll n,cnt = 0,ans = 1;
	cin >> n;
	string s;
	cin >> s;
	
	ll cnt_used[26] = {false};
	
	rep(i,0,n){
		cnt_used[s[i] - 'a']++;
	}
	
	rep(i,0,26){
		ans *= cnt_used[i]+1;
		ans %= MOD;
	}
	
	cout << ans - 1 << endl;
	
	return 0;

}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 0) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  std::map< std::string, ll > mc;

  ll N;
  std::cin >> N;
  std::vector< std::string > vs(N);
  for (ll i = 0; i < N; i++) {
    std::cin >> vs[i];
    mc[vs[i]]++;
  }

  if (mc.size() == 3) print("Three");
  else print("Four");

  return 0;
}


Measured memory_bytes: 256