akhauriyash/Code-Regression huggingface dataset:
//Volume0-0085
import java.util.Scanner;

public class Main {

	public static void main(String[] args){

	    //declare
		int        n,m,num,cnt,i;
		String  [] s;
		boolean [] list;

        //input
        Scanner sc = new Scanner(System.in);

        while(true){
        	s = sc.nextLine().split("\\s");
        	n = Integer.parseInt(s[0]);
        	m = Integer.parseInt(s[1]);
        	if((n|m) == 0){break;}

        	//calculate
        	list = new boolean[n];
        	num = n;
        	i   = n;
        	while(num-- > 0){
            	cnt = 0;
        		for(;cnt<m;i++){
        			if(!list[i=i%n]){cnt++;}
        		}
        		list[(i-1+n)%n] = true;
        	}

        	//output
        	System.out.println(i);
        }
	}
}

Measured memory_bytes: 19352
#include<bits/stdc++.h>
using namespace std;
int main(){
    float N,T,A,best=150000;
    int answer=0;
    cin >> N >> T >> A;
    vector<float>H(N);
    for(int i=0;i<N;i++){
        cin >> H.at(i);
        float a=T-H.at(i)*0.006;
        if(max(A,a)-min(A,a)<best){
            best=max(A,a)-min(A,a);
            answer=i+1;
        }
    }
    cout << answer;
}

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

