akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int a[45];
int b[45];
int c[45];

int dp[41][415][415];

int gcd(int x, int y);
int min(int a, int b);

int main() {

	int i, j, k;

	for (i = 0; i <= 40; i++) {
		for (j = 0; j <= 400; j++) {
			for (k = 0; k <= 400; k++) {
				dp[i][j][k] = 114514;
			}
		}

	}

	int N, Ma, Mb;

	scanf("%d %d %d",&N,&Ma,&Mb);

	for (i = 0; i < N; i++) {
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
	}

	dp[0][0][0] = 0;
		
	for (i = 0; i < N; i++) {
		for (j = 0; j <= 400; j++) {
			for (k = 0; k <= 400; k++) {
				if (dp[i][j][k] == 114514) { continue; }
				dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
				dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
			}
		}

	}
	int ans = 114514;

	for (i = 1; i <= 400; i++) {
		for (j = 1; j <= 400; j++) {
			if (i / gcd(i, j) == Ma&&j / gcd(i, j) == Mb) {
				ans = min(ans,dp[N][i][j]);
			}
		}
	}

	if (ans == 114514) { ans = -1; }

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


	return 0;
}
int gcd(int x, int y){
	int t;
	while (y != 0)
	{
		t = x % y;
		x = y;
		y = t;
	}
	return x;
}
int min(int a, int b) {
	if (a >= b) { return b; }
	else { return a; }
}

Measured memory_bytes: 27136
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<Integer, Integer> map1 = new HashMap<Integer, Integer>();
    HashMap<Integer, Integer> map2 = new HashMap<Integer, Integer>();
    for(int i = 0; i < n ; i++) {
      int v = sc.nextInt();
      if(i % 2 == 0) {
        if(map1.containsKey(v)) {
          map1.put(v, map1.get(v) + 1);
        } else {
          map1.put(v, 1);
        }
      } else {
        if(map2.containsKey(v)) {
          map2.put(v, map2.get(v) + 1);
        } else {
          map2.put(v, 1);
        }
      }
    }
    int m1 = 0;
    int m12 = 0;
    int m2 = 0;
    int m22 = 0;
    int p1 = 0;
    int p2 = 0;
    int k1 = 0;
    int k2 = 0;
    for(int key : map1.keySet()) {
      if(map1.get(key) > m1) {
        m1 = map1.get(key);
        p1 = key;
        k1 = 1;
      } else if(map1.get(key) == m1) {
        k1++;
      }
    }
    for(int key : map2.keySet()) {
      if(map2.get(key) > m2) {
        m2 = map2.get(key);
        p2 = key;
        k2 = 1;
      } else if(map2.get(key) == m2) {
        k2++;
      }      
    }

    for(int key : map1.keySet()) {
      if(map1.get(key) < m1) {
        m12 = Math.max(m12, map1.get(key));
      }
    }
    for(int key : map2.keySet()) {
      if(map2.get(key) < m2) {
        m22 = Math.max(m22, map2.get(key));
      }   
    }
    
    int ans = 0;
    if(p1 == p2) {
      if((k1 == 1) && (k2 == 1)) {
        if(m1 + m22 > m12 + m2) {
          ans = n - (m1 + m22);
        } else {
          ans = n - (m12 + m2);
        }
      } else {
        ans = n - (m1 + m2);
      }
    } else {
      ans = n - (m1 + m2);
    }    
    System.out.println(ans);
  }
}


Measured memory_bytes: 65072
#include <stdio.h>
#define M 1000

void insertionSort(int[],int);

