akhauriyash/Code-Regression huggingface dataset:
//abc064_c.cpp
//Sun Jun  3 11:33:44 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;

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

	int color[9];
	for (int i=0;i<9;i++){
		color[i] = 0;
	}

	for (int i=0;i<n;i++){
		int temp;
		cin >> temp;
		if (temp <= 399){
			color[0]++;
		} else if (temp <= 799){
			color[1]++;
		} else if (temp <= 1199){
			color[2]++;
		} else if (temp <= 1599){
			color[3]++;
		} else if (temp <= 1999){
			color[4]++;
		} else if (temp <= 2399){
			color[5]++;
		} else if (temp <= 2799){
			color[6]++;
		} else if (temp <= 3199){
			color[7]++;
		} else{
			color[8]++;
		}
	}

	int ans = 0;

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

	int maxans = ans + color[8];

	if (ans == 0 && color[8]>0){
		ans = 1;
	}


	cout << ans << " " << maxans<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)
            r=(r*a)%m;
        b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

int main(){
    ll n,k; cin>>n>>k;
    string s; cin>>s;
    ll a = 0;
    rep(i,0,n-1)
    {
        if(s[i]==s[i+1])a++;
    }
    cout<<min(n-1,a+2*k)<<endl;
    return 0;
}


Measured memory_bytes: 512
N = int(input())
A = [int(i) for i in input().split()]
t = A[0]
s = -1
ans = 1
for i, a in enumerate(A):
	if s > 0:
		if a < t:
			ans += 1
			s = -1
	elif s < 0:
		if t < a:
			s = 1
		elif t > a:
			s = 0
	else:
		if a > t:
			ans += 1
			s = -1
	t = a
print(ans)