int main() {
  int n,c,m;
  cin >> n;
  m=n;
  c=0;
  while(n/10.0>0){
    c += n%10;
    n /= 10;
}
  if(m/c==m/(c+0.0))  cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<string>
#include<algorithm>
#include<bitset>
typedef long long ll;

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define MOD 1000000007;
using namespace std;
ll k,c=0,ans=0;;
deque<ll>d;
int main(){
    cin>>k;

    rep(i,1,10)d.push_back(i);
    while(c<k){
        c++;
        ans = d.front();
        //puts(ans);
        d.pop_front();
        
        ll m=ans%10;
        if(m!=0){
            d.push_back(ans*10+m-1);
        }
        d.push_back(ans*10+m);
        if(m%10!=9){
            d.push_back(ans*10+m+1);
        }
    }
    puts(ans);
}  


Measured memory_bytes: 1792
/*
  AUTHOR:SOURABH
  CREATED:19:01:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

mll c;
vector<vector<pll> > adj(10001);
ll tot;

ll modex(ll x,ll y)
{
    x=x%mod;
    ll r=1;
    while(y>0)
    {
        if(y%2==1)
            r=(r*x)%mod;
        y/=2;
        x=(x*x)%mod;
    }
    return r;
}

ll mm(ll x,ll y)
{
    x=x%mod;
    y=y%mod;
    return (x*y)%mod;
}

ll solve(ll id)
{
    ll p=1,q=1,i,k=adj[id].size();
    fn(i,k)
    {
        p=mm(p,modex(adj[id][i].fi,c[adj[id][i].fi]-adj[id][i].se));
        q=mm(q,modex(adj[id][i].fi,c[adj[id][i].fi]));
    }
    q=mm(tot,modex(q,mod-2));
    p=mm(p,q);
    return p;
}

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

    //freopen("in.txt","r",stdin);
    //freopen(2 "out.txt","w",stdout);

    ll n,v,i,j,ans=0,g,c1;
    cin>>n;
    fn(i,n)
    {
        cin>>v;
        for(j=2;j*j<=v;j++)
        {
            if(v%j==0)
            {
                c1=0;
                W(v%j==0)
                {v/=j;c1++;}
                c[j]=max(c[j],c1);
                adj[i].pb({j,c1});
            }
        }
        if(v>1)
        {c[v]=max(c[v],1LL);adj[i].pb({v,1});}
    }
    mll::iterator it;
    tot=1;
    fit(it,c)
    tot=mm(tot,modex(it->fi,it->se));
    //cout<<tot<<endl;
    fn(i,n)
    ans=(ans+solve(i))%mod;
    cout<<ans;
}










Measured memory_bytes: 1920
//Shuncha's code???

#include "bits/stdc++.h"
 
typedef struct {
    int ax, ay, bx, by, cnt;
} TWIN_t;
 
TWIN_t queue[300000];
int head, tail;
 
void enq(TWIN_t t)
{
    queue[(tail++) % 300000] = t;
}
 
void deq(TWIN_t *t)
{
    *t = queue[(head++) % 300000];
}
 
int main(void)
{
    TWIN_t first, temp;
    int x, y, i, j, dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}, flag;
    char map[51][51];
    static char v[51][51][51][51];
     
    while (1){
        scanf("%d %d", &x, &y);
         
        if (x + y == 0)
            break;
         
        scanf("%d %d", &first.ax, &first.ay);
        scanf("%d %d", &first.bx, &first.by);
         
        first.ax -= 1;
        first.ay -= 1;
        first.bx -= 1;
        first.by -= 1;
         
        for (i = 0; i < y; i++){

            for (j = 0; j < x; j++)
                scanf("%d", &map[i][j]);
        }

        first.cnt = temp.cnt = 0;
        head = tail = 0;
        memset(v, 0, sizeof(v));
        v[first.ay][first.ax][first.by][first.bx] = 1;
        enq(first);
		flag = 0;

        while (head != tail){
            deq(&temp);
             
            if (temp.cnt >= 100)
                break;
             
            if (temp.ax == temp.bx && temp.ay == temp.by){
                printf("%d\n", temp.cnt);
                flag = 1;
                break;
            }
             
            for (i = 0; i < 4; i++){
                first = temp;

                if (0 <= first.ax + dx[i] && first.ax + dx[i] < x && 0 <= first.ay + dy[i] && first.ay + dy[i] < y && map[first.ay + dy[i]][first.ax + dx[i]] == 0){
                    first.ax += dx[i];
                    first.ay += dy[i];
                }

                if (0 <= first.bx - dx[i] && first.bx - dx[i] < x && 0 <= first.by - dy[i] && first.by - dy[i] < y && map[first.by - dy[i]][first.bx - dx[i]] == 0){
                    first.bx -= dx[i];
                    first.by -= dy[i];
                }

                first.cnt++;

                if (!v[first.ay][first.ax][first.by][first.bx]){
                    v[first.ay][first.ax][first.by][first.bx] = 1;
                    enq(first);
                }
            }
        }
        if (!flag)
            printf("NA\n");
    }
     
    return 0;
}

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

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<LL> VI;
typedef unsigned long long ULL;

#define MP make_pair
#define PB push_back
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)a.size()
#define f first
#define s second
#define FILL(a, b) memset(a, b, sizeof(a))

const int MAX = 200*1000 + 7;
const int INF = 1000*1000*1000;
const LL LINF = 1LL*INF*INF;
const int MOD = 998244353;
const double PI = acos(-1.);

LL dpT1[MAX][3];
LL dp1(int n, int ost)
{
	if(n==0)
	{
		return (ost==0);
	}
	if(dpT1[n][ost] != -1)
		return dpT1[n][ost];
	LL ans = 0;
	FOR(i, 0, 3)
	{
		ans += dp1(n-1, (ost + 3 - i)%3);
	}
	return dpT1[n][ost] = ans % MOD;
}
LL dpT2[MAX][3][4];
LL dp2(int n, int ost, int prev)
{
	if(n==0)
	{
		return (ost==0);
	}
	if(dpT2[n][ost][prev] != -1)
		return dpT2[n][ost][prev];
	LL ans = 0;
	FOR(i, 0, 3)
	{
		if(i != prev)
			ans += dp2(n-1, (ost + 3 - i)%3, i);
	}
	return dpT2[n][ost][prev] = ans% MOD;
}

int cnt = 0;
map<string, int> used;
void dfs(string s)
{
	cnt++;
	used[s] = 1;
	FOR(i,0,SZ(s)-1)
	{
		if(s[i] != s[i+1])
		{
			string ns = s;
			int ind = 3 - (s[i]-'a') - (s[i+1]-'a');
			ns[i] = char(int('a') + ind);
			ns[i+1] = char(int('a') + ind);
			if(!used[ns])
				dfs(ns);
		}
	}
}
int brut(string s)
{
	dfs(s);
	return cnt;
}
int main()
{
	ios_base::sync_with_stdio(0);
	string s;
	cin >> s;
	bool ok = 1;
	FOR(i,0,SZ(s))
		if(s[i]!= s[0])
			ok = 0;
	if(ok)
	{
		cout << 1;
		return 0;
	}
	if(SZ(s)!=3)
	{
		FILL(dpT1, -1);
		FILL(dpT2, -1);
		int ost = 0;
		FOR(i,0,SZ(s))
			ost += (s[i] - 'a');
		ost %= 3;
		int no_double = 1;
		FOR(i,0,SZ(s) - 1)
			if(s[i]==s[i+1])
				no_double = 0;
		cout << (dp1(SZ(s), ost) + MOD - dp2(SZ(s), ost, 3) + no_double)%MOD;
	}
	else
	{
		cout << brut(s);
	}
	return 0;
}


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

int main()
{
	int h, w;
	while (cin >> h >> w, h || w)
	{
		for (int i = 0; i < h; i++)
		{
			for (int j = 0; j < w; j++) cout << '#';
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3060
from collections import defaultdict
from itertools import combinations
march = ['M','A','R','C','H']
combi = combinations(march,3)
N = int(input())
dic = defaultdict(int)
for i in range(N):
    c = input()[0]
    if c in march:
        dic[c] += 1
ans = 0
for c1,c2,c3 in combi: ans += dic[c1]*dic[c2]*dic[c3]
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define int long long
using pi=pair<int,int>;

signed main(){
  int n,mdi=0;
  cin>>n;
  vector<int> a(n-1),b(n-1),col(n,0),dim(n,0);
  vector<vector<int>> G(n);
  for(int i=0;i<n-1;++i){
    cin>>a[i]>>b[i];
    --a[i],--b[i];
    ++dim[a[i]],++dim[b[i]];
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }
  for(int i=0;i<n;++i)if(dim[mdi]<dim[i])mdi=i;
  map<pi,int> res;
  vector<bool> vis(n,false);
  cout<<dim[mdi]<<"\n";
  queue<int> que;
  que.push(mdi);
  while(!que.empty()){
    int q=que.front();
    que.pop();
    int c=1;
    vis[q]=true;
    for(auto i:G[q])if(!vis[i]){
      while(c==col[q])++c;
      res[pi(q,i)]=res[pi(i,q)]=col[i]=c++;
      que.push(i);
    }
  }
  for(int i=0;i<n-1;++i)cout<<res[pi(a[i],b[i])]<<"\n";
}

Measured memory_bytes: 22144
D, N = map(int, input().split())
if D == 2:
  if N == 100:
    print(1010000)
  else:
    print(N*10000)
elif D == 0:
  if N == 100:
    print(101)
  else:
    print(N)
else:
  if N == 100:
    print(10100)
  else:
    print(N*100)
  

Measured memory_bytes: 9192
#107_B
H,W=map(int,input().split())
A=[]
for _ in range(H):
    S=input()
    if set(S)=={'.'}:
        continue
    A.append(list(S))
for w in range(W-1,-1,-1):
    flg=True
    for h in range(len(A)):
        if A[h][w]=='#':
            flg=False
    if flg:
        for h in range(len(A)):
            A[h].pop(w)

for s in A:
    print(''.join(s))

Measured memory_bytes: 3064
def partition(A, p, r):
    x = A[r][1]
    i = p-1
    for j in range(p, r):
        if A[j][1] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1

def quick_sort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quick_sort(A, p, q-1)
        quick_sort(A, q+1, r)

n = int(input())
card = []
tmpdic = {}
for i in range(n):
    suit, num = input().split()
    num = int(num)
    card.append((suit, num))
    if num in tmpdic:
        tmpdic[num] += suit
    else:
        tmpdic[num] = suit

order = ""
for i in sorted(tmpdic.keys()):
    order += tmpdic[i]

quick_sort(card, 0, n-1)

for i in range(n):
    if order[i] != card[i][0]:
        print("Not stable")
        break
    if i == n-1:
        print("Stable")

for suit, num in card:
    print(f"{suit} {num}")


Measured memory_bytes: 19172
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define pb push_back
#define mpr make_pair
#define Senky_Bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{   
    Senky_Bansal
    IIIT_ALLAHABAD
    ll a,b;
  cin>>a>>b;
  ll p=max(a,b);
  cout<<max(a+b,p+p-1);
    
        






}

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

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


#define      TEST    int t ; cin >> t ; while( t -- )

const ll big = 10e7 + 11 ;

int  main (  ) {

    FASTIO ;

    double n ;
    cin >> n ;

    double ans = 2 * 3.1416 * n ;

    cout << ans ;

    return  0 ;
}


Measured memory_bytes: 3800
use text_io::*;
use std::collections::HashMap;
use std::process::exit;

fn main() {
    let n:usize = read!();
    let ss:String = read!();
    let s:Vec<char> = ss.chars().collect();
    let mut k:usize = 0;
    for i in 0..n-2 {
        if s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C' {
            k += 1;
        }
    }
    println!("{}",k);
}


Measured memory_bytes: 2148
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }


/*
<url:https://onlinejudge.u-aizu.ac.jp/services/room.html#RitsCamp18Day1/problems/B>
問題文============================================================
 AORイカちゃんは集合 S={a1,...,aN} と写像 f:S→Sを作った。
 f(ai)=bi である。
 集合 S の任意の要素 x について、g(f(x))=h(f(x)) を満たす全ての写像 g,h:S→S が、
 g(x)=h(x) を満たすかどうか判定し、満たさない場合は反例を一つ構成せよ。

=================================================================

解説=============================================================

 set(b[i]) のサイズがNであれば YES
 Nでなければ、{1..N} のなかで存在しない値に該当する部分を変えれば良い
 
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> a(N),b(N);
    for(auto& in:a) {cin >> in; in--;}
    for(auto& in:b) {cin >> in; in--;}
    set<ll> s(b.begin(),b.end());
    if(s.size() == N){
        cout << "Yes" << endl;
    }else{
        vector<int> f(N,0);
        for(auto it:s){
            f[it] = 1;
        }
        vector<ll> c(N),d(N);
        iota(c.begin(),c.end(),1);
        iota(d.begin(),d.end(),1);
        for(int i = 0; i < N;i++){
            if(f[a[i]] == 0){
                c[i] = i+1;
                if(i == 0) d[i] = 2;
                else d[i] = 1;
            }else{
                c[i] = i+1;
                d[i] = i+1;
            }
        }
        cout << "No" << endl;
        cout << c << endl;
        cout << d << endl;

    }
	return 0;
}



Measured memory_bytes: 10836
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	int N, T;
	cin >> N >> T;
	vi A(N);
	vi B(N);
	vector<pii> BB(N);
	rep(i, N) {
		cin >> A[i] >> B[i];
		BB[i].first = A[i];
		BB[i].second = i;
	}
	sort(BB.begin(), BB.end(), greater<pii>());
	vi Aa(N);
	vi Bb(N);
	rep(i, N) {
		Aa[i] = A[BB[i].second];
		Bb[i] = B[BB[i].second];
	}
	A = Aa;
	B = Bb;
	vector<vector<vi>> ansmax(N + 1);
	rep(i, N + 1) {
		ansmax[i].resize(T + 1);
		rep(j, T + 1) {
			ansmax[i][j].resize(2);
			rep(b, 2) {
				ansmax[i][j][b] = 0;
			}
		}
	}
	rep(i, N) {
		int Atmp = A[i];
		int Btmp = B[i];
		ansmax[i + 1] = ansmax[i];
		rep(j, T + 1) {
			rep(b, 2) {
				int jnew = j + Atmp;
				int Bnew = ansmax[i][j][b] + Btmp;
				if (b == 0) {
					if (Bnew > ansmax[i + 1][j][1]) {
						ansmax[i + 1][j][1] = Bnew;
					}
				}
				if (jnew >= T)
					continue;
				if (Bnew > ansmax[i + 1][jnew][b]) {
					ansmax[i + 1][jnew][b] = Bnew;
				}
			}
		}
	}
	int ans = 0;
	rep(j, T + 1) {
		rep(b, 2) {
			int eval = ansmax[N][j][b];
			ans = max(ans, eval);
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 492928
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

typedef struct CELL{
    int row;
    int col;
}CELL;

int dp[100][100];


int main( ){
    
    int i, j, k, n;
    
    scanf("%d", &n);
    
    CELL *A = (CELL *)malloc(sizeof(CELL)*(n+1));
    
    for (i=0; i<n; i++) {
        scanf("%d %d", &(A[i].row), &(A[i].col));
    }
    
    for (i=0; i < 100; i++) {
        for (j=0; j < 100; j++) {
            if (i==j) {
                dp[i][j] = 0;
            }
            else{
                dp[i][j] = 100000000;
            }
            
        }
    }
    
    
    j = 1;

    for (j=1; j < n; j++) {
        for (i=0; i + j < n; i++) {
            for (k = i; k < i+j; k++) {
                if( dp[i][i+j] > dp[i][k] + dp[k+1][i+j] + A[i].row * A[k].col * A[i+j].col){
                    dp[i][i+j] = dp[i][k] + dp[k+1][i+j] + A[i].row * A[k].col * A[i+j].col;
                }
            }
        }
    }
    
    printf("%d\n", dp[0][n-1]);
    
    return 0;
}

Measured memory_bytes: 632
import sys


input = sys.stdin.readline


def main():
    m = N % 10
    if m in [2, 4, 5, 7, 9]:
        print("hon")
    elif m in [0, 1, 6, 8]:
        print("pon")
    else:
        print("bon")


if __name__ == "__main__":
    N = int(input())
    main()


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

int gcd(int a, int b) {
  if(a < b) return gcd(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
  int K; cin >> K;
  ll ans=0;
  for(int i=1;i<=K;i++){
    for(int j=1;j<=K;j++){
      for(int k=1;k<=K;k++){
        ans+=gcd(gcd(i,j),k);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());
	if(s < t)
		cout << "Yes" << "\n";
	else
		cout << "No"<< "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  long n,k;
  cin >> n >> k;
  if (n < k){
    if (k-n > n){
      cout << n << endl;
    } else {
      cout << k - n << endl;
    }
  } else{
    long b = n % k;
    if (b > k % 2){
      cout << k - b << endl;
    } else {
      cout << b << endl;
    }
  }
}

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

int main()
{  
  char r,s;
  cin >> r >> s;
  if(r==s){
    cout << "Bad";
    return 0;
  }
  r=s;
  cin >> s;
  if(r==s){
    cout << "Bad";
    return 0;
  }
  r=s;
  cin >> s;
  if(r==s){
    cout << "Bad";
    return 0;
  }
  cout << "Good";
  return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, K; cin >> N >> K;
	int dislike = 0;
	for (int i = 0; i < K; i++) {
		int D; cin >> D;
		dislike |= 1 << D;
	}

	auto is_good = [&](int x) -> bool {
		while (x) {
			if (dislike & (1 << (x%10))) return false;
			x /= 10;
		}
		return true;
	};

	int ans = N;
	while (!is_good(ans)) ans++;
	cout << ans << '\n';

	return 0;
}


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

bool solve(int A, int B) {
    int C = 1;
    int count = 0;
    for (int i = 1; i <= 3; i++) {
        int x;
        x = A * B * C;
        if (x % 2 != 0) {
            count++;
        }
    }
    if (count > 0) {
        return true;
    }
    else {
        return false;
    }
}

int main() {

    int A, B;

    cin >> A >> B;

    if (solve(A, B) == true) {
        cout << "Yes" << endl;
    }

    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#pragma warning(disable:4996)

int main() {
	int n = 0 , c = 0;

	scanf("%d", &n);
		
	printf("%d\n", (int)pow(n, 3));

	//system("PAUSE");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string key;
	
	while (getline(cin, key)) {

		for (int j = 0; j < 26; j++) {
			for (int i = 0; i < key.size(); i++) {
				if (key[i] >= 'a' && key[i] <= 'z') {
					key[i] = (key[i] == 'z') ? 'a' : key[i] + 1;
				}
			}

			if (key.find("the") != string::npos || key.find("this") != string::npos || key.find("that") != string::npos)
				cout << key<<endl;
		}
	}
	return 0;
}

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

int main() {
	int n; cin >> n;
	vector<int> a(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	int count = 0;
	int d = 1;
	for (int i = 1; i <= n; i++) {
		if (a[i] == d) {
			d++;
		}
		else {
			count++;
		}
	}

	if (d == 1) cout << -1 << endl;
	else cout << count << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

#define DATA_MAX     (52)
#define MAX(a,b)    ((a)>(b)?(a):(b))

int scan_line(int *buf){
    int cnt;
    char c;
    cnt = 0;
    while( (scanf("%d%c",&buf[cnt],&c)>0) && (++cnt) && (c!='\n') );
    return cnt;
}

int main(){
    int buf[2][DATA_MAX];
    int cnt[2];
    int now,pre;
    int i;

    cnt[0] = scan_line( buf[0] );
    pre = 0;
    now = 1;

    while( (cnt[now] = scan_line( buf[now] )) && (cnt[now] > 0) ){
        if(cnt[pre]<cnt[now]){
            /* upper half */
            /*     0       1     */
            /*   /   \   /   \   */
            /* 0       1       2 */
            /* +       +       + */
            /* 0    MAX(0,1)   2 */
            buf[now][0] += buf[pre][0];
            for(i=1;i<cnt[now]-1;i++){
                buf[now][i] += MAX(buf[pre][i-1], buf[pre][i]);
            }
            buf[now][cnt[now]-1] += buf[pre][cnt[now]-2];
        }else{
            /* lower half */
            /* 0       1       2 */
            /*   \   /   \   /   */
            /*     0       1     */
            /*     +       +     */
            /* MAX(0,1) MAX(1,2) */
            for(i=0;i<cnt[now];i++){
                buf[now][i] += MAX(buf[pre][i], buf[pre][i+1]);
            }
        }
        pre = now;
        now = 1-pre;
    }

    printf("%d\n",buf[pre][0]);

    return 0;
}