int main(void){
    int n,i;
    int A[M+1];
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    
    insertionSort(A,n);
    
}
void insertionSort(int A[],int N){
    int v,i,j;
    for(i=0;i<N;i++){
        v = A[i];
        j = i-1;
        while( j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
	for(j=0;j<N-1;j++)printf("%d ",A[j]);
	printf("%d\n",A[j]);
    }
}



Measured memory_bytes: 2128
package main

import "fmt"

var field [1000]string
var paths [1000][1000]int

var CYCLE = 1000000007

func main() {
	var height, width int
	fmt.Scan(&height, &width)
	for i := 0; i < height; i++ {
		fmt.Scan(&field[i])
	}

	for i := 0; i < height; i++ {
		for j := 0; j < width; j++ {
			s := 0
			if field[i][j] == '.' {
				if i == 0 {
					if j == 0 {
						s = 1
					} else {
						s = paths[i][j-1]
					}
				} else {
					if j == 0 {
						s = paths[i-1][j]
					} else {
						s = (paths[i-1][j] + paths[i][j-1]) % CYCLE
					}
				}
			}
			paths[i][j] = s
		}
	}

	fmt.Println(paths[height-1][width-1])
}


Measured memory_bytes: 9472
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define INPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.in"
#define OUTPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.out"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

void solve()
{
    int n;
    cin >> n;
    cout << n / 3 << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
    //freopen(INPUT, "r", stdin);freopen(OUTPUT, "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}



Measured memory_bytes: 256
n, d, a = map(int, input().split())
p = []
for i in range(n):
    x, h = map(int, input().split())
    p.append((x, h))

from collections import deque

p.sort()

q = deque()
total = 0
ans = 0
for i in range(n):
    x, h = p[i][0], p[i][1]
    while q and q[0][0] < x:
        total -= q[0][1]
        q.popleft()
    h -= total
    if h > 0:
        num = (h+a-1)//a
        ans += num
        damage = num*a
        total += damage
        q.append((x+2*d, damage))

print(ans)

Measured memory_bytes: 72408
import java.util.Scanner;

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

			System.out.println(s.substring(0, s.lastIndexOf("FESTIVAL")));
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		}
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    cin >> p >> q >> r;
    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(), q.end(), greater<int>());
    sort(r.begin(), r.end(), greater<int>());
    while(p.size() > x) p.pop_back();
    while(q.size() > y) q.pop_back();
    ll ans = accumulate(p.begin(), p.end(), 0ll) + accumulate(q.begin(), q.end(), 0ll);
    int eaten = p.size() + q.size();
    for(int ri : r) {
        if(eaten == x + y) {
            int rem = min(p.empty() ? lim<int>::max() : p.back(), q.empty() ? lim<int>::max() : q.back());
            if(ri > rem) {
                ans += ri;
                ans -= rem;
                if(not p.empty() and rem == p.back()) {
                    p.pop_back();
                } else {
                    q.pop_back();
                }
            }
        } else {
            ans += ri;
            eaten++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<int> A(N + 1);
  for (int i = 0; i < N + 1; ++i) {
    cin >> A[i];
  }
  vector<int> B(N);
  for (int i = 0; i < N; ++i) {
    cin >> B[i];
  }
  ll ans = 0;
  for (int i = 0; i < N; ++i) {
    int cnt;

    cnt = min(A[i], B[i]);
    A[i] -= cnt;
    B[i] -= cnt;
    ans += cnt;
    
    cnt = min(A[i + 1], B[i]);
    A[i + 1] -= cnt;
    B[i] -= cnt;
    ans += cnt;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define mod 1000000007
using namespace std;
using ll=long long int;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vii;
typedef pair<ll ,ll> pii;
const int dx[]={-1,1,0,0};
const int dy[]={0,0,-1,1};
#define MAXN   1000001 
  
// stores smallest prime factor for every number 
int spf[MAXN]; 
  
// Calculating SPF (Smallest Prime Factor) for every 
// number till MAXN. 
// Time Complexity : O(nloglogn) 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
void solve()
{
	sieve();
	int n;
	cin>>n;
	int arr[n],b[n];
	
	forn(i,n)
	{
		cin>>arr[i];
		b[i]=arr[i];
	}
	set<int> pp;
	bool f=0;
	forn(i,n)
	{
		set<int> p;
		while(arr[i]!=1)
		{
			p.insert(spf[arr[i]]);
			arr[i]/=spf[arr[i]];
		}
		for(auto i:p)
		{
			if(pp.count(i))f=1;
			pp.insert(i);
		}
		if(f)
		{
			break;
		}
	}
	if(f==0)
	{
		cout<<"pairwise coprime"<<endl;
		return;
	}
	int gg=0;
	forn(i,n)
	{
		gg=__gcd(gg,b[i]);
	}
	if(gg==1)
	{
		cout<<"setwise coprime"<<endl;
	}
	else
	{
		cout<<"not coprime"<<endl;
	}
	
}
int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int t=1;
  //  cin>>t;
    while(t--)
	solve();
    return 0;
}


Measured memory_bytes: 15376
#include<bits/stdc++.h>
using namespace std;
int dis(int x,int y){return x-y>0?x-y:y-x;}
int a[10],n=5,k;bool f=1;
int main()
{
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);scanf("%d",&k);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;++i)
		for(int j=i+1;j<=n;++j)
			if(dis(a[i],a[j])>k)
				f=0;
	puts(f?"Yay!":":(");
} 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <array>
#include<unordered_map>
#include<unordered_set>

using namespace std;
#define IO                 \
	ios::sync_with_stdio(0); \
