akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N, M;

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

  cin >> N >> M;
  string ans = N==M?"Yes":"No";
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	float time_500, time_1000;
	
	while (scanf("%f %f", &time_500, &time_1000) != EOF){
	
		if (time_500 < 35.50 && time_1000 < 71.00){
			printf("AAA\n");
		}
		else if (time_500 < 37.50 && time_1000 < 77.00){
			printf("AA\n");
		}
		else if (time_500 < 40.00 && time_1000 < 83.00){
			printf("A\n");
		}
		else if (time_500 < 43.00 && time_1000 < 89.00){
			printf("B\n");
		}
		else if (time_500 < 50.00 && time_1000 < 105.00){
			printf("C\n");
		}
		else if (time_500 < 55.00 && time_1000 < 116.00){
			printf("D\n");
		}
		else if (time_500 < 70.00 && time_1000 < 148.00){
			printf("E\n");
		}
		else {
			printf("NA\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >> S;
    sort(S.begin(), S.end());
    if (S[0] == S[1] && S[2] == S[3] && S[0] != S[2]) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args:Array<String>){
    val (n,a) = readLine()!!.split(" ").map{it.toInt()}
    val x = readLine()!!.split(" ").map{it.toInt()}
    val dp = Array(60){Array(60){LongArray(3000) } }
    dp[0][0][0] = 1
    for(i in 0 until n){
        for(j in 0 .. 50){
            for(k in 0 .. 2500){
                if(j > 0 && k >= x[i]) dp[i + 1][j][k] += dp[i][j - 1][k - x[i]]
                dp[i + 1][j][k] += dp[i][j][k]
            }
        }
    }
    var ans = 0L
    for(i in 1 .. 50){
        ans += dp[n][i][i * a]
    }
    println(ans)
}


Measured memory_bytes: 160104
#include<stdio.h>

int main() {
  int num, prime, i, j, k, n[1000001] = {}; 

  while(scanf("%d", &num) != EOF) {
    for(i = 2; i < num + 1; i += 1) {
      n[i] = i;
    };

    for(j = 2; j < num +  1; j += 1) {
      for(k = n[j] * 2; k < num + 1; k += n[j]) {
        if(n[j] == 0) {
          break;
        };
        n[k] = 0;
      };
    };
    prime = 0;
    for(i = 2; i < num + 1; i += 1) {
      if(n[i] != 0) {
        prime += 1;
      };
    };

    printf("%d\n", prime);
  };

  return 0;
}

Measured memory_bytes: 4508
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

int main(){
    lli a,b,x,ans=0;
    lli i,j;
    cin>>a>>b>>x;
    if(a==0){
        ans++;
    }
    if(a!=0){
        a--;
    }
    ans+=b/x-a/x;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

h, w = map(int, input().split())
ma = [ list(map(int,input().split(" "))) for i in range(10)]
sco = [ list(map(int,input().split(" "))) for i in range(h)]
a = csr_matrix(ma)
b = dijkstra(a)
ans = 0
for i in range(h):
  for j in range(w):
    num = sco[i][j]
    if num != -1:
      ans += b[num][1]
print(int(ans))

Measured memory_bytes: 38244
/*
* @Author: dnhirapara
* @Problem: abc171_e
* @Time: 07-September-2020 : ( 16:20:25 )
*/
#include <bits/stdc++.h>

using namespace std;

/************defination************/

#define endl "\n"
#define logger(x) cout << __LINE__ << ": " << #x << " -> " << (x) << endl;
#define ll long long int
#define ull unsigned long long int

//@time comp :
//@space comp :
int main()
{
    // ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    // cin.ignore(); must be there when using getline(cin, s)
    ll tc = 1;
    //cin >> tc;
    while (tc--)
    {
        ll n;
        cin>>n;
        ll a[n];
        ll ans[n];
        ll cumulative_xor = 0;
        for (int i = 0; i < n; i++){
            cin >> a[i];
            cumulative_xor ^= a[i];
        }
        for (int i = 0; i < n;i++){
            ans[i] = cumulative_xor ^ a[i];
            cout << ans[i] << " ";
        }

    }
    return 0;
}

Measured memory_bytes: 6696
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 100005
 
#define PI 3.14159265358979323846264338327950
 
#define F first
#define S second
 
#define ll 	 long long int
 
#define mod  1000000007

 
int main()
{
	FAST;
	ll a[5];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << 10*a[2] +  a[0] + a[1];
	return 0;
}

Measured memory_bytes: 3600
city={}
result=True

for i in range(4):
    city[i]=0

for i in range(3):
    a,b=map(int,input().split())
    a-=1
    b-=1
    city[a]+=1
    city[b]+=1

for i in range(4):
    if(2<city[i]):
        result=False

if(result):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	scanf("%d", &n);
	ll ans=0, b;
	for(int i=0; i<n; i++){
		ll a;
		scanf("%d", &a);
		if(i==0){
			ans+=(a-1);
			b=1;
			continue;
		}
		if(a==b+1){
			b++;
		}else{
			ans+=((a-1)/(b+1));
		}
	}
	printf("%lld\n", ans);
    return 0;
}

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

int main() {

	ll n, x; cin >> n >> x;
	vector<ll> m(n);
	ll sum = 0;
	for (ll i = 0; i < n; i++) {
		cin >> m[i];
		sum += m[i];
	}
	sort(m.begin(), m.end());
	x -= sum;
	cout << x / m[0] + n << endl;
	return 0;
}

Measured memory_bytes: 3628
package main

import (
	"fmt"
)

func main() {
	var a, b, c, x, sum int
	fmt.Scan(&a, &b, &c, &x)
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if 500*i+100*j+50*k == x {
					sum++
				}
			}
		}
	}
	fmt.Println(sum)
}


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

