akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n;
string s;

void yes(){
   cout<<"YES"<<endl;
   //exit (0);
}
void no(){
   cout<<"0"<<endl;
   exit (0);   
}

int32_t main(){_

   cin>>s;
   n = sz(s);

   if (n <= 2){
      no();
   }

   // int cnt = 0, ans = 0;
   // while(1){
   //    cnt = 0;
   //    for (int i = n-1; i-2 >= 0; --i)
   //    {
   //       if (s[i-2] == 'A' and s[i-1] == 'B' and s[i] == 'C'){
   //          s[i-2] = 'B';
   //          s[i-1] = 'C';
   //          s[i] = 'A';
   //          cnt++;
   //       }
   //    }

   //    if (cnt == 0){
   //       break;
   //    }
   //    ans += cnt;
   // }

   int ans = 0;
   int countA = 0, countBC = 0;
   for (int i = 0; i < n; )
   {
      if(s[i] != 'A'){
         tr("came here",i);
         countA = 0;
         countBC = 0;
         ++i;
         continue;
      }
      int j = i;
      while(j < n and s[i] == s[j])++j;
      tr(countA, i, j);
      countA += j - i;
      countBC = 0;
      tr(j, i);
      int k = j, lst = j;
      for (k = j+1; k < n; ++k)
      {
         if(s[k-1] == 'B' and s[k] == 'C'){
            countBC++;
            lst = k+1;
            ++k;
         }
         else{
            break;
         }
      }
      tr(i, j, k, countA, countBC);
      if(countBC == 0)countA = 0;
      ans += countBC * countA;
      i = lst;
   }
   
   cout<<ans;

   return 0;
}

// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me give it a try.
// Mistakes made in past
// -Ques. ask for max-min => think binary_search, DP, greedy
// -not reading question properly / skipping to read & understand all samples properly & wasting time in wrong direction.
// -Using wrong indexing in nested loops something like a[i], when it is supposed to be a[j](WA)
// -value of const int N is not correct (WA/RTE).
// -Did you memset dp to -1 ?
// -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it couldn't be solved, but it isn't the case.
// -Avoid using #define int long long as much as possible when it's dp problem and requires high memory say, O(N^2, N=5000) (MLE)
// -Check Bitwise Operator Precedence 
// -Use pragmas to optimize (by constant factor) when necessary..
// -Think before coding & starting to debug. Have patience to look inside code and actually see how it works


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    
    int count1=0, count0=0;
    for(int i=0; i<s.size(); i++){
        if(s[i]-'0' == 1) count1++;
        else count0++;
    }
    
    cout << min(count1, count0)*2 << endl;
    
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int n,i,check=0;
  scanf("%d",&n);
  int a[n+1];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    if(a[i]%2==0){
      if(a[i]%5!=0 && a[i]%3!=0)
        check=1;
    }
  }
  if(check==0)
    printf("APPROVED\n");
  else
    printf("DENIED\n");
  return 0;
}


Measured memory_bytes: 128
# import bisect
# from collections import Counter, defaultdict, deque, namedtuple
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

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

def main():
    h, w = list(map(int,ipti().split()))
    n = int(input())
    a = list(map(int,ipti().split()))

    grid = [[0] * w for _ in range(h)]
    x = 0
    y = 0
    direction = 1

    for i in range(n):
        color = i + 1
        rem = a[i]
        while rem > 0:
            grid[y][x] = color
            rem -= 1
            x += direction
            if x == w:
                x -= 1
                direction *= -1
                y += 1
            if x == -1:
                x += 1
                direction *= -1
                y += 1

    for i in range(h):
        print(*grid[i])

if __name__ == '__main__':
    main()

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

int main()
{
    int n;
    cin >> n;
    int ac = 0, wa = 0, tle = 0, re = 0;

    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        if (s == "AC")
        {
            ac++;
        }
        else if (s == "WA")
        {
            wa++;
        }
        else if (s == "TLE")
        {
            tle++;
        }
        else if (s == "RE")
        {
            re++;
        }
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}

Measured memory_bytes: 3620
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define pob pop_back
#define forr(x) for(int i = 0; i < x; i++)
#define forrr(x) for(int j = 0; j < x; j++)
#define F first
#define S second
#define endl '\n'
#define pi pair<ll, ll>
#define mp make_pair
const ll N = 3e5 + 5, inf = 1e9 + 5;

int n;
int a[N];
int b[N];
int c[N];
int dp[N][3];

