akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

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

	string K;
	int d;
	cin >> K >> d;

	int n = K.size();
	int dp[n][d][10];
	int sum[n][d];
	int mod = 1e9 + 7;

	for(int j = 0; j < d; j++)
	{
		sum[0][j] = 0;

		for(int k = 0; k < 10; k++)
		{
			dp[0][j][k] = (j == k % d);
			sum[0][j] += dp[0][j][k];
		}
	}

	for(int i = 1; i < n; i++)
	{
		for(int j = 0; j < d; j++)
		{
			sum[i][j] = 0;
			for(int k = 0; k < 10; k++)
			{
				int prev_rest = (j - k + d * 10) % d;
				dp[i][j][k] = sum[i - 1][prev_rest];      

				sum[i][j] += dp[i][j][k];
				if(sum[i][j] > mod) sum[i][j] -= mod;
			}
		}
	}

	int ans = 0;
	int rest = 0;
	for(int i = n - 1; i >= 0; i--)
	{
		int curr = K[n - 1 - i] - '0';
		if(i == 0) curr++;

		for(int k = 0; k < curr; k++)
		{
			ans += dp[i][rest][k];
			if(ans > mod) ans -= mod;
		}

		rest = (rest - curr + d) % d;
	}

	// 0 jest wliczone do wyniku
	cout << ans - 1 << "\n";
}


Measured memory_bytes: 43264
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using P = pair<ll,ll>;
using vi = vector<int>;
int INF = 1e9+7;

int main() {
    int a,b;
    cin >> a >> b;
    if (a%2==0 | b%2==0) cout << "Even" << endl;
    else cout << "Odd" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    out((n - 1 + k - 2) / (k - 1));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define loopj(n) for(int j=0;j<n;j++)
#define loopi(a,b,k) for(int i=a;i<b;i=i+k)
#define  deb(x) cout<<#x<<"  "<<x<<endl
#define sync std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll mx=max(a*c,a*d);
	ll mx2=max(b*c,b*d);
	cout<<max(mx,mx2);
}

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

int main()
{
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  rep(i, 1000)
  {
    string t = "000";
    int a = i;
    rep(j, 3)
    {
      if (a == 0)
        break;
      t[2 - j] = a % 10 + '0';
      a /= 10;
    }
    int cnt = 0;
    bool found = false;
    rep(j, s.size())
    {
      if (s[j] == t[cnt])
      {
        cnt++;
        if (cnt == 3)
        {
          found = true;
          break;
        }
      }
    }
    if (found)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n, i, h[110000], ans=0, cnt=0;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> h[i];
    }
    for(i=1;i<n;i++){
        if(h[i]>h[i-1]){
            if(cnt>ans) ans=cnt;
            cnt=0;
        }
        else cnt++;
    }
    if(cnt>ans) ans=cnt;
    cout << ans <<endl;
    return 0;

}

Measured memory_bytes: 1024
import java.io.*;
class Main
{
        public static void main(String args[])
        {
                int x;
                InputStreamReader isr = new InputStreamReader(System.in);
                BufferedReader br = new BufferedReader(isr);
                try{
                        String buf = br.readLine();
                        x = Integer.parseInt(buf);
                }catch(Exception e){
                        x = 0;
                }
                System.out.println(x*x*x);
        }
}