int main()
{
    int a, b;
    cin >> a >> b;
    if (a > b*2)
    {
        cout << a - b*2 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
set<ll> s;
void primeFactors(ll n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        s.insert(2);  
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
           	s.insert(i); 
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
         s.insert(n);  
}  
ll gcd(ll a,ll b)
{
  return (b == 0)?a:gcd(b,a%b);
}
int main()
{
  ll a,b;
  cin>>a>>b;
  ll g;
  if(a>b)
    g = gcd(a,b);
  else
    g = gcd(b,a);
  primeFactors(g);
  cout<<s.size()+1;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,j,b[1000]={0};
    char a[100000];
    scanf("%s",a);
    for(i=0;a[i]!='\0';i++)
        {
        }
    i++;

    //printf("%d",j);
    for(j=0;j<i;j++)
    {
        b[a[j]-97]++;
    }
    for(j=0;j<29;j++)
    {
        if(b[j]%2!=0)
        {
            puts("No\n");
            return 0;
        }

    }
    puts("Yes\n");
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define vec(T) vector<T>
using namespace std;
using ull = unsigned long long;
using ll = long long;


int main() {
    int A, B;
    cin >> A >> B;
    int T;
    cin >> T;
    cout << T / A * B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
inline void out(long long x){if(x<0) putchar('-'),x=-x;if(x>9) out(x/10);putchar(x%10+'0');}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))

int n,m,k;
int s1,s2,t1,t2;

queue<ii> q;

main(){
    #define task "TASK"
    if(fopen(task".inp","r")){
        freopen(task".inp","r",stdin);
        //freopen(task".out","w",stdout);
    } fasty;

    cin>>m>>n>>k;
    vector<vector<int>> f(m+1,vector<int>(n+1));
    cin>>s1>>t1>>s2>>t2;
    forinc(i,1,m) forinc(j,1,n) {char ch; cin>>ch; f[i][j]=(ch=='.' ? -1 : 1e9);}

    q.push({s1,t1}); f[s1][t1]=0;

    while(q.size()){
        int x,y; tie(x,y)=q.front(); q.pop();
        if(x>0 && (f[x-1][y]==-1 || f[x-1][y]==f[x][y]+1)){
            forinc(i,1,k){
                if(x-i>0 && f[x-i][y]==f[x][y]+1) continue;
                if(x-i<1 || f[x-i][y]!=-1) break;
                f[x-i][y]=f[x][y]+1;
                q.push({x-i,y});
            }
        }
        if(y>0 && (f[x][y-1]==-1 || f[x][y-1]==f[x][y]+1)){
            forinc(i,1,k){
                if(y-i>0 && f[x][y-i]==f[x][y]+1) continue;
                if(y-i<1 || f[x][y-i]!=-1) break;
                f[x][y-i]=f[x][y]+1;
                q.push({x,y-i});
            }
        }
        if(x<m && (f[x+1][y]==-1 || f[x+1][y]==f[x][y]+1)){
            forinc(i,1,k){
                if(x+i<=m && f[x+i][y]==f[x][y]+1) continue;
                if(x+i>m || f[x+i][y]!=-1) break;
                f[x+i][y]=f[x][y]+1;
                q.push({x+i,y});
            }
        }
        if(y<n && (f[x][y+1]==-1 || f[x][y+1]==f[x][y]+1)){
            forinc(i,1,k){
                if(y+i<=n && f[x][y+i]==f[x][y]+1) continue;
                if(y+i>n || f[x][y+i]!=-1) break;
                f[x][y+i]=f[x][y]+1;
                q.push({x,y+i});
            }
        }
    }
    cout<<(f[s2][t2]==1e9 ? -1 : f[s2][t2]);
}


Measured memory_bytes: 15028
#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() {
  string S;
  cin >> S;
  int N = S.length();
  int cnt[2];
  cnt[0] = cnt[1] = 0;

  for (int i = 0; i < N; i++)
  {
    if (S[i] == '0')
    {
      cnt[0]++;
    } else
    {
      cnt[1]++;
    } 
  }
  cout << min(cnt[0], cnt[1]) * 2 <<endl;
  return 0;
}


Measured memory_bytes: 3744
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{
    int n, a;
    cin >> n >> a;
    cout << n * n - a << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;

int main(){
	ios::sync_with_stdio(0), cin.tie(0);
	long long int t;
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(ll i = 0;i<n;i++) cin>>a[i];
	ll dp[n+1];
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for(ll i = 2;i<n;i++){
		ll c = INT_MAX;
		for(ll j = 1;j<=k && j<=i;j++){
			ll val = dp[i-j] + abs(a[i]-a[i-j]);
			if(val<c){
				c = val;
			}
		}
		dp[i] = c;
	}
	cout<<dp[n-1]<<endl;
}



Measured memory_bytes: 5068
n=int(input())
ab = []
for _ in range(n):
    a= int(input())
    ab.append(a)

ab.sort()
memo = 1
ans = 0
for i in range(n):
    if i == n-1:
        ans += memo%2
    elif ab[i] == ab[i+1]:
        memo += 1
    else:
        ans += memo%2
        memo = 1
print(ans)

Measured memory_bytes: 50264
N=int(input())

sub=[0 for i in range(N)]

A=[0]
array=list(map(int,input().split()))
for i in range(len(array)):
    A.append(array[i]) 

for i in range(1,len(A)):
    sub[A[i]-1]+=1

for i in sub:
    print(i)

Measured memory_bytes: 100520
a,b,c,d=map(int,input().split())
import fractions as f
cc=b//c-(a-1)//c
dd=b//d-(a-1)//d
gcd=f.gcd(c,d)
lcm=c*d//gcd
cd=b//lcm-(a-1)//lcm
print((b-a+1)-(cc+dd-cd))

Measured memory_bytes: 5048
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = Integer.parseInt(in.nextLine());
		double[] x = new double[N];
		String[] u = new String[N];
		for (int i = 0; i < N; ++i) {
			String[] tokens = in.nextLine().split(" ");
			x[i] = Double.parseDouble(tokens[0]);
			u[i] = tokens[1];
		}
		in.close();
		double result = 0.0;
		for (int i = 0; i < N; ++i) {
			if (u[i].equals("JPY")) {
				result += x[i];
			} else {
				result += x[i] * (380000.0);
			}
		}
		System.out.println(result);
	}

}