cin.tie(0);              \
cout.tie(0);
#define forn(i, n) for (int i = 0; i < n; i++)
#define forse(i, s, e) for (int i = s; i < e; i++)
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define mp make_pair
#define fi first
#define se second
#define all(vec) vec.begin(), vec.end()
#define getcurrtime() \
	cerr << "Time = " << ((double)clock() / CLOCKS_PER_SEC) << endl

#define watch(x) cerr << (#x) << " is " << (x) << endl;

#ifndef LOCAL
#define cerr if(false)cerr
#endif
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll P=1e9+7;
double PI=3.141592653589793;
const int arrn = 2e5 + 1;


void solve(){
	ll t=100;
	ll x; cin >> x;
	int d=0;
	while(t<x){
		t+=(t/100);
		d++;
	}
	cout << d << endl;
}

int main() {
	IO;
	int T=1;
//	cin >> T;
	forn(c,T){
		solve();
	}
}



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

int main() {
  int n; std::cin >> n;
  std::vector<std::string> a(n);
  for (int i = 0; i < n; ++i) std::cin >> a[i];
  // int n = 5;
  // std::vector<std::string> a{"7.5", "2.4", "17.000000001", "17", "16.000000000"};

  /* ピリオドをすべての文字列に加える */
  for (int i = 0; i < n; i++)
    if (a[i].find('.') == std::string::npos) // ピリオドの有無
      a[i].push_back('.');                   // ピリオドを末尾に加える
  
  /* key:val = (c2, c5):cnt */
  std::map<std::pair<int, int>, long long> p;

  /* aの素因数2と5の数を数える */
  for (int i = 0; i < n; i++) {
    // a[i].length() => 文字列の長さ
    // a[i].find('.') => .(ピリオド)が存在すればその位置, なければstd::string::npos

    // std::cout << a[i] << " " <<  a[i].length() - a[i].find('.') - 1 << std::endl;
    /* 小数点以下の数 */
    int d_cnt = a[i].length() - a[i].find('.') - 1;
    int c2 = -d_cnt; // 2の数を-d_cntで初期化
    int c5 = -d_cnt; // 5の数を-d_cntで初期化
    
    /* 文字を数字に変換 */
    a[i].replace(a[i].find('.'), 1, ""); // .(ピリオド)を削除 str.replace(開始位置, 長さ, 置き換え後の新たな文字列)
    long long a_ll = std::stoll(a[i].c_str()); // long longに変換
    
    /* 2の数を取得 */
    while (a_ll%2 == 0) {
      ++c2;
      a_ll /= 2;
    }
    /* 5の数を取得 */
    while (a_ll%5 == 0) {
      ++c5;
      a_ll /= 5;
    }

    /* mapに key:val = (c2, c5):数 保持 */
    p[std::pair<int, int>(c2, c5)]++; // keyが存在しない場合は0が追加される
  }

  /* チェック */
  // for (auto itr = p.begin(); itr != p.end(); ++itr)
  //   // std::cout << "(" << (*itr).first.first << ", " << (*itr).first.second << ")" 
  //   //           <<  " " << (*itr).second << std::endl;
  //   std::cout << "(" << itr->first.first << ", " << itr->first.second << ")" 
  //             <<  " " << (*itr).second << std::endl;
  
  long long cnt = 0;
  for (auto itr_1 = p.begin(); itr_1 != p.end(); ++itr_1) {
    int c2_1 = itr_1->first.first;
    int c5_1 = itr_1->first.second;
    long long cnt_1 = itr_1->second;

    if (c2_1 >= 0 && c5_1 >= 0)
      cnt += cnt_1 * (cnt_1-1)/2;

    // if (itr_1->first.first >= 0 && itr_1->first.second >= 0)
    //   cnt += itr_1->second*(itr_1->second-1)/2;

    for (auto itr_2 = std::next(itr_1, 1); itr_2 != p.end(); ++itr_2) {
    int c2_2 = itr_2->first.first;
    int c5_2 = itr_2->first.second;
    int cnt_2 = itr_2->second;
      if (c2_1 + c2_2 >= 0 && c5_1 + c5_2 >= 0)
        cnt += cnt_1 * cnt_2;
      // if (itr_1->first.first + itr_2->first.first >= 0 && itr_1->first.second + itr_2->first.second >= 0)
      //   cnt += itr_1->second * itr_2->second;
    }

  }
  std::cout << cnt << std::endl;


  return 0;
}

Measured memory_bytes: 9544
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split("");

		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);
		int c = Integer.parseInt(str[2]);
		int d = Integer.parseInt(str[3]);

		if (a == b || b == c || c == d) {
			System.out.println("Bad");
		} else {
			System.out.println("Good");
		}
	}
}


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

