akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();

        long answer = 1;
        for (int i = 0; i < n; i++)
        {
            answer = Lcm(answer, sc.NextLong());
        }

        Console.WriteLine(answer);
    }

    // 最大公約数（long）
    private static long Gcd(long a, long b)
    {
        if (a < b)
        {
            return Gcd(b, a);
        }
        while (b != 0)
        {
            long r = a % b;
            a = b;
            b = r;
        }
        return a;
    }

    // 最小公倍数（long）
    private static long Lcm(long a, long b)
    {
        return a / Gcd(a, b) * b;
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;
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; }

// ****************************************CODE***************************************//


ll n;
ll h[100010];
ll dp[100010];

ll rec(int i) {
    if(dp[i] != inf) return dp[i];
    if(i == 0) return 0;

    ll res = inf;
    res = min(res, rec(i-1) + abs(h[i] - h[i-1]));
    if(i > 1) res = min(res, rec(i-2) + abs(h[i] - h[i-2]));

    return dp[i] = res;
}

int main() {
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    for(int i = 0; i < 100010; i++) dp[i] = inf;

    cout << rec(n-1) << endl;
}

Measured memory_bytes: 6528
package main

import (
	"fmt"
	"strings"
)

func Reverse(s string) string {
    runes := []rune(s)
    for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
        runes[i], runes[j] = runes[j], runes[i]
    }
    return string(runes)
}

func main() {
	var s string
	words := []string{"dream", "dreamer", "erase", "eraser"}
	fmt.Scan(&s)
	s = Reverse(s)
	for i := 0; i < len(words); i++ {
		words[i] = Reverse(words[i])
	}
	ans := true
	for len(s) > 0 {
		wordsHasPrefix := false
		for i := 0; i < len(words); i++ {
			wordsHasPrefix = strings.HasPrefix(s, words[i])
			if wordsHasPrefix {
				s = strings.TrimPrefix(s, words[i])
				break
			}
		}
		if !wordsHasPrefix {
			ans = false
			break 
		}
	}
	if ans {
		fmt.Println("YES")	
	} else {
		fmt.Println("NO")	
	}
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

const LL MOD = 1000000007;

int main() {
  int N, M, A[1001] = {}, B[1001] = {};
  cin >> N >> M;
  REP(i, N) {
    cin >> A[i];
  }
  REP(i, M) {
    cin >> B[i];
  }
  sort(A, A + N, greater<int>());
  sort(B, B + M, greater<int>());
  int cA = 0, cB = 0, used = 0;
  LL ret = 1;
  for(int i = N * M; i >= 1; --i) {
    if(i == A[cA] && i == B[cB]) {
      ++cA; ++cB; 
    } else if(i == A[cA]) {
      ++cA;
      ret *= cB;
    } else if(i == B[cB]) {
      ++cB;
      ret *= cA;
    } else {
      int empty = cA * cB - used;
      if(empty <= 0) {
        cout << 0 << endl;
        return 0;
      }
      ret *= empty;
    }
    ret %= MOD;
    ++used;
  }
  cout << ret << endl;
}

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

class Dice{
  public:
    int face[6];
    int temp;

  Dice(int f[6]){
    for(int i = 0; i < 6; i++){
      face[i] = f[i];
    }
  }

  void north(){
    temp = face[0];
    face[0] = face[1];
    face[1] = face[5];
    face[5] = face[4];
    face[4] = temp;
  }

  void south(){
    temp = face[0];
    face[0] = face[4];
    face[4] = face[5];
    face[5] = face[1];
    face[1] = temp;
  }

  void west(){
    temp = face[0];
    face[0] = face[2];
    face[2] = face[5];
    face[5] = face[3];
    face[3] = temp;
  }

  void east(){
    temp = face[0];
    face[0] = face[3];
    face[3] = face[5];
    face[5] = face[2];
    face[2] = temp;
  }

  void roll(char order){
    if(order == 'N') north();
    if(order == 'S') south();
    if(order == 'W') west();
    if(order == 'E') east();
  }

  void spin(){
    temp = face[1];
    face[1] = face[2];
    face[2] = face[4];
    face[4] = face[3];
    face[3] = temp;
  }

  void findTop(int top){
    string order = "NNNWNNN";
    for(int i = 0; i < 7; i++){
      if(face[0] == top) break;
      roll(order[i]);
    }
  };

  void findFront(int front){
    for(int i = 0; i < 4; i++){
      if(face[1] == front) break;
      spin();
    }
  }

  void rightSide(int top, int front){
    findTop(top);
    findFront(front);
    cout << face[2] << endl;
  }

  bool isSame(Dice dice1){
    string order = "NNNWNNN";
    for(int i = 0; i < 7; i++){
      for(int j = 0; j < 4; j++){
        if(face[0] == dice1.face[0] && face[1] == dice1.face[1] && face[2] == dice1.face[2] && face[3] == dice1.face[3] && face[4] == dice1.face[4] && face[5] == dice1.face[5]){
          return true;
        }
        spin();
      }
      roll(order[i]);
    }

    return false;
  }
};

int main(){
  int input[6];

  for(int i = 0; i < 6; i++){
    cin >> input[i];
  }
  Dice dice1(input);
  for(int i = 0; i < 6; i++){
    cin >> input[i];
  }
  Dice dice2(input);
  string res = dice1.isSame(dice2) ? "Yes" : "No";
  cout << res << endl;
}

Measured memory_bytes: 3164
h,n=map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]

