akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef LOCAL
#include <pprint.hpp>
#endif
#define endl "\n";
#define pb push_back
#define md 1000000007
#define ll long long int
#define all(v) v.begin(),v.end()
ll power(ll a,ll b){ll z=1;while(b){if(b&1){z*=a;z%=md;}a*=a;a%=md;b/=2;}return z%md;}
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll n,m,u,v;
vector<vector<ll>> used;
vector<string> s;

int main(){
	//You need to change array size!
	#ifndef LOCAL
	ios_base::sync_with_stdio(false);	cin.tie(NULL);
	#endif 
	
	cin>>n>>m;
	s.resize(n);
	used.assign(n,vector<ll>(m,0));
	for(int i=0;i<n;++i)
		cin>>s[i];

	for(int i=n-1;i>=0;--i){
		used[i][m-1]=(s[i][m-1]=='.');
		if((i+1)<n-1 && used[i+1][m-1]==0)
			used[i][m-1]=0;
	}
	for(int j=m-1;j>=0;--j){
		used[n-1][j]=(s[n-1][j]=='.');
		if((j+1)<m-1 && used[n-1][j+1]==0)
			used[n-1][j]=0;
	}
	for(int i=n-2;i>=0;--i){
		for(int j=m-2;j>=0;--j){
			used[i][j] += used[i+1][j] + used[i][j+1];
			if(s[i][j]=='#')
				used[i][j]=0;
			used[i][j]%=md;
		}
	}
	cout<<used[0][0];

	return 0;	
}




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