Measured memory_bytes: 600
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
	ll y;
	ll b=100;
	cin>>y;
	for(int i=0;;i++)
	{
		if(b>=y){
			cout<<i;
			break;
		}
		else{
			b =(ll)(b*1.01);
		}
	}
	
	return 0;
}


Measured memory_bytes: 3636
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;

#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#define deb1(x)      	cout << #x << "=" << x << endl
#define deb2(x, y)  	cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z)  	cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x,y) 		memset(x, y, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x


const int N=1e5 + 5;
const int MOD=1e9 + 7;

int32_t main()
{
	IOS;
	int T=1;
	//cin >> T;
	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		int n;
		cin >> n;
		int a[n+5];
		int c = 0;
		rep(i,1,n)
		{
			cin >> a[i];
		}
		rep(i,1,n)
		{
			if(i%2==1 && a[i]%2==1)
				c++;
		}
		cout << c;
	}
}

Measured memory_bytes: 3648
def d_triangles():
    from itertools import combinations
    from bisect import bisect_right
    N = int(input())
    L = sorted([int(i) for i in input().split()])

    ans = 0
    for max_index in range(2, N):
        c = L[max_index]
        for second_index in range(max_index):
            b = L[second_index]
            other_index = bisect_right(L, c - b)
            if max_index > other_index:
                ans += max_index - other_index
                if other_index <= second_index:
                    ans -= 1
    return ans // 2