dp=[float('inf')]*(h+1)
dp[0]=0
for i in range(h):
    for j in range(n):

        next=i+ab[j][0] if i+ab[j][0]<=h else h
        dp[next]=min(dp[next],dp[i]+ab[j][1])
print(dp[-1])


Measured memory_bytes: 74580
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 12, M = 12, INF = 0x3f3f3f3f;

int cc[N], aa[N][M], ul[M];

int main() {
	int n, m, x; cin >> n >> m >> x;
	for (int i = 0; i < n; i++) {
		cin >> cc[i];
		for (int j = 0; j < m; j++)
			cin >> aa[i][j];
	}
	int ans = INF;
	for (int b = 1; b < 1 << n; b++) {
		fill(ul, ul + m, 0);
		int c = 0;
		for (int i = 0; i < n; i++)
			if (b & 1 << i) {
				c += cc[i];
				for (int j = 0; j < m; j++)
					ul[j] += aa[i][j];
			}
		bool yes = true;
		for (int j = 0; j < m; j++)
			if (ul[j] < x) {
				yes = false;
				break;
			}
		if (yes)
			ans = min(ans, c);
	}
	cout << (ans != INF ? ans : -1) << '\n';
	return 0;
}


Measured memory_bytes: 3652
//tt89 ;)
#include<bits/stdc++.h>
using namespace std;
//typedef long long ll;
#define int long long
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
void testcase(int t) { cout<<"Case #"<<t<<": "; }
void online() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif //ONLINE_JUDGE
}
const int mod= 1e9+7;

signed main() {
    fastIO;

    int n,x,t; cin>>n>>x>>t;
    int a= n/x;
    int ans= a*t;
    if(n%x) ans+=t;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std ;
int main ()
{
  int  a,b,c,m,n,x;
  cin>>a>>b>>c;
  m=a+b;
  n= a+c;
  x= b+c ;
 if (m<=n && m<=x)
  cout<<m<<endl;
 else if (n<=m && n<=x)
 cout<<n<<endl;
 else
 cout<<x<<endl;
return 0;
}

Measured memory_bytes: 3628
import sys
from collections import deque
sys.stdin.readline()
A = deque()
ans = []

def push(arg):
    A.appendleft(arg[2:]) if arg[0] == '0' else A.append(arg[2:])
def randomAccess(arg):
    ans.append(A[int(arg)])
def pop(arg):
    A.popleft() if arg[0] == '0' else A.pop()

C = {'0': push, '1': randomAccess, '2': pop}

for query in sys.stdin:
    C[query[0]](query[2:])

sys.stdout.writelines(ans)


Measured memory_bytes: 34676
n,c = (int(i) for i in input().split())
x,y = [0 for i in range(100002)],[]
for _ in range(n):
	i,j,k = (int(l) for l in input().split())
	y.append([k,i,j])
y = sorted(y)
x[y[0][1]-1]+=1
x[y[0][2]]-=1
for i in range(1,n):
	if y[i][0]==y[i-1][0] and y[i][1]==y[i-1][2]:
		x[y[i][1]]+=1
		x[y[i][2]]-=1
	else:
		x[y[i][1]-1]+=1
		x[y[i][2]]-=1
for i in range(1,len(x)): x[i]+=x[i-1]
print(max(x))

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

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    vector<ll> b(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        b[i] = a[i];
    }
    for (int i = 0; i < n - 1; i++)
    {
        if (a[i] + a[i + 1] > x)
        {
            ll r = a[i] + a[i + 1] - x;
            a[i + 1] -= (r > a[i + 1]) ? a[i + 1] : r;
        }
        if (a[i] > x)
            a[i] = x;
    }
    ll ans = 0;
    for (int i = 0; i < n; i++)
        ans += b[i] - a[i];
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
class Main{
	public static void main(String[]args){
		Scanner in=new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out, true);
		int n = in.nextInt();
		int x = in.nextInt();
		int t = in.nextInt();
		int time = 0;

		while(n!=0){
			n = Math.max(n-x, 0);
			time += t;
		}

		out.println(time);
	}
}


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

using namespace std;

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

    long long ans = 0;
    for(int i = s.length() - 1, counter = 0; i >= 0;) {
        if (s[i] == 'A') {
            ans += counter;
            i--; 
        }
        if (s[i] == 'B') {
            counter = 0;
            i--; 
        }
        if (s[i] == 'C') {
            if (i > 0 && s[i - 1] == 'B') {
                counter++;
                i -= 2;
            } else counter = 0, i--;
        }
    }
    cout << ans;
}


Measured memory_bytes: 640
import java.util.*;
    
public class Main {
    public static void main(String[] args) throws Exception {
    Scanner sc = new Scanner(System.in);
     
 	int sx = Integer.parseInt(sc.next());
    int sy = Integer.parseInt(sc.next());
    int tx = Integer.parseInt(sc.next());
    int ty = Integer.parseInt(sc.next());
	
	System.out.print("D");
	for(int i = 0; i<=tx-sx; i++){
	    System.out.print("R");
	}
	for(int i = 0; i<=ty-sy; i++){
	    System.out.print("U");
	}
	System.out.print("L");
	System.out.print("U");
	for(int i = 0; i<=tx-sx; i++){
	    System.out.print("L");
	}
	for(int i = 0; i<=ty-sy; i++){
	    System.out.print("D");
	}
	System.out.print("R");
	for(int i = 0; i<tx-sx; i++){
	    System.out.print("R");
	}
	for(int i = 0; i<ty-sy; i++){
	    System.out.print("U");
	}
	for(int i = 0; i<tx-sx; i++){
	    System.out.print("L");
	}
	for(int i = 0; i<ty-sy; i++){
	    System.out.print("D");
	}

	sc.close();
    }
}

