akhauriyash/Code-Regression huggingface dataset:
# Date [ 2020-08-22 21:03:51 ]
# Problem [ c.py ]
# Author Koki_tkg

import sys;      from decimal import Decimal
import math;     from itertools import combinations, product
import bisect;   from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b)

def Main():
    n = read_int()
    a = read_int_list()
    ans = 0
    
    for i in range(1, n):
        if a[i] < a[i - 1]:
            ans += a[i - 1] - a[i]
            a[i] = a[i - 1]
    
    print(ans)


if __name__ ==  '__main__':
    Main()

Measured memory_bytes: 34208
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - Handshake
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_A = 100000;

/* typedef */

typedef long long ll;
typedef pair<ll,ll> pll;

/* global variables */

int as[MAX_N];
ll ass[MAX_N + 1];

/* subroutines */

ll check(int n, int b) {
  ll cnt = 0;
  for (int i = 0; i < n; i++) {
    int k = lower_bound(as, as + n, b - as[i]) - as;
    cnt += (n - k);
  }
  return cnt;
}

pll cntsum(int n, int b) {
  ll cnt = 0, sum = 0;
  for (int i = 0; i < n; i++) {
    int k = lower_bound(as, as + n, b - as[i]) - as;
    cnt += n - k;
    sum += ass[n] - ass[k] + (ll)(n - k) * as[i];
  }
  return pll(cnt, sum);
}

/* main */

int main() {
  int n;
  ll m;
  scanf("%d%lld", &n, &m);

  for (int i = 0; i < n; i++) scanf("%d", as + i);
  sort(as, as + n);
  //for (int i = 0; i < n; i++) printf("%d ", as[i]); putchar('\n');

  for (int i = 0; i < n; i++) ass[i + 1] = ass[i] + as[i];

  int b0 = 0, b1 = MAX_A * 2 + 1;
  while (b0 + 1 < b1) {
    int b = (b0 + b1) / 2;
    if (check(n, b) >= m) b0 = b;
    else b1 = b;
  }

  pll p0 = cntsum(n, b0);
  pll p1 = cntsum(n, b1);
  ll c0 = p0.first, s0 = p0.second;
  ll c1 = p1.first, s1 = p1.second;
  //printf("b0=%d, cnt=%lld, sum=%lld\n", b0, c0, s0);
  //printf("b1=%d, cnt=%lld, sum=%lld\n", b1, c1, s1);

  ll s = (s0 - s1) / (c0 - c1) * (m - c1) + s1;
  printf("%lld\n", s);
  return 0;
}


Measured memory_bytes: 1408
from collections import Counter
h, w = map(int, input().split())
a = ''
for i in range(h):
    a += input()
c = Counter(a).values()
m1 ,m2 = 0, 0
for i in c:
    if i%2:
        m1 += 1
    elif i%4 == 2:
        m2 += 1
g1 = h%2 * w%2
g2 = h%2*(w//2) + w%2*(h//2)
# g4 = w//2 * h//2
if m1 <= g1 and m2 <= g2:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3316
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    bool po = true;
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
        if (A[i]%2 == 0){
            if ((A[i]%3 != 0) && (A[i]%5 != 0)){
                po = false;   
            }
        }
    }
    if (po==true)
    {
        cout << "APPROVED";
    }else{
        cout << "DENIED";
    }
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin >> n >> k;
    map<int,int> m;
    rep(i,n) {
        int a;
        cin >> a;
        m[a]++;
    }
    vector<int> v;
    for(auto p : m) v.pb(p.second);
    int ans = 0;
    sort(all(v));
    if(v.size() > k)rep(i,v.size()-k) ans += v[i];
    cout << ans << endl;
}


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

char a[100],b[100];