Measured memory_bytes: 23764
# Author: S Mahesh Raju
# Username: maheshraju2020
# Date: 30/07/2020

from sys import stdin,stdout
from math import gcd, ceil, sqrt
from collections import Counter
from bisect import bisect_left, bisect_right
ii1 = lambda: int(stdin.readline().strip())
is1 = lambda: stdin.readline().strip()
iia = lambda: list(map(int, stdin.readline().strip().split()))
isa = lambda: stdin.readline().strip().split()
mod = 1000000007

n = ii1()
cur = None
for i in range(n):
    a, b, c = iia()
    if not cur:
        cur = [a, b, c]
    else:
        t1 = max(cur[1], cur[2]) + a
        t2 = max(cur[0], cur[2]) + b
        t3 = max(cur[0], cur[1]) + c
        cur = [t1, t2, t3]
print(max(cur))

Measured memory_bytes: 75080
#include <stdio.h>
   
   
   int main(void) {
    int A,B;

    
    
     scanf("%d %d",&A,&B);

      int SUM = A + B;
      
     if( SUM > 9) {
                  printf("error");
              } else {
                  printf("%d",SUM);
              }
   
   
   
   return 0;
   
   }

Measured memory_bytes: 128
#include<iostream>
#include<string>

using namespace std;

int main(){
	string s;

	cin >> s;
	int l,r;
	for(l =0;l < s.size();l++)if(s[l] == 'A')break;
	for(r =s.size()-1;r >= 0;r--)if(s[r] == 'Z')break;

	cout << r-l+1 <<endl;
	
	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

// 500, 80min

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 60

ll N;
ll D[MAX_N] = {};

signed main()
{
    cin >> N;
    REP(i, N) { scanf("%lld", &D[i]); }

    if(N >= 24) {
        printf("0\n");
        return 0;
    }
    else if(N == 23 || N == 22) {
        map<int, int> times;
        REP(i, N) {
            times[D[i]]++;
            if(times[D[i]] >= 3 ||
               (D[i] == 12 && times[D[i]] >= 2) ||
               D[i] == 0) {
                printf("0\n");
                return 0;
            }
        }
        printf("1\n");
        return 0;
    }
    // 全パターン試す
    ll ans = 0;
    for(ll i = 0; i < 2097152; ++i) {
        ll s = LLINF;
        vector<ll> time_line;
        time_line.push_back(0);
        REP(j, N) {
            if(D[j] == 0) {
                printf("0\n");
                return 0;
            }
            ll tmp;
            if((i >> j) & 1) { tmp = D[j]; }
            else { tmp = 24 - D[j]; }
            time_line.push_back(tmp);
        }
        SORT(time_line);
        for(ll j = 0; j < time_line.size(); ++j) {
            ll prev = j - 1;
            ll next = j + 1;
            if(prev < 0) { prev = time_line.size() - 1; }
            if(next >= time_line.size()) { next = 0; }
            ll huge = (time_line[j] > time_line[prev]) ? time_line[j] : time_line[prev];
            ll little = (time_line[j] < time_line[prev]) ? time_line[j] : time_line[prev];
            s = min({s, huge - little, 24 + little - huge});
            huge = (time_line[j] > time_line[next]) ? time_line[j] : time_line[next];
            little = (time_line[j] < time_line[next]) ? time_line[j] : time_line[next];
            s = min({s, huge - little, 24 + little - huge});
        }
        ans = max(ans, s);
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int f(char a, char b, char c)
{
	if(a == b && b == c){
		if(a == 'o') return 1;
		else if(a == 'x') return 2;
	}
	return 0;
}

int main()
{
	string s;
	while(cin >> s){
		string t;
		int res = 0;
		for(int i = 0; i < 3 && res == 0; ++i){
			res = f(s[i*3],s[i*3+1],s[i*3+2]);
		}
		for(int i = 0; i < 3 && res == 0; ++i){
			res = f(s[i],s[i+3],s[i+6]);
		}
		if(res == 0){
			res = f(s[0],s[4],s[8]);
		}
		if(res == 0){
			res = f(s[2],s[4],s[6]);
		}
		cout << (res == 0 ? 'd' : res == 1 ? 'o' : 'x') << endl;
	}
}

Measured memory_bytes: 1176
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>

using namespace std;



int main() {
	int L;
	cin >> L;

	long double e = (long double)L / 3.0;

	std::cout << std::fixed;
	cout << std::setprecision(7) << e * e * e;
}


Measured memory_bytes: 256
def main():
    A, B, C, D, E, F = (int(i) for i in input().split())

    water = set()
    for a in range(0,F+1,100*A):
        for b in range(0,F+1,100*B):
            if a + b != 0 and a+b <= F:
                water.add(a+b)

    max_consist = 0
    ans = (0,0)
    for w in water:
        ab = w //100
        sugar_max = E * ab
        x = sugar_max // C
        y = sugar_max // D
        s = max(C*i + D*j for i in range(x+1) for j in range(y+1) if C*i + D*j <= sugar_max and w + C*i + D*j <= F)
        if w + s <= F:
            cur_consist = (100*s)/(w+s)
            if max_consist <= cur_consist:
                max_consist = cur_consist
                ans = (w + s,s)

    print(*ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g){
    for(int i=g;i<n;i++){
        int v=A[i];
        int j=i-g;
        while(j>=0&&A[j]>v){
            A[j+g]=A[j];
            j-=g;
            cnt++;
        }
        A[j+g]=v;
    }
}

void shellSort(int A[], int n){
    for(int h=1;;){
        if(h>n)break;
        G.push_back(h);
        h = 3*h+1;
    }
    for(int i=G.size()-1; i >=0;i--){
        insertionSort(A, n, G[i]);
    }
}

int main(){
    cin >> n;
    for(int i=0;i<n;i++)scanf("%d", &A[i]);
    cnt=0;
    shellSort(A,n);
    cout << G.size() << endl;
    for(int i=G.size()-1;i>=0;i--){
        printf("%d", G[i]);
        if(i) printf(" ");
    }
    printf("\n");
    printf("%d\n", cnt);
    for(int i=0;i<n;i++)printf("%d\n", A[i]);

    return 0;
}

Measured memory_bytes: 7208
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


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

    string sin;
    int h, w, y, x;
    cin >> h >> w;
    rep(i, h){
        rep(j, w){
            cin >> sin;
            if(sin == "snuke"){
                y = i;
                x = j;
                break;
            }
        }
    }

    cout << char(x + 'A') << y+1 << endl;

    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Here your code !
employeeSalesList = []

def resetDataset():
    for count in range(len(employeeSalesList)):
        employeeSalesList.pop(0)

def readDataCount():
    return int(input())

def searchEmployeeSales(employeeId):
    for data in employeeSalesList:
        if data[0] == employeeId:
            return data
    
    newData = [employeeId, 0]
    employeeSalesList.append(newData)
    return newData

def checkSales():
    employeeId, price, volume = list(map(int, input().split(" ")))
    employeeSales = searchEmployeeSales(employeeId)
    employeeSales[1] += price * volume

def printEmployeeOfDataset():
    found = False
    for data in employeeSalesList:
        if data[1] >= 1000000:
            print(data[0])
            found = True
    if not found:
        print("NA")

resetDataset()
dataCount = readDataCount()
while dataCount > 0:
    for _ in range(dataCount):
        checkSales()
    printEmployeeOfDataset()
    resetDataset()
    dataCount = readDataCount()

Measured memory_bytes: 7900
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define ms(x, v) memset(x, v, sizeof(x))
using namespace std;
const int N = 100005;
int s[N], b[N];
int main()
{
#ifdef LOCAL
	freopen("in.txt", "r", stdin);
#endif
	ios::sync_with_stdio(0), cin.tie(0);
	int n, x;
	cin >> n;
	rep1(i, n)
	{
		cin >> x;
		if(x) b[x - 1]++;
		b[x]++;
		b[x + 1]++;
	}
	int mx = 0;
	rep(i, N) if (mx < b[i]) mx = b[i];
	cout << mx << endl;
	return 0;
}

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


void solve(std::string S, std::string T, long long A, long long B, std::string U){
    if(S==U){
        A--;
    }else{
        B--;
    }
    cout<< A << " " << B<< endl;

}

// Generated by 1.1.6 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(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    std::string U;
    std::cin >> U;
    solve(S, T, A, B, U);
    return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)

ans = [0]*N
lr_idx = 0
for i in range(N-1):
    if S[i] == 'R' and S[i+1] == 'L':

        r_odd = 0  # 奇数
        r_even = 0  # 偶数
        for c, j in enumerate(reversed(range(lr_idx, i))):
            if S[j] == 'R':
                if (c+1) % 2 == 0:
                    r_even += 1
                else:
                    r_odd += 1

        l_odd = 0
        l_even = 0
        for c, j in enumerate(range(i+2, N)):
            if S[j] == 'R' and S[j+1] == 'L':
                break

            if S[j] == 'L':
                if (c+1) % 2 == 0:
                    l_even += 1
                else:
                    l_odd += 1

        ans[i] = 1+r_even+l_odd
        ans[i+1] = 1+r_odd+l_even

        lr_idx = i+2
print(' '.join(map(str, ans)))


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

#define N 200010
#define MAX 1000000000000000000

#include <stdio.h>

int main (void) {
    int x, i;

    for (i = 0; i < 5; i++) {
        scanf("%d", &x);
        if (x == 0) {
            printf("%d", i+1);
        }
    }

    return 0;
}



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

namespace AtCoder_20190707_1
{
    class Program
    {
        static void Main(string[] args)
        {             
            Console.WriteLine(3 * Math.Pow(int.Parse(Console.ReadLine()),2));
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
using namespace std;
typedef unsigned long long ll;
const int maxn=1e5+50;
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int HASH=131;

int a[maxn];
int num[maxn];
int main()
{
    char s[maxn];
    cin>>s;
    int len=strlen(s);
    int ans=0;
    int tmp=0;
    for(int i=0;i<len;i++)
    {
        if(s[i]=='S') {ans=max(ans,tmp);tmp=0;continue;}
        tmp++;
    }
    if(tmp>0) ans=max(ans,tmp);
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;
const int N = 1e5 + 3;
vector<int> occ[26];
char s[N], t[N];
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
#endif
	scanf("%s %s", s, t);
	for (int i = 0; s[i]; ++i)
		occ[s[i] - 'a'].push_back(i + 1);
	int cycles = 0, idx = 0;
	for (int i = 0; t[i]; ++i) {
		if (occ[t[i] - 'a'].empty()) {
			cycles = 0;
			idx = -1;
			break;
		}
		auto it = upper_bound(occ[t[i] - 'a'].begin(), occ[t[i] - 'a'].end(), idx);
		if (it == occ[t[i] - 'a'].end()) {
			idx = *occ[t[i] - 'a'].begin();
			++cycles;
		} else {
			idx = *it;
		}
	}
	printf("%lld\n", 1LL * cycles * strlen(s) + idx);
	return 0;
}


Measured memory_bytes: 1024
/**
 *    author:  tourist
 *    created: 22.10.2017 08:47:46       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  int ans = 1;
  int sub = 1;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    if (a % 2 == 0) {
      sub *= 2;
    }
    ans *= 3;
  }
  cout << ans - sub << endl;
  return 0;
}


Measured memory_bytes: 256
/*! if g++ -g alds_1_5_d.cpp -o alds_1_5_d.out; then ./alds_1_5_d.out < alds_1_5_d.test; fi
 */

#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iterator>
#include <numeric>
#include <functional>
#include <climits>



using namespace std;
typedef unsigned long long ull;
typedef long long ll;

vector<int> a, b;
ull cross=0;

void print(){
  int n = a.size();
  for (size_t i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}

void sort(int l, int r){
  int c = (l+r)/2;
  if(r > l + 1){
    sort(l, c);
    sort(c, r);
  }
  int li = l, ri = c, bi = l;
  while(li < c && ri < r){
    if(a[li] <= a[ri]){
      b[bi++] = a[li++];
    } else{
      b[bi++] = a[ri++];
      cross += c-li;
    }
  }
  while(li < c)b[bi++] = a[li++];
  while(ri < r)b[bi++] = a[ri++];
  for (int i = l; i < r; i++) {
    a[i] = b[i];
  }
}

int main(int argc, char *argv[]){
  size_t n;
  cin >> n;
  a.resize(n);
  b.resize(n);
  for (size_t i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(0, n);
  cout << cross << endl;
  // for (size_t i = 0; i < n-1; i++) {
  //   cout << a[i] << " ";
  // }
  // cout << a.back() << endl;
  return 0;
}

Measured memory_bytes: 2592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int k = sc.nextInt();
        long t = 7;
        int i = 1;
        for ( ; i <= k; i++) {
            t = t % k;
            if (t == 0) {
                System.out.println(i);
                return;
            } else {
                t = t * 10 + 7;
            }
        }

        System.out.println(-1);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32776
#include <string>
#include <algorithm>
#include <iostream>
#define rep(i,n) for(int i = 0; i< (n); i++)
using namespace std;
using ll = long long;

bool kaibun(string s) {
    if(s.length()==1) return true;
    string ss = s;
    reverse(s.begin(),s.end());
    if(s==ss) return true;
    else return false;
}

int main(void) {
    string S; cin >> S;
    string s1 = S.substr(0,S.length()/2);
    string s2 = S.substr(S.length()/2+1,S.length()/2);
    if(kaibun(S) && kaibun(s1) && kaibun(s2)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
  string S;
  cin >> S;
  bool a=false;
  for(int i=0;i<S.size();i++){
    if(i%2==0 && S.at(i)=='L'){
      a=true;
      break;
    }
    if(i%2==1 && S.at(i)=='R'){
      a=true;
      break;
    }
  }
  if(a){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}
      
      

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    int x, t;
    cin >> x >> t;

    cout << max(x - t, 0) << endl;

    return 0;
}

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

int main( void ) {

	int n, i;
	double x1, y1, x2, y2, x3, y3, a1, a2, b1, b2, c1, c2, x, y, r;

	scanf( "%d", &n );

	for ( i = 0; i < n; i++ ) {

		scanf( "%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3 );

		a1 = 2*(x2-x1);
		a2 = 2*(x3-x1);
		b1 = 2*(y2-y1);
		b2 = 2*(y3-y1);
		c1 = x1*x1 - x2*x2 + y1*y1 - y2*y2;
		c2 = x1*x1 - x3*x3 + y1*y1 - y3*y3;
		x = (b1*c2 - b2*c1) / (a1*b2 - a2*b1);
		y = (c1*a2 - c2*a1) / (a1*b2 - a2*b1);
		r = sqrt((x1-x)*(x1-x) + (y1-y)*(y1-y));

		printf( "%.3lf %.3lf %.3lf\n", x + 0.0, y + 0.0, r );

	}

	return 0;

}

Measured memory_bytes: 664
N, X, M = map(int, input().split())

existence = [False] * M
a = []
A = X
for i in range(N):
    if existence[A]:
        break
    existence[A] = True
    a.append(A)
    A = A * A % M

for i in range(len(a)):
    if a[i] == A:
        loop_start = i
        break
else:
    loop_start = len(a)

result = sum(a[:loop_start])
N -= loop_start
if N != 0:
    a = a[loop_start:]
    loops = N // len(a)
    remainder = N % len(a)
    result += sum(a) * loops + sum(a[:remainder])
print(result)


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

int main(void){
  int sx, sy, tx, ty;

  cin >> sx >> sy >> tx >> ty;

  int height = abs(sy-ty), width = abs(sx-tx);

  for(int i = 0; i < height; i ++)
    cout << "U" ;
  for(int i = 0; i < width; i ++)
    cout << "R" ;
  for(int i = 0; i < height; i ++)
    cout << "D" ;
  for(int i = 0; i <= width; i ++)
    cout << "L" ;
  for(int i = 0; i <= height; i ++)
    cout << "U" ;
  for(int i = 0; i <= width; i ++)
    cout << "R" ;
  
  cout << "D" ;
  cout << "R" ;

  for(int i = 0; i <= height; i ++)
    cout << "D" ;
  for(int i = 0; i <= width; i ++)
    cout << "L";

  cout << "U" << endl;

  return 0;
}

Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));
$str = trim(fgets(STDIN));

$maxSize = 0;
for($i = 0; $i < $n; $i++){
    $map1 = $map2 = [];
    for($j = 0; $j < $n; $j++){
        if($i < $j){
            $map1[$str[$j]] = true;
        }else{
            $map2[$str[$j]] = true;
        }
    }
    $size = count(array_intersect(array_keys($map1), array_keys($map2)));
    $maxSize = max($size, $maxSize);
}
echo $maxSize;

Measured memory_bytes: 4728
#include<iostream>
#include<algorithm>
#include<cstring>
#define INF 9999999
using namespace std;
int h, w;
char block[100][100];
int dp[100][100];
int solve(int x, int y);
int main(){
  cin >> h >> w;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> block[i][j];
    }
  }
  memset(dp, -1, sizeof(dp));
  cout << solve(0, 0) << endl;
}

int solve(int x, int y){
  if(x == w - 1 && y == h - 1) return block[y][x] - '0';
  if(x < 0 || x >= w || y < 0 || y >= h) return INF;
  if(dp[y][x] != -1) return dp[y][x];
  return dp[y][x] = min(solve(x + 1, y) + block[y][x] - '0', solve(x, y + 1) + block[y][x] - '0');
}

Measured memory_bytes: 1220
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    string s;
    string t;
    cin >> s >> t;
    int len_s = (int)s.size();
    int len_t = (int)t.size();
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

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

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

constexpr long long mod = 1000000007;

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

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

    long long n;
    cin >> n;
    vll a(n+1, 0);

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

    for (int i = 1; i <= n; i++){
        cout << a[i] << endl;
    }
}

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

int main(){
  long long k,a,b,ans=0;
  cin >> k >> a >> b;
  if(a+1>=b){
    cout << k+1; return 0;
  }
  k-=a-1;
  ans+=k%2;
  ans+=(k/2)*b-((k/2)-1)*a;
  cout << ans;
}

Measured memory_bytes: 256
import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
import time
# import itertools

mod = int(1e9+7)
INF = 1<<29

def main():
    n,k = map(int,input().split())
    if (n + 1) // 2 >= k:
        print("YES")
    else:
        print("NO")
    return

if __name__=='__main__':
    main()

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

int a[100000], b[100000];
int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d%d", &a[i], &b[i]);
	for (int i = n; i >= 0; i--) {
		int cnt = 0;
		for (int j = 0; j < n&&cnt < i; j++) {
			if (a[j] - 1 <= i&&i < b[j])cnt++;
		}
		if (cnt == i) {
			printf("%d\n", i);
			return 0;
		}
	}
	puts("0");
}

Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  int A[N][N], B[M][M];
  char c;
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      cin >> c;
      if (c=='.') A[i][j]=0;
      if (c=='#') A[i][j]=1;
    }
  }
  for (int i = 0; i < M; i++){
    for (int j = 0; j < M; j++){
      cin >> c;
      if (c=='.') B[i][j]=0;
      if (c=='#') B[i][j]=1;
    }
  }
  bool res = false;
  for (int i = 0; i <= N-M; i++){
    for (int j = 0; j <= N-M; j++){
      bool check = true;
      for (int k = 0; k < M; k++){
        for (int l = 0; l < M; l++){
          if (A[i+k][j+l] != B[k][l]) check = false;
        }
      }
      if (check) res = true;
    }
  }
  if (res){
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int n;
  int i=0;
  int a;
  int min=1000000;
  int max=-1000000;
  long long int sum=0;

  scanf("%d", &n);

  for(i=0;i<n;i++){
    scanf("%d",&a);
    if(min>a) min=a;
    if(max<a) max=a;
    sum=sum+a;
  }

  printf("%d %d %lld\n", min, max, sum);
  return 0;
}


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

int main()
{
  double n,d,ans;
  ans=0;
  cin>>n>>d;
  vector<double> x(n);
  vector<double> y(n);
  vector<double> z(n);
  for(int i=0;i<n;i++)
  {
    cin>>x.at(i)>>y.at(i);
  }
  for(int i=0;i<n;i++)
  {
    z.at(i)=sqrt(x.at(i)*x.at(i)+y.at(i)*y.at(i));
    if(z.at(i)<=d)
    {
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 8060
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
//#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define reps(i, j, k) for(auto i = j; i < k; ++i)
#define rep(i, j) reps(i, 0, j)
#define decs(i, j, k) for(auto i = j; i >= k; --i)
#define dec(i, j) decs(i, j, 0)
#define iter(i, j) for(auto i = j.begin(); i != j.end(); ++i)
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int, int>
#define vpi vector<pi>
#define vb vector<bool>
#define F first
#define S second
#define mp make_pair
#define um unordered_map
#define all(x) (x).begin(), (x).end()  
#define fast_io ios::sync_with_stdio(0); cin.tie(0);
#define file_io freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define IMAX std::numeric_limits<int>::max()
#define IMIN std::numeric_limits<int>::min()
using namespace std;

int main()
{
    //fast_io
    //file_io
	ll n, a, b; cin >> n >> a >> b;
	ll d = floor(ld(n) / ld(a + b));
	cout << a * d + min(a, n - (a + b) * d);
}


Measured memory_bytes: 512
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 10e16;
int inf = 10e8;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

template<typename T>
void dump_2d_mat(T &m, int N, int M) {
    REP(i, N) {
        REP(j, M) {
            cout << m[i][j] << " ";
        }
        cout << endl;
    }
}

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

    int P[N];
    REP (i, N) cin >> P[i];

    int M[N];

    M[0] = P[0];
    REP(i, N-1) {
        M[i+1] = min(M[i], P[i+1]);
    }

    int res = 0;
    REP(i, N) {
        if (P[i] <= M[i]) ++res;
    }
    
    cout << fixed << setprecision(20);
    cout << res << endl;

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

/*
    i番目の人が押してからi+1番目の人が押すまでにお湯は
        min(T,t[i+1]-t[i])(秒)
    流れるので、t[N+1]=INFとすれば、答えは
        Σmin(T,t[i+1]-t[i]) (1<=i<=N)
    で求まる.
*/

signed main()
{
    int N,T; cin>>N>>T;
    vint t(N+1);
    REP(i,N) cin>>t[i];
    t[N]=1e18;

    int ans=0;
    REP(i,N) ans+=min(T,t[i+1]-t[i]);
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    ll N, A, ans=1e15;
    in(N);
    rep(i,N){
        in(A);
        if(A%2){  //奇数だった。
            puts("0");
            return 0;
        }
        ll tmp=A, cnt=0;
        while(!(tmp%2)){//偶数の時続ける
            tmp /= 2;
            cnt++;
        }
        chmin(ans, cnt);
    }
    put(ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>

using namespace std;


int n;
int cursor;
vector<string> s;

int calc(int mode, int depth) {
        int sum = mode == 1 ? 0 : 1;

        while (cursor < n && depth == s[cursor].size() - 1){
                string str = s[cursor];
                int points = str.size() - 1;
                char a = str[points];
                int num = a - '0';
                if (mode == 1){
                        if (a == '+') {
                                cursor++;
                                sum += calc(1, depth + 1);
                        }
                        else if (a == '*') {
                                cursor++;
                                sum += calc(2, depth + 1);
                        }
                        else{
                                cursor++;
                                sum += num;
                        }
                }
                if (mode == 2){
                        if (a == '+') {
                                cursor++;
                                sum *= calc(1, depth + 1);
                        }
                        else if (a == '*') {
                                cursor++;
                                sum *= calc(2, depth + 1);
                        }
                        else{
                                cursor++;
                                sum *= num;
                        }
                }
        }
        return sum;
}

int main() {
        while (cin >> n, n != 0) {
                s = vector<string>(n);
                for (int i = 0; i < n; i++){
                        cin >> s[i];
                }
                cursor = 0;
                int sum = calc(1, 0);
                cout << sum << endl;
        }
        return 0;
}

Measured memory_bytes: 3152
def gcd(p, q):
  a, b = (p, q) if p >= q else (q, p)
  c = a % b
  while c != 0:
    a, b = (b, c) if b >= c else (c, b)
    c = a % b
  return  b

N, X = [int(x) for x in input().split()]
xn = sorted([int(x) for x in input().split()])

diffs = []

if X < xn[0]:
  diffs.append(xn[0] -X)
for n in range(N-1):
  if xn[n] < X < xn[n+1]:
    diffs.append(X - xn[n])
    diffs.append(xn[n+1] - X)
  else:
    diffs.append(xn[n+1] - xn[n])
if X > xn[N-1]:
  diffs.append(X - xn[N-1])
if len(diffs) > 1:
  D = gcd(diffs[0], diffs[1])
  for i in range(N-2):
    D = gcd(D, diffs[i+2])
else:
  D = diffs[0]
print(D)
  

Measured memory_bytes: 14100
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;

int main(void){
  int n;
  double dp[100001]={0},p,w;
  
  dp[1]=1.0;

  for(int i=2;i<100001;i++){
    p=1.0;
    w=0.5;
    for(int j=1; j<i && 0.00000000001<p; j++){
      dp[i]+=p*(1-w)*(j+dp[max(0,i-j-1)]);
      p*=w;
      w/=2;
    }
    dp[i]+=i*p;
  }

  while(cin >> n,n)
    printf("%.8f\n",dp[n]);

  return 0;
}

Measured memory_bytes: 1976
#include <cstdio>
#include <algorithm>
using namespace std;
const int NIL = -1;

struct node {
	int parent;
	int left;
	int right;
};

node nodes[100000];

void preorder(int v) {
	if (v == NIL) return;
	printf(" %d", v);
	preorder(nodes[v].left);
	preorder(nodes[v].right);
}

void inorder(int v) {
	if (v == NIL) return;
	inorder(nodes[v].left);
	printf(" %d", v);
	inorder(nodes[v].right);
}

void postorder(int v) {
	if (v == NIL) return;
	postorder(nodes[v].left);
	postorder(nodes[v].right);
	printf(" %d", v);
}

int main()
{
	int n;
	for (int i = 0; i < 100000; ++i) {
		node &p = nodes[i];
		p.parent = NIL;
		p.left = NIL;
		p.right = NIL;
	}
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int v, l, r;
		scanf("%d %d %d", &v, &l, &r);
		node &p = nodes[v];
		p.left = l;
		p.right = r;
		if (l != NIL) nodes[l].parent = v;
		if (r != NIL) nodes[r].parent = v;
	}

	int r = NIL;
	for (int i = 0; i < n; ++i) {
		if (nodes[i].parent == NIL) {
			r = i;
			break;
		}
	}
	printf("Preorder\n");
	preorder(r);
	printf("\nInorder\n");
	inorder(r);
	printf("\nPostorder\n");
	postorder(r);
	printf("\n");

	return 0;
}

Measured memory_bytes: 2216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    
    string s;
    cin>>s;
    int sum=0;
    for(int i=0;i<s.size();i++)sum+=(s[i]-'0');
    if(sum%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3780
#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 a, b, c;
  cin >> a >> b >> c;
  string ans = "No";
  if (a == b && a != c) ans = "Yes";
  if (a == c && a != b) ans = "Yes";
  if (c == b && a != c) ans = "Yes";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    long long S;
    cin >> S;
    long long MAX = 1e9;
    long long X1 = 0, Y1 = 0, X2 = MAX, Y2 = 1, X3, Y3;
    X3 = (MAX - S % MAX) % MAX;
    Y3 = (S + X3) / MAX;
    printf("%lld %lld %lld %lld %lld %lld\n", X1, Y1, X2, Y2, X3, Y3);
}

Measured memory_bytes: 3728