Measured memory_bytes: 22852
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,i;
    cin>>a>>b;
   for(i=0;i<=a;i++)
   {
       c=a-i;
       d=2*i+4*c;
       if(d==b)
       {
           cout<<"Yes";
           return 0;
       }
   }
   cout<<"No";

}

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

using namespace std;

const int INF = 1e9;

int n, k, q, a[2005];

int main(){
	scanf("%d%d%d", &n, &k, &q);
	
	for(int i = 0; i < n; i++)
	scanf("%d", &a[i]);
	
	int res = INF;
	
	for(int i = 0; i < n; i++){
		//fix smallest = a[i]
		
		vector <int> tmp, best;
		
		for(int j = 0; j < n; j++){
			if(a[j] >= a[i])
			tmp.push_back(a[j]);
			else{
				if((int)tmp.size() >= k){
					sort(tmp.begin(), tmp.end());
					for(int ii = 0; ii < (int)tmp.size() - k + 1; ii++)
					best.push_back(tmp[ii]);
				}
				tmp.clear();
			}
		}
		
		if((int)tmp.size() >= k){
			sort(tmp.begin(), tmp.end());
			for(int ii = 0; ii < (int)tmp.size() - k + 1; ii++)
			best.push_back(tmp[ii]);
		}
		tmp.clear();
		
		sort(best.begin(), best.end());
		
		if((int)best.size() >= q)
		res = min(res, best[q - 1] - a[i]);
	}
	
	printf("%d\n", res);
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

from collections import Counter


def answer():
    n_2 = int(input())
    assert n_2 % 2 == 0
    n = n_2 // 2
    tmp = input()
    values = [int(w) for w in tmp.split()]

    GATE_KEEPER = -1

    values_odd = values[::2]
    values_even = values[1::2]

    counts = [Counter(values_partial).most_common(2) for values_partial in [values_odd, values_even]]
    if counts[0][0][0] != counts[1][0][0]:
        # just go
        ans = sum([n - count[0][1] for count in counts])
    else:
        # replace
        # set gatekeeper
        for i in range(2):
            counts[i].append((GATE_KEEPER, 0))
        ans = min([(n - counts[0][0][1]) + (n - counts[1][1][1]),
                   (n - counts[0][1][1]) + (n - counts[1][0][1])])
    print(ans)


if __name__ == '__main__':
    answer()


Measured memory_bytes: 16548
#include <cstdio>

int main()
{
    int x; scanf("%d", &x);
    int lo = 0, hi = 45000, mid;
    while (lo < hi - 1) {
        mid = (lo + hi) >> 1;
        if (mid * (mid + 1) / 2 >= x) hi = mid; else lo = mid;
    }
    printf("%d\n", hi);
    return 0;
}


Measured memory_bytes: 128
using System;
public class Hello{
    public static void Main(){
    string input=Console.ReadLine();
    int N=int.Parse(input.Substring(input.Length-1,1));
    
    if(N==2||N==4||N==5||N==7||N==9) {
        Console.WriteLine("hon");
    } else if(N==0||N==1||N==6||N==8) {
        Console.WriteLine("pon");
    } else if(N==3) {
        Console.WriteLine("bon");
    }

    }
}


Measured memory_bytes: 17636
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
bool visited[100001];
vector < vector <lli> > g(100001);
bool dfs(int i ){
    if(visited[i])return false;

    visited[i]= true;
    for(int x =0;x<g[i].size();x++){
        dfs(g[i][x]);
    }
    return true;
}
int main(){
    
    lli ans = 0;
    lli n,k;
    cin >> n>>k;
    for(int i =1;i<=k;i++){
        lli x,y,z;
        cin >> x >> y >> z;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int i =1;i<=n;i++){
        if(dfs(i))ans++;
    }
    cout << ans << endl;
}

/*

*/


Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define int long long int
#define pb push_back

#define mod 1000000007
#define sp fixed<<setprecision(12)
using namespace std;
/*
const int MAX=10000005;
vector<int> primes;
bitset<MAX> is_prime;
void sieve(){
    is_prime.set();
    is_prime[0]=is_prime[1]=0;
    for(int i=4;i<MAX;i+=2){
        is_prime[i]=0;
    }
    for(int i=3;i*i<MAX;i+=2){
        if(is_prime[i]){
            primes.pb(i);
            for(int j=i*i;j<MAX;j+=i){
                is_prime[j]=0;
            }
        }
    }
}
*/
/*
void lcs(char s1[],char s2[]){
    int n=strlen(s1);
    int m=strlen(s2);
    vector<vector<int>> dp(n+1,vector<int>(m+1,0));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            int sum=0;
            if(s1[i-1]==s2[j-1]){
                sum=1+dp[i-1][j-1];
            }
            else{
                sum=max(dp[i-1][j],dp[i][j-1]);
            }
            dp[i][j]=sum;
        }
    }
    
    int index=dp[n][m];
    //cout<<index<<endl;
    char ans[index+1];
    ans[index]='\0';
    index--;
    int x=n;
    int y=m;
    while(x>0 and y>0){
        if(dp[x-1][y]==dp[x][y-1] and dp[x-1][y]!=dp[x][y]){
            ans[index]=s1[x-1];
            index--;
            x--;
            y--;
        }else if(dp[x-1][y]>dp[x][y-1]){
            x--;
        }else{
            y--;
        }

    }
    //reverse(ans.begin(),ans.end());

    cout<<ans;
    return;
}
*/



int32_t main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    //double    pi=3.14159265358979323846;
    //sieve();
    int t=1;
    
    //cin>>t;
    
    for(int tc=1;tc<=t;tc++){
        int n,d;
        cin>>n>>d;
        int ans=0;
        while(n--){
            int x,y;
            cin>>x>>y;
            double dis=sqrt((x*x)+(y*y));
            if(dis<=d){
                ans++;
            }
        }
        cout<<ans<<'\n';
    }
    
    return 0;
    
}

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

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//Declare -> ordered_set NAMA;
//Nth smallest integer -> find_by_order(N-1)
//Number of elements less than N -> order_of_key(N)
//Delete N from the set -> erase(N)