int main()
{
	scanf("%s",a);
	scanf("%s",b);
	for(int i = 0;a[i] != '\0';++i)
		if(a[i] != b[i]){
			cout<<"No"<<endl;
			return 0;
		}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 3768
#include<cstdio>
using namespace std;
int a[50],b[50],n,ans,s;
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(int i=0;i<n;i++)
		scanf("%d",&b[i]);
	for(int i=0;i<(1<<n);i++)
	{
		s=0;
		for(int j=0;j<n;j++)
			if(i&(1<<j))s+=a[j]-b[j];
		ans=ans>s?ans:s;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <iostream>
#include <vector>
#include <list>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <complex>

#define MAX_N 1000001
#define INF 987654321
using namespace std;
typedef long long lld;
typedef unsigned long long llu;

int main(){

	int a,b;

	cin>>a>>b;

	if(2*b>=a)
		cout<<"0";
	else
		cout<<a-2*b;

	return 0;
}

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

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

def check():
    count = 0
    for i in range(N):
        if A[i][0] == A[i][1]:
            count+=1
        else:
            count=0
            continue
        if count >=3:
            print("Yes")
            return
    print("No")

check()

Measured memory_bytes: 9188
'use strict';
(function(stdin) {

  var inputs  = stdin.toString().trim().split('\n');
  var cols = inputs[0].split(' ');
  var a = parseInt(cols[0], 10);
  var b = parseInt(cols[1], 10);
  var c = parseInt(cols[2], 10);

function f(a,b,c){return a<b && b<c ? 'Yes' : 'No';}

console.log(f(a,b,c));
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15524
import java.util.Scanner;

/**
 * Created by Santa on 2016/10/16.
 */
public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int a[][] = new int[2][N];
        int map[][] = new int[2][N];

        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < N; j++) {
                a[i][j] = scanner.nextInt();
            }
        }

        for (int i = 0; i < N - 1; i++) {
            a[0][i + 1] += a[0][i];
        }

        a[1][0] += a[0][0];
        for (int i = 0; i < N - 1; i++) {
            a[1][i + 1] += Math.max(a[1][i], a[0][i + 1]);
        }

        System.out.println(a[1][N - 1]);


    }


}



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