Measured memory_bytes: 14252
#include <iostream>
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    int like[m];
    for (int i=0; i<m; i++) {
        like[i] = 0;
    }
    for (int i=0; i<n; i++) {
        int k;
        cin >> k;
        for (int j=0; j<k; j++) {
            int a;
            cin >> a;
            like[a-1]++;
        }
    }
    int result = 0;
    for (int i=0; i<m; i++) {
        if (like[i] == n) {
            result++;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main(){
  int q;
  int l,r;
  int flag;
  vector<int> islikenumber(1000001,0);
  vector<int> number(1000001,0);
  cin >> q;
  for(int i = 2 ; i <= 100000 ; i++){
    flag = 1;
    for(int j = 2 ; j <= sqrt(i) ; j++){
      if(i%j == 0){
        flag = 0;
        break;
      }
    }
    number[i] = flag;
  }
  for(int i = 3 ; i <= 100000 ; i += 2){
    if(number[i] == 1 && number[(i+1)/2] == 1){
      islikenumber[i] += 1;
    }
    islikenumber[i] += islikenumber[i-2];
  }

  for(int main = 0 ; main < q ; main++){
    cin >> l >> r;
    if(l == 1){
      cout << islikenumber[r] << endl;
    }else{
      cout << islikenumber[r] - islikenumber[l-2] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 8448
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        string s = Console.ReadLine();

        foreach(char c in s) {
            if (c == '9') Console.Write("1");
            else if (c == '1') Console.Write("9");
        }
        Console.WriteLine();
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static int[] SpIntRead(char c)
    {
        return Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
    }
    public static string ToConvertBit(int N, int e)
    {
        string ret = "";
        int r = 0;
        while (N != 0)
        {
            r = N % e;
            ret += r.ToString();
            N -= r;
            N /= e;
        }
        ret = strReverce(ret);
        return ret;
    }

}


Measured memory_bytes: 13140
N=int(input())
S=input()

answer =0
for i in range(1,N-1):
  X = S[:i]
  Y = S[i:]
  count=0
  for l in 'abcdefghijklmnopqrstuvwxyz':
    if l in X and l in Y:
      count +=1
  answer =max(answer, count)
  
print(answer)
  


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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	int cost;
} edge;

int main( void ){
	// initialize();
	int N; cin >> N;
	printf("%.10lf\n",(double)N*2*M_PI);
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
int ans,x;
long long n;
int main(){
	cin>>n;
	for(int i=sqrt(n);i>=1;i--)
	{
		if(n%i==0) 
		{
			x=n/i;
			while(x>0) x/=10,ans++;
			break;
		}
	}
	cout<<ans;
	return 0;         
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  string S;
  cin >> S;
  i64 size = S.size();
  for (i64 i = 0; i < size / 2; i++)
    if (S[i] != S[size - i - 1])
    {
      cout << "No" << endl;
      return 0;
    }
  for (i64 i = 0; i < size / 4; i++)
    if (S[i] != S[size / 2 - i - 1])
    {
      cout << "No" << endl;
      return 0;
    }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e10;
const ll MOD = 1000000007;
// {a,c,g,t}
ll n;
ll dp[105][4][4][4] = {0};
void solve(){
    rep(i,2,n){
        rep(a,4){
            rep(b,4){
                rep(c,4){
                    rep(d,4){
                        if (b == 0 && c == 2 && d == 1) continue;
                        if (b == 2 && c == 0 && d == 1) continue;
                        if (b == 0 && c == 1 && d == 2) continue;
                        if (a == 0 && c == 2 && d == 1) continue;
                        if (a == 0 && b == 2 && d == 1) continue;
                        dp[i+1][b][c][d] += dp[i][a][b][c];
                    }
                    dp[i+1][a][b][c] %= MOD;
                }
            }
        }
    }
}
int main() {
    cin >> n;
    rep(a,4){
        rep(b,4){
            rep(c,4){
                if (a == 0 && b == 2 && c == 1) continue;
                if (a == 0 && b == 1 && c == 2) continue;
                if (a == 2 && b == 0 && c == 1) continue;
                dp[2][a][b][c] = 1;
            }
        }
    }
    solve();
    ll ans = 0;
    rep(a,4){
        rep(b,4){
            rep(c,4){
                ans += dp[n-1][a][b][c];
                ans %= MOD;
            }
        }
    }
    PRINT(ans);
}

Measured memory_bytes: 256
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

aa = inputs[0][0]
bb = inputs[0][1]

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag

end

puts [aa - 2*bb, 0].max


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

namespace Atcoder
{
    class AtCodeeeeeeeeeeeeeeeeeeeer
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            double JPY = 0;double BTC =0;
            for (int i = 0; i < N; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                double obj = double.Parse(s[0]);
                if (s[1]=="JPY")
                {
                    JPY += obj;
                }
                else if (s[1]=="BTC")
                {
                    BTC += obj;
                }
            }
            Console.WriteLine(
                JPY + (BTC * 380000.0)
                );
        }
    }
}


Measured memory_bytes: 13140
import sys
x = int(input())

if x == 2 or x == 3:
    print(x)
    sys.exit()

for i in range(10000):

    for j in range(2, int(x/2)+1):
        if (x%j == 0):
            break

        if (j == int(x/2)):
            print(x)
            sys.exit()

    x += 1



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

int main() {
  int n,m,k;
  cin >> n >> m >> k;
  vector<long long> a(n+1),b(m+1);
  for(int i=0;i<n;i++) {
    cin >> a[i+1];
    a[i+1]+=a[i];
  }
  for(int i=0;i<m;i++) {
    cin >> b[i+1];
    b[i+1]+=b[i];
  }
  int ok=0,ng=n+m+1;
  while(ok+1<ng) {
    int mid=(ng+ok)>>1;
    long long v=__INT64_MAX__;
    for(int i=max(0,mid-m);i<=min(n,mid);i++) {
      v=min(v,a[i]+b[mid-i]);
    }
    if(v<=k) ok=mid;
    else ng=mid;
  }
  cout << ok << endl;
}

Measured memory_bytes: 6424
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pb push_back

int main()
{
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	ll sum = 0;
	ll copy[n];
	for(int i=0;i<n;i++){
	copy[i]=	(arr[i] - (i+1));
	}
	sort(copy,copy+n);
	sum = copy[n/2];
	ll res=0;
	for(int i=0;i<n;i++)
		res += abs(arr[i]-(i+1)-sum);
	cout<<res<<"\n";

}	


/*1 1 1 1 2 3 4
0 -1 -2 -3 -3 -3 -3
2  1  0 -1  -1 -1 -1*/

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

int main(void){
	
	int n;
	int a[1001];
	int ans;
	
	cin>>n;
	for(int i=0;i<n;i++)
			cin>>a[i];
			
	sort(a,a+n);
	
	ans=a[n-1]-a[0];
	
	cout<<ans<<endl;
	

				
		
	
	return 0;
}

Measured memory_bytes: 256
class Dice:
    def __init__(self, ary): # [top, front, right, left, back, bottom]
        self.__top = ary[0]
        self.__fro = ary[1]
        self.__rit = ary[2]
        self.__lft = ary[3]
        self.__bak = ary[4]
        self.__btm = ary[5]

    def turn_e(self): # 右に転がる
        self.__top, self.__lft, self.__btm, self.__rit = \
        self.__lft, self.__btm, self.__rit, self.__top

    def turn_s(self): # 手前に転がる
        self.__top, self.__fro, self.__btm, self.__bak = \
        self.__bak, self.__top, self.__fro, self.__btm

    def turn_w(self): # 左に転がる
        self.__top, self.__lft, self.__btm, self.__rit = \
        self.__rit, self.__top, self.__lft, self.__btm

    def turn_n(self): # 奥に転がる
        self.__top, self.__fro, self.__btm, self.__bak = \
        self.__fro, self.__btm, self.__bak, self.__top

    def spin_r(self): # 右回転 
        self.__rit, self.__fro, self.__lft, self.__bak = \
        self.__bak, self.__rit, self.__fro, self.__lft

    def spin_l(self): # 左回転
        self.__rit, self.__fro, self.__lft, self.__bak = \
        self.__fro, self.__lft, self.__bak, self.__rit

    def is_same_setting(self, ary): # 同じように置いているか
        if self.__top == ary[0] and self.__fro == ary[1] and self.__rit == ary[2] and \
            self.__lft == ary[3] and self.__bak == ary[4] and self.__btm == ary[5]:
            return True

    def is_same_dice(self, ary): # 回転させて同じダイスになるか
        is_same = False
        for _ in range(2):
            for _ in range(3):
                for _ in range(4):
                    if self.is_same_setting(ary):
                        is_same = True
                    self.spin_r()
                self.turn_n()
            self.spin_r()
            self.turn_s()
        return is_same

    def show_top(self): # 上面の値を表示
        return self.__top


n = int(input())
surfaces_stack = [None] * n
for i in range(n):
    surfaces_stack[i] = list(map(int,input().split()))

for i in range(n-1):
    for j in range(i+1, n):
        dice = Dice(surfaces_stack[i])
        if dice.is_same_dice(surfaces_stack[j]):
            print('No')
            break
    else:
        continue
    break
else:
    print('Yes')


Measured memory_bytes: 5620
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;


ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN

    ll n,m,x,y; cin>>n>>m>>x>>y;
    vll X(n); REP(i,n) cin>>X[i];
    vll Y(m); REP(i,m) cin>>Y[i];
    VSORTR(X); VSORT(Y);
    FOR(z,x+1,y){
        if (z>X[0] && z<=Y[0]) {
            cout<<"No War"<<endl; 
            return 0;
        }
    }
    cout<<"War"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int [] vals = new int [n];
		int count = 0;

		for (int i = 0; i < n; i++) {
			if (s.charAt(i) == 'I') {
				count++;
			}else if(s.charAt(i) == 'D') {
				count--;
			}
			vals[i] = count;
		}
		int intMax = vals[0];
		for(int val : vals) {
			if(intMax < val) {
				intMax = val;
			}
		}
		if (intMax < 0) {
			System.out.println(0);
		}else {
			System.out.println(intMax);
		}
	}
}


Measured memory_bytes: 35760
# coding: utf-8

def main():
    N = int(input())
    pw = []
    for i in range(N):
        w = input().strip()
        if i > 0 and (w in pw or w[0] != pw[-1][-1]):
            return "No"
        pw.append(w)
    return "Yes"

print(main())


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(void) {
  int n,b=0;
  cin >> n;
  int a[n];
  for(int i=0;i<n;++i) {
    cin >> a[i];
    b += a[i];
  }
  cout << b - n << endl;
}

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

int main(void){
 vector<int> a(3);
 cin >> a[0] >> a[1] >> a[2];
 sort(a.begin(), a.end());
 cout << ((a[0]+a[1]==a[2]) ? "Yes" : "No") << endl; 
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SC scanf
#define PR printf
#define pb push_back
#define mp make_pair
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define db double
#define ldb long double
#define uint unsigned
#define ll long long
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef pair<pii,pii> ppp;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef map<int,int> mii;
const int INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const int xx[4]={1,-1,0,0};
const int yy[4]={0,0,1,-1};
int inline nextin(){
	int t;
	if(scanf("%d",&t)!=1)exit(0);
	return t;
}
int inline in(){
	int x=0,c;
	for(;(uint)((c=getchar())-'0')>=10;){
		if(c=='-')return -in();
		if(!~c)throw ~0;
	}
	do{
		x=(x<<3)+(x<<1)+(c-'0');
	}while((uint)((c=getchar())-'0')<10);
	return x;
}
int n;
char c[100005];
int r[100005];
bool hantei(int a,int b,int c,char t){
	if(t=='o'&&b==0)if(a==c)return true;else return false;
	if(t=='o'&&b==1)if(a!=c)return true;else return false;
	if(t=='x'&&b==0)if(a!=c)return true;else return false;
	if(t=='x'&&b==1)if(a==c)return true;else return false;
	return false;
}
int main(){
    cin.sync_with_stdio(false);cin.tie(0);
    cin>>n;
	rep(i,n)cin>>c[i];
	rep(i,4){
		r[0]=i/2;r[1]=i%2;
		for(int j=2;j<n;j++){
			if(c[j-1]=='o')r[j]=r[j-2];
			else r[j]=1-r[j-2];
			if(r[j-1]==1)r[j]=1-r[j];
		}
		if(!hantei(r[n-2],r[n-1],r[0],c[n-1]))continue;
		if(!hantei(r[n-1],r[0],r[1],c[0]))continue;
		rep(j,n)putchar(r[j]?'W':'S');
		return 0;
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 896
#include <stdio.h>

int main(void) {

  long n;
  long divisor,multiple;

  while(1) {
    
    scanf("%ld",&n);

    if(n==0) return 0;

    divisor=5;
    multiple=0;

    while(divisor<=n) {
      
      multiple+=n/divisor;
      divisor=divisor*5;

    }

    printf("%ld\n",multiple);
  }

  return 0;

}

Measured memory_bytes: 0
n, m, x = map(int, input().split())
c = [0] * n
a = [[0 for _ in range(m)] for q in range(n)]
for i in range(n):
    l = list(map(int, input().split()))
    c[i] = l[0]
    for w in range(m):
        a[i][w] = l[w + 1]
inf = float('inf')
ans=inf
for i in range(2 ** n):
    cost = 0
    e=[0]*m
    for j in range(n):
        if i >> j & 1:
            cost += c[j]
            for k in range(m):
                e[k] += a[j][k]
    ok=True
    for y in range(m):
        if e[y] < x:
            ok = False
            break
    if ok:
        ans = min(ans, cost)
print(ans if ans!=inf else '-1')
            


Measured memory_bytes: 9176
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int f;

int main(){
    INIT;
    cin >> f;
    cout << (f - 30)/2 << endl;
}


Measured memory_bytes: 3172
use proconio::input;

fn main() {
  input! {
    n: i64,
    m: i64,
    a: [i64; m],
  }
  let sum = a.iter().fold(0i64, |x, &y| x + y);
  println!("{}", if n >= sum { n - sum } else { -1 });
}

Measured memory_bytes: 2268
#include<bits/stdc++.h>
#define clr(x)  memset(x,0,sizeof(x))
using namespace std;

long long ar[500005],visit[500005],len;
map<long long,long long>ma;
pair<long long,long long>pa;

string s,ss;

struct st
{
    long long a,b,c;
    string s;
};

st vv[500005];


int main()
{
    long long i,j,k,n,ans=0,a,b,c,tc,x=0,m;
    cin>>n;
   cout<<3*n*n<<endl;


    return 0;

}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
#define Speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;

#define st              first
#define nd              second
#define pb              push_back
#define pf              push_front
#define all(a)          (a).begin(), (a).end()
#define lwb             lower_bound
#define upb             upper_bound
#define vvll            vector<vector<ll> >
#define Mset(s, n)      memset(s, n, sizeof(s))
#define Sz(a)           int((a).size())
#define Max(a, b, c)    max(max((ll)(a), (ll)(b)), (ll)(c))
#define Min(a, b, c)    min(min((ll)(a), (ll)(b)), (ll)(c))
#define Unique(a)       sort(all(a)); (a).resize(unique(all(a)) - (a).begin())

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

const ll MOD = 1e9 + 7;
const int oo = 2e9;
const ld PI = acos((ld) -1);
int Getbit(ll x, int k){return (x >> (k - 1)) & 1;}
ll Lcm(ll a, ll b) {return a / __gcd(a, b) * b;}
bool isPrime(ll n){for(ll i = 2; i * i <= n; i++){if(n % i == 0) return 0;} return (n > 1) ? 1 : 0;}
ll Powmod(ll n, ll k, ll p = MOD) {ll r = 1; for(; k; k /= 2, n = n * n % p){if(k & 1) r = r * n % p;} return r;}

const int N = 6e3 + 5;


ll n, m, query;

int a[N];
int ans = 0;
bool cmp(string s, string t, int n){
    for(int i = 0; i < n; i++){
        if(s[i] < t[i]) return false;
        if(s[i] > t[i]) return true;
    }
    return true;
}
void Solve(){
    int n;
    cin >> n >> m;
    vector<string> v;
    for(int i = 1; i <= n; i++){
        string s;
        cin >> s;
        v.pb(s);
    }
    sort(all(v));
    for(string s: v) cout << s;
}

int main(){
//    Speed;
    int query = 1;
//    cin >> query;
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout)
    while(query--){
        Solve();
    }
}






Measured memory_bytes: 256
# AOJ 0611: Silk Road
# Python3 2018.7.4 bal4u

import sys
from sys import stdin
input = stdin.readline

INF = 0x7fffffff
n, m = map(int, input().split())
d = [int(input()) for i in range(n)]
c = [int(input()) for i in range(m)]
dp = [[INF for j in range(n+1)] for i in range(m+1)]
dp[0][0] = 0
for i in range(m):
	for j in range(n+1): dp[i+1][j] = dp[i][j]
	for j in range(n):
		if dp[i][j] != INF:
			dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j]+c[i]*d[j])
print(dp[m][n])


Measured memory_bytes: 19124
S = input()
flag =0
for i in range(len(S)):
  if i % 2 == 1 and S[i] == 'R':
    flag=1
    break
  elif(i % 2 == 0 and S[i] == 'L'):
    flag=1
    break
ans = "Yes" if flag == 0 else "No"
print(ans)
  

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    Node[] nodes = new Node[N];
    for (int i = 0; i < N; i++) nodes[i] = new Node();
    int M = scanner.nextInt();
    for (int i = 0; i < M; i++) {
      int l = scanner.nextInt() - 1;
      int r = scanner.nextInt() - 1;
      int d = scanner.nextInt();
      nodes[l].adjacent.add(new Edge(nodes[r], d));
      nodes[r].adjacent.add(new Edge(nodes[l], -d));
    }

    for (int i = 0; i < N; i++) {
      if (!nodes[i].visited) {
        nodes[i].pos = 0;
        if (dfs(nodes[i])) {
          System.out.println("No");
          return;
        }
      }
    }
    System.out.println("Yes");
  }

  private static boolean dfs(Node node) {
    node.visited = true;
    for (Edge a : node.adjacent) {
      if (!a.to.visited) {
        a.to.pos = node.pos + a.dist;
        if (dfs(a.to)) {
          return true;
        }
      } else if (a.to.pos != node.pos + a.dist) {
        return true;
      }
    }
    return false;
  }

  private static class Node {
    private final List<Edge> adjacent = new ArrayList<>();
    private int pos;
    private boolean visited;
  }

  private static class Edge {
    private final Node to;
    private final int dist;

    private Edge(Node to, int dist) {
      this.to = to;
      this.dist = dist;
    }
  }
}