int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin >> n;
	forr(n)
		cin >> a[i] >> b[i] >> c[i];
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for(int i = 1; i < n; i++)
	{
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
	}
	int ans = max(dp[n - 1][0], dp[n - 1][1]);
	ans = max(ans, dp[n - 1][2]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5632
import sys
import math
A, B, X = [float(v) for v in input().split()]

tansheeta = (2 * X) / (A * B * B)
if tansheeta > A / B:
    tansheeta = (2 * (A * A * B - X)) / (A * A * A)
    sheeta = math.atan(tansheeta)
    print(sheeta / math.pi * 180)
else:
    sheeta = math.atan(tansheeta)
    print(90 - sheeta / math.pi * 180)



Measured memory_bytes: 3060
N,A = [input() for i in range(2)]
A = list(map(int, A.split()))

EvenCount = int(N)
OperationCount = 0

while EvenCount == int(N): #リスト内が全て偶数の時
    EvenCount = 0
    for i in range(int(N)):
        if A[i] % 2 == 0:
            EvenCount += 1
            if EvenCount == int(N):
                A = [a / 2 for a in A]
                OperationCount += 1

print(OperationCount)


Measured memory_bytes: 3060
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;

int main() {
	int N, M;
	cin >> N >> M;
	vi D(N), C(M);
	REP(i, N) {
		cin >> D[i];
	}
	REP(i, M) {
		cin >> C[i];
	}

	vvi dp(M + 1, vi(N + 1, INF));
	dp[0][0] = 0;
	REP(day, M) {
		REP(city, N) {
			dp[day + 1][city] = min(dp[day + 1][city], dp[day][city]);
			dp[day + 1][city + 1] = min(dp[day + 1][city + 1], dp[day][city] + D[city] * C[day]);
		}
	}

	int ans = INF;
	FOR(day, 0, M) {
		ans = min(ans, dp[day][N]);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    string S;
    int N;
    int buff;

    std::cin >> N >> S;

    for(int i = 0; i < S.size(); i++){
        buff = (int)S[i];
        buff = buff + N;
        if(buff > 90){
            buff = buff -26;
        }
        S[i] = buff;
        std::cout << S[i];
    }


}

Measured memory_bytes: 3628
# Aizu Problem 0306: Symmetric Ternary Number

import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


N = int(input())
ans = ""
while N > 0:
    if N % 3 == 2:
        ans += '-'
        N += 1
    elif N % 3 == 1:
        ans += '+'
    else:
        ans += '0'
    N //= 3
print(ans[::-1])

Measured memory_bytes: 7764
import math
init = input().split(' ')
count=0
for i in range(int(init[0])):
    line_str = input().split(' ')
    line = [int(line_str[0]),int(line_str[1])]
    if int(init[1]) >= math.sqrt(line[0]**2+line[1]**2):
        count +=1
print(count)

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

int main(){

	  while(1){
			int e; cin >> e;
			if(!e) break;
			int mini = e;
			for(int z=0; z*z*z<=e; z++){
				  for(int y=0; z*z*z + y*y<=e; y++){
						int x = e - z*z*z - y*y;
						mini = min(mini,x+y+z);	
				  }
			}
			cout << mini << endl;

	  }

}

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

int main()
{
  string s;
  cin>>s;
  vector<int> t(s.length(),-1);
  int i;
  int count;
  for(i = 0; i < s.length()-1; i++)
  {
    if((s.at(i)=='R'&&s.at(i+1)=='L'))
    {
      t.at(i) = 0;
      t.at(i+1) = 0;
    }
  }
  count = 1;
  for(i = 0; i < s.length(); i++)
  {
    if(s.at(i)=='L'&&t.at(i)==-1)
    {
      t.at(i) = count;
      count++;
    }
    else if(t.at(i)==0)
    {
      count = 1;
    }
  }
  count = 1;
  for(i = s.length()-1; i>= 0; i--)
  {
    if(s.at(i)=='R'&&t.at(i)==-1)
    {
        t.at(i) = count;
        count++;
    }
    else if(t.at(i)==0)
    {
      count = 1;
    }
  }
  vector<int> ans(s.length(), 0);
  for(i = 0; i < s.length(); i++)
  {
    if(t.at(i) == 0)ans.at(i)++;
    else if(s.at(i) == 'R'&& t.at(i)%2==0)ans.at(i+t.at(i))++;
    else if(s.at(i) == 'R'&& t.at(i)%2!=0)ans.at(i+t.at(i)+1)++;
    else if(s.at(i) == 'L'&& t.at(i)%2==0)ans.at(i-t.at(i))++;
    else ans.at(i-t.at(i)-1)++;
  }
  for(i = 0; i < s.length(); i++)
  {
    if(i == 0)cout << ans.at(i);
    else cout << ' ' << ans.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <set>
using namespace std;

int n, a;
set<int> st;
int main() {
	scanf("%d", &n);
	while(n--) {
		scanf("%d", &a);
		if(st.count(a)) st.erase(a);
		else st.insert(a);
	}
	printf("%d", st.size());
	return 0;
}

Measured memory_bytes: 4864
N,K = map(int, input().split())
MOD = int(1e9+7)

fac = [0] * (N+10)
finv = [0] * (N+10)
inv = [0] * (N+10)

fac[0], fac[1] = 1, 1
finv[0], finv[1] = 1, 1
inv[1] = 1
for i in range(2,N+10):
  fac[i] = fac[i-1] * i % MOD
  inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
  finv[i] = finv[i - 1] * inv[i] % MOD
  
def cmb(n, k):
  if n < k:
    return 0
  if n < 0 or k < 0:
    return 0
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;

red,blue = N-K,K
for i in range(1,K+1):
  # Bが2回に分かれるということは、R[0], B[1], R[1], B[1], R[0] となること
  # なので、Bの並べ方はblue-2個と区切り一つの重複並び替え
  # R の並べ方は red-1個と区切り２つの重複並び替え
  # B=3 R BRBRB R
  # B blue-3 と区切り２
  # R red-2 と区切り３つ
  bc = cmb(blue - 1, i-1)
  #if blue == i:
    #bc = 1
  rc = cmb(red + 1, i)
  #if red == i-1:
    #rc = 1
  #print(bc, rc)
  print(bc*rc % MOD)

Measured memory_bytes: 42736
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

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


int main() {
	int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin >> k;
	cout << a[k - 1] << endl;
	
	return 0;
}

Measured memory_bytes: 888
while True:
    l = input().split()
    h = int(l[0])
    w = int(l[1])
    if h == 0 and w == 0:
        break
    for i in range(h):
        if i == 0 or i == h-1:
            print("#" * w)
        else:
            print("#" + "." * (w-2) + "#")
    print()

Measured memory_bytes: 5608
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

class union_find {
    private:
        vector<int> par;
        vector<int> ran;
        vector<ll> size;
    public:
        union_find(int n);
        int find(int x);
        void unite(int x, int y);
        bool same(int x, int y);
        ll show_size(int x);
};

union_find::union_find(int n){
    par.resize(n);
    ran.resize(n);
    size.resize(n);
    rep(i,n) par[i] = i;
    rep(i,n) ran[i] = 0;
    rep(i,n) size[i] = 1;
};

int union_find::find(int x) {
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
};

void union_find::unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    ll t = show_size(x)+show_size(y);
    size[x] = size[y] = t;
    if(ran[x] < ran[y]){
        par[x] = y;
        //size[y] += size[x];
    }
    else{
        par[y] = x;
        //size[x] += size[y];
        if(ran[x] == ran[y]) ran[x]++;
    }
};

ll union_find::show_size(int x) {
    if(par[x] == x) return size[x];
    return show_size(par[x] = find(par[x]));
}

bool union_find::same(int x, int y) {
    return (find(x) == find(y));
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    union_find uf(n);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        --a; --b;
        uf.unite(a, b);
    }
    int ans = 1;
    rep(i,n){
        int cmp = uf.show_size(i);
        chmax(ans, cmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6364
use proconio::input;

const MOD: usize = 2019;

fn main() {
    input! {
        s: String,
    }
    let chars: Vec<char> = s.chars().collect();
    let (mut mods, mut current_mod, mut current_pow) = (vec![0; MOD], 0, 1);
    for c in chars.iter().rev() {
        let int = c.to_digit(10).unwrap() as usize;
        current_mod = (int * current_pow + current_mod) % MOD;
        current_pow = current_pow * 10 % MOD;
        mods[current_mod] += 1;
    }
    let combination = mods
        .iter()
        .map(|&m| combination2(m))
        .fold(0, |sum, x| sum + x);
    let zero = mods.first().unwrap();
    println!("{}", combination + zero);
}

fn combination2(from: usize) -> usize {
    if from > 1 {
        from * (from - 1) / 2
    } else {
        0
    }
}


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main (void) { 
    int N;
    cin >> N;
    vector<int> L(N);
    for(int i=0; i<N; i++) cin >> L[i];

    std::sort(L.begin(), L.end());

    int ans = 0;
    for(int i=0; i<N; i++) {
        for(int j=i+1; j<N; j++) {
            auto itr1 = upper_bound(next(L.begin(),j+1), L.end(), abs(L[i]-L[j]));
            int lidx  = distance(L.begin(),itr1);
            auto itr2 = lower_bound(next(L.begin(),j+1), L.end(), abs(L[i]+L[j]));
            int ridx =  distance(L.begin(), itr2);
            ans += (ridx - lidx);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
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;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

ll a[51] = {0};
ll p[51] = {0};

ll solve(ll N, ll X){
    if(N == 0 && X == 1) return 1;
    if(X == 1) return 0;
    if(1 < X && X <= (1 + a[N-1])) return solve(N-1, X-1);
    if(X == (2 + a[N-1])) return p[N-1] + 1;
    if(X > (2 + a[N-1]) && X <= (2 + 2 * a[N-1])){
        return p[N-1] + 1 + solve(N-1, X-2-a[N-1]);
    }
    else{
        return 2 * p[N-1] + 1;
    }
}

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


    ll N, X;
    cin >> N >> X;

    a[0] = 1;
    p[0] = 1;
    for(int i = 1; i < 51; i++){
        a[i] = 2 * a[i-1] + 3;
        p[i] = 2 * p[i-1] + 1;
    }

    cout << solve(N,X) << endl;
    return 0;
}

Measured memory_bytes: 256
n, x = gets.chomp.split.map(&:to_i)
cost = gets.chomp.split.map(&:to_i)
mins = Array.new(n){Array.new(n)}

n.times{|i|
    min = nil
    n.times{|j|
        min = cost[i - j] if min.nil? || min > cost[i - j]
        mins[j][i] = min
    }
}

min = nil
n.times{|i|
    val = mins[i].inject(:+) + i * x
    min = val if min.nil? || min > val
}
puts min


Measured memory_bytes: 33276
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf INT_MAX-2
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise fixed(cout);cout<<setprecision(16);
using namespace std;
const int MAXN= 100010;


int n;
int v[MAXN],dp[MAXN];


int main()
{
  int k;
  cin >> n >> k;
  for(int i=0;i<=n+5;i++) dp[i]=inf;

  for(int i=0;i<n;i++) cin >> v[i];
  dp[0]=0;

  for(int i=0;i<n;i++)
  {
    for(int j=i+1; j<= i+k; j++)
    {
      if(j<n) dp[j]=min(dp[j],dp[i]+abs(v[j]-v[i]));
    }
  }

  cout << dp[n-1]<<endl;

}


Measured memory_bytes: 1024
#include <iostream>

int main()
{
    int A[100][100] = {};
    int b[100] = {};
    int m, n;
    std::cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            std::cin >> A[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        std::cin >> b[i];
    }
    // std::cout << "result" << std::endl;
    int c[100] = {};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            c[i] += A[i][j] * b[j];
        }
        std::cout << c[i] << std::endl;
    }

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i=0;i<N;i++){
    cin >> a[i];
  }
  int ans=0;
  for (int i=0;i<N;i++){
    while (a[i]%2==0){
      ans++;
      a[i]/=2;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>

#ifdef PRINTERS
#include "printers.hpp"
using namespace printers;
#define tr(a)        cout<<a<<endl;
#else
#define tr(a)    
#endif

#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)    for(int i=a;i<b;i++)
using namespace std;

void solve(){
    int A,B;
    cin>>A>>B;
    if(A==B)cout<<"Draw\n";
    else if(A==1 or (A>B and B!=1))cout<<"Alice\n";
    else cout<<"Bob\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, size):
        # self.parent holds a list of idx for parant node of i-th node
        # if i-th node is a root, self.parent[i] holds the - (number of nodes) in the parent.
        # if self.parent[i] = j, j-th node is a paranet of i-th node. 
        self.parent = [-1 for _ in range(size)]
        
        # self.height holds a list of trees' heights
        self.height = [0] * (size)
        
    def find(self, i):
        """
        Search for i-th node's parent.
        Args : 
            i : index of target node.
        Return :
            index of root of target node
        """ 
        
        if self.parent[i] < 0:
            # root node
            return i
        else:
            # if not root, search by the parent's node
            self.parent[i] = self.find(self.parent[i])
            return self.parent[i]     
        
    def unite(self, i_, j_):
        """
        Unite two parents
        Args : 
            i, j : indices of target nodes.
        """ 
        # search roots
        i = self.find(i_)
        j = self.find(j_)
        
        if self.height[i] < self.height[j]:
            self.parent[j] += self.parent[i]
            self.parent[i] = j_
            
        else:
            self.parent[i] += self.parent[j]
            self.parent[j] = i_
            if self.height[i] == self.height[j]:
                self.height[i] += 1
       
    def size(self, i):
        """
        Get num of nodes in same parent
        Args : 
            i : index of target node.
        """
        return - self.parent[self.find(i)]
        
        

import numpy as np
N, M = map(int, input().split())
ab_list = [list(map(int, input().split())) for _ in range(M)]

a_list = np.array(ab_list)[:, 0][-1::-1]
b_list = np.array(ab_list)[:, 1][-1::-1]

huben = [int((N) * (N-1) * 0.5)]
        
uni = UnionFind(size=N+1)

for a, b in zip(a_list, b_list):
    a_group = uni.find(a)
    b_group = uni.find(b)
    
    if a_group == b_group:
        huben.append(huben[-1])
    else:
        huben.append(huben[-1] - uni.size(a)*uni.size(b))
        uni.unite(a, b)
        
for ans in huben[-1::-1][1:]:
    print(ans)

Measured memory_bytes: 47196
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(x: isize, mut k: isize, d: isize);

    let xd = x.abs() / d;

    if xd > k {
        println!("{}", (x.abs() - (k * d).abs()).abs());
    } else {
        let aaa = x.abs() % d;

        let ax = (k - xd) % 2;
        if ax == 0 {
            println!("{}", aaa);
        } else {
            println!("{}", (aaa - d).abs());
        }
    }
}


Measured memory_bytes: 2204
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong();
		long k=sc.nextLong();
		System.out.println(Math.min((n%k),(Math.abs((n%k) -k))));
	}
}


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

int cnt10,cnt50,cnt100,cnt500;
int i,j,k,l,yen,ten,fifty,hundred,five_hundred,
  tmp,result,oturi,oturi_num;
int min10,min50,min100,min500;
int flag = 0;

void check(){
  int min = 100;
  int c10,c50,c100,c500;
  cnt10 = ten,cnt50 = fifty,cnt100 = hundred,cnt500 = five_hundred;
  for( i = 0; i <= five_hundred; i++ ){
    for( j = 0; j <= hundred; j++ ){
      for( k = 0; k <= fifty; k++ ){
	for( l = 0; l <= ten; l++ ){
	  result =  10*l + 50*k + 100*j + 500*i; 
	  if( result >= yen ){
	    c10 = cnt10 - l;
	    c50 = cnt50 - k;
	    c100 = cnt100 - j;
	    c500 = cnt500 - i;
	    oturi = result - yen;
	    	   
	    if( oturi >= 500 ){
	      tmp = oturi / 500;
	      oturi -= 500 * tmp;
	      c500 += tmp;
	    }

	    if( oturi >= 100 ){
	      tmp = oturi / 100;
	      oturi -= 100 * tmp;
	      c100 += tmp;
	    }

	    if( oturi >= 50 ){
	      tmp = oturi / 50;
	      oturi -= 50 * tmp;
	       c50 += tmp;
	    }

	    if( oturi >= 10 ){
	      tmp = oturi / 10;
	      c10 += oturi / 10;
	    }

	    oturi_num = c10 + c50 + c100 + c500;

	    if( oturi_num < min ){
	      min = oturi_num;
	      min10 = l;
	      min50 = k;
	      min100 = j;
	      min500 = i;
	    }

	  }

	}
      }
    }
  }
  
}


int  main(){
  
 
  while(1){
    cin >> yen; 
    if( yen == 0 ) break;

    cin >> ten >> fifty >> hundred >> five_hundred;
    cnt10 = ten,cnt50 = fifty,cnt100 = hundred,cnt500 = five_hundred;
    if( flag == 1) cout << endl;

    check();
    
    if( min10 > 0 ) cout << "10" << " " << min10 << endl;
    if( min50 > 0 ) cout << "50" << " " << min50 << endl;
    if( min100 > 0 ) cout << "100" << " " << min100 << endl;
    if( min500 > 0 ) cout << "500" << " " << min500 << endl;
    flag = 1;
  }
  return 0;
}
    

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

int main(){
  int L, R;
  cin >> L >> R;
  vector<int> mod;
  for(int i = L; i <= R; i++){
    int temp = i % 2019;
    if(i != L){
      if(mod.at(0) == temp) break;
    }
    mod.push_back(temp);
  }
  int N = mod.size();
  vector<int> modmod;
  for(int i = 0; i < N; i++){
    for(int j = i; j < N; j++){
      if(i == j) modmod.push_back(2019);
      else modmod.push_back((mod.at(i) * mod.at(j)) % 2019);
    }
  }
  sort(modmod.begin(), modmod.end());
  cout << modmod.at(0) << endl;
}

Measured memory_bytes: 10616
n = int(input())
a = list(map(int,input().split()))

from collections import defaultdict
d = defaultdict(int)
for i in range(n):
    d[a[i]]+=1

d = sorted(d.items(),key=lambda x:(x[0],x[1]),reverse=True)

ans = []
for i in range(n):
    if d[i][1]>=4 and len(ans)==0:
        ans.append(d[i][0])
        ans.append(d[i][0])
    if len(ans)==2:
        break

    if d[i][1]>=2:
        ans.append(d[i][0])
        if len(ans)==2:
            break

if len(ans)!=2:
    print(0)
else:
    print(ans[0]*ans[1])



Measured memory_bytes: 74008
#include<bits/stdc++.h>
namespace ZDY{
	#pragma GCC optimize(3)
	#define il __inline__ __attribute__ ((always_inline))
	#define rg register
	#define ll long long
	#define ull unsigned long long
	#define db double
	#define sht short
	#define MB template <class T>il
	#define Fur(i,x,y) for(int i=x;i<=y;i++)
	#define Fdr(i,x,y) for(int i=x;i>=y;i--)
	#define fl(i,x) for(int i=head[x],to;to=e[i].to,i;i=e[i].nxt)
	#define clr(x,y) memset(x,y,sizeof(x))
	#define cpy(x,y) memcpy(x,y,sizeof(x))
	#define fin(s) freopen(s".in","r",stdin)
	#define fout(s) freopen(s".out","w",stdout)
	#define fcin ios::sync_with_stdio(false)
	#define l2(n) (int(log2(n)))
	#define inf 0x3f3f3f3f
	MB T ABS(T x){return x>0?x:-x;}
	MB T MAX(T x,T y){return x>y?x:y;}
	MB T MIN(T x,T y){return x<y?x:y;}
	MB T GCD(T x,T y){return y?GCD(y,x%y):x;}
	MB void SWAP(T &x,T &y){T t=x;x=y;y=t;}
}using namespace ZDY;using namespace std;
namespace IO{const char* ln="\n";const int str=1<<20;struct IN{char buf[str],*s,*t;bool _;IN():s(buf),t(buf),_(0){}il char gc(){return s==t&&((t=(s=buf)+fread(buf,1,str,stdin))==s)?EOF:(*s++);}IN&operator>>(char&ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)_=1;else ch=c;return *this;}IN& operator>>(char* ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;*ch=c;ch++;while((c=gc())!=EOF&&!isspace(c))*ch=c,ch++;if(c==EOF)_=1;return *this;}IN& operator>>(string& ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;ch+=c;while((c=gc())!=EOF&&!isspace(c))ch+=c;if(c==EOF)_=1;return *this;}template<typename T>IN&operator>>(T&x){if(_)return *this;char c=gc();bool ff=0;while(c!=EOF&&(c<'0'||c>'9'))ff^=(c=='-'),c=gc();if(c==EOF){_=1;return *this;}x=0;while(c!=EOF&&'0'<=c&&c<='9')x=(x<<3)+(x<<1)+c-48,c=gc();if(c==EOF)_=1;if(ff)x=-x;return *this;}}in;struct OUT{char buf[str],*s,*t;OUT():s(buf),t(buf+str){}~OUT(){fwrite(buf,1,s-buf,stdout);}void pt(char c){(s==t)?(fwrite(s=buf,1,str,stdout),*s++=c):(*s++=c);}OUT&operator<<(const char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(string s){for(int i=0;s[i];i++)pt(s[i]);return *this;}template<typename T>OUT&operator<<(T x){if(!x)return pt('0'),*this;if(x<0)pt('-'),x=-x;char a[30],t=0;while(x)a[t++]=x%10,x/=10;while(t--)pt(a[t]+'0');return *this;}}out;}using namespace IO;
#define N 10011
int main(){
	int a,b;
	in>>a>>b;
	out<<MAX(MAX(a+b,a-b),a*b);
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;


public class Main {
	
	static Comparator<Character> downer= new Comparator<Character>(){
        public int compare (Character ch1, Character ch2) {
            return (ch1.compareTo(ch2));
        }
    };
    
    static Comparator<Character> upper= new Comparator<Character>(){
        public int compare (Character ch1, Character ch2) {
            return (ch1.compareTo(ch2));
        }
    };
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.nextLine());
		
		for(int i = 0; i < n; i++){
			String str = sc.nextLine();
			List<Character> max_list = new ArrayList<Character>();
			List<Character> min_list = new ArrayList<Character>();
			
			for(char c:str.toCharArray()){
				max_list.add(c);
				min_list.add(c);
			}
			
			Collections.sort(max_list);
			Collections.reverse(max_list);
			Collections.sort(min_list);
			
			
			StringBuilder b1 = new StringBuilder();
			for(char c:max_list){
				b1.append(c);
			}
			
			StringBuilder b2 = new StringBuilder();
			for(char c:min_list){
				b2.append(c);
			}
			
			int max = Integer.parseInt(b1.toString());
			int min = Integer.parseInt(b2.toString());
			
			System.out.println(max - min);
		}
		
	}
}

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


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N; cin >> N;

  double s = 0;

  for (int i = 0; i < N; i++) {
    double x;
    string u;
    cin >> x >> u;
    if (u == "JPY") {
      s += x;
    }else {
      s += x * 380000;
    }
  }
  cout << s << endl;
  
  

  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int i,j,k,n;
long long int a[110][25],x;
//long long int b;

int main(){
	scanf("%d%lld",&n,&x);
	for(i=0;i<n-1;i++)for(j=0;j<=20;j++)a[i][j]=0;
	a[0][x]=1;
	for(i=1;i<n-1;i++){
		scanf("%lld",&x);
		for(j=0;j<=20;j++){
			if(a[i-1][j]>0){
				if(j+x<=20 && j+x>=0)a[i][j+x]+=a[i-1][j];
				if(j-x<=20 && j-x>=0)a[i][j-x]+=a[i-1][j];
			}
		}
	}
	scanf("%lld",&x);
	printf("%lld\n",a[n-2][x]);
	
	return 0;
}

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

typedef long long ll;

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

// chmax, chmin
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; }

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i,N){
        cin >> a[i];
    }
    
    sort(a.begin(),a.end());
    
    int x = a[N-1];
    
    auto itr = upper_bound(a.begin(),a.end(),x/2);
    
    int dis0 = itr - a.begin();
    int dis1;
    if ( dis0 > 0 ){
        dis1 = dis0 - 1;
    }
    
    if ( abs(x - 2 * a[dis0]) < abs(x - 2 * a[dis1]) ){
        cout << x << " " << a[dis0] << endl;
    } else {
        cout << x << " " << a[dis1] << endl;
    }
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
using namespace std;
typedef long long ll;
#include<iostream>
ll prime(ll x) {
	ll i;
	if (x < 2)return 0;
	else if (x == 2) return 1;
	if (x % 2 == 0) return 0;
	for (i = 3; i*i <= x; i += 2) {
		if (x%i == 0) return 0;
	}
	return 1;
}
int main() {
	ll N;
	cin >> N;
	vector<ll>v;
	for (ll i = 6; i<50000; i += 5) {
		if (prime(i))
			v.push_back(i);
	}
	for (ll i = 0; i<N; ++i) {
		cout << v[i] << " ";
	}
	cout << "" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	int h;
	cin >> h;

	int a;
	cin >> a;

	cout << ceil((double)h / a) << endl;

	return 0;

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int A = sc.nextInt();

        if (H%A == 0){
            System.out.println(H/A);
        } else {
            System.out.println(H/A +1);
        }
    }
}


Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int min=10000;
		for(int i=0;i<(s.length()-t.length()+1);i++){
			String r=s.substring(i,i+t.length());
			int a=0;
			for(int k=0;k<t.length();k++){
				if(t.charAt(k)!=r.charAt(k)){a++;}
			}
			if(min>a){min=a;}
		}
		System.out.println(""+min);
	}
}

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