int main(){
	int n;
	cin >> n;
	double v[n];
	for(int i = 0;i < n;i++) cin >> v[i];
	sort(v,v+n);
	for(int i = 1;i < n;i++){
		v[i] =(double)(v[i]+v[i-1])/2.0;
	}
	cout << v[n-1];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define mx INT_MAX
#define mn INT_MIN
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define itr set<int> :: iterator
#define map_it map<int,int> :: iterator
const int mod = 1e9+7;

vector<int> adj[100001];
ll dp[100001][2];

void dfs(int v , int par){
  
  dp[v][0] = 1;
  dp[v][1] = 1;
  for(int u = 0; u<adj[v].size(); u++){
      int child = adj[v][u];
      if(child==par)
        continue;

      dfs(child, v);
      dp[v][0] = (dp[v][0]* (dp[child][0] + dp[child][1])%mod)%mod;
      dp[v][1] = (dp[v][1]* dp[child][0])%mod;
  }
   
  return;
}

int main(){

    // ******* START HERE ******
    
    int n;
    cin>>n;
    
    for(int i=0; i<n-1; i++){
      int x,y;
      cin>>x>>y;
      adj[x].pb(y);
      adj[y].pb(x);
    }
    
    dfs(1, -1);
    int res = (dp[1][0] + dp[1][1])%mod;
    cout<<res<<endl;
    // ***** END HERE ***** 
    return 0;
}


Measured memory_bytes: 17348
M = 10**9 + 7
N, A, AB, ABC = 1, 0, 0, 0
idx = {'A': 1, 'B': 2, 'C': 3}
for c in input():
    if c == '?':
        ABC = (ABC * 3 + AB) % M
        AB = (AB * 3 + A) % M
        A = (A * 3 + N) % M
        N = (N * 3) % M
    elif c == 'A':
        A += N
    elif c == 'B':
        AB += A
    else:
        ABC += AB
print(ABC % M)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1e9 + 7;
const int MAXN = 1e5 + 5;
vector<int> adj[MAXN];
int n;
// col = 0 for parent = b,col = 1 for parent = w
// root ka col = 1
int dp[MAXN][2];
ll dfs(int curr,int p,int col) {
    if(dp[curr][col]!= 0) return dp[curr][col];
    // printf("%d %d %d\n",curr,p,col);
    ll ans = 1;
    ll prod1 = col;
    ll prod2 = 1;
    for(auto it: adj[curr]) {
        if(it != p) {
            if(col == 1) {
                prod1 = (prod1*dfs(it,curr,0))%mod;
                prod2 = (prod2*dfs(it,curr,1))%mod;
            } else {
                prod2 = (prod2*dfs(it,curr,1))%mod;
            }
        }
    }
    ans = (prod1 + prod2)%mod;
    return dp[curr][col] = ans;
}
int main() {
    cin>>n;
    int u,v;
    for(int i =0;i<n-1;i++) {
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    cout<<dfs(1,0,1)<<"\n";

}

Measured memory_bytes: 18188
N = int(input())
dp = [[0]*N for _ in range(3)]

a, b, c = map(int, input().split())
dp[0][0] = a
dp[1][0] = b 
dp[2][0] = c

for i in range(N-1):
    a, b, c = map(int, input().split())
    dp[0][i+1] = max(dp[1][i], dp[2][i]) + a
    dp[1][i+1] = max(dp[0][i], dp[2][i]) + b
    dp[2][i+1] = max(dp[0][i], dp[1][i]) + c

print(max([dp[0][-1], dp[1][-1], dp[2][-1]]))

Measured memory_bytes: 20872
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll N;
    string S;
    cin >> N >> S;
    vector<ll> R(N), G(N), B(N);
    vector<ll> Rsum(N + 1), Gsum(N + 1), Bsum(N + 1);
    rep(i, N) {
        if(S[i] == 'R')
            R[i]++;
        if(S[i] == 'G')
            G[i]++;
        if(S[i] == 'B')
            B[i]++;
    }
    rep(i, N) {
        Rsum[i + 1] = R[i] + Rsum[i];
        Gsum[i + 1] = G[i] + Gsum[i];
        Bsum[i + 1] = B[i] + Bsum[i];
    }
    ll res = 0;
    for(int i = 0; i < N - 2; i++) {
        for(int j = i + 1; j < N - 1; j++) {
            if((S[i] == 'R' && S[j] == 'G') || (S[i] == 'G' && S[j] == 'R')) {
                res += Bsum[N] - Bsum[j + 1];
                if(2 * j - i < N && S[2 * j - i] == 'B')
                    res--;
            } else if((S[i] == 'R' && S[j] == 'B') ||
                      (S[i] == 'B' && S[j] == 'R')) {
                res += Gsum[N] - Gsum[j + 1];
                if(2 * j - i < N && S[2 * j - i] == 'G')
                    res--;
            } else if((S[i] == 'B' && S[j] == 'G') ||
                      (S[i] == 'G' && S[j] == 'B')) {
                res += Rsum[N] - Rsum[j + 1];
                if(2 * j - i < N && S[2 * j - i] == 'R')
                    res--;
            }
        }
    }
    cout << res << endl;
    return 0;
}

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

int main() {
	int n,gokei=0,temp=1000000,ans=0;cin>>n;
  	vector<int> a(n);
  	for(int i=0;i<n;i++){
      	cin>>a[i];
    	gokei+=a[i];
    }
  	for(int i=0;i<n;i++){
    	if(temp>abs(gokei-n*a[i])){
        	ans=i;
          	temp=abs(gokei-n*a[i]);
        }
    }
  	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<functional>
#include<cmath>
#include<complex>
#define INF 10000000
#define pb push_back
using namespace std;
typedef complex<double> Point;
typedef pair<double,int> P;
const double PI=4*atan(1);
vector<vector<Point> > p;
int n,s,g;
double dot(Point a, Point b){
    return real(conj(a)*b);
}
double cross(Point a, Point b){
    return imag(conj(a)*b);
}
double dlp(Point a, Point b, Point c) {
  if(dot(b-a,c-a)<=0 )return abs(c-a);
  if(dot(a-b,c-b)<=0 )return abs(c-b);
  return abs(cross(b-a,c-a))/abs(b-a);
}
int iil(Point a1,Point a2,Point b1,Point b2){
	return (cross(a2-a1,b1-a1)*cross(a2-a1,b2-a1)<=0)&&(cross(b2-b1,a1-b1)*cross(b2-b1,a2-b1)<=0);
}
double dll(Point a1,Point a2,Point a3,Point a4){
    if(iil(a1,a2,a3,a4))
        return 0.0;
	return min(min(dlp(a1,a2,a3),dlp(a1,a2,a4)),min(dlp(a3,a4,a1),dlp(a3,a4,a2)));
}
double cal(int a,int b){
    double ret=INF;
    for(int i=0;i<5;i++)
        for(int j=2;j<4&&i+j<5;j++)
            for(int k=0;k<5;k++)
                for(int l=2;l<4&&k+l<5;l++)
                	ret=min(dll(p[a][i],p[a][i+j],p[b][k],p[b][k+l]),ret);
    return ret;
}
int main(){
    while(cin>>n>>s>>g,n||s||g){
        p.clear();
        p.resize(n);
        for(int i=0;i<n;i++){
            double x,y,a,r;
            cin>>x>>y>>a>>r;
            Point c=Point(x,y);
            for(int j=0;j<5;j++){
            	p[i].pb(c+polar(r,(a+72.0*j+90)*PI/180.0));
            }
        }
        vector<vector<double> > cost(n,vector<double>(n,INF));
        for(int i=0;i<n;i++){
            for(int j=i;j<n;j++){
            	if(i==j){
            		cost[i][j]=0;
            		continue;
            	}
                cost[i][j]=cost[j][i]=cal(i,j);
            }
        }
    	for(int k=0;k<n;k++){
    		for(int i=0;i<n;i++){
    			for(int j=0;j<n;j++){
    				cost[i][j]=min(cost[i][k]+cost[k][j],cost[i][j]);
    			}
    		}
    	}
    	printf("%.8lf\n",cost[s-1][g-1]);
    }
    return 0;
}

Measured memory_bytes: 1100
import java.util.*;
import java.lang.*;

/**
 * Shuffle
 */
public class Main {

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

        out_of_loop: while (true) {
            String str = sc.next();

            if (str.equals("-")) {
                break out_of_loop;
            }

            int m = Integer.parseInt(sc.next());

            for (int i = 0; i < m; i++) {
                int n = Integer.parseInt(sc.next());
                // ここでシャッフル
                str = str.substring(n) + str.substring(0, n);
            }

            System.out.println(str);
        }
    }
}


Measured memory_bytes: 26260
import java.util.Scanner;

// https://atcoder.jp/contests/abc145/tasks/abc145_a
public class Main {

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

		System.out.println(r*r);

	}

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#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++)
using ll = long long;
using vec = vector<ll>;
using vec2 = vector<vector<ll>>;
ll inf = pow(2,62);

int main(){
    ll n;cin >> n;
    rep(i,n){
        cout << "ACL";
    }
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define llu unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;

int main()
{
	fast
	double t, volume=1.0; 
	cin>>t;
	t=t/3;
	volume*=t*t*t;
	cout << std::setprecision(12)<<volume<<endl;
}

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

int main() {
	int a,b=0;
	while(1){
		cin >> a;
		if(a==0) break;
		a=1000-a;
		if(a>=500){
			a-=500;
			b++;
		}

		while(1){
			if(a<100) break;
			a-=100;
			b++;
		}

		if(a>=50){
			a-=50;
			b++;
		}

		while(1){
			if(a<10) break;
			a-=10;
			b++;
		}

		if(a>=5){
			a-=5;
			b++;
		}

		while(1){
			if(a==0) break;
			a-=1;
			b++;
		}
		cout <<b << endl;
		b=0;
	}
	return 0;
}

Measured memory_bytes: 2988
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe
import Data.Ord
import qualified Data.Vector as VC
import qualified Data.Vector.Mutable as VM

readNums :: IO [Integer]
readNums = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readNumLists :: Int -> IO [[Integer]]
readNumLists n = replicateM n (map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine)

readStrings :: IO [String]
readStrings = map BS.unpack . BS.words <$> BS.getLine

readStringLists :: Int -> IO [[String]]
readStringLists n = replicateM n (map BS.unpack . BS.words <$> BS.getLine)

toTuple :: [a] -> (a, a)
toTuple (x:y:_) = (x, y)

p s = putStr (show s ++ " ")

main :: IO ()
main = do
  (a:b:_) <- readNums
  putStrLn $ solve a b

solve a b
  | a == b = "Yes"
  | otherwise = "No"

Measured memory_bytes: 380
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;

int main(){
  double a,b,c=0,d=0,e,g,h,n,m;
  string s,t={},u={};
  cin>>a;
  a/=3;
  fix(12);
  co(pow(a,3));
    
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
typedef struct{
  char c;
  int num;
  int count;
} Card;

void quickSort(Card [],int,int);
int partition(Card [],int,int);

int main(){

  int i,j,n,k,l,flag=0;
  Card card[100000];
  Card card2[100000];

  scanf("%d",&n);

 for(i=0;i<n;i++){
   scanf(" %c %d",&card[i].c, &card[i].num);
   card[i].count = i;
 }

 quickSort(card,0,n-1);


 for(i=1;i<n;i++){
   if(card[i-1].num == card[i].num && card[i-1].count > card[i].count){
     flag = 1;
   }
 }
 if(flag == 1){
   printf("Not stable\n");
 }
 else{
   printf("Stable\n");
 }

 for(i=0;i<n;i++){
   printf("%c %d\n",card[i].c,card[i].num);
 }

 return 0;
}

void quickSort(Card A[],int p,int r){

  int q;

  if(p < r){
    q = partition(A,p,r);
    quickSort(A,p,q-1);
    quickSort(A,q+1,r);
  }
}

int partition(Card A[],int p,int r){

  int  i,j,x;
  Card temp;

  x = A[r].num;
  i = p-1;
  for(j=p;j<r;j++){
    if(A[j].num <= x){
      i = i+1;
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
  }
  temp = A[i+1];
  A[i+1] = A[r];
  A[r] = temp;
  return i+1;
}

Measured memory_bytes: 1776
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll a, b;
  cin >> a >> b;
  ll ans;
  if (b - a >= 0) {
    ans = a;
  } else {
    ans = a - 1;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long A = long.Parse(str[0]);
		long B = long.Parse(str[1]);
		long ans = A*B/2;
		if(A==1){
			ans = 1;
		} else if(B==1){
			ans = 1;
		} else if(A%2==1&&B%2==1){
			ans = (A*B+1)/2;
		}
		Console.WriteLine(ans);
	}
}

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

#define ll long long

using namespace std;

const int N = 123, M = 2e5, mod = 1e9 + 7;

int n, k;

ll a[N], dp[M + 5], can[M], p[M];

ll sum (int l, int r) {
    if (l == 0)return p[r];
    return (p[r] - p[l - 1] + mod) % mod;
}

int main () {
    cin >> n >> k;
    for (int i = 1;i <= n;i ++) {
        cin >> a[i];
    }dp[0] = 1;
    p[0] = 1;
    for (int j = 1;j <= k;j ++) {
        p[j] = p[j - 1] + dp[j];
    }
    for (int i = 1;i <= n;i ++) {
        for (int j = k;j >= 0;j --) {
            int l = max (0ll, j - a[i]), r = j - 1;
            dp[j] = (dp[j] + sum (l, r)) % mod;
        }
        for (int j = 1;j <= k;j ++) {
            p[j] = p[j - 1] + dp[j];
        }
    }
    cout << dp[k];
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s;
  cin>>t;
  bool good = true;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      good=false;
    }
  }
  if(s.size()+1 != t.size()){
    good = false;
  }
  if(good)  cout<<"Yes"<<endl;
  else  cout<<"No"<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int cx, cy, dx, dy;
typedef pair<int, int> pii;
#define F first
#define S second
int a[1006][1006];
int b[1006][1006];
queue<pii> bfs(queue<pii> que, int que_id) {
    vector<pii> v;
    while (!que.empty()) {
        pii p = que.front(); que.pop();
        int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
        for (int k=0; k<4; k++) {
            int newx = p.F + dx[k], newy = p.S + dy[k];
            if (a[newx][newy]==0) continue;
            if (b[newx][newy]==-1 || b[newx][newy]==que_id + 1) {
                b[newx][newy]=que_id;
                que.push(make_pair(newx,newy));
            }
        }
        for (int i=-2; i<=2; i++) {
            for (int j=-2; j<=2; j++) {
                int newx =p.F+i,newy=p.S+j;
                if (a[newx][newy]==0) continue;
                if (b[newx][newy]==-1) {
                    b[newx][newy]=que_id+1;
                    v.push_back(make_pair(newx,newy));
                }
            }
        }
    }
    queue<pii> ret;
    for (int i=0; i<(int)v.size(); i++) {
        pii p=v[i];
        if (b[p.F][p.S]==que_id + 1) {
            ret.push(p);
        }
    }
    return ret;
}

int main () {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m; cin >> n >> m;
    cin >> cx >> cy >> dx >> dy;
    cx+=1,cy+=1,dx+=1,dy+=1;
    for (int i=0; i<n; i++) {
        string s; cin >> s;
        for (int j=0; j<m; j++) {
            if (s[j]=='.') {
                a[i+2][j+2]=1;
            }
        }
    }
    memset(b,-1,sizeof(b));
    b[cx][cy]=0;
    queue<pii> now;
    now.push(make_pair(cx, cy));
    for (int i=0; ; i++) {
        now = bfs(now, i);
        if (now.empty()) break;
    }
    cout << b[dx][dy] << endl;
}

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


int main() {
    int N;
    int j;
    int count = 0;
    int max_count = 0;
    int answer = 0;
    cin >> N;

    if (N  == 1){
        answer = 1;
    }
    else {
        for (int i=N; i>0; i--) {
            j = i;
            if (j % 2 == 0){
                while (j > 0){
                    if (j % 2 == 0){
                        count++;
                    }
                    j = j / 2;
                }
            }
            if (max_count < count){
                max_count = count;
                answer = i;
            }
            count = 0;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000100
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
using namespace std;
 
ll gcd(ll n1,ll n2){
    if(!n1)return n2;
    if(!n2)return n1;
    if(n1%n2==0)return n2;
    return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
    base%=mod;
    ll ans=1;
    while(exponent){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent/=2;
    }
    ans%=mod;
    return ans;
}
int main()
{
    int a,b,c;
    
    cin>>a>>b>>c;
   if(a==b)cout<<c; 
   if(b==c)cout<<a;
   if(c==a)cout<<b;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

int main(void){
	int p,q,r;
	cin>>p>>q>>r;
	cout<<p+q+r-max(p,max(q,r))<<endl;
    return 0;
}


Measured memory_bytes: 764
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<String>().as_bytes().iter().map(|c|*c as i32).collect::<Vec<i32>>();
    let b=read::<String>().as_bytes().iter().map(|c|*c as i32).collect::<Vec<i32>>();
    println!("{}",if a<b{"<"}else if a>b{">"}else{"="})
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
const int N = 2e5 + 5;
ll M = 1e9 + 7;
ll fac[N];

ll power(ll x,ll y)
{
    ll res=1;
    while(y)
    {
        if(y&1) res = (res*x)%M;
        y = y>>1;
        x = (x*x)%M;
    }
    return res%M;
}

void pre()
{
    fac[0]=1; //inv[0]=1;
    for(int i=1;i<N-2;i++)
    {
        fac[i] = (fac[i-1]*(ll)i)%M;
        //inv[i] = power(fac[i],M-2);
    }
    
}

ll C(ll a,ll b)
{
    ll a1 = ( power(fac[a],M-2)*power(fac[b],M-2) )%M;
    ll ans = (a1*fac[a+b])%M;
    return ans%M;
}


int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	pre();
	ll h,w,a,b; cin>>h>>w>>a>>b;
	ll ans = 0;
	ll p=h-a, q=b+1;
	while( p>=1 && q<=w )
	{
	    //cout<<C(p-1,q-1)<<' '<<C(h-p,w-q)<<'\n';
	    ans = (ans + ( C(p-1,q-1)*C(h-p,w-q) )%M)%M;
	    p--; q++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1792
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <deque>
#include <unordered_set>
#include <functional>
 
using namespace std;
 
int main() {
    string s;
    int q;
    cin>>s;
    cin>>q;
    int t, f;
    char c;
    bool rev=false;
    deque<char> z(s.begin(), s.end());
    for (int qq=0;qq<q;++qq){
        cin>>t;
        if (t==1){
            rev=!rev;
        } else {
            cin>>f>>c;
            bool bef = (f==1&&!rev)||(f==2&&rev);
            if (bef){
                z.push_front(c);
            } else {
                z.push_back(c);
            }
        }
    }
    if (rev){
        for (auto it=z.rbegin();it!=z.rend();++it) {
            cout<<*it;
        }
    } else {
        for (auto it=z.begin();it!=z.end();++it) {
            cout<<*it;
        }
    }
    cout<<"\n";
}

Measured memory_bytes: 896
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a = [int(input()) for _ in range(5)]
    b = [(x + 9) // 10 * 10 for x in a]

    ans = INF
    for i in range(5):
        ans = min(ans,sum(b) - b[i] + a[i])

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

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

    vector<int> a(n);
    string s;

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

    sort(a.rbegin(), a.rend());

    int Alice = 0, Bob = 0;

    for (int i = 0; i < n; i++) {
        if (i % 2) {
            Bob += a[i];
        } else {
            Alice += a[i];
        }
    }

    cout << (Alice - Bob) << endl;

    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)

ans = 0
(N-1).downto(0) do |i|
  n = [B[i], A[i+1]].min
  B[i] -= n
  ans += n

  n = [B[i], A[i]].min
  A[i] -= n
  ans += n
end

puts ans


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

typedef vector<int> vi;
typedef pair<int,int> pii;
#define For(i,n) for(int i = 0; i < (int) n; ++i)
#define Rep(i,n) for(int i = 1; i <= (int) n; ++i)
#define ll long long
#define lld long double
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define ar array
#define INF 1e18;
#define all(v) (v).begin(),(v).end()
const int N=2e6+1,mod=1e9+7;
vi adj[N];
int cnt[N],p[N];
//int ans=0;

int find(int x){
    return x^p[x]?p[x]=find(p[x]):x;
}

bool join(int x,int y){
    if((x=find(x))==(y=find(y)))
        return 0;

    p[x]=y;
    cnt[y]+=cnt[x];
    //ans=max(ans,cnt[y]);
    return 1;

}


void solve(){
    int n,m;
    cin>>n>>m;
    //for(int i=0;i<=n;i++)cnt[i]=1;
    int ans=0;
    iota(p,p+n+1,0);
    fill(cnt,cnt+n+1,1);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v,--u,--v;
        if(join(u,v)){
            ans=max(ans,cnt[find(u)]);
        }
    }
    cout<<max(ans,1)<<endl;



}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t;
    t=1;
    while(t--){
        //cout<<"Case #"<<a<<": ";
        solve();
        //a+=1;
    }
}


Measured memory_bytes: 52104
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ll long long
#define MOD 1000000007
#define MAX 100010
#define aout(a) REP(i,sizeof(a)) cout << a[i] << " "; cout << endl;
#define vout(v) REP(i,v,size()) cout << v[i] << " "; cout << endl;
using namespace std;
using Graph = vector<vector<int>>;
#define PI 3.1415926535897932384
 
int main(){
  int N,M,K; cin>>N>>M>>K;
  vector<ll> A(N),B(M);
  REP(i,N) cin>>A[i];
  REP(i,M) cin>>B[i];
  vector<ll> a(N+1),b(M+1);
  a[0]=0; b[0]=0;
  REP(i,N) a[i+1] = a[i] + A[i];
  REP(i,M) b[i+1] = b[i] + B[i];
  
  int ans=0;
  int j=M;
  REP(i,N+1){
    if(a[i] > K) break;
    while(b[j] > K-a[i]){
      if(j==0) break;
      j -= 1;
    }
    ans = max(ans, i+j);
  }
  cout<<ans;
}

Measured memory_bytes: 9464
#include <stdio.h>
#include <cstdio>
#include <queue>
#include <set>

int main(){
  
  // read problem from standard input
  int K;
  scanf("%d", &K);
  
  // special cases
  if(K == 1){
    printf("1\n1");
    return 0;
  }
  else if(K == 2){
    printf("2\n1 1\n2 2");
    return 0;
  }
 
  
  
  // general cases
  else{
    // if K is even
    if(K % 4 == 0){
      printf("%d\n", K/2); //n
      for(int i = 0; i < K/2; i++){
        for(int j = 0; j < K/2; j++){
          printf("%d ", (i*2) + (j%2) +1);
        }printf("\n");
      }
      return 0;
    }
    // if K%4 == 1
    else if(K % 4 == 1){
      //n
      int n = (K+3)/2;
      printf("%d\n", n);
      // first three lines
      for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
          if((i-j+n)%n >= 3)
            printf("%d ", 2*((i-j+n)%n) + j%2 -2);
          else if((i-j+n)%n == 0)
            printf("1 ");
          else if((i-j+n)%n == 1)
            printf("2 ");
          else //if(i-j+n)%n == 2)
            printf("3 ");
        }printf("\n");
      }
      return 0;
    }
    
    else if(K % 4 == 2){
      //n
      int n = (K+2)/2;
      printf("%d\n", n);
      // first three lines
      for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
          if((i-j+n)%n >= 2)
            printf("%d ", 2*((i-j+n)%n) + j%2 -1);
          else if((i-j+n)%n == 0)
            printf("1 ");
          else if((i-j+n)%n == 1)
            printf("2 ");
        }printf("\n");
      }
      return 0;
    }
    
    else if(K % 4 == 3){
      // n
      int n = (K+1)/2;
      printf("%d\n", n);
      // first line
      for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
          if((i-j+n)%n != 0)
            printf("%d ", 2*((i-j+n)%n)  + j%2);
          else printf("1 ");
        }printf("\n");
      }
      return 0;
    }
  }
  
  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