Measured memory_bytes: 178368
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	double n, m, d; cin >> n >> m >> d;
	double res = 0;
	res = 2 * (n - d) / (n*n);
	res *= m - 1;
	if (d == 0)res /= 2;
	cout << fixed << setprecision(10) << res << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    static final int INF = 1000000000;     
    
    public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; ++i) a[i] = input.nextInt();
        for (int i = 1; i < n; ++i) {
            System.out.print(a[0]);
            for (int k = 1; k < n; ++k) System.out.print(" " + a[k]);
            System.out.println("");
            int key = a[i];
            int k = i - 1;
            while (k >= 0 && a[k] > key) {
                a[k + 1] = a[k];
                --k;
            }
            a[k + 1] = key;
        }        
        System.out.print(a[0]);
        for (int i = 1; i < n; ++i) System.out.print(" " + a[i]);
        System.out.println("");
    }   
}

Measured memory_bytes: 24328
//
//  main.cpp
//  C - Divide the Problems
//
//  Created by Hashizo on 2019/06/29.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>

using namespace std;

#undef INT_MAX
#undef INT_MIN

#define INT_MAX	2147483647
#define INT_MIN	(-INT_MAX  -1)

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define REPLACE(s, f, t) regex_replace(s, regex(f), t)

int main(int argc, const char * argv[]) {
	int n;
	cin >> n;

	vector<int> d(n);
	
	REP(i, n) {
		cin >> d[i];
	}
	
	SORT(d);
	
	int div = abs(d[(n/2)-1] - d[(n/2)]);
	
	cout << div << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    int sum = 0;
    REP(i,0,n+1) {
        sum += i;
        if (sum >= n) {
            RREP(j,1,i+1) {
                if (n <= 0) break;
                if (n < j) continue;
                n -= j;
                cout << j << endl;
            }
            return;
        }
    }
}

