akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>   
int main(void) 
{     
	int n,b;     
	scanf("%d",&n);
	int a[101];
	for(b=0;b<n;b++){
		scanf("%d",&a[b]);     
	}     
		while(1){         
			if(b==1){
				break;
			}         
		printf("%d ",a[b-1]);         
		b=b-1;               
		}     
		printf("%d\n",a[b-1]);     
	return 0; 
} 





	

Measured memory_bytes: 596
using System;

class Program
{
    static void Main()
    {
        int sum = 0;
        while (true)
        {
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int x = int.Parse(s[1]);
            if (n == 0 && x == 0)
                break;
            else
            {
                for(int i =1;i<=n;i++)
                {
                    for (int j = i+1; j<=n;j++ )
                    {
                        for (int k = j+1; k<=n; k++)
                        {
                            if (i + j + k == x)
                                sum += 1;
                        }
                    }
                }
            }
            Console.WriteLine(sum);
            sum = 0;
        }
    }
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  int A = read(), B = read();
  print((A * B) - (A + B - 1));
}


Measured memory_bytes: 256
import kotlin.math.abs

fun main(args: Array<String>) {
    val (n, m) = readIntList()
    val st = List(n) { readLongList() }
    val pt = List(m) { readLongList() }

    st.forEach { (a, b) ->
        var min = abs(a - pt[0][0]) + abs(b - pt[0][1])
        var ans = 0
        for (i in 1 until m) {
            val k = abs(a - pt[i][0]) + abs(b - pt[i][1])
            if (k < min) {
                min = k
                ans = i
            }
        }
        println(ans + 1)
    }
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	double X;
	cin >> X;
	ll money = 100;
	int ans = 0;
	while (money<X) {
		money *= 1.01;
		ans++;
	}
	ce(ans)
    return 0;
}



Measured memory_bytes: 3724
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n), b(n), c(n - 1);
    for(int i = 0; i < n; ++i){
        cin >> a.at(i);
        a.at(i)--;
    }
    for(int i = 0; i < n; ++i){
        cin >> b.at(i);
    }
    for(int i = 0; i < n - 1; ++i){
        cin >> c.at(i);
    }
    ll ans = 0;
    for(int i = 0; i < n; ++i){
        ans += b.at(a.at(i));
        if(i > 0 && a.at(i) == (a.at(i - 1) + 1)){
            ans += c.at(a.at(i - 1));
        }
    }
    cout << ans << endl;
    return 0;
}

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


using namespace std;

#define pb push_back
const int maxi=1e6;
int a[maxi];
string s;
int n;
vector<long long> v[maxi];
int k;
int c[1000][1000];
pair<int,int> skup[maxi];
int ob[maxi];
int par,nep;
int dp[1000][1000];

void dfs(int x, int pa)
{
    if (pa==1) par++; else
    nep++;
    ob[x]=1;

   for (int i=1;i<=n;i++)
    if (!c[i][x] && !ob[i]) dfs(i,1-pa);

  return;
}

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

    for (int i=1;i<=m;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        v[x].pb(y);
        v[y].pb(x);
        c[x][y]=1;
        c[y][x]=1;
    }

    for (int i=1;i<=n;i++)
        for (int j=i+1;j<=n;j++)
        for (int k=j+1;k<=n;k++)
        if (c[i][j]+c[j][k]+c[i][k]==0) return !printf("-1\n");


   int tot=0;

    for (int i=1;i<=n;i++)
        if (!ob[i])
    {
        par=0;
        nep=0;
        dfs(i,0);
        tot++;
        skup[tot]={par,nep};
    }

   dp[0][0]=1;

    for (int j=0;j<=tot;j++){
    for (int i=0;i<=n;i++)
    {
        int val1=skup[j].first;
        int val2=skup[j].second;
        int num1=0;
        if (val1<=i) num1=dp[j-1][i-val1];
        int num2=0;
        if (val2<=i) num2=dp[j-1][i-val2];
        dp[j][i]=max(dp[j][i],max(num1,num2));
     }
    }

    for (int i=n/2;i>=0;i--){
        if (dp[tot][i]) return !printf("%d\n",(i*(i-1))/2+((n-i)*(n-i-1))/2);
    }

  // printf("-1\n");
    return 0;
}



Measured memory_bytes: 41088
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

