akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>
#include <string>
#include <tuple>
#include <set>

using namespace std;

int get_single_int() {
  string line;
  getline( cin, line );
  return stoi( line );
}

bool is_rect( vector<string> &table, char ch ) {
  int min_x = 10000, max_x = -1, min_y = 10000, max_y = -1;
  for ( int i = 0; i < table.size(); i++ ) {
	for ( int j = 0; j < table[ i ].length(); j++ ) {
	  if ( ch == table[ i ][ j ] ) {
		min_x = min( min_x, j );
		max_x = max( max_x, j );
		min_y = min( min_y, i );
		max_y = max( max_y, i );
	  }
	}
  }
  for ( int i = min_y; i <= max_y; i++ ) {
	for ( int j = min_x; j <= max_x; j++ ) {
	  if ( table[ i ][ j ] != '#' and ch != table[ i ][ j ] ) {
		return false;
	  }
	}
  }
  for ( int i = min_y; i <= max_y; i++ ) {
	for ( int j = min_x; j <= max_x; j++ ) {
	  table[ i ][ j ] = '#';
	}
  }
  return true;
}

int main() {
  int n = get_single_int();
  for ( int t = 0; t < n; t++ ) {
	int h, w;
	cin >> h >> w;
	string line;
	getline( cin, line );
	vector<string> table( h );
	for ( int j = 0; j < h; j++ ) {
	  getline( cin, table[ j ] );
	}
	set<char> ch_set;
	for ( int i = 0; i < h; i++ ) {
	  for ( int j = 0; j < w; j++ ) {
		if ( table[ i ][ j ] != '.' ) {
		  ch_set.insert( table[ i ][ j ] );
		}
	  }
	}
	int bef_no_ch = ch_set.size() + 1;
	while ( bef_no_ch > ch_set.size() ) {
	  bef_no_ch = ch_set.size();
	  set<char> remove_set;
	  for ( char ch : ch_set ) {
		if ( is_rect( table, ch ) ) {
		  remove_set.insert( ch );
		}
	  }
	  for ( char ch : remove_set ) {
		if ( ch_set.find( ch ) != ch_set.end() ) {
		  ch_set.erase( ch );
		}
	  }
	}
	if ( ch_set.size() == 0 ) {
	  cout << "SAFE" << endl;
	} else {
	  cout << "SUSPICIOUS" << endl;
	}
  }
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int main(void){
    int n;
    scanf("%d",&n);
    bool truth=true;
    long long t[n],a[n],m[n],ans=1,max=0;
    for (int i=0; i<n; i++){
        scanf("%lld",&t[i]);

    }
    
    for (int i=0; i<n; i++){
        scanf("%lld",&a[i]);
    }
    
    for (int i=0; i<n; i++){
        if (t[i]<=a[i]){
            m[i]=t[i];
        } else {
            m[i]=a[i];
        }
    }
    for (int i=0; i<n; i++){
        if (m[i]>max){
            max=m[i];
        }
        if (max<t[i]){
            truth=false;
        }
    }
    max=0;
    for (int i=n-1; i>=0; i--){
        if (m[i]>max){
            max=m[i];
        }
        if (max<a[i]){
            truth=false;
        }
    }
    
    bool climb=false;
    for (int i=0; i<n-1; i++){
        if (climb==false){
            if (m[i]==m[i-1]){
                ans=ans*m[i]%1000000007;
            }
        } else {
            if (m[i]==m[i+1])
                ans=ans*m[i]%1000000007;
            
        }
        if (m[i]==max){
            climb=true;
        }
    }
    
    if (truth==false){
        ans=0;
    }
    printf("%lld\n",ans);
	return 0 ;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,i,a[1005],x=0,y=0;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		x+=a[i];
	}
	double z=(double)x*1.0/(4*m);
	//printf("%f",z);
	for(i=0;i<n;i++)
	{
		//printf("%d",a[i]);
		if(a[i]>=z)
		y++;
	}
//	printf("%d",y);
	if(y>=m)
	printf("Yes\n");
	else
	printf("No\n");
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, k;
	int a[100000];
	int i, ans=0;
	
	scanf("%d %d", &n, &k);
	for(i=0; i<n; i++)
		scanf("%d", &a[i]);
	
	if(n == k)
		printf("1");
	else{
		for(i=n-1; i>0; i-=k-1)
			ans++;
		printf("%d", ans);
	}
	
	return 0;
}



Measured memory_bytes: 512
input_line1 = map(int,raw_input().split(" "))
#input_line2 = map(int,raw_input().split(" "))

input_line1.sort()
if input_line1[0] == 5 and input_line1[1] == 5 and input_line1[2] == 7:
	print "YES"
else:
	print "NO"