#define endl '\n'
#define MOD 1000000007
#define PI 3.141592653
#define fi first
#define sc second
#define pb push_back
#define pbb pop_back

//#pragma GCC optimize("Ofast")
//#pragma GCC target ("string"...)
//#pragma GCC push_options
//#pragma GCC pop_options
//#pragma GCC reset_options
//#pragma GCC optimize ("O3")

typedef long long ll;
typedef long double ld;
typedef pair<int , int> pii;
typedef pair<long long , long long> pll;

void BOOST(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
}
void fcin(int &x){
	bool neg = false;
	register int c;
	x = 0;
	c = getchar();
	if(c=='-'){
		neg = true;
		c = getchar();
	}
	for(;(c>47 && c<58);c=getchar())x = (x<<1)+(x<<3)+c-48;
	if(neg)x*=-1;
}
ll pmod(ll a , ll b){
	if(b==0)return 1;
	ll temp = pmod(a , b/2);
	if(b%2==0)return(temp*temp)%MOD;
	return (((temp*temp)%MOD)*a)%MOD;
}
int main(){
//	BOOST();
	int a , b ,c , d , e;
	cin>>a>>b>>c>>d>>e;
	if(a==0)cout<<1<<endl;
	else if(b==0)cout<<2<<endl;
	else if(c==0)cout<<3<<endl;
	else if(d==0)cout<<4<<endl;
	else cout<<5<<endl;
}







Measured memory_bytes: 3640
count_map = {}
while True:
    try:
        i = int(input())
        if i in count_map:
            count_map[i] += 1
        else:
            count_map[i] = 1
    except EOFError:
        break
max_count = max(count_map.values())
mode_values = []
for item in count_map.items():
    if item[1] == max_count:
        mode_values.append(item[0])
for mode in sorted(mode_values):
    print(mode)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
	string S;
	cin >> S;
	vector<int> A(3);
	for (size_t i = 0; i < S.size(); i++)
	{
		if (S.at(i) == 'a')A.at(0)++;
		else if (S.at(i) == 'b')A.at(1)++;
		else A.at(2)++;
	}
	sort(A.begin(), A.end());
	//cout << A.at(0) << A.at(1) << A.at(2);
	if (A.at(2) - A.at(0) > 1)cout << "NO";
	else cout << "YES";
}

Measured memory_bytes: 512
code = """
# distutils: language=c++
# distutils: include_dirs=[/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl]
# cython: boundscheck=False
# cython: wraparound=False
from libcpp.vector cimport vector
cdef extern from "/opt/atcoder-stl/atcoder/fenwicktree.hpp" namespace "atcoder":
    cdef cppclass fenwick_tree[T]:
        fenwick_tree(int n)
        void add(int p, T x)
        T sum(int l, int r)

cdef class FenwickTree:
    cdef fenwick_tree[long long] *_thisptr
    def __cinit__(self, int n):
        self._thisptr = new fenwick_tree[long long](n)
    cpdef void add(self, int p, long long x):
        self._thisptr.add(p, x)
    cpdef long long sum(self, int l, int r):
        return self._thisptr.sum(l, r)
"""
import os,sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    open('atcoder.pyx','w').write(code)
    os.system('cythonize -i -3 -b atcoder.pyx')
  
import sys
from atcoder import FenwickTree

N,Q = list(map(int,input().split()))
A = list(map(int,input().split()))
fw = FenwickTree(N)
for i, a in enumerate(A):
    fw.add(i,a)

for i in range(Q):
    a,b,c = list(map(int,input().split()))
    if a==0:
        fw.add(b,c)
    else:
        print(fw.sum(b,c))

Measured memory_bytes: 66200
h,w=[int(i) for i in input().split()]

e=[]
for i in range(h):
    a=list(input())
    e.append(a)