int main() {
    ll a;
    double b;
    cin >> a >> b;
    ll seisu = -1;
    double c = b;
    while (c > 0) {
        c = c - 1.00;
        seisu++;
    }
    double shousu = b - seisu;
    // cout << seisu << " " << shousu << endl;

    ll res = a * seisu;
  	ll kakeru = ll(shousu*100 + 0.5);
    ll ss = kakeru * a;
    ss /= 100;
    cout << res + ss << endl;
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int rectangle=0, lozenge=0;
    while(true){
        int a, b, c;
        if(!(cin>>a)) break;
        cin.ignore();
        cin>>b;
        cin.ignore();
        cin>>c;
        if(a==b) ++lozenge;
        else if(a*a+b*b==c*c) ++rectangle;
    }
    cout<<rectangle<<'\n'<<lozenge<<'\n';
    return 0;
}

Measured memory_bytes: 3012
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define inf 1e16
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 200010
ll dp[M][4];
	string s;
ll go(ll x,ll k){
	if(x==s.size())return 0;
	ll n=s.size();
	ll ans=-inf;
	ll i=0;
	if(dp[x][k]!=-1)return dp[x][k];
	if(k==0){
	for(i=1;i<=3;++i){
		if(x+i-1<n){
			ans=max(ans,1+go(x+i,i));
		}
	
	}
	}
	for(i=1;i<=3;++i){
		if(x+i-1<n&&s.substr(x-k,k)!=s.substr(x,i)){
			ans=max(ans,1+go(x+i,i));
		}
	}return dp[x][k]=ans;
	
	
	
}
int main(){
	IOS;
	cin>>s;
	memset(dp,-1,sizeof(dp));
	ll p=go(0,0);
	cout<<p<<"\n";
}



