akhauriyash/Code-Regression huggingface dataset:
n = int(input())
hn =list(map(int, input().split()))

ans = 0
count = 0
for i in range(n-1):
    if hn[i+1] <= hn[i]:
        count += 1
    else:
        ans = max(ans, count)
        count=0

ans = max(ans, count)

print(ans)

Measured memory_bytes: 20256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] t = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int[] h = new int[n];
            bool[] d = new bool[n];
            int result = 1;

            for (int i = 0; i < n; i++)
            {
                h[i] = t[i];
                d[i] = true;
                if (i > 0)
                    if (h[i - 1] >= h[i])
                        d[i] = false;
            }

            for (int i = n - 1; i >= 0; i--)
            {
                if (!d[i])
                {
                    if (h[i] >= a[i])
                    {
                        h[i] = a[i];
                        d[i] = true;
                        if (i < n - 1)
                            if (h[i + 1] >= h[i])
                                d[i] = false;
                    }
                    else
                    {
                        if (i < n - 1)
                        {
                            if (a[i + 1] < a[i])
                            {
                                if (a[i] != h[i])
                                    result = 0;
                            }
                        }
                    }
                }
                else
                {
                    if (i < n - 1)
                    {
                        if (a[i + 1] < a[i])
                        {
                            if (a[i] != h[i])
                                result = 0;
                        }
                    }

                    if (h[i] > a[i])
                    {
                        result = 0;
                    }
                }
            }

            for (int i = 0; i < n; i++)
            {
                if (!d[i])
                {
                    result = (int)(((long)result * h[i]) % 1000000007);
                }
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 26688
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << ":" << x << "\n"
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;

int main() {
    int H, N;
    cin >> H >> N;
    int A_sum = 0, Ai;
    rep(i, N) {
        cin >> Ai;
        A_sum += Ai;
    }
    string ans;
    if (A_sum >= H) {
        ans = "Yes";
    } else {
        ans = "No";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int selectionSort(int a[],int n)
{
    int i,j,minj,num=0;
    for(i=0;i<n;i++)
    {
        minj=i;
        for(j=i;j<n;j++)
        {
            if(a[j]<a[minj])
            {
                minj=j;
            }
        }
        swap(a[i],a[minj]);
        if(i==minj)
            continue;
        num++;
    }
    return num;
}
int main()
{
    int N,A[101];
    cin>>N;
    for(int i=0;i<N;i++)
    {
        cin>>A[i];
    }
    int num=selectionSort(A,N);
    for(int i=0;i<N;i++)
    {
        if(i)
            cout<<" ";
        cout<<A[i];
    }
    cout<<endl<<num<<endl;
    return 0;
}



Measured memory_bytes: 3112
#ifndef CLion
#pragma GCC optimize ("O3")
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define pb push_back
#define ll long long
#define all(x) x.begin() , x.end()
#define rep(i,s,e) for (int i = s; i < e; ++i)
#define rev(i,s,e) for (int i = s; i > e; --i)
#define mem(a,v) memset(a , v , sizeof a)
//#define mod(x,m) ((x%m + m)%m)
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
        tree_order_statistics_node_update>;

const int N = 1e6 + 9 , mod = 1e9 + 7;

ll add( ll x , ll y ){
    ll ret = x + y;
    while ( ret >= mod ) ret -= mod;
    while ( ret <  0   ) ret += mod;
    return ret;
}

int ed;
ll dp[N][2][2];
ll go( int i , int z , int n ){
    if ( i == ed ) return (z && n);

    ll &ret = dp[i][z][n];
    if ( ~ret ) return ret;

    ret = 0;
    rep(j,0,10){
        ret = add(ret , go(i + 1 , (z | (j == 0)) , (n | (j == 9)) ));
    }
    return ret;
}

void Main(int cse , bool last){
    cin >> ed;
    mem(dp , -1);
    cout << go(0,0,0) ;
}

int main(){

#ifndef CLion
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif
#ifdef CLion
    freopen( "in.txt" , "r" , stdin  );
//    freopen( "out.txt", "w" , stdout );
    clock_t st = clock();
#endif

    int t = 1;
//    cin >> t;
    for ( int cse = 1; cse <= t; ++cse ) Main(cse, cse == t);

#ifdef CLion
    clock_t en = clock();
    cout << "\n\nTime: " << fixed << (en - st - 0.0) / CLOCKS_PER_SEC;
#endif
    return 0;
}

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

using namespace std;

#ifndef ONLINE_JUDGE
  #define pr_debug(...) do { printf("DEBUG: line %d: %s: ", __LINE__, __PRETTY_FUNCTION__); printf(__VA_ARGS__); } while(0)
  #define pr_vars(...) do { pr_debug(" "); pr_var(split(#__VA_ARGS__, ',').begin(), __VA_ARGS__); } while(0)
#else
  __attribute__ ((constructor)) static void fast_cin() { ios_base::sync_with_stdio(false); cin.tie(0); }
  #define pr_debug(...) do { } while(0)
  #define pr_vars(...) do { } while(0)
#endif /* ONLINE_JUDGE */

using ll = int64_t;
using ull = uint64_t;
#define X first
#define Y second
#define pb push_back

template<typename T> ostream &operator<< (ostream &fout, const vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fout << vec[i] << ' '; return fout; }

template<typename T> istream &operator>> (istream &fin, vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fin >> vec[i]; return fin; }

vector<string> split(const string &s, char c) { vector<string> v; ull st = 0, fn = 0, lvl = 0;
for ( ; fn < s.size(); fn++ ) { if (s[fn] == c && lvl == 0) { v.push_back(s.substr(st, fn - st)); st = fn + 1; }
if (s[fn] == '(') { lvl++; } if (s[fn] == ')') { lvl--; } } v.push_back(s.substr(st, fn - st)); return v; }

void pr_var(vector<string>::iterator it) { (void) it; cout << endl; }
template<typename T, typename... Args> void pr_var(vector<string>::iterator it, T a, Args... args)
{ cout << *it << "=" << a << "  "; pr_var(++it, args...); }

ll div_ceil(ll n, ll d) { ll res = n / d; if (res >= 0) res += n % d ? 1 : 0; return res; }
ll gcd(ll a, ll b) { a = llabs(a); b = llabs(b); while (a && b) a > b ? a %= b : b %= a; return a + b; }
ll lcm(ll a, ll b) { ll c = gcd(a, b); return c == 0 ? 0 : llabs(a / c * b); }

#define setp(a) fixed << setprecision(a)
const double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr ll INF = numeric_limits<ll>::max();
constexpr ll MOD = 1e9 + 7;

using mp = pair<ll, ll>;
using mt = tuple<ll, ll, ll>;    // unpack: tie(ll, ll, ll) = mt;

constexpr ll MAX = 1e5 + 5;

int main()
{
    ll res = 0;
    ll a, b, c, x, y; cin >> a >> b >> c >> x >> y;

    res = a * x + b * y;
    //pr_vars(res);

    ll r1 = 2 * x * c;
    ll y1 = y - x; if (y1 < 0) y1 = 0;
    r1 += b * y1;
    //pr_vars(r1);
    res = min(res, r1);

    r1 = 2 * y * c;
    ll x1 = x - y; if (x1 < 0) x1 = 0;
    r1 += x1 * a;
    //pr_vars(r1);
    res = min(res, r1);

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
#define ld long double
int inf=100000000;
ll INF=4000000000000000000;
ll MOD=1000000007;


int main() {
   int n,d;
   cin >> n >> d;
   vector<vector<int>> a(n,vector<int>(d));
   rep(i,n){
       rep(j,d) cin >> a.at(i).at(j);
   }
   int ans=0;
   rep(i,n-1){
       for (int j=i+1;j<n;j++){
           int t=0;
            rep(k,d){
                t+=(a.at(i).at(k)-a.at(j).at(k))*(a.at(i).at(k)-a.at(j).at(k));
            }
            for (int k=1;k<200;k++){
                if (k*k==t) ans++;
            }
       }
   }
   cout << ans << endl;
}


Measured memory_bytes: 764
#include<cstdio>

#define int long long

using namespace std;

inline int read()
{
	int x=0;int f=1;
	int c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=(x<<1)+(x<<3)+(c^48);
		c=getchar();
	}
	return x*f;
} 

int n;
int a[100010];

signed main()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		a[read()]=i;
	}
	for(int i=1;i<=n;i++)
	{
		printf("%lld ",a[i]);
	}
	return 0;
}

Measured memory_bytes: 1536
<?php
fscanf(STDIN, '%d %d', $n, $k);
fscanf(STDIN, '%s', $s);

for ($i=0; $i < $n; $i++) {
    if ($i+1 === $k) {
        echo strtolower(substr($s, $i, 1));
    } else {
        echo substr($s, $i, 1);
    }
}

echo PHP_EOL;


Measured memory_bytes: 16112
/*
    author: Salam_35
    Created at :

*/

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

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));