vector <ll> a[100010], b1[100010], b2[100010];
ll ans[100010], dis1[100010], dis2[100010];
int main(){
  ll n, m, aa, bb, x, y, s, t;
  while(cin>>n>>m>>s>>t){
    for(int i=0; i<m; ++i){
      cin>>x>>y>>aa>>bb;
      a[x].push_back(y);
      b1[x].push_back(aa);
      b2[x].push_back(bb);

      a[y].push_back(x);
      b1[y].push_back(aa);
      b2[y].push_back(bb);
    }
    for(int i=1; i<=n; ++i){
      dis1[i]=dis2[i]=1e17;
    }
    priority_queue < pair<ll, ll> > q;
    q.push(mk(0, s));
    pair<ll, ll> tp, tmp;
    while(!q.empty()){
      tp=q.top();
      q.pop();
      tp.fs*=-1;
      if(dis1[tp.sc]<=tp.fs)
        continue;
      dis1[tp.sc]=tp.fs;
      for(int i=0; i<a[tp.sc].size(); ++i){
        q.push(mk(-tp.fs-b1[tp.sc][i], a[tp.sc][i]));
      }
    }
    q.push(mk(0, t));
    while(!q.empty()){
      tp=q.top();
      q.pop();
      tp.fs*=-1;
      if(dis2[tp.sc]<=tp.fs)
        continue;
      dis2[tp.sc]=tp.fs;
      for(int i=0; i<a[tp.sc].size(); ++i){
        q.push(mk(-tp.fs-b2[tp.sc][i], a[tp.sc][i]));
      }
    }
    ans[n+1]=1e17;
    for(int i=n; i>=1; --i){
      ans[i]=min(ans[i+1], dis1[i]+dis2[i]);
    }
    ll mx=1e15;
    for(int i=1; i<=n; ++i){
      cout<<mx-ans[i]<<endl;
    }
  }
  return 0;
}