Measured memory_bytes: 2568
// Problem : C - Marks
// Contest : AtCoder - M-SOLUTIONS Programming Contest 2020
// URL : https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(int i=a;i>=b;i--)
//vector
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pp pop_back
//pair
#define pi pair<int ,int >
#define mk make_pair
#define ff first
#define ss second
//set
#define si set<int>
#define sit set<int>::iterator 
using namespace std;
int main()
{
fast;
ll n,k;cin>>n>>k;
ll a[n];
fr(i,0,n) cin>>a[i];
fr(i,k,n)
{
	if(a[i-k]>=a[i]) cout<<"No\n";
	else cout<<"Yes\n";
}
return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define dd(x) cout<<#x<<" = "<<x<<" "
#define de(x) cout<<#x<<" = "<<x<<"\n"
#define sz(x) int(x.size())
#define All(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef priority_queue<int> BQ;
typedef priority_queue<int,vector<int>,greater<int> > SQ;
const int maxn=3e5+10,mod=1e9+7,INF=0x3f3f3f3f;
ll pw5[maxn];
int main()
{
	for (ll i=1;i<=4000;++i)
		pw5[i]=i*i*i*i*i;
	ll x;
	cin>>x;
	for (int i=0;i<=4000;++i){
		for (int j=0;j<=4000;++j){
			if (pw5[i]-pw5[j]==x){
				cout<<i<<" "<<j;
				return 0;
			}
			if (pw5[i]+pw5[j]==x){
				cout<<i<<" "<<-j;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using ull = unsigned long long;
using ul = unsigned;
using ll = long long;
#define mod 10e+7+7
#define rep(i,a,b) for (int i =a;i<b;++i)
using namespace std;
void solve();
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin); 
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
#endif
	int t=1;
	//cin>>t;
	while(t--)
	{
	solve();
	 cout<<"\n";
	}
	
	cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
	return 0;

}
void solve()
{
	int n;
	cin>>n;
	int a[n][3];
	rep(i,0,n)
	cin>>a[i][0]>>a[i][1]>>a[i][2];
	
	int dp[n][3];
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for(int i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i-1][1]+a[i][0],dp[i-1][2]+a[i][0]);
		dp[i][1]=max(dp[i-1][0]+a[i][1],dp[i-1][2]+a[i][1]);
		dp[i][2]=max(dp[i-1][1]+a[i][2],dp[i-1][0]+a[i][2]);

	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));

}

Measured memory_bytes: 6128
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<stdlib.h>
#include<math.h>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int H, W;
char fld[1010][1010];
int dist[1010][1010];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};