Measured memory_bytes: 24220
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
int main(){
	int n;
	string s;
	cin>>n;cin.get();
	while(n-->0){
		getline(cin,s);
		for(int i=0;i<s.size();i++){
			if(s.substr(i,7)=="Hoshino")
				s[i+6]='a';
		}
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
class dice:
	def __init__(self,data):
		self.faces = data
	
	def turn(self,direction):
		if direction == 'N':
			idx = [1,5,2,3,0,4]
			self.faces = [self.faces[i] for i in idx]
		elif direction == 'S':
			[self.turn('N') for i in range(3)]
		elif direction == 'E':
			idx = [3,1,0,5,4,2]
			self.faces = [self.faces[i] for i in idx]
		elif direction == 'W':
			[self.turn('E') for i in range(3)]
		elif direction == 'c':
			self.turn('N')
			self.turn('W')
			self.turn('S')

def issame(d1,d2):
	for o in 'cccWcccEcccNcccWcccWccc':
		if d1.faces == d2.faces:
			break
		else:
			d2.turn(o)
	if d1.faces == d2.faces:
		return True
	else:
		return False

if __name__ == '__main__':
	from itertools import combinations
	n = int(input())
	dices = []
	for i in range(n):
		dices.append(dice([int(s) for s in input().split()]))
	ans = True
	for d1,d2 in combinations(dices,2):
		if issame(d1,d2):
			ans = False
			break
	print({True:'Yes',False:'No'}[ans])
	

Measured memory_bytes: 7864
i = list(map(int, input().split()))
A = i[0]
B = i[1]

ABC1 = A * B * 1
ABC2 = A * B * 2
ABC3 = A * B * 3

def kisuu(num):
  if num % 2 == 1:
    return True
  else:
    return False

if kisuu(ABC1):
  print('Yes')
elif kisuu(ABC2):
  print('Yes')
elif kisuu(ABC2):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
a, b, c = input().split()

flag = bool

if a == '5' and b =='7' and c=='5':
    flag = True
if a =='7' and b=='5' and c == '5':
    flag = True
if a =='5' and b=='5' and c == '7':
    flag = True

if flag == True:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n,k;
  cin >> n >> k;
  string s;
  cin >> s;

  vector<ll> v;
  for(int i=0;i<n;i++){
    ll a=0;
    while(i+a<n && s[i+a]==s[i]){
      a++;
    }
    v.push_back(a);
    i=i+a-1;
  }
  
  if(2*k+1>=v.size())cout << n-1 << endl;
  else{
    ll l=0;//maxをとるスタート地点。このとき、l+1～l+kの向きをそろえることになる。
    ll m=0;//vの中の連続する2k+1個の和のmax
    ll c[v.size()-2*k]={};//vの中の、i番目から連続した2k+1個の和
    for(int i=0;i<2*k+1;i++)c[0]+=v[i];
    for(int i=1;i<v.size()-2*k;i++){
      c[i]=c[i-1]-v[i-1]+v[i+2*k];
    }
    m=c[0];
    for(int i=1;i<v.size()-2*k;i++){
      if(c[i]>m){
        l=i;
        m=c[i];
      }
    }
    m=m-v[l]-v[l+2*k];
    ll p=0;//vの0番目からl番目まで足す
    for(int i=0;i<=l;i++){
      p+=v[i];
    }
    if(s[p]=='R'){
      for(int i=0;i<m;i++){
        s[p+i]='L';
      }
    }
    else{
      for(int i=0;i<m;i++){
        s[p+i]='R';
      }
    }
    /*for(int i=0;i<n;i++){
      cout << s[i] ;
    }
    cout << endl;*/

    ll t=0;
    for(int i=0;i<n;i++){
      if(i==0){
        if(s[i]=='R'&& s[i+1]=='R')t++;
      }
      else if(i==n-1){
        if(s[i]=='L' && s[i-1]=='L')t++;
      }
      else{
        if(s[i]=='R'&& s[i+1]=='R')t++;
        if(s[i]=='L' && s[i-1]=='L')t++;
      }
    }
    cout << t << endl;

  }

}

Measured memory_bytes: 4892
import Control.Applicative
import Text.Printf

main :: IO ()
main = do
  xs <- map read . words <$> getLine
  let [s, c, h] = calc xs
  printf "%.8f\n%.8f\n%.8f\n" s c h

calc :: [Float] -> [Float]
calc [a, b, th] = [s, (a + b + c), h]
  where
    th' = th * pi / 180
    s = 0.5 * a * b * sin th'
    c = sqrt (a^2 + b^2 - 2 * a * b * cos th')
    h = b * sin th'



Measured memory_bytes: 4088
A, B, C, D, E, F = map(int, input().split())

water = []
for i in range(31):
    for j in range(31):
        tmp = 100*i*A + 100*j*B
        if tmp <= F:
            water.append(tmp)
            
water = list(set(water))
water.remove(0)

sugar = []
for i in range(101):
    for j in range(101):
        tmp = i*C + j*D
        if tmp <= F:
            sugar.append(tmp)
            
sugar = list(set(sugar))
sugar.remove(0)

ans = []
for w in water:
    for s in sugar:
        if w + s <= F and s / (w + s) <= E / (100 + E):
            ans.append([w, s, s / (w+s)])
            
if ans:
    ans.sort(key=lambda x:x[2], reverse=True)
    print(ans[0][0]+ans[0][1], ans[0][1])
else:
    print(water[0], 0)

Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back

int a[202][202];
int pre[202][202];

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

    int i,j,l=0,r=0,x=2,y=2,m,n,k,ans=0,base=0;
    cin>>n;
    cout<<360ll/__gcd(360ll,n);

}



Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int main(void){
  int n;
  cin>>n;
  ulong l[n];
  l[0]=2;
  l[1]=1;
  for(int i(2);i<=n;i++){
    l[i]=l[i-1]+l[i-2];
  }
  cout<<l[n]<<endl;
  return 0;
}

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

"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def bfs(H, W, maze, sx, sy):
    max_ans = 1
    # 上下左右に移動する場合の座標の変化量
    dx = [0, 0, -1, 1]
    dy = [-1, 1, 0, 0]

    path = [(sx, sy)]           #  切り取りに含める切手の座標 (まずは探索開始地点のみからスタート)
    Q = deque()
    Q.append((sx, sy, path))
    while Q:
        cx, cy, path = Q.popleft()        #  現在地の座標と探索状況
        for i in range(len(dx)):
            nx = cx + dx[i]
            ny = cy + dy[i]
            #  移動先まで通行可能 かつ 既に探索済でなければ、その先でも探索を続ける
            if 0 <= nx < W and 0 <= ny < H and not (nx, ny) in path and maze[ny][nx] == 1:
                t = path[:]
                t.append((nx, ny))
                ans = len(t)
                if ans > max_ans:
                    max_ans = ans
                Q.append((nx, ny, t[:]))
    return max_ans


def solve(H, W, maze):
    # 全てのマスを起点にして、条件を満たす切り取り方をチェックする
    ans = 0
    for y in range(H):
        for x in range(W):
            if maze[y][x] == 1:
                t = bfs(H, W, maze, x, y) #  座標x, yを起点にした解の一覧
                ans = max(ans, t)
    return ans


def main(args):
    while True:
        W = int(input())
        H = int(input())
        if W == 0 and H == 0:
            break
        maze = []
        for _ in range(H):
            maze.append([int(x) for x in input().split()])
        ans = solve(H, W, maze)
        print(ans)

if __name__ == '__main__':
    main(sys.argv[1:])




Measured memory_bytes: 6312
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
int main(){
  std::string str1,str2;
    std::cin>>str1;
    std::cin>>str2;
	
  int ans[str1.length()+1][str2.length()+1];
  for (int j = 0; j < str1.length() + 1; j++) {
	  for (int k = 0; k < str2.length() + 1; k++) {
		  
		if (j == 0) {
			  ans[j][k] = k;
	  	}else if(k == 0) {
		  	  ans[j][k] = j;
		}else{
			  //std::cout << " str1= " << str1[j-1] << " str2= " << str2[k-1] << " \n ";
			  if (str1[j-1] == str2[k-1]){
			  	//std::cout << "(" <<ans[j - 1][k - 1] << "or" << ans[j - 1][k]+1 << "or" << ans[j][k - 1]+1 << ")" ;
				  ans[j][k] = std::min({ ans[j - 1][k - 1], ans[j - 1][k]+1, ans[j][k - 1]+1 });
				  //ans[j][k] = std::max({ 1,2,3 });
			  }else {
				  	ans[j][k] = std::min({ ans[j - 1][k - 1]+1,ans[j - 1][k]+1, ans[j][k - 1]+1 });
			  }
		}
		//std::cout << ans[j][k] << " ";
		
	  }
	  //std::cout << "\n";
  }
  std::cout << ans[str1.length()][str2.length()] << "\n";

  return 0;
}


Measured memory_bytes: 7072
import java.util.Scanner;

class Main { 	//2つの配列の中から同じものの個数を数える。



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int [] array1 = new int[n];	//1つ目の配列
		for (int i = 0; i < n; i++) {
			array1[i] = sc.nextInt();
		}
		int m = sc.nextInt();
		int [] array2 = new int[m];	//2つ目の配列
		for (int j = 0; j < m; j++) {
			array2[j] = sc.nextInt();
		}
		System.out.println(calc(array2, array1, m, n));
	}
	public static int calc(int[] a, int[] b ,int n, int m) {
		int count = 0;
		for (int i = 0; i < n; i++) {
			boolean d = true;
				for (int j = 0; j < m; j++) {
					if(d)
					if (a[i] == b[j]) {
						count++;
						d = false;
					}
				}
		}
		return count;
	}
}


