akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<queue>
#include<iostream>
#include<algorithm>
#define pa pair<int,int>
using namespace std;
const int N=100010;
int n;
struct edg{
	int v,to,next;
}e[2*N];
int size,head[N];
priority_queue<pa,vector<pa>,greater<pa> >minn;
bool vis[N];
int dis[N]; 
void add(int x,int y,int v)
{
	size++;
	e[size].to=y;
	e[size].next=head[x];
	e[size].v=v;
	head[x]=size;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		add(i,(i+1)%n,1);
		add(i,(i*10)%n,0);
	}
	for (int i=0;i<=n;i++)
		dis[i]=1e9;
	dis[1]=1;
	minn.push(make_pair(0,1));
	while (!minn.empty())
	{
		int x=minn.top().second;
		minn.pop();
		if (vis[x]) continue;
		vis[x]=1;
		for (int i=head[x];i;i=e[i].next)
		{
			int y=e[i].to;
			if (dis[x]+e[i].v<dis[y])
				dis[y]=dis[x]+e[i].v,minn.push(make_pair(dis[y],y));
		}
	}
	printf("%d",dis[0]);
}

Measured memory_bytes: 4092
#!/usr/bin/env python3
#import sys; sys.stdin=open('input_file.txt')
#------------------------------------------
import numpy as np

N,M = map(int,input().split())
A = np.array(input().split(),np.int64)

A = np.sort(A)
S = np.zeros(N+1,np.int64)
S[1:]= np.cumsum(A)

hi = 200001
lo = -1

while hi-lo > 1:
    mid = (hi+lo)//2
    above_mid = (N-np.searchsorted(A,mid-A,side='left')).sum()
    if above_mid >= M:
        lo = mid
    else:
        hi = mid

X = np.searchsorted(A,hi-A,side='left')

above_hi = (N-X).sum()
happiness = (S[-1]-S[X]).sum()
happiness += (A*(N-X)).sum()
happiness += (M-above_hi)*lo

print(happiness)


