akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(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 digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



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

    map<char,ll> mp;

    for(int i=0;i<n;i++){
        mp[s[i]]++;
    }

    ll ans = mp['R']*mp['G']*mp['B'];

    for(int i=0;i<n-2;i++){
        for(int j=1;i+2*j<n;j++){
            if(s[i]!=s[i+j]&&s[i]!=s[i+2*j]&&s[i+j]!=s[i+2*j]){
                ans--;
            }
        }
    }

    cout << ans << endl;
}


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

using namespace std;

int main()
{
	int H , W;
	while(cin >> H >> W , H || W)
	{
		for(size_t i = 0; i < H; i++)
		{
			for(size_t j = 0; j < W; j++)
			{
				cout << ( ( i + j ) % 2 ? '.' : '#' );
			}
			cout << endl;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1156
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define N 51
using namespace std;
char Change(char,char);
bool Check(vector<int>,vector<char>,vector<int>,vector<char>);

int main(){
  int n,m,x,y,bx,by;
  char d;
  vector<int> v[N];
  vector<char> c[N],dir[N];
  while(1){
    cin>>n;
    if(!n) break;
    for(int i=0;i<=n;i++){
      cin>>m;
      for(int j=0;j<m;j++){
	cin>>x>>y;
	if(j){
	  v[i].push_back(max(abs(bx-x),abs(by-y)));
	  if(by==y){
	    if(x-bx>0) d='r';
	    else d='l';
	  }else{
	    if(y-by>0) d='u';
	    else d='d';
	  }
	  c[i].push_back(d);
	}
	bx=x,by=y;
      }
      for(int j=0;j<c[i].size()-1;j++) dir[i].push_back(Change(c[i][j],c[i][j+1]));
    }
    for(int i=1;i<=n;i++)
      if(Check(v[0],dir[0],v[i],dir[i])) cout<<i<<endl;
    cout<<"+++++"<<endl;
    for(int i=0;i<=n;i++) v[i].clear(),c[i].clear(),dir[i].clear();
  }
  return 0;
}

char Change(char a,char b){
  if((a=='u'&&b=='r')||(a=='r'&&b=='d')||(a=='d'&&b=='l')||(a=='l'&&b=='u')) return 'l';
  return 'r';
}

bool Check(vector<int> a,vector<char> b,vector<int> c,vector<char> d){
  if(a==c&&b==d) return true;
  reverse(c.begin(),c.end());
  reverse(d.begin(),d.end());
  for(int i=0;i<d.size();i++) d[i]=='l'?d[i]='r':d[i]='l';
  if(a==c&&b==d) return true;
  return false;
}

Measured memory_bytes: 1224
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
 
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
 
#include <functional>
#include <cassert>
 
typedef long long ll;
using namespace std;
 
#define debug(x) cerr << #x << " = " << x << endl;
 
#define mod 1000000007 //1e9+7
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 10000
 
bool used[10];
 
int t;
ll p;
ll n;
ll max_d = 0;
ll ans = -1;
 
void dfs(int h=0,ll sum=0){
 
  if(h==t){
    if(max_d < min(abs(sum-n),p-abs(sum-n)) ){
      max_d = min(abs(sum-n),p-abs(sum-n));
      ans = sum;
    }
    return;
  }
  
  for(int i=0;i<10;i++){
    if(used[i]) continue;
 
    used[i] = true;
    
    dfs(h+1,sum*10+i);
 
    used[i] = false;
  }
 
}
  
 
int main(){
  string s;
 
  cin >> s;
 
  t = s.size();
  n = stoll(s);
 
  p = 1;
  
  for(int i=0;i<t;i++){
    p *= 10;
  }
  
  dfs();
 
  string ans_s = to_string(ans);
 
  while((int)ans_s.size() < t){
    ans_s = "0" + ans_s;
  }
   
  cout << ans_s << endl;
  
  return 0;
}



Measured memory_bytes: 3264
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N,M; cin>>N>>M;
    vi v(M,0);
    rep(i,N) {
        int K; cin>>K;
        rep(j,K) {
            int A; cin>>A; A--;
            v[A]++;
        }
    }
    int counter=0;
    rep(i,M) {
        if(v[i]==N) {
            counter++;
        }
    }
    cout<<counter<<endl;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    W = [readline().strip() for _ in range(N)]

    for w in W:
        if W.count(w) > 1:
            print('No')
            return

    for i in range(N - 1):
        if W[i][-1] != W[i + 1][0]:
            print('No')
            return

    print('Yes')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9136
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
 
using namespace std;
using ll = long long;
 
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){ return a/gcd(a, b)*b; };
 
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Unique(a) a.erase(unique(Range(a)), a.end());
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int main(void){
    Cin(int, x);
    Cout((int)ceil((sqrt(8.0*x+1)-1)/2));
}


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

int main(){
  int K, S;
  cin >> K >> S;
  long long count=0;
  for(int X=0; X<=K; X++){
    for(int Y=0; Y<=K; Y++){
      if(0<= S-X-Y && S-X-Y<=K) count++;
    }
  }
  cout << count << endl;
  return 0;
}

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

using namespace std;

int solve() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> lens(N);
  for (int i = 0; i < N; ++i) {
    cin >> lens[i];
  }
  int cnts = 0;
  sort(lens.begin(), lens.end());
  for (int i = N - 1; i >= 2; --i) {
    for (int j = i - 1; j >= 1; --j) {
      int remain = lens[i] - lens[j] + 1;
      auto end = lens.begin() + j;
      auto it = lower_bound(lens.begin(), end, remain);
      if (it >= end) {
        break;
      }
      cnts += end - it;
    }
  }
  return cnts;
}

int main() {
  cout << solve() << endl;
}


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

#define mod 1000000007
const int NMAX = 100010;
vector <int> adia[NMAX];
int dp[2][NMAX];
/// 0 -> alb 1 -> negru sau alb

void dfs(int nod, int tata)
{
    dp[0][nod] = dp[1][nod] = 1;
    for (auto i : adia[nod]) {
        if (i == tata)
            continue;
        dfs(i, nod);
        dp[0][nod] = 1LL * dp[0][nod] * dp[1][i] % mod;
        dp[1][nod] = 1LL * dp[1][nod] * dp[0][i] % mod;
    }

    dp[1][nod] = (dp[1][nod] + dp[0][nod]) % mod;
}

int main()
{
    int n, a, b;
    scanf("%d", &n);

    while (--n) {
        scanf("%d%d", &a, &b);
        adia[a].push_back(b);
        adia[b].push_back(a);
    }

    dfs(1, 0);

    printf("%d\n", dp[1][1]);

    return 0;
}


Measured memory_bytes: 13440
// Breadth_First_Search.cs

using System;
using System.Collections.Generic;

struct G {
    
    public int edge, d;
    public int[] adj;

    public G(int n) {
        edge = n;
        adj = new int[n];
        d = -1;
    }
}

class Breadth_First_Search {
    public static void Main() {

        int n = int.Parse(Console.ReadLine());
        G[] g = new G[n + 1];

        for(int i = 0; i < n; i++) {
            string[] str = Console.ReadLine().Split(' ');
            int stringToInt1 = int.Parse(str[0]), stringToInt2 = int.Parse(str[1]);
            g[stringToInt1] = new G(stringToInt2);

            for(int j = 0; j < stringToInt2; j++) {
                g[stringToInt1].adj[j] = int.Parse(str[j + 2]);
            }
        }

        g[1].d = 0;
        var queue = new Queue<int>();
        queue.Enqueue(1);

        while(queue.Count > 0) {
            int id = queue.Dequeue();

            for(int i = 0; i < g[id].edge; i++) {
                if(g[g[id].adj[i]].d == -1) {
                    g[g[id].adj[i]].d = g[id].d + 1;
                    queue.Enqueue(g[id].adj[i]);
                }
            }
        }

        for(int i = 1; i <= n; i++) {
            Console.WriteLine(i + " " + g[i].d);
        }

    }
}

Measured memory_bytes: 10112
import java.util.Scanner;
public class Main {
	static boolean prime(int a) {
		if(a==1)return false;
		for(int i=2;i*i<=a;i++) {
			if(a%i==0)
				return false;
		}
		return true;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int a = sc.nextInt();
			int d = sc.nextInt();
			int n = sc.nextInt();
			if(a+d+n==0)break;
			int b = a;
			if(prime(a))n--;
			int ans = a;
			if(n!=0) {
				for(int i=0;;i++) {
					b += d;
					if(prime(b))n--;
					if(n==0) {
						ans = b;
						break;
					}
				}
			}
			System.out.println(ans);
			
		}
	}

}