string S;

char unused_smallest_char(string s, char first='a'){
  bool used[26] = {};
  for(int i = 0; i < s.length(); i++){
    used[s[i] - 'a'] = true;
  }
  for(int i = 0; i < 26; i++){
    if(!used[i] && first - 'a' <= i){
      return (char) ('a' + i);
    }
  }
}

int descend_start_index(string s){
  for(int i = s.length() - 1; i - 1 >= 0; i--){
    if(s[i - 1] < s[i]){
      return i;
    }
  }
  return 0;
}

int main(){
  cin >> S;

  if(S.length() < 26){
    cout << S << unused_smallest_char(S) << endl;
  }else{
    int idx = descend_start_index(S);
    if(idx == 0){
      cout << -1 << endl;
    }else{
      cout << S.substr(0, idx - 1) << (char)(unused_smallest_char(S.substr(0, idx), S[idx - 1
										       ])) << endl;
    }
  }
}


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

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    for(auto& e : d) cin >> e;
    sort(d.begin(), d.end());
    cout << d[n/2] - d[n/2 - 1] << endl;
    return 0;
}

Measured memory_bytes: 640
k = int(input())

n = list([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51])

print(n[k - 1])

Measured memory_bytes: 3060
import std.stdio;
import std.string;
import std.conv;
import std.range;
import std.algorithm;