print(d_triangles())

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N,K,sum,max,min;
	cin>>N>>K;
	max=N-K+1;
	min=1;
	sum=max-min;
	if(K!=1)
	cout<<sum<<endl;
	else
	cout<<"0"<<endl;
	return 0;
}

Measured memory_bytes: 256
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    x,y = map(int,ipt().split())
    if y%2 == 0 and x*2 <= y <= x*4:
        print("Yes")
    else:
        print("No")

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 9704
#include <bits/stdc++.h>
#include <math.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++)
using ll = long long;
using vec = vector<ll>;
using vec2 = vector<vector<ll>>;
ll inf = pow(2,62);

ll keta(ll x){
    ll digits = 0;
    while(x > 0){
        x /= 10;
        digits++;
    }
    return digits;
}

int main(){
    ll n;cin >> n;
    ll ans = keta(n);
    for(ll i = 1;i*i <= n;i++){
        if(n % i != 0){
            continue;
        }
        else{
            ll a = i;
            ll b = n / a;
            if(a > b){
                break;
            }
            ll f = max(keta(a),keta(b));
            ans = min(ans, f);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
import java.util.stream.*;
import java.io.*;

public class Main {

  static int n, k, ans;
  static boolean[] motu;
  
  public static void main(String[] args) throws Exception {
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    String[] in = br.readLine().split(" ");
    n = Integer.parseInt(in[0]);
    k = Integer.parseInt(in[1]);

    motu = new boolean[n];

    for(int i = 0; i < k; i++){
      in = br.readLine().split(" ");
      int d = Integer.parseInt(in[0]);
      in = br.readLine().split(" ");
      int[] a = Stream.of(in).mapToInt(Integer::parseInt).toArray();
      
      for(int j = 0; j < d; j++){
        motu[a[j] - 1] = true;
      }
    }
    
    br.close();

    ans = 0;

    for(int i = 0; i < n; i++){
      if(!motu[i]) ans++;
    }

    PrintWriter out = new PrintWriter(System.out);
    out.println(ans);
    out.flush();

  }
}

Measured memory_bytes: 35816
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void){
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n;
  cin>>n;
  std::vector<int> pos(n+1);
  for(int i=1;i<=n;i++){
    int a;
    cin>>a;
    pos[a]=i;
  }

  int curr_pos=0;
  int max_len=0;
  int len=0;
  for(int i=1;i<=n;i++){
    if(curr_pos<pos[i]){
      len++;
      curr_pos=pos[i];
    }else{
      max_len=std::max(max_len,len);
      curr_pos=pos[i];
      len=1;
    }
  }

  max_len=std::max(max_len,len);

  cout<<n-max_len<<endl;







  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;
ll power(ll a,ll b)
{
    ll res =1;
    while(b)
    {
        if(b&1) res = (res%mod*a%mod)%mod;
        b/=2;
        a = (a%mod*a%mod)%mod;
    }
    return res;
}
ll sieve[1000005];
void pre()
{
    sieve[0]=1;
    sieve[1]=1;
    for(int i=2;i<1000005;i++)
    {
        if(sieve[i]==0)
        for(int j=2*i;j<1000005;j+=i)
        {
            sieve[j]=1;
        }
    }
}
ll ch(ll p)
{
    ll sum=0;
    while(p)
    {
        sum++;
        p/=10;
    }
    if(sum%2!=0)
    return 1;
    else
    return 0;
}
signed main()
{
    
    senky_bansal
    IIIT_ALLAHABAD
      
    string s;
    cin>>s;
    ll p = s.size();
    vector<ll>v;
    map<ll,ll>mp;
    for(int i=0;i<s.size()-1;i++)
    {
         if(s[i]=='R' && s[i+1]=='L')
        {
            mp[i]=1;
            mp[i+1]=1;
            v.pb(i);
            i++;
        }
    }
    for(int i=0;i<s.size();i++)
    {
        if(mp[i]==0)
        {
             if(s[i]=='R')
             {
                 ll p1 = upper_bound(v.begin(),v.end(),i)-v.begin();
                 if((v[p1]-i)%2==0)
                 mp[v[p1]]+=1;
                 else
                 mp[v[p1]+1]+=1;
             }
             else
             {
                 ll p1 = upper_bound(v.begin(),v.end(),i)-v.begin();
                 p1--;
                 if((v[p1]-i)%2==0)
                 mp[v[p1]]+=1;
                 else
                 mp[v[p1]+1]+=1;
             }
        }
    }
    for(int i=0;i<s.size();i++)
    cout<<mp[i]<<" ";
    
    
}








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

int main() {
  int N,Max =1,Ans =0;
  vector<int> H(100);
  cin >> N;
  
  for(int i =0;i < N;i++){
    cin >> H.at(i);
  }
  for(int j =0;j <N;j++){
    if(H.at(j) >= Max){
      Max = H.at(j);
      Ans += 1;
    }
  }
  cout << Ans << endl;
}
  
  


Measured memory_bytes: 256
// finish date: 2018/01/21
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    int X;
    cin >> X;
    int b2_4ac = (int) sqrt(1 + (ll) 8 * X);
    int n = (-1 + b2_4ac) / 2;
    if ((ll) b2_4ac * b2_4ac != 1 + (ll) 8 * X) n++;
    cout << n << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int a, t, r;

  cin >> a >> t >> r;

  double ans = (double)t / a * r;

  printf("%.10lf\n", ans);

  return 0;
}



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

int n, y;
int d[100];
int a10 = -1, a5 = -1, a1 = -1;

int main() {
    cin >> n >> y;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n - i; j++) {
            int k = n - i - j;
            int total = k * 10000 + j * 5000 + i * 1000;
            if (total == y) {
                a10 = k;
                a5 = j;
                a1 = i;
                break;
            }
            else if (total < y) {
                break;
            }
        }
    }
    cout << a10 << ' ' << a5 << ' ' << a1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<algorithm>
#define mod 1000000007
using namespace std;
typedef long long ll;
const int maxn=10000000;
int main()
{
	int n,x,num4,num1,i;
	while(scanf("%d",&n)!=EOF)
	{
		num4=num1=0;
		for(i=1;i<=n;i++)
	    {
		    scanf("%d",&x);
	   	    if(x%4==0)
			num4++;
		    else if(x%2)
		    num1++;
     	}
     	//cout<<num4<<' '<<num1<<endl;
     	if(n-num1>=num1)
     	{
     		if(num4<num1)
     		printf("No\n");
     		else
     		printf("Yes\n");
		}
		else
		{
			if(num4==num1-1)
			printf("Yes\n");
			else
			printf("No\n");
		}
	}
    return 0;
}

Measured memory_bytes: 256
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

n, m, x = map(int, input().split())
ans = [0 for _ in range(m)]
a = []
minv = 1
for i in range(n):
    a.append(list(map(int, input().split())))
    minv += a[i][0]
maxv = minv
for i in range(2**n):
    ans = [0 for _ in range(m)]
    cnt = 0
    for j in range(n):
        if ((i>>j)&1):
            for k in range(m):
                ans[k] += a[j][k+1]
            cnt += a[j][0]
    ok = True
    for j in range(m):
        if ans[j] < x:
            ok = False
    if ok and cnt < minv: minv = cnt

print(minv) if minv != maxv else print(-1)

Measured memory_bytes: 10336
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    ll N;
    cin >> N;
    vector<ll> v(N-1);
    vector<ll> ans(N);
    map<ll, ll> mp;
    rep(i, N - 1) cin >> v[i];

    for (ll i = 0; i < N-1; i++){
        ll x = v[i]-1;
        if(mp.count(x)) {
            mp[x]++;
        } else {
            mp[x] = 1;
        }
    }

    for (ll i = 0; i < N; i++){
        ans[i] = mp[i];
        cout << ans[i] << endl;
    }
}


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