const ll MOD = 1e9+7;

typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

ll dp[1001][10001];
ll vis[1001][10001];
ll cost[100001];
ll weight[100001];

ll h,n;
ll fun(ll pos, ll hel)
{
    if(pos>=n)
    {
        if(hel<=0)return 0;
        return INT_MAX;
    }
    if(hel<=0)return 0;
    if(dp[pos][hel]!=-1)return dp[pos][hel];
    ll niye = cost[pos]+fun(pos,hel-weight[pos]);
    ll naniye = fun(pos+1,hel);
    return dp[pos][max(hel,0ll)]=min(niye ,naniye);
}
int main()
{
    memset(dp,-1,sizeof dp);
    cin >> h >> n;
    for(int i=0;i<n;i++)cin >> weight[i]>>cost[i];
    cout<<fun(0,h)<<endl;
}


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

int main()
{
	int64_t n;
	cin >> n;
	vector<int64_t> as(n);
	for (auto &&a : as)
	{
		cin >> a;
	}

	unordered_map<int64_t, int64_t> mp;
	for (auto &&a : as)
	{
		if (mp[a])
		{
			cout << "NO" << endl;
			return 0;
		}
		mp[a]++;
	}

	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 10056
package main

import (
	"bufio"
    "fmt"
    "os"
)

var sharp = []byte("#")[0]

func main() {
	var h, w int
	fmt.Scanf("%d %d", &h, &w)
	sc := bufio.NewScanner(os.Stdin)
	table := make([]string, h)
	for i := 0; i < h; i++ {
		sc.Scan()
		table[i] = sc.Text()
	}
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if table[i][j] == sharp {
				fmt.Printf("%s", "#")
				continue
			}
			sum := 0
			if i+1<h && j-1>=0 && table[i+1][j-1] == sharp {
				sum++
			}
			if i+1<h && table[i+1][j] == sharp {
				sum++
			}
			if i+1<h && j+1<w && table[i+1][j+1] == sharp {
				sum++
			}
			if j-1>=0 && table[i][j-1] == sharp {
				sum++
			}
			if j+1<w && table[i][j+1] == sharp {
				sum++
			}
			if i-1>=0 && j-1>=0 && table[i-1][j-1] == sharp {
				sum++
			}
			if i-1>=0 && table[i-1][j] == sharp {
				sum++
			}
			if i-1>=0 && j+1<w && table[i-1][j+1] == sharp {
				sum++
			}
			fmt.Printf("%d", sum)
		}
		fmt.Printf("\n")
	}
}

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