void main() {
    int count = 0;
    string input;

    while ((input = readln.chomp).length != 0) {
        if (hantei(input)) count++;
    }

    writeln(count);
}

bool hantei(string input) {
    for (int i = 0; i < (input.length / 2); i++) {
        if (input[i] != input[(input.length - 1) - i]) return false;
    }

    return true;
}

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

int main(){
  int N;
  string c;
  
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>c;
    if(c=="Y"){
      cout<<"Four"<<endl;
      return 0;
    }
  }
  cout<<"Three"<<endl;
}


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

using namespace std;

int n;
int memo = -1;
int *sa, *a;

int bit(int m) {
	if (memo == -1) {
		int ans = 1;
		for (int i = 0; i < m; i++)
			ans *= 2;
		return ans;
	}
	else
		return memo;
}

int main() {
	while (1) {
		cin >> n;
		if (n == 0)
			break;
		sa = new int[bit(n)];
		a = new int[n];
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		for (int i = 0; i < bit(n); i++) {
			sa[i] = 0;
			for (int j = 0; j < n; j++) {
				if (i >> j & 1)
					sa[i] += a[j];
				else
					sa[i] -= a[j];
			}
			sa[i] = abs(sa[i]);
		}
		int min = 1000000;
		for (int i = 0; i < bit(n); i++) {
			if (min > sa[i])
				min = sa[i];
		}
		cout << min << endl;
	}


	return 0;
}