signed main(){
    cin >> H >> W;
    queue<pii > que;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> fld[i][j];
            dist[i][j] = INF;
            if(fld[i][j] == '#'){
                que.push(mk(i, j));
                dist[i][j] = 0;
            }
        }
    }
    while(!que.empty()){
        int nx = que.front().first;
        int ny = que.front().second;
        que.pop();
        for(int i = 0; i < 4; i++){
            int tx = nx + dx[i];
            int ty = ny + dy[i];
            if(0 <= tx && tx < H && 0 <= ty && ty < W){
                if(fld[tx][ty] == '.'){
                    dist[tx][ty] = dist[nx][ny] + 1;
                    fld[tx][ty] = '#';
                    que.push(mk(tx, ty));
                }
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans << endl;



    

    return 0;
}
/*



*/

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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w, n;
	pii xy[214514];
	cin>>h>>w>>n;
	REP(i, n){
		cin>>xy[i].first>>xy[i].second;
		--xy[i].first;
		--xy[i].second;
	}
	sort(xy, xy+n);
	int ans=h, cnt=0;
	REP(i, n){
		if(xy[i].first==xy[i].second+cnt){
			++cnt;
		}
		else if(xy[i].first>xy[i].second+cnt){
			cout<<xy[i].first<<'\n';
			return 0;
		}
		// DEBUG(cnt);
		// DEBUG(ans);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1920
use proconio::input;

const MOD: isize = 1_000_000_007;
fn main() {
  input! {
    n: usize,
  }
  
  let mut dp = vec![
    vec![
      vec![
        vec![0;4];4
      ];4];
  n+1];
  dp[0][3][3][3] = 1;
  
  for len in 0..n {
    for c1 in 0..4 {
      for c2 in 0..4 {
        for c3 in 0..4 {
          for next in 0..4 {
            // c3_c2_c1_next
            if c2 == 0 && c1 == 1 && next == 2 { continue }
            if c2 == 1 && c1 == 0 && next == 2 { continue }
            if c2 == 0 && c1 == 2 && next == 1 { continue }
            if c3 == 0 && c2 == 1 && next == 2 { continue }
            if c3 == 0 && c1 == 1 && next == 2 { continue }
            
            dp[len+1][c2][c1][next] += dp[len][c3][c2][c1];
            dp[len+1][c2][c1][next] %= MOD;
          }
        }
      }
    }
  }
  
  let mut result = 0;
  for c1 in 0..4 {
    for c2 in 0..4 {
      for c3 in 0..4 {
        result += dp[n][c3][c2][c1];
        result %= MOD;
      }
    }
  }
  println!("{}", result);  
}

Measured memory_bytes: 2248
N,K=map(int,input().split())
snuke=[0]*N
for i in range(K):
    d=int(input())
    A=list(map(int,input().split()))
    for j in range(d):
        snuke[A[j]-1] += 1
ans=0
for i in snuke:
    if i==0:
        ans+=1
print(ans)

Measured memory_bytes: 9132
def merge(ns, ns1, ns2, n, mid):
    j = 0
    k = 0
    c = 0
    for i in range(n):
        if ns1[j] < ns2[k]:
            ns[i] = ns1[j]
            j += 1
            if j == mid:
                for l in range(n - mid - k):
                    ns[i + 1 + l] = ns2[k + l]
                return c
        else:
            ns[i] = ns2[k]
            k += 1
            c += mid - j
            if k == n - mid:
                for l in range(mid - j):
                    ns[i + 1 + l] = ns1[j + l]
                return c

def merge_sort(ns, n):
    if n <= 1:
        return 0
    elif n == 2:
        if ns[0] > ns[1]:
            k = ns[0]
            ns[0] = ns[1]
            ns[1] = k
            return 1
        else:
            return 0
    else:
        mid = n // 2
        ns1 = ns[:mid]
        ns2 = ns[mid:]
        c1 = merge_sort(ns1, mid)
        c2 = merge_sort(ns2, n - mid)
        c3 = merge(ns, ns1, ns2, n, mid)
        return c1 + c2 + c3

def compute_inversions(ns, n):
    return merge_sort(ns, n)

n = int(input())
ns = list(map(int, input().split()))

print(compute_inversions(ns, n))

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

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		try {
			int lim = Integer.parseInt(in.readLine());

			String[] nums = in.readLine().split(" ");
			int[] a = new int[lim];
			
			for (int i = 0; i < a.length; i++) {
				a[i] = Integer.parseInt(nums[i]);
			}
			
			int cnt = 0;
			for (int i = 0; i < a.length; i++) {
				for (int j = (a.length - 1); j > i; j--) {
					if (a[j] < a[j - 1]) {
						int tmp = a[j];
						a[j] = a[j - 1];
						a[j - 1] = tmp;
						cnt++;
					}
				}
			}
			
			System.out.print(a[0]);
			for (int i = 1; i < a.length; i++) {
				System.out.print(" " + a[i]);
			}
			System.out.println();
			
			System.out.println(cnt);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

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

using namespace std;
using ll = long long;
using vec = vector<int>;

#define rep(i, n)  for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
#define pout(n, a) cout << fixed << setprecision(n) << (a)
#define Cast(dig, n) static_cast<std::bitset<(dig)>>(n)

const int INF = 2147483647;
const ll  MOD = 1000000007;

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

    bool ans = true;

    while(1) {
        c -= b;
        if(c <= 0) {
            break;
        }

        a -= d;
        if(a <= 0) {
            ans = false;
            break;
        }
    }

    cout << ((ans)?"Yes":"No");
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <set>
#include <array>
#include <string>
#include <algorithm>

using namespace std;

struct Point {
	int x;
	int y;

};

int main() {

	string s;
	cin >> s;

	const char first = s[0];

	for (int index = s.size() / 2 - 1; index >= 0; index--)
	{
		bool flag = true;
		if (s[index] == first)
		{
			for (int i = 1; i < index; i++)
			{
				if (s[i] != s[index + i])
				{
					flag = false;
					break;
				}
			}

			if (flag)
			{
				cout << index * 2 << endl;
				return 0;
			}

		}
	}

	cout << 0 << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int read(){
	int x=0,f=1;char c=getchar();
	while(c>'9'||c<'0') f= c=='-' ? -1:1,c=getchar();
	while(c<='9'&&c>='0') x=10*x+c-'0',c=getchar();
	return x*f;
}
int a[2000];
int main()
{
	int n=read(),m=read();
	for(int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1);
	int ans=0;
	for(int i=1;i<=n;i++)
		if(a[i]<=m) m-=a[i],ans++;
		else break;
	if(ans==n&&m>0) ans--; 
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int int64_t
#define pb push_back
#define pii pair<int, int>
#define F first
#define S second
#define vecsort(x) sort(x.begin(), x.end())
#define vecrsort(x) sort(x.rbegin(), x.rend())
#define massort(x, n) sort(x, x + n)
#define FOR(i, n) for(int i = 0; i < n; i ++)
using namespace std;
void input();
int max(int32_t a, int b){
   return max((int)a, b);
}

int32_t main(){
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   int n; cin >> n;
   vector<pii> a(n);
   for(int i = 0; i < n; i ++){
      cin >> a[i].F;
      a[i].S = i;
   }
   sort(a.begin(), a.end());
   pii mx1 = a[n-1];
   pii mx2 = a[n-2];
   for(int i = 0; i < n; i ++){
      if(i == mx1.S){
         cout << mx2.F << endl;
      }else{
         cout << mx1.F << endl;
      }
   }
}


Measured memory_bytes: 4736
#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>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real()*a.real() + a.imag()*a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
int main() {
	string s;
	cin >> s;
	int ans = 10000;
	for(int i = 0;i < s.length()-2;++i){
		int geko = s[0+i] - '0';
		geko *= 10;
		geko += s[1+i] - '0';
		geko *= 10;
		geko += s[2+i] - '0';
		if (abs(geko - 753) < ans) {
			ans = abs(geko - 753);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // AGC032A - Limited Insertion
  int N; cin >> N;
  vector<int> b(N);
  REP(i, N){
    cin >> b[i];
  }
  vector<int> ans;
  while(b.size()){
    for(int i = b.size()-1; i >= 0; i--){
      if(b[i] == i+1){
        ans.push_back(b[i]);
        b.erase(b.begin() + i);
        break;
      }
      if(i == 0){
        cout << -1 << endl;
        return 0;
      }
    }
  }
  
  for(int i = N-1; i >= 0; i--){
    cout << ans[i] << endl;
  }  
}

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

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

	pair<int, int> p[9] = {
		{-1,-1},{0,-1},{1, -1},
		{-1, 0},{0, 0},{1, 0},
		{-1, 1},{0, 1},{1, 1},
	};

	vector<string> s(h);
	for (int i = 0; i < h; ++i)
	{
		cin >> s[i];
	}
	
	for (int i = 0; i < h; ++i)
	{

		for (int j = 0; j < w; ++j)
		{
			if (s[i][j] == '#')
			{
				continue;
			}
			int bcnt = 0;
			for (int pidx = 0; pidx < 9; ++pidx)
			{
				if (pidx == 4)
				{
					continue;
				}

				int x = j + p[pidx].first;
				int y = i + p[pidx].second;
				if (x < 0 || w <= x || y < 0 || h <= y)
				{
					continue;
				}
				if (s[y][x] == '#')
				{
					++bcnt;
				}
			}
			s[i][j] = bcnt + '0';
		}
	}

	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			printf("%c", s[i][j]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll h,w;cin>>h>>w;
  /* ans=((w+1)/2)*((h+1)/2) ;
  ans+=(h/2)*(w/2);*/
  if(h==1 || w==1){
    cout<<1<<ENDL;
  }
  else if(h*w%2){
    cout<<h*w-(h*w/2)<<ENDL;
  }else{
    cout<<h*w/2<<ENDL;
  }
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  ll x, y;
  cin >> x >> y;

  // 解答
  cout << (x % y == 0 ? -1 : x) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#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())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;

  int len = s.length();

  FOR(i,0,len-1){
    int num = (int)(s[i]-'A');
    num += n;
    num %= 26;
    s[i] = (char)('A'+num);
  }

  cout << s << endl;





}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    int a,b;
    
    cin >> a >> b;
    
    cout << (a-1)*(b-1) << endl;
    
    
    
    
    
//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1, 1, -1};
int dy[] = {1, -1, 0, 0, 1, -1};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

int board[310][310], check[310][310];
int solve_testcase() {
    int T, N; scanf("%d%d", &T, &N);
    if(T == 0 and N == 0) return 1;

    const int ofs = 70;
    const int MAXS = 305;
    fill(board[0], board[MAXS], 0);
    fill(check[0], check[MAXS], INF);
    for(int i=0; i<N; i++) {
        int x, y; scanf("%d%d", &y, &x);
        x += ofs, y += ofs;
        board[x][y] = 1;
    }

    int sx, sy; scanf("%d%d", &sy, &sx);
    sx += ofs, sy += ofs;
    int ans = 0;
    check[sx][sy] = 0;

    queue< tuple<int, int, int> > que;
    que.emplace(sx, sy, 0);
    while(que.size()) {
        int x, y, c; tie(x, y, c) = que.front();
        que.pop();
        ans++;
        if(c > check[x][y] or c == T) continue;
        for(int k=0; k<6; k++) {
            int nx = x + dx[k], ny = y + dy[k];
            if(board[nx][ny] == 0 and check[nx][ny] > c + 1) {
                check[nx][ny] = c + 1;
                que.emplace(nx, ny, c + 1);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

int main() {
    while(!solve_testcase());
    return 0;
}



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

int main(){
  string s;
  cin >> s;
  
  if(s.at(0) != s.at(1) && s.at(0) != s.at(2)&&s.at(1) != s.at(2)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
int min(int n,int m)
{
	if(n>m)
	   return m;
	else
	   return n;   
}
int a[5]; 
int main()
{
	int i,j;
    for(i=0;i<4;i++)
    {
    	scanf("%d",&a[i]);
	}
	printf("%d",min(a[0],a[1])+min(a[2],a[3]));
	return 0;  
}



Measured memory_bytes: 256
n,m = map(int,input().split())
ab_list = [list(map(int,input().split())) 
           for nesya in range(m)]
start = set()
end = set()
for ab in ab_list:
  if ab[0] == 1:
    start.add(ab[1])
  elif ab[1] == n:
    end.add(ab[0])
ans = start&end
if len(ans) > 0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')


Measured memory_bytes: 58896
program sample
  implicit none

  integer(16) :: n,m,a,b,c,ans,i
  read(*,*) n

  m=10**9+7
  a=1
  b=1
  c=1

  do i=1,n
     a=a*10
     a=mod(a,m)
  enddo

  do i=1,n
     b=b*9
     b=mod(b,m)
  enddo

  do i=1,n
     c=c*8
     c=mod(c,m)
  enddo

  ans=mod(a-b*2+c,m)

  if(ans<0)then
     ans=ans+m
  endif
  
  write(*,*) ans

  stop
end program sample

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var abcd = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            var tCount = abcd[2] / abcd[1] + (abcd[2] % abcd[1] > 0 ? 1 : 0);
            var aCount = abcd[0] / abcd[3] + (abcd[0] % abcd[3] > 0 ? 1 : 0);
            if (tCount > aCount)
            {
                Console.WriteLine("No");
                return;
            }
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 28264
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int LL;
typedef LL ll;
typedef long double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); } 
const ll M=2e5+5,LG=19,SM=600+5,inf=1e18+1;
ll mod=1e9+7;

ll n;
str z[2]={"YES","NO"};
ll s;
ll ted[M],a[M];

ll dif(ll x)
{
    //(n)*j-s==x
    x+=s;
    if (x%n || x<0) RET(z[1]);
    return x/n;
}

int main()
{
	ios::sync_with_stdio(0);
    cin >> n;
    For(i,0,n)
    {
        cin >> a[i];    
        s+=a[i];
    }
    if (s%(n*(n+1)/2)) RET(z[1]);
    s/=(n*(n+1)/2);
    ll ss=0;
    For(i,1,n)
    {
        ss+=dif(a[i-1]-a[i]);
    }
    ss+=dif(a[n-1]-a[0]);
    RET(z[s!=ss]);
}    

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

int main(){
  int N,K;
  cin>>N>>K;
  int x[N];
  int sum=0;

  for(int i=0; i<N; i++){
    cin>>x[i];
    if(x[i]<K-x[i]){
      sum+=x[i];
    }else{
      sum+=K-x[i];
    }
  }

  cout<<sum*2<<endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){

        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        if(N%10==3){
            System.out.println("bon");

        }else if(N%10==0 || N%10==1 || N%10==6 || N%10==8){
            System.out.println("pon");

        }else{
            System.out.println("hon");
        }
    }
}

Measured memory_bytes: 35768
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>

using namespace std;

typedef long long ll; 
const int MAXN = 200010;
const ll  INF = 1e16+1;

int n, m;
struct iv{
	int l, r, w;
	bool operator<(const iv &o)const{return r!=o.r?r<o.r:l<o.l;}
}a[MAXN];

ll f[MAXN];

struct node{
	int l, r;
	ll maxx, tag;
}t[MAXN<<2];
inline void pushUp(int k){
	t[k].maxx = max(t[k<<1].maxx, t[k<<1|1].maxx);
}
inline void pushDown(int k)
{
	if(!t[k].tag) return ;
	t[k<<1].maxx   += t[k].tag;
	t[k<<1|1].maxx += t[k].tag;
	t[k<<1].tag    += t[k].tag;
	t[k<<1|1].tag  += t[k].tag;
	t[k].tag = 0;
}
void build(int l, int r, int k)
{
	t[k].l = l; t[k].r = r; t[k].maxx = 0; t[k].tag = 0;
	if(l == r) return ;
	int mid = l + r >> 1;
	build(l, mid, k<<1);
	build(mid+1, r, k<<1|1);
	pushUp(k);
}
void update(int x, int y, ll val, int k)
{
	if(t[k].l >= x && t[k].r <= y){
		t[k].maxx += val;
		t[k].tag += val;
		return ;
	}
	pushDown(k);
	int mid = t[k].l + t[k].r >> 1;
	if(x <= mid) update(x, y, val, k<<1);
	if(y >= mid+1) update(x, y, val, k<<1|1);
	pushUp(k);
}
ll query(int x, int y, int k)
{
	if(t[k].l >= x && t[k].r <= y) return t[k].maxx;
	pushDown(k);
	int mid = t[k].l + t[k].r >> 1;
	ll res = -INF;
	if(x <= mid) res = max(res, query(x, y, k<<1));
	if(y >= mid+1) res = max(res, query(x, y, k<<1|1));
	return res;
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%d%d%d",&a[i].l,&a[i].r,&a[i].w);
	sort(a+1, a+m+1);
	a[m+1].r = 0;
	build(1, n, 1);
	int now = 1;
	for(int i=1;i<=n;i++)
	{
		update(i, i, query(1, i, 1), 1);
		while(a[now].r == i){
			update(a[now].l, a[now].r, a[now].w, 1);
			++now;
		}
	}
	printf("%lld\n",max(query(1, n, 1), 0ll));
	return 0;
}

Measured memory_bytes: 18816
#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>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define MOD 998244353
#define seg_size 524288
int main(){
	int a;
	cin >> a;
	if (a < 1200) {
		cout << "ABC" << endl;
	}
	else if (a < 2800) {
		cout << "ARC" << endl;
	}
	else cout << "AGC" << endl;
}

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

bool prime(int n){
  int n_root = sqrt(n);
  if(n==1){
    return false;
  }
  else if(n==2){
    return true;
  }
  else if (n%2==0){
    return false;
  }
  for(int i=3;i<n_root+1;i+=2){
    if(n%i==0){
      return false;
    }
  }
  return true;
}

int main() {
  int x;
  cin >> x;
  while (!prime(x)){
    x++;
  }
  cout << x << endl;
  return 0;
}


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n;
int p[25];

int main(){
    scanf("%d",&n);
    REP(i,n)scanf("%d",p+i);
    int ans = 0;
    FOR(i,1,n-1){
        int a[3] = {p[i-1],p[i],p[i+1]};
        sort(a,a+3);
        if(a[1]==p[i])ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n = list(map(int, list(input())))
m = len(n)

DP = [[float("inf")]*2 for i in range(m+1)]
DP[0] = [0,1]

for i in range(m):
    # tight
    tmp = float("inf")
    for j in range(10):
        if j == 0:
            tmp = min(tmp, DP[i][1]+9-n[i])
        elif j <= n[i]:
            tmp = min(tmp, DP[i][1]+j+10+j-1-n[i])
        else:
            tmp = min(tmp, DP[i][0]+j+j-1-n[i])
    DP[i+1][1] = tmp

    # not tight
    tmp = float("inf")
    for j in range(10):
        if j < n[i]:
            tmp = min(tmp, DP[i][1]+j+(10+j)-n[i])
        else:
            tmp = min(tmp, DP[i][0]+j+j-n[i])
    DP[i+1][0] = tmp

print(DP[-1][0])

Measured memory_bytes: 215036
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<cstring>
#include<queue>
#include<stack>
#include<string>
#include<cstdio>
using namespace std;
//typedef long long LL;
#define For(a,b,c) for(int a=b;a<=c;a++)
#define For_(a,b,c) for(int a=b;a>=c;a--)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define debug(x) cout<<#x<<" "<<x<<" "
int read(){
    int r=0,f=1;
    char c=getchar();
    while(!isdigit(c)){
        if(c=='-')
          f=-1;
        c=getchar();
    }
    while(isdigit(c)){
        r=(r<<1)+(r<<3)+c-'0';
        c=getchar();
    }
    return r*f;
}
#define MAXN 200005
long long ans ;
int a[MAXN];
int main(){
    int n = read();
    For(i,1,n){
        a[i] = read();
        ans ^= a[i];
    }
    For(i, 1, n){
        printf("%lld ",ans^a[i]);
    }
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 4548
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, M;
	string S;
	cin >> N >> M >> S;
	
	reverse(S.begin(), S.end());

	VI ans;
	int i = 1;
	int tmp = 0;
	int cnt = 1;
	int pos;
	while (i < N + 1) {

		if (S[i] == '0') {
			//cout << i << " " << cnt << endl;
			pos = i;
			tmp = max(tmp, cnt);
		}
		if (cnt == M) {
			if (tmp == 0) {
				cout << -1 << endl;
				return 0;
			}
			else {
				ans.push_back(tmp);
				tmp = 0;
				cnt = 0;
				i = pos;
			}
		}
		cnt++;	

		i++;
	}
	if(tmp)ans.push_back(tmp);
	reverse(ans.begin(), ans.end());
	for (int i : ans) {
		cout << i << " ";
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 1480
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef long double db;
#define pb push_back
#define mp make_pair
#define np(str) next_permutation(str.begin(),str.end())
#define ub(v,val) upper_bound(v.begin(),v.end(),val)
#define lb(v,val) lower_bound(v.begin(),v.end(),val)
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define PI 3.1415926535
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define mt make_tuple
#define repr(i,n) for( i=n-1;i>=0;i--)
#define rep(i,n) for( i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int M = 1e8 ;
int INF = 1e6;

ll n, m;


int main() {
	// your code goes here
	IOS;

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll i, j, t, k, x, y, z,  N;
	db c;
	cin >> n >> c;
	ll cnt = 0;
	rep(i, n) {
		db a, b;
		cin >> a >> b;
		if (sqrt(a * a + b * b) <= c)
			cnt++;
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 3868
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define ll long long int
#define sf(a) scanf("%d", &a)
#define forn(n) for(int i = 0; i < n; ++i)
#define form(m) for(int j = 0; j < m; ++j)
const int mx = 1e6+5;
const int inf = 0x3f3f3f3f;
 
using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n; 
	sf(n);
	int ans = 0,x;
	set<int> st;
	forn(n){
		sf(x);
		st.insert(x);
		if(st.find(x) == st.begin()) ++ans;
	}
	printf("%d\n", ans);
	return 0;
}

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

/*                        [Template]                        */
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define let auto
#define of :
#define all(y) y.begin(), y.end()
#define present( x, y ) x.find( y ) != x.end()
#define _matrix(T) vector<vector<T>>
template<class T>
auto matrix( int r, int c, T v ){
	return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
int mod = (int)1e9 + 7 ;
#define inf (int)1e18
/************************************************************/


signed main(){
	int n ; cin >> n ;
	vector<int> a(n) ;
	for( int i = 0 ; i < n ; i++ ) cin >> a[i] ;
	int sum = 0 ;
	for( int i = 0 ; i < n - 1 ; i++ ) {
		if( a[i] > a[i+1] ){
			sum += a[i] - a[i+1] ;
			a[i+1] = a[i] ;
		}
	}
	cout << sum ;
	return 0 ;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
#define fr first
#define se second
const ll mod = 1e9+7;

void solve(ll cas){
    string s;cin>>s;
    int n=s.size()-1;
    if(s[n]=='s') cout<<s+"es"<<endl;
    else cout<<s+"s"<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll qu=1;
    // cin>>qu;
    for(ll cas=1;cas<=qu;cas++){
        solve(cas);
    }
}


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

int main()
{
	int m, nmin, nmax;
	while(cin >> m >> nmin >> nmax, !(m == 0 && nmin == 0 && nmax == 0)) {
		vector<int> p(m);

		for(int i = 0; i < m; ++i) {
			cin >> p[i];
		}

		sort(p.begin(), p.end());
		reverse(p.begin(), p.end());

		int ans = 0, gap = -1;
		for(int i = nmax; i >= nmin; --i) {
			int g = p[i - 1] - p[i];

			if(gap < g) {
				ans = i;
				gap = g;
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
struct edge { ll s, t, x; };
typedef pair<ll, ll> P;
typedef pair<ll,P> event;
const ll MAX = 510000;
const ll MOD = 1000000007;

int main() {
  int N,T;
  cin>>N>>T;
  ll A[N],B[N];
  vector<P>C(N);
  rep(i,N){
    ll a,b;
    cin>>a>>b;
    C[i]=P(a,b);
  }
  sort(C.begin(),C.end());
  rep(i,N){
    A[i]=C[i].first;
    B[i]=C[i].second;
  }
  ll dp[N+1][T+1][2];
  rep(i,N+1){rep(j,T+1){dp[i][j][0]=0ll;dp[i][j][1]=0ll;}}
  rep(i,N){
    rep(j,T){
      //ふつーに選ぶとき
      if(j+A[i]<T){dp[i+1][j+A[i]][0]=max(dp[i+1][j+A[i]][0],dp[i][j][0]+B[i]);}
      dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][0]);
      //最後を選ぶとき
      dp[i+1][j][1]=max(dp[i+1][j][1],dp[i][j][0]+B[i]);
      if(j+A[i]<T){dp[i+1][j+A[i]][1]=max(dp[i+1][j+A[i]][1],dp[i][j][1]+B[i]);}
      dp[i+1][j][1]=max(dp[i+1][j][1],dp[i][j][1]);
    }
  }
  ll ans=0ll;
  rep(i,T+1){
    ans=max(ans,dp[N][i][1]);
    ans=max(ans,dp[N][i][0]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 144320
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

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

	ll n, w, m, k, ans = 0;
	cin >> n >> w;
	vll W(n), V(n);
	rep(i, n) cin >> W[i] >> V[i];
	vvll dp(n+1, vll(w+1, 0));
	repr(i, n) {
		rep(j, w + 1) {
			if (j < W[i]) dp[i][j] = dp[i + 1][j];
			else
				dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - W[i]] + V[i]);
		}
	}
	/*rep(i, n + 1) {
		rep(j, w + 1) {
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/
	cout << dp[0][w] << endl;
	return 0;
}


Measured memory_bytes: 80256
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef long long ll;
struct node{
	int x,v;
	node(int a=0,int b=0){x=a;v=b;}
}p[100010];
int h[100010],nex[200010],to[200010],a[100010],b[100010],fa[100010],M;
ll s[100010],f[100010];
bool v[100010];
void add(int a,int b){
	M++;
	to[M]=b;
	nex[M]=h[a];
	h[a]=M;
}
bool operator<(node a,node b){return a.v<b.v;}
int get(int x){return x==fa[x]?x:(fa[x]=get(fa[x]));}
int main(){
	int n,m,i,j,x,y;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++){
		scanf("%d%d",a+i,b+i);
		a[i]=max(a[i]-b[i],0);
		p[i]=node(i,a[i]);
	}
	while(m--){
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	sort(p+1,p+n+1);
	for(i=1;i<=n;i++){
		fa[i]=i;
		s[i]=b[i];
		f[i]=a[i];
	}
	for(i=1;i<=n;i++){
		v[p[i].x]=1;
		for(j=h[p[i].x];j;j=nex[j]){
			if(v[to[j]]){
				x=get(p[i].x);
				y=get(to[j]);
				if(x==y)continue;
				fa[y]=x;
				s[x]+=s[y];
				if(a[x]>f[y]+s[y])
					f[x]=min(f[x],a[x]-s[y]);
				else
					f[x]=min(f[x],f[y]);
			}
		}
	}
	x=get(1);
	printf("%lld",f[x]+s[x]);
}

Measured memory_bytes: 5760
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        boolean sucess = true;
        for(int i=0; i<N; i++) {
            int t = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();

            if ((x+y)%2 != t%2 || (x+y) > t) {
                sucess = false;
                break;
            }
        }
        if (sucess) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 87220
import java.util.Scanner;

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

			for (int i = 0; i<n; i++) {
				num[i] = sc.nextInt();
			}

			for (int i = n - 1; i >= 0; i--) {
				System.out.print(num[i]);
				if (i != 0)System.out.print(' ');
			}
			System.out.print('\n');
		}
	}
}


Measured memory_bytes: 26300
from operator import mul
from functools import reduce

def cmb(n,r):
    if n < r:
        return 0
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
  
N, M = list(map(int, input().split()))
print(cmb(N, 2) + cmb(M, 2))

Measured memory_bytes: 3700
#include<iostream>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
const long long INF=4000000000000000000LL;
typedef pair<long long,int> P;
int N,M,a=1;

int main(){
	cin>>N>>M;
	for(int i=0;i<M;++i){
		a*=2;
	}
	cout<<(1900*M+(N-M)*100)*a<<endl;
	return 0;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===



int dp[100100];



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

	int N, K; cin >> N >> K;
	Vi h(N);
	for (int i = N - 1; i >= 0; --i) {
		cin >> h[i];
	}

	for (int i = 0; i <= N ; ++i) {
		dp[i] = I_INF;
	}
	dp[1] = 0;

	for (int i = 1; i <= N - 1; ++i) {
		for (int j = 1; j <= min(K, N - i); ++j) {
			int cost = abs(h[i + j - 1] - h[i - 1]);
			dp[i + j] = min(dp[i + j], dp[i] + cost);
		}
	}

	cout << dp[N] << endl;

	return 0;
}

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

int main() {
	string moji;
	int a,b,i;
	for(i=0;i<9;i++){
		cin>>moji;
		cin>>a>>b;
		cout<<moji<<" "<<a+b<<" "<<a*200+b*300<<endl;
	}
	return 0;
}

Measured memory_bytes: 3060
private fun readInts() = readLine()!!.split(" ").map { it.toInt() }

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val S = readLine()!!

    var t = 0
    for (i in 1 until N) {
        val r = S.dropLast(i)
        val s = S.drop(N - i)
        val q = ('a'..'z').filter { r.contains(it) && s.contains(it) }.size
        if (t < q) t = q
    }

    println(t)
}

Measured memory_bytes: 33780
#include <bits/stdc++.h>
using namespace std;
int main(){
  int64_t n;
  cin >> n;
  vector<double> vec(n);
  int64_t i;
  for(i=0;i<n;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  double sum=vec.at(0)+vec.at(1);
  int64_t ni=2;
  for(i=2;i<n;i++){
    sum+=ni*vec.at(i);
    ni*=2;
  }
  cout << sum/ni;
}
    
    


Measured memory_bytes: 256