int main(void){
  int a, b, power = 1;
  cin >> a >> b;
  for(int i = 0; ; i++){
    if(power >= b){
      cout << i << endl;
      return 0;
    }
    power += a - 1;
  }
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int N,M,A,B,C,D;
const int inf = 100000;
int main()
{
	cin >> N >> M;
	int K[32][32];
	for(int i = 1; i < N+1; i++)
	{
		for(int j = 1; j < N+1; j++)
		{
			K[i][j] = inf;
		}
	}
	for(int i = 0; i < M; i++)
	{
		scanf("%d,%d,%d,%d", &A, &B, &C, &D);
		K[A][B] = C;
		K[B][A] = D;
	}
	for(int k = 1; k < N+1; k++)
	{
		for(int i = 1;i < N+1;i++)
		{
			for(int j = 1;j < N+1;j++)
			{      
				K[i][j] = min( K[i][j], K[i][k] + K[k][j]);
			}
		}
	}
	int s,g,V,P;
	scanf("%d,%d,%d,%d",&s,&g,&V,&P);
	V -= K[s][g];
	V -= K[g][s];
	V -= P;
	cout << V <<endl;
}

Measured memory_bytes: 3232
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<utility>


using namespace std;

int main(void){
    long long int H;
    scanf("%lld",&H);
    int count = 0;
    long long int sum = 1;
    while(H>1){
        H = H/2;
        count++;
        sum += pow(2,count);
    }
    printf("%lld",sum);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    int a, b, c; std::cin >> a >> b >> c;

    int d = a % b;
    if (d == c) {
            std::cout << "YES" << std::endl;
            return 0;
    }
    int i = 2;

    while (true) {
        int dd = (a * i) % b;
        if (dd == c ) {
            std::cout << "YES" << std::endl;
            return 0;
        }
        if (d == dd) {
            break;
        }
        i++;
    }
    std::cout << "NO" << std::endl;
    return 0;
}

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

int main(void) {
	std::string s;

	std::cin >> s;

	for (size_t i = 0; i < s.length(); i++) {
		if (s[i] == '1') {
			s[i] = '9';
		}
		else {
			s[i] = '1';
		}
	}

	std::cout << s << std::endl;

	return 0;
}

Measured memory_bytes: 256
function main()
    
    (A, B, C) = map(x -> parse(Int,x),split(readline()))
    
    vs = [A B C]
    count5 = 0
    count7 = 0
    
    for i in 1:3
        
        if vs[i] == 5
            count5 += 1
        elseif vs[i] == 7
            count7 += 1
        end
        
    end
    
    if count5 == 2 && count7 == 1
        println("YES")
    else
        println("NO")
    end
    
end

main()

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

using ll=long long;
#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 ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

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

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

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

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

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

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

char* readCharArray(){
	static char buf[3341919];
	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(a>b)
		a=b;
}

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

const int inf=LLONG_MAX/3;
const int Nmax=2017;

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

vi Wafrelka(vi a,vi b){
	int n=a.size(),m=b.size();
	vi res;
	int i=0,j=0;
	REP(_,n+m){
		bool l=true;
		if(i==n||(j<m&&a[i]<b[j]))l=false;
		if(l)res.PB(a[i++]);
		else res.PB(b[j++]);
	}
	return res;
}

signed main(){
	int n=read();
	vi a;
	REP(i,n)a.PB(read());
	sort(ALL(a));
	vi ans,used(n,0);
	function<vi(int i)>Yutaka;
	Yutaka=[&](int i){
		vi res;
		used[i]=true;
		REP(j,n)if(!used[j])
			if(gcd(a[i],a[j])>1)
				res=Wafrelka(res,Yutaka(j));
		res.insert(res.begin(),a[i]);
		return res;
	};
	REP(i,n)if(!used[i])
		ans=Wafrelka(ans,Yutaka(i));
	REP(i,n)
		print(ans[i],i==n-1?1:2);
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; ++i) cin >> A[i];

    int res = 0;
    for(int i=0; i+1<N; ++i) {
        if(A[i] == A[i+1]) {
            ++res;
            ++i;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    
    if a[1] % a[0] ==0:
        print(a[0]+a[1])
    else:
        print(a[1]-a[0])


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define ff first
#define ss second
#define pb push_back
#define vi vector<ll>
#define all(_x) _x.begin(), _x.end()
#define rep(i, s, e) for (ll i = s; i < e; i++)
#define lb(_x, _a) (lower_bound(all(_x), _a) - _x.begin())
#define ub(_x, _a) (upper_bound(all(_x), _a) - _x.begin())
ll n, tc;

int main()
{
  	// ll is int now
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    int a,b,c;
    int dp[3] = {0};
    cin>>a>>b>>c;
    dp[0] = a;
    dp[1] = b;
    dp[2] = c;
    for(int i=1; i<n; i++)
    {
        cin>>a>>b>>c;
        a += max(dp[1], dp[2]);
        b += max(dp[0], dp[2]);
        c += max(dp[0], dp[1]);

        dp[0] = a;
        dp[1] = b;
        dp[2] = c;
    }
    cout<<max({dp[0],dp[1],dp[2]});
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define faster ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long
#define ld long double
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define REP(i,a,b) for(ll i = a; i < b; i++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define bins(v, x) binary_search(v.begin(), v.end(), x)
#define pi 2*acos(0.0)
const int INF = 1e9+1;
const int mod = 1e9+7;
const int mod1 = 998244353;
 
ll modExp(ll base, ll exp, ll mod) {
   ll res = 1;
   while (exp > 0) {
    	if (exp % 2 == 1) {
        	res= (res * base) % mod;
		}
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}

ll inverse(ll base, ll exp, ll mod) {
   return modExp(base, exp - 2, mod);
}
 
ll nCr(ll n, ll k) { 
   ll C[n + 1][k + 1]; 
   
   REP(i,0,n+1){ 
      REP(j,0,min(i,k)+1) {
         if(j==0 || j==i) {
            C[i][j] = 1;  
         } else {
            C[i][j] = C[i-1][j-1] + C[i-1][j]; 
         }
      } 
   }
   return C[n][k]; 
}

bool compare(pair<int, int>&i, pair<int, int>&j) {
    return (i.S > j.S || (i.S == j.S && i.F > j.F));
}

void readtxt() {
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
}

void test() {
   int x, n;
   cin >> x >> n;

   vi v(n);
   REP(i,0,n) cin >> v[i];

   sort(all(v));
   if(!bins(v, x)) {
      cout << x << "\n";
   } else {
      for(int i = 1; ; i++) {
         if(!bins(v, x-i) && !bins(v, x+i)) {
            cout << x-i;
            break;
         } else if(!bins(v, x-i) && bins(v, x+i)) {
            cout << x-i;
            break;
         } else if(bins(v, x-i) && !bins(v, x+i)) {
            cout << x+i;
            break;
         }
      }
   }
}

int main() {
   //readtxt();
   faster;

   int t = 1;
   //cin >> t;
   while(t--)
      test();
}

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

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<db, db> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<db> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;
typedef vector<vi> vii;
typedef vector<vl> vll;
typedef vector<vd> vdb;
typedef vector<vb> vbb;
typedef vector<vc> vcc;
typedef vector<vs> vss;

#define f first
#define s second	
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define part(x, n) (x).begin(), (x).begin()+n
#define rpart(x, n) (x).rbegin(), (x).rbegin()+n
#define rsz resize
#define ins insert
#define cnt count
#define fr front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound

#define LSOne(S) ((S)&-(S))

#define F0R(i, a, b) for(int i = (a); i < (b); ++i)
#define FOR(i, a) F0R(i, 0, a)
#define R0F(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define ROF(i, a) R0F (i, 0, a)
#define trav(a, x) for (auto& a: x)

const int MOD = 1e9+7;

//input
template<class A> void read(complex<A>& c);
template<class A, class B> void read(pair<A,B>& p);
template<class A> void read(vector<A>& v);
template<class A, size_t SZ> void read(array<A,SZ>& a);

template<class T> void read(T& x) { cin >> x; }
void read(db& d) { str t; read(t); d = stod(t); }
void read(ld& d) { str t; read(t); d = stold(t); }
template<class H, class... T> void read(H& h, T&... t) { read(h); read(t...); }

template<class A> void read(complex<A>& c) { A a,b; read(a,b); c = {a,b}; }
template<class A, class B> void read(pair<A,B>& p) { read(p.f,p.s); }
template<class A> void read(vector<A>& x) { trav(a,x) read(a); }
template<class A, size_t SZ> void read(array<A,SZ>& x) { trav(a,x) read(a); }

//output
template<class A> void print(A x) { cout << (x); }
template<class H, class... T> void print(const H& h, const T&... t) {
	print(h); print(t...); }
void prints() { print("\n"); } // print w/ spaces
template<class H, class... T> void prints(const H& h, const T&... t) {
	print(h); if (sizeof...(t)) print(" "); prints(t...); }

void setIn(str s) {freopen(s.c_str(), "r", stdin);}
void setOut(str s) { freopen(s.c_str(), "w", stdout);}
void unsyncIO() { ios::sync_with_stdio(0); cin.tie(0);}
void setIO(str s= ""){
	unsyncIO();
	if(sz(s)) { setIn(s+".in"), setOut(s+".out");}
}

int main(){
	setIO();
	double d, t, s;
	read(d, t, s);
	if(d/s <= t)
		prints("Yes");
	else
		prints("No");
	return 0;
}



Measured memory_bytes: 3696
def main():

    from bisect import bisect_left as bl, bisect_right as br, insort
    import sys
    import heapq
    # from math import *
    from collections import defaultdict as dd, deque
    def data(): return sys.stdin.readline().strip()
    def mdata(): return map(int, data().split())
    out = sys.stdout.write
    # sys.setrecursionlimit(100000)

    n, k = mdata()
    a = list(mdata())
    dp = [0]*(k+1)
    for i in range(1, k + 1):
        for j in a:
            if i >= j:
                if dp[i - j] == 0:
                    dp[i] = 1
            if dp[i] == 1:
                break
    print("First" if dp[k] else "Second")


if __name__ == '__main__':
    main()

Measured memory_bytes: 42136
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main() {
	double ax, bx, ay, by, cx, dx, cy, dy;

	while (~fscanf(stdin, "%lf%lf%lf%lf%lf%lf%lf%lf", &ax, &ay, &bx, &by, &cx, &cy, &dx, &dy)) {
		if (ax <= dx&&cx <= bx) {
			if (ay <= dy&&cy <= by) { puts("YES"); }
			else puts("NO");
		}
		else puts("NO");
	}
	return 0;
}

Measured memory_bytes: 616
X,K,D=list(map(int,input().split()))
    
if abs(X)//D<K:
    if (K-abs(X)//D)%2==0:
        print(abs(X)%D)
    else:
        print(abs(abs(X)%D-D))
else:
    print(abs(X)-D*K)

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

int main() {
  int n, d;
  cin >> n >> d;
  int x, y, count = 0;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    double dis = sqrt(pow(x,2) + pow(y,2));
    if (d >= dis) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  string s,t;
  int ans=0;
  cin>>s>>t;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]) ans++;
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 3916
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			String s=sc.nextLine();
			int num=0;
			for(int i=0; i<4; i++) {
				if(s.charAt(i)=='+') {
					num++;
				}
				else {
					num--;
				}
			}
			System.out.println(num);
			
			
		}
	}
}



Measured memory_bytes: 23764
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int,int);
void dfs( vector< vector<int> >&, int , vector<int>& );
void bfs( vector< vector<int> >&, int , vector<int>& );

void solve()
{
    int n,k;
    cin>>n>>k;

    vector<int> a(n+1);

    rep(i,1,a.size())
    {
        cin>>a[i];
    }

    vector<int> ans;
    ans.pb(1);
    int x = 1;
    map<int,int> p;
    int pos[n+1] = {0};
    int l = 1;
    while(1)
    {
        p[x]++;
        if ( p[x] == 2 )
        {
            break;
        }
        pos[x] = l++;
        ans.pb(a[x]);
        x = a[x];
    }

    // rep(i,0,ans.size())
    // {
    //     out1(ans[i]);
    // }
    // out1(pos[x]);
    // out1(x);
    int y = pos[x] - 1;

    if ( k <= y )
    {
        cout<<ans[k]<<endl;
        return;
    }

    k -= y;
    k %= (ans.size()-1-y);

    cout<<ans[y+k]<<endl;
}

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void dfs ( vector< vector<int> > &v , int x , vector<int> &vis )
{
    vis[x] = 1;

    rep(i,0,v[x].size())
    {
        if( vis[v[x][i]] == 0 )
        {
            dfs(v,v[x][i],vis);
        }
    }
}

void bfs( vector< vector<int> > &v , int x , vector<int> &vis )
{
    queue<int> q;
    q.push(x);

    while( !q.empty() )
    {
        int p = q.front();
        q.pop();

        rep(i,0,v[p].size())
        {
            if ( vis[v[p][i]] == 0 )
            {
                vis[v[p][i]] = 1;
                q.push(v[p][i]);
            }
        }
    }
}

Measured memory_bytes: 20128
import itertools
import math

N,M=map(int,input().split())
ans = 0
even = 0
odd = 0
if N > 1:
    even += math.factorial(N) / (math.factorial(2)*math.factorial(N - 2))
if M > 1:
    odd += math.factorial(M) / (math.factorial(2)*math.factorial(M - 2))
ans=even+odd
print(int(ans))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
	string temp;
	cin >> temp;
	int count = 0;
	for (int i = 0; i < 6; i++)
	{
		if (temp[i] == '1') count++;
	}
	cout << count;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine().Select(x => x - '0').ToArray();

        var available = CountAvailableCodes(3, s, 0);
        Console.WriteLine(available);
    }

    private static int CountAvailableCodes(int length, int[] seed, int p)
    {
        if (length < 1 && p <= seed.Length)
        {
            return 1;
        }
        if (p >= seed.Length)
        {
            return 0;
        }

        --length;
        var k = 0;
        for (int i = 0; i < 10; ++i)
        {
            int q = p;
            while (q < seed.Length && seed[q] != i)
            {
                ++q;
            }
            
            k += CountAvailableCodes(length, seed, q + 1);
        }
        return k;
    }
}