def check(i,j,e):
    global h
    global w
    top=[i-1,j]
    bottom=[i+1,j]
    right=[i,j+1]
    left=[i,j-1]
    checkpoints=[top,bottom,left,right]
    if i==0:
        checkpoints.remove(top)
    if i==h-1:
        checkpoints.remove(bottom)
    if j==0:
        checkpoints.remove(left)
    if j==w-1:
        checkpoints.remove(right)
        
    if e[i][j]==".":
        return True
    else:
        kouho=[]
        for checkpoint in checkpoints:
            kouho.append(e[checkpoint[0]][checkpoint[1]])
        if "#" in kouho:
            return True
        else:
            return False
ans=0        
for i in range(h):
    for j in range(w):
        if not check(i,j,e):
            ans+=1
        
if ans==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
/*#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;
# define ll long long
# define int long long  //comment it out when MLE
//# define endl "\n"
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//# define m 163577857
//# define MOD 163577857
# define pi acos(-1)
# define fi first
# define se second
#define REP(i,n) for (int i = 1; i <= n; i++)

const ll mod = 1000000007;
const int K = 2;
//typedef vector<vector<int> > matrix;
int add(int a, int b,int mod) {
    a%=mod;
    b%=mod;
	a += b;
	if (a >= mod) a -= mod;
	if(a<0)
    {
        a += mod;
        a %= mod;
    }
	return a;
}

int mul(ll a, int b,int mod) {
    a%=mod;
    b%=mod;
	a *= b;
	return a % mod;
}
int po(int a,int b,int mod)
{
    if(b==0)
        return 1;
    if(b%2==0)
        return po(mul(a,a,mod),b/2,mod);
    return mul(a,po(mul(a,a,mod),(b-1)/2,mod),mod);
}


ll fact[1000003];
ll inv[1000003];

void fact0()
{
	int i,j;
	fact[0]=1;
	for(i=1;i<=200000;i++)
	{
		fact[i]=i*fact[i-1]%mod;
	}
	inv[0]=1;
	inv[1]=1;
	ll p=mod;
	for (i=2; i<=200000; i++)
		inv[i] = (p - (p/i) * inv[p%i] % p) % p;

	for(i=2;i<=200000;i++)
	{
		inv[i]*=inv[i-1];
		inv[i]%=mod;
	}
}

signed main()
{
    gok
   //fact0();
   int n,k;
   cin>>n>>k;
   map<int,int> mp;
   while(k--)
   {
       int d;
       cin>>d;
       while(d--){
        int x;
       cin>>x;
       mp[x]=1;
       }
   }
int c=0;
  for(int i=1;i<=n;i++)
  {
      if(mp[i]==0)
        c++;
  }

cout<<c;













    return 0;
    }


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

int main()
{
  int a, b;
  cin >> a >> b;
  int i;
  int ans = 0;
  for(i = a; i <= b; i++)
  {
    if(i/10000 == i%10 && (i/1000)%10 == (i/10)%10)
    {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from sys import stdin
from itertools import repeat
def main():
    n = int(stdin.readline())
    a = map(int, stdin.read().split(), repeat(10, n))
    p = [0] * n
    for i, x in enumerate(a):
        p[x-1] = i
    x = ans = 1
    for i in xrange(1, n):
        if p[i] > p[i-1]:
            x += 1
        else:
            x = 1
        if ans < x:
            ans = x
    print n - ans
main()


Measured memory_bytes: 19976
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#define ll long long
using namespace std;
constexpr auto mod=998244353;
ll dp[200000*2+5];
vector<pair<ll,ll>> v;
int main(){
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=k;i++){
        int a,b;
        cin>>a>>b;
        v.emplace_back(make_pair(a,b));
    }
    dp[1]=1;
    dp[2]=-1;
    for(int i=1;i<=n;i++){
        dp[i]=((dp[i]+dp[i-1])%mod+mod)%mod;
        for(int j=0;j<k;j++){
            dp[i+v[j].first]=dp[i+v[j].first]+dp[i];
            dp[i+v[j].second+1]=dp[i+v[j].second+1]-dp[i];
        }
    }
    cout<<dp[n]<<endl;
    //getchar();
    //getchar();
    return 0;
}

Measured memory_bytes: 6604
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int grid[101][101];
int main(){
  int a,b;cin>>a>>b;
  rep(i,100){
    rep(j,100){
      if(i>50){
        grid[i][j]=-1;
      }else{
        grid[i][j]=1;
      }
    }
  }
  cout<<100<<" "<<100<<endl;

  int ansa=0,ansb=0;
  rep(i,49){
    if(ansa==a-1){
        break;
    }
    rep(j,100){
        if(i%2==0&&j%2==0){
            grid[i][j]=-1;
            ansa++;
        }
        if(ansa==a-1){
            break;
        }
    }
  }

  FOR(i,51,100){
    if(ansb==b-1){
        break;
    }
    rep(j,100){
        if(i%2==0&&j%2==0){
            grid[i][j]=1;
            ansb++;
        }
        if(ansb==b-1){
            break;
        }
    }
  }

  rep(i,100){
    rep(j,100){
      if(grid[i][j]==1){
        cout<<"#";
      }else{
        cout<<".";
      }
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound

using namespace std;

int main() {
  int N;
  cin >> N;
  int ans = 1;
  vector<string> vec(N);
for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
}
  sort(vec.begin(), vec.end());
  for (int j = 0; j < N - 1; j++){
    if(vec.at(j) != vec.at(j + 1))
{
        ans += 1;
      }
    
  }
  cout << ans << endl;
  
        

 

}

Measured memory_bytes: 7640
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val MOD = 1e9.toInt + 7
  val n, a, b = in.next().toInt

  // (x ^ n) % mod
  def repeatSquares(x: Long, n: Int): Long = {
    if(n == 0)
      1
    else if(n % 2 == 0)
      repeatSquares(x*x % MOD, n/2)
    else
      (x * repeatSquares(x*x % MOD, n/2)) % MOD
  }

  //
  def fact(n: Long, a: Long): Long = {
    def func(x: Long, res: Long): Long = {
      if (x == n - a)
        res
      else
        func(x-1, (x * res) % MOD)
    }

    func(n, 1)
  }

  val hoge1 = repeatSquares(2, n)
  val hoge = (hoge1 + MOD - 1) % MOD

  val mc = new ModComb(b, MOD)
  var ans = hoge
  ans = (ans + MOD) - ((fact(n, a) * mc.factInv(a)) % MOD)
  ans %= MOD
  ans = (ans + MOD) - ((fact(n, b) * mc.factInv(b)) % MOD)
  ans %= MOD


  println(ans)
}

class ModComb(maxNum: Int, mod: Long) {

  private def repeatSquares(x: Long, n: Long): Long = {
    if(n == 0)
      1
    else if(n % 2 == 0)
      repeatSquares(x*x % mod, n/2)
    else
      (x * repeatSquares(x*x % mod, n/2)) % mod
  }

  private val fact = new Array[Long](maxNum + 1)

  fact(0) = 1
  for (i <- 1 to maxNum)
    fact(i) = (i * fact(i-1)) % mod

  val factInv = new Array[Long](maxNum + 1)

  factInv(maxNum) = repeatSquares(fact(maxNum), mod-2)
  for (i <- (1 to maxNum).reverse)
    factInv(i-1) = (i * factInv(i)) % mod


  // nCk
  def comb(n: Int, k: Int): Long = {
    val numer = fact(n)
    val denom = (factInv(n-k) * factInv(k)) % mod

    (numer * denom) % mod
  }

}


object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 29516
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;

#define INF 1000000000



int main(){
  int card[50];
  int tmp[50];

  while(true){
    int n,r;
    cin >> n >> r;
    if(n==0 && r==0)break;

    rep(i,n) card[i]=n-i;

    rep(i,r){
      int p,c;
      scanf("%d %d", &p, &c);
      p--;

      rep(j,c){
	tmp[j]=card[p+j];
      }
      rep(j,p){
	card[c+p-j-1] = card[p-j-1];
      }
      rep(j,c){
	card[j]=tmp[j];
      }
    }

    cout << card[0] << endl;

  }

}

Measured memory_bytes: 1244
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define INF 1e9

static const int seed=6;
static const int D=365;
static const int ntype=26;
static const double swap_rate=0.7;
static const double change_rate=1.0-swap_rate;
static int ans[D+1];
static int max_score=0;
static const int t=1100000;
static const int last_swap=100000;

class Contest{
public:
    Contest(){
        last=0;
    }
    int s[D+1];
    int c;
    int last;
};

static Contest contest[ntype+1];

void Input(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int d;
    cin>>d;
    for(int i=1;i<=ntype;++i){
        int t;
        cin>>t;
        contest[i].c=t;
    }
    for(int day=1;day<=D;++day){
        for(int type=1;type<=ntype;++type){
            int t;
            cin>>t;
            contest[type].s[day]=t;
        }
    }
}

int Score(int type){
    int sum=0;
    contest[type].last=0;
    for(int day=1;day<=D;++day){
        if(ans[day]==type){
            sum+=contest[type].s[day];
            int n=day-contest[type].last;
            sum-=contest[type].c*(n*(n-1)/2);
            contest[type].last=day;
        }
    }
    if(ans[D]!=type){
        int n=D-contest[type].last;
        sum-=contest[type].c*(n*(n+1)/2);
    }
    return sum;   
}

void Output(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    for(int d=1;d<=D;++d) cout<<ans[d]<<'\n';
}

void Init(){
    for(int d=1;d<=D;++d) ans[d]=rand()%ntype+1;
}

void Greedy(){
    vector<int> l(ntype+1,0);
    int score=0;
    for(int d=1;d<=D;++d){
        for(int i=1;i<=ntype;++i) score-=contest[i].c*(d-l[i]);
        int temp=score;
        int t=-1;
        for(int i=1;i<=ntype;++i){
            int k=contest[i].s[d]+contest[i].c*(d-l[i])+score;
            if(k>temp){
                temp=k;
                t=i;
            }
        }
        ans[d]=t;
        l[t]=d;
    }
}

void change(){
    int p=rand()%D+1;
    int before=ans[p];
    int after=rand()%ntype+1;
    int before_score=Score(before)+Score(after);
    ans[p]=after;
    int delta=Score(before)+Score(after)-before_score;
    if(delta>0){ 
        max_score+=delta;
    }
    else ans[p]=before;
}

void swap(){
    int p1=rand()%D+1;
    int p2=rand()%D+1;
    while(p1==p2) p2=rand()%D+1;
    int temp_score=Score(ans[p1])+Score(ans[p2]);
    int temp=ans[p1];
    ans[p1]=ans[p2];
    ans[p2]=temp;
    int delta=Score(ans[p2])+Score(ans[p1])-temp_score;
    if(delta>0){
        max_score+=delta;
    }
    else{
        ans[p2]=ans[p1];
        ans[p1]=temp;
    }
}

void Solve(int times){
    Greedy();
    for(int i=1;i<=ntype;++i) max_score+=Score(i);
    for(int i=0;i<times;++i){
        double p=(double)rand()/RAND_MAX;
        if(p<swap_rate) swap();
        else change();
    }
    for(int i=0;i<last_swap;++i) swap();
}

int main(){
    srand(seed);
    Input();
    Solve(t);
    Output();
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;
 
int main() {
    int n, x;
    cin >> n >> x;

    if(x == 1 || x == 2*n-1) {
        cout << "No" << "\n";
        return 0;
    }

    cout << "Yes" << "\n";

    if(n == 2) {
        for(int i = 1; i <= 3; i++) {
            cout << i << "\n";
        }
        return 0;
    }

    vector<int> v(2*n-1);
    set<int> st;

    for(int i = 1; i <= 2*n-1; i++) {
        st.insert(i);
    }

    v[n-2] = x-1;  v[n-1] = x;  v[n] = x+1;
    st.erase(x-1);  st.erase(x);  st.erase(x+1);

    if(1 <= x-2) {
        v[n+1] = x-2;
        st.erase(x-2);
    } 
    else {
        v[n-3] = x+2;
        st.erase(x+2);
    }

    rep(i, 2*n-1) {
        if(!v[i]) {
            v[i] = *st.begin();
            st.erase(st.begin());
        }
        cout << v[i] << "\n";
    }

    return 0;
}

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



void solve(long long N, std::vector<long long> A){
    sort(A.begin(),A.end());
    ll maxA = ll(1e6)+5;
    bool ok[maxA];
    for(int i=0;i<maxA;i++){
        ok[i] = true;
    }
    ll ans =0;
    for(int i=0;i<N;i++){
        
        if(ok[A[i]]){
            ans++;
            ll t = 1;
            while(t*A[i]<maxA){
                // cerr <<"t=" <<t << endl;
                ok[t*A[i]] = false;
                t++;
            }
            if(i<N-1&&A[i] == A[i+1]){
                ans--;
            }

        }
       
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 5892
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {

    int h, w, a, b;
    cin >> h >> w >> a >> b;

    vector<vector<int>> grid(h, vector<int>(w, 0));
    rep(y, h) rep(x, w) {
            if ((y < b && x < a) || (b <= y && a <= x)) {
                grid[y][x] = 1;
            }
        }

    rep(y, h) {
        rep(x, w) {
            cout << grid[y][x];
        }
        cout << endl;
    }
}


Measured memory_bytes: 7476
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,cur)               lower_bound(all(v),cur)-v.begin()
#define ub(v,cur)               upper_bound(all(v),cur)-v.begin()
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
ll pows(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD){if(m == 1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}
int main()
{
fastIO
ll n,m,i,j,k,x,y,z,e,f,p,q,g,l,r,w,h,count1=0,prod=1,a,b,c,d,index,x1,x2,diff,ans=0,sum=0,sum1=0,sum2=0,flag=0,flag1=0,flag2=0;
string s,s1,s2;
cin>>a>>b;
if(a<=9&&a>0&&b<=9&&b>0)
{
  cout<<a*b;
}
else
{
  cout<<"-1";
}
}


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

using namespace std;

int N, K;
vector<int> h;
vector<int> dp_table;

void dp() {
	dp_table[0] = 0;
	dp_table[1] = abs(h[1] - h[0]);
	for (int i = 2; i < N; i++) {
		vector<int> cost(K+1, 9999999*100);
		for (int step = 1; (step <= K && i-step >= 0); step++) {
			cost[step] = dp_table[i - step] + abs(h[i-step] - h[i]);
		}
		dp_table[i] = *min_element(cost.begin(), cost.end());
	}
}

int main() {
	cin >> N >> K;

	for (int i = 0; i < N; i++) {
		int _;
		cin >> _;
		h.push_back(_);
		dp_table.push_back(-1);
	}

	dp();

	std::cout << dp_table[N-1] << endl;
}


Measured memory_bytes: 1276
def calc(ds):
    sum = 0
    cnt = 0
    if len(ds) == 0:
        return (0, 1)
    x = 0
    for i in range(len(ds)):
        x = 10*x + ds[i]
        (s, c) = calc(ds[i+1:])
        sum += s + c * x
        cnt += c
    return (sum, cnt)

def main():
    S = input().strip()
    ds = [int(c) for c in S]
    (answer, _) = calc(ds)
    print(answer)
    
main()


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main() {
	int a,b;
	cin >> a >> b;

	if (a != 1 && b != 1) {
		cout << 1 << endl;
	}
	if (a != 2 && b != 2) {
		cout << 2 << endl;
	}
	if (a != 3 && b != 3) {
		cout << 3 << endl;
	}

	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
#define sz(x) static_cast<int>(x.size())
using ll = long long;
using namespace std;

int main() {
  int h, w; cin >> h >> w;
  vector<vector<char>> grid(h, vector<char>(w));
  REP(y, h)REP(x, w) cin >> grid[y][x];

  map<int, bool> mx, my;

  REP(y, h){
    bool f = false;
    REP(x, w){
      f |= grid[y][x] == '#';
    }
    if(!f) my[y] = true;
  }

  REP(x, w){
    bool f = false;
    REP(y, h){
      f |= grid[y][x] == '#';
    }
    if(!f) mx[x] = true;
  }

  REP(y, h){
    REP(x, w){
      if(my[y] || mx[x]) continue;
      cout << grid[y][x];
    }
    if(!my[y]) cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
class Dice
{
private:
  vector<int> dice;
public:
  Dice(vector<int> num) {
    for (int i = 0; i < (int)num.size(); ++i) {
      dice.push_back(num.at(i));
    }
  }

  Dice roll(char c) {
    int tmp;
    if(c == 'S'){
      tmp = dice.at(0);
      dice.at(0) = dice.at(4);
      dice.at(4) = dice.at(5);
      dice.at(5) = dice.at(1);
      dice.at(1) = tmp;
    } else if (c == 'E') {
      tmp = dice.at(0);
      dice.at(0) = dice.at(3);
      dice.at(3) = dice.at(5);
      dice.at(5) = dice.at(2);
      dice.at(2) = tmp;
    } else if (c == 'N') {
      tmp = dice.at(0);
      dice.at(0) = dice.at(1);
      dice.at(1) = dice.at(5);
      dice.at(5) = dice.at(4);
      dice.at(4) = tmp;
    } else {
      tmp = dice.at(0);
      dice.at(0) = dice.at(2);
      dice.at(2) = dice.at(5);
      dice.at(5) = dice.at(3);
      dice.at(3) = tmp;
    }
    return dice;
  }
  int getDiceTopNum() { return dice.at(0); }
};


int main(int argc, char *argv[])
{
  vector<int> num(6);
  string s;
  for (int i = 0; i < 6; ++i) {
    cin >> num.at(i);
  }
  Dice dice(num);
  cin >> s;

  for (int j = 0; j < (int)s.length(); ++j) {
    dice = dice.roll(s[j]);
  }
  cout << dice.getDiceTopNum() << endl;

  return 0;
}



Measured memory_bytes: 3208
#include <cstdio>
#include <cmath>
#include <climits>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cassert>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <fstream>
#include <functional>
#include <utility>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <iomanip>
#define memtst(x) (sizeof(x) / 1024. / 1024.)
#define mem0(x) memset((x), 0, (sizeof x))
#define meminf(x) memset((x), INF, (sizeof x))
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define pq std::priority_queue
#define iter iterator
#define mp(x, y) std::make_pair((x), (y))
#define fst first
#define sec second
#define lc(x) ((x) * 2)
#define rc(x) ((x) * 2 + 1) 
#define md(x, y) (((x) + (y)) / 2)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair <int, int> pii;
const double PI = acos(-1);
const double EPS = 1e-6;
const ll MOD = 998244353;
const ll INF = 0x3F3F3F3F;
template <typename T>
inline T Abs(T x)
{
    return x < 0 ? x * -1 : x;
}
template <typename T>
inline T Max(T x, T y, T z)
{
    return std::max(std::max(x, y), z);
}
template <typename T>
inline T Min(T x, T y, T z)
{
    return std::min(std::min(x, y), z);
}
template <typename T>
inline T Ckmax(T &x, T y)
{
    return x = std::max(x, y);
}
template <typename T>
inline T Ckmin(T &x, T y)
{
    return x = std::min(x, y);
}
template <typename T>
inline T Sqr(T x)
{
    return x * x;
}
template <typename T>
inline T Pow(T x, T y)
{
    T r = 1;
    while (y > 0)
    {
        if (y % 2 > 0)
            (r *= x) %= MOD;
        (x *= x) %= MOD;
        y /= 2;
    }
    return r % MOD;
}
template <typename T>
T Pow(T x, T y, T z)
{
    T r = 1;
    while (y > 0)
    {
        if (y % 2 > 0)
            (r *= x) %= z;
        (x *= x) %= z;
        y /= 2;
    }
    return r % z;
}
template <typename T>
inline T gcd(T x, T y)
{
    return y > 0 ? gcd(y, x % y) : x;
}
template <typename T>
inline T lcm(T x, T y)
{
    return x / gcd(x, y) * y;
}
inline void cinspu(void)
{
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
}
inline ll read(void)
{
    char x;
    while (x = getchar(), x != '-' && !isdigit(x))
        ;
    char flg = x == '-';
    ll num = (flg ? getchar() : x) - '0';
    while (isdigit(x = getchar()))
        (num *= 10) += x - '0';
    return flg ? -num : num;
}
const int N = 100000 + 10;
int a[N];
int main()
{
	cinspu();
	int n, m;
	std::cin >> n >> m;
	for (int i = 1; i <= n; ++i)
		std::cin >> a[i];
	std::sort(a + 1, a + n + 1);
	int ans = INT_MAX;
	for (int i = 1, j = m; j <= n; ++i, ++j)
		Ckmin(ans, a[j] - a[i]);
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 640
N = int(input())
lis_A = list(map(int, input().split()))
lis_ev = [i for i in lis_A if i%2==0]
lis_3or5 = [j for j in lis_ev if (j%3==0)|(j%5==0)]
if lis_ev == lis_3or5:
    ans = 'APPROVED'
else :
    ans = 'DENIED'
print(ans)

Measured memory_bytes: 3060