static const int N = 4;
static const int N2 = 16;
static const int LIMIT = 100;

static const int dx[] = {0,-1,0,1};
static const int dy[] = {1,0,-1,0};
static const char dir[] = {'r','u','l','d'};
int MDT[N2][N2];


struct Puzzle {
    int f[N2], space, MD;
};


Puzzle state;
int limit; // ??±????????¶???
int path[LIMIT];

int getAllMD(Puzzle pz) {
    int sum=0;
    for(int i=0; i<N2; i++) {
	if( pz.f[i] == N2 ) continue;
	sum += MDT[i][pz.f[i]-1];
    }
    return sum;
}

bool isSolved(){
    for(int i=0; i<N2; i++)
	if( state.f[i] != i+1)
	    return false;
    return true;
}

bool DFS(int depth, int prev) {

    if( state.MD == 0 ) return true;
    if( depth + state.MD > limit ) return false; // ??±?????¶???OUT

    int sx = state.space / N;
    int sy = state.space % N;
    Puzzle tmp;
    for(int r=0; r<4; r++) {
	int tx = sx + dx[r];
	int ty = sy + dy[r];
	if( tx<0 or ty<0 or tx>=N or ty>=N ) continue;
	if( max(prev,r) - min(prev,r) == 2 ) continue;
	tmp = state;
	state.MD -= MDT[tx*N+ty][state.f[tx*N+ty]-1];
	state.MD += MDT[sx*N+sy][state.f[tx*N+ty]-1];
	swap(state.f[sx*N+sy], state.f[tx*N+ty]);
	state.space = tx*N+ty;

	if( DFS(depth+1, r) ) {
	    path[depth] = r;
	    return true;
	}
	state = tmp;
    }
    return false;	    
}

string iterative_deeping(Puzzle in) {
    in.MD = getAllMD(in);

    for(limit = in.MD; limit <=LIMIT; limit++) {
	state = in;
	if( DFS(0,-100) ) {
	    string ans = "";
	    for(int i=0; i<limit; i++)
		ans += dir[path[i]];
	    return ans;
	}
    }
    return "unsolvable";
}

int main() {
    for(int i=0; i<N2; i++)
	for(int j=0; j<N2; j++)
	    MDT[i][j] = abs(i/N-j/N) + abs(i%N-j%N);

    Puzzle in;

    for(int i=0; i<N2; i++) {
	cin >> in.f[i];
	if(in.f[i] == 0) {
	    in.f[i] = N2;
	    in.space = i;
	}
    }
    string ans = iterative_deeping(in);
    cout << ans.size() << endl;
    
    return 0;
}

Measured memory_bytes: 3184
/*
* Author:sam51305
*/
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define endl '\n'
#define f first
#define s second
#define mp make_pair
#define ll long long
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pb push_back
#define ary array

#define Yes cout << "Yes" <<endl;
#define No cout << "No" << endl;
int main() {
    fastio
    int x;
    for(int i=1;i<=5;i++){
        cin >> x;
        if(x == 0) cout << i;
    }

    return 0;
}


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

#ifdef LOCAL
#include "prabh.hpp"
#endif

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define rrange(v) v.rbegin(), v.rend()
#define mod (int)(1e9 + 7)
#define inf (int)(5e18)
#define N (int)(2e5 + 10)

using namespace std;

int dp[10005][100][2];
string s;
int n, d;

int digitSum(int pos, int mo, bool tight) {
	if (pos == n) return !mo;
	int &ans = dp[pos][mo][tight];
	if (ans != -1) return ans;

	ans = 0;
	int lim = tight ? s[pos] - '0' : 9;
	for (int i = 0; i <= lim; i++) {
		ans += digitSum(pos + 1, (mo + i) % d, tight and (i == lim));
		ans %= mod;
	}

	return ans;
}

void solve() {
	cin >> s >> d;
	n = s.length();
	memset(dp, -1, sizeof(dp));
	cout << (digitSum(0, 0, 1) - 1 + mod) % mod << endl;
}
// Remember to clear the global containers

// Got stuck and want to leave ? look at the bottom once..
int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
	// cin >> t_c;
	while (t_c--)
		solve();
}
/* Come on Dude .. Dont get up until u get the solution
 * Giving up not gonna help ryt ? So get ur lazy ass to code already
 * You can do it ... Stay Calm and Dont Panic :)
 */