Measured memory_bytes: 13396
n, m = map(int, input().split())
l = [1]*(n + 1)

for i in range(m):
    a = int(input())
    l[a] = 0

for i in range(2, n + 1):
    if l[i] != 0:
        l[i] = (l[i - 1] + l[i - 2])%(10**9 + 7)

print(l[-1])

Measured memory_bytes: 6900
#include<stdio.h>
#include<string.h>

int main(void)
{
	char s[50];
	int n;
	char abc[3]="ABC";
	int i;
	int count;
	
	scanf("%d%s",&n,s);
	
	for(i=0;i<n-2;i++){
		if(strncmp(s+i,abc,3)==0)
			count++;
	}
	
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 128
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var s = next();
	var t = next();
	var map = {};
	var output = 0;
	for(var i = 0; i < s.length; i++){
		if(map[s[i]] == null){
			map[s[i]] = [];
		}
		map[s[i]].push(i);
	}
	var maeIndex = -1;
	var loop = 0;
	for(var i = 0; i < t.length; i++){
		if(map[t[i]] == null){
			myout(-1);
			return;
		}
		if(i == 0){
			output = map[t[i]][0] + 1;
			maeIndex = map[t[i]][0];
		}else{
			var index = binarySearch(map[t[i]], maeIndex);
			if(index == map[t[i]].length || map[t[i]][index] == maeIndex){
				loop++;
				index = 0;
			}
			output = (loop * s.length) + map[t[i]][index] + 1;
			maeIndex = map[t[i]][index];
		}
	}
	myout(output);
}
function binarySearch(list,search){
  //listはあらかじめ昇順ソート済みとする。右側が有効エリア、左側が無効エリアと仮定し、
  //searchによって返す要素(インデックス)は ok:有効な部分の最小値、ng:無効な部分の最大値
  var ng = -1;
  var ok = list.length;
  var center;
  while(Math.abs(ok - ng) > 1){
    center = Math.floor((ok + ng) / 2);
    if(list[center] > search){
       ok = center;
    }else{
       ng = center;
    }
  }
  return ok;
  //return list[ng];
}