Measured memory_bytes: 56436
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void YES(){cout<<"YES\n";} void NO(){cout<<"NO\n";}
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 1e9+7;

vector<ll> fact,ifact,inv,pow2;
ll add(ll a, ll b)
{
	a+=b; a%=MOD;
	if(a<0) a+=MOD;
	return a;
}
ll mult(ll a, ll b)
{
	if(a>MOD) a%=MOD;
	if(b>MOD) b%=MOD;
	ll ans=(a*b)%MOD;
	if(ans<0) ans+=MOD;
	return ans;
}
ll pw(ll a, ll b)
{
	ll r=1;
	while(b){
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}

const bool DEBUG = 0;
const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n; cin>>n;
	ll dp[n+5]{};
	dp[0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=3;i-j>=0;j++)
		{
			dp[i]=add(dp[i],dp[i-j]);
		}
	}
	
	cout<<dp[n]<<'\n';
	
	return 0;
}


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

int main(){
  string S;
  cin >> S;
  bool g=true;
  int ans=0;
  if(S[0]=='p') ans=-1;
  for(int i=1; i<S.size(); i++){
    if(g){
      if(S[i]=='g') ans++;
      g=false;
    }else{
      if(S[i]=='p') ans--;
      g=true;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;
int keta(int x){
    int ret=1;
    while(x>=10){
        x/=10;
        ret++;
    }
    return ret;
}

signed main(){
    int N;cin>>N;
    bool ok=true;
    string S=to_string(N);
    REPS(i,S.size()-1)if(S[i]!='9')ok=false;
    if(ok) cout<<9*(keta(N)-1)+(S[0]-'0')<<endl;
    else{
      if(keta(N)!=1)cout<<(int)(S[0]-'0')-1+9*(keta(N)-1)<<endl;
      else cout<<S[0]-'0'<<endl;
    }
}


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

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


// r -> P, s -> R, p -> S
int main() {
    int N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    auto score = [&](int i) {
        if (T[i] == 'r') return P;
        else if (T[i] == 's') return R;
        else return S;
    };
    long long res = 0;
    for (int k = 0; k < K; ++k) {
        for (int i = k; i < N;) {
            int j = i;
            while (j < N && T[j] == T[i]) j += K;
            int len = (j - i) / K;
            res += score(i) * ((len + 1) / 2);
            i = j;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def f(l, r, kousa=1):
    n = (r - l) // kousa
    return (r + l) * (n + 1) // 2

def solve():
    N = II()
    # N = 10

    ans = 0
    for i in range(1, N+1):
        mx = i * (N // i)
        # print(i, mx)
        if i == mx:
            ans = ans + f(i, N, 1)
            break
            # mx = i
        # print(i, mx, f(i, mx, i))
        ans = ans + f(i, mx, i)
    print(ans)

if __name__ == '__main__':
    solve()


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int x, y, z;
  while (cin >> x >> y >> z) {
    cout << x * y / 2 << endl;
  }
  
  return 0;
}


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

int main() {
    int sums = 0;

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

    for (int i = 1; i <= N; i++) {
        int tmp1 = i, sum = 0;
        for (int j = 4; 0 <= j; j--) {
            int tmp2 = tmp1 / pow(10, j);
            sum += tmp2;
            tmp1 -= tmp2 * pow(10, j);
        }

        if (A <= sum && sum <= B) {
            sums += i;
        }
    }

    printf("%d\n", sums);

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
  int n, a, b;
  cin >> n;
  if(1 == n)
  {
    cout << "Hello World" << endl;
  }
  else
  {
    cin >> a >> b;
    cout << a + b << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
def examA():
    A, B, C = LI()
    if A==B:
        ans = C
    else:
        if A==C:
            ans = B
        else:
            ans = A
    print(ans)



import sys,copy,bisect,itertools
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()


Measured memory_bytes: 3432
// CODE FESTIVAL 2016 qual C
// E - 順列辞書 / Encyclopedia of Permutations

#include <cstdio>
#define MAX_N 500000
#define MOD 1000000007LL
#define MAX_BIT_IDX MAX_N
using namespace std;

typedef long long int ll;


template <typename T>
class BIT {
public:
  T b[MAX_BIT_IDX + 1];
  int n;
private:
public:
  void init(int num);
  T sum(int i);
  void add(int i, T x);
private:
};

template <typename T>
void BIT<T>::init(int num) {
  n = num;
  for (int i = 0; i <= n; i++) {
    b[i] = 0;
  }
  return;
}

template <typename T>
T BIT<T>::sum(int i) {
  T s = 0;

  while (i > 0) {
    s += b[i];
    i -= i & -i;
  }
  return s;
}

template <typename T>
void BIT<T>::add(int i, T x) {
  while (i <= n) {
    b[i] += x;
    i += i & -i;
  }
  return;
}


int N, K;
int P[MAX_N];
int sum_less[MAX_N + 1];
ll sum_k, sum_sum_more;
ll nn[MAX_N + 1];
BIT<int> bit;
ll ans;

int main() {

  ll t1, t2;
  ll k;
  ll inv2 = (MOD + 1) / 2;

  scanf("%d", &N);
  bit.init(N);
  sum_less[0] = 0;
  for (int i = 1; i <= N; i++) {
    sum_less[i] = 1;
  }
  for (int i = 0; i < N; i++) {
    scanf("%d", &P[i]);
    if (P[i] == 0) {
      K++;
    } else {
      sum_less[P[i]] = 0;
    }
  }
  sum_k = 0;
  for (int i = 1; i <= N; i++) {
    if (sum_less[i] == 1) {
      sum_k = (sum_k + i) % MOD;
    }
    sum_less[i] += sum_less[i - 1];
  }

  nn[0] = 1;
  for (int i = 1; i <= N; i++) {
    nn[i] = (nn[i - 1] * i) % MOD;
  }

  k = 0;
  sum_sum_more = 0;
  ans = 0;
  for (int i = 0; i < N; i++) {
    if (P[i] == 0) {
      t1 = (sum_k * nn[K - 1] - nn[K] + MOD) % MOD;
      t2 = (sum_sum_more * nn[K - 1]) % MOD;
      t2 = (t2 + k * nn[K] % MOD * inv2) % MOD;
      k++;
    } else {
      t1 = (P[i] - 1) * nn[K] % MOD;
      t2 = (ll)bit.sum(P[i]) * nn[K] % MOD;
      t2 = (k > 0) ? (t2 + k * sum_less[P[i] - 1] % MOD * nn[K - 1]) % MOD : t2;
      sum_sum_more = (sum_sum_more + K - sum_less[P[i]]) % MOD;
      bit.add(P[i], 1);
    }
    ans = (ans + (t1 - t2 + MOD) % MOD * nn[N - 1 - i]) % MOD;
  }
  ans = (ans + nn[K]) % MOD;

  printf("%lld\n", ans);

  return 0;

}




Measured memory_bytes: 9984