Measured memory_bytes: 22612
s = int(input())
a = []
a.append(s)
for i in range(100000):
  if a[i] % 2 == 0:
    if a[i]//2 in a:
      print(i+2)
      break
    else:
      a.append(a[i]//2)
  else:
    if 3*a[i]+1 in a:
      print(i+2)
      break
    else:
      a.append(3*a[i]+1)

Measured memory_bytes: 3060
data = input()

sc = 0
ans = []
if (data[0] == data[1]) & (data[0] == data[2]):
    data = int(data)
    print(data)
elif int(data[0]) > int(data[1]):
    sc = int(data[0])
    ans = 100 * sc + 10 * sc + sc
    print(ans)
elif int(data[0]) == int(data[1]):
    if int(data[1]) > int(data[2]):
        sc = int(data[0])
        ans = sc * 100 + sc * 10 + sc
        print(ans)
    else :
        sc = int(data[0]) + 1
        ans = 100* sc + 10 * sc + sc
        print(ans)


        
else:
    sc = int(data[0]) + 1
    ans = 100* sc + 10 * sc + sc
    print(ans)


    
    


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

int main() {
  string s;
  cin >> s;
  int w = 0,b = 0;
  //w,b,w,b,w,...
  for(int i = 0;i < s.size();i++){
    if(i%2 == 0 && s.at(i) == '0'){
      w++;
    }
    if(i%2 == 1 && s.at(i) == '1'){
      w++;
    }
  }
  for(int i = 0;i < s.size();i++){
    if(i%2 == 0 && s.at(i) == '1'){
      b++;
    }
    if(i%2 == 1 && s.at(i) == '0'){
      b++;
    }
  }
  if(b > w){
    cout << w << endl;
  }
  else{
    cout << b << endl;
  }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
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; }

int k;
int main() {
    cin >> k;
    vector<int> a(32, 0);
    a[0] = 1;
    a[1] = 1;
    a[2] = 1;
    a[3] = 2;
    a[4] = 1;
    a[5] = 2;
    a[6] = 1;
    a[7] = 5;
    a[8] = 2;
    a[9] = 2;
    a[10] = 1;
    a[11] = 5;
    a[12] = 1;
    a[13] = 2;
    a[14] = 1;
    a[15] = 14;
    a[16] = 1;
    a[17] = 5;
    a[18] = 1;
    a[19] = 5;
    a[20] = 2;
    a[21] = 2;
    a[22] = 1;
    a[23] = 15;
    a[24] = 2;
    a[25] = 2;
    a[26] = 5;
    a[27] = 4;
    a[28] = 1;
    a[29] = 4;
    a[30] = 1;
    a[31] = 51;

    cout << a.at(k-1) << endl;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;
#define rep(i,s,e) for(int i = (int)(s); i < (int)(e); ++i)
#define per(i,s,e) for(int i = (int)(s)-1; i >= (int)(e); --i)

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n;cin >> n;
  vector<int> a(100001,0),b(100001,0);
  bool eq = true;
  rep(i,0,n){
    int x=0;int p = x;
    cin >> x;
    if(i&&p!=x)eq=false;
    if(i%2)b[x]++;
    else a[x]++;
    debug(x);
    debug(a[x]);
    debug(b[x]);
  }
  if(eq){cout << n/2 << endl; return 0;}
  int amax=0, bmax=0,ai,bi;
  rep(i,0,100001){    
    if(ChangeMax(bmax,b[i]))bi=i;
    if(ChangeMax(amax,a[i]))ai=i;
  }
  int asec=0,bsec=0,asi,bsi;
  rep(i,0,100001){
    if(bi!=i&&ChangeMax(bsec,b[i]))bsi=i;
    if(ai!=i&&ChangeMax(asec,a[i]))asi=i;
  }
  debug(amax);
  debug(bmax);
  debug(asec);
  debug(bsec);
  debug(ai);
  debug(bi);
  debug(asi);
  debug(bsi);
  if(ai==bi){
    if(amax+bsec>bmax+asec)bmax=bsec;
    else amax = asec;
  }
  cout << n-(amax+bmax) << endl;
  return 0;
}


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

double DP[2][3010][3010];
double val[2][3010];
int n;

double rec(int state,int index,int nyala,int mati)
{
	// cout << state << " " << index << " " << nyala << " " << mati << endl;
	if (DP[state][index][nyala] != -1.0) return DP[state][index][nyala];
	if (index == n)
	{
		if (mati >= nyala) return DP[state][index][nyala] = 0.0;
		// cout << state << " " << index << " " << nyala << " " << mati << " " ;
		return DP[state][index][nyala] = val[state][index];
	}
	double ret = 0.0;
	ret += val[state][index] * rec(state,index + 1,nyala + (state ^ 1),mati + (state));
	ret += val[state][index] * rec(state^1,index + 1,nyala + (state),mati + (state ^ 1));
	// cout << state << " " << index << " " << nyala << " " << ret << endl;
	return DP[state][index][nyala] = ret;
}

int main()
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(0);
	// cout.tie(0);
	cin >> n;
	for (int i = 1 ; i <= n ; i++)
	{
		cin >> val[0][i];
		val[1][i] = 1 - val[0][i];
	}
	for (int i = 0 ; i < 2 ; i++)
		for (int j = 1 ; j <= n ; j++)
			for (int k = 0 ; k <= n ; k++)
				DP[i][j][k] = -1.0;
	double ans = rec(0,1,1,0) + rec(1,1,0,1);
	printf("%.12lf\n", ans);
}

Measured memory_bytes: 141824
main :: IO ()
main = do
  x <- readLn
  print $ solve x

solve :: Int -> Int
solve x = head $ filter isPrime [x .. ]

isPrime :: Int -> Bool
isPrime x = all (\n -> x `mod` n /= 0) [2 .. y]
  where y = floor $ (sqrt (fromIntegral x) :: Double)


Measured memory_bytes: 508
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize
    }
    let mut m = n;
    let mut s = 0;
    while m > 0 {
        s += m % 10;
        m /= 10;
    }
    println!("{}", if n % s == 0 {"Yes"} else {"No"});
}


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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, K;
  cin >> N >> K;

  if ( (N-1)*(N-2)/2 < K ) {
    cout << -1 << endl;
    return 0;
  }

  using P = pair<int, int>;
  vector<P> ans;
  for ( int i = 1; i < N; i++ ) {
    ans.push_back(P(0, i));    
  }
  int now = (N-1)*(N-2)/2;
  for ( int i = 1; i < N; i++ ) {
    for ( int j = i+1; j < N; j++ ) {
      if ( now == K ) {
	i = N;
	break;
      }
      now--;
      ans.push_back(P(i, j));      
    }
  }

  cout << ans.size() << endl;
  for ( P p : ans ) cout << p.first+1 << " " << p.second+1 << endl;
  
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

int main(){
    ll A, B, N; cin >> A >> B >> N;
    ll x = N;
    if (N >= B-1) x = B-1;
    ll ans = A*x/B - A*(x/B);
    cout << ans << endl;

}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <set>
#include <climits>
#include <map>