int main(){
    int n;
    cin>>n;
    if(n%1000==0){
        cout<<0<<endl;
        return 0;
    }
    cout<<1000-n%1000<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;

bool sort_p(pair<double, string> a, pair<double, string> b) {
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

int main() {
    while(1) {
    int n; cin >> n;
    if(n == 0) return 0;
    vector<pair<double, string>> v(n);
    rep(i, n) {
        string l;
        double res;
        double p, a, b, c, d, e, f, s, m;
        cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
        if(m == 1) res = (f*s - p) / (a+b+c+d+e);
        else res = (f*s*m - p) / (a+b+c+d*m+e*m);
        v[i].first = res;
        v[i].second = l;
    }
    sort(all(v), sort_p);
    rep(i, n) cout << v[i].second << endl;
    cout << '#' << endl;
    }
}


Measured memory_bytes: 3260
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,num,x,y,z,o;
int d[100004],head[100004],vis[100004],us[100004];
struct inqueue
{
	int to;
	int ne;
	int we;
}q[400004];
void add(int fr,int to,int we)
{
	q[++num].to=to;
	q[num].we=we;
	q[num].ne=head[fr];
	head[fr]=num;
}
int dfs_spfa(int u)
{
	us[u]=1;
	vis[u]=1;
	for(int i=head[u];i;i=q[i].ne)
	{
		if(d[q[i].to]>d[u]+q[i].we)
		{
			d[q[i].to]=d[u]+q[i].we;
			if(vis[q[i].to]) return 0;
			if(!dfs_spfa(q[i].to)) return 0;
		}
	}
	vis[u]=0;
	return 1;
}
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d %d %d",&x,&y,&z);
		add(x,y,z);
		add(y,x,-z);
	}
	for(int i=1;i<=n;i++) d[i]=0x3fffffff;
	for(int i=1;i<=n;i++)
	{
		if(!us[i]) if(!dfs_spfa(i)) o=1;
		if(o) 
		{
			printf("No");
			return 0;
		}
	}
	printf("Yes");
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define test(a) printf("(%3d)", a)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

const int MAXN = 5e4 + 10;

int mp[1001][1001];
int n, m, t, p;
int d, c, x, y;
int ox, oy, xlen, ylen;

void fold1 (int pos) { // horizontal
    for (int i = 0; i < pos; i++) {
        for (int j = 0; j < ylen; j++) {
            mp[ox-pos-1-i][oy+j] += mp[ox-pos+i][oy+j];
            mp[ox-pos+i][oy+j] = 0;
        }
    }
    xlen = (ox-pos) - min(ox-2*pos,ox-xlen);
    ox -= pos;
}

void fold2 (int pos) { // vertical
    for (int j = 0; j < pos; j++) {
        for (int i = 0; i < xlen; i++) {
            mp[ox-1-i][oy+pos+j] += mp[ox-1-i][oy+pos-1-j];
            mp[ox-1-i][oy+pos-1-j] = 0;
        }
    }
    ylen = max(oy+2*pos,oy+ylen)-(oy+pos);
    oy += pos;
}

void init (void) {
    for (int i = 0; i < xlen; i++) {
        for (int j = 0; j < ylen; j++) {
            mp[ox-1-i][oy+j] = 0;
        }
    }
    ox = 1000, oy = 0;
    xlen = m, ylen = n;
    for (int i = 0; i < xlen; i++) {
        for (int j = 0; j < ylen; j++) {
            mp[ox-i-1][oy+j] = 1;
        }
    }
}

int main (void) {
    while (~scanf("%d%d%d%d", &n, &m, &t, &p) && (n||m||t||p)) {
        init();
        while (t--) {
            scanf("%d%d", &d, &c);
            if (d == 1) fold2(c);
            else fold1(c);
        }
        while (p--) {
            scanf("%d%d", &x, &y);
            printf("%d\n", mp[ox-1-y][oy+x]);
        }
    } 
    return 0;
}


Measured memory_bytes: 4872
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b, c, n, k;
string s,t;



int main()
{
	cin >> n;
	vector<int> A(n);
	rep(i, n)
		cin >> A.at(i);
	sort(all(A),greater<int>());

	cout << A[0]-A[n-1] << endl;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long INF = 1LL << 60;
//cout<<fixed<<setprecision(10);

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> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

signed main()
{   
    gearup;
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];

    ll mi=INF;ll ave;
    for(int i=-100;i<=100;i++){
        ll sum = 0;
        rep(j,n){
            sum += pow(i-a[j],2);
        }
        if(sum < mi){
             ave = i;
             mi = sum;
        }
    }

    cout << mi << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main() 
{
    int N=0, M=0;
    int x=0;
    cin >> N >> M;
        for (int i = 0; i < M; i++)
        {
            cin >> x;
            N -= x;
        }
    if (N >= 0)
        cout << N << endl;
    else
        cout << -1;
        
        
        return  0;
}

Measured memory_bytes: 3636
import std.stdio, std.algorithm, std.range, std.format, std.numeric, std.string, std.conv, std.array;

void main() {
    int n, k;
    readf("%d %d\n", &n, &k);
    // 1 <= a, b <= n
    // b > a % b >= k >= 0
    // n / b             : a%b = 0 となる値の個数
    // n / b * (b - k)   : n - (n % b) までで余りが b > a%b >= k となる個数
    // max(0, n % b - k + min(k, 1)) : n % b >= k となる個数
    // n / b * (b - k) + max(0, n % b - min(k, 1)) : 余りが b > a%b >= k となる個数
    size_t count = 0;
    immutable mk = min(1, k) - k;
    foreach (b; k + 1.. n + 1) {
        count += n / b * (b - k) + max(0, n % b + mk);
    }
    writeln(count);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>

int main(void) {
	int cnt[26] = {}; // ??¢?????????????????????????????????????????????
	char str[1200];
	int i;
	
	while (gets(str)) {
		i = 0;
		while (str[i] != '\0') {
			if (islower(str[i])) cnt[str[i] - 'a']++;
			else if (isupper(str[i])) cnt[str[i] - 'A']++;
			i++;
		}
	}
	
	for (i = 0; i < 26; i++)
		printf("%c : %d\n", 'a' + i, cnt[i]);
	
	return 0;
}

Measured memory_bytes: 524
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	static int plen,cnum,width,cspace;
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			plen=Integer.parseInt(br.readLine());
			if(plen==0){
				break;
			}
			cnum=Integer.parseInt(br.readLine());
			width=Integer.parseInt(br.readLine());
			cspace=Integer.parseInt(br.readLine());
			String space="";
			String empty="";
			for(int i = 0;i<width;i++){
				empty=empty+".";
			}
			for(int i = 0;i<cspace;i++){
				space=space+".";
				
			}
			ArrayList<MyString> list = new ArrayList<MyString>();
			while(true){
				String s = br.readLine();
				if(s==null){
					s="";
				}
				if(s.equals("?")){
					break;
				}
				list.add(new MyString(width,s));
			}
			int cnt=0;
			ArrayList<String> strs=new ArrayList<String>();
			for(int i = 0;i<list.size();i++){
				for(int j = 0;j<list.get(i).list.size();j++){
					strs.add(list.get(i).list.get(j));
				}
				cnt+=list.get(i).list.size();
			}
			int memoNum=((cnt-1)/(cnum*plen))+1;
			cnt=0;
			String[][] ans = new String[memoNum][plen];
			for(int i  =0;i<memoNum;i++){
				for(int j = 0;j<plen;j++){
					ans[i][j]="";
				}
			}
			for(int i  =0;i<memoNum;i++){
				for(int j = 0;j<cnum;j++){
					for(int k = 0;k<plen;k++){
						if(cnt<strs.size()){
							ans[i][k]=ans[i][k]+strs.get(cnt++);
						}
						else{
							ans[i][k]=ans[i][k]+empty;
						}
						if(j!=cnum-1){
							ans[i][k]=ans[i][k]+space;
						}

					}
				}
			}
			String spacespace="";
			for(int i = 0;i<cnum;i++){
				spacespace=spacespace+empty;
			}
			for(int i = 0;i<cnum-1;i++){
				spacespace=spacespace+space;
			}
			for(int i  =0;i<memoNum;i++){
				boolean f=false;
				for(int k = 0;k<plen;k++){
					if(!ans[i][k].equals(spacespace)){
						f=true;
					}
				}
				if(f){
					for(int k = 0;k<plen;k++){
						System.out.println(ans[i][k]);
					}
					System.out.println("#");
				}
			}
			System.out.println("?");
		}
	}
}
class MyString{
	int width;
	ArrayList<String> list = new ArrayList<String>();
	MyString(int w,String s){
		width=w;
		if(s.length()==0){
			for(int i = 0;i<width;i++){
				s=s+".";
			}
			list.add(s);
		}
		else{
			int n=s.length();
			for(int i = 0;i<n;i+=w){
				if(i+w>n){
					String a=s.substring(i,n);
					for(int j = a.length();j<w;j++){
						a=a+".";
					}
					list.add(a);
				}
				else{
					list.add(s.substring(i,i+w));
				}
			}
		}
		for(int i = 0;i<list.size();i++){
			//System.out.println(list.get(i));
		}
	}
}