Measured memory_bytes: 36872
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int A, B, C, X;
	vector<int>V;
	cin >> A >> B >> C;
	cin >> X;
	V.push_back(A);
	V.push_back(B);
	V.push_back(C);
	sort(V.begin(), V.end());
	int large = V[2];
	for (int i = 0; i < X; ++i) {
		large *= 2;
	}
	cout << V[0] + V[1] + large << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N;cin>>N;
  string S;cin>>S;
  
  vector<bitset<10>>A(N),B(N);
  for(long i=1;i<N;i++){
    A[i]=A[i-1];A[i].set(S[i-1]-48);
  }
  for(long i=N-2;i>=0;i--){
    B[i]=B[i+1];B[i].set(S[i+1]-48);
  }
  vector<vector<vector<bool>>>C(10,vector<vector<bool>>(10,vector<bool>(10)));
  for(long i=0;i<N;i++)for(long j=0;j<10;j++)for(long k=0;k<10;k++){
    if(A[i].test(j)&&B[i].test(k))C[j][S[i]-48][k]=1;
    
  }
  long ans=0;
  for(long i=0;i<10;i++)for(long j=0;j<10;j++)for(long k=0;k<10;k++)if(C[i][j][k])ans++;
  cout<<ans<<endl;
  
  
}