using namespace std;

long long x[1000];
long long y[1000];
long long z[1000];

int x_coeffs[2] = {-1, 1};
int y_coeffs[2] = {-1, 1};
int z_coeffs[2] = {-1, 1};

int main(){
  int N;
  int M;
  cin >> N >> M;
  for(int i = 0; i < N; i++){
    cin >> x[i] >> y[i] >> z[i];
  }

  long long ans = 0;
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < 2; j++){
      for(int k = 0; k < 2; k++){
        vector <long long> item_values;
        for(int l = 0; l < N; l++){
          long long item_val = x_coeffs[i] * x[l] + y_coeffs[j] * y[l] + z_coeffs[k] * z[l];
          item_values.push_back(item_val);
        }
        sort(item_values.begin(), item_values.end(), greater<long long>());

        long long tmp_ans = 0;
        for(int l = 0; l < M; l++){
          tmp_ans += item_values[l];
        }
        ans = max(ans, tmp_ans);
      }
    }
  }

  cout << ans << endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if ((b -1) % (a-1) == 0){
    cout << (b -1) / (a-1) << endl;
  }
  else{
    cout << (b -1) / (a-1) + 1<< endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i, n) for (int i=0; i<(int) (n);i++)
using ll = long long;
using P = pair<int,int>;

void solve_A(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int ans = - h1*60 - m1 + h2*60 + m2 -k;
    cout << ans;
    
}

void solve_B(){
    string t;
    cin >> t;
    rep(i, t.size()){
        if(t[i] == '?'){
            t[i] = 'D';
        }
    }
    cout << t;
}

void solve_C(){
    
}

void solve_D(){
    
}

void solve_E(){
    
}

void solve_F(){
    
}

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