Measured memory_bytes: 23156
#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)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
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; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int main() {
  int a,b;
  while(input(a,b)) {
    int x = b + a;
    if (x % 2 == 1) {
      cout << "IMPOSSIBLE" << endl;
    } else {
      cout << x / 2 << endl;
    }
  }
}


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

int dp[1234567][3];

int main(){
  string s;cin>>s;
  int n=s.size();
  dp[0][1]=1;
  for(int i=0;i<n;i++){
    int a=s[i]-'0';
    dp[i+1][0]=dp[i][0]+a;
    dp[i+1][1]=min({dp[i][0]+a+1,dp[i][1]+9-a,dp[i][2]+a+1});
    dp[i+1][2]=min({dp[i][1]+10-a,dp[i][1]+a+1,dp[i][2]+a});
  }
  cout<<min(dp[n][0],dp[n][2])<<endl;
}


Measured memory_bytes: 13572
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


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

  Int X;
  cin>>X;

  Int a = (X / 500) * 1000;
  X %= 500;
  Int b = (X / 5) * 5;
  Int ans = a + b;
  cout<<ans<<endl;

  return 0;
}


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

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N, X;
	cin >> N >> X;

	ll d = 0;
	ll ans = 1;
	rep(i, 0, N) {
		ll L;
		cin >> L;
		d = d + L;
		if (d <= X) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
long double A, B, C;
cin >> A >> B >> C;
if(A/C<=B) cout << "Yes";
else cout << "No";
}