Measured memory_bytes: 20088
void main() {
	auto ip = readAs!(int[]), A = ip[0], B = ip[1], C = ip[2];
	(C % gcd(A, B) == 0 ? "YES" : "NO").writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

int main(){
    int n; ll l;
    cin >> n >> l;
    ll a[n+1];
    rep(i,n) cin >> a[i+1];
    int p = 0;
    for(int i = 1; i < n; i++) {
        if(a[i] + a[i+1] >= l) p = i;
    }
    if(p == 0){
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    for(int i = 1; i < p; i++) cout << i << endl;
    for(int i = n-1; i >= p; i--) cout << i << endl;
    return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>

int main()
{
	int a[100],i,m=1,n;

	for(i=0;i<100;i++){
		a[i]=0;
	}

	while(scanf("%d",&n)!=EOF){
		a[n]++;
		if(a[n]>m) m=a[n];
	}

	for(i=0;i<100;i++){
		if(m==a[i]) printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 592
#include <stdio.h>
#define MAX_N 1000


int main(void){
	int n, m, a[MAX_N], i, decided;

	while(1){
		scanf("%d%d",&n,&m);
		if(n == 0 && m == 0){
			break;
		}

		for(i = 0;i < n;i++){
			scanf("%d",&a[i]);
		}

		// endが1以上になれば終了
		decided = 0;

		// 非負判定
		for(i = 0;i < n;i++){
			if(a[i] < 0){
				decided = i + 1;
			}
		}
		if(decided == 0){
			// mとa[i]との剰余を取り,その最大値を探す。
			int max = -1, min_idx = MAX_N, min_cnt = 0;
			for(i = 0;i < n;i++){
				if(max < m % a[i]){
					max = m % a[i];
				}
			}

			// mとa[i]の剰余がmaxである,a[i]の最小値を探す。
			for(i = 0;i < n;i++){
				if(max == m % a[i] && (min_idx == MAX_N || a[min_idx] > a[i])){
					min_idx = i;
				}
			}

			// mとa[i]の剰余がmaxで,a[i]の最小値がa[min_idx]である数を数える。
			for(i = 0;i < n;i++){
				if(max == m % a[i] && a[min_idx] == a[i]){
					min_cnt++;
				}
			}
			if(min_cnt == 1){
				decided = min_idx + 1;
			}else{
				// ホープを選任
				decided = n;
			}


		}

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


	}
	return 0;
}

Measured memory_bytes: 1032
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define INF 1000000000000000LL
const ll MOD = 1000000007;
const double PI = acos(-1);
//|| stoll to_string
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl

signed main(){
	IO_STREAM;
	ll N;
	cin>>N;
	vector<pair<ll,int>>Fs;
	ll n=N;
	for(ll i=2;(i*i)<=N;i++){
		int cnt=0;
		while(n%i==0){
			n/=i;
			cnt++;
		}
		Fs.emplace_back(i,cnt);
		DBG(i,"^",cnt,"");
		if(n==1) break;
	}
	if(n>1){
		Fs.emplace_back(n,1);
		DBG(n,"^",1,"");
	}
	int ans=0;
	for( auto v: Fs ){
		int cnt=v.second;
		rep(i,1,100){
			if(cnt>=i){
				cnt-=i;
				ans++;
			}
			else{
				break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

int main()
{
    int N, K;
    cin >> N >> K;
    
    if (N % K == 0) {
        cout << "0" << endl;
    }else{
        cout << "1" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
using namespace std;
using P = pair<int, int>;

string S, T, U;
int A, B;

int main()
{
	cin >> S >> T;
	cin >> A >> B;
	cin >> U;
	if (S == U) {
		A--;
	}
	else {
		B--;
	}
	cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
int a, b, c, ans = 0;
int main() {
    scanf("%d%d%d", &a, &b, &c);
    if (a < b) std::swap(a, b);
    if (b < c) std::swap(b, c);
    if (a < b) std::swap(a, b);
    if (b < c) std::swap(b, c);
    while (b < a) b++, c++, ans++;
    while (c < a) c += 2, ans++;
    if (c > a) a++, b++, ans++;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
ll a,b,c;
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	a=read(),b=read(),c=read();
	if((a&1)&&(b&1)&&(c&1))cout<<min(a*b,min(a*c,b*c));
	else puts("0");
	return 0;
}




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

a_sum = sum(a)
x, ans = 0, 10**20

for i, v in enumerate(a):
    x += v
    if i < n-1:
        ans = min(ans, abs(a_sum-2*x))

print(ans)
exit(0)

Measured memory_bytes: 24832
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();

        int A[][] = new int[n][m];
        int B[][] = new int[m][l];
        long cnt = 0;
        int ai = 0, bi = 0, abj = 0, x = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                int num = sc.nextInt();
                A[i][j] = num;
            }
        }
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < l; j++) {
                int num = sc.nextInt();
                B[i][j] = num;
            }
        }
        while (x < n * l) {
            cnt += A[ai][abj] * B[abj][bi];
            if (abj + 1 == m) {
                System.out.print(cnt);
                x++;
                if (x % l != 0) {
                    System.out.print(" ");
                } else {
                    System.out.println("");
                }
                cnt = 0;
                abj = 0;
                if (bi < l - 1) {
                    bi++;
                } else {
                    bi = 0;
                    if (ai < n - 1) {
                        ai++;
                    }
                }
            }else{
                abj++;
            }
        }
    }
}

Measured memory_bytes: 56108
#include<bits/stdc++.h>
using namespace std;
#define int  long long int
#define fi first
#define se second
#define pb push_back
#define soo(v) sort(v.rbegin(),v.rend())
#define so(v) sort(v.begin(),v.end())
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define endl '\n'
#define dbv(v) cout<<endl;cout<<#v<<"-->> ";for(auto it:v){cout<<it<<" ";}cout<<endl;
#define dbm(m)cout<<endl;cout<<#m<<"-->> ";for(auto it:m){cout<<it.fi<<" "<<it.se.fi<<" "<<it.se.se<<endl;}
#define dbs(s)cout<<endl;cout<<#s<<"-->> ";for(auto it:s){cout<<it<<" ";}cout<<endl;
#define mod 1000000007
#define db1(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl;
#define mx 1e18
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define double long double
#define re(s) reverse(s.begin(),s.end())
#define io std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
int powe(int x,int n)
{
  if(n==0)return 1;
  if(n%2==0)
    return powe((x%mod*x%mod)%mod,n/2)%mod;
  return (x%mod*powe((x%mod*x%mod)%mod,(n-1)/2))%mod;
}
int gcd(int A,int B)
{
  if(B==0)return A;
  return gcd(B,A%B);
}


int32_t main()
{
  io
int a,b,c,d;
cin>>a>>b>>c>>d;
int cc=0;
while(1)
{

cc++;
if(c-b<=0)
{
  cout<<"Yes"<<endl;return 0;
}
else if(a-d<=0)
{
  cout<<"No"<<endl;return 0;
}
if(cc%2==1)
c-=b;
else
a-=d;
}
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


bool isprime(int x){
  for (int i=2; i*i<=x; i++){
    if (x % i == 0) return false;
  }
  return true;
}

int main() {
  int n; cin >>n;
  vector<int> A(n); rep(i, n) cin >>A[i];
  int res = 0;
  rep(i, n) if (isprime(A[i])) res++;
  cout << res <<endl;
}



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

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

    bool isApeared[1000000] = {};

    int ans = 0;
    while (1)
    {
        ans++;
        if (isApeared[s])
        {
            cout << ans << endl;
            return 0;
        }
        isApeared[s] = true;
        if (s % 2 == 0)
        {
            s /= 2;
        }
        else
        {
            s *= 3;
            s += 1;
        }
    }
}


Measured memory_bytes: 1280
N, X, M = map(int, input().split())
A = [X]
A_dict = {X}
a = X
s = X
r = 0
r0 = 0
l = 0
amari = 0

for i in range(M+1):
  a = a ** 2 % M
  if a in A_dict:
    r0 = A.index(a)
    l = len(A[r0:])
    r = (N - i - 1) // l
    amari = (N - i - 1) % l
    s = s + sum(A[r0:])*r + sum(A[r0:r0+amari])
    break
  A.append(a)
  A_dict.add(a)
  s += A[-1]

print(s)

Measured memory_bytes: 13132
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		
		Console.WriteLine("{0}",s[0]+s[1]+s[2]>=22?"bust":"win");
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  ll n;
  cin >> n;
  vector<ll> a(n + 2);
  int sum = 0;
  a[0] = 0;
  a.back() = 0;
  for(int i = 1; i <= n; ++i)
  {
    cin >> a[i];
    sum += abs(a[i] - a[i - 1]);
  }
  sum += abs(a[n]);

  for(int i = 1; i <= n; ++i)
  {
    if (
      (a[i - 1] <= a[i] && a[i] <= a[i + 1]) ||
      (a[i - 1] >= a[i] && a[i] >= a[i + 1])
    )
    {
      cout << sum << endl;
    }
    else
    {
      cout << sum - min(abs(a[i] - a[i - 1]), abs(a[i] - a[i + 1])) * 2  << endl;
    }
    
  }

}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3984
/*
 *ver3
 *l_gcdとr_gcdの配列計算方法変更
 */

import java.util.Scanner;
import java.util.Arrays;

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

	int n = scan.nextInt();
	int[] a = new int[n];
	for(int i = 0; i < n; i++){
	    a[i] = scan.nextInt();
	}
	
	//最大公約数の配列
	int[] gcd = new int[n];

	//端の処理
	gcd[0] = ruisekiGcd(a, 1, n);
	gcd[n-1] = ruisekiGcd(a, 0, n-1);

	//右側、左側累積GCDを作成
	int[] l_gcd = new int[n];
	int[] r_gcd = new int[n];
	l_gcd[0] = a[0];
	r_gcd[n-1] = a[n-1];
	for(int i = 1; i < n-1; i++){
	    l_gcd[i] = getGcd(l_gcd[i-1], a[i-1]);
	    r_gcd[n-i-1] = getGcd(r_gcd[n-i], a[n-i]);
	}
	
	//累積GCDを作成
	for(int i = 1; i < n-1; i++){
	    gcd[i] = getGcd(l_gcd[i], r_gcd[i]);
	}

	//累積GCDの最大値を計算
	Arrays.sort(gcd);
	
	System.out.println(gcd[n-1]);
    }

    static int ruisekiGcd(int[] a, int s, int l){
	int gcd = a[s];
	for(int i = s+1; i < l; i++){
	    gcd = getGcd(gcd, a[i]);
	}
	return gcd;
    }

    static int getGcd(int a, int b){
	if(a < b){
	    int tmp = a;
	    a = b;
	    b = tmp;
	}

	while(b != 0){
	    int tmp = a % b;
	    a = b;
	    b = tmp;
	}
	
	return a;
    }
}


Measured memory_bytes: 50596
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(new InputStreamReader(System.in))) {
            while (sc.hasNextInt()) {
                int cellCount = sc.nextInt();
                int diceCount = sc.nextInt();

                if (cellCount == 0) {
                    return;
                }

                List<SugorokuCell> cells = readCells(sc, cellCount);
                int[] dices = readDices(sc, diceCount);

                int result = countGoalStep(cells, dices);
                System.out.println(result);
            }
        }
    }

    private static int[] readDices(Scanner sc, int diceCount) {
        int[] dices = new int[diceCount];

        for (int i = 0; i < diceCount; i++) {
            dices[i] = sc.nextInt();
        }

        return dices;
    }

    private static List<SugorokuCell> readCells(Scanner sc, int cellCount) {
        List<SugorokuCell> cells = new ArrayList<>();

        for (int i = 0; i < cellCount; i++) {
            int cellNo = i;
            int offset = sc.nextInt();
            cells.add(new SugorokuCell(cellNo, offset));
        }

        return cells;
    }

    private static int countGoalStep(List<SugorokuCell> cells, int[] dices) {
        int currentCell = 0;
        int goalCell = cells.size() - 1;

        for (int i = 0; i < dices.length; i++) {
            int dice = dices[i];
            currentCell += dice;

            if (goalCell <= currentCell) {
                return i + 1;
            }

            SugorokuCell cell = cells.get(currentCell);
            currentCell += cell.getOffset();

            if (goalCell <= currentCell) {
                return i + 1;
            }

            if (currentCell < 0) {
                currentCell = 0;
            }

        }

        throw new RuntimeException("This line not be execute, "
                + "Because every inputs can be resolve");
    }

    public static class SugorokuCell {
        private final int cellNo;
        private final int offset;

        public SugorokuCell(int cellNo, int offset) {
            this.cellNo = cellNo;
            this.offset = offset;
        }

        public int getCellNo() {
            return cellNo;
        }

        public int getOffset() {
            return offset;
        }
    }
}