Measured memory_bytes: 3732
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4 2
1 3
2 4"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """10 3
3 6
5 7
6 9"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """100000 1
1 100000"""
        output = """100000"""
        self.assertIO(input, output)
def resolve():
    (N,M)=(int(i) for i in input().split())
    ll=[]
    rr=[]
    for i in range(M):
        (l,r)=(int(i) for i in input().split())
        ll.append(l)
        rr.append(r)
    lm=max(ll)
    rm=min(rr)
    if lm>rm:
        print(0)
        return
    if N>=rm:
        print(1+rm-lm)
    elif N>=lm:
        print(1+N-lm)
    else:
        print(0)
if __name__ == "__main__":
    resolve()

Measured memory_bytes: 13896
#include <bits/stdc++.h>
#include <iterator>
#include <tuple>
using namespace std;
using ll = long long;

int main()
{
  int n;
  cin >> n;
  vector<ll> a;
  a.push_back(0);
  for (int i = 0; i < n; ++i)
  {
    int tmp;
    cin >> tmp;
    a.push_back(tmp + a[i]);
  }

  unordered_map<ll, ll> t;
  for (int i = 0; i < a.size(); ++i)
  {
    t[a[i]]++;
  }

  ll sum = 0;
  for (auto &e : t)
  {
    sum += e.second * (e.second - 1) / 2;
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 10096
using System;
using System.Collections.Generic;


namespace ConsoleApplication8
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int W = int.Parse(str[0]);
            int H = int.Parse(str[1]);
            int x = int.Parse(str[2]);
            int y = int.Parse(str[3]);
            int r = int.Parse(str[4]);
            

            if (x - r >= 0 && x + r <= W && y + r >= 0 && y + r <= H)
            {
                Console.WriteLine("Yes");
            }
            if (x - r < 0 || x + r > W || y - r < 0 || y + r > H)
            {
                Console.WriteLine("No");
            }

        }
    }
}

Measured memory_bytes: 8996
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#define debug(x) cout<<"***"<<x<<"***"<<endl;
using namespace std;
int main()
{
	int n,map[105],tmp=1;
	cin>>n;
	memset(map,0,sizeof(map));
	for (int i=1;i<=100;i=i*2)
	{
		map[i]=1;
	}
	for (int i=n;i>=1;i--)
	{
		if (map[i]==1)
		{
			cout<<i;
			break;
		}
	}
	return 0;
}
	

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

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) cin >> s[i];

    for (int i = 0; i < n; i++) sort(s[i].begin(), s[i].end());
    sort(s.begin(), s.end());

    vector<string*> sp(n);
    sp[0] = &s[0];
    for (int i = 1; i < n; i++) {
        if (s[i] == s[i-1]) sp[i] = sp[i-1];
        else sp[i] = &s[i];
    }

    long long cnt = 0;
    long long over = 0;
    for (int i = 1; i < n; i++) {
        if (sp[i] == sp[i-1]) {
           over++;
        }else {
           for (int j = 1; j <= over; j++) {
               cnt += j;
           }
           over = 0;
       }
    }
    for (int j = 1; j <= over; j++) {
        cnt += j;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 8064
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a==b)cout<<"Draw"<<endl;
  else if(a==1&&b!=1||a!=1&&b!=1&&a>b)cout<<"Alice"<<endl;
  else if(a!=1&&b==1||a!=1&&b!=1&&a<b)cout<<"Bob"<<endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

// 立っているビット数を求める (int)
inline int bit_count(int n){
  n=((n>>1)&0x55555555)+(n&0x55555555);
  n=((n>>2)&0x33333333)+(n&0x33333333);
  n=((n>>4)&0x0f0f0f0f)+(n&0x0f0f0f0f);
  n=((n>>8)&0x00ff00ff)+(n&0x00ff00ff);
  n=((n>>16)&0x0000ffff)+(n&0x0000ffff);
  return n;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, a[20], x[20][20], y[20][20];
  cin>>n;
  REP(i, n){
    cin>>a[i];
    REP(j, a[i]){
      cin>>x[i][j]>>y[i][j];
      --x[i][j];
    }
  }
  int ans=0;
  REP(i, 1<<n){
    int num[20];
    REP(j, n){
      num[j]=-1;
    }
    bool ok=true;
    REP(j, n){
      if(i>>j&1){
        REP(k, a[j]){
          if(i>>x[j][k]&1){
            if(!y[j][k]){
              ok=false;
            }
          }
          else{
            if(y[j][k]){
              ok=false;
            }
          }
          if(num[x[j][k]]==-1){
            num[x[j][k]]=y[j][k];
          }
          else if(num[x[j][k]]!=y[j][k]){
            ok=false;
          }
        }
      }
    }
    if(ok){
      CHMAX(ans, bit_count(i));
    }
  }
  cout<<ans<<'\n';
  return 0;
}

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

int main() {
	int i = 0,j,N=0,t,a=0;
	string S;
	cin >> S;
	
	while (1) {
		if (S[N] == '\0') {
			break;
		}
		N++;
	}
	/*for (i = 0; i < N - 1; i++) {
		for (j = 0; j < N - 1; j++) {
			if (S[j] > S[j+1]) {
				t = S[j];
				S[j] = S[j + 1];
				S[j + 1] = t;
			}
		}
	}*/
	t = 97;
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			if (S[j] == 97 + i) {
				t = 98 + i;
			}
		}
		if (t == 123) {
			break;
		}
		else if (t != 98 + i) {
			a = 1;
			break;
		}
		
	}
	if (t == 123) {
		printf("None");
	}
	else if (a = 1) {
		printf("%c", t);
	}
	//else {
		//printf("None");
	//}
	cin >> a;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//arc072_c
//偶数番目が負の場合と奇数番目が負の場合
//和の符号が異なる点に注意
//どっちもやってみてminをとる
int main(){
  ll N,res;
  cin >> N;

  vector <ll> a(N+1);
  a[0] = 0;
  for(ll i = 1; i <= N; ++i)
  {
    cin >> a[i];
  }

  //偶数
  ll evenCnt = 0;
  ll koremadewa = 0;
  for(ll i = 1; i <= N; ++i)
  {
    koremadewa += a[i];
    if(i % 2 == 0)
    {
      //負
      if(koremadewa >= 0)
      {
        evenCnt += abs(koremadewa) + 1;
        koremadewa = -1;
      }
    }
    else
    {
      if(koremadewa <= 0)
      {
        evenCnt += abs(koremadewa) + 1;
        koremadewa = 1;
      }
    }
  }


  //奇数
  ll oddCnt = 0;
  koremadewa = 0;
  for(ll i = 1; i <= N; ++i)
  {
    koremadewa += a[i];
    if(i % 2 == 1)
    {
      //負
      if(koremadewa >= 0)
      {
        oddCnt += abs(koremadewa) + 1;
        koremadewa = -1;
      }
    }
    else
    {
      if(koremadewa <= 0)
      {
        oddCnt += abs(koremadewa) + 1;
        koremadewa = 1;
      }
    }
  }

  res = min(evenCnt,oddCnt);

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 1024
s = str(input())

n = len(s)-1
ans = 0
for i in range(2**n):
    op = [""]*n
    for j in range(n):
        if (i>>j)&1:
            op [n - 1 - j] = "+"
    formula = ""
    for p1 ,p2 in zip(s, op + [""]):
        formula += (p1 + p2)
    ans += eval(formula)

print(ans)
  
        


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

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

    if(s == "MON"){
        cout << 6 << endl;
    }
    else if (s == "TUE")
    {
        cout << 5 << endl;
    }
    else if (s == "WED")
    {
        cout << 4 << endl;
    }
    else if (s == "THU")
    {
        cout << 3 << endl;
    }
    else if (s == "FRI")
    {
        cout << 2 << endl;
    }
    else if (s == "SAT")
    {
        cout << 1 << endl;
    }
    else if (s == "SUN")
    {
        cout << 7 << endl;
    }
}


Measured memory_bytes: 256
import sys
import math
import itertools
import collections
from collections import deque
from collections import defaultdict

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD2 = 998244353
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():

    N, M = NMI()
        
    PY = [[m,NLI()] for m in range(M)]
    
    PY = list(sorted(list(sorted(PY,key = lambda x : x[1][1])),key = lambda x : x[1][0]))
    

    
    city = PY[0][1][0]
    cnt = 0

    for m in range(M):
        if PY[m][1][0] == city:
            cnt += 1
        else:
            city = PY[m][1][0]
            cnt = 1
            
        PY[m][1] = str(PY[m][1][0]).zfill(6) + str(cnt).zfill(6)
    
    PY = list(sorted(PY))
    
    
    for m in range(M):
        print(PY[m][1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 41544
#include<bits/stdc++.h>
using namespace std;
map<string,int> ma;

int main(){
    int n;
    cin >> n;
    int v =-1e8;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        ma[s]++;
        v =max(v,ma[s]);
    }
    for(auto it:ma){
        if(it.second == v ) cout<<it.first<<endl;
    }
    return 0;
}


Measured memory_bytes: 25216
n, d = [int(x) for x in input().split()]
dist = lambda x, y : (x * x + y * y) ** 0.5
cnt = 0
for _ in range(n):
    a, b = [int(x) for x in input().split()]
    has_d = dist(a, b)
    cnt += has_d <= d
print(cnt)


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

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    h, w = list(map(int, input().split()))
    board = [list(map(str, input())) for _ in range(h)]
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    for i in range(h):
        for j in range(w):
            if board[i][j] == '#':
                count = 0

                for k in range(len(dx)):
                    x = i + dx[k]
                    y = j + dy[k]

                    if (x >= 0) and (x < h) and (y >= 0) and (y < w) and (board[x][y] == "#"):
                        count += 1

                if count == 0:
                    print('No')
                    exit()

    print('Yes')


Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
	int sh,sm,ss,eh,em,es;
	int h,m,s,i;
	for(i=0;i<3;i++){
	scanf("%d %d %d %d %d %d",&sh,&sm,&ss,&eh,&em,&es);
	if(es<ss){em=em-1;es=es+60;}
	s=es-ss;
	if(em<sm){eh=eh-1;em=em+60;}
	m=em-sm;
	h=eh-sh;
	printf("%d %d %d\n",h,m,s);
	}

	return 0;
}

Measured memory_bytes: 1816
MOD = 10 ** 9 + 7
S = input()
dp = [[0] * 13 for _ in range(len(S) + 1)]
dp[0][0] = 1

for i in range(len(S)):
    tmpS = 0
    if S[i] == '?':
        tmpS = -1
    else:
        tmpS = int(S[i])
    for j in range(10):
        if tmpS != -1 and tmpS != j: continue
        for k in range(13):
            dp[i + 1][(k * 10 + j) % 13] += dp[i][k]
            dp[i + 1][(k * 10 + j) % 13] %= MOD

print(dp[len(S)][5])

Measured memory_bytes: 95744
n = int(input())
t, x, y = 0, 0, 0
ans = "Yes"
for i in range(1, n+1):
  ti, xi, yi = map(int, input().split())
  displacements = (xi - x) + (yi - y)
  dist = abs(displacements)
  dt = ti - t
  if dt >= dist and (dt - dist) % 2 == 0:
    t, x, y = ti, xi, yi
  else:
    ans = "No"
    break

print(ans)

Measured memory_bytes: 3064
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    int n = sc.nextInt();
    int[] arr = new int[100001];

    arr[0] = 0;
    for(int i = 0; i <= 100000; i++){
      arr[i] = i;
    }
    int coinnum = 6;
    for(; coinnum <= 100000; coinnum = coinnum * 6){
      for(int j = 0; j + coinnum <= 100000; j++){
        if(arr[j + coinnum] > arr[j] + 1){
          arr[j + coinnum] = arr[j] + 1;
        }
      }
    }

    coinnum = 9;
    for(; coinnum <= 100000; coinnum = coinnum * 9){
      for(int j = 0; j + coinnum <= 100000; j++){
        if(arr[j + coinnum] > arr[j] + 1){
          arr[j + coinnum] = arr[j] + 1;
        }
      }
    }

    System.out.println(arr[n]);
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	string s1;
	cin>>s>>s1;
	int ans=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]==s1[i])
		{

		}
		else
		{
			ans=ans+1;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 3820
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>

#define ll long long

using namespace std;

int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<char>> a(H,vector<char>(W));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> a[i][j];
        }
    }
    vector<int> H_m;
    vector<int> W_m;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(a[i][j]=='#'){
                H_m.push_back(i);
                W_m.push_back(j);
            }
        }
    }
    sort(H_m.begin(),H_m.end());
    sort(W_m.begin(),W_m.end());
    for(int i=0;i<H_m.size();i++){
        for(int j=0;j<W_m.size();j++){
            while(i!=H_m.size()-1&&H_m[i]==H_m[i+1]){
                i++;
            }
            while(j!=W_m.size()&&W_m[j]==W_m[j+1]){
                j++;
            }
            cout << a[H_m[i]][W_m[j]];
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 384
// ABC088D
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <map>
#include <functional>
#include <set>
#include <iterator>
#include <queue>

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

int N, M;
int p[100010];
int x[100010];
int y[100010];

int par[100010];
int trank[100010];

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

int main() {
   cin >> N >> M;
   init(N+1);
   for (int i=1;i<=N;i++) {
      cin >> p[i];
   }
   for (int i=0;i<M;i++) {
      int a, b;
      cin >> a >> b;
      unite(a, b);
   }
   int ans = 0;
   for (int i=1;i<=N;i++) {
      if (same(p[i], i)) {
         ans++;
      }
   }
   printf("%d", ans);
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    string S;
    cin >> S;
    int len = S.size();
    bool dance = true;
    for (int i = 0; i < len; i += 2){
        if (S[i] == 'L'){
            dance = false;
        }
    }
    for (int i = 1; i < len; i += 2){
        if (S[i] == 'R'){
            dance = false;
        }
    }
    if (dance){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
int main() {
    int N,Q;
    string Str;
    cin >> N >> Q >> Str;
    vector<int>S(N+1, 0);
    rep(i, 0, N){
        if(i+1<N && Str[i] == 'A' && Str[i+1] == 'C'){
            S[i+1] = S[i]+1;
        } else {
            S[i+1] = S[i];
        }
    }
    rep(i, 0, Q){
        int l,r;
        cin >> l >> r;
        l--;
        r--;
        cout << S[r] - S[l] << endl;
    }
    
    return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long A, long long B, long long C){
    VLL memo;
    memo.PB(A);
    memo.PB(B);
    memo.PB(C);

    sort(ALL(memo));

    LL ans = memo[2] - memo[1] + memo[2] - memo[0];
    if(ans % 2 == 1) ans+=3;
    cout << ans / 2 << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
int a[200010];
bool used[200010] = {};
int main(){
  int n, x;
  cin >> n >> x;
  if (x == 1 || x == 2 * n - 1) {
    puts("No");
    return 0;
  } else {
    puts("Yes");
  }
  if (x == 2 && n == 2) {
    cout << "1\n2\n3\n";
    return 0;
  }
  a[n - 1] = x;
  used[x] = true;
  a[n] = x + 1;
  used[x + 1] = true;
  if (x != 2) {
    a[n - 2] = x - 2;
    used[x - 2] = true;
    a[n + 1] = x - 1;
    used[x - 1] = true;
  } else {
    a[n + 1] = 5;
    used[5] = true;
    a[n - 2] = 1;
    used[1] = true;
  }
  int num = 1;
  for (int i = 0; i < 2 * n - 1; i++) {
    if (n - 2 <= i && i <= n + 1) continue;
    if (!used[num]) {
      a[i] = num;
      num++;
    } else {
      while (used[num]) {
        num++;
      }
      a[i] = num;
      num++;
    }
  }
  for (int i = 0; i < 2 * n - 1; i++) {
    cout << a[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 2304
#include <stdio.h>
#include <memory.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
int main(void){
  char str[256];
  int len, i;
  scanf("%s", str);
  len = strlen(str);
  for (i=0;i<len;i++){
    str[i] = 'x';
  }
  printf("%s", str);
  return 0;
}

Measured memory_bytes: 128
N = int(input())
T, A = [int(s) for s in input().rstrip().split()]
H = [int(s) for s in input().rstrip().split()]

temp = [T - x * 0.006 for x in H]
diff = [abs(A - temp[0])]
diff_min = diff[0]
ans = 0
for n in range(1, N):
    new_diff = abs(A - temp[n])
    if new_diff < diff_min:
        ans = n
        diff_min = new_diff
    diff.append(new_diff)

print(ans + 1)

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

int q(const int *a,const int *b)
{
    return *a-*b;
}

int main(void)
{
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d",(a-1)*(b-1));
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int>VI;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define fi first
#define se second
#define MAX 100100//5
#define MAX_N 200100
#define MAX_B 1001001//6
#define MAX_S 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1 << 29
#define INFTY 1000000000000000000LL
#define MAX_INT INT_MAX


int main(){

    int r,d,x;cin>>r>>d>>x;
    rep(i,10){
        x=r*x-d;
        cout<<x<<endl;
    }
}

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

ll K;

void solve(){
	printf("50\n");
	if(K % 50 == 0){
		ll num = (K / 50) + 49;
		for(int i = 1; i <= 50; i++){
			printf("%lld", num);
			if(i == 50) printf("\n");
			else printf(" ");
		}
	}else{
		ll num1 = 100 + (K / 50) - (K % 50);
		ll num2 = num1 - 51;
		for(int i = 1; i <= K % 50; i++){
			printf("%lld ", num1);
		}
		for(int i = K % 50 + 1; i <= 50; i++){
			printf("%lld", num2);
			if(i == 50) printf("\n");
			else printf(" ");
		}
	}
}

int main(){
	scanf("%lld", &K);
	solve();
	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
#define v1out(v) FOR(j,0,v.size()){cout<<v[j]; if(j!=(ll)v.size()-1)cout<<" ";else cout<<endl; }
#define v2out(v) FOR(i,0,v.size())v1out(v[i]);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin>>x;
    ll ans=0;
    FOR(i,1,x+1){
        if(i%3!=0 && i%5!=0) ans+=i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <math.h>
#define rep(i) for (i = 0; i < 3; i++)
#define PI 3.1415926535

int main(void) {
    long double a, b, C;
    long double answers[3] = {};
    long double c, rad;
    int i;

    scanf("%Lf %Lf %Lf", &a, &b, &C);

    rad = C * PI / 180.0;
    answers[2] = b * sin(rad);

    c = sqrt((a*a) + (b*b) - (2*a*b*cos(rad)));

    answers[0] = a * answers[2] * 0.5;
    answers[1] = a + b + c;

    rep(i) printf("%Lf\n", answers[i]);
    return 0;
}


Measured memory_bytes: 2056
n = int(input())
s = input()
ans = 0
for i in range(1,n):
    x = list(set(s[:i]))
    y = list(set(s[i:]))
    count = 0
    for j in range(len(x)):
        if x[j] in y:
            count += 1
    ans = max(ans, count)
print(ans)


Measured memory_bytes: 3060
A=int(input())
B=int(input())
C=int(input())
X=int(input())

ans=0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i+100*j+50*k==X:
        ans+=1
print(ans)

Measured memory_bytes: 3064
const selectionSort = (n, a) => {
  let counter = 0;
  for (let i = 0; i < n; i++) {
    minIndex = i;
    for (let j = i; j < n; j++) {
      if (a[minIndex] > a[j]) {
        minIndex = j;
      }
    }
    if (minIndex != i) {
      let tmp = a[minIndex];
      a[minIndex] = a[i];
      a[i] = tmp;
      counter += 1;
    }
  }
  console.log(a.join(" "));
  console.log(counter);
};

process.stdin.resume();
process.stdin.setEncoding("utf8");
let input_string = "";

process.stdin.on("data", chunk => {
  input_string += chunk;
});

process.stdin.on("end", () => {
  const lines = input_string.split("\n").filter(v => {
    return v !== "";
  });
  selectionSort(lines[0], lines[1].split(" ").map(i => parseInt(i, 10)));
});



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

long long A, B;
bool ban[100][100];

int main(){
	cin >> A >> B;

	for(long long i = 0; i < 50; i++){
		for(long long j = 0; j < 100; j++){
			ban[i][j] = true;
		}
	}
	A--;B--;

	long long y = 0;
	long long x = 0;
	while(A){
		A--;
		ban[y][x] = false;
		x+=2;
		if(x >= 100){
			y += 2;
			x = 0;
		}
	}

	y = 51;
	x = 0;
	while(B){
		B--;
		ban[y][x] = true;
		x+=2;
		if(x >= 100){
			y += 2;
			x = 0;
		}
	}


	cout << "100 100" << endl;
	for(long long i = 0; i < 100; i++){
		for(long long j = 0; j < 100; j++){
			if(ban[i][j]){
				cout << "#";
			}else{
				cout << ".";
			}
		}
	cout << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int x=scan.nextInt();
		int y=scan.nextInt();

		int[] unit = new int[13];
		unit[1]=unit[3]=unit[5]=unit[7]=unit[8]=unit[10]=unit[12]=1;
		unit[4]=unit[6]=unit[9]=unit[11]=2;
		unit[2]=3;


		if(unit[x]==unit[y]){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll x;cin>>x;
  ll ans=0;
  while(x>=5){
    if(x/500>=1)ans+=1000*(x/500),x-=(x/500)*500;
    else if(x/5>=1)ans+=5*(x/5),x-=(x/5)*5;
  }

  out(ans);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main() {
    int n;
    cin >> n;
    int a[2*n];
    for(int i=0; i<2*n; i++) cin >> a[i];
    sort(a, a+2*n);
    int b = 0;
    for(int i=0; i<2*n; i+=2) b += min(a[i], a[i+1]);
    cout << b << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input(''))
s=input('')
s=s.split(' ')
p=1
f=0
t=0

for a in range(n):
    s[a]=int(s[a])

for b in s:
    if b==0:
        t=1

if t==1:
    print(0)
else:
    for a in range(n):
        p=p*s[a]

        if p>10**18:
            f=1
            break


    if f==1:
        print(-1)
    else:
        print(p)


Measured memory_bytes: 19492
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        A: i64,
        B: i64,
        C: i64,
    }
    println!("{}",min(C, B/A));
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
using namespace std;

int main(int argc, char const *argv[]) {

  int N, K;

  scanf("%d %d", &N, &K);

  if(N+1 >= 2*K) printf("YES");
  else printf("NO");

  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#define MAXSIZE 100000

int head = 0;       //キューの先頭
int tail = 0;       //キューの最後
int n=0;
typedef struct Process{
  char name[10];
  int time;
}P;
P p[MAXSIZE];
void enq(P x) {
  p[tail]=x;
  tail=(tail+1)%MAXSIZE;
}

P deq() {
  P x=p[head];
  head=(head+1)%MAXSIZE;
  return x;
}
int min(int x,int y){
  if(x>y)return y;
  else return x;
}
  int main(){
    int i,n,q,t,e=0;
    P pp;
    scanf("%d %d",&n,&q);
    for(i=0;i<n;i++){
      scanf("%s%d",p[i].name,&p[i].time);
    }
    head=0;
    tail=n;
    while(head!=tail){
      pp=deq();
      t=min(q,pp.time);
      pp.time-=t;
      e+=t;
      if(pp.time>0)enq(pp);
      else{
	printf("%s %d\n",pp.name,e);
      }
    }
    return 0;
  }
    



Measured memory_bytes: 3272
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type& a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	string s,t;
	cin>>s>>t;
	
	int cnt=0;
	REP(i,3) if(s[i]==t[i]) cnt++;
	
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
from fractions import gcd

N, K = map(int, input().split())
A = list(map(int, input().split()))

g = A[0]
for a in A[1:]:
    g = gcd(a, g)

if max(A) >= K and K % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 16240
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int a,b,c,d,e; cin >>a >>b >>c >>d >>e;
  int res = 15 - a - b - c - d - e;
  cout <<res <<endl;
}

Measured memory_bytes: 3600
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int fun(vector<int> &x, int p) {
	int sum = 0;

	for (int i = 0; i < (int) x.size(); ++i) {
		sum += (x[i] - p) * (x[i] - p);
	}

	return sum;
}

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

	vector<int> x(n);

	for (int i = 0; i < n; ++i) {
		cin >> x[i];
	}

	int ans = INF;

	for (int i = 1; i < 101; ++i) {
		ans = min(ans, fun(x, i));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int inf = 1e9;
const int mod = 1e9+7;
const ll linf = 1e18;

int main()
{
    ll h,w;cin>>h>>w;
    ll first = ceil( (double) w/2);
    ll second = floor(w/2);
    ll ans = 0;


    if(h%2 == 0){
        ans += first*( h/2 )+ second *( h/2 );
    }else{
        ans += first*( (h-1)/2 ) + second *( (h-1)/2 ) ;
        ans += first;
    }

    if(h == 1 || w == 1) ans = 1;

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

Measured memory_bytes: 256