Measured memory_bytes: 30224
A = list(input())
B = list(input())
C = list(input())

now = A.pop(0)
while True:
    if now == "a":
        if len(A) == 0:
            print("A")
            exit()
        now = A.pop(0)
        
    elif now == "b":
        if len(B) == 0:
            print("B")
            exit()
        now = B.pop(0)
        
    else:
        if len(C) == 0:
            print("C")
            exit()
        now =C.pop(0)

Measured memory_bytes: 3064
#include<stdio.h>

int a,t;
int s[100];
int main(void){
scanf("%d",&a);
for(int i=0;i<a;i++){
scanf("%d",&s[i]);
}
for(int i=0;i<a;i++){
t+=s[i];
}
int  p=t/a;
int  w=p+1;
int q=0;
int x=0;
for(int i=0;i<a;i++){
q+=(p-s[i])*(p-s[i]);
x+=(w-s[i])*(w-s[i]);
}
if(q<x){
  printf("%d",q);
}else{
printf("%d",x);
}
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, n, w = 0, ans = 0, count = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n;
  vlli d(n);
  rep(i, 0, n)
  {
    cin >> d[i];
  }
  SORTR(d);
  // rep(i, 0, n - 1)
  // {
  //   if (count < 2)
  //   {
  //     // cout << "i: " << i << " count: " << count << endl;
  //     ans += d[i] + w;
  //     // cout << "ans: " << ans << endl;
  //     count++;
  //   }
  //   else
  //   {
  //     w += min(d[i - 1] - d[i], 0LL);
  //     ans += (d[i] + w);
  //     // cout << i << " ans2: " << ans << endl;
  //     count = 0;
  //     count++;
  //   }
  // }
  rep(i,1,n){
    ans += d[i / 2];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll a;
    double b;
    cin >> a >> b;

    ll tmp = b * 100 + 0.5;

    ll ans = (a * tmp) / 100;

    cout << ans << endl;

    return 0;
}


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

int main() {
  int N, T;
  cin >> N >> T;

  bool flag = false;
  int c, t, min_c = 1000;
  for (int i = 0; i < N; i++) {
    cin >> c >> t;
    if (min_c >= c && T >= t) {
      min_c = c;
      flag  = true;
    }
  }

  if (flag) {
    cout << min_c << endl;
  } else {
    cout << "TLE" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

ll dp[100005][2];
// i桁目まで見て、すでに「未満」 が達成されているか

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

    string L;
    cin >> L;

    int n = L.size();

    dp[0][1] = 1;
    for (int i = 0; i < n; i++) {
        if (L[i] == '0') {
            dp[i+1][0] = 3 * dp[i][0] % MOD;
            dp[i+1][1] = dp[i][1];
        } else {
            dp[i+1][0] = (3 * dp[i][0] + dp[i][1]) % MOD;
            dp[i+1][1] = 2 * dp[i][1] % MOD;
        }
    }

    cout << (dp[n][0] + dp[n][1]) % MOD << "\n";
    return 0;
}

Measured memory_bytes: 2012
N = int(input().strip())
A = [int(v) for v in input().strip().split(" ")]

exist_in_input = [0 for _ in range(10**6 + 1)]
if_can_divide = [0 for _ in range(10**6 + 1)]

for a in A:
    exist_in_input[a] += 1

counter = 0
for i in range(1, 10**6+1):
    if if_can_divide[i] == 1 or exist_in_input[i] == 0:
        continue

    if exist_in_input[i] == 1:
        counter += 1

    for j in range(0, 10**6+1, i):
        if_can_divide[j] = 1

print(counter)

Measured memory_bytes: 36888
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

string divide[4]={"dream","dreamer","erase","eraser"};

int main(){
    string n;
    cin >> n;
    reverse(n.begin(),n.end());
    rep(i,4) reverse(divide[i].begin(),divide[i].end());
    bool can=true;
    for(int i=0;i<n.size();){
        bool can2=false;
        for(int j=0;j<4;j++){
            string d=divide[j];
            if(n.substr(i,d.size())==d){
                can2=true;
                i+=d.size();
            }
        }
        if(!can2){
            can=false;
            break;
        }
    }
    if(can)
        cout << "YES";
    else
        cout << "NO";

    return 0;
}

Measured memory_bytes: 512
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(n: usize) -> Vec<usize> {
    let mut sieve = vec![true; 55556];
    sieve[0] = false;
    sieve[1] = false;

    for i in 2..sieve.len() {
        if sieve[i] == false { continue }

        for j in 2.. {
            let k = j*i;
            if k >= sieve.len() {break}
            sieve[k] = false;
        }
    }

    let mut v = Vec::new();

    for i in 0..sieve.len() {
        if sieve[i] == true && i % 5 == 2 {
            v.push(i);
            if v.len() == n { break }
        }
    }

    v
}

fn main() {
    let n = parse_line!(usize);

    println!("{}", solve(n).iter().map(|n| n.to_string()).collect::<Vec<String>>().as_slice().join(" "));
}

#[test]
fn solve_test() {
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll ans = __LONG_LONG_MAX__, cur, sum;
    
    rep(p, 2) {
        cur = 0;
        sum = 0;
        
        for (int i = 0, sign = 1; i < n; i++, sign *= -1) {
            sum += a[i];
            
            if ((sign * sum) <= 0) {
                cur += 1 - sign * sum;
                sum += sign * (1 - sign * sum);
            }
        }
        
        ans = min(ans, cur);
        
        rep(i, n) {
            a[i] = -a[i];
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
def maxheapify(a, i):
    l = 2*i
    r = 2*i + 1
    if l <= h and a[l] > a[i]:
        large = l
    else:
        large = i
    if r <= h and a[r] > a[large]:
        large = r
     
    if large != i:
        a[i], a[large] = a[large], a[i]
        maxheapify(a, large)
 
h = int(input())
n = int(h/2)
klist = list(map(int,input().split()))
klist.insert(0,0)
 
for i in range(n):
    j = n - i
    maxheapify(klist, j)
 
print("",*klist[1:])


Measured memory_bytes: 63700
#include "bits/stdc++.h"
using namespace std;

const int N = 1e5 + 5;

int ac[N];
int wa[N];

void getAC() {	
	ios_base :: sync_with_stdio(false); cin.tie(0);
	int n , m; cin >> n >> m;
	int pen = 0;
	set<int> c;
	for(int i = 1; i <= m; ++i) {
		int p; string v; cin >> p >> v;
		if(v == "AC" and c.find(p) == c.end()) {
			pen += wa[p];
			ac[p] = true;
			c.insert(p);
			wa[p] = 0;
		} else {
			wa[p]++;
		}
	}
	cout << (int) c.size() << ' ' << pen << endl;

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

Measured memory_bytes: 5760
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

#define rotate_swap(x,a,b,c,d) swap(x.a,x.b);swap(x.b,x.c);swap(x.c,x.d);
 
class Dice{
public:
  int top,front,right,left,back,bottom;
  bool operator<(const Dice &a)const{
    if (top != a.top)return top < a.top;
    if (front != a.front)return front < a.front;
    if (right != a.right)return right < a.right;
    if (left != a.left)return left < a.left;
    if (back != a.back)return back < a.back;
    if (bottom != a.bottom)return bottom < a.bottom;
    return false;
  }
};
 
void rotate_r(Dice &x){
 rotate_swap(x,top,left,bottom,right);
}
 
void rotate_l(Dice &x){
 rotate_swap(x,top,right,bottom,left);
}
 
void rotate_f(Dice &x){
 rotate_swap(x,top,back,bottom,front);
}
 
void rotate_b(Dice &x){
 rotate_swap(x,top,front,bottom,back);
}
 
void rotate_cw(Dice &x){
  rotate_swap(x,back,left,front,right);
}
 
void rotate_ccw(Dice &x){
  rotate_swap(x,back,right,front,left);
}
 
Dice data[24];

void generate_all(Dice &x){
  rep(i,6){
   rep(j,4){
     data[i*4+j]=x;
     rotate_cw(x);
   }
   if (i%2 == 0)rotate_r(x);
   else rotate_f(x);
 }
}

main(){
  string hoge[6]={"Red","Yellow","Blue","Magenta","Green","Cyan"};
  int n;
  while(cin>>n && n){
    set<Dice> S;
    rep(i,n){
      int a[6];
      rep(j,6){
	string tmp;
	cin>>tmp;
	rep(k,6)if (hoge[k] == tmp)a[j]=k;
      }
      Dice d={a[0],a[1],a[2],a[3],a[4],a[5]};
      generate_all(d);
      bool isok=true;
      rep(j,24){
	if (S.find(data[j]) != S.end()){
	  isok=false;
	}
      }
      if (isok)S.insert(d);
    }
    cout << n-S.size() << endl;
  }
  return false;
}

Measured memory_bytes: 0
from __future__ import print_function
while True:
    a, b = map(int, raw_input().split(' '))
    if a == 0 and b == 0:
        break
    for i in range(a):
        if i % 2 == 0:
            for j in range (b):
                if j % 2 == 0:
                    print("#", end="")
                else:
                    print(".", end="")
            print ("")
        else:
            for j in range (b):
                if j % 2 == 0:
                    print(".", end="")
                else:
                    print("#", end="")
            print ("")
    print ("")

Measured memory_bytes: 6456
# -*- coding: utf-8 -*-
# 整数の入力
#a = int(input())
# スペース区切りの整数の入力
#b, c = map(int, input().split())
# 文字列の入力
#s = input()
# 出力
#print("{} {}".format(a+b+c, s))

N = int(input())
ans = 'second'
for i in range(0, N):
    a = int(input())
    if a % 2 == 1:
        ans = 'first'
print("{}".format(ans))


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

// string から int にする関数
int to_int(string a, int b){
    int ans = 0;
    REP(i, b){
        ans += a[i] * pow(10, b - i - 1);
    }
    return ans;
}

int main(void){
    while(true){
        int aInt, b; cin >> aInt >> b;
        if(aInt == 0 and b == 0) return 0;
        else{
            vector<int> Num(0);
            Num.push_back(aInt); // 初めのぶんも追加しておかないといけない
            string a = to_string(aInt);
            bool find = false;
            if(a.size() < b) while(a.size() != b) a.push_back('0'); // 桁数合わせ
            while (true){
                if(a.size() < b) while(a.size() != b) a.push_back('0'); // 桁数合わせ

                whole(sort, a); // 辞書順でソートすると勝手に最小になってくれる
                string aMinStr = a; // わざわざ変数入れるまででもないけどわかりやすいように
                int aMin = to_int(aMinStr, b);

                whole(sort, a, greater<>()); // 逆すると最大になる
                string aMaxStr = a;
                int aMax = to_int(aMaxStr, b);

                int ans = aMax - aMin; // 保存される値
                int findNum; // 見つかりました？
                for(int i = 0; i <= Num.size() - 1; i++){
                    if(ans == Num[i]){
                        find = true;
                        findNum = i; // 見つかったときの値を覚えておかなくちゃ
                    }
                }

                if(find){
                    cout << findNum << " " << Num[findNum] << " " <<  Num.size() - findNum << endl;
                    break;
                }
                else{
                    Num.push_back(ans);
                    a = to_string(ans);
                }
            

            }
            
        }
    }
}


Measured memory_bytes: 3384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int N,Q;
string s;
char t[200020],d[200020];
int check(int x){
    for(int i = 0; i < Q; i++){
        if(s[x] == t[i]){
            if(d[i] == 'R') x++;
            if(d[i] == 'L') x--;
        }
        if(x == -1) return -1;
        if(x == N) return 1;
    }
    return 0;
}
int main(){
    cin >> N >> Q;
    cin >> s;
    for(int i = 0; i < Q; i++){
        cin >> t[i] >> d[i];
    }
    int l = -1;
    int r = N;
    int mid;
    while(l <= r-2){
        mid = (l+r)/2;
        if(check(mid) == -1) l = mid;
        else r = mid;
    }
    int z = l;
    l = -1;
    r = N;
    while(l < r-1){
        mid = (l+r)/2;
        if(check(mid) == 1) r = mid;
        else l = mid;
    }
    int zz = r;
    cout << zz - z -1 << endl;
}



Measured memory_bytes: 900
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		int n,price,tmp;
		Scanner sc = new Scanner(System.in);
		
		while(true){
			n = sc.nextInt();
			tmp = n%10;
			if(n == -1){
				break;
			}
			
			if(n < 10){
				price = 1150;
			}else if(n < 20){
				price = 1150+tmp*125;
			}else if(n < 30){
				price = 1150+1250+tmp*140;
			}else{
				tmp = n-30;
				price = 1150+1250+1400+tmp*160;
			}
			
			System.out.println(4280-price);
		}
	}
}

Measured memory_bytes: 18580
n, k = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# k = int(input())
p = list(map(int, input().split()))
#a = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# p = [list(map(int, input().split())) for i in range(n)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
p.sort()
#
# print(p)
total = sum(p[:k])
print(total)

Measured memory_bytes: 9252
use proconio::input;
use proconio::marker::Chars;
fn main() {
    input!{
        s:String
    };
    println!("{}", match s.as_str() {
        "Sunny" => "Cloudy",
        "Cloudy" => "Rainy",
        "Rainy" => "Sunny",
        _ => unreachable!()
    });
}

Measured memory_bytes: 2084
while 1:
  n = input()
  if n == 0:  break
  d = range(1, 7)
  ans = 1
  for i in range(n):
    c = raw_input()[0]
    if c == 'N': S = [1,5,2,3,0,4]
    elif c == "S": S = [4,0,2,3,5,1]
    elif c == "E": S = [3,1,0,5,4,2]
    elif c == "W": S = [2,1,5,0,4,3]
    elif c == "R": S = [0,2,4,1,3,5]
    elif c == "L": S = [0,3,1,4,2,5]
    d = [d[s] for s in S]
    ans += d[0]
  print ans

Measured memory_bytes: 4848
#include <stdio.h>
//input
 int main(void){
 int a, b, c;

 scanf("%d%d%d", &a, &b, &c);

 int ispoor = 0;
 if (a == b && b != c) ispoor = 1;
 if (b == c && c != a) ispoor = 1;
 if (c == a && a != b) ispoor = 1;

 if (ispoor) {
 puts("Yes");
 } else {
 puts("No");
 }

 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <math.h>

#define lli long long int
#define ld long double
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{
    string s;
    cin>>s;
    lli x = s.size();
    for(int i = 0; i <x; i ++)
        cout<<"x";
    cout<<'\n';
    return ;
}



/*
*/

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
#include <iostream>
using namespace std;

int main(){
	int A,B,sum,sub,mult,max;
	cin >> A;
	cin >> B;

	sum = A+B;
	sub = A-B;
	mult = A*B;

	if(sum>=sub && sum>=mult)max=sum;
	else if(sub>=mult && sub>=sum)max=sub;
	else max=mult;

	cout << max << endl;

	return 0;
} 

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int ans = 0;
    if(a>b)ans+=b;
    else ans+=a;
    if(c>d)ans+=d;
    else ans+=c;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n;
/**********************************************/

int main(){
    cin >> n;
    int ans = 1;
    REP(i, 8){
        if(pow(2, i) > n){
            ans = pow(2, i-1);
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 21474836001234567L

class SegTree{
public:
  int n;
  vector<long> data, sum; // data: 区間内の値，sum:区間内の実際の和
  inline void lazy_eval(int k, int l, int r){
    if(data[k]>0){ // 最新の更新が下に伝搬していないとき
      sum[k] = data[k]*(r-l);
      if(k<n-1){
        data[2*k+1]=data[k];
        data[2*k+2]=data[k];
      }
      data[k]=0;
    }
  }
  void _update(int a, int b, long v, int k, int l, int r){
    lazy_eval(k,l,r);
    if(r<=a || b<=l) return;
    if(a<=l && r<=b){
      data[k] = v;
      lazy_eval(k,l,r);
      return;
    }
    int m=(l+r)/2;
    _update(a,b,v,k*2+1,l,m);
    _update(a,b,v,k*2+2,m,r);
    sum[k] = sum[k*2+1] + sum[k*2+2];
    return;
  }
  // [a,b) をvに更新
  void update(int a, int b, long v){ _update(a,b,v,0,0,n); }

  long _sum(int a, int b, int k, int l, int r){
    lazy_eval(k,l,r);
    if(r<=a || b<=l) return 0;
    if(a<=l && r<=b) return sum[k];
    int m=(l+r)/2;
    long vl = _sum(a,b,k*2+1,l,m);
    long vr = _sum(a,b,k*2+2,m,r);
    sum[k] = sum[k*2+1] + sum[k*2+2]; //??
    return vl+vr;
  }
  // [a,b) の合計
  long query(int a,int b){ return _sum(a,b,0,0,n); }

  SegTree(int n_){
    n=1;
    while(n<n_) n*=2;
    data = vector<long>(2*n-1, 0);
    sum = vector<long>(2*n-1, 0);
  }
};

int main(){
  int n,q;
  cin>>n>>q;
  vector<int> a(q);
  vector<long> b(q);
  rep(i,q) cin>>a[i]>>b[i];

  SegTree st(n);

  rep(i,q){
    int li=-1,ri=a[i];
    while(ri-li>1){
      int mi=(li+ri)/2;
      // [mi,a[i])を埋めなおす
      long sumnew = st.query(mi,a[i]) + b[i];
      long newh = sumnew/(a[i]-mi);
      if(sumnew%(a[i]-mi)!=0) newh++;

      if(st.query(mi,mi+1) >= newh) li = mi;
      else ri = mi;
    }
    long sumnew = st.query(ri,a[i]) + b[i];
    long newh = sumnew/(a[i]-ri);
    long rem = sumnew%(a[i]-ri);
    st.update(ri+rem, a[i], newh);
    st.update(ri, ri+rem, newh+1);

//    rep(j,n) cout << st.query(j,j+1) << endl; cout<<endl;
  }

  rep(i,n) cout << st.query(i,i+1) << endl;

  return 0;
}


Measured memory_bytes: 6912
import java.util.Scanner;

public class Main{
	static long mod = (long)1e9+7;
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			
			int N = scan.nextInt();
			int M = scan.nextInt();
			long ans = 0;
			long Npow = N;
			long Mpow = M;
			
			for(int i =N-1;i>0;i--) {
				Npow = i*Npow%mod;
				//System.out.println(Npow);
			}
			for(int i =M-1;i>0;i--) {
				Mpow = i*Mpow%mod;
			}
			
			//System.out.println(Npow);
			//System.out.println(Mpow);
			if(Math.abs(N-M)==1) {
				
				ans+=Npow*Mpow%mod;
				System.out.println(ans);
				
			}else if(N==M){	
				ans+=(Npow*Mpow%mod)*2%mod;
				System.out.println(ans);
				
			}else{
				System.out.println(0);
			}
			

		}
		
		
	}
	
	
		

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll x;
    cin>>x;
    ll a[x];
    ll ans = 0;
    ll maxT = 0;
    for(int i=0;i<x;i++) {
        cin>>a[i];
        if(i == 0) {
            maxT = a[0];
        }
        if(i > 0) {
            if(a[i] < a[i-1]) {
                ans += (a[i-1]-a[i]);
                a[i] = a[i-1];
            }
            maxT = a[i];
        }
    }
    // 2 1 5 4 3
    cout<<ans<<endl;

}


Measured memory_bytes: 5132
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
int main(void)
{
	int n;//石の個数
	char *c;//石の色 n個
	int lw=0;//左にあるWの数
	int rr=0;//右にあるRの数
	int *aaa;//しきいi(i=0^n+1)の時の操作回数 n+1個
	int min=INT_MAX;
	scanf("%d",&n);
	c=(char *)malloc(sizeof(char)*n);
	aaa=(int *)malloc(sizeof(int)*n+1);
	int i;
	for(i=0;i<n;i++)
	{
		scanf(" %c",&c[i]);//改行を読み込まない
	}
	for(i=0;i<n;i++)
	{
		if(c[i]=='R')
		{
			rr++;
		}
	}
	if(lw<rr)
	{
		aaa[0]=rr;
	}
	else
	{
		aaa[0]=lw;
	}
	for(i=1;i<n+1;i++)
	{
		if(c[i-1]=='W')
		{
			lw++;
		}
		else
		{
			rr--;
		}
		
		if(lw<rr)
		{
			aaa[i]=rr;
		}
		else
		{
			aaa[i]=lw;
		}
	}
	for(i=0;i<n+1;i++)
	{
		if(aaa[i]<min)
		{
			min=aaa[i];
		}
	}
	printf("%d",min);
	

	
	free(c);
	c=NULL;
	free(aaa);
	aaa=NULL;
	return 0;
}

Measured memory_bytes: 2564
#include<stdio.h>
int main(void)
{
    int a,b;
	scanf("%d %d",&a,&b);
	while(1){
	    if(a==0&&b==0) break;
	    if (a<=b){
		    printf("%d %d\n",a,b);
		}
		else{
		    printf("%d %d\n",b,a);
		}
		scanf("%d %d",&a,&b);
	}
	return 0;
}

Measured memory_bytes: 2692
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

void chmax(string &s1, string s2) {
  if (s1.size() < s2.size()) {
    s1 = s2;
    return;
  }

  if (s1.size() == s2.size() && s1 < s2) {
    s1 = s2;
    return;
  }

  return;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int matches[10] = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};

  int N, M;
  cin >> N >> M;
  vector<int> as;
  for (int i = 0; i < M; ++i) {
    int ai;
    cin >> ai;
    as.push_back(ai);
  }

  string dp[10001];
  fill(dp, dp + 10001, "");
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < as.size(); ++j) {
      if (i == 0 || dp[i] != "") {
        int match = matches[as[j]];
        if (i + match <= N) {
          chmax(dp[i + match], dp[i] + to_string(as[j]));
        }
      }
    }
  }

  cout << dp[N] << endl;
}

Measured memory_bytes: 33024
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
using namespace std;

int chizu[51][51];

void labeling(int y,int x,int w,int h){
	chizu[y][x]=0;
	REP(dy,-1,2){
		REP(dx,-1,2){
			if(0 <= y+dy && y+dy < h && 0 <= x+dx && x+dx < w){
				if(chizu[y+dy][x+dx]){
					labeling(y+dy,x+dx,w,h);
				}
			}
		}
	}
}

int main(){
	int w,h;
	while(cin>>w>>h&&w&&h){

		int count=0;
		REP(i,0,h){
			REP(j,0,w){
				cin>>chizu[i][j];
			}
		}
		REP(i,0,h){
			REP(j,0,w){
				if(chizu[i][j]){
					count++;
					labeling(i,j,w,h);
				}
			}
		}

		p(count);
	}
	return 0;
}

Measured memory_bytes: 3220
#include <stdio.h>

int main(void){
  int a, b;
  int x;
  scanf("%d %d", &a, &b);
  if((a + b)%2 == 0){
    x = (a + b)/2;
    printf("%d\n", x);
  }
  else{
    x = (a + b)/2 + 1;
    printf("%d\n", x);
  }
  return 0;
}


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

int gcd(int a, int b) {
  if(a < b) return gcd(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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

  long long total = 0;
  for(int i=1; i <= n; i++) for(int j=1; j <= n; j++) for(int k=1; k <= n; k++) {
    total += gcd(i, gcd(j, k));
  }
  cout << total << endl;
}


Measured memory_bytes: 3624
# Import
from collections import deque

# I/O
def read(): return input()
def read_int(): return int(input())
def read_array(type=int): return list(map(type, input().split()))
def read_tupple(type=None):
    tmp = input().split()
    if type is None: return map(int, tmp)
    assert len(tmp) == len(type)
    return [type[i](tmp[i]) for i in range(len(tmp))]

# Implementation
a, b = read_tupple([int, str])
b = b.split('.')
b = int(b[0]) * 100 + int(b[1])
print(a * b // 100)

Measured memory_bytes: 64988
#include <iostream>
#include <string>

template <typename anyType>
void err(anyType message) {
    std::cerr << message << std::endl;
}

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

#if DEBUG_ON
    freopen("input", "r", stdin);
#endif

    int n, res = -1;
    std::cin >> n;
    double tax = 1.08;
    for (int i = 1; i <= n; ++i) {
        int x = (int) (i * tax);
        if (x == n) {
            res = i;
            break;
        }
    }
    if (res == -1) {
        std::cout << ":(\n";
    } else {
        std::cout << res << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  long long int N, D;
  cin >> N >> D;
  long long int X[N];
  long long int Y[N];
  for (int i=0; i<N; i++) {
    cin >> X[i] >> Y[i];
  }
  int c = 0;
  for (int i=0; i<N; i++) {
    if (X[i]*X[i] + Y[i]*Y[i] <= D*D) c++;
  }
  cout << c;
  return 0;
}

Measured memory_bytes: 6700
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    ll k;
    cin >>s >> k;
    ll n = s.length();
    ll ans = 1, id = -1;
    for(int i=0;i<n;i++){
    	if(s[i] != '1'){
    		ans = (s[i] - '0');
    		id = i;
    		break;
    	}
    }
    if(id == -1) cout << 1 << endl;
    else if(id +1 <= k){
    	cout << ans << endl;
    }
    else{
    	cout << 1 << endl;
    }
    return 0;
}


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

int main(void)
{
    string s, output;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'B')
        {
            if (!output.empty())
            {
                output.pop_back();
            }
        }
        else
        {
            output.push_back(s[i]);
        }
    }
    cout << output << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 0, b = 0, c, d, n, k = 0, ans = 0;
string s, t;


int main()
{
	cin >> n;
	vector<int> b(n + 1);
	for (int i = 1; i < n ; i++)
		cin >> b[i];
	b[0] = b[1]; b[n] = b[n-1];
	int sum = 0;
	rep(i, n)
		sum += min(b[i], b[i + 1]);
	cout << sum << endl;


	return 0;
}


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

int main(void){
  int y,m,d;
  char c,e;
  cin >> y >> c >> m >> e >> d;
  if(m <= 4) cout << "Heisei" << endl;
  else cout << "TBD" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
#define rep(i, n) for(int i=0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
#define PRINT(V) for (auto v : (V))cout << v << " "
inline int GCD(int a, int b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;

int main()
{
    int N;
    string S;
    cin >> N >> S;
    vi cnt(26);
    ll ans = 1;
    rep(i, 26)
    {
        cnt.at(i) = count(ALL(S), char(int('a')+i));
        ans = (ans * (cnt.at(i)+1))%MOD;
    }
    ans -= 1;
    cout << ans << endl;
}

Measured memory_bytes: 512
/**
 *    Author:  "Robin Singh" !!!!    
**/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define ifr(a, value) insert(a.begin(), value)
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define szz(v) ((int)(v).size())  
#define vi vector<int>
#define vll vector<ll>
#define str string
#define fr(i, j, k) for(i = j; i < k; i++)
#define bk(i, j, k) for(i = j; i >= k; i--)
#define frit(a, it) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)        // use fill() for value other than 0 //
#define rtn return 
#define clk fprintf(stderr, "\nTIME = %lf\n", 1.0 * clock()/CLOCKS_PER_SEC)
#define nl "\n"
#define inf 1LL<<61
#define dbg(x) (cerr << #x << ": " << x << "\n")
const long long mod = 1e9+7;

ll gcd(ll a,ll b) { return b==0 ? a : gcd(b, a%b); }   // no need to swap a, b, it auto. happens after first call //
ll expo(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0) { if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
void matmul(ll a[][2], ll b[][2]) { ll tmp[2][2]; for(int i=0; i<2; i++) { for(int j=0; j<2; j++) { tmp[i][j] = 0; for(int k=0; k<2; k++) tmp[i][j] = (tmp[i][j] + a[i][k]*b[k][j]) % mod; }} for(int i=0; i<2; i++) for(int j=0; j<2; j++) a[i][j] = tmp[i][j]; }
ll fibo(int n)    // returns nth fibonacci number, also S(n) = f(n+2)-1
{ if(n == 0) return 0; else if(n == 1) return 1; ll T[2][2] = { {0, 1} , {1, 1} }; ll res[2][2] = { {1, 0}, {0,1} }; n--; while(n) { if(n & 1) matmul(res, T); n >>= 1; matmul(T, T); } return res[1][1]; }

const int nn = 2e5 + 10;
ll sum[nn], xr[nn];

bool chk(int l, int r)
{
   return sum[r]-sum[l-1] == (xr[r] ^ xr[l-1]);
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, x;
    cin >> n;
    for(int i=1; i<=n; i++)
    {
        cin >> x;
        sum[i] = sum[i-1] + x;
        xr[i] = xr[i-1] ^ x;
    }
    ll ans = 0;
    int l = 1;
    
    for(int r = 1; r <= n; r++)
    {
        while(! chk(l, r))                                  // if 1->3 is not answer 1->4 can't be the answer.
            l++;
        ans += r-l+1;                                     // 1 for single element 
 //       dbg(r); dbg(l); dbg(ans);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;
class Main{
	public static void main(String[] a){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int debt = 100000;
		for(int i = 0; i < n; i++){
			debt += debt / 20;
			debt = up(debt);
		}
		System.out.println(debt);
	}
	static int up(int money){
		money += 999;
		money -= money % 1000;
		return money;
	}
}

Measured memory_bytes: 17164
# 0028
array = []
while True:
    try:
        a = input()
        if a == '': break
        array.append(int(a))
    except EOFError:
        break
count = list(map(lambda a: array.count(a), set(array)))
modes = list(filter(lambda a: array.count(a) == max(count), set(array)))
print(*modes, sep = '\n')

Measured memory_bytes: 7600
#include <iostream>
#include <cmath>
#include <string>
#include <cstdlib>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cctype>
#include <map>
#include <cstring>
#include <typeinfo>
#define REP(i,n) for(int i = 0;i < n ;i++)
#define FOR(i,m,n) for(int i= m ;i<n;i++)
using namespace std;

int main(void){
  int N,i;
  int sum=0;
  cin >> N;
  for(i=0;i<=N;i++){
    sum+= i;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    args = input().rstrip().split(' ')
    N = int(args[0])
    item_list = {}
    for i in range(N):
        item = input().rstrip()
        if(item in item_list):
            item_list[item] += 1
        else:
            item_list[item] = 0
    print(len(item_list))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 35420