bool is_square(int n)
{
    for (int i = 0; i <= n; i++)
    {
        if (i * i == n)
        {
            return true;
        }
    }
    return false;
}
double distance(double x1, double y1, double x2, double y2)
{
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

int main()
{
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    int b = a[2] * 2 - a[1] - a[0];
    if (b % 2 == 0)
    {
        cout << b / 2 << endl;
    }
    else
    {
        cout << b / 2 + 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
const int MOD=1e9+7;
int n, m;
char ns[1000+3][1000+3];
int dp[1000+3][1000+3];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++){
        scanf("%s", ns[i]);
    }


    dp[0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(!i&&!j) continue;
            if(ns[i][j]=='#') continue;
            if(i) dp[i][j] += dp[i-1][j]%MOD;
            if(j) dp[i][j] += dp[i][j-1]%MOD;
            dp[i][j]%=MOD;
        }
    }

    printf("%d\n", dp[n-1][m-1]);



    return 0;
}


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

int main() {
    int n,sp=0;
    long long ans=1000, k=0;
    cin >> n;
    vector<int> a(n),s(n+1);
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<=n; i++){
        if(i==0) s[0]=0;
        else if(i==n) s[n]=-1;
        else{
            s[i]=a[i]-a[i-1];
        }
    }
    for(int i=0; i<n; i++){
        if(sp%2==0){
            if(s[i+1]>0){
                k=ans/a[i];
                ans-=k*a[i];
                sp++;
            }
        }
        else{
            if(s[i+1]<0){
                ans+=k*a[i];
                k=0;
                sp++;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main()
{
    int n,k,x;
    scanf("%d %d", &n, &k);

    x = 0;
    if(n==0){
        x++;
    }
    while(n > 0){
        n /= k;
        x++;
    }
    printf("%d\n", x);
    return 0;
}

Measured memory_bytes: 128
n=int(input())
a=[float('Inf')]
a+=list(map(int,input().split()))
i=0
m=1000
while i<n:
    if a[i]>a[i+1]:
        s=a[i+1]
    if a[i]<a[i+1]:
        m=m//s*a[i+1]+m%s
        s=a[i+1]
    i+=1
print(m)

Measured memory_bytes: 9184
#include <iostream>
#include <cmath>
using namespace std;
int n,ans,a[10000];
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    for(int j=0;a[i]%2==0;j++){
      ans++;
      a[i]/=2;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
s = {}
for i in range(N):
    str = input()
    if str in s:
        s[str]+=1
    else:
        s[str] = 1
M = int(input())
for j in range(M):
    str = input()
    if str in s:
        s[str]-= 1
    else:
        s[str] = -1
if max(s.values()) < 0:
    print(0)
else:
    print(max(s.values()))

Measured memory_bytes: 9040
#include<iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a == b) {
        cout << "Draw" << endl;
    }
    else if (a == 1) {
        cout << "Alice" << endl;
    }
    else if (b == 1) {
        cout << "Bob" << endl;
    }
    else if (a > b) {
        cout << "Alice" << endl;
    }
    else if (b > a) {
        cout << "Bob" << endl;
    }
    return 0;
}

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

int main() {
  int N, X, T;
  cin >> N >> X >> T;

  if(N % X == 0){
    cout << N / X * T <<endl;
  }
  else{
    cout << (N / X + 1) * T <<endl;
  }
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <algorithm>

using namespace std;

struct Info{
	Info(){m_node = m_distance = 0;}
	Info(int node,int distance){
		m_node = node;
		m_distance = distance;
	}
	int m_node,m_distance;
};

class InfoQueue{
public:
	InfoQueue(){
		info = new Info[10000];
		num_of_data = head = tail = 0;
	}
	bool isEmpty(){
		return num_of_data == 0;
	}
	void enqueue(Info data){
		info[tail] = data;
		tail = (tail+1)%10000;
		num_of_data++;
	}
	Info dequeue(){
		Info ret = info[head];
		head = (head+1)%10000;
		num_of_data--;
		return ret;
	}
private:
	Info* info;
	int head,tail,num_of_data;
};


int main(){

	int n,row,col,num;
	scanf("%d",&n);

	int table[n+1][n+1];
	int check_table[n+1];

	for(int i=1;i<=n;i++){
		check_table[i] = -1;
		for(int k=1;k<=n;k++)table[i][k] = 0;
	}

	for(int i=1;i<=n;i++){
		scanf("%d %d",&row,&num);
		for(int k=1;k<=num;k++){
			scanf("%d",&col);
			table[row][col]=1;
		}
	}

	check_table[1] = 0;

	InfoQueue Q;
	Q.enqueue(Info(1,0));

	Info tmp;
	while(!Q.isEmpty()){
		tmp = Q.dequeue();
		for(int i=1;i<=n;i++){
			if(table[tmp.m_node][i]==1 && check_table[i] == -1){
				check_table[i] = tmp.m_distance+1;
				Q.enqueue(Info(i,tmp.m_distance+1));
			}
		}
	}

	for(int i=1;i<=n;i++){
		printf("%d %d\n",i,check_table[i]);
	}

    return 0;
}



Measured memory_bytes: 2876
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_bit(n) for (int bit = 0; bit < (1<<n); ++bit)
#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define SP <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
using namespace std;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vi> Graph;

//条件式 ? 真の場合の文 : 偽の場合の文
//abs(x) = (x の絶対値)
//string S  S,at(i),S += T,S += c,S.size(),S.substr(l)l文字目から最後まで,
///S.substr(l, r)l文字目からl+r-1文字目 n文字目から0個で空列を返せる
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//swap(a, b)
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool,b.size() 要素が小さい順
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1; 変数[key] = value; 変数.erase(key); 変数.at(key); 変数.count(key)所属判定　変数.size()
//find(all(x), key)boolソート済みのベクトル
//*lower_bound(all(x),k)以上の最小の要素,*uppper_bound(all(x),k)より大きい最小の要素
//char('0'+cnt) 数字cntからcharへの変換
//int(char-'0') charからintへの変換
int main(){

    int n;
    ll c,k;
    cin >> n >> c >> k;
    vl t(n);
    rep(i,n) cin >> t.at(i);
    sort(all(t));
    int ans = 1;
    int now = 0;
    rep(i,n){
        if(now+c==i || t.at(now)+k < t.at(i)){
            ans++;
            now = i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int x = sc.nextInt();
      int[] a = new int[n];
      for(int i = 0;i < n;i++)a[i]=sc.nextInt();
      Arrays.sort(a);
      int cnt = 0;
      while(x>0&&cnt<=n-1){
      	x-=a[cnt];
        cnt++;
      }
      if(x>0)System.out.println(n-1);
      else if(x==0)System.out.println(cnt);
      else System.out.println(cnt-1);
    }
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> mp(h);
  for (int i = 0; i < h; i++) cin >> mp[i];
  vector<vector<int>> ans(h, vector<int>(w));
  vector<int> cur(w);

  int now = 0, min_id = w;

  for (int i = 0; i < h; i++) {
    int cnt = 0;
    int fst = now;
    for (int j = 0; j < w; j++) {
      if (mp[i][j] == '#') {
        now++;
        cnt++;
      }
    }
    if (fst == now) {
      if (i > 0) {
        ans[i] = ans[i - 1];
      }
    } else {
      min_id = min(min_id, i);
      int j = 0;
      bool ok = false;
      while (fst < now) {
        for (; j < w; j++) {
          ans[i][j] = fst + 1;
          if (mp[i][j] == '#') {
            fst++;
            if (ok) {
              ans[i][j] = fst;
            } else {
              ok = true;
            }
            j++;
            break;
          }
        }
      }
      j--;
      for (; j < w; j++) {
        ans[i][j] = fst;
      }
    }
  }
  for (int i = min_id - 1; i >= 0; i--) {
    ans[i] = ans[i + 1];
  }
  for (int i = 0; i < h; i++) {
    cout << ans[i][0];
    for (int j = 1; j < w; j++) cout << " " << ans[i][j];
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>
int main(){

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

  return 0;

}



Measured memory_bytes: 2140
import math
n,l =  input() , [ q-p for p,q in enumerate([ i for i,j in enumerate( map( int , input().split())) if i+1 == j ] ) ]

dict = {}
for i in l:
  if i in dict:
    dict[i] += 1
  else:
    dict[i] = 1


print( sum( [ math.ceil(dict[i]/2) for i in dict ] ) )

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

#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcd(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

template <class Monoid, class OperatorMonoid = Monoid> class LazySegmentTree {
  using F = std::function<Monoid(Monoid, Monoid)>;
  using G = std::function<Monoid(Monoid, OperatorMonoid, int)>;
  using H = std::function<OperatorMonoid(OperatorMonoid, OperatorMonoid)>;

  private:
    int n;
    std::vector<Monoid> seg;
    std::vector<OperatorMonoid> lazy;

    const F f;
    const G g;
    const H h;
    const Monoid M1;
    const OperatorMonoid OM1;

    void lazyUpdate(int k, int l, int r) {
      if(lazy[k] == OM1) return;

      seg[k] = g(seg[k], lazy[k], r - l);
      if(r - l > 1) {
        lazy[2 * k + 1] = h(lazy[2 * k + 1], lazy[k]);
        lazy[2 * k + 2] = h(lazy[2 * l + 2], lazy[k]);
      }
      lazy[k] = OM1;
    }

  public:
    LazySegmentTree(int sz, const F f, const G g, const H h, const Monoid &M1, const OperatorMonoid &OM1) : f(f), g(g), h(h), M1(M1), OM1(OM1) {
      n = 1;
      while(n < sz) n *= 2;
      seg.resize(2 * n - 1, M1);
      lazy.resize(2 * n - 1, OM1);
    }

    void update(int a, int b, Monoid x, int k = 0, int l = 0, int r = -1) {
      if(r < 0) r = n;

      lazyUpdate(k, l, r);

      if(b <= l || r <= a) return;

      if(a <= l && r <= b) {
        lazy[k] = h(lazy[k], x);
        lazyUpdate(k, l, r);
      }
      else {
        update(a, b, x, 2 * k + 1, l, (l + r) / 2);
        update(a, b, x, 2 * k + 2, (l + r) / 2, r);
        seg[k] = f(seg[k * 2 + 1], seg[k * 2 + 2]);
      }
    }

    Monoid query(int a, int b, int k = 0, int l = 0, int r = -1) {
      if(r < 0) r = n;

      lazyUpdate(k, l, r);

      if(b <= l || r <= a) return M1;
      if(a <= l && r <= b) return seg[k];
      Monoid vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
      Monoid vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
      return f(vl, vr);
    }
};

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

  int n, q;
  cin >> n >> q;
  LazySegmentTree<int> seg(n, [](int a, int b){ return min(a, b); },
                              [](int a, int b, int len){ return b; },
                              [](int a, int b){ return b; }, INT_MAX, INT_MAX);
  rep(i, 0, q) {
    int c;
    cin >> c;
    if(c == 0) {
      int s, t, x;
      cin >> s >> t >> x;
      seg.update(s, t + 1, x);
    }
    else {
      int x;
      cin >> x;
      cout << seg.query(x, x + 1) << endl;
    }
  }
}


Measured memory_bytes: 4972
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K, sum=0;
  cin >> K >> N;
  vector<int> A(N),diff(N);
  for(int i=0;i<N;i++) cin >> A.at(i);
  for(int i=0;i<N;i++){
    if(i == N-1) diff.at(i) = A.at(0) + K - A.at(N-1);
    else diff.at(i) = A.at(i+1) - A.at(i);
  }
  sort(diff.begin(), diff.end());
  for(int i=0;i<N;i++) sum += diff.at(i);
  sum -= diff.at(N-1);
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1792