Measured memory_bytes: 39888
//  155 C
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;

int main(){
    int n, tmp=0;
    string buf;
    cin >> n;
    bool check;
    map<string, int> s;
    vector<string> s_max;
    for(int i=0; i<n; i++){
        cin >> buf;
        s[buf] += 1;
    }

    int max_v = 0;
    for(auto itr = s.begin(); itr != s.end(); itr++){
        if(max_v <= itr->second){
            max_v = itr->second;
        }
    }
    for(auto itr = s.begin(); itr != s.end(); itr++){
        if(itr->second == max_v) {cout << itr->first << endl;} 
    }
    return 0;
}

Measured memory_bytes: 25216
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <sstream>

using namespace std;
const long long P = 1000000007;
const long long INF = 1LL << 60;

int main() {
  int n,m;
  cin >> n >> m;
  int a[m],b[m];
  map<int,int> mp;
  bool flag = false;
  for(int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    if(a[i] == 1) {
      mp[b[i]]++;
      if(mp[b[i]] == 2) {
        flag = true;
        break;
      }
    }
    if(b[i] == n) {
      mp[a[i]]++;
      if(mp[a[i]] == 2) {
        flag = true;
        break;
      }
    }
  }
  if(flag) {
    cout << "POSSIBLE" << endl;
  }else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 11136
// Author : MohamedSameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
void fo (){fflush(stdout);}
using namespace std;

int a[100];
int main ()
{

  int n ;
  scanf ("%d" , &n );
  for (int i =0 ; i < n ;i++)scanf ("%d" ,a+i ) ;
  sort(a,a+n);
  int pr = n-1 ;
  int ans = 1;
  for (int i = n-2 ; i >=0 ;i--)
  {
    if (a[i] < a[pr])
    {
      pr = i ;
      ans++;
    }
  }
  printf ("%d\n" , ans );

  //cerr << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}


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

using namespace std;


int main(void)
{
	string s;

	cin >> s;
	int c = 0;
	int c_num = 0;
	int big = 0;

	if (s[0] == 'A')
	{
		for (int i = 0; i < s.size(); i++)
		{
			if (s[i] == 'C')
			{
				c = i;
				c_num++;
			}
			else if (s[i] < 'a')
			{
				big++;
			}
		}
	}
	else
	{
		cout << "WA" << endl;

		return 0;
	}

	if (c >= 2 && c < s.size() - 1)
	{
		if (c_num == 1)
		{
			if (big == 1)
			{
				cout << "AC" << endl;

				return 0;
			}
		}
	}

	cout << "WA" << endl;

	return 0;
}

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

int main() {

    int n; cin >> n;

    vector <vector <double> > dp(n + 1, vector <double> (n + 1, 0));

    dp[0][0] = 1.0;
    for (int i = 1; i <= n; i++) {
        double p; cin >> p;

        for (int n_heads = 0; n_heads < i; n_heads++) {
            int n_tails = i - 1 - n_heads;
            
            dp[n_heads + 1][n_tails] += dp[n_heads][n_tails] * p;
            dp[n_heads][n_tails + 1] += dp[n_heads][n_tails] * (1 - p);
        }
    }

    double result = 0;
    for (int n_heads = n / 2; n_heads <= n; n_heads++) {
        int n_tails = n - n_heads;

        if (n_tails >= n_heads) continue;
        result += dp[n_heads][n_tails];
    }

    printf("%.10f", result);

    return 0;
}

Measured memory_bytes: 70656
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;


int main(void){
  int n,i,ans[100005]={};
  string s;
  
  cin >> s;
  n=s.size();
  
  i=0;
  int r,l,b;
  while (i<n){
    r=l=0;
    while (i<n && s[i]=='R'){
      r++;
      i++;
    }
    b=i;
    while (i<n && s[i]=='L'){
      l++;
      i++;
    }
    ans[b-1]+=(r+1)/2+l/2;
    ans[b]+=r/2+(l+1)/2;
  }
  
  for (i=0;i<n;i++) cout << ans[i] << ' ';
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

void CountingSort(unsigned short*,unsigned short*,int *,int,int);

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  j=-1;
  for(i=0;i<n;i++){ /* jに最大値を入れる＋ Aにすべての数を入れる */
    scanf("%d",&A[i]);
    if(j<A[i]) j=A[i];
  }
  
  CountingSort(A,B,C,j,n);
  


  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    
    if(i!=n) printf(" ");
    else printf("\n");
  }

  return 0;
}

void CountingSort(unsigned short* A,unsigned short* B,int *C,int k,int n){
  int i;

  for(i=0;i<=k;i++) C[i]=0;/* Cを初期化 */

  for(i=0;i<n;i++) C[A[i]]++;

  for(i=1;i<=k;i++) C[i]=C[i]+C[i-1];

  for(i=n-1;i>=0;i--){
    B[C[A[i]]]=A[i];
    C[A[i]]--;
  }

  return;
}



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

using namespace std;

int main(){
        long long int n,time[5],ans=4;
        cin>>n;
        for(int i=0; i<5; i++) cin>>time[i];

        sort(time,time+5);

        ans+=n/time[0];
        if(n%time[0]!=0)ans++;

        cout<<ans<<endl;
        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

using namespace std;
int main() {
	int n, k;
	cin >> n;
	string s;
	cin >> s;
	cin >> k;
	rep(i, s.size()) {
		if (s.at(i) != s.at(k - 1)) s.at(i) = '*';
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
using namespace std;

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

typedef long long ll;

int n;
ll gcd(ll a, ll b){
    return b == 0 ? a : gcd(b, a%b);
}
int main(){
    // LCM
    ll lcm = 1;
    cin >> n;
    REP(i, n){
        ll t;
        cin >> t;
        lcm = lcm / gcd(lcm, t) * t;
    }
    cout << lcm << endl;
}


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

using namespace std;
#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long

signed main(){
	int h,w;;
	cin>>h>>w;
	vector<int> a,b;
	lp(i,h){
		lp(j,w){
			char c;
			cin>>c;
			if(c=='B'){
				a.push_back(i+j);
				b.push_back(j-i);
			}
		}
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());

	cout<<max(abs(a[0]-a[a.size()-1]),abs(b[0]-b[b.size()-1]))<<endl;
	return 0;
}


Measured memory_bytes: 15432
import java.util.*;


import java.io.*;
 

 
 
public class Main 
{   
	
	
	public static void main(String[] args) throws IOException 
	{ 
		
		
	
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		StringTokenizer s=new StringTokenizer(br.readLine());
		
		int n=Integer.parseInt(s.nextToken());
		
		int a[]=new int[n];
		
		s=new StringTokenizer(br.readLine());
		for(int i=0;i<n;i++) {
						
			a[i]=Integer.parseInt(s.nextToken());
			
		}
		
		int min[]=new int[n];
		Arrays.fill(min, Integer.MAX_VALUE);
		min[n-1]=a[n-1];
		for(int i=n-2;i>=0;i--) {
			min[i]=Math.min(a[i], min[i+1]);
		}
//		for(int i=0;i<n;i++) {
//			pw.println(min[i]);
//		}
		
		for(int i=n-1;i>=0;i--) {
			if(a[i]-min[i]>1) {
				pw.println("No");
				pw.close();
			}
		}
		pw.println("Yes");
		pw.close();
		
		
	}

}

Measured memory_bytes: 61304
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int m=sc.nextInt();
        int[] priceA=new int[a+1];
        int[] priceB=new int[b+1];
        int minA=Integer.MAX_VALUE,minB=Integer.MAX_VALUE;
        for(int i=1;i<=a;i++)
        {
            priceA[i]=sc.nextInt();
            minA=Math.min(minA,priceA[i]);
        }
        for(int i=1;i<=b;i++)
        {
            priceB[i]=sc.nextInt();
            minB=Math.min(minB,priceB[i]);
        }
        int res=minA+minB;
         for(int i=1;i<=m;i++)
         {
             int x=sc.nextInt();
             int y=sc.nextInt();
             int c=sc.nextInt();
             int price=priceA[x]+priceB[y]-c;
             res=Math.min(res,price);
         }
         System.out.println(res);
    }
}

Measured memory_bytes: 132748
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	string S;
	cin >> S;
	ll d = 0;
	ll keta = 1;
	for(int i=S.length() - 1; i>=0; i--){
		if(S[i] == '/') continue;
		d += (S[i] - '0') * keta;
		keta *= 10;
	}
	
	cout << (d <= 20190430 ? "Heisei" : "TBD" );
	
	
    return 0;
}

Measured memory_bytes: 256
N,M = list(map(int,input().split()))

A = []
C = []
for i in range(M):
    a,b = list(map(int,input().split()))
    c = list(map(int,input().split()))
    A.append(a)
    d = 0
    for j in range(b):
        d += pow(2, c[j]-1)
    C.append(d)

goal = pow(2, N)-1
e_list = [[] for i in range(goal+1)]
for i in range(goal+1):
    for j in range(M):
        e_list[i].append((i|C[j],A[j]))
#dijkstra
#you need to prepare e_list = [[orient,dist]]

import heapq
vi = 0
min_d_list = [10**27 for i in range(goal+1)]
min_d_list[vi] = 0
q = []
for i in range(N):
    heapq.heappush(q,[min_d_list[i],i])

while len(q)>0:
    d,v = heapq.heappop(q)
    for e in e_list[v]:
        v1,d1=e
        if min_d_list[v1]>d+d1:
            min_d_list[v1]=d+d1
            heapq.heappush(q,[d+d1,v1])

if min_d_list[goal]>=10**27:
    print(-1)
else:
    print(min_d_list[goal])

Measured memory_bytes: 163460
#include <stdio.h>
#define MAX 100000

int S[MAX];

int binSearch(int key, int n) {
  int lowest, highest, middle;
  lowest = 0;
  highest = n - 1;
  middle = (highest + lowest) / 2;

  while(lowest <= highest) {
    if(key == S[middle])
      return 1;
    else if(key > S[middle])
      lowest = middle + 1;
    else
      highest = middle - 1;

    middle = (highest + lowest) / 2;
  }

  return key == S[middle];
}

int main() {
  int i, n, q, tmp, cnt;
  cnt = 0;

  scanf("%d", &n);
  for(i = 0;i < n;i++)
    scanf("%d", &S[i]);

  scanf("%d", &q);
  for(i = 0;i < q;i++) {
    scanf("%d", &tmp);
    if(binSearch(tmp, n))
      cnt++;

  }

  printf("%d\n", cnt);

  return 0;
}



Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define mod 1000000007
typedef long long ll;
using namespace std;

const int M = (int)(2e6 + 239);

void decitobinbitodeci()
{
    string binary = bitset<8>(128).to_string(); //to binary
    cout<<binary<<"\n";

    unsigned long decimal = bitset<8>(binary).to_ulong();
    cout<<decimal<<"\n";
}

int getnum(string a)
{
    int i,p=0;
    rep0(i,a.size())
    {
        p*=10;
        p+=a[i]-'0';
    }
    return p;
}

/*
1.always remember for ncr(n,2), you can calculate by->
n*(n-1)/2
2.Power of 2 ->  (1ll<<i)
*/

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast

    string a,b;
    cin>>a>>b;
    string s=b.substr(0,a.size());
    if(a==s)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}