Measured memory_bytes: 3736
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

void Rotate (vec &x, vec &y, vector<char> &p, ll N) {
    Rep (i, N) {
        ll nx = 200000-y[i], ny = x[i];
        char np;
        if (p[i] == 'L') np = 'D';
        else if (p[i] == 'R') np = 'U';
        else if (p[i] == 'U') np = 'L';
        else np = 'R';

        x[i] = nx, y[i] = ny, p[i] = np;
    }
    return;
}

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

    ll N;
    cin >> N;
    vec X(N), Y(N);
    vector<char> P(N);
    Rep (i, N) {
        cin >> X[i] >> Y[i] >> P[i];
    }

    ll ans = inf;
    Rep (_, 4) {
        vector<vector<pair<ll, char>>> a(200010), b(400010);
        Rep (i, N) {
            if (P[i] == 'L' or P[i] == 'R') continue;
            a[X[i]].push_back({Y[i], P[i]});
        }

        Rep (i, 200010) {
            sort(a[i].begin(), a[i].end());
            ll n = a[i].size();
            Rep (j, n-1) {
                if (a[i][j].second == 'U' and a[i][j+1].second == 'D') {
                    chmin(ans, (a[i][j+1].first - a[i][j].first) * 5);
                }
            }
        }

        Rep (i, N) {
            if (P[i] == 'L' or P[i] == 'D') continue;
            b[X[i]+Y[i]].push_back({Y[i], P[i]});
        }

        Rep (i, 400010) {
            sort(b[i].begin(), b[i].end());
            ll n = b[i].size();
            Rep (j, n-1) {
                if (b[i][j].second == 'U' and b[i][j+1].second == 'R') {
                    chmin(ans, (b[i][j+1].first - b[i][j].first) * 10);
                }
            }
        }

        Rotate(X, Y, P, N);
    }

    if (ans == inf) cout << "SAFE\n";
    else cout << ans << endl;


}