Measured memory_bytes: 33940
unittest
{
	assert( [ "2" ].parse.expand.solve == 3 );
	assert( [ "4" ].parse.expand.solve == 7 );
	assert( [ "1000000000000" ].parse.expand.solve == 1099511627775 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto h = input.front.to!( long );
	return tuple( h );
}

long solve( long h )
{
	if( h == 0 ) return 0L;
	else         return 1L + solve( h / 2 ) * 2;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

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

    vector<vector<int>> yearRanks;
    rep(i, N) {
        vector<int> yearRank;
        yearRanks.pb(yearRank);
    }

    vector<P> input;
    rep(i, M) {
        int Pi, Yi;
        cin >> Pi >> Yi;
        input.pb(make_pair(Pi, Yi));
        yearRanks[Pi - 1].pb(Yi);
    }

    // sort and create map
    map<int, int> rankMap; //  key: year, value: rank
    rep(i, N) {
        sort(all(yearRanks[i]));
        int rank = 1;
        for(int year : yearRanks[i]) {
            rankMap.insert(make_pair(year, rank));
            rank++;
        }
    }

    rep(i, M) {
        int p = input[i]._1;
        int y = input[i]._2;
        int rank = rankMap.at(y);

        cout << setfill('0') << setw(6) << right << p;
        cout << setfill('0') << setw(6) << right << rank;
        cout << endl;
    }
}


Measured memory_bytes: 13160
H,W=list(map(int,input().split()))
A=[]
for h in range(H):
    A.append(list(input()))

B=[]
for h in range(H):
    if '#' in A[h]:
        B.append(A[h])

C=[]
for w in range(W):
    C.append([])

for h in range(len(B)):
    for w in range(W):
        C[w].append(B[h][w])

D=[]
for h in range(len(C)):
    if '#' in C[h]:
        D.append(C[h])

E=[]
for w in range(W):
    E.append([])

for h in range(len(D)):
    for w in range(len(D[h])):
        E[w].append(D[h][w])

for h in range(len(E)):
    print("".join(E[h]))

Measured memory_bytes: 3316
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
int main(){
    long long a,s,t,z=0;
    cin>>a;
    long long k[a]={0};
    map<long long,long long>g;
    for(int i=0;i<a;i++){
        cin>>s;
        if(g.find(s)==g.end()){
            k[z]=s;
            z+=1;
            g[s]=1;
        }
        else g[s]+=1;
    }
    sort(k,k+z);
    t=0;
    s=0;
    for(int i=0;i<z;i++){
        if(g[k[i]]/4>=1){
            t=k[i];
            s=k[i];
        }
        else if(g[k[i]]/2>=1){
            s=t;
            t=k[i];
        }
    }
    if(s==0){
        cout<<"0"<<endl;
    }
    else cout<<t*s<<endl;
}


Measured memory_bytes: 7296
N,M=gets.split.map(&:to_i)
E=Array.new(N+1){[]}
l=[]
M.times{
	a,b=gets.split.map(&:to_i)
	E[a] << b
	E[b] << a
	l << [a,b]
}
c=0
l.each{|e|
	s=e[0]
	f=Array.new(N+1){false}
	f[s]=true
	q=[]
	E[s].each{|x|
		next if x==e[1]
		q.push(x)
	}
	until q.empty?
		n=q.shift
		next if f[n]
		f[n]=true
		break if n==e[1]
		E[n].each{|x|
			next if f[x]
			q.push(x)
		}
	end
	#warn e.inspect
	#warn f.inspect
	if !f[e[1]]
		c+=1
	end
}
puts c


Measured memory_bytes: 14376
n = int(input())
numbers = [int(x) for x in input().split()]
flag = 'APPROVED'
for number in numbers:
  if number%2==0 and (number % 3 == 0 or number % 5 == 0):
    continue
  elif number%2 != 0: continue
  else:
      flag = 'DENIED'
      break
print(flag)


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

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

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

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


signed main(void) {
    int n,t,q;
    cin >> n >> t >> q;
    vi a(n),d(n);
    vector<vi> x(2);
    rep(i,n){
        cin >> a[i] >> d[i];
        d[i]--;
        x[d[i]].push_back(a[i]);
    }
    while(q--){
        int ind;
        cin >> ind;
        ind--;
        if(d[ind]){//西、a[ind]より小さいx[0]の最大
            int p = lower_bound(all(x[0]), a[ind]) - x[0].begin();
            p--;
            if(p < 0){
                cout << a[ind]-t << endl;
            }else{
                //pと衝突する人（ x[0][p]より大きい最小のx[1]）をさがす
                int q = lower_bound(all(x[1]),x[0][p]) - x[1].begin();
                int r = (x[0][p]+x[1][q])/2;//a[ind]が立ち止まる地点
                if(abs(a[ind]-r) <= t)cout << r << endl;
                else cout << a[ind]-t << endl;
            }
        }else{//a[ind]より大きいx[1]の最小
            int p = upper_bound(all(x[1]), a[ind]) - x[1].begin();
            if(p == x[1].size()){
                cout << a[ind]+t << endl;
            }else{
                //pと衝突する人（ x[1][p]より小さい最大のx[0]）をさがす
                int q = lower_bound(all(x[0]),x[1][p]) - x[0].begin();
                q--;
                int r = (x[1][p]+x[0][q])/2;//a[ind]が立ち止まる地点
                if(abs(a[ind]-r) <= t)cout << r << endl;
                else cout << a[ind]+t << endl;
            }
        }
    }
}



Measured memory_bytes: 5400
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

ll N, M, R;
vector<ll> r;
vector<ll> g[300];
ll dist[300][300];

ll dp[1 << 8][300];

// s -> all, v -> now
ll bitdfs(ll s, ll v){
	if(dp[s][v] >= 0) return dp[s][v];

	if(s == (1 << R) -1){
		return dp[s][v] = 0;
	}

	ll res = LLINF;
	rep(i, r.size()){
		ll u = r[i];
		if(!(s >> i & 1)) {
			res = min(bitdfs(s | 1 << i, u) + dist[v][u], res);
		}
	}

	return dp[s][v] = res;
}

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	cin >> N >> M >> R;
	r.resize(R);
	rep(i, R) {
		ll a; cin >> a;
		a--;
		r[i] = a;
	}

	rep(i, 300){
		fill(dist[i], dist[i]+300, LLINF);
	}
	rep(i, 300){
		dist[i][i] = 0;
	}


	rep(i, M){
		ll a, b, c; cin >> a >> b >> c;
		a--; b--;
		g[a].push_back(c);
		g[b].push_back(c);
		dist[a][b] = c;
		dist[b][a] = c;
	}

	rep(k, N){
		rep(i, N){
			rep(j, N){
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}


	ll ans = LLINF;
	rep(i, R){
		memr(dp, -1);
		ans = min(ans, bitdfs(0, r[i]));
	}


	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2048
#include <cstdio>
using namespace std;
int n,m,a,s;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;++i){
		scanf("%d",&a);
		s+=a;
	}
	if(n<s)printf("-1\n");
	else printf("%d\n",n-s);
	return 0;
}



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

int main(){

  int N,K=0;
  cin>>K>>N;
  
  int A[N];
  int dis[N];
  rep(i,N){
    cin>>A[i];
    if(i==0)continue;
    dis[i-1]=A[i]-A[i-1];
  }
  dis[N-1]=A[0]+K-A[N-1];
  
  int n = sizeof(dis) / sizeof(dis[0]); 
  

  int max=*max_element(dis, dis + n);
  
  cout<<K-max<<endl;


}

Measured memory_bytes: 1792
#include <bits/stdc++.h>  
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
#define REP(i, a, n, op) for(int i=a; i<(int)(n); op ## op ## i)
#define cout(val) cout << val << endl

using namespace std;  

int main(){
    long long int x, p = 100;
    int count = 0;
    cin >> x;
    while(x > p){
        p *= 1.01;
        count++;
    }
    cout(count);
}


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

int col(int n){
    if(n%2 ==0){
        return (n/2);
    }
    else{
        return (3*n+1);
    }
}

int main() {
    int s;
    cin >>s;
    vector<int> S(1,s);
    bool flag = false;
    while(!flag){
        S.push_back(col(S.back()));
        for(int i=0; i<S.size()-1; i++){
            if(S.at(i) == S.back()){
                flag = true;
                cout << S.size() << endl;
                return 0;
            }
        }
    }

}

Measured memory_bytes: 256
'use strict'
const main = input => {
  const line = input.split('\n')
  const T = line[1]
  let ar = line[0].split('')
  let judgement = 'No'
  for (let i = 0; i < ar.length; i++) {
    const str = ar.join('')
    if (str === T) {
      judgement = 'Yes'
      break
    }
    ar.unshift(ar.pop())
  }
  console.log(judgement)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
#include<stdio.h>
#define N 8
#define FREE 0
#define NOT_FREE 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
int X[N][N];

void init(){
  int i,j;
  for(i=0;i<N;i++) row[i]=col[i]=FREE;
  for(i=0;i<2*N-1;i++) dpos[i]=dneg[i]=FREE;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      X[i][j]=FREE;
    }
  }
}