Measured memory_bytes: 36032
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
 
int main(){
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(m), b(m), c(k), d(k);
    vector<vector<int>> friend_list(n+1);
    for(int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        friend_list[a[i]].push_back(b[i]);
        friend_list[b[i]].push_back(a[i]);
    }
    vector<vector<int>> block_list(n+1);
    for(int i = 0; i < k; i++) {
        cin >> c[i] >> d[i];
        block_list[c[i]].push_back(d[i]);
        block_list[d[i]].push_back(c[i]);
    }
    int label = 1;
    vector<int> labels(n+1, -1), label_num{0};
    for(int i = 1; i < n+1; i++){
        if(labels[i] == -1){
            queue<int> q;
            q.push(i);
            labels[i] = label;
            label_num.push_back(1);
            while(q.empty() != true){
                int v = q.front();
                q.pop();
                for(int x : friend_list[v]){
                    if(labels[x] == -1){
                        q.push(x);
                        labels[x] = label;
                        label_num[label]++;
                    }
                }
            }
            label++;
        }
    }
    vector<int> correction(n+1);
    for(int i = 0; i < m; i++){
        if(labels[a[i]] == labels[b[i]]){
            correction[a[i]]++;
            correction[b[i]]++;
        }
    }
    for(int i = 0; i < k; i++){
        if(labels[c[i]] == labels[d[i]]){
            correction[c[i]]++;
            correction[d[i]]++;
        }
    }
    for(int i = 1; i < n+1; i++){
        cout << label_num[labels[i]] - correction[i] - 1 << " ";
    }
    return 0;
}