Measured memory_bytes: 9368
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    string s, t; cin>>s>>t;
    int n = s.size(), m = t.size();
    int lcs[n+1][m+1];

    for(int i = 0; i<=n; i++){
        for(int j = 0; j<=m; j++){
            if(i==0 || j==0) lcs[i][j] = 0;
            else if(s[i-1]==t[j-1]) lcs[i][j] = lcs[i-1][j-1] + 1;
            else lcs[i][j] = max(lcs[i-1][j], lcs[i][j-1]);
        }
    }
    if(lcs[n][m]==0) return cout<<"\n", 0;

    string res = "";
    for(int i = n, j = m; i>0 && j>0;){
        if(lcs[i][j]!=lcs[i-1][j] && lcs[i][j]!=lcs[i][j-1]){
            res.push_back(s[i-1]);
            i--; 
            j--;
        }
        else if(lcs[i-1][j]>lcs[i][j-1]) i--;
        else j--;
    }

    reverse(res.begin(),res.end());
    cout<<res<<"\n";
    return 0;
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string s;cin>>s;
	int n = s.size();
	int cnt_s = 0;
	int ans = 0;
	for(int i = 0; i < n; i++) {
		if (s[i] == 'S'){
			cnt_s++;
		}
		else{
			if (cnt_s == 0){
				ans ++;
			}
			else{
				cnt_s--;
			}
		}
	}
	cout << 2 * ans << endl;
	return 0;
}