void printB(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(X[i][j]==NOT_FREE){
	if(row[i]!=j) return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void putQ(int i) {
  int j;
  if(i==N) {
    printB();
    return;
  }
  
  for(j=0;j<N;j++){
    if(col[j]==NOT_FREE || dpos[i+j]==NOT_FREE || dneg[i-j+N-1]==NOT_FREE) continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
    putQ(i+1);
    row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}

int main() {
  int i,k,r,c;
  
  init();
  scanf("%d",&k);
  for(i=0;i<k;i++) {
    scanf("%d%d",&r,&c);
    X[r][c]=1;
  }
  putQ(0);
  
  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define mod 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll H, W; cin >> H >> W;
  if (H == 1 || W == 1) {
  	cout << 1 << endl;
  }
  else if (H * W % 2) {
  	cout << (H * W + 1) / 2 << endl;
  } else {
  	cout << H * W / 2 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN

 main() {
int ans =0;
string s;
cin >> s;
for(int i=0;i<s.size();i++){
   if(s.at(i)=='1')ans++;
}
cout << ans << endl;
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
    {
    	cin.tie(0);
        ios::sync_with_stdio(0);
        string s,S;cin>>s;
    	for (int i = 0; i <s.size() ; ++i)
    	{
    		if(i%2==0)cout<<s[i];
    	}
    	return 0;
    }
 

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

int main() {
  int D, T, S;
  cin >> D >> T >> S;
  
  if (S * T >= D) cout << "Yes" << endl;
  else if (S * T < D) cout << "No" << endl;
  
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

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


int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    
    long long N, P;
    while (cin >> N >> P) {
        auto pf = prime_factorize(P);
        long long res = 1;
        for (auto p : pf) {
            long long fac = p.second / N;
            for (int i = 0; i < fac; ++i) res *= p.first;
        }
        cout << res << endl;
    }
}


















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

typedef vector<int> vi;

int N, Q;
vector<vi> G;
vi X, R;

void input_init(void) {
	cin >> N >> Q;
	G.resize(N + 1);
	for (int i = 1; i < N; ++i) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	X.resize(N + 1, 0);
	for (int i = 1; i <= Q; ++i) {
		int p, x;
		cin >> p >> x;
		X[p] += x;
	}
	R.resize(N + 1);
	for (int i = 1; i <= N; ++i)
		R[i] = X[i];
}

void dfs(int cur, int pre = -1) {
	int sz = G[cur].size();
	for (int i = 0; i < sz; ++i) {
		int nxt = G[cur][i];
		if (nxt == pre) continue;
		R[nxt] += R[cur];
		dfs(nxt, cur);
	}
}

int main(void) {
	input_init();
	dfs(1);
	for (int i = 1; i <= N; ++i)
		cout << R[i] << ((i == N) ? '\n' : ' ');
	return 0;
}


Measured memory_bytes: 27392
import bisect

N,K=map(int,input().split())
A=list(map(int,input().split()))

dic={}
for i in range(N):
    if A[i] not in dic:
        dic[A[i]]=[]
    dic[A[i]].append(i)

check={}
for ai in dic:
    check[ai]=0
    check[ai]=max(dic[ai])


front=[-1]
pos=0
visit=set([-1])
while True:
    val=A[pos]
    if pos>=check[val]:
        front.append(pos)
        if pos in visit:
            break
        else:
            visit.add(pos)
        pos=dic[val][0]+1
        if pos==N:
            front.append(-1)
            break
    else:
        index=bisect.bisect_right(dic[val],pos)
        pos=dic[val][index]+1
        if pos==N:
            front.append(-1)
            break
last=front[-1]
i=front.index(last)
period=len(front)-i-1
const=i
K-=const
K-=1
r=K%period
fff=front[r]
if fff!=-1:
    import heapq
    que=[]
    check={A[i]:0 for i in range(N)}
    index=0
    flag=True
    while N>index:
        if A[index]!=A[fff] and flag:
            index+=1
        elif A[index]==A[fff] and flag:
            index+=1
            flag=False
        else:
            if check[A[index]]==0:
                heapq.heappush(que,(-index,A[index]))
                check[A[index]]=1
                index+=1
            else:
                while True:
                    test,a=heapq.heappop(que)
                    check[a]=0
                    if a==A[index]:
                        break
                check[A[index]]=0
                index+=1
    que.sort(reverse=True)
    que=[que[i][1] for i in range(len(que))]
    print(*que)
else:
    import heapq
    que=[]
    check={A[i]:0 for i in range(N)}
    index=0
    while N>index:
        if check[A[index]]==0:
            heapq.heappush(que,(-index,A[index]))
            check[A[index]]=0
            check[A[index]]=1
            index+=1
        else:
            while True:
                test,a=heapq.heappop(que)
                check[a]=0
                if a==A[index]:
                    break
            check[A[index]]=0
            index+=1
    que.sort(reverse=True)
    que=[que[i][1] for i in range(len(que))]
    print(*que)

Measured memory_bytes: 138328
s=input()
K=1
tmp=s[0]
i=0
if len(s)==1:
    print(1)
elif len(s)==2:
    if s[0]==s[1]:
        print(1)
    else: print(2)
else:
    while i<len(s)-1:
        if tmp==s[i+1] and i<len(s)-2:
            tmp=s[i+1]+s[i+2]
            K+=1
            i=i+2
        elif tmp!=s[i+1]:
            K+=1
            tmp=s[i+1]
            i=i+1
        elif i==len(s)-2:
            break
    print(K)

Measured memory_bytes: 41308
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

N = ii()
A = li()

for i in reversed(range(N//2)):
    ind = i+1
    ind += i+1
    while(ind-1 < N):
        A[i] += A[ind-1]
        ind += i+1
    A[i] %= 2

'''
for i in range(N):
    ind = 2*(i+1)
    while(ind-1 < N):
        A[i] += A[ind-1]
        ind += i+1
    A[i] %= 2
'''

ans = ''
print(sum(A))
for i in range(N):
    if A[i]%2 == 1:
        ans += str(i+1) + ' '

if ans != '':
    print(ans[:-1])

Measured memory_bytes: 8600
package main

import "fmt"

func main() {
	var n, k int

	fmt.Scan(&n)
	fmt.Scan(&k)

	if k <= (n - 1) * (n - 2) / 2 {
		fmt.Println(n * (n - 1) / 2 - k)

		for j := 1; j < n; j++ {			
			fmt.Println(j, n)
		}

		i := k;
		for j1 := 1; j1 < n; j1++ {
			for j2 := j1 + 1; j2 < n; j2++ {
				i++;
				if i <= (n - 1) * (n - 2) / 2 {
					fmt.Println(j1, j2)
				}
			}
		}
	} else {
		fmt.Println(-1)
	}
}

Measured memory_bytes: 640
S=gets.chomp.chars
T=gets.chomp.chars
def f(a,b)
    h = {}
    a.zip(b) do |s,t|
        h[s] ||= []
        h[s] << t
    end

    h.each do |k,v|
        # p [k,v]
        if v.uniq.size != 1
            puts 'No'
            exit 0
        end
    end
end
f(S,T)
f(T,S)

puts 'Yes'




Measured memory_bytes: 27260
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  int d[n], ans=0;
  for (int i=0; i<n; i++) scanf("%d", d+i);
  for (int i=0; i<n-1; i++) {
    for (int j=i+1; j<n; j++) {
      ans += d[i]*d[j];
    }
  }
  printf("%d\n", ans);
  return 0;
}


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

int main() {
    int n;cin>>n;
    vector<int>dp(3,0);
    for (int i = 0; i < n; ++i) {
        vector<int>a(3),temp(3,0);
        for (int j = 0; j < 3; ++j) {
            cin>>a[j];
        }
        for (int k = 0; k < 3; ++k) {
            for (int j = 0; j < 3; ++j) {
                if (k != j)
                    temp[j] = max(temp[j] , dp[k] + a[j]);
            }
        }
        dp = temp;
    }
    cout<<*max_element(dp.begin(),dp.end())<<'\n';
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  int d=0,e=0,f=99999999;
  for(int i=0;i<n;i++){
    cin >> a[i];
    d+=a[i];
  }
  for(int i=0;i<n;i++){
    e+=a[i];
    d-=a[i];
    if(f>abs(d-e))f=abs(d-e);
  }
  cout << f;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;
 
int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

bool is_prime(long long N){
    if (N == 1) return false;
    for (long long i = 2;i * i <= N;i++){
        if (N % i == 0) return false;
    }
    return true;
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
 
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
 
///////////////////////////////////////////////////////////////////////////////////

int main(){
    int n;
    cin >> n;
    bool ok = true;
    vector<int> t(n), x(n), y(n);
    for (int i = 0;i < n;i++){
        cin >> t[i] >> x[i] >> y[i];
    }
    
    if((t[0] - x[0] - y[0]) %2 != 0 || t[0] < x[0] + y[0]){
        cout << "No" << endl;
        return 0;
    }
    int D, T;
    for (int i = 1;i < n;i++){
        D = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
        T = t[i] - t[i-1];

        if ((T-D)%2 != 0 || D > T){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 4580
#include <stdio.h>
#include <math.h>
int main(int argc, char const *argv[]) {
  int N,D;
  int X[10][20];
  int counter =0;
  double dis =0;
  double dis2, dis3;

  scanf("%d %d\n",&N,&D );
  for (int i = 0; i < N; i++) {
    for (int j = 0; j< D; j++) {
      scanf("%d",&X[i][j] );
    }
    printf("\n");
  }

  for (int i = 0; i < N-1; i++) {
    for (int j = i+1; j< N; j++) {
      for (int k = 0; k < D; k++) {
        dis += ((X[i][k] - X[j][k])*(X[i][k] - X[j][k]));
      }
      dis2 = (double)sqrt(dis);
      dis3 = ceil(dis2);
      if(dis2 == dis3){
        counter ++;
      }
      dis =0;
    }
  }

  printf("%d\n",counter );






  return 0;
}


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

#define LL long long

int arr[100009];
int cnt[100009];

int main(){
	

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin>>n;

	for(int i=1;i<=n;i++){cin>>arr[i];}
	for(int i=1;i<=n;i+=2){
		cnt[arr[i]]++;
	}

	vector<pair<int,int> > v1,v2;
	for(int i=1;i<=100000;i++){
		if(cnt[i]>0){
			v1.push_back(make_pair(cnt[i],i));
		}
	}

	memset(cnt,0,sizeof(cnt));

	for(int i=2;i<=n;i+=2){
		cnt[arr[i]]++;
	}

	for(int i=1;i<=100000;i++){
		if(cnt[i]>0){
			v2.push_back(make_pair(cnt[i],i));
		}
	}

	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());

	reverse(v1.begin(),v1.end());
	reverse(v2.begin(),v2.end());

	if(v1[0].second != v2[0].second){
		cout<<(n - (v1[0].first + v2[0].first))<<endl;
	}else{
		if((int)v1.size()>1 && (int)v2.size()>1){
			cout<<(n - max(v1[0].first + v2[1].first,v1[1].first+v2[0].first))<<endl;
		}else if((int)v1.size()==1 && (int)v2.size()==1){
			cout<<(n/2)<<endl;
		}else if((int)v1.size()==1){
			cout<<(n/2 - v2[1].first)<<endl;
		}else{
			cout<<(n/2 - v1[1].first)<<endl;
		}
	}
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define mod 1e9+7
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rof(i,a,b) for(ll i=a;i>b;i--)
//cf dont use unordered map. use simply map<... , ... > m;

//They are Iterator minus v.begin() krna //lower_bound(v.begin(),v.end(),x)-v.begin()  //upper_bound(v.begin(),v.end(),x)-v.begin()
// lower bound tells greater than or equal to // upper bound tells strictly greater than
//int a[1001][1001] //aise global me hi// ll lcm(ll a, ll b){ return a / __gcd(a, b) * b; }
//memset can initialize to 0 or -1 ONLY //memset(str, 't', sizeof(str)); // string //memset(a, 0, sizeof(a));  //1D array    // memset(a,0,sizeof(a[0][0])*n*n); //2D array
// set.insert(),find() //for(auto it=set.begin();....) cout<<*it;   // sort(v.begin(),v.end(),compare)

void solve()
{

ll n;cin>>n;
string s;cin>>s;
ll r=0,g=0,b=0;
f(i,0,s.length())
{
	if(s[i]=='R') r++;
	else if(s[i]=='G') g++;
	else b++;
}
ll ans=r*g*b;

f(i,0,n)
{

	f(j,1,n)
	{
		if(i+j+j<n)
		if(s[i]!=s[i+j]&&s[i+j]!=s[i+j+j]&&s[i]!=s[i+j+j])
			ans--;
	}
}


cout<<ans;
}


int main()
{

ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t=1;
  //  cin>>t;
    while(t--)
    {
     solve();
    }
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y);}
template<class T, class U> void umax(T& x, const U& y){ x = max(x, (T)y);}
template<class T, class U> void init(vector<T> &v, U x, size_t n) { v=vector<T>(n, x); }
template<class T, class U> void init(vector<T> &v, U x, size_t n, size_t m...) { v=vector<T>(n); for(auto& a : v) init(a, x, m);}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    FOR(i, n) cin >> a[i];

    double p = 0;
    FOR(i, k) p += log(a[i]);

    for(int i = k; i < n; i++){
        double p2 = p - log(a[i-k]) + log(a[i]);
        if (p2 > p)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
        p = p2;
    }

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}



Measured memory_bytes: 3992
#include <stdio.h>

int main(void) {
	int N, a;
	int color[9] = { 0 }, cnt = 0, max, min;

	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &a);
		for (int j = 1; j <= 8; j++) {
			if (a <= 400 * j  - 1) {
				if (color[j - 1] == 0) {
					cnt++;
					color[j - 1]++;
				}
				break;
			}
			if (a >= 3200) {
				color[8]++;
				break;
			}
		}
	}

	if (cnt == 0) min = 1;
	else min = cnt;

	if (color[8] != 0) max = cnt + color[8];
	else max = cnt;

	printf("%d %d\n", min, max);

	return 0;
}

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

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


	int total{};
	std::vector<int> stuff(N,0);

	for( int i{}; i < N; ++i )
	{
		int t;
		std::cin >> t;
		total += t;
		stuff[i] = t;
	}

	
	const auto capable
		= std::count_if(
			std::cbegin( stuff )
			, std::cend( stuff )
		, [=]( const auto e )
		{
			return total <= 4 * M * e;
		}
	);

	std::cout << (capable>=M?"Yes":"No") << "\n";

	return 0;
}

Measured memory_bytes: 3140
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }


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

	vector<int> a(n);
	rep(i, n) {
		a[i] = (int)s[i] - 48;
	}

	ll ans = 0;

	vector<unsigned short> pre(2019), now(2019), all0(2019);

	rep(i, n) {
		std::vector<unsigned short>().swap(pre);
		pre = now;
		now = all0;
		if (i == 0) {
			now[a[i]]++;
		}
		else {
			now[a[i]]++;
			rep(j, 2019) {
				int z = (10 * j + a[i]) % 2019;
				now[z] += pre[j];
			}
		}
		ans += now[0];
	}

	cout << ans << endl;
}




Measured memory_bytes: 4308
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int a;
	scan(a);
	prin(a+a*a+a*a*a);
	return 0;
}


Measured memory_bytes: 3584
<?php

fscanf(STDIN, '%d', $x);

if($x==1){
    $max = 1;
}else{
$max = 0;

for ($i = 2; $i < $x/2; $i++) {
    $ans = 0;
    while (true) {
        if ($ans == 0) {
            $ans = $i * $i;
        } else {
            $ans = $ans * $i;
        }
        if ($ans > $x) {
            $ans = $ans / $i;
            break;
        }
    }
    if ($max < $ans) {
        $max = $ans;
    }
}
}
echo $max;


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


Measured memory_bytes: 256
// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;

LL bin(LL a, LL b, LL p) {
	LL res = 1;
	for (a%=p; b; b>>=1, a=a*a%p)
		if (b & 1)
			res = res * a % p;
	return res;
}


const double pi = 3.141592653;
const int MOD = 1e9+7;
inline LL sum(int x) {
	return 1LL *x*(x+1)/2;
}
int main(int argc, char const *argv[]) {
    // code
   	int n, k;
   	scanf("%d%d", &n, &k);
   	LL ans = 0;
   	for (int i=k; i<=n+1; ++i) {
   		LL a = sum(i-1), b = sum(n) - sum(n-i);
   		ans += b-a+1;
   		ans %= MOD;
   	}
   	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3688
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[]$) {
        Scanner sc = new Scanner(in);
        String s=sc.next();
        int c=0;
        long ans=0;
        int stop=s.length();
        for (int i = 0; i <stop ; i++) {
            if(s.charAt(i)=='W'){
                ans+=c;
            }else{
                c++;
            }
        }
        out.println(ans);
    }
    static long power(long x,int n){
        long mod=1000000007;
        long ans=1;
        while (n>0) {
            if((n&1)==1){
                ans=(ans*x)%mod;
            }
            x=(x*x)%mod;
            n>>=1;
        }
        return ans;
    }
    //最大公約数
    static int gcd (int a,int b) {
        int temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }
    //※最小公倍数はa*b/gcd(a,b)である
    static class UF{
        static int size=51;
        static int[] par=new int[size];
        //初期化
        static void init(){
            for (int i = 1; i <size ; i++) {
                par[i]=i;
            }
        }
        //根をたどる
        static int root(int x){
            if(par[x]==x){
                return x;
            }else{
                return par[x]=root(par[x]);
            }
        }
        //同じ根をもつか(同じ集合に属するか)判定
        static boolean same(int x,int y){
            return root(x)==root(y);
        }
        //合体
        static void unite(int x,int y){
            x=root(x);
            y=root(y);
            if(x==y)return;
            par[x]=y;
        }
    }
}

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

syozi = 1000
kabu = 0

for i in range(N-1):
  if A[i] < A[i+1]:
    kabu += syozi // A[i] 
    syozi -= (syozi // A[i]) * A[i]
  elif A[i] > A[i+1]:
    syozi += A[i] * kabu
    kabu = 0
  else:
    pass

syozi += A[-1] * kabu

print(syozi)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
const ll MOD = 1e9 + 7;

void mainsolve(){
	ll h,w,n;
	cin >> h >> w >> n;

	ll c = max(h,w);
	if(c >= n) cout << 1 << endl;
	else if(n%c==0) cout << n/c << endl;
	else cout << n/c + 1 << endl;
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;

#define INF 1001001001

struct Edge {
  int from;
  int to;
  int cost;
  Edge(int from, int to, int cost) : from(from), to(to), cost(cost) {}
};

using Graph = vector< vector<Edge> >;

int dfs(Graph G, int r) {
  int n = G.size();
  vector<int> minEdge(n,-1);
  vector<int> minCost(n,INF);

  // T*構成
  for (auto es : G) {
    for (auto e : es) {
      if (e.to == r) continue;
      if (e.cost < minCost[e.to]) {
        minEdge[e.to] = e.from;
        minCost[e.to] = e.cost;
      }
    }
  }

  // 閉路検出
  int v = -1;
  rep(i,n) {
    if (minEdge[i]==-1) continue;
    vector<bool> isVisited(n);
    int now = i;
    while (now != r && !isVisited[now]) {
      isVisited[now] = true;
      now = minEdge[now];
    }
    if (now != r) {
      v = now;
      break;
    }
  }

  // 閉路なしの場合
  if (v == -1) {
    int ans = 0;
    rep(i,n) {
      if (minEdge[i]==-1) continue;
      ans += minCost[i];
    }
    return ans;
  }

  // 閉路ありの場合
  int ans = 0;
  int now = v;
  vector<bool> onCycle(n);
  while (!onCycle[now]) {
    onCycle[now] = true;
    ans += minCost[now];
    now = minEdge[now];
  }

  // グラフを縮約
  Graph newG(n);
  rep(i,n) {
    for (auto e : G[i]) {
      int s = e.from;
      int t = e.to;
      int c = e.cost;
      if (t == r) continue;
      if (onCycle[s] && onCycle[t]) continue;
      if (onCycle[t]) {
        c -= minCost[t];
        t = v;
      }
      if (onCycle[s]) s = v;
      newG[i].emplace_back(s,t,c);
    }
  }
  ans += dfs(newG,r);

  return ans;
}

int main() {
  int v, e, r;
  cin >> v >> e >> r;
  vector< vector<Edge> > G(v);
  rep(i,e) {
    int s, t, w;
    cin >> s >> t >> w;
    G[t].emplace_back(s,t,w);
  }

  cout << dfs(G, r) << endl;

  return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> 
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	ll x;
	cin >>x;
	cout <<x*x*x <<"\n";
	return 0;
}



Measured memory_bytes: 3092