/*Remember Remember, if you are so much excited that
your mind is shaking,
this is not the last contest that you are proceeding now,
if Almighty wants,
time will come.*/


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
 
/*------------------------------------------------------------------*/
 
int main(){
    string s; cin >> s;
    int n = s.size();
    int r_count = 0;
    rep(i, n){
        if(s[i] == '0')r_count++;
    }
    cout << n - abs(n - 2 * r_count) << endl;
}

Measured memory_bytes: 512
a,b,c,d = map(int,input().split())
if a >= 0:
  if d <= 0:
    print(a*d)
  else:
    print(b*d)
    
elif b>0:
  if d<0:
    print(a*c)
  else:
    print(max(a*c,b*d))
else:
  if c>=0:
    print(b*c)
  else:
    print(a*c)

Measured memory_bytes: 9188
import java.util.Scanner;

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

        long[] sumA = new long[n+1];
        long[] sumB = new long[m+1];

        for (int i=1; i<=n; i++) {
            long a = sc.nextLong();
            sumA[i] = sumA[i-1] + a;
        }

        for (int i=1; i<=m; i++) {
           long b = sc.nextLong();
            sumB[i] = sumB[i-1] + b;
        }

        int ans = 0;
        int flag = m;
        for(int i=0; i<=n; i++) {
            if(sumA[i]>k) break;
            while (sumB[flag]>k-sumA[i]&&flag>0) {
                flag--;
            }
            ans = Math.max(ans, i+flag);
        }
        System.out.print(ans);
    }
}