/*


*/

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] strlist = str.split(" ");
		int a = Integer.parseInt(strlist[0]);
		int b = Integer.parseInt(strlist[1]);
		int c = Integer.parseInt(strlist[2]);
		int d = Integer.parseInt(strlist[3]);

		if(a*b > c*d){
			System.out.println(a*b);
		}else{
			System.out.println(c*d);
		}

	}

}


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

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

    if(S.size()==1){
        cout << S << endl;
        return 0;
    }
    vector<long long>num;
    vector<int> p;
    for(int i=0;i<S.size();i++){
        p.push_back((int)(S[i]-'0'));
    }
    for(int i=0;i<(1<<S.size()-1);i++){
        long long sum=0;
        int ct=0;
        for(int j=0;j<S.size()-1;j++){
            if((i>>j)&1){
                long long c=1;
                for(int l=0;l<ct+1;l++){
                    sum+=p[j-l]*c;
                    c*=10;
                }
                ct=0;
            }else ct++;
            if(j==S.size()-2){
                if(ct!=0){
                    long long c=1;
                    for(int l=0;l<ct+1;l++){
                        sum+=p[j+1-l]*c;
                        c*=10;
                    }
                }
                else sum+=p[p.size()-1];
            }
        }
        num.push_back(sum);
    }
    long long ans=0;
    for(int i=0;i<num.size();i++){
        ans+=num[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from math import *
N=int(input())
L=[list(map(int,input().split())) for i in range(N)]
S=0
for i in range(N):
    for j in range(N):
        S+=sqrt((L[i][0]-L[j][0])**2+(L[i][1]-L[j][1])**2)
print(S/N)

Measured memory_bytes: 9196
#include <cstdio>
using namespace std;

int main(){
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H){
		printf("%s\n", "Yes");
	}else{
		printf("%s\n", "No");
	}
	return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	string s;
	cin >> s;
	if (s == "Sunny") {
		cout << "Cloudy";
	}
	if (s == "Cloudy") {
		cout << "Rainy";
	}
	if (s == "Rainy") {
		cout << "Sunny";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <regex>
using ll = long long;
using namespace std;
ll mod=998244353;

int main(){
  int N;
  string s;
  cin>>N>>s;
  if (N%2==0){
    for (int i(0);i<N/2;i++){
      if (s[i]!=s[i+N/2]){
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
    return 0;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		sc.fill(A);

		int count = 0;
		boolean undefined = true;
		boolean increase = false;
		for (int i = 1; i < A.length; i++) {
			if (A[i - 1] != A[i]) {
				if (undefined) {
					increase = (A[i - 1] < A[i]);
					undefined = false;
				} else {
					if ((A[i - 1] < A[i] && !increase)
							|| A[i - 1] > A[i] && increase) {
						count++;
						undefined = true;
					}
				}
			}
		}

		System.out.println(count + 1);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b, int[] c) throws IOException {
			if (a.length != b.length || b.length != c.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
				c[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 25940
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let a = input::<i64>();
    let b = input::<i64>();
    let k = input::<i64>();

    let m = std::cmp::max(a, b);
    let mut cnt = 0;
    let mut ans = 0;
    for i in (0..m + 1).rev() {
        if a % i == 0 && b % i == 0 {
            cnt += 1;
            if cnt == k {
                ans = i;
                break;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vector<string> v;
    rep(i, n) {
        string s;
        cin >> s;
        v.pb(s);
    }
    sort(all(v));

    rep(i, n) {
        cout << v[i];
    }

    cout << endl;
    re0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	/*int??????????????????????????????????????§long long ??§??¨??? long long????????§ll??¨?????\??§??????????????????????????????????????????*/
	ll int a,b;
	cin >> a >> b;
	/*fixed << setprecision??????????????????http://d.hatena.ne.jp/hidemon/20080715/1216111956*/
	cout << (ll int) a/b <<" " <<  a%b << fixed << setprecision(10)  << " " << (long double)a / (long double) b << endl;
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
using namespace std;
main(){
  int m,n,l,day,sum;
  while(1){
    cin>>l;
    if(l==0)break;
    day=0;
    sum=0;
    for(int i=0;i<12;i++){
      cin>>m>>n;
      if(day!=0)continue;
      sum+=m-n;
      if(sum>=l){
	day=i+1;
      }
    }
    if(day!=0){
      cout<<day<<endl;
    }
    else{
      cout<<"NA"<<endl;
    }
  }
}

Measured memory_bytes: 1160
import numpy as np
n,d = map(int,input().split())
ans=0
g=[]
if d==1:
    for _ in range(n):
        lis = np.array(list(map(int,input().split())))
    ans=n*(n-1)//2
    print(ans)
else:
    for _ in range(n):
        lis = np.array(list(map(int,input().split())))
        for i in range(len(g)):
            u = g[i]-lis
            z=np.linalg.norm(u)
            if z==int(z):
                ans+=1
        g.append(lis)
    print(ans)

Measured memory_bytes: 12504
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]

use proconio::input;
use proconio::marker::*;

fn main() {
    input! {
        k: usize,
    }
    let mut buf = 0;
    let mut ans = -1;
    for i in 1..=k {
        buf = (buf * 10 + 7) % k;
        if buf % k == 0 {
            ans = i as isize;
            break;
        }
    }
    println!("{}", ans);
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x, y) CPP_CAT_I(x, y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x, y) x##y

#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define M5 100007
#define M9 1000000000

// util {{{
#define FOR(i, start, end) for (i64 i = (start), CPP_CAT(i, xxxx_end) = (end); i < CPP_CAT(i, xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f, c, ...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); })(c))
#define ll long long int
#define VI vector<int>
template <typename C>
i64 SIZE(const C &c)
{
    return static_cast<i64>(c.size());
}

template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template <typename T, typename U, typename Comp = less<>>
bool chmax(T &xmax, const U &x, Comp comp = {})
{
    if (comp(xmax, x))
    {
        xmax = x;
        return true;
    }
    return false;
}

template <typename T, typename U, typename Comp = less<>>
bool chmin(T &xmin, const U &x, Comp comp = {})
{
    if (comp(x, xmin))
    {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit
{
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit()
    {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

bool isOK(int mid, double key)
{
}

int binary_search(double key)
{
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 2000000000;
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key))
            right = mid;
        else
            left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}

bool isKaibun(string st)
{
    bool ans = true;
    int n = st.length();
    REP(i, n / 2)
    {
        if (st[i] != st[n - i - 1])
        {
            return false;
        }
    }
    return true;
}

int toInt(char a)
{
    return a - '0';
}

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

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

void solve()
{
    int N, K;
    cin >> N >> K;
    vector<int> P(N);
    REP(i, N)
    cin >> P[i];

    sort(P.begin(), P.end());
    int ans = 0;
    REP(i, K)
    {
        ans += P[i];
    }
    cout << ans;
}

signed main()
{

    solve();

    return 0;
}


Measured memory_bytes: 3636
import numpy as np

n, k = list(map(int, input().split()))
x = np.array(list(map(int, input().split())))

result = np.inf
for i in range(len(x) - k +1):
    tmp1 = np.abs(x[i+k-1] - x[i]) + np.abs(x[i])
    tmp2 = np.abs(x[i+k-1] - x[i]) + np.abs(x[i+k-1])
    result = np.min([tmp1, tmp2, result])

print(int(result))

Measured memory_bytes: 23112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 1000000007
#define N 100005
ll dp[105][N];
int main()
{
    fastio;
    int n,k;
    cin>>n>>k;
    int ara[n+5];
    for(int i=0;i<n;i++) cin>>ara[i];
    dp[n][0]=1;
    for(int i=1;i<=k;i++) dp[n][i]+=dp[n][i-1];
    for(int i=n-1;i>=0;i--)
    {
        for(int j=k;j>=0;j--)
        {
            dp[i][j]=dp[i+1][j];
            int m=j-ara[i]-1;
            if(m>=0) dp[i][j]=(dp[i][j]-dp[i+1][m]+mod)%mod;
        }
        if(i==0) break;
        for(int j=1;j<=k;j++)
        {
            dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
        }
    }
    cout<<dp[0][k]<<endl;
}


Measured memory_bytes: 82456
import java.util.Scanner;
class Main{
    public static void main(String arg[]){
        Scanner scn=new Scanner(System.in);
        int a = scn.nextInt();
        int b = scn.nextInt();
        if(a%2==0||b%2==0){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 22996
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in)){
            while(true){
                int n = sc.nextInt();
                int r = sc.nextInt();
                if(n==0 && r==0) break;
                int[] values = new int[n];
                for(int i=0;i<values.length;i++){
                    values[i]=n-i;
                }
                for(int i=0;i<r;i++){
                    int p = sc.nextInt();
                    int c = sc.nextInt();
                    int[] temporary = new int[p+c-1];
                    for(int j=0;j<c;j++){
                        temporary[j]=values[p-1+j];
                    }
                    for(int j=0;j<p-1;j++){
                        temporary[c+j]=values[j];
                    }
                    for(int j=0;j<temporary.length;j++){
                        values[j]=temporary[j];
                    }
                }
                System.out.println(values[0]);
            }
        }
    }
}


Measured memory_bytes: 38000
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<char, int> P;
vector<P> A;
// A[p,...,r]をA[r]を基準に左右に分ける, return 境目
int partition(int p, int r){
  int x = A[r].second;
  int i = p - 1; // A[r]以下の場所の最大
  FOR(j,p,r){
    if(A[j].second <= x){
      i++;
      swap(A[i], A[j]);
    }
  }
  swap(A[i+1], A[r]);
  return i + 1;
}
void quicksort(int p, int r){
  if(p < r){
    int q = partition(p, r);
    quicksort(p, q - 1);
    quicksort(q + 1, r);
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  A.resize(n);
  map<int, string> MAP1, MAP2;
  FOR(i,0,n){
    cin>>A[i].first>>A[i].second;
    MAP1[A[i].second] += A[i].first;
  }
  quicksort(0, n - 1);
  FOR(i,0,n){
    MAP2[A[i].second] += A[i].first;
  }
  bool isSt = true;
  for(auto m1 : MAP1){
    if(m1.second != MAP2[m1.first]) isSt = false;
  }
  cout<<(isSt?"Stable":"Not stable")<<endl;
  FOR(i,0,n){
    cout << A[i].first << " " << A[i].second <<endl;
  }
}


Measured memory_bytes: 9124
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int sum=0;
    rep(i,n){
        sum=sum^a[i];
    }
    rep(i,n){
        cout << (sum ^ a[i]) << "\n";
    }
    return 0;
}

Measured memory_bytes: 3992
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int W; cin >> W;
	vector<int>as(W);
	for (int i = 0; i < W; ++i) {
		cin >> as[i];
	}
	vector<int>oks(W);
	for (int i = 0; i < W; ++i) {
		if (!as[i]) {
			{
				int limit = 1e9;
				for (int x = i - 1; x >= 0; --x) {
					if (as[x] == 0)break;
					else if (as[x] > 0) {
						oks[x] = max(oks[x], min(as[x], limit));
					}
					else {
						limit = min(limit, -as[x]);
					}
					limit--;
				}
			}
			{
				int limit = 1e9;
				for (int x = i + 1; x <W; ++x) {
					if (as[x] == 0)break;
					else if (as[x] > 0) {
						oks[x] = max(oks[x], min(as[x], limit));
					}
					else {
						limit = min(limit,-as[x]);
					}
					limit--;
				}
			}
		}
	}
	int ans = accumulate(oks.begin(), oks.end(), 0);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
void FastInputOutput(){
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
inline ll power(ll x, ll p, ll m){
    ll res = 1;
    while(p){
        if(p & 1)
            res = ((res % m) * (x % m)) % m;
        x = ((x % m) * (x % m)) % m;
        p >>= 1;
    }
    return res % m;
}
long double ModLog(long double base, long double x) {
    return (logl(x) / logl(base));
}
int gcd (int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
int lcm(int a, int b){
    return a / gcd(a, b) * b;
}
const ll P = 1e9 + 9;
const int N = 1e6 + 1;

char a[N];
int cml[N], cmr[N];
int main(){
    int n = D();
    scanf("%s", a);
    for(int i = 1; i <= n; ++i){
        cml[i] = cml[i - 1] + (a[i - 1] == 'W');
    }
    for(int i = n; i > 0; --i){
        cmr[i] = cmr[i + 1] + (a[i - 1] == 'W');
    }
    int ans = INT_MAX;
    for(int i = 1; i <= n; ++i){
        int el = (i - 1) - cml[i - 1];
        int er = (n - i) - cmr[i + 1];
        ans = min(ans, (cml[i - 1]) + er);
        //printf("pos : %d wl = %d  el = %d wr = %d er = %d\n", i, cml[i - 1], el, cmr[i + 1], er);
    }
    printf("%d", ans);
    
}


Measured memory_bytes: 7552
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

// ────────────────────────────────────────────────────

int main() {
	int h, r;
	cin >> h >> r;

	if (h == -r) cout << 0 << endl;
	else if (h > -r) cout << 1 << endl;
	else cout << -1 << endl;
}


Measured memory_bytes: 3100