akhauriyash/Code-Regression huggingface dataset:
N = int(input())
S = input()



candidate = [("S", "S"), ("S", "W"), ("W", "S"), ("W", "W")]
for a,b in candidate:
    ans = [""] * (N+2)

    ans[0], ans[1] = a, b
    for i in range(N):
        if ans[i+1] == "S":
            if S[i] == "o":
                ans[i+2] = ans[i]
            else:
                if ans[i] == "S":
                    ans[i+2] = "W"
                else:
                    ans[i+2] = "S"
        else:
            if S[i] == "o":
                if ans[i] == "S":
                    ans[i+2] = "W"
                else:
                    ans[i+2] = "S"
            else:
                ans[i+2] = ans[i]
    
    if ans[0] == ans[N] and ans[1] == ans[N+1]:
        print("".join(ans[1:N+1]))
        exit()

print(-1)

Measured memory_bytes: 46192
/***************************************** START OF TEMPLATE *********************************************/

#include<bits/stdc++.h>

using namespace std;

#define  SPEED          ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  f              first
#define  s              second
#define  pb             push_back
#define  INPa(a,n)      foo(i,1,n) cin>>a[i];
#define  deb2d(a,n,m)   foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}
#define  deb1d(a,n)     foo(i,1,n)cout<<a[i]<<" ";newl;
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<" ";newl;
#define  deb2(a,b)      cout<<a<<" "<<b<<" ";newl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<" ";newl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d;newl;
#define  ll             long long
#define  ld             long double
#define  pll            pair<ll,ll>
#define  vll            vector<ll>
#define  vpll           vector<pll>

const ll   MOD   =  1e+9 + 7;
const ll   INF   =  LLONG_MAX;
const int  INFi  =  INT_MAX;
const ll   N     =  1e+2 + 8;

vll adj[N]; ll vis[N];
ll dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

ll test_cases = 1; randomINIT;

/*********************************************************************************************************/
/***************************************** VARIABLE DECLARATIONS *****************************************/
ll n, m, x, c[N], a[N][N], res = INF, kn[N];

/***************************************** FUNCTION IMPLEMENTATIONS **************************************/
void solve() {
    for (ll msk = 0; msk <= pow(2, n) - 1; msk++) {
        foo(i, 1, m) kn[i] = 0;
        ll ok = 1, cost = 0;
        for (ll i = 1; i <= n; i++) {
            if ((msk & (1LL << (i - 1))) != 0) {

                foo(j, 1, m) kn[j] += a[i][j];
                cost += c[i];
            }
        }
        foo(i, 1, m) ok &= (kn[i] >= x);
        if (ok) {
            res = min(res, cost);
        }
    }
    if (res == INF)res = -1;
}


/***************************************** START OF MAIN FUNCTION ****************************************/
void MAIN(ll tc) {
    cin >> n >> m >> x;
    foo(i, 1, n) {
        cin >> c[i];
        foo(j, 1, m) {
            cin >> a[i][j];
        }
    }

    solve();
    cout << res;
}

int main() {
    SPEED;

    //cin>>test_cases;
    foo(i, 1, test_cases) {
        MAIN(i);
    }
}