Measured memory_bytes: 640
/*---> 22 December 2019 <--- > 17:40:04 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;

int32_t main(){__
	int n;
	cin>>n;
	int cur=1;
	vi a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		if(a[i]==cur){
			cur++;
		}
	}
	cur--;
	if(cur==0){
		cout<<-1<<"\n";
		return 0;
	}
	cout<<n-cur<<"\n";
return 0;
}

Measured memory_bytes: 1792
#pragma warning (disable :4996)
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
const double PI = cos(-1.0);
const double eps = 1e-12;
#define For(i,n,m) for(int i=n;i<=m;++i)
#define clr(a,b) memset(a,b,sizeof(a))

int n, m;

void dfs(int le,int ri,int k) {
	if (k == m + 1) return;
	dfs(le - 1, ri + 1, k + 1);
	cout << le << " " << ri << "\n";
}
int main() {
	ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	cin >> n >> m;

		int a(1), b(n);
		For(i, 1, m) {
			cout << a << " " << b << "\n";
			++a, --b;
			int d1 = b - a, d2 = n - d1;
			if (d1 == d2 || d1 + 2 == d2) --b;
		}
		

}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
int max_R[200000];
int R[200000];
int main() {
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		scanf("%d",&R[i]);
		max_R[i]=R[i];
	}
	for(int i=n-1;i>0;i--) max_R[i-1]=max(max_R[i-1],max_R[i]);
	int ans=-(1<<30);
	for(int i=0;i+1<n;i++) {
		ans=max(ans,max_R[i+1]-R[i]);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 4704
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)
string silent_ans = "RRRBBB";
string sim(vector<int> inputs) {
	int cnt[2] = {};
	REP(i, inputs.size()) {
		if (silent_ans[inputs[i] - 1] == 'R') {
			cnt[0]++;
		}
		else {
			cnt[1]++;
		}
	}
	if (cnt[0] > cnt[1]) {
		return "Red";
	}
	else {
		return "Blue";
	}
}
int cnt = 0;
int output(vector<int> inputs) {
	cnt++;
	if (cnt >= 210) {
		cout << "Limit Exceed." << endl;
		exit(0);
	}
	cout << "?";
	REP(i, inputs.size()) {
		cout << " " << inputs[i];
	}
	cout << endl;
	string s;
	cin >> s;
	if (s == "-1") {
		exit(0);
	}
	if (s == "Red") {
		return 0;
	}
	else if(s == "Blue"){
		return 1;
	}
}
int n;
int starting(int i) {
	vector<int> kousei;
	REP(q, n) {
		kousei.push_back((i + q) % (2 * n) + 1);
	}
	return output(kousei);
}
int ans[200000] = {};
int main(){
	cin >> n;
	int bot = 0;
	int top = 2*n;
	int hoge = starting(0);
	while (top - bot > 1) {
		int mid = (top + bot) / 2;
		int a = starting(mid);
		if (hoge == a) {
			bot = mid;
		}
		else {
			top = mid;
		}
	}
	//we now the itr now
	int now_itr = top;
	vector<int> checkit;
	for (int q = 0; q < n-1; ++q) {
		checkit.push_back((q + now_itr + 1));
	}
	for (int q = 0; q < 2 * n; ++q) {
		if (now_itr > q || now_itr + (n - 1) <= q) {
			checkit.push_back(q+1);
			int hoge = output(checkit);
			if (hoge == 0) {
				ans[q] = 1;
			}
			else {
				ans[q] = 2;
			}
			checkit.pop_back();
		}
	}
	int cnt[2] = {};
	checkit.clear();
	for (int q = 0; q < 2 * n; ++q) {
		if (ans[q] != 0) {
			if (ans[q] == 1) {
				cnt[0]++;
				if (cnt[0] <= n / 2) {
					checkit.push_back(q+1);
				}
			}
			else {
				cnt[1]++;
				if (cnt[1] <= n/2) {
					checkit.push_back(q+1);
				}
			}
		}
	}
	for (int q = 0; q < 2 * n; ++q) {
		if (ans[q] == 0) {
			checkit.push_back(q+1);
			int hoge = output(checkit);
			if (hoge == 0) {
				ans[q] = 1;
			}
			else {
				ans[q] = 2;
			}
			checkit.pop_back();
		}
	}
	cout << "! ";
	REP(i, 2 * n) {
		if (ans[i] == 1) {
			cout << "R";
		}
		else {
			cout << "B";
		}
	}
	cout << endl;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    i32 n; cin >> n;
    vi a(n); rep(i,n) cin >> a[i];
    sort(rbegin(a), rend(a));

    /**
     * p1-p2 + p3-p2 + p3-p4
     * -> p1 + 2*p3  -  p4 - 2*p2
     *  = p1 + 2*(p3-p2) - p4
     *  
     *  -p2 + 2*(p0 + p1) -p3
     *
     *  p1~6
     *  -> p1 + 2*(p3+p5-p2-p4) - p6
     *
     * p1-p2 + p3-p2 + p3-p4 + p5-p4
     * -> p1 + 2*p3 -2*p2 - 2*p4 + p5
     *  = p1 + 2*(p3-p2-p4) + p5
     *  
     *  8 -3 8 -1 6 -1 6 -2
     *  -> 2*(8 +6 -1) -2 -3
     *  -> 2*(p0 + p1 - p4) -p3 -p4
     *
     *  p1~3
     *  -> p1 - 2*2p + 3p
     *
     */

    i32 ans = 0, ans2 = 0;
    if(n & 1) {
        for(i32 i = 0; i < (n-2)/2; ++i) ans += 2*a[i];
        for(i32 i = (n-2)/2; i < (n-2)/2+2; ++i) ans += a[i];
        for(i32 i = (n-2)/2+2; i < n; ++i) ans -= 2*a[i];
        
        for(i32 i = 0; i < (n-2)/2+1; ++i) ans2 += 2*a[i];
        for(i32 i = (n-2)/2+1; i < (n-2)/2+1+2; ++i) ans2 -= a[i];
        for(i32 i = (n-2)/2+1+2; i < n; ++i) ans2 -= 2*a[i];        
    }
    else {
        for(i32 i = 0; i < (n-2)/2; ++i) ans += 2*a[i];
        for(i32 i = (n-2)/2; i < (n-2)/2+1; ++i) ans += a[i];
        for(i32 i = (n-2)/2+1; i < (n-2)/2+2; ++i) ans -= a[i];
        for(i32 i = (n-2)/2+2; i < n; ++i) ans -= 2*a[i];
    }

    cout << max(ans, ans2) << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 1024