Measured memory_bytes: 14200
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math, core.stdc.stdio;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }


void main() {
    int a,b,c;
    scanf("%d%d%d", &a,&b,&c);
    writeln(a+b >= c ? "Yes" : "No");
    auto _ = readln(); // dbg
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

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

    int cb = count(ALL(s), '#');
    int cw = n-cb;

    int ans = cb;

    int b = 0;
    REP(i,n){
      chmin(ans, b+cw);
      if(s[i] == '#'){
	++b;
      }else{
	--cw;
      }
    }

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


Measured memory_bytes: 720
from collections import deque


def nearlist(N, LIST):  # 隣接リスト
    NEAR = [set() for _ in range(N)]
    for a, b in LIST:
        NEAR[a - 1].add(b - 1)
        NEAR[b - 1].add(a - 1)
    return NEAR


def bfs(NEAR, S, N):  # 幅優先探索  # キュー
    dist = [-1 for _ in range(N)]  # 前処理
    dist[S] = 0
    que, frag = deque([S]), set([S])

    while len(que) > 0:
        q = que.popleft()
        for i in NEAR[q]:  # 移動先の候補
            if i in frag:  # 処理済みか否か
                continue
            dist[i] = dist[q] + 1
            que.append(i), frag.add(i)
    return dist


n, u, v = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n - 1)]