Measured memory_bytes: 32812
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0

for a in range(A + 1):
    
    for b in range(B + 1):
        
        for c in range(C + 1):
            
            if(a * 500 + b * 100 + c * 50 == X):
                cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	return c - '0';
}
int keta(int a) {
	return to_string(a).size();
}

signed main(){
	int a, b;
	cin >> a >> b;
	int ans = 0;
	if (a == 3) ans++;
	if (a == 2)ans += 2;
	if (a == 1)ans += 3;
	if (b == 3)ans++;
	if (b == 2)ans += 2;
	if (b == 1)ans += 3;
	if (a == 1 && b == 1)ans += 4;
	cout << ans * 100000 << endl;
}


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

int main() {
	char asc[10];
	int n;
	scanf("%s", asc);
	sscanf(asc, "%d", &n);

	int p = 0, total = 0;
	while (asc[p] != 0)
		total += asc[p++] - '0';

	printf("%s\n", n % total == 0 ? "Yes" : "No");
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <map>
#include <math.h>
#include <time.h>
#include <vector>
#include <stdarg.h>
#include <algorithm>
#include <iostream>

#define ll long long

using namespace std;

int
main() {
  ll n, k;
  cin>>n>>k;

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

    a[i]--;
    a[i] += a[i-1];
    a[i] %= k;
  }

  map<ll, ll> count;
  ll ans = 0;

  for (ll i=0; i<=n; i++) {
    ans += count[a[i]];
    count[a[i]]++;

    if (i-(k-1) >= 0) count[a[i-(k-1)]]--;
  }

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



Measured memory_bytes: 14336