Measured memory_bytes: 63380
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N];
		long total = 0;
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt()*2;
			if(i % 2 == 0)
				total += A[i];
			else
				total -= A[i];
		}
		long D = total/2;
		StringBuilder ans = new StringBuilder();
		for(int i = 0; i < N; i++) {
			ans.append(D);
			if(i != N-1)
				ans.append(" ");
			D = A[i] - D;
		}
		System.out.println(ans);

	}

}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);


typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;


#define MAX (int)1e6 + 10
const ll mod = 1e9 + 7;
const double pi = 2*acos(0.0);
vector<bool> prime(MAX,true);

vl graph[MAX];
vl parent(MAX);
vector<bool> vis(MAX,0);

int main(int argc, char const *argv[])
{
	ll a,b;
	cin >> a >> b;
	if(b % a == 0)cout << b + a << '\n';
	else cout << b - a << '\n';
}


Measured memory_bytes: 31744
Scanf.scanf "%d %d" (fun n k ->
    let d = Array.make 10 false in
    for i = 1 to k do
        Scanf.scanf " %d" (fun j -> d.(j) <- true)
    done;

    let check k =
        let s = string_of_int k in
        let sn = String.length s in
        let rec loop i =
            if i = sn then true else
                if d.(int_of_char s.[i] - 48) then false else loop (i + 1)
        in
        loop 0
    in

    let rec loop i =
        if check i then Printf.printf "%d\n" i else loop (i + 1)
    in
    loop n
)