near = nearlist(n, ab)
tkdist, akdist = bfs(near, u - 1, n), bfs(near, v - 1, n)

node = [i for i in range(n) if tkdist[i] <= akdist[i]]
ans = max((akdist[i], i) for i in node)
print(ans[0] - 1)


Measured memory_bytes: 144752
import sys
a,b,c,k = map(int, input().split())

n_sum = 0
if a >= k:
  n_sum += k
  print(n_sum)
  sys.exit()
else:
  n_sum += a
  k -= a

k -= b

if k <=0:
  print(n_sum)
  sys.exit()
  
if c >= k:
  n_sum -= k
  print(n_sum)
  sys.exit()
else:
  n_sum -= c
  print(n_sum)
  sys.exit()

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const ll INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int n;
vi pool;
vi s;

void print(){
    char tmp[n];
    rep(i,n){
        tmp[i] = 'a' + s[i];
    }
    tmp[n] = '\0';
    cout << tmp << endl;
}

void dfs(int cur){
    if(s.size() == n){
        print();
        return;
    }
    for(auto x : pool){
        s.push_back(x);
        dfs(cur);
        s.pop_back();
    }
    s.push_back(cur);
    pool.push_back(cur);
    dfs(cur+1);
    s.pop_back();
    pool.pop_back();
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    cin >> n;
    dfs(0);
    return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  if (A % 2 == 0 || B % 2 == 0) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}




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

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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 int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int X;
  cin >> X;

  int ans = X/500*1000;
  X %= 500;
  ans += X/5*5;

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1012345678;

int main() {
    vector<int> A(5);
    cin >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];
    vector<int> P = { 0, 1, 2, 3, 4 };
    int final_answer = inf;
    do {
        int ans = 0;
        for(int i=0;i< 5;i++){
            while(ans % 10 != 0) ans += 1;
            ans += A[P[i]];
        }
        final_answer = min(final_answer, ans);
    } while (next_permutation(P.begin(), P.end()));
    cout << final_answer << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define aint(v) v.begin(),v.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
int32_t main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  fastio
  double p1i = 3.14159265358979323846;
  double ans=2*p1i;
  double r;
  cin>>r;
  ans=ans*r;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3800
#include<iostream>

using namespace std;

int main(){
	int x[10000];
	int i = 0;
	while (1){
		cin >> x[i];
		if (x[i] == 0){
			i += 1;
			break;
		}
		i += 1;
	}
	for (int q = 0; q < i-1; q++){
		cout <<"Case "<<q+1<<": "<< x[q] << endl;
	}
	return 0;
}

Measured memory_bytes: 3140