N, M = [int(str) for str in input().strip().split()]
PY = [[int(str) for str in input().strip().split()] for _ in range(M)]

DEBUG = False

dbgp = print if DEBUG else lambda *x:x

rank = dict()
counter = dict([i, 1] for i in range(1, N + 1))
for p, y in sorted(PY, key= lambda x:x[1]):
    rank[y] = counter[p]
    counter[p] += 1

dbgp('rank : ', rank)
dbgp('counter : ', counter)

for p, y in PY:
    print('{0:06}{1:06}'.format(p, rank[y]))

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

int main(){
	int m, f, r;
	int sum;
	char rank[1];
	
	for(;;){
		cin >> m >> f >> r;
		if(m == -1 && f == -1 && r == -1) break;
		 
		sum = m + f;
		if(sum >= 80){
			rank[0] = 'A';
		}else if(sum >= 65){
			rank[0] = 'B';
		}else if(sum >= 50){
			rank[0] = 'C';
		}else if(sum >= 30){
			if(r >= 50){
				rank[0] = 'C';
			}else {
				rank[0] = 'D';
			}
		}else {
			rank[0] = 'F';
		}
		if(m == -1 || f == -1) rank[0] = 'F';	
		cout << rank[0] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1152
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextInt()){
			int N = sc.nextInt();
			int[] n = new int[N];

			for(int i = 0; i < N; i++)
				n[i] = sc.nextInt()*60 + sc.nextInt();

			int M = sc.nextInt();
			int[] m = new int[M];

			for(int i = 0; i < M; i++)
				m[i] = sc.nextInt()*60 + sc.nextInt();

			int[] nm = new int[N+M];
			for(int i = 0; i < N; i++)
				nm[i] = n[i];
			for(int i = 0 ; i < M; i++)
				nm[N+i] = m[i];
			Arrays.sort(nm);
			int count=0;
			for(int i=1;i<nm.length;i++){
				if((nm[i]==nm[i-1])){
					nm[i-1]=0;count++;
				}

			}
			Arrays.sort(nm);
			for(;count < N+M; count++){
				System.out.printf("%d:%02d",nm[count]/60, nm[count]%60);
			if(!(count == N+M-1))
				System.out.print(" ");
			}
			System.out.println();
		}
	}
}

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

