akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>
#include <cctype>
#include <ctype.h>

#define INF 200000000
#define MOD 1000000007

using namespace std;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0, ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'I')
        {
            cnt++;
        }
        else if (s[i] == 'D')
        {
            cnt--;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n,a,b,c,d=map(x->parse(Int,x),split(readline()))
for i=0:n-1
	L=-d*i+c*(n-1-i)
	R=-c*i+d*(n-1-i)
	if L<=a-b<=R
		println("YES")
		exit()
	end
end
println("NO")


Measured memory_bytes: 168944
#include<iostream>

using namespace std;

long long int n;
long long int a[100005], b[100005];


long long int dp(long long int m, bool l){
  long long int s[100005][2];
  s[0][0] = 0;
  s[0][1] = -1000000002;
  for(int i = 0; i < m; ++i){
    s[i + 1][0] = max(s[i][0] + a[i], s[i][1] - a[i]);
    s[i + 1][1] = max(s[i][0] - a[i], s[i][1] + a[i]);
  }
  return s[m][0];
  //return a[m];
}

int main(){
  cin >> n;
  for(int i = 0; i < n; ++i){
    cin >> a[i];
  }
  cout << dp(n, 0) << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#define SIZE 30
using std::vector;
using namespace std;


int main() {
    std::cin.tie(0);std::ios::sync_with_stdio(false);
	int n,m;
	cin >>n>>m ;
	int a,b;
	int city[51] = {};
	for(int i=0;i<m;++i){
		cin >> a >> b;
		city[a]++;
		city[b]++;
	}
	for(int i=1;i<=n;++i){
		cout << city[i] << endl;
	}
return 0;

}

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

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))
#define MOD 1000000007

using namespace std;

using ll = long long;
const ll MAX = LLONG_MAX;
const ll MIN = LLONG_MIN;

typedef stack<ll> llStack;
typedef queue<ll> llQueue;
typedef vector<ll> llVector;
typedef list<ll> llList;

typedef struct S{
  int a;
  int b;
} Object;

#define MAX_N 100000

int par[MAX_N];
void init(int n){
  for(int i=0;i<n;i++){
    par[i] = i;
  }
}
int root(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = root(par[x]);
  }
}
bool same(int x, int y){
  return root(x) == root(y);
}
void unite(int x, int y){
  x = root(x);
  y = root(y);
  if(x == y) return;
  par[x] = y;
}

int main(){
  ll N, M, K;
  cin >> N >> M >> K;
  ll A[M], B[M], C[K], D[K];
  for(int i=0;i<M;i++){
    cin >> A[i] >> B[i];
  }
  for(int i=0;i<K;i++){
    cin >> C[i] >> D[i];
  }
  
  init(N);
  for(int i=0;i<M;i++){
    unite(A[i]-1, B[i]-1);
  }
  ll countG[N];
  for(int i=0;i<N;i++){
    countG[i] = 0;
  }
  for(int i=0;i<N;i++){
    countG[root(i)]++;
  }
  ll countF[N];
  for(int i=0;i<N;i++){
    countF[i] = 0;
  }
  for(int i=0;i<M;i++){
    countF[A[i]-1]++;
    countF[B[i]-1]++;
  }
  ll countB[N];
  for(int i=0;i<N;i++){
    countB[i] = 0;
  }
  for(int i=0;i<K;i++){
    if(same(C[i]-1, D[i]-1)){
      countB[C[i]-1]++;
      countB[D[i]-1]++;
    }
  }
  
  ll ans;
  for(int i=0;i<N;i++){
    ans = countG[root(i)]-countF[i]-countB[i]-1;
    cout << ans << endl;
  }
}

Measured memory_bytes: 6656
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    v = f()
    c = f()
    a = 0
    for i in range(n):
        if v[i] - c[i]>0:
            a+= v[i] - c[i]
    print(a)

solve()


Measured memory_bytes: 3060
import java.util.Scanner;
 
class Main{
  public static void main(String[] arg){
    int H, W;

    Scanner in = new Scanner(System.in);

    while(true){
        H = in.nextInt();
        W = in.nextInt();

        if(H == 0 && W == 0) return;
        
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                System.out.print("#");
            }
            System.out.println();
        }
        System.out.println();
    }
    
  }
}

Measured memory_bytes: 34260
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;