Measured memory_bytes: 5776
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main {
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) throws Exception {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			
			int n = Integer.parseInt(br.readLine());
			
			Map<String, Integer> map = new HashMap<>();
			int max = 0, tmp = 0;
			for (int i = 0; i < n; i++) {
				String s = br.readLine();
				if (map.containsKey(s)) {
					tmp = map.get(s) + 1;
					map.replace(s, tmp);
					max = Math.max(max, tmp);
				} else {
					map.put(s, 1);
					max = Math.max(max, 1);
				}
			}
			List<String> list = new ArrayList<>();
			for (String key : map.keySet()) {
				if (map.get(key) == max)
					list.add(key);
			}
			Collections.sort(list);
			for (String s : list)
				out.println(s);
			out.flush();
		}
	}
}

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

int main(void){
   long double l;
   cin >> l;
   l /=3;
   //std::setprecision(20);
   cout << setprecision(40) <<l * l * l << endl;
   return 0;
}

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

int n;
string u[256];
int m;
string t;

int main() {
	int i, j;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> u[i];
	cin >> m;
	
	bool isOpen = false;
	for (i = 0; i < m; i++) {
		cin >> t;
		for (j = 0; j < n; j++) {
			if (t == u[j]) {
				break;
			}
		}
		if (j < n) {
			isOpen = !isOpen;
			if (isOpen) { cout << "Opened by " << t << endl; }
			else { cout << "Closed by " << t << endl; }
		}
		else {
			cout << "Unknown " << t << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3192
x1,y1,x2,y2 = map(int,input().split())
L = (x1-x2)**2 + (y1-y2)**2
x4 = x1 -(y2-y1)
y4 = y1 + (x2-x1)
x3 = x2 - (y2-y1)
y3 = y2 + (x2-x1)
 

print(x3)
print(y3)
print(x4)
print(y4)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;

char s[1000];
int n;
int main() {
	//freopen("a.inp", "r", stdin);
	scanf("%d\n",&n);
	scanf("%s", s);
	int thieu = 0;
	int mo = 0;
	for(int i=0;i<n;i++) {
		if (s[i] == '(') {
			mo ++;
		} else mo--;
		if (mo <0) {
			mo = 0;
			thieu++;
		}
	}
	for(int i=0;i<thieu;i++) {
		cout<<'(';
	}
	cout<<s;
	for(int i=0;i<mo;i++) {
		cout<<')';
	}
}

Measured memory_bytes: 256
/*input

*/


// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll          int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}

const ll N = 2e5+5;
ll n,k;
vi t(2*N+10);

// [l,r)
void modify(int l, int r, int value) 
{

  for (l += n, r += n; l < r; l >>= 1, r >>= 1) 
  {
    if (l&1) t[l++] += value;
    if (r&1) t[--r] += value;
  }

}

int query(int p) 
{
  int res = 0;
  for (p += n; p > 0; p >>= 1) res += t[p];
  return res;
}


int solve()
{
	cin>>n>>k;
	vi a(n);
	rep(i,0,n) cin>>a[i];

	if(k>50) rep(i,0,n) a[i]=n;
	else
	{
		while(k--)
		{
			rep(i,0,sz(t)) t[i]=0;
			rep(i,0,n)
			{
				ll l = max(0,i-a[i]);
				ll r = min(n,i+a[i]+1);

				modify(l,r,1);
			}

			rep(i,0,n) a[i]=query(i);

		}
	}

	rep(i,0,n) cout<<a[i]<<" ";

	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll w,h;

vector<vector<ll>> v;
vector<string> vs;

int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};

bool in(int y,int x){
    return y >= 0 && y < h && x >= 0 && x < w;
}

ll c(int y,int x){
    v[y][x] = -1;
    ll res = 0;
    rep(i,4){
        ll ny = y + dy[i];
        ll nx = x + dx[i];
        if(!in(ny,nx))continue;
        if(vs[ny][nx] == 'W'){
            res |= 1;
            continue;
        }
        else if(vs[ny][nx] == 'B'){
            res |= 2;
            continue;
        }
        else if(v[ny][nx] == -1)continue;
        ll num = c(ny,nx);
        res |= num;
    }
    return res;
}

void solve(int y,int x,int col){
    v[y][x] = col;
    rep(i,4){
        int ny = y + dy[i];
        int nx = x + dx[i];
        if(!in(ny,nx))continue;
        if(vs[ny][nx] == '.' && v[ny][nx] == -1)solve(ny,nx,col);
    }
}

void print(){
    rep(i,h){
        rep(j,w){
            printf("%2lld",v[i][j]);
        }
        cout << endl;
    }
}

int main(){
    while(cin >> w >> h && w){
        vs.clear();
        v.clear();
        vs.resize(h);
        v.resize(h);
        rep(i,h){
            v[i].resize(w,0);
            cin >> vs[i];
        }
        rep(i,h){
            rep(j,w){
                ll col;
                if(vs[i][j] == '.'){
                    col = c(i,j);
                    solve(i,j,col);
                // print();
                }
            }
        }
        ll ans[2] = {};
        rep(i,h){
            rep(j,w){
                // printf("%2lld",v[i][j]);
                if(v[i][j] == 2)ans[0]++;
                else if(v[i][j] == 1)ans[1]++;
            }
            // cout << endl;
        }
        cout << ans[0] << " " << ans[1] << endl;
    }
}


Measured memory_bytes: 3428
import java.util.*;
import java.lang.Math;

class Main {
  private static long score(long n, long a) {
    return a - 1 + n/a - 1;
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();

    long min = Long.MAX_VALUE;
    for (long i = 1; i * i <= n; i++) {
      if (n % i == 0) {
        min = Math.min(score(n, i), min);
      }
    }

    System.out.println(min);
  }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using tiii = tuple<int, int, int>;
const int MAX_HW = 500;

int colors[MAX_HW][MAX_HW];
vector<string> bw_grid;
int bw_cnt[2][MAX_HW * MAX_HW];
int h, w;

int bw(int i, int j)
{
    return int(bw_grid[i][j] == '#');
}

void bfs()
{
    int color = 1;
    rep(i, 0, h)
    rep(j, 0, w)
    if (colors[i][j] == 0)
    {
        queue<tiii> que;
        int reverse_bw = (1 + bw(i, j)) % 2;
        que.push(make_tuple(i, j, reverse_bw));
        while (que.size() > 0)
        {
            int x,y,prev_c;
            tie(x, y, prev_c) = que.front();
            que.pop();

            if (x < 0 or h <= x) continue;
            if (y < 0 or w <= y) continue;

            if (colors[x][y] != 0) continue;

            int now_c = bw(x, y);
            if (now_c == prev_c) continue;

            colors[x][y] = color;
            ++bw_cnt[now_c][color];

            que.push(make_tuple(x-1, y, now_c));
            que.push(make_tuple(x+1, y, now_c));
            que.push(make_tuple(x, y-1, now_c));
            que.push(make_tuple(x, y+1, now_c));
        }
        ++color;
    }
}

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

    rep(i, 0, h)
    {
        string s;
        cin >> s;
        bw_grid.push_back(s);
    }
    bfs();

    ll ans = 0;
    rep(i, 1, MAX_HW * MAX_HW)
        ans += (ll)bw_cnt[0][i] * bw_cnt[1][i];

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int dx[]={1,0};
  int dy[]={0,1};
  char a[3][3];
  while(cin>>a[0][0]) {
    REP(i,3)
      REP(j,3)
      if (i!=0||j!=0)
        cin >> a[j][i];
    int f = 0;
    REP(i,2) {
      int x = 0, y = 0;
      REP(j,3) {
        char b[3];
        if (dx[i]) x=0;
        if (dy[i]) y=0;
        REP(k,3) {
          b[k] = a[x][y];
          x += dx[i];
          y += dy[i];
        }
        if (b[0]=='o'&&b[1]=='o'&b[2]=='o') cout << 'o' << endl, f=1;
        if (b[0]=='x'&&b[1]=='x'&&b[2]=='x') cout << 'x' << endl, f=1;
        x += dx[i^1];
        y += dy[i^1];
      }
    }
    if (a[0][0]==a[1][1]&&a[1][1]==a[2][2]) {
      if (a[0][0]!='s')
        cout << a[0][0] << endl,f=1;
    }
    if (a[2][0]==a[1][1]&&a[1][1]==a[0][2]) {
      if (a[2][0]!='s')
        cout << a[2][0] << endl,f=1;
    }
    if(f==0) cout << 'd' << endl;
  }
      
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main() {

    int a[3],tmp,sum;
    for(int i=0; i<3; i++){
        cin >> a[i];
    }
    for(int i=0; i<2; i++){
        for(int j=i; j<3; j++){
            if(a[i] < a[j]){
                tmp = a[j];
                a[j] = a[i];
                a[i] = tmp;
            }
        }
    }
    sum = a[0]-a[1];
    sum+= a[1]-a[2];
    cout << sum;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];

  int s = 0;
  ll mo = 1000;
  REP(i, n) {
    ll mi = a[i];
    if(i == n - 1 || a[i] > a[i + 1]) {
      FOR(j, s, i) {
        mi = min(mi, a[j]);
      }
      s = i;
    }
    ll t = (mo / mi);
    mo -= (mi * t);
    mo += t * a[i];
  }

  cout << mo << endl;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL N; cin >> N;
	VL a(N);
	set<LL>se;
	FOR(i, 0, N) {
		cin >> a[i];
		auto it = se.find(a[i]);
		if (it != se.end()) {
			se.erase(it);
		}
		else {
			se.insert(a[i]);
		}
	}

	LL ans = SZ(se);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5760
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

typedef struct{
  int x,y;
  int cost;
  int ch;
}mouse;

int maxch[1000][1000];

main(){
  int h,w,n;
  cin>>h>>w>>n;
  char ku[h][w];
  rep(i,h)cin>>ku[i];

  int sx,sy;
  rep(i,h)rep(j,w)if(ku[i][j]=='S')sx=i,sy=j;

  queue<mouse> Q;
  memset(maxch,-1,sizeof(maxch));

  Q.push((mouse){sx,sy,0,0});
  maxch[sx][sy]=0;


  int ans=0;
  while(!Q.empty()){
    //    cout<<Q.size()<<endl;
    mouse t=Q.front();Q.pop();
    int cx=t.x,cy=t.y,cost=t.cost;
    int ch=t.ch;
    if(ch==n){
      ans=cost;
      break;
    }



    rep(i,4){
      int nx=cx+dx[i],ny=cy+dy[i];
      if(nx<0 || nx>=h || ny<0 || ny>=w)continue;
	 if(ku[nx][ny]=='X')continue;
	 int nch=ch;
	 if(ku[nx][ny]<='9' && ku[nx][ny]>='1'){
	   int num=ku[nx][ny]-'0';
	   if(num==t.ch+1){
	     nch=ch+1;
	   }
	 }
	 if(maxch[nx][ny]>=nch)continue;
	 maxch[nx][ny]=nch;

	 Q.push((mouse){nx,ny,cost+1,nch});
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<ll> ans(N+1,0);
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,less<pair<ll,int>>> que;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        que.push(make_pair(a,-i-1));
    }
    que.push(make_pair(0,0));

    priority_queue<pair<ll,int>,vector<pair<ll,int>>,less<pair<ll,int>>> tmp;
    ll a=que.top().first;
    int pos=-que.top().second;
    ll cnt=1;
    que.pop();
    while((int)que.size()){
        ll b=que.top().first;
        int sec=-que.top().second;
        que.pop();
        //cout << a << ' ' << pos << ' ' << b << ' ' << sec << ' ' << cnt << endl;
        if(pos>sec){
            //cout << pos << ' ' << sec << ' ' << cnt << endl;
            ans[pos]=cnt*(a-b);
            while((int)tmp.size()&&tmp.top().first>=b){
                //cout << "tmp " <<  tmp.top().first << ' ' << tmp.top().second << endl;
                ans[pos]+=tmp.top().first-b;
                cnt++;
                tmp.pop();
            }
            cnt++;
            a=b;
            pos=sec;
        }else{
            tmp.push(make_pair(b,-sec));
        }
    }
    for(int i=1; i<=N; i++){
        cout << ans[i] << '\n';
    }
}

Measured memory_bytes: 5616
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>

typedef int llint;

llint dp[2][6001] = {};

int main(void){
  int n, t;
  std::cin >> n >> t;

  std::vector<std::array<int, 2> > foods(n);
  for(int i=0; i<n; i++){
    std::cin >> foods[i][0] >> foods[i][1];
  }

  std::sort(foods.begin(), foods.end());
  //for(const auto& elem: foods){
  //  std::cout << elem[0] << " " << elem[1] << " " << elem[2] << std::endl;
  //}
  /**
  for(const auto& elem: data){
    std::cout << elem[0] << " " << elem[1] << std::endl;
  }
  **/

  int ret = 0;
  for(int i=0; i<n; i++){
    auto food = foods[i];
    for(int j=0; j<t; j++){
      int temp = dp[(i+1)%2][j] + int(food[1]);
      if(temp > dp[i%2][j+int(food[0])])
	dp[i%2][j+int(food[0])] = temp;
      if(dp[(i+1)%2][j] > dp[i%2][j])
	dp[i%2][j] = dp[(i+1)%2][j];
      if(temp > ret) ret = temp;
    }


    //for(int i=0; i<60; i++){
    //  std::cout << dp[i%2][i] << " ";
    //}
    //std::cout << std::endl;

  }

  /**
  int best = 0;
  for(int i=0; i<n; i++){
    if(data[i][0] >= t) break;
    if(best < data[i][1]) best = data[i][1];

    for(int j=i+1; j<n; j++){
      if(best < data[i][1] + foods[j][2]) best = data[i][1] + foods[j][2];
    }
  }
  **/
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 256