int main(){
  string w; 
  cin>>w;
  int N=w.size();
  map<char, int> beauty;
  for(int i=0; i<N; i++){ 
    if(beauty.count(w.at(i))) beauty[w.at(i)]++;
    else beauty[w.at(i)]=1;
  }
  bool beautiful=true;
  for (auto p : beauty) {
  auto v = p.second;
  if(v%2==1) beautiful=false;
  }
  if(beautiful) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <iomanip>
#include <queue>
#include <map>
#include <set>
#include <random>
#include <sstream>
#include <stack>
#include <deque>

using namespace std;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

int H, W;
int d[10][10];
ll ans = 0;

int main() {
  cin >> H >> W;
  rep(i,10) rep(j,10) {
    int c;
    cin >> c;
    d[i][j] = c;
  }
  rep(k,10) rep(i,10) rep(j,10) {
    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  }
  rep(i,H) rep(j,W) {
    int c;
    cin >> c;
    if (c != -1) ans += d[c][1];
  }
  cout << ans << endl;
  return 0;
}


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

ll F(ll N, ll X){
    if(N==1&&X==1){return 0;}
    else if(N==1&&X==5){return 3;}
    else if(N==1){return X-1;}
    else if(N>1&&X==1){
        return 0;
    }
    else if(N>1&&2<=X&&X<=pow(2,N+1)-2){
        return F(N-1,X-1);
    }
    else if(N>1&&X==pow(2,N+1)-1){
        return pow(2,N);
    }
    else if(N>1&&X>=pow(2,N+1)&&X<=pow(2,N+2)-4){
        return pow(2,N)+F(N-1,X-pow(2,N+1)+1);
    }
    else if(N>1){
        return pow(2,N+1)-1;
    }
}


int main(){
ll N;
cin >> N;
ll X;
cin >> X;
cout<<F(N,X)<<endl;

return 0;


}  



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

int main(){
  int a,b;
  cin >> a >> b;
  if(a>b){
    for(int i=0;i<a;i++){
      cout << b;
    }
  }
  else {
    for(int i=0;i<b;i++){
      cout << a;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
//typedef long long ll;
typedef pair<int, int> P;
//const ll MOD = 1000000007LL;
int main()
{
	long long N,k;
	cin >> N >> k;
	long long number = 0;
	number = N / k;
	number = number * number*number;
	if (k%2 == 0 && N>=k/2){
		long long y = (N - k / 2) / k+1;
		
		number = number + y*y*y;
	}
	cout << number << endl; 

}

Measured memory_bytes: 256
import sys
a = []
while True:
    x = map(int, raw_input().split())
    if x[0] == 0 and x[1] == 0:
        break
    a.append(x)
for i in range(len(a)):
    for j in range(a[i][0]):
        if j == 0 or j == (a[i][0]-1):
            for k in range(a[i][1]):
                sys.stdout.write('#')
        else:
            sys.stdout.write('#')
            for k in range(a[i][1]-2):
                sys.stdout.write('.')
            sys.stdout.write('#')
        print ''
    print ''

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

using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
int dp[10010][2];
int main(){
    memset(dp, -1, sizeof(dp));
    ios_base::sync_with_stdio(false);
    string st;
    cin >> st;
    int ans = 0;
    int l = 0 ,r = st.length()-1;
    while(l < r){
        if(st[l] == 'x' && st[r] == 'x'){
            l++;
            r--;
            continue;
        }
        if(st[l] == 'x'){
            l++;
            ans++;
            continue;
        }
        if(st[r] == 'x'){
            r--;
            ans++;
            continue;
        }
        if(st[l] == st[r]){
            l++;
            r--;

            continue;
        }
        cout << "-1";
        return 0;
    }
    cout << ans;


    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define pii pair<int, int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,n,0)
#define ALL(c) ((c).begin(),(c).end())
#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define PW(n) (1LL<<(n))
using namespace std;
template <class T> inline bool CHMIN(T& a, T b) { if(a>b) { a=b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if(a<b) { a=b; return 1; } return 0; }
template <class T> inline void SORT(T& a) { sort(ALL(a)); }
template <class T> inline void REV(T& a) { reverse(ALL(a)); }
template <class T> inline void UNI(T& a) { SORT(a); a.erase(unique(ALL(a)),a.end()); }
template <class S, class T> ostream& operator<<(ostream& os, const pair<S,T> a) {
  return os << a.first << ' ' << a.second;
}
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N,M;
set<string> st[100010];
string O[100010];

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

  cin >> N;
  REP(i,N) {
    string C;
    int D;
    cin >> C >> D;
    st[D].EMP(C);
  }
  cin >> M;
  REP(i,M) cin >> O[i];
  int idx = 0;
  FOR(i,1,100001) if (!st[i].empty()) {
    if (idx < M && st[i].count(O[idx])) idx++;
  }
  cout << (idx == M ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 25892
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def divis(l):
    seq = []
    beg, end = 0, 0
    le = len(l)
    for i in range(1,le):
        end = i
        if l[i] < l[i-1]:
            seq.append(l[beg:end])
            beg = i
    seq.append(l[beg:end+1])
    return seq

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    divia = divis(a)
    saihu = 1000
    for i in divia:
        saihu += (i[-1]-i[0])*(saihu//i[0])
    print(saihu)
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 77456
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N;
  int M;
  cin >> N >> M;
  vector< long long> A(M);
  long long sum = 0;
  for (int i= 0;i<M;++i){
    cin >> A[i];
    sum += A[i];
  }
  if(N - sum >= 0){
    cout << N - sum ;
  }else{ 
    cout << -1 ;
  }
}


Measured memory_bytes: 3676
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k:Integer;
  l:array of Integer;
  s,s123,s1,s2,s3:string;
  tf:Boolean;
begin
  try
    { TODO -oUser -cConsole メイン : ここにコードを記述してください }
    Read(a);
    Readln(b);

    max:=((a+b)+(a-b)+abs((a+b)-(a-b)))div 2;
    Writeln(((a*b)+max+abs((a*b)-max))div 2);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 128
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int A, B, C;
	cin >> A >> B >> C;

	if(A != B || B != C) cout << "No" << endl;
	else cout << "Yes" << endl;


	return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
A,B,C,D = [],[],[],[]
for i in range(M):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
for i in range(M):
    if A[i] == 1:
        C.append(B[i])
    if B[i] == N:
        D.append(A[i])
print("POSSIBLE" if len(set(C) & set(D)) > 0 else "IMPOSSIBLE")

Measured memory_bytes: 28116
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const int MOD = 1000000007;
//const int MOD = 998244353;

int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

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

	cin >> H >> W >> K;
	if (W == 1) {
		cout << 1 << endl;
		return 0;
	}
	vector<vector<long long int>>dp(H + 1, vector<long long int>(W));
	dp[0][0] = 1;
	map<int, long long int>by;
	by[0] = 1;
	by[-1] = 1;
	long long int bby[] = { 1,2,3,5,8,13,21,34,55 };
	for (int i = 1; i < 9; i++)by[i] = bby[i];
	K--;
	for (int i = 1; i <= H; i++) {
		for (int j = 0; j < W; j++) {
			if (!j) {
				dp[i][j] = dp[i - 1][j + 1] * by[W - 3];
				dp[i][j] += dp[i - 1][j] * by[W - 2];
				dp[i][j] %= MOD;
			}
			else if (j == W - 1) {
				dp[i][j] = dp[i - 1][j - 1] * by[W - 3];
				dp[i][j] += dp[i - 1][j] * by[W - 2];
				dp[i][j] %= MOD;
			}
			else {
				dp[i][j] = dp[i - 1][j + 1] * by[W - 3 - j] * by[j - 1];
				dp[i][j] += dp[i - 1][j - 1] * by[W - 2 - j] * by[j - 2];
				dp[i][j] += dp[i - 1][j] * by[W - 2 - j] * by[j - 1];
				dp[i][j] %= MOD;
			}
//			cout << i << " " << j << " " << dp[i][j] << endl;
		}
	}
	cout << dp.back()[K] << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private final static int LIST_MAX = 10;
	private final static int INPUT_MIN = 0;
	private final static int INPUT_MAX = 10000;
	
	public static void main(String[]args){
		int Mt_list[];
		Mt_list = input();
		
		sort(Mt_list);
		
		show(Mt_list);
	}
	
	public static void show(int[] list){
		for(int i = 0;i < 3;i++){
			System.out.println(list[i]);
		}
	}
	
	public static int[] input(){
		Scanner stdIn = new Scanner(System.in);
		int list[] = new int[LIST_MAX];
		
		for(int i = 0;i < LIST_MAX;i++){
			int tmp = stdIn.nextInt();
			if(input_ck(tmp)){
				list[i] = tmp;
			}else{
				continue;
			}
		}
		
		stdIn.close();
		return list;
	}
	
	public static boolean input_ck(int x){
		if(INPUT_MIN <= x && x <= INPUT_MAX){
			return true;
		}
		return false;
	}
	
	public static int[] sort(int[] list){
		for(int i = 0;i < LIST_MAX - 1;i++){
			for(int j = LIST_MAX - 1;j >= i + 1;j--){
				if(list[j - 1] < list[j]){
					int work = list[j - 1];
					list[j - 1] = list[j];
					list[j] = work;
				}
			}
		}
		return list;
	}
}

Measured memory_bytes: 26348
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;

#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define vpii vector<pair<ll,ll>>
#define pll  pair<ll,ll>
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1000000000+7;
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
ll factor(ll n){
    vll ans;
	if(n==2)ans.pb(2);
	else
    {for(ll i=2;i*i<=n;i++){if(n%i==0 && n%i!=i){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}ans.pb(n);}
    return ans.sz+1;
}
ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i; 
    return res; } 
  
ll nCr(ll n, ll r){ return fact(n) / (fact(r) * fact(n - r)); } 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 

ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}

void solve()
{
	ll n;
	cin>>n;
	vll a(n);
	ll m5=0,sum=0;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
		if(a[i]%10!=0)
			m5++;
	}
	if(sum%10==0)
	{
		if(m5==0)
		{
			cout<<0;
			return;
		}
		else
		{
			sort(all(a));
			for(ll i=0;i<n;i++)
			{
				if(a[i]%10!=0)
				{
					cout<<sum-a[i];
					return;
				}
			}
		}
	}
	else
		cout<<sum;
	return;
	
	
}            
int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cmath>
#include <time.h>
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) ((c).rbegin(),(c).rend())
//#define sort(v,n) sort(v,v+n)
#define ll long long
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//

int n, k, s;
int a[30];
ll cont;
inline void solve(int now,ll sum,int b) {
	if (b==n) {
		if (now==k && sum == s) {
			cont++; return;
		}
		else {
			return;
		}
	}
	else {
		solve(now + 1, sum + a[b], b + 1);
		solve(now, sum, b + 1);
	}
}

int main() {
	while (cin >> n >> k >> s, n) {
		for (int i = 0; i < n; i++) {
			a[i] = i + 1;
		}
		cont = 0;
		solve(0, 0, 0);
		cout << cont << endl;
	}
	return 0;
}

Measured memory_bytes: 3072