int main()
{
	
	int n;
	cin >> n;
	while (n % 111 != 0){
		n++;
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[101][100005],wt[105],price[105],n,m;
ll op(ll pos,ll prv)
{
    if(pos==n)
        return 0;
    if(dp[pos][prv]!=0)
        return dp[pos][prv];
    ll z=op(pos+1,prv);
    if(prv+wt[pos]<=m){
        ll k=op(pos+1,prv+wt[pos])+price[pos];
        z=max(z,k);
    }
    return dp[pos][prv]=z;
}

int main()
{
    ll i,j,k,a,b,c,x,y,z;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        scanf("%lld%lld",&wt[i],&price[i]);
    }
    a=op(0,0);
    cout<<a<<endl;
}


Measured memory_bytes: 76416
#include "bits/stdc++.h"
using namespace std;
 
int main(void) {
	int h, w;
	cin >> h >> w;

	char a[h+2][w+2];
	
	for(int i=0;i<h+2;i++) {
		for(int j=0;j<w+2;j++) {
			a[i][j] = '#';
		}
	}

	for(int i=0;i<h;i++) {
		for(int j=0;j<w;j++) {
			cin >> a[i+1][j+1];
		}
	}

	for(int i=0;i<h+2;i++) {
		for(int j=0;j<w+2;j++) {
			cout << a[i][j];
		}
		cout << endl;
	}
}


Measured memory_bytes: 256
R = lambda: map(int, input().split())
R()
a = [0] * 100001
s = 0
for x in R():
  s += x
  a[x] += 1
q, = R()
for _ in range(q):
  b, c = R()
  s += (c - b) * a[b]
  print(s)
  a[c]+=a[b]
  a[b] = 0


Measured memory_bytes: 17824
#include<iostream>
#include<numeric>

using namespace std;

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

int main(){

    int n, s1, s2, min;

    cin >> n;

    int w[n], abs[n -1];

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

        cin >> w[i];
    }

    for(int i = 0;i < n - 1;i++){

        s1 = accumulate(w, w + i + 1, 0);
        s2 = accumulate(w + i + 1, w + SIZE_OF_ARRAY(w), 0);

        abs[i] = (s1 > s2)? s1 - s2:s2 - s1;

        if(i == 0){

            min = abs[i];
        }
        else if(min > abs[i]){

            min = abs[i];
        }
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, C, K;
  cin >> N >> C >> K;
  vector<int> T(N);
  for (int i = 0; i < N; i++){
    cin >> T[i];
  }
  sort(T.begin(), T.end());
  vector<long long> T2(N * 2);
  for (int i = 0; i < N; i++){
    T2[i * 2] = T[i];
    T2[i * 2 + 1] = T[i] + K;
  }
  sort(T2.begin(), T2.end());
  int ans = 0;
  int cnt = 0;
  queue<int> Q;
  for (int i = 0; i < N * 2; i++){
    if (cnt < N){
      while (T[cnt] == T2[i]){
        Q.push(T[cnt]);
        cnt++;
        if (cnt < N){
          break;
        }
      }
    }
    if (!Q.empty()){
      if (Q.front() + K == T2[i]){
        while (Q.front() + K == T2[i]){
          vector<int> bus;
          while (!Q.empty()){
            bus.push_back(Q.front());
            Q.pop();
            if (bus.size() == C){
              break;
            }
          }
          ans++;
          if (Q.empty()){
            break;
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=2e5;
const int INF=1e9;
int main(){
	int N;cin>>N;int ans=0;
	rep(i,1,N+1){
		int temp=i;int count=0;
		while(temp!=0){
			temp/=10;
			count++;
		}if(count%2==1) ans++;
	}cout<<ans<<endl;
}

Measured memory_bytes: 256
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
 
 
 
def main():
    n, p = map(int, input().split())
    l = factorize(p)
    ans = 1
    for ll in l:
        if ll[1] >= n:
            ans *= ll[0]**(ll[1]//n)
    print(ans)
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 38512
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll x, y, ans;

    cin >> x >> y;

    ans = abs(abs(x)-abs(y));

    if(x>0 && y>0 && x>y) ans += 2;

    if(x<0 && y<0 && x>y) ans += 2;

    if(x*y<0) ans += 1;

    if(x>0&&y==0 || x==0&&y<0) ans += 1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 2000
int main()
{
    int q[N],i,j,k,a,temp;
    int n,sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&q[i]);
    }
    for(i=0;i<n-1;i++)
      {
          k=i;
          for(j=i+1;j<n;j++)
          {
              if(q[j]<q[k])
                k=j;
          }
          if(k!=i)
          {
              temp=q[k];
              q[k]=q[i];
              q[i]=temp;
          }
      }
      for(i=0;i<n-2;i++)
      {
         for(j=i+1;j<n-1;j++)
            for(a=j+1;a<n;a++)
         if(q[i]+q[j]>q[a])
          sum++;
      }
      printf("%d",sum);

}


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

N, M = map(int, input().split())
sw = [[int(_)-1 for _ in input().split()] for i in range(M)]
p = [int(_) for _ in input().split()]

def rec(n, onoff, lmp):
    if n < N:
        onoff[n] = True
        s = rec(n+1, onoff, lmp)
        onoff[n] = False
        s += rec(n+1, onoff, lmp)
        return s
    else:
        sm = 0
        for i in range(M):
            r = 0
            for j in sw[i][1:]:
                if onoff[j]:
                    r+=1
            if r % 2 == lmp[i]:
                sm += 1
        if sm == M:
            return 1
        else:
            return 0

onoff = [False for _ in range(N)]
print(rec(0, onoff, p))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<unordered_map>	
#include<unordered_set>
#define pb emplace_back
#define rt(v) return cout<<v,0
#define sz(v) (int)(v.size())
#define all(a) a.begin(),a.end()
#define endl '\n'
#define space " "
typedef long long ll;
typedef unsigned long long ull;
const int N = 10 + 1e5;
const int mod = 1e9 + 7;
/*

███╗   ███╗███████╗███╗   ███╗███████╗    ██╗      ██████╗ ██████╗ ██████╗
████╗ ████║██╔════╝████╗ ████║██╔════╝    ██║     ██╔═══██╗██╔══██╗██╔══██╗
██╔████╔██║█████╗  ██╔████╔██║█████╗      ██║     ██║   ██║██████╔╝██║  ██║
██║╚██╔╝██║██╔══╝  ██║╚██╔╝██║██╔══╝      ██║     ██║   ██║██╔══██╗██║  ██║
██║ ╚═╝ ██║███████╗██║ ╚═╝ ██║███████╗    ███████╗╚██████╔╝██║  ██║██████╔╝
╚═╝     ╚═╝╚══════╝╚═╝     ╚═╝╚══════╝    ╚══════╝ ╚═════╝ ╚═╝  ╚═╝╚═════╝

*/

using namespace std;
void Ferrari() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
char img[55][55];
char temp[55][55];
char ans[55][55];
int n, m;
bool check() {
	bool ok = 1;
	for(int i = 0 ; i < m; ++i)
		for(int j = 0 ; j < m ; ++j)
			if (ans[i][j] != temp[i][j])
			{
				ok = 0; break;
			}
	return ok;
}
int main() {
	Ferrari();
	long long a, b, x; cin >> a >> b >> x;
	long long len = b - a;
	long long ans = len / x;
	long long rem = len % x;
	long long firstm = ((a + (x - 1)) / x) * x;
	//else firstm = ((a + (x - 1)) / x) * x;
	if (firstm - a <= rem) ++ans;
	cout << ans;
	return 0;
}





/* stuff you should look for
	* keepin sharp mind.
	* int overflow, array bounds.
	* special cases (n=1?), set tle , make sure you understand the proble correctly.
	* don`t stuck in a problem.
	* test the idea on samples.
	*/

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

template<class T>
void chmin(T &a, T b) {
    a = (a > b ? b : a);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, 0, N) {
        cin >> A[i];
    }
    const ll inf = 1LL << 60;
    auto dp = make_v(N, N, inf);
    REP(i, 0, N) {
        dp[i][i] = 0;
    }
    vector<ll> S(N + 1, 0);
    REP(i, 0, N) {
        S[i + 1] += S[i] + A[i];
    }

    REP(k, 1, N) {
        REP(i, 0, N - k) {
            REP(j, i, i + k) {
                chmin(dp[i][i + k], dp[i][j] + dp[j + 1][i + k] + S[i + k + 1] - S[i]);
            }
        }
    }

    cout << dp[0][N - 1] << endl;

    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){

	int N;
	std::vector<int> si;

	cin >> N;
	int sum = 0;
	for(int i=0; i<N; i++){
		int temp;
		cin >> temp;
		si.push_back(temp);
		sum += temp;
	}

	if(sum%10 != 0){
		cout << sum << endl;
	}else{
		bool f=true;
		for(int s:si){
			if(f && s%10 == 0){
				f=true;
			}else{
				f=false;
				break;
			}
		}
		if(f){
			puts("0");
		}else{
			sort(si.begin(),si.end());
			int min = 0;
			for(int s:si){
				if(s%10!=0){
					min = s;
					break;
				}
			}
			cout << sum-min << endl;
		}
	}

	

return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    if(N==1){
        cout<<1<<endl;
        return 0;
    }
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    int ans=1;
    int flag=(A[0]<=A[1])+(A[0]==A[1]);
    rep(i,1,N-1){
        if(flag==1&&A[i]>A[i+1]){
            ans++;
            i++;
            if(i<N-1) flag=(A[i]<=A[i+1])+(A[i]==A[i+1]);
            continue;
        }
        if(flag==0&&A[i]<A[i+1]){
            ans++;
            i++;
            if(i<N-1) flag=(A[i]<=A[i+1])+(A[i]==A[i+1]);
            continue;
        }
        if(flag==2){
            if(A[i]<A[i+1]) flag=1;
            if(A[i]>A[i+1]) flag=0;
            continue;
        }
    }
    cout<<ans<<endl;
}


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

int main(){
    
    while(true){
        int a, b;
        cin >> a >> b;
        if(a==0&&b==0){
            break;
        }else{
            cout << min(a, b) << " " << max(a, b) << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define int long long
char pi[3001][3001];
int dp[3001][3001];
string s1,s2;

signed main() {
	cin>>s1>>s2;
	int n1=s1.size(),n2=s2.size();
	for(int i=0;i<=n1;i++)
		for(int j=0;j<=n2;j++){
			if(i==0 or j==0) 
				dp[i][j]=0;
			else if(s1[i-1]==s2[j-1]) {
				dp[i][j]=dp[i-1][j-1]+1;
				pi[i][j]='d';
			}
			else if(dp[i][j-1]>=dp[i-1][j]){
				dp[i][j]=dp[i][j-1];
				pi[i][j]='l';
				}
			else{
				dp[i][j]=dp[i-1][j];
				pi[i][j]='u';
				}
			}
	int i=n1,j=n2;stack<char> st;
	while(i>0 and j>0){
		if(pi[i][j]=='d'){
			st.push(s1[i-1]);
			i--;j--;
		}
		else if(pi[i][j]=='l') j--;
		else if(pi[i][j]=='u') i--;
		
	}
	int l=st.size();
	for(int i=0;i<l;i++) {
		cout<<st.top();
		st.pop();
	}
	return 0;
}

Measured memory_bytes: 79360
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from collections import deque
from decimal import *
import queue

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()
	C = inputStr()

	aida = []
	anzen = 0
	ai = 0
	yokei = 0
	flg = False
	for i,val in enumerate(C):
		ai += 1
		if val == "W":
			if flg == False:
				flg = True
		elif val == "R":
			anzen += 1
			if flg == False:
				aida.append(ai)
			else:
				yokei += 1
				aida.append(ai)

	if yokei == 0:
		print(0)
		sys.exit()

	ans = 0
	for i,val in enumerate(aida):
		if val <= anzen:
			continue
		ans += 1

	print(ans)
	#print(aida)
	#print(yokei)


#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 91772
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    a, b, c = map(int, readline().split())
    if (a*b*c)%2 == 0:
        print(0)
    else:
        #すべて奇数
        print(min((a*b, b*c, c*a)))
if __name__ == '__main__':
    main()


Measured memory_bytes: 9028
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = [input().split() for _ in range(N)]

ans = 0
for num, s in A:
    if s == 'JPY':
        ans += int(num)
    else:
        ans += 380000.0 * float(num)

print(ans)
 




Measured memory_bytes: 9200
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i  =0 ; i < N; i++) cin >> H[i];
    int m = 0;
    int cnt = 1;
    for(int i = 0; i < N; i++){
        if(i == 0) m = max(m, H[i]);
        else{
            if(H[i] >= m) cnt++;
            m = max(H[i], m);
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;
typedef long long ll;

int main(){
  int n, a[1001];

  cin>>n;
  for(int i=0; i<n; i++){
    cin>>a[i];
  }
  for(int j=n-1; j>=0; j--){
    if(j==0)cout<<a[j];
    else cout<<a[j]<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 3100
N = int(input())
S = list(input())
65 - 90
A = []
for i in range (65, 91):
  A.append(chr(i))
A *= 2
for j in range (len(S)):
  k = A.index(S[j])
  S[j] = A[k+N]
L = ''
for m in S:
  L += m
print(L)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main () {
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    
    if( 2*C > A+B) {
        cout << A * X + B * Y;
    } else {
        int long_num = max (X, Y);
        int shrt_num = min (X, Y);
        if (X > Y) cout << min ( long_num * C * 2, shrt_num * 2 * C + (long_num - shrt_num) * A); 
        if (Y > X) cout << min ( long_num * C * 2, shrt_num * 2 * C + (long_num - shrt_num) * B);
        if (Y == X) cout << long_num * C * 2;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;


// <<fixed<<setprecision(6)<<


int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

bool isPrime(int x){
  int i;
  if(x < 2)return 0;
  else if(x == 2) return 1;
  if(x%2 == 0) return 0;
  for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
  return 1;
}

int binary(vector<int> a,lint key) {
  lint left = 0;
  lint right = a.size();
  while(left<right){
    lint mid = (left+right)/2;
    if(a[mid] == key){
      return 1;
    }
    else if(key<a[mid]){
      right = mid;
    }
    else{
      left = mid+1;
    }
  }
  return 0;
}


int main(){
  int a,b;
  cin>>a>>b;
  cout<<(a+b)/2<<endl;

}


Measured memory_bytes: 3092
#include<iostream>
#include<string>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)

int main(void) {
	int a[] = { 0,1,3,1,2,1,2,1,1,2,1,2,1 };
	int x, y; cin >> x >> y;
	cout << (a[x] == a[y] ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> H = new ArrayList<Integer>();
        ArrayList<Integer> W = new ArrayList<Integer>();
        int tempH, tempW;

        while (true) {
            tempH = sc.nextInt();
            tempW = sc.nextInt();
            if (tempH == 0 && tempW == 0)
                break;

            H.add(tempH);
            W.add(tempW);
        }

        for (int k = 0; k < H.size(); k++) {
            for (int i = 0; i < H.get(k); i++) {
                for (int j = 0; j < W.get(k); j++) {
                    if ((i + j) % 2 == 0)
                        System.out.print("#");
                    else
                        System.out.print(".");
                }
                System.out.println();
            }
            System.out.println();
        }

        sc.close();
    }
}


Measured memory_bytes: 35212
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int A = scan.nextInt() , B = scan.nextInt();
        int p1 = 0 , p2 = 0 , p3 = 0;
        for(int i = 0 ; i < n ; ++i){
            int tmp = scan.nextInt();
            if(tmp > B)p3++;
            else if(tmp > A)p2++;
            else p1++;
        }
        System.out.println(Math.min(p3,Math.min(p2,p1)));
    }
}


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

using namespace std;

int main(){
	int t,n;
	cin >> n;
	cin >> t;
	vector <pair<int,int> >  costos;
	int x,y;
	for (int i = 0; i < n; ++i){
		cin >> x>> y;
		costos.push_back({x,y});
	}
	sort(costos.begin(),costos.end());
	
	int i = 0;
	while(i < n){
		if(costos[i].second <= t) break;
		i++;
	}
	if(i == n) cout << "TLE" << endl;
	else{
		cout << costos[i].first << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
struct node{
	int l,r;
	bool f[30];
	node*lt,*rt;
};
int ans[30],q,n;
char str[550000];
int max(int a,int b) {
	return a>b?a:b;
}
void build(node *p,int l,int r) {
	p->l=l;
	p->r=r;
	p->lt=NULL;
	p->rt=NULL;
	int mid=(l+r)>>1;
	if (l==r) {
		p->f[str[l-1]-'a'+1]=1;
		return;
	}
	if (l<=mid) {
		p->lt=new node();
		build(p->lt,l,mid);
		for (int i=1;i<=26;++i) p->f[i]=max(p->lt->f[i],p->f[i]);
	} 
	if (mid+1<=r) {
		p->rt=new node();
		build(p->rt,mid+1,r);
		for (int i=1;i<=26;++i) p->f[i]=max(p->f[i],p->rt->f[i]);
	}
}
void change(node *p,int x,char ch) {
	if (p->l==p->r) {
		memset(p->f,0,sizeof p->f);
		p->f[ch-'a'+1]=1;
		return;
	}
	int mid=(p->l+p->r)>>1;
	if (x<=mid) change(p->lt,x,ch);
	if (x>mid) change(p->rt,x,ch);
	memset(p->f,0,sizeof p->f);
	for (int i=1;i<=26;++i) p->f[i]=max(p->lt->f[i],p->f[i]);
	for (int i=1;i<=26;++i) p->f[i]=max(p->f[i],p->rt->f[i]);
}
void check(node *p,int l,int r) {
	if (p->l>=l&&p->r<=r) {
		for (int i=1;i<=26;++i) ans[i]=max(p->f[i],ans[i]);
		return;
	}
	int mid=(p->l+p->r)>>1;
	if (l<=mid) check(p->lt,l,r);
	if (mid<r) check(p->rt,l,r);
}
int main() {
	scanf("%d",&n);
	scanf("%s",&str);
	node *root=new node();
	build(root,1,n);
	scanf("%d",&q);
	for (int i=1;i<=q;++i) {
		int t,p,l,r,b=0;
		char ch;
		memset(ans,0,sizeof ans);
		scanf("%d",&t); 
		if (t==1) {
			scanf("%d %c",&p,&ch);
			change(root,p,ch);
		} else {
			scanf("%d%d",&l,&r);
			check(root,l,r);
			for (int j=1;j<=26;++j) b+=ans[j];
			printf("%d\n",b);
		}
	}
	return 0;
} 

Measured memory_bytes: 63360
fun main(args : Array<String>) {
    val nums = readLine()!!.split(delimiters = " ").map { it.toInt() }.sorted()

    if (nums[0] % 2 == 0 && nums[1] % 2 == 0 && nums[2] % 2 == 0) {
        println((nums[2]-nums[0]+nums[2]-nums[1])/2)
        return
    }

    if (nums[0] % 2 == 1 && nums[1] % 2 == 1 && nums[2] % 2 == 1) {
        println((nums[2]-nums[0]+nums[2]-nums[1])/2)
        return
    }

    if (nums[0] % 2 == nums[1] % 2) {
        println((nums[2]-nums[1])/2 + (nums[2]-nums[0])/2 + 1)
    } else {
        println((nums[2]-nums[1])/2 + (nums[2]-nums[0])/2 + 2)
    }
}


Measured memory_bytes: 37872
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef vector<ll> Vl;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;


ll x, tmp;
ll cnt1, cnt2;

int main() {

	cin >> x;

	tmp = x % 500;

	cnt1 = x / 500;

	cnt2 = tmp / 5;

	cout << cnt1 * 1000 + cnt2 * 5 << endl;

	return 0;
}

Measured memory_bytes: 256
class Node():
    def __init__(self, node_id, left, right):
        self.node_id    =   node_id
        self.left       =   left
        self.right      =   right

    def pre_order_search(self):
        l = self.left
        r = self.right
        print("",self.node_id, end="")
        if l != -1:
            tree[l].pre_order_search()
        if r != -1:
            tree[r].pre_order_search()

    def in_order_search(self):
        l = self.left
        r = self.right
        if l != -1:
            tree[l].in_order_search()
        print("",self.node_id, end="")
        if r != -1:
            tree[r].in_order_search()

    def post_order_search(self):
        l = self.left
        r = self.right
        if l != -1:
            tree[l].post_order_search()
        if r != -1:
            tree[r].post_order_search()
        print("",self.node_id, end="")

n = int(input())
tree = [None for i in range(n)]
root_set = set(range(n))

for i in range(n):
    node_id, left, right = map(int, input().split())
    tree[node_id] = Node(node_id, left, right)
    root_set -= set([left, right])
root = root_set.pop()

print("Preorder")
tree[root].pre_order_search()
print("")

print("Inorder")
tree[root].in_order_search()
print("")

print("Postorder")
tree[root].post_order_search()
print("")

Measured memory_bytes: 7860
import sys
input=sys.stdin.readline


def main():
	#N,M=map(int,input().split())
	#S=input().rstrip()
	#vA=list(map(int,input().split()))
	vAB=[tuple(map(int,input().split()))
		 for _ in [0,]*3]
	N=int(input())
	vD= [int(input()) for _ in [0,]*N]
	
	vQ = [False,] * 9
	for i in range(3):
		a,b,c = vAB[i]
		vQ[3*i+0] = a in vD
		vQ[3*i+1] = b in vD
		vQ[3*i+2] = c in vD
	
	bi = False
	if any((all(vQ[0:3]), all(vQ[3:6]),
		all(vQ[6:9]), all(vQ[0::3]),
		all(vQ[1::3]), all(vQ[2::3]),
		all((vQ[0],vQ[4],vQ[8])),
		all((vQ[2],vQ[4],vQ[6])),
		)):
		bi = True
	
	res = "Yes" if bi else "No"
	print(res)
	
	
main()


Measured memory_bytes: 39820
#include <iostream>
#include <map>

using namespace std;

int main() {
  int n, a;
  long long res = 0;
  map<int, int> m;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    res += m[i - a];
    m[i + a]++;
  }
  cout << res << endl;
}

Measured memory_bytes: 20612
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
int n;
int a[5][100005];
bool good(int x){
	set<int>s; 
	for(int i=1;i<=3;i++){
		s.insert((a[i][x]-1)/3);
	}
	return s.size()==1;
}
bool get(int x){
	int cnt1=0,cnt2=0;
	for(int i=1;i<=3;i++){
		if(a[i][x]>a[2][x])cnt1++;
		if(a[i][x]<a[2][x])cnt2++;
	}
	if(cnt1!=1||cnt2!=1)return -1;
	return a[1][x]<a[2][x]?0:1;
}
int to[100005];
ll get_inv(vector<int>cur,vector<int>tar){
	for(int i=0;i<tar.size();i++)to[tar[i]]=i;
	for(auto &vv:cur)vv=to[vv];
	ll tot=0;
	for(int i=0;i<cur.size();i++){
		for(int j=i+1;j<cur.size();j++){
			if(cur[i]>cur[j])tot++;
		}
	}
	return tot;
}
int ind[100005],inv[100005];
int main(){
	cin>>n;
	for(int i=1;i<=3;i++){
		for(int j=1;j<=n;j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		if(!good(i)){
			puts("No");
			return 0;
		}
	}
	int Odd=0,Even=0;
	for(int i=1;i<=n;i++){
		ind[i]=(a[1][i]+2)/3;
		inv[i]=get(i);
		if(inv[i]){
			if(i&1)Odd++;
			else Even++;
		}
		if(inv[i]==-1){
			puts("No");
			return 0;
		}
	}
	vector<int>checker;
	for(int i=1;i<=n;i++){
		if(i&1)checker.push_back(ind[i]);
	}
	sort(checker.begin(),checker.end());
	for(int i=0;i<checker.size();i++){
		if(checker[i]!=i*2+1){
			puts("No");return 0;
		}
	}
	vector<int>cur[2],tar[2];
	for(int i=1;i<=n;i++){
		cur[i&1].push_back(i);
		tar[i&1].push_back(ind[i]);
	}
	ll odd=get_inv(cur[1],tar[1]);
	ll even=get_inv(cur[0],tar[0]);
	cerr<<"inverse: "<<odd<<" "<<even<<endl;
	cerr<<"reverse: "<<Odd<<" "<<Even<<endl;
	if(odd%2==Even%2&&Odd%2==even%2){
		puts("Yes");
	}else{
		puts("No");
	}
	return 0;
}

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

#define vint vector<int> 
#define vbool vector<bool>
#define vvint vector<vector<int>>

#define rep(a, b, c) for(int (a)=(b); (a)<(c); (a)++)
#define all(a) (a).begin(), (a).end()

int main(){
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());

    int x;
    cin >> x;
    int ans = (x/500)*1000 + ((x%500)/5)*5;
    cout << ans;

    //for(vector<int> a : ans) cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
    
}

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

int main() {
int n,a = 1;
cin >> n;
vector<pair<double,double>> x(n);
rep(i,n) {
  cin >> x.at(i).first >> x.at(i).second;
}
for (int i = n;i > 0;i--) a *= i;
double ans = 0;
rep(i,a) {
rep(i,n-1) {
  double cnt;
  cnt = pow(x.at(i).first-x.at(i+1).first,2) + pow(x.at(i).second-x.at(i+1).second,2);
  ans += sqrt(cnt);
}
next_permutation(x.begin(),x.end());

}
ans /= a;
printf("%.10f\n",ans);
return 0;
}



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

int main() {
    
  int N;
  cin >> N;
  int sum=0;
  for(int i=0;i<N;i++){
    int l,r;
    cin>>l>>r;
    sum+=r-l+1;
  }
  cout<< sum <<endl;
        
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define mod 1000000007
#define pb emplace_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll> 
#define vi vector< ll > 
#define vvi vector< vi > 
#define vpi vector< pii > 
#define vvpi vector< vpi > 
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define test(t) ll t;cin>>t;while(t--)
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
#define fr(i,n) for(ll i=0;i<(n);++i)
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b)))
#ifndef ONLINE_JUDGE
#define debarr(a,n)cerr<<#a<<":";for(int i=0;i<n;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(int i=0;i<row;i++){for(int j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S,class T>ostream &operator<<(ostream &os,const pair<S,T> &p){return os<<"("<<p.first<<","<<p.second<<")";}
template<class T>ostream &operator<<(ostream &os,const vector<T> &p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const set<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const multiset<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class S,class T>ostream &operator<<(ostream &os,const map<S,T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>void dbs(string str,T t){cerr<<str<<":"<<t<<"\n";}
template<class T,class...S>void dbs(string str,T t,S... s){int idx=str.find(',');cerr<<str.substr(0,idx)<<":"<<t<<",";dbs(str.substr(idx+1),s...);}
#else
#define pr(...){}
#define debarr(a,n){}
#define debmat(mat,row,col){}
#endif
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
signed main()
{
    fast;
    ll n,a,b;
    cin>>n>>a>>b;
    ll x = min(b-1,n-a);
    if(abs(a-b)%2==0)
        cout<<abs(a-b)/2;
    else
    {
        x = min(x,(b-a-1)/2+a);
        x = min(x,n-b+1+(b-a-1)/2);
        cout<<x;
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver1.9.4
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl;
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cout << fixed << setprecision(8);
  int n;
  cin >> n;
  int now=0,ct=0;
  while(now < n){
    ct++;
    now=ct*(ct+1)/2;
  }
  int d=now-n;
  rep(i,0,ct){
    if(d != i+1) cout << i+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n; cin>>n;
    if(n==25)cout<<"Christmas"<<endl;
    else if(n==24)cout<<"Christmas Eve"<<endl;
    else if(n==23)cout<<"Christmas Eve Eve"<<endl;
    else cout<<"Christmas Eve Eve Eve"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define rep1(i,n) for(int i=1; i<(int)n; i++)
#define repa(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
#define COUT(x) cout<<(x)<<endl
#define YES(x) cout<<(x?"YES":"NO")<<endl
#define Yes(x) cout<<(x?"Yes":"No")<<endl
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a / gcd(a, b)*b;}
//cout << fixed << setprecision(15);
int N, M, K, H, W, L, R, X;
string S, T;

signed main(){
  cin >> N;
  vector<bool> bj(1001,false);
  bj[1] = true;
  for(int i=2; i*i<=1001; i++){
    for(int j=2; j<=1000; j++){
      if(pow(i,j)>1000) break;
      bj[pow(i,j)] = true;
    }
  }
  for(int i=N; i>0; i--){
    if(bj[i]){ COUT(i); return 0;}
  }
  
  return 0;
}


Measured memory_bytes: 4112
def main():
    pointers = int(input())
    points = []
    for i in range(pointers):
        points.append(input().split())
    
    distances = 0
    distances_len = 0

    search_point = 0
    target_point = 1

    for i in range(search_point, pointers):
        for j in range(target_point, pointers):
            distances_len += 1
            distance = ((int(points[i][0]) - int(points[j][0])) ** 2 + (abs(int(points[i][1]) - int(points[j][1]))) ** 2) ** 0.5
            distances += distance
        target_point += 1

    print(distances / distances_len * (pointers - 1))

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include<stdio.h>

void drop(int x,int y,int s);

int m[10][10];

int main(void){
	int i,l,x,y,s,max=0,ans=0;
	
	for(i=0;i<10;i++){
		for(l=0;l<10;l++){
			m[i][l]=0;
		}
	}
	
	while(scanf("%d,%d,%d",&x,&y,&s)!=EOF){
		drop(x,y,s);
	}
	
	
	for(i=0;i<10;i++){
		for(l=0;l<10;l++){
			if(m[i][l]==0)ans++;
			if(max<m[i][l])max=m[i][l];
		}
	}
	
	printf("%d\n%d\n",ans,max);
	
	
	return 0;
	
	
}

void drop(int x,int y,int s){
	int i,l;
	
	for(i=x-1;i<=x+1;i++){
		if(i<0 || i>9)continue;
		for(l=y-1;l<=y+1;l++){
			if(l<0 || l>9)continue;
			if(s==1 && (i!=x && l!=y))continue;
			m[i][l]++;
		}
	}
	if(s==3){
		i=x-2;
		if(i>=0)m[i][y]++;
		i=x+2;
		if(i<=9)m[i][y]++;
		l=y-2;
		if(l>=0)m[x][l]++;
		l=y+2;
		if(l<=9)m[x][l]++;
	}
	return;
}
		
		
	
	
	

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include <vector>

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

using namespace std;

int main(){
	char S[100];
	ll K;

	scanf("%s", S);
	scanf("%lld", &K);

	int x = -1;
	REP(i, strlen(S)){
		if (S[i] != '1'){
			break;
		}
		else{
			x++;
		}
	}

	if (K <= x + 1){
		printf("1\n");
	}
	else{
		printf("%c\n", S[x+1]);
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n != 0) {
			String[] a = new String[n];
			for(int i = 0; i < n; i++) {
				a[i] = sc.next();
			}
			int j = 1;
			int ans = 0;
			while(j < n) {
				if(a[j-1].equals("lu") && a[j].equals("ru")) {
					ans ++;
				}else if(a[j-1].equals("ru") && a[j].equals("lu")) {
					ans ++;
				}else if(a[j-1].equals("rd") && a[j].equals("ld")) {
					ans ++;
				}else if(a[j-1].equals("ld") && a[j].equals("rd")) {
					ans ++;
				}
				j++;
			}
			System.out.println(ans);
			n = sc.nextInt();
		}
		sc.close();
	}
}



Measured memory_bytes: 37544
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

const long long MOD = 1e9 + 7;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    double ans = 0;
    cin >> n >> k;
    rep(i, 1, n + 1)
    {
        if (i < k)
        {
            ll t = i;
            double tmp = 1;
            while (t < k)
            {
                t *= 2.0;
                tmp /= 2.0;
            }
            ans += tmp;
        }
        else
            ans++;
    }
    ans /= n;
    cout << fixed << setprecision(15) << ans << endl;
}


Measured memory_bytes: 256
# coding:utf-8
import sys


def main():
    N = int(input())
    # N,M = map(int,input().split())
    coordinate = []
    maxx = 0
    maxy = 0
    for i in range(N):
        x, y = map(int, input().split())
        # if maxx < x:
        #     maxx = x
        # if maxy < y:
        #     maxy = y
        coordinate.append([x, y])
    coordinate.sort()
    # print(coordinate)

    ans = N
    checklist = []

    for i in range(N-1):
        x1 = coordinate[i][0]
        y1 = coordinate[i][1]

        for j in range(i+1, N):
            x2 = coordinate[j][0]
            y2 = coordinate[j][1]
            p = x2 - x1
            q = y2 - y1
            if not [p, q] in checklist:
                checklist.append([p, q])
    # print(checklist)

    # for i in range(5):
    #     for j in range(i, 5):
    #         if not i == j:
    #             print(i, j)

    for templ in checklist:
        pi = templ[0]
        qi = templ[1]
        count = N
        for i in range(N):
            for j in range(i, N):
                if i == j:
                    continue
                elif coordinate[i][0] + pi == coordinate[j][0] and coordinate[i][1] + qi == coordinate[j][1]:
                    count -= 1
        if count < ans:
            ans = count

    # arrivelist = []
    # for templ in checklist:
    #     pi = templ[0]
    #     qi = templ[1]
    #     for i in range(N):
    #         temp = []
    #         temp.append(i)
    #         nowx = coordinate[i][0] + pi
    #         nowy = coordinate[i][1] + qi
    #         for j in range(i, N):
    #             if nowx == coordinate[j][0] and nowy == coordinate[j][1]:
    #                 temp.append(j)
    #                 nowx += pi
    #                 nowy += qi
    #             elif nowx < coordinate[j][0]:
    #                 break
    #         if not temp in arrivelist:
    #             arrivelist.append(temp)

    # print(arrivelist)
    # arrivelist.sort(key=lambda x: len(x), reverse=True)
    # print(arrivelist)
    # dp = [[]]*len(arrivelist)

    # print(dp)
    print(ans)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 41052
#define scanf_s scanf
#include <stdio.h>
#include <iostream>
using namespace std;
#define MAX 200
int main(void)
{
	int n,a, b, c,x, sum, cou = 0;
	scanf_s("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf_s("%d %d %d", &a, &b, &c);
		if (a > b) {
			x = a; a = b; b = x;
		}
		if (b > c) {
			x = b; b = c; c = x;
		}
		if(c* c == a*a + b * b)	printf("YES\n");
		else printf("NO\n");
	}
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	int a, b, c;
	cin >> a >> b >> c;
	cout << min({ a + b,b + c,c + a }) << endl;
	return 0;
}

Measured memory_bytes: 256
// -_-
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for(int i = a; i <= b; i++)
#define ford(i, a, b) for(int i = a; i >= b; i--)
#define mod 1000000007
#define  sort1(v) sort(v.begin(), v.end()) 
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;

 
signed main() 
{

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

	int n;
	cin >> n;
	int h[n+1];
	h[0] = -1;
	fori(i, 1, n) cin >> h[i];
	fori(i, 1, n-1)
	{
		if(h[i] > h[i+1]  || h[i] > h[i-1] || i == 1)
			h[i]--;
			if(h[i] > h[i+1] || (h[i-1] > h[i]))
			{
				cout << "No";
				return 0;
			}
			
	}
	cout << "Yes";

	return 0;
}

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

int main() {
    int MAX = 101010;
    vector<int> is_prime(MAX, 1);
    is_prime[0] = 0;
    is_prime[1] = 0;

    for(int i=2; i<MAX; ++i){
        if(!is_prime[i]){
            continue;
        }
        for(int j=i*2; j<MAX; j+=i){
            is_prime[j] = 0;
        }
    }

    vector<int> a(MAX, 0);
    for(int i=0; i<MAX; ++i){
        if(i%2==0){
            continue;
        }
        if(is_prime[i] && is_prime[(i+1)/2]){
            a[i] = 1;
        }
    }

    vector<int> s(MAX+1, 0);
    for(int i=0; i<MAX; ++i){
        s[i+1] = s[i] + a[i];
    }

    int q;
    cin >> q;

    for(int i=0; i<q; i++){
        int l, r;
        cin >> l >> r;
        r++;

        cout << s[r] - s[l] << endl;
    }

    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define sz 105

using namespace std;

int main()
{
    char str1[sz],str2[sz],str3[sz];

    scanf("%s %s %s",str1,str2,str3);

    ll len1=strlen(str1);
    ll len2=strlen(str2);
    ll len3=strlen(str3);

    if(str1[len1-1]==str2[0]&&str2[len2-1]==str3[0])
        printf("YES\n");

    else
        printf("NO\n");

    return (0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
    char a[4];
    scanf("%s", a);
    
    bool able=true;
    for(int i=1;i<4;i++) if(a[i]==a[i-1]) able=false;

    printf(able?"Good\n":"Bad\n");
}

Measured memory_bytes: 384