int main() {
    solve();
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
#define int long long
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
signed main(void){
    int n,k; cin>>n>>k;
    vector <int> a(n); 
    int sum = 0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+= a[i];
    }
    vector <int> yaku;
    for(int i=1;i*i<sum;i++){
        if(sum % i ==0) {yaku.push_back(i); yaku.push_back(sum/i);}
    }
    int x = yaku.size();
    //rep(i, x) cout<<yaku[i]<<endl;
    sort(yaku.begin(),yaku.end());
    for(int i=x-1; i>=0; i--){
        //cout<<yaku[i]<<'*'<<endl;
        vector <int> ama(n); 
        rep(j, n){
            ama[j] = a[j]%yaku[i];
        }
        sort(ama.begin(),ama.end());
        vector <int> decs(n), incs(n);
        decs[0] = ama[0]; incs[n-1] = yaku[i] - ama[n-1];
        for(int j=1;j<n;j++){
            //cout<< ama[j]<< '+' <<decs[j-1]<<endl;;
            decs[j] = ama[j] + decs[j-1];
        }
        //rep(j, n) cout<<decs[j]<<'*';
        for(int j = n-2; j>=0; j--){
            incs[j] = yaku[i] - ama[j] + incs[j+1];
        }
        int cost = max(incs[0], decs[n-1]);
        for(int j=0;j<n-1;j++){
            chmin(cost, max(decs[j],incs[j+1]));
        }
        //cout<<cost<<endl;
        if(cost <= k ) {cout<<yaku[i]<<endl; return 0;}
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

const double pi = acos(-1);

int n, X1, Y1, X2, Y2, X[200010], Y[200010], tmp[200010];

vector <int> V;

bool cmp(int x, int y) {
    return X[x] < X[y];
}

int main() {
    scanf("%d%d%d%d%d", &X1, &Y1, &X2, &Y2, &n);
    for(int i = 1; i <= n; i++) scanf("%d%d", &X[i], &Y[i]);
    for(int i = 1; i <= n; i++) tmp[i] = i;
    if(X1 > X2) {
        swap(X1, X2);
        swap(Y1, Y2);
    }
    sort(tmp + 1, tmp + n + 1, cmp);
    int l = 1, r = n;
    while(l != n + 1 && X[tmp[l]] < X1) l++;
    while(r != 0 && X[tmp[r]] > X2) r--;
    X[tmp[l - 1]] = X1;
    Y[tmp[l - 1]] = Y1;
    X[tmp[r + 1] = n + 1] = X2;
    Y[tmp[r + 1]] = Y2;
    if(Y1 > Y2) {
        for(int i = l - 1; i <= r + 1; i++) Y[tmp[i]] *= -1;
        Y1 = -Y1;
        Y2 = -Y2;
    }
    Y[tmp[l - 1]]--;
    Y[tmp[r + 1]]++;
    for(int i = l - 1; i <= r + 1; i++) if(Y[tmp[i]] > Y[tmp[l - 1]] && Y[tmp[i]] < Y[tmp[r + 1]]){
        int w = lower_bound(V.begin(), V.end(), Y[tmp[i]]) - V.begin();
        if(w == V.size()) V.push_back(Y[tmp[i]]); else V[w] = Y[tmp[i]];
    }
    printf("%.13lf\n", (X2 - X1 + Y2 - Y1) * 100ll + (V.size() == min(Y2 - Y1, X2 - X1) + 1) * 5 * pi - V.size() * (20 - pi * 10 / 2));
    return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#include <set>
using namespace std;
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define fill(x, y)     memset(x, y, sizeof(y))
#define all(x)         (x).begin(), (x).end()
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;

int n;
int opt;
bool visited[100010];
vector<int> graph[100010];
int in[100010];
int dp[100010];

void dfs(int u) {
    visited[u] = true;
    for (int v : graph[u]) {
        dp[v] = max(dp[v], dp[u]+1);
        in[v]--;
        if (in[v] == 0) dfs(v);
    }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int m;
  cin >> n >> m;
  int a, b;
  opt = 0;
  for (int i = 0; i < m; i++) {
      cin >> a >> b;
      graph[a].pb(b);
      in[b]++;
  }
  for (int i = 1; i <= n; i++) {
      if (!visited[i] && in[i] == 0) dfs(i);
  }
  int opt = 0;
  for (int i = 1; i <= n; i++) {
      opt = max(opt, dp[i]);
  }
  cout << opt << "\n";
  return 0;
}

Measured memory_bytes: 14520
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String C1 = sc.next();
    StringBuffer C2 = new StringBuffer(sc.next());

    String msg = "NO";
    if(C1.equals(C2.reverse().toString())) msg = "YES";

    System.out.println(msg);

  }
}


Measured memory_bytes: 21972
#109 B

N=int(input())
start=[]
for i in range(N):
    start.append(input())
cnt=0
for i in range(N):
    if i!=0 and start[i][0]==start[i-1][-1]:
        cnt+=1
        
if len(start)==len(set(start)) and cnt==N-1:
    print('Yes')
else:
    print('No')

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

struct Data {
    int d;
    ll p;
    Data(ll p, int d) : p(p), d(d){}
    bool operator < (const Data &d) const {
        return p < d.p;
    }
};

int main() {
    int N;
    ll L;
    cin >> N >> L;
    ll p[N];
    int d[N];
    vector<Data> v;
    for (int i = 0; i < N; i++) {
        cin >> p[i] >> d[i];
        v.push_back(Data(p[i], d[i]));
    }
    
    sort(v.begin(), v.end());
    ll l[N + 1]{};
    ll r[N + 1]{};
    for (int i = 0; i < N; i++) {
        if (v[i].d == 0) {
            l[i + 1] = l[i] + v[i].p - i - 1;
        } else {
            l[i + 1] = l[i] - (v[i].p - i - 1);
        }
        if (v[N - i - 1].d == 0) {
            r[i + 1] = r[i] - (L - v[N - i - 1].p - i);
        } else {
            r[i + 1] = r[i] + (L - v[N - i - 1].p - i);
        }
    }
    
    ll ans = 0;
    for (int i = 0; i <= N; i++) {
        ll t = r[i] + l[N - i];
        ans = max(ans, t);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 7184
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=1;i<=n;i++)
using namespace std;
using ll=long long;
using P = pair<int,int>;
int main(){
  int a;
  cin >> a;
  if(a==0)cout << 1 << endl;
  else cout << 0 << endl;  
}

Measured memory_bytes: 3628
from copy import deepcopy
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools
import copy


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n = int(input())
p = map(str, input().split())
q = map(str, input().split())
p_int = int(''.join(p))
q_int = int(''.join(q))
#print(p_int, q_int)
seq = list(range(1, n+1))
# print(seq)
x = list(itertools.permutations(seq))
xx = sorted(x)
# print(xx)
for i in range(math.factorial(n)):
    a = map(str, list(xx[i]))
    b = "".join(map(str, a))
    c = int("".join(map(str, b)))
    # print(c)
    if c == p_int:
        p_ans = i+1
    if c == q_int:
        q_ans = i+1
print(abs(p_ans-q_ans))


Measured memory_bytes: 71768
x = input()
n = len(x)

ans = 0
cnt = 0
for i in range(n):
    if x[i] == 'S':
        cnt += 1
        ans += 1
    else:
        if cnt > 0:
            cnt -= 1
            ans -= 1
        else:
            ans += 1

print(ans)


Measured memory_bytes: 3500
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int K;
long long int A[110000];

bool check1(long long int num){
	
	long long int ret = num;
	
	for(int i = 0; i < K; i++){
		ret -= (ret % A[i]);
	}
	
	if(ret >= 2){
		return true;
	}
	return false;
}

bool check2(long long int num){
	
	long long int ret = num;
	
	for(int i = 0; i < K; i++){
		ret -= (ret % A[i]);
	}
	
	if(ret > 2){
		return true;
	}
	return false;
}

long long int bin_search1(long long int lef, long long int rig){
	long long int middle = (lef + rig) / 2;
	if(rig - lef <= 1){
		if(check1(rig)){
			return rig;
		}else{
			return lef;
		}
	}
	if(check1(middle)){
		rig = middle;
	}else{
		lef = middle;
	}
	return bin_search1(lef, rig);
}

long long int bin_search2(long long int lef, long long int rig){
	long long int middle = (lef + rig) / 2;
	if(rig - lef <= 1){
		if(check2(rig)){
			return rig;
		}else{
			return lef;
		}
	}
	if(check2(middle)){
		rig = middle;
	}else{
		lef = middle;
	}
	return bin_search2(lef, rig);
}

int main(){
	
	cin >> K;
	
	for(int i = 0; i < K; i++){
		cin >> A[i];
	}
	
	long long int ans1 = bin_search1(1LL, 1000000000000000LL);
	long long int ans2 = bin_search2(1LL, 1000000000000000LL) - 1;
	
	bool flag = true;
	
	long long int ret = ans1;
	
	for(int i = 0; i < K; i++){
		ret -= (ret % A[i]);
	}
	
	if(ret != 2){
		flag = false;
	}
	
	ret = ans2;
	
	for(int i = 0; i < K; i++){
		ret -= (ret % A[i]);
	}
	
	if(ret != 2){
		flag = false;
	}
	
	if(flag){
		cout << ans1 << " " << ans2 << endl;
	}else{
		cout << "-1" << endl;
	}
	
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a, b, c;
    a = n / 100;
    b = n % 100 / 10;
    c = n - 100 * a - 10 * b;

    if(a == 7 || b == 7 || c == 7){
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll D,G;
	cin >> D >>G;
	vector<ll> p(D);
	vector<ll> c(D);
	for(int i = 0; i < D; i++) {
		cin >> p[i] >> c[i];
 	}
	
	vector<vector<ll>> dp(11,vector<ll>(1500,0));
	int sum = 0;

	for(int i = 0; i < D; i++) {
		for(int j = 0; j <=1001; j++) {
			for(int k = 0; k <= p[i]; k++) {
				if (k == p[i]){
				dp[i+1][j+k] = max(dp[i+1][j+k],dp[i][j] + (i + 1) * 100 * k + c[i]);
				}
				else{
					dp[i+1][j+k] = max(dp[i+1][j+k],dp[i][j] + (i + 1) * 100 * k);
				}
			}
		}
	}

	for(int i = 0; i <= 1001; i++) {
		// cout << dp[D][i] << endl;
		if (dp[D][i] >= G){
			cout << i << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll n;
	double ans;

	cin >> n;


	if (n % 2 == 0) {
		ans = 1.0 / 2.0;
	}
	else {
		ans = (n + 1.0) / 2.0 / (double)n;
	}

	cout << setprecision(10) << scientific << ans << endl;
}

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

int main(){
  long long int n,y;
  cin >> n >> y;
  y = y/1000-n;
  long long int xk,yk;
  xk=y/4;
  if(y%9==0) yk = 2*y/9;
  else yk = 2*y/9+1;
  if(xk < yk) {
    cout << "-1 -1 -1" << endl;
    return 0;
  }
  long long xn,yn,zn;
  for(int i=yk;i<=xk;i++){
    xn = -4*i+y;
    yn = 9*+i-2*y;
    zn = n-xn-yn;
    if(zn>=0){
      cout << xn << " " << yn << " " << zn << endl;
      return 0;
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int N = 100005;
const int M = 3;
const long long inf = 1e18+7;
 
#define REP(i, n) for (int (i) = 0; (i) < (n); ++(i))
 
int n, a[N];
char c;
long long f[N][M+1];
 
int main() {
	ios::sync_with_stdio(false);
 
	cin >> n >> a[0];
	for (int i = 1; i < n; ++i) {
		cin >> c >> a[i];
		if (c == '-') a[i] *= -1;
	}
	REP(i, n+1) REP(a, M+1) {
		f[i][a] = -inf;
	}
	f[0][0] = 0;
	REP(i, n) REP(x, M) {
		if (f[i][x] == -inf) continue;
		long long val = f[i][x] + (x%2?-1:+1)*a[i];
		f[i+1][x] = max(f[i+1][x], val);
		if (a[i] < 0) f[i+1][min(x+1,M)] = max(f[i+1][min(x+1,M)], val);
		if (x > 0) f[i+1][max(x-1,0)] = max(f[i+1][max(x-1,0)], val);
	}
	long long result = -inf;
	REP(a, M) result = max(result, f[n][a]);
	cout << result << endl;
	return 0;
}

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

int main () {
  int H, N;
  cin >> H >> N;
  
  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
  }
  
  int sum = 0;
  rep(i, N) {
    sum += A[i];
  }
  
  if (sum>=H) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 640
def main():
    num = list(map(int, input().split()))

    ans = 0
    while num[0] != num[1] or num[1] != num[2]:
        tmp = max(num)
        if num.count(tmp) == 2:
            num[num.index(min(num))] += 2
        else:
            num[num.index(max(num))] -= 1
        ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define F first
#define S second
#define mset(x,v) memset(x, v, sizeof(x))
#define left(x) 2*x
#define right(x) (2*x) + 1
#define ALL(t) (t).begin(),(t).end() 
#define ret return 0
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define rev(s) reverse(s.begin(),s.end())
#define WL(t) while(t --)
#define MOD 1000000007
int main()
{
      boost;
      int n,a;
      cin>>n>>a;
      int x=n%500;
      if(a>=x)
      {
            cout<<"Yes";
            return 0;
      }
      cout<<"No";
}

Measured memory_bytes: 256
N = int(input())
A = [int(_) for _ in input().split()]
num = [0]*(10**5+1)
for i in A:
    num[i] += 1

doub = 0
for i in num:
    if i > 0:
        doub += i-1

print(N-(doub+1)//2*2)

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

main(){
  int a,b;
  double a_d,b_d;
  cin >> a >> b;
  a_d = (double)a;
  b_d = (double)b;

  printf("%d %d %.5f\n",(a/b),(a%b),(a_d/b_d));
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int h, w;
    cin >> h >> w;
    vector<string> s(h);

    rep(i, h) cin >> s[i];

    cout << string(w + 2, '#') << endl;
    rep(i, h) cout << "#" << s[i] << "#" << endl;
    cout << string(w + 2, '#') << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF=INT_MAX;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))


int main(){
	int a,b,c;
	cin>>a>>b>>c;
	LL sum=c;
	int cnt=0;
	while(sum%(a+b)>a&&cnt<100000){
		sum+=60;cnt++;
	}
	if(cnt==100000)cout<<-1<<endl;
	else cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1160