Measured memory_bytes: 4144
#include<iostream>
using namespace std;
int main(){
  int n,l;cin >> n >> l;
  if (l <= 0 && 0 <= l+n-1) cout << (l+l+n-1)*n/2 << endl;
  else if (l > 0) cout << ((l+l+n-1)*n)/2-l << endl;
  else cout << (l+l+n-1)*n/2-(l+n-1) << endl;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline

N,M=[int(n) for n in input().split()]
lis=[[i]+[int(n) for n in input().split()] for i in range(M)]
#print(lis)
l_2=sorted(lis, key=lambda x: x[2])
dic={}
for k,i,j in l_2:
    dic[i]=dic.get(i,0)+1
    lis[k]='{:0=6}{:0=6}'.format(i,dic[i])
for i in lis:print(i)

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

int main()
{
	int n,k,x,y;
	cin >> n;
	cin >> k;
	for(int i=0;i<k;i++){
		cin >> x >> y;
		int pos = min(x,min(y,min(n-x+1,n-y+1)));
		switch(pos%3){
			case 0:
				cout << 3 << endl;
				break;
			case 1:
				cout << 1 << endl;
				break;
			case 2:
				cout << 2 << endl;
				break;
			default:
				break;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <stack>
#include <math.h>
using namespace std;
typedef long long int ll;
bool check[100005];
int cnt[100005];
bool isprime(int n,int k=2){if(n==1){return false;}if(n<k*k){return true;}if(n%k==0){return false;}return isprime(n,k+1);}
int main(){
	int q; cin >> q;
	vector<int> n(q);
	for(int i=0;i<q;i++){
		cin >> n[i];
	}
	for(int i=0;i<100001;i++){
		if(check[i]==true)continue;
		if(i<2){
			check[i]=false;
			continue;
		}
		if(isprime(i)){
			check[i]=false;
			continue;
		}
		int q=-1;
		for(int j=2;j<=sqrt(i)+1;j++){
			if(i%j==0){
				q=j;
				break;
			}
		}
		for(int j=q+1;j<i/q;j++){
			if(i%j==0){
				check[i]=true;
				break;
			}
		}
		if(check[i]){
			for(int j=i+i;j<=100000;j+=i){
				check[j]=true;
			}
		}
	}
	for(int i=0;i<100001;i++){
		if(check[i]){
			cnt[i]++;
		}
	}
	for(int i=1;i<100001;i++){
		cnt[i]+=cnt[i-1];
	}
	for(int i=0;i<q;i++){
		cout << cnt[n[i]] << endl;
	}
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 

bool is_square(int64_t n){
    int64_t sn = sqrt(n);
    if (sn * sn == n) return true;
    else return false;
}

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

int N; cin >> N;

// 1+8N は奇。奇＝奇×奇。
// 1+8N が平方数であるならyes
if (is_square(1 + 8*N)){
    cout << "Yes\n";
    int w = (sqrt(1 + 8*N) + 1) / 2;
    cout << w << "\n";
    VVI ans(w, VI(w-1));
    for(int i = 0, a = 1; i < w-1; ++i){
        rep(j, i, w-1){
            ans[i][j] = a;
            ans[j+1][i] = a;
            ++a;
        }
    }
    rep(i, 0, w){
        cout << w-1 << ' ';
        rep(j, 0, w-1) cout << ans[i][j] << ' ';
        cout << "\n";
    }
}
else 
    cout << "No\n";



return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



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

namespace aaa
{
	class MainClass
	{
		public static void Main(string[] args)
		{	
			for (int i = 1; i < 10; i++) {
				for (int j = 1; j < 10; j++) {
					Console.Out.WriteLine(i+"x"+j+"="+i*j);
				}
			}	
		}
	}
}

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

int main(){
  int n;
  bool table[123457*2];
  for (int i = 0; i < 123457*2; i++)
    table[i] = true;
  table[0] = table[1] = false;
  for (int i = 2; i < 123457; i++){
    if (table[i])
      for (int j = 2 * i; j < 123457*2; j += i)
  	table[j] = false;
  }

  while (1){
    cin >> n;
    if (!n) break;
    int count = 0;
    for (int i = n+1; i <= 2*n; i++) if (table[i]) count++;
    cout << count << endl;
  }
}

Measured memory_bytes: 1400
/*===============================================================
*   Copyright (C) 2017 All rights reserved.
*   Filename：d.cpp
*   Author：  zhuyutian
*   Date：    2017.02.17
================================================================*/

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

typedef long long ll;
typedef unsigned long long ull;

const int N = 100005;

int n,T,a;

int main()
{
	scanf("%d%d",&n,&T);
	int ans=0;
	int mx=0,mi=0;
	for(int i = 0; i < n; i++)
	{
		scanf("%d",&a);
		if(i == 0 || a-mi < 0) mi=a;
		else if(a-mi>mx) 
		{
			ans=1;
			mx=a-mi;
		}
		else if(a - mi == mx) ans++;
	}
	printf("%d\n",ans);
    return 0;
}


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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool isprime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

struct CustomCompare
{
    bool operator()(const int& lhs, const int& rhs)
    {
        return lhs < rhs;
    }
};

bool comp(pair<ll, ll>a,pair<ll,ll>b)
{
    return a.fi>=b.fi;
}

ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}

ll addmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a+b)%mod;
}
ll mulmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll n; cin>>n;
ll ans = n +(n*n) + (n*n*n);
cout<<ans<<endl;
return 0;
}
/*
1
8
1 7 3 4 7 6 2 9
*/


Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N, M;

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

	cin >> N >> M;
	vector<pair<int, int>> G(M);

	int x, y;
	rep(i, 0, M)
	{
		cin >> x >> y;
		G[i] = make_pair(y, x);
	}

	sort(all(G));

	int ans = 0;
	int tr = 0;
	rep(i, 0, M)
	{
		if (G[i].second >= tr)
		{
			tr = G[i].first;
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
// ABC 169 A C++ ver.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
int main()
{
    int A, B;
    std::cin >> A >> B;
    cout << A * B << endl;
}


Measured memory_bytes: 3604
using System;

class Discover_A{
  static void Main(){
    int[] Ar = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    int O = 0;
    if (Ar[0] == 1) O += 300000;
    else if (Ar[0] == 2) O += 200000;
    else if (Ar[0] == 3) O += 100000;
    if (Ar[1] == 1) O += 300000;
    else if (Ar[1] == 2) O += 200000;
    else if (Ar[1] == 3) O += 100000;
    if (Ar[0] == 1 && Ar[1] == 1) O += 400000;
    Console.WriteLine(O);
  }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

int main(void){
	int a, b; cin >> a >> b;

	if(a + b == 15) cout << "+" << '\n';
	else if(a * b == 15) cout << "*" << '\n';
	else cout << "x" << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

long long N, K, L;
long long p[200005];
long long q[200005];
long long r[200005];
long long s[200005];


// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
	  // 最初は全てのデータiがグループiに存在するものとして初期化
	  for(int i = 0; i < n; i++){
		  par[i] = i;
	  }
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};

int main(){
	cin >> N >> K >> L;
	for(long long i = 0; i < K; i++){
		cin >> p[i] >> q[i];
		p[i]--;
		q[i]--;
	}
	for(long long i = 0; i < L; i++){
		cin >> r[i] >> s[i];
		r[i]--;
		s[i]--;
	}
	UnionFind uf(N);
	UnionFind uf2(N);
	UnionFind uf3(N);
	for(long long i = 0; i < K; i++){
		uf.unite(p[i], q[i]);
	}

	for(long long i = 0; i < L; i++){
		uf2.unite(r[i], s[i]);
	}

	map<pair<long long, long long>, long long> memo;

	for(long long i = 0; i < N; i++){
		memo[make_pair(uf.find(i), uf2.find(i))]++;
	}

	for(long long i = 0; i < N; i++){
		cout << memo[make_pair(uf.find(i), uf2.find(i))];
		if(i != N-1){
			cout << " ";
		}else{
			cout << endl;
		}
	}


}


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

using namespace std;

int main(void)
{
    string s, t;
    cin >> s;
    cin >> t;
    int n = s.size();

    int mas[26] = {}, mat[26] = {};
    bool f = true;
    for(int i = 0; i < n; i++)
    {
        if(mas[s[i] - 'a'])
        {
            if(mas[s[i] - 'a'] != (t[i] - 'a'))
            {
                f = false;
                break;
            }
        }
        else if(mat[t[i] - 'a'])
        {
            if(mat[t[i] - 'a'] != (s[i] - 'a'))
            {
                f = false;
                break;
            }
        }
        else
        {
            mas[s[i] - 'a'] = t[i] - 'a';
            mat[t[i] - 'a'] = s[i] - 'a';
        }
    }

    cout << (f ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n;
  cin>>n;
  pair<int,int> memo[n];
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    memo[i]=make_pair(a,i);
  }
  sort(memo,memo+n);
  for(int i=0;i<n;i++){
    cout<<memo[i].second+1;
    if(i!=n-1) cout<<' ';
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 1536
n,k = map(int,input().split())
lst = list(map(int,input().split()))

id_of_one = lst.index(1) #リスト内の最小値1のインデックスを取得

left = len(lst[0:id_of_one]) #1より左側にある数列の長さ
right = len(lst[id_of_one+1:]) #1より右側にある数列の長さ
total = left + right





counter = 0
while total > 0:
    counter += 1
    total -= k - 1

print(counter)

Measured memory_bytes: 13812
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
 
/* Coding Space*/
vector<ll> G[4];
int main(){
  ll n,w; cin >> n >> w;
  ll base;
  rep(i,n){
    ll w,v; cin >> w >> v;
    if(i == 0) base = w;
    G[w-base].pb(v);
  }
  rep(i,4){
    sort(ALL(G[i]),greater<ll>());
    G[i].insert(G[i].begin(),0);
    for(int j =1; j < G[i].size(); j++){
      G[i][j] += G[i][j-1];
    }
  }
  ll ans = 0;
  rep(i,G[0].size())
  rep(j,G[1].size())
  rep(k,G[2].size())
  rep(l,G[3].size()){
    if(i*base+j*(base+1)+k*(base+2)+l*(base+3) <= w)
      ans = max(ans,G[0][i]+G[1][j]+G[2][k]+G[3][l]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 998244353;

Int dp[100005][15];

int main() {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    Int n = (Int)s.size();
    dp[0][0] = 1;
    Int p = 1;
    for (Int i = 0; i < n; i++) {
        for (Int j = 0; j < 10; j++) {
            if (s[i] != '?' && s[i] != '0' + j) continue;
            Int d = (j * p) % 13;
            for (Int k = 0; k < 13; k++) {
                dp[i + 1][(k + d) % 13] += dp[i][k];
                dp[i + 1][(k + d) % 13] %= mod;
            }
        }
        p = (p * 10) % 13;
    }
    dump(dp[n][5]);
    return 0;
}

Measured memory_bytes: 12160
N,M=map(int,input().split())
ans=[0]*N
guess=0
num=0
S=[]
C=[]
for _ in range(M):
    s,c=map(int,input().split())
    S.append(s)
    C.append(c)
for i in range(M):
    s=S[i]
    c=C[i]
    if ans[s-1]!=0 and ans[s-1]!=c:
        guess=1
        break
    elif s==1 and c==0:
        if N!=1:
            guess=1
            break
    else:
        ans[s-1]=c
if guess==0:
    if ans[0]==0:
        if N!=1:
            ans[0]=1
    for i in range(N):
        num+=ans[i]*(10**(N-1-i))
    print(num)
else:
    print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll N;
    cin>>N;
    vector <ll> ans;
//    N--;
    while(N){
        ll rest=(N-1)%26;
        N--;
        N/=26;
        ans.push_back(rest);
    }
    ll len=ans.size();
    for(ll i=len-1;i>=0;i--){
        char c='a'+ans[i];
        cout<<c;
    }
    return 0;
}


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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
const lli I_MAX = 1LL << 60;
const lli mod = 1000000007;


void solve() {
	lli n, m, q, k;
	cin >> n;

	if ( n%10 == 1 ) n += 8;
	else if ( n%10 == 9 ) n -= 8;
	
	if ( (n/10)%10 == 1 ) n += 80;
	else if ( (n/10)%10 == 9 ) n -= 80;
	
	if ( n/100 == 1 ) n += 800;
	else if ( n/100 == 9 ) n -= 800;
	
	cout << n << '\n';
}

int main() {
	int t = 1;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}


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

#define ll long long
#define ld long double

using namespace std;
const long long LINF = LLONG_MAX;
const int INF = INT_MAX;
const int MOD = 1000000007;

const int N = 2e5 + 111;

int dp[2][2019];

int main() {
    ios::sync_with_stdio(false);
    string s;
    vector<string> a;
    cin >> s;
    int n = s.size();
    ll ans = 0;
    dp[0][s[0] - '0']++;
    for (int i = 1; i < n; i++){
        for (int j = 0; j < 2019; j++){
            int nxt = (10 * j + (s[i] - '0')) % 2019;
            dp[1][(10 * j + (s[i] - '0')) % 2019] = dp[0][j];
        }
        dp[1][(s[i] - '0') % 2019]++;
        ans += dp[1][0];
        swap(dp[0], dp[1]);
    }
    cout << ans;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
int main()
{
          long long int a,b,n,c,d=0;
          cin>>n>>c;
          for(int i=0;i<n;i++)
          {
                    cin>>a>>b;
          if(a*a+b*b<=c*c)
                    d++;
          }
          cout<<d<<endl;
return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,k;
    int a[10005];
    for(i=0;i<=10000;i++){
        a[i]=0;
    }
    for(i=1;i<=100;i++){
        for(j=1;j<=100;j++){
            for(k=1;k<=100;k++){
                if(i*i+j*j+k*k+i*j+i*k+j*k<=10000)
                  a[i*i+j*j+k*k+i*j+j*k+k*i]++;
            }
        }
    }
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        printf("%d\n",a[i]);
    }
    return 0;
}


Measured memory_bytes: 3880
import collections
N = int(input())
lsA = list(map(int,input().split()))
counterA = collections.Counter(lsA)
ans = 0
for X in range(1,10**5+1):
    b1 = counterA[X-1]
    b2 = counterA[X]
    b3 = counterA[X+1]
    ans = max(ans,sum([b1,b2,b3]))
print(ans)

Measured memory_bytes: 21016
#include <bits/stdc++.h>
using namespace std;
#define pai 3.141592653589793

int main(){
    long double a,b,x,ans;
    cin >> a >> b >> x;
    if(x/(a*a)>=b/2){
        ans = atan(2*((b/a)-(x/(a*a*a))));
    }
    else{
        ans = atan(b*b*a/(2*x));
    }
    cout << setprecision(10) << ans*180.0/pai << endl;
}


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

int main() {
    int s;
    cin >> s;
    unordered_set<int> st;
    int a = s;
    for (int i = 1; i <= 1000000; i++) {
        if (st.find(a) != st.end()) {
            cout << i << endl;
            return 0;
        }
        st.insert(a);
        a = (a & 1) ? (3 * a + 1) : (a >> 1);
    }
    return 0;
}


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

int knapsack(int wt[], int val[], int n, int W)
{
    if(n==0) return 0;
    if(W==0) return 0;

    if(wt[n-1]<=W)
    {
        int take=val[n-1]+knapsack(wt,val,n-1,W-wt[n-1]);
        int nott=knapsack(wt,val,n-1,W);
        return max(take, nott);
    }
    else
    {
        return knapsack(wt,val,n-1,W);
    }

}

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

        int n,i,j,k,W; cin>>n>>W;
        int wt[n],val[n];
        for(i=0;i<n;i++) {
                cin>>wt[i]>>val[i];
        }

        //cout<<knapsack(wt,val,n,W);


        int dp[n+1][W+1];
        memset(dp,0,sizeof(dp));

        for(i=1;i<=n;i++)
        {

            for(j=1;j<=W;j++)
            {
                if(j-wt[i-1]>=0)
                {
                    dp[i][j] = max(dp[i-1][j], val[i-1]+dp[i-1][j-wt[i-1]]);
                }
                else
                    dp[i][j]=dp[i-1][j];

            }

        }

//        for(i=0;i<=n;i++)
//        {
//            for(j=0;j<=W;j++)
//            {
//                cout<<dp[i][j]<<"  ";
//            }
//            cout<<endl;
//        }


        cout<<dp[n][W];

    return 0;
}



Measured memory_bytes: 79232
#include<stdio.h>

int main(void){
    int i,j,b;
    int trump[4][13] = {};
    char suit[2],a;
    int  num,number;

    scanf("%d",&num);

    for(i = 0; i < num; i++){
        scanf("%s %d",suit,&number);

        switch(suit[0]){
            case 'S':
                b = 0;
                break;
            case 'H':
                b = 1;
                break;
            case 'C':
                b = 2;
                break;
            case 'D':
                b = 3;
                break;
        }
        trump[b][number-1] =  1;
    }


    for(i = 0; i < 4; i++){
        for(j = 0; j < 13; j++){
            if(trump[i][j] != 1){

                switch(i){
                    case 0:
                        a = 'S';
                        break;
                    case 1:
                        a = 'H';
                        break;
                    case 2:
                        a = 'C';
                        break;
                    case 3:
                        a = 'D';
                        break;
                }
                printf("%c %d\n",a, j+1);
            }
 }
    }
    return 0;
}

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

red_points = [[int(i) for i in input().split()] for j in range(N)]

blue_points = [[int(i) for i in input().split()] for j in range(N)]

red_points.sort()
blue_points.sort()
count = 0
distance = 9999
for blue_point in blue_points:
    tmp = [i for i in red_points if blue_point[0] > i[0] and blue_point[1] > i[1]]
    if tmp:
        for j in tmp:
            if (blue_point[1] - j[1]) < distance:
                distance = blue_point[1] - j[1]
                min_red = j
        count = count + 1
        red_points.remove(min_red)
        distance = 9999

print(count)

Measured memory_bytes: 3064
// F.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;
typedef long long LL;
typedef pair<int, int> II;

int n, a, b, c;
vector<int> h;
vector<int> ans;

bool dfs(int d, int a, int b, int c) {
	if (d == n) {
		return true;
	}
	if ((h[d] & 1) != 0 && a > 0) {
		if (h[d] & 2) {
			ans[d] = 1;
			if (dfs(d + 1, a - 1, b + 1, c)) {
				return true;
			}
		}
		if (h[d] & 4) {
			ans[d] = 2;
			if (dfs(d + 1, a - 1, b, c + 1)) {
				return true;
			}
		}
	}
	if ((h[d] & 2) != 0 && b > 0) {
		if (h[d] & 1) {
			ans[d] = 0;
			if (dfs(d + 1, a + 1, b - 1, c)) {
				return true;
			}
		}
		if (h[d] & 4) {
			ans[d] = 2;
			if (dfs(d + 1, a, b - 1, c + 1)) {
				return true;
			}
		}
	}
	if ((h[d] & 4) != 0 && c > 0) {
		if (h[d] & 1) {
			ans[d] = 0;
			if (dfs(d + 1, a + 1, b, c - 1)) {
				return true;
			}
		}
		if (h[d] & 4) {
			ans[d] = 1;
			if (dfs(d + 1, a, b + 1, c - 1)) {
				return true;
			}
		}
	}
	return false;
}

int main(int argc, char* argv[]) {
	cout.precision(20);
#ifdef _MSC_VER
	while (true)
#endif
	{
		n = -1;
		cin >> n >> a >> b >> c;
		if (n < 0) return 0;
		h.resize(n);
		ans.resize(n);
		for (int i = 0; i < n; ++i) {
			string s;
			cin >> s;
			if (s == "AB") {
				h[i] = 3;
			}
			if (s == "AC") {
				h[i] = 5;
			}
			if (s == "BC") {
				h[i] = 6;
			}
		}
		if (dfs(0, a, b, c)) {
			cout << "Yes" << endl;
			for (int j = 0; j < n; ++j) {
				cout << (char('A' + ans[j])) << endl;
			}
		} else {
			cout << "No" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 11896
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#define ll long long
using namespace std;

const int N=100005;

int n,m,t,pos,cnt;
ll k;
double ans;
int x[N],a[N],p[N],f[N],b[N];
bool vis[N];

int main(){
	int i,j;
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&x[i]);
	for (i=n;i>=1;i--) x[i]-=x[i-1];
	for (i=1;i<=n;i++) p[i]=i;
	scanf("%d%lld",&m,&k);
	for (i=1;i<=m;i++) scanf("%d",&a[i]);
	for (i=1;i<=m;i++) swap(p[a[i]],p[a[i]+1]);
	for (i=1;i<=n;i++) if (!vis[i]){
		pos=i; cnt=0;
		a[cnt]=i;
		while (p[pos]!=i){
			pos=p[pos];
			a[++cnt]=pos;
		}
		f[i]=a[k%(cnt+1)];
		for (j=1;j<=cnt;j++) f[a[j]]=p[f[a[j-1]]];
		for (j=0;j<=cnt;j++) vis[a[j]]=1;
	}
	for (i=1;i<=n;i++){
		ans+=(double)x[f[i]];
		printf("%.1f\n",ans);
	}
	return 0;
}

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

int main()
{
    // freopen("E:\Sublime Text 3\input.txt","r",stdin);
    // freopen("E:\Sublime Text 3\output.txt","w",stdout);
    ll x;
    cin>>x;
	ll r=x%11;
	ll ans=(x/11)*2;

	if(!r)
		cout<<ans<<endl;
	else
	{
    	if(r<=6)
    		ans++;
    	else
    		ans+=2;

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

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

int main() {
  int N;
  cin >> N;
  int X = 0;
  for (int i=0;i<N;i++){
    int l;
    int r;
    cin >> l >> r;
    X+=r-l+1;
  }
  cout << X << endl;
}


Measured memory_bytes: 3640
from sys import stdin
import bisect

sysin=stdin.readline

N,M,K=[int(x) for x in sysin().rstrip().split()]
a=[int(x) for x in sysin().rstrip().split()]
b=[int(x) for x in sysin().rstrip().split()]

# N,M=3,4
# K=240
# a=[60, 90, 120]
# b=[80, 150, 80, 150]

ans=0

accum_a=[0]
for i in a:
    _a=accum_a[-1]+i
    if _a>K:
        break
    else:
        accum_a.append(_a)
accum_a.append(K)

accum_b=[0]
for i in b:
    accum_b.append(accum_b[-1]+i)

ans=0

for j in range (len(accum_a)-1):
    Kb=K-accum_a[j]
    bookB=bisect.bisect_right(accum_b,Kb)-1
    if j+bookB>ans:
        ans=j+bookB
    else:
        pass

print(ans)

Measured memory_bytes: 42524
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N = 0; cin >> N;
  vector<ll> INL(N);
  REP(i, N) cin >> INL[i];
  ll sm = accumulate(INL.begin(), INL.end(), 0LL);
  cout << (sm - N) << endl;
  return 0;
}


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

int n, k;
string s;
stack<int> st;
int main() {
	int i, j, fl;
	cin >> n >> k >> s;
	for(i=n; i; ) {
		fl = 0;
		for(j=min(i, k); j; j--) {
			if(s[i-j] == '0') {
				i -= j;
				st.push(j);
				fl = 1;
				break;
			}
		}
		if(!fl) return puts("-1")*0;
	}
	while(!st.empty()) printf("%d ", st.top()), st.pop();
	return 0;
}

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

#define INF 1e9
#define PI 3.141592653589793238
#define N 1000000010
#define mod 1000000007
#define REP(inc, bgn, end) for(int inc=bgn; inc<end; inc++)
typedef long long ll;

int main() {
    ll A,B,K; cin>>A>>B>>K;
    if(A+B<=K) cout<<0<<" "<<0<<endl;
    else if(A<=K) cout<<0<<" "<<A+B-K<<endl;
    else cout<<A-K<<" "<<B<<endl;

    return 0;
}

Measured memory_bytes: 3560
/*input
4 5
1 2
3 4
1 3
2 3
1 4
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int dsu[maxn];
ll sz[maxn];
ll cur=0;

int find(int u){
	if(dsu[u]==u) return u;
	return dsu[u]=find(dsu[u]);
}
void mrg(int u,int v){
	u=find(u);
	v=find(v);
	if(u==v) return;
	if(sz[u]<sz[v]) swap(u,v);
	cur-=sz[u]*sz[v];
	dsu[v]=u;
	sz[u]+=sz[v];
}


vector<ll> ans;
int u[maxn],v[maxn];
int main()
{
	IOS;
	ll n,m;
	cin>>n>>m;
	REP(i,m){
		cin>>u[i]>>v[i];
		u[i]--;v[i]--;
	}
	REP(i,n) dsu[i]=i,sz[i]=1;

	cur=n*(n-1)/2;

	for(int i=m-1;i>=0;i--){
		ans.pb(cur);
		mrg(u[i],v[i]);
	}
	reverse(ALL(ans));
	for(ll i:ans) cout<<i<<'\n';
	return 0;
}


Measured memory_bytes: 5492
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int num[] = new int[3];
    int sev = 0;
    int fiv = 0;

    String ans;
    
    for(int i = 0 ; i < 3 ; ++i){
      num[i] = sc.nextInt();
      if(num[i]==7) sev++;
      else if(num[i]==5) fiv++;
    }
    
    if(sev==1&&fiv==2) ans = "YES";
    else ans = "NO";
    System.out.println(ans);
    
  }
}

Measured memory_bytes: 35684
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};

int main()
{
  string str;
  string str1;
  int ans = 0;
  while(cin >>str){
    str1 = str;
    reverse(str.begin(), str.end());
    if(str1 ==str){
      ans++;
    }
  }
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 1196
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
def f():
 for i in range(n-1):
  d=a[i][:];d[3],d[4]=d[4],d[3]
  for j in range(i+1,n):
   e=a[j][:];e[3],e[4]=e[4],e[3]
   for p in('012345','152043','215304','302541','410352','514320'):
    f=[d[int(k)]for k in p]
    g=f[1:5]*2
    for k in range(4):
     if(g[k:k+4]==e[1:5])*(f[0]==e[0])*(f[5]==e[5]):return 'No'
 return 'Yes'
print(f())


Measured memory_bytes: 5608
#include<iostream>
#define G 1
#define C 2
#define P 3
#define N 5
using namespace std;

int a[N];

void calc() {

  int g,c,p;

  g=0;
  c=0;
  p=0;

  for ( int i=0; i<N; i++ ) {
    if ( a[i] == G )
      g = 1;
    if ( a[i] == C )
      c = 1;
    if ( a[i] == P )
      p = 1;
  }

  for ( int i=0; i<N; i++ ) {
    if ( ((g == c) && (c == p)) || (g && c && p) ) {
      cout << 3 << endl;
    } else {
      if ( g == 1 ) {
	if ( a[i] == G ) {
	  if ( c == 1 )
	    cout << 1 << endl;
	  else if ( p == 1 ) 
	    cout << 2 << endl;
	  else
	    cout << 3 << endl;
	}
	if ( a[i] == C ) {
	  cout << 2 << endl;
	}
	if ( a[i] == P ) {
	  cout << 1 << endl;
	}
      } else if ( c == 1 ) {
	if ( a[i] == G ) {
	  cout << 1 << endl;
	}
	if ( a[i] == C ) {
	  if ( g == 1 )
	    cout << 2 << endl;
	  else if ( p == 1 ) 
	    cout << 1 << endl;
	  else
	    cout << 3 << endl;
	}
	if ( a[i] == P ) {
	  cout << 2 << endl;
	}

      } else if ( p == 1 ) {
	if ( a[i] == G ) {
	  cout << 1 << endl;
	}
	if ( a[i] == C ) {
	  cout << 2 << endl;
	}
	if ( a[i] == P ) {
	  if ( g == 1 ) 
	    cout << 1 << endl;
	  else if ( c == 1 )
	    cout << 2 << endl;
	  else
	    cout << 3 << endl;
	}
      }
    }
  }
}

int main () {
  
  while ( true ) {
    bool skip = false;
    for ( int i=0; i<N; i++ ) {
      cin >> a[i];
      if ( a[i] == 0 ) {
	return 0;

      }

    }

    if ( a == 0 )
      break;

    calc();
  }
}
    

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n>=400 and n<=599)
    {
        cout<<8<<endl;
    }
    if(n>=600 and n<=799)
    {
        cout<<7<<endl;
    }
    if(n>=800 and n<=999)
    {
        cout<<6<<endl;
    }
    if(n>=1000 and n<=1199)
    {
        cout<<5<<endl;
    }
    if(n>=1200 and n<=1399)
    {
        cout<<4<<endl;
    }
    if(n>=1400 and n<=1599)
    {
        cout<<3<<endl;
    }
    if(n>=1600 and n<=1799)
    {
        cout<<2<<endl;
    }
    if(n>=1800 and n<=19999)
    {
        cout<<1<<endl;
    }

    return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    ll n;
    string s;
    cin >> n >> s;
    ll a[3] = {0,0,0};
    for (int i = 0;i < n;++i) {
        if (s[i] == 'R') a[0]++;
        else if (s[i] == 'G') a[1]++;
        else a[2]++;
    }
    ll ans = a[0]*a[1]*a[2];
    for (int i = 1;i < n;++i) {
        for (int j = 0;j < n;++j) {
            if (j+i+i >= n) break;
            if (s[j] != s[j+i] && s[j+i] != s[j+i+i] && s[j] != s[j+i+i]) ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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

using ll = long long;
using namespace std;
// cout << fixed << setprecision(10）<<  << endl;

vector<pair<ll,ll>> prime(ll n) {
    vector<pair<ll,ll>> res;
    for (int i = 2; i * i <= n; i++) {
        if (n % i != 0) continue;
        ll count = 0;
        while (n % i == 0) { count++; n /= i; }
        res.push_back(make_pair(i,count));
    }
    if(n != 1) res.push_back(make_pair(n,1));
    return res;
}

int main() {
    ll n; cin >> n;
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        auto p = prime(n - i);
        ll count = 1;
        rep(j,(int)p.size()) count *= (p[j].second + 1);
        ans += count;
    }
    cout << ans << endl;
    return 0;
}

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


int main(){
    int a,b;cin>>a>>b;

    if(a > 0 && b > 0){
        cout<<"Positive\n";
    }else if(a <= 0 && b >= 0){
        cout<<"Zero\n";
    }else{
        if(b-a==1)
            cout<<"Positive\n";
        else if((a+b)%2==0)
            cout<<"Negative\n";
        else
            cout<<"Positive\n";
    }
    return 0;
}


Measured memory_bytes: 256
#coding:UTF-8
def Queue(n,q,B):
    ans=[]
    ftime=0
    while len(B)>0:
        name=B[0].split(" ")[0]
        time=int(B[0].split(" ")[1])
        if time>q:
            ftime+=q
            newB=name+" "+str(time-q)
            B.append(newB)
            B.pop(0)
        else :
            ans.append(name+" "+str(ftime+time))
            B.pop(0)
            ftime+=time
    for i in range(n): 
        print(ans[i])
        
  
if __name__=="__main__":
    a=input()
    n=int(a.split(" ")[0])
    q=int(a.split(" ")[1])
    B=[]
    for i in range(n):
        B.append(input())
    Queue(n,q,B)

Measured memory_bytes: 11800
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

long long calc(int num)
{
    long long ans = num;
    --num;
    while (num != 0) {
        ans *= num;
        ans %= MOD;
        --num;
    }
    return ans;
}

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

    long long ans;
    if (abs(N-M) > 1)
        ans = 0ll;
    else if (N == M)
        ans = ((calc(N) % MOD) * (calc(M) % MOD) * 2) % MOD;
    else
        ans = (calc(N) * calc(M)) % MOD;

    cout << ans << endl;
}

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


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

        while (true)
        {
            if (tmp % 2 == 0)
            {
                tmp /= 2;
                li[i - 1]++;
            }
            else
            {
                break;
            }
        }
    }
    
    int max_i, max = -1;
    for (int i = 1; i <= n; i++)
    {
        if (li[i - 1] > max)
        {
            max = li[i - 1];
            max_i = i;
        }
    }

    cout << max_i << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner kb = new Scanner( System.in);	
		
		while( true ) {
			int H = kb.nextInt();
			int W = kb.nextInt();
			
			if( 0==W && 0==H ) { break; }
			
			for( int i=0; i<H; i++ ) {
				for( int j=0; j<W; j++ ) {
					if( 0==i || H-1==i || 0==j || W-1==j ) {
						System.out.print( "#" );
					} else {
						System.out.print( "." );
					}
				}
				System.out.print( "\n" );
			}
			System.out.print( "\n" );
		}
	}
}

Measured memory_bytes: 29596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    cin>>N;
    vector<pair<string,int>> st(N);
    rep(i,N) {
        string s;
        int t;
        cin>>s>>t;
        st[i]=make_pair(s,t);
    }
    string X;
    cin>>X;
    int total=0;
    rep(i,N) {
        total+=st[i].se;
    }
    int wake=0;
    int point;
    rep(i,N) {
        if(st[i].fi==X) {
            point=i;
            break;
        }
        wake+=st[i].se;
    }
    wake+=st[point].se;
    int answer=total-wake;
    cout<<answer<<endl;
}

Measured memory_bytes: 256
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  unsigned int c,x,y;
  for(;;){
    cin>>x>>y;
    if(x+y==0)
      break;
    if(x<y)
      swap(x,y);
    for(c=0;y;c++){
      x%=y;
      swap(x,y);
    }
    cout<<x<<" "<<c<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

struct CSF{
    int C;
    int S;
    int F;
};

int main(){
    int N;
    cin >> N;
    vector<CSF> x(N-1);
    for (int i = 0; i < N-1; i++) {
        cin >> x[i].C >> x[i].S >> x[i].F;
    }
    int t;
    for (int i = 0; i < N; i++) {
        t = 0;
        for (int j = i; j < N-1; j++) {
            if(t <= x[j].S){
                t = x[j].S + x[j].C;
            }
            else{
                t = (1 + (t-1)/x[j].F) * x[j].F + x[j].C;
            }
        }
        printf("%d\n", t);
    }

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cassert>
#include<cmath>
#define ll long long
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n,a[110],now[110];
int main(){
	n=read();int i,maxn=0,cnt=0;
	for(i=1;i<=n;i++) a[i]=read(),maxn=max(maxn,a[i]),now[a[i]]++;
	if(maxn%2){
		for(i=maxn/2+1;i<=maxn;i++){
			if(now[i]<2){
				puts("Impossible");return 0;
			}
		}
		now[maxn/2+1]-=2;
		for(i=0;i<=maxn/2+1;i++){
			if(now[i]){
				puts("Impossible");return 0;
			}
		}
		puts("Possible");
	}
	else{
		if(!now[maxn/2]){
			puts("Impossible");return 0;
		}
		now[maxn/2]--; 
		for(i=maxn/2+1;i<=maxn;i++){
			if(now[i]<2){
				puts("Impossible");return 0;
			}
		}
		for(i=0;i<=maxn/2;i++){
			if(now[i]){
				puts("Impossible");return 0;
			}
		}
		puts("Possible");
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;
ll const MAXVAL = 1e6;

int main() {
  ll n;
  cin >> n;
  ll ans = 0;

  reps1(i, n) ans += (n-1) / i;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3568
# Your code here!

n, a = gets.chomp.split(" ").map(&:to_i)
k = gets.chomp.split(" ").map(&:to_i)
j = k.sort.reverse
all = 0
(1..n).each do |i|
    all += k[i-1]
end
count =0
N = (all.to_f / (4 * a.to_f)).ceil

(0..a-1).each do |d|
    if j[d] >= N
        count += 1
    end
end
if a == count.to_i
    puts "Yes"
else
    puts "No"
end


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

int main() {
    char str;
    cin >> str;
    if(str == 'a' || str == 'e' || str == 'i' || str == 'o' || str == 'u') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
}


Measured memory_bytes: 256