akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H,W;
  cin>>H>>W;
  int A[H][W];
  FOR(h,0,H){
    FOR(w,0,W){
      cin>>A[h][w];
    }
  }
  int ans = 1e9;
  FOR(h,0,H){
    FOR(w,0,W){
      int cnt = 0;
      FOR(hh,0,H){
        FOR(ww,0,W){
          cnt += min(abs(h-hh),abs(w-ww)) * A[hh][ww];
        }
      }
      ans = min(ans, cnt);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3192
import math
from sys import stdin


def get_result(data):
    A, B, N = data
    if B == 1:
        return 0
    length = N//B+1
    x = [B*(i+1)-1 for i in range(length)]
    ans = []
    for val in x:
        if val > N:
            val = N
        ans.append(math.floor(A*val/B) - A*math.floor(val/B))
    return max(ans)


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip().split(' ')))
    result = get_result(data)
    print(result)


Measured memory_bytes: 62244
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get!(usize);
    let v = get!([usize]);
    let mut ans = 0;
    for i in 0..n {
        let mut flag = false;
        for j in 0..n {
            if i <= j {
                break;
            }
            if v[i] < v[j] {
                flag = true;
            }
        }
        if !flag {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
def resolve():
    import math
    A, B, C, D = [int(i) for i in input().split()]
    A -= 1
    LCMCD = C * D // math.gcd(C, D)
    ans = (B - B // C - B // D + B // LCMCD) - \
          (A - A // C - A // D + A // LCMCD)
    print(ans)


resolve()


Measured memory_bytes: 9136
#include<stdio.h>
#include<string.h>

int main(){
    int i, len;
    char str[1001];

    while(fgets(str, 1000, stdin) != NULL){
        len = strlen(str);
        for(i = 0; i < len - 5; i++){
            if(strncmp(&str[i], "apple", 5) == 0) strncpy(&str[i], "peach", 5);
            else if(strncmp(&str[i], "peach", 5) == 0) strncpy(&str[i], "apple", 5);
        }
        printf("%s", str);
    }
    return 0;
}

Measured memory_bytes: 524
N = int(input())
s = [int(input()) for i in range(N)]

if all(i%10 == 0 for i in s):
    print(0)
    exit()

elif sum(s)%10 != 0:
    print(sum(s))
    exit()

test = []
s = sorted(s)
for i in s:
    test.append(i)

for i in range(N):
    test[i] = 0
    if sum(test)%10 != 0:
        print(sum(test))
        exit()
    else:
        test[i] = s[i]


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

int main(){
 int A, B, X;
 cin >> A >> B;
  for(int i = 0; i < 2; i++){
   X += max(A , B); 
   if(A >= B){
    A -= 1; 
   }else if(A < B){
    B -= 1; 
   }
  }
cout << X << endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main(){   
   int a;
   cin>>a;
   vector<int> s(a);
   vector<int> p(a);
   vector<int> q(a);
   for (int i = 0; i < a; i++)
   {
      s[i]=i+1;
   }
   for (int i = 0; i <a; i++)
   {
      cin>>p[i];
   }
   for (int i = 0; i <a; i++)
   {
      cin>>q[i];
   }
   int pcount=0;
   int qcount=0;
   int count=1;
   do{
         if(s==p) pcount=count;
         if(s==q) qcount=count;
   count++;   
   }   while(next_permutation(s.begin(),s.end()));
   count=pcount-qcount;
   count=abs(count);
   cout<<count<<endl;
return 0;
}

Measured memory_bytes: 256
/*
    Author - Param Kothari
    Ah shit, here we go again
*/
 
/* Ordered Set Implementaton:

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;

typedef tree<
    int,
    null_type,
    less<int>,
    rb_tree_tag,
    tree_order_statistics_node_update>
ordered_set;
*/

#include <bits/stdc++.h>
 
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair 
 
typedef long long ll;
typedef long double ld;

void solve(){
    ll n = 0;
    cin >> n;
    cout << (n + 1) / 2LL << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i,n){
        string c;
        cin >> c;
        mp[c] = 0;
    }
    cout << mp.size() << endl;

    return 0;
}


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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
        #define eprintf(...) 42
#endif

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

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

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

int ask(int x)
{
  cout << x << endl;

  string s;
  cin >> s;

  if(s == "Vacant") return -1;
  if(s == "Male") return 0;
  return 1;
}

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

  int s = ask(0);   
  if(s == -1) return 0;

  int l = 0, r = n;
  rep(i, 19){
    int m = (l+r)/2;
    int t = ask(m);
    if(t == -1) return 0;
    else if((t+m%2)%2 == s){
      l = m;
    }else{
      r = m;
    }
  }

  return 0;
}


Measured memory_bytes: 976
// Problem : A - Takoyaki
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,b) for(int i=a;i>=b;i--)
//vector
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pp pop_back
//pair
#define pi pair<int ,int >
#define mk make_pair
#define ff first
#define ss second
//set
#define si set<int>
#define sit set<int>::iterator 
using namespace std;
int main()
{
	/*
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
	#endif
	*/
fast;
ll a,b,c;cin>>a>>b>>c;
ll ans=(a+b-1)/b;
cout<<ans*c;
return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, sum=0, M=0, p; cin >> N;
  for (int i=N; i>0; i--){
    cin >> p;
    sum += p;
    M = M>p?M:p;
  }
  cout << sum - M/2 << endl;
}

Measured memory_bytes: 256
a,b,c = map(int, input().split())
def check(a, b, c):
    if c > b and c > a:
        if c-a-b <= 0:
            return "No"
        else:
            if 4*a*b < (c-a-b)**2:
                return 'Yes'
            else:
                return "No"
    else:
        return "No"

print(check(a, b, c))

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

int main(){
    double a, b, n;
    cin >> a >> b >> n;

    double tgt = min(b, n);
    // float diff = 10.0;
    long long ans = 0;
    for(long long i = (long long)tgt; i >= 1 ; i--){
        long long tmp;
        tmp = floor(a * i / b) - a * floor(i / b);
        ans = max(ans, tmp);
        if(tmp < ans){
            break;
        }
    }   

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

Measured memory_bytes: 3720
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, v, b, w, t; cin >> a >> v >> b >> w >> t;
    ll diff = abs(a - b);
    if (w - v > 0) cout << "NO\n";
    else if (diff > (v - w) * t) cout << "NO\n";
    else cout << "YES\n";
    return 0;
}


Measured memory_bytes: 3652
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int n;
string s,s1[10001], s2[10001];
string t;
int main(){
	cin >> n;
	lp(n) {
		cin >> s;
		s1[0] = "a";
		s2[0] = "a";
		s1[n + 1] = s2[n + 1] = "zzzzzzzzzzzzzzzzzzzz";
		s1[i+1] = s;
		s2[i+1] = s;
		lop(s.size(),j) {
			if (s[j] == '?') {
				s1[i+1][j] = 'a';
				s2[i+1][j] = 'z';
			}
		}
	}
	cin >> t;
	sort(s1, s1 + n + 1);
	sort(s2, s2 + n + 1);
	bool flag = false;
	lp(n+1) {
		if (s1[i] <= t&&t <= s2[i + 1]) {
			if (flag)cout << ' ';
			else flag = true;
			cout << i + 1;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1408
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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 INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("Yay!");else out(":(");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
	if(!b)return 1;	if(b&1)return modpow(a,b-1,m)*a%m;
	int memo = modpow(a,b>>1,m);
	return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  int g=max(a,max(b,max(c,max(d,e))));
  int h=min(a,min(b,min(c,min(d,e))));
  YESNO(g-h<=f);
}


Measured memory_bytes: 256
// #Sazaの1日1AC
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
const int INF=mod;
const double PI=3.14159265358979323846;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<int, int>;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vP=vector<pair<long long, long long>>;
//ショートカット
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,k,n) for(int i = k; i < n; i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mkp make_pair
//入力
#define vin(v,N) for(long long id=0;id<N;id++) cin>>v.at(id)
#define lin(n) long long n;cin>>n
#define chin(x) char x;cin>>x;
#define sin(s) string s;cin>>s;
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)


//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1);
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//構造体

/////////////////⊂('ω'⊂ )))Σ≡GO!/////////////////



int main(){

  rep(i, 5){
    int x; cin >> x;
    if(x == 0){
      cout << i + 1 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3624
require 'pp'

x = gets.chomp!.to_i

if x < 100
    puts 0
    exit 0
end

cnt = x / 100
rem = x % 100

cnt2 = rem / 5
rem2 = x % 5

if cnt2 + (rem2 > 0 ? 1 : 0) <= cnt
    puts 1
else
    puts 0
end


Measured memory_bytes: 2044
#include <vector>
#include <iostream>
#include<string>

using namespace std;

int main(){
   string t;
    cin >> t;
    for(auto& si: t) if(si =='?') si = 'D';
    /*
    bool was_p = false;
    int out = 0;
    for(int i=1; i!=t.size(); i++){
        if(t.at(i)=='D') {
            out++;
            if(was_p) out++;
            was_p = false;
        }else{was_p = true;}
    }
    */
   cout << t << endl;
} 

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n,k,c; cin >> n >> k >> c;
    string s; cin >> s;
    vector<int> early, late;
    int idle = c+1;
    int cnt = 0;
    rep(i,n){
        if(s[i] == 'o') {
            if(idle >= c && cnt < k){
                early.pb(i+1);
                idle = 0;
                cnt++;
            }
            else idle++;
        }
        else {
            idle++;
        }
    }
    idle = c+1;
    cnt = 0;
    rrep(i,n){
        if(s[i] == 'o') {
            if(idle >= c && cnt < k){
                late.pb(i+1);
                idle = 0;
                cnt++;
            }
            else idle++;
        }
        else {
            idle++;
        }
    }
    reverse(ALL(late));
    rep(i,k){
        if(early[i] == late[i]) cout << early[i] << endl;
    }
}


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

int main() {
    string s;
    cin >> s;
  	bool foo = s[2] == s[3];
  	bool bar = s[4] == s[5];
  	if (foo && bar) {
      cout << "Yes" << endl;
    } else {
	  cout << "No" << endl;
    }
	return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;

int N, ans = 1;
vector<ll> v;

int main()
{
    cin >> N;
    vector<ll> a(N);
    v.push_back(0);
    for (int i = 0; i < N; i++)
        cin >> a[i];
    sort(a.begin(), a.end());
    for (int i = 0; i < N; i++)
        v.push_back(v.back() + a[i]);
    for (int i = N - 2; i >= 0; i--)
    {
        if (a[i + 1] <= 2 * (a[i] + v[i]))
            ans++;
        else
            break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2168
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int out = 0;
		out = A - 2*B;
		if(out <0) {
			out = 0;
		}
		System.out.println(out);
	}

}


Measured memory_bytes: 21844
program main
implicit none
integer :: i, j, k
integer :: a, b, c, d, e
character :: s*11, op(2)*1

op = (/'+','-'/)
read(*,*) e
a = e/1000
b = (e-a*1000)/100
c = (e-a*1000-b*100)/10
d = (e-a*1000-b*100-c*10)/1


do i = 1, 2
   do j = 1, 2
      do k = 1, 2
         if( a+b*(-1)**(i+1)+c*(-1)**(j+1)+d*(-1)**(k+1) == 7 ) then
            write(s,"(i1.1,a1,i1.1,a1,i1.1,a1,i1.1,'=7')") a, op(i), b, op(j), c, op(k), d
            write(*,*) s
            stop
         end if         
      end do
   end do
end do
end program main


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 5;

bool ar[N];
vector<int> prime;

void sieve() {
    fill_n(ar, N, 1);
    ar[0] = ar[1] = 0;
    for (int i = 4; i < N; i+=2) ar[i] = 0;
    for (int i = 3; i*i < N; i+=2) {
        if (not ar[i]) continue;
        for (int j = i*i; j < N; j+=i) ar[j] = 0;
    }
    prime.push_back(2);
    for (int i = 3; i < N; i+=2) {
        if (ar[i]) prime.push_back(i);
    }
}

int main() {
    sieve();

    ll n;
    scanf("%lld", &n);

    auto tmp = n;
    int indx = 0;
    map<ll,int> factor;
    while(tmp != 1) {
        if ((ll) prime[indx]*prime[indx] > tmp) break;
        while(tmp%prime[indx] == 0) {
            tmp = tmp/prime[indx];
            factor[prime[indx]]++;
        }
        indx++;
    }
    if (tmp != 1) factor[tmp] = 1;
    int cnt = 0;
    for (auto p : factor) {
        for (int i = 1; ; ++i) {
            if ((i*(i+1))/2 > p.second) {
                cnt += i-1;
                break;
            }
        }
    }
    printf("%d\n", cnt);
    
}

Measured memory_bytes: 4892
n = int(input())
a = list(map(int,input().split(' ')))
count = 0;
flag =True
while True:
    for i in a :
        if i % 2 != 0 :
            flag=False
            break
    if flag :
        a = list(map(lambda x: x/2 , a))
        count=count+1
    else:
        break
    
print(str(count))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
void Main(){
    int N = read(), ans = 0;
    vector<int> A(N), B(N, -1);
    for (auto& a:A) {
        a = read();
    }
    int it;
    for (int i = 0; i<N; i++) {
        it = lower_bound(B.begin(), B.end(), A[i])-B.begin();
        B[it-1] = A[i];
    }
    for (auto b:B) {
        if (b != -1) ans++;
    }
    printf("%d\n", ans);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 1024
n, d = input().split(" ")
p = [[int(i) for i in input().split()] for i in range(int(n))]
counter = 0
for i in range(int(n)):
    for j in range(int(n)):
        if i > j or i == j:
            continue
        else:
            dist = 0
            for k in range(int(d)):
                dist += (p[i][k] - p[j][k]) ** 2
            if (dist ** (1 / 2)).is_integer():
                counter += 1
print(counter)

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
#include <map>
#include <queue>
#include <string>
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define inf (int)(1e9)
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

double speed[444444];
double mspeed[444444];
int main(void){
  int n;
  vector<int>t,v;
  cin>>n;
  int x,sumt=0;
  for(int i=0;i<n;i++){
    cin>>x;
    t.pb(x);
    sumt+=x;
  }
  for(int i=0;i<n;i++){
    cin>>x;
    v.pb(x);
  }
  
  x=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<t[i];j++){
      mspeed[x]=mspeed[x+1]=v[i];
      x+=2;
    }
  }
  
  for(int i=1;i<=sumt*2;i++){
    if(speed[i-1]+0.5<=min(mspeed[i],mspeed[i-1])){
      speed[i]=speed[i-1]+0.5;
    }
    else if(speed[i-1]==min(mspeed[i],mspeed[i-1])){
      speed[i]=min(mspeed[i],mspeed[i-1]);
    }
    else{
      x=i;
      speed[x]=mspeed[i];
      while(x>0&&speed[x]!=speed[x-1]-0.5){
	speed[x-1]=speed[x]+0.5;
	x--;
      }
    }
  }
  double res=0;
  for(int i=0;i<=sumt*2;i++){
    res+=speed[i]*0.5;
  }
  printf("%f\n",res);
  return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <string.h>

//問題文より、英文と英単語のそれぞれの最大の文字数
#define TEXT_MAXLENGTH 1000
#define WORD_MAXLENGTH 10

//単語が一致しているか判別する関数
int word_match(char *word1, char *word2, int word1_length, int word2_length);

int main(void)
{
	//word_countは文章Tに含まれる単語の数を格納
	int i, word_count, match_count, word_length;
	char word[WORD_MAXLENGTH];
	char text[TEXT_MAXLENGTH][TEXT_MAXLENGTH];

	//英単語を入力し、その文字数を求める
	scanf("%s", word);
	word_length = strlen(word);

	word_count = 0;
	while(scanf("%s", text[word_count])){
		//文章の終わりまで入力を続ける
		if(!(strcmp(text[word_count], "END_OF_TEXT"))){
			break;
		}
		//単語の数を一つ増やす
		else{
			word_count++;
		}
	}

	match_count = 0;
	//文章Tに含まれる単語の数だけ判定する
	for(i = 0; i < word_count; i++){
		if(word_match(word, text[i], word_length, strlen(text[i]))){
			match_count++;
		}
	}

	//結果を出力
	printf("%d\n", match_count);

	return 0;
}

//2つの単語が一致していれば1を、そうでなければ0を返す
int word_match(char *word1, char *word2, int word1_length, int word2_length)
{
	int i;

	//2つの単語の文字数が等しければ判定を続ける
	if(word1_length == word2_length){
		//1文字ずつ確かめる
		for(i = 0; i < word1_length; i++){
			//'a' - 'A'は32
			if((*word1 != *word2) && ((*word1 - 32) != *word2)){
				break;
			}
			else{
				word1++;
				word2++;
			}
		}

		//最後まで繰り返しが完了した場合は2つの単語が一致している
		if(i >= word1_length){
			return 1;
		}
		else{
			return 0;
		}
	}
	else{
		return 0;
	}
}


Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
signed main()
{
	int n;
	cin>>n;

	int x=n%10;
	if(x==2 or x==4 or x==5 or x==7 or x==9)
	{
		cout<<"hon";
	}
	else if(x==3)
	{
		cout<<"bon";
	}
	else
	{
		cout<<"pon";
	}
	return 0;
}

Measured memory_bytes: 3592
def main():
    _ = int(input())
    A = list(int(c) for c in input().split(' '))

    tmp = []
    for i in range(len(A)-1):
        if A[i] != A[i+1]:
            tmp.append(A[i])
    if len(tmp) == 0:
        return 1000
    if A[-1] != tmp[-1]:
        tmp.append(A[-1])
    A = tmp
    #print(A)

    money = 1000
    if len(A) < 2:
        return 1000

    if len(A) == 2:
        if A[0] < A[1]:
            kabu = money // A[0]
            money -= kabu*A[0]
            money += kabu*A[1]
            return money
        else:
            return 1000

    l = []
    kabu = 0
    if A[1] > A[0]:
        ascending = True
        kabu = money // A[0]
        money -= kabu*A[0]
    else:
        ascending = False
    for i in range(len(A)-1):
        #print(A[i],kabu,money)
        if ascending:  #上昇中
            if A[i] > A[i+1]:
                #下降に転じたので売り
                if kabu > 0:
                    money += kabu*A[i]
                    kabu = 0
                    ascending = False
                else:
                    pass
            else:
                continue
        else:  #下降中
            if A[i] < A[i+1]:
                #上昇したので買い
                assert kabu == 0
                kabu = money // A[i]
                money -= kabu*A[i]
                ascending = True
            else:
                continue
    if kabu > 0:
        money += kabu*A[-1]
        kabu = 0
    return money
if __name__ == "__main__":
    ret = main()
    print(ret)

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

int main() {
  int count=0;
  int N;
  cin>>N;
  vector<int>D(N);
  rep(i,N){
    cin>>D[i];
  }
  sort(D.begin(),D.end());
  cout<<D[N/2]-D[N/2-1];
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
	int x, y;
	
	while(1){
		
	scanf("%d %d", &x, &y);
	
		if(x==0&&y==0){
			break;
		}
		
		if(x>y){
		printf("%d %d\n", y, x);
	}
	else{
		printf("%d %d\n", x, y);
	}
	
}
	return 0;
}

Measured memory_bytes: 600
//lunchtime june Increasing and Decreasing
//<<  <  ,
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <algorithm>
#include <math.h>
#include <string>
#define pi 3.1415926535897932384626
#include <cmath>
#define test(t) while(t--)
#define MOD 1000000007
#define ll  long long int

#define in  cin>>
#define out cout<<
#define en "\n"
#define sp " "
#define pb push_back
#define fast()  ios_base::sync_with_stdio(false);cin.tie(0);
#define double long double

using namespace std;
ll form(ll n){
return (n*(n+1))/2;
}
ll exponent(ll base, ll power){
   ll res = 1;
  ll m = 1000000007;
   while(power){
    if(power&1)
        res = (res*base)%m;
    base= (base*base)%m;
    power=power>>1;
   }
return res;}
bool count_one(ll n){
    ll cnt = 0;
    while(n>0){
            cnt+=1;
       n= n&(n-1);

    }
    if(cnt>1)
        return true;
    return false;
}


void solve()
{  ll n;
in n;
    ll a[n];
    for(ll i=0;i<n;i++){
        in a[i];
    }
    ll cnt=0;
    for(ll i=0;i<n;i++){
        if((i+1)&1){
            if(a[i]&1)
                cnt+=1;
        }

    }
    out cnt<<en;
}




int main(){ fast()
             //freopen("input.txt","r",stdin);
             //freopen("output.txt","w",stdout);
             ll t=1;
            //cin>>t;
            test(t){
            solve();
            }
return 0;}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	int a=read(),b=read();
	if(a<=9&&b<=9)
	{
		a=a*b;
		if(a==0)puts("-1");
		else cout<<a;
	}
	else puts("-1");
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    string s[101];
    int p[101];
    int N;
    cin >> N;
    rep(i, N) cin >> s[i] >> p[i];
    vector<int> v(N, 0);
    iota(v.begin(), v.end(), 0);
    sort(v.begin(), v.end(), [&](const int & a, const int & b) {
        if (s[a] == s[b]) return p[a] > p[b];
        return s[a] < s[b];
    });
    rep(i, N) cout << v[i]+1 << endl;
    return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

ll dp[55][55][2555];

void mod_add(ll &a, ll b){
	a += b;
	a %= MOD;
}

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
	ll n, score;cin >> n >> score;
	dp[0][0][0] = 1;
	REP(i, n){
		REP(j, i+1)REP(k, score + 1){
			ll nj = j;
			mod_add(dp[i + 1][nj][k + 2 * nj], dp[i][j][k]);
			nj = j + 1;
			mod_add(dp[i + 1][nj][k + 2 * nj], dp[i][j][k]);
			nj = j;
			ll x = 2*j;
			mod_add(dp[i + 1][nj][k + 2 * nj], dp[i][j][k] * x % MOD);
			nj = j - 1;
			x = j * j;
			if(j)mod_add(dp[i + 1][nj][k + 2 * nj], dp[i][j][k] * x % MOD);
		}
	}
	cout << dp[n][0][score] << endl;
	return 0;
}


Measured memory_bytes: 55552
H,W,K = map(int,input().split())
S = []
for i in range(H):
  temp = str(input());temp = list(temp)
  S.append(temp)
#print(S)
ans = []
cum = 0
num = 0
for i in range(H):
  if "#" not in S[i]:
    #print(i)
    cum += 1
  else:
    temp = []; num +=1
    First = True
    for j in range(W):
      if S[i][j] == "#":
        if First:
          temp.append(num)
          First = False
        else:
          num +=1
          temp.append(num)
      else:
        temp.append(num)
    ans.append(temp)
    for t in range(cum):
      ans.append(temp)
    cum = 0
if cum > 0:
  for t in range(cum):
    temp = ans[-1]
    ans.append(temp)
for x in ans:
  print(*x)

Measured memory_bytes: 78552
#include <iostream>
int main(void) {
	unsigned int h, w, d, mh, mw, md, i, j, nd;
	while(1) {
		std::cin >> h >> w;
		if (!h && !w) return 0;
		d = h * h + w * w, md = (unsigned int)-1;
		for (i = 1; i < 150; i++) {
			for (j = i + 1; j < 150; j++) {
				nd = i * i + j * j;
				if (d < nd || (d == nd && h < i)) break;
			}
			if (j < 150 && nd < md) md = nd, mh = i, mw = j;
		}
		std::cout << mh << ' ' << mw << std::endl;
	}
	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(10);
    int n;
    cin >> n;
    ll ans = 1, mod = 1e9 + 7;
    vector<int> cnt(n + 1);
    rep(i, 1, n + 1) {
        int a;
        cin >> a;
        if (a == 0) {
            ans = ans * (3 - cnt[0]) % mod;
            cnt[0]++;
        } else {
            ans = ans * (cnt[a - 1] - cnt[a]) % mod;
            cnt[a]++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>//stayCalmNeverSettle
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define endl "\n"
#define pb push_back
#define x first
#define y second
using namespace std;
typedef long long ll;

const ll M = 1e9+7;
const int N = 300010;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int l,r,d;
    cin >> l >> r >> d;
    int cnt = 0;
    for(int i = l;i<=r;i++){
    	if(i%d==0){
    		cnt++;
    	}
    }
    cout << cnt << endl;
}

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

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

  int count = 0;

  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '1') {
      count++;
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CRemovingCoins {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    vector<vector<int>> G;

    P dfs(int v, int par) {
        P res = {0, v};

        REP(i, G[v].size()) {
            int to = G[v][i];
            if (to == par) continue;
            auto tmp = dfs(to, v);
            tmp.first++;
            res = max(tmp, res);
        }

        return res;
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        G = vector<vector<int>>(N);
        REP(i, N - 1) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            G[a].push_back(b);
            G[b].push_back(a);
        }

        auto u = dfs(0, -1);
        auto v = dfs(u.second, -1);

        vector<int> dp(N+1);
        dp[1] = 1;
        dp[2] = 0;
        FOR(i, 3, N) {
            if (dp[i-1] == 0 || dp[i-2] == 0) {
                dp[i] = 1;
            } else {
                dp[i] = 0;
            }
        }

        int len = v.first + 1;
        if (dp[len] == 1) {
            cout << "First" << endl;
        } else {
            cout << "Second" << endl;
        };
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CRemovingCoins solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 24704
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

const int NMAX = 1e5 + 5;
int parent[NMAX];
int ar[NMAX];
int par(int a){
	if(parent[a] == a) return a;
	return parent[a] = par(parent[a]);
}

void unite(int a, int b){
	int para = par(a), parb = par(b);
	parent[para] = parb;
}

int main(){
	ios_base::sync_with_stdio(false);
	
	int n, m;
	cin >> n >> m;
	for(int i=1; i<=n; i++){
		cin >> ar[i];
		parent[i] = i;
	}

	for(int i=0; i<m; i++){
		int x, y;
		cin >> x >> y;
		unite(x, y);
	}

	int res = 0;
	for(int i=1; i<=n; i++){
		if(ar[i] == i) res++;
		else{
			if(par(i) == par(ar[i])){
				res++;
				/*int cp = ar[i];
				ar[i] = i+1;
				ar[cp] = Cp;
				parent[i+1] = 1;
				parent[cp] = cp; */
			}
		}
	}

	cout << res;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    deque <long long> a;
    string s;
    cin>>s;
    f(i,0,s.size()){
        if(s[i]=='0'){
            a.push_back(0);
        }
        else if(s[i]=='1'){
            a.push_back(1);
        }
        else{
            if(!a.empty()){
                a.pop_back();
            }
        }
    }
    f(i,0,a.size()){
        cout<<a[i];
    }
    cout<<endl;
    return 0;
}

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

using namespace std;


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

	int n = s.length(), m = t.length();

	vector<vector<int>> dp(n + 1, vector<int>(m + 1));

	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			if(s[i - 1] == t[j - 1])
				dp[i][j] = dp[i - 1][j - 1] + 1;
			else
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}

	string ans = "";


	while(n > 0 && m > 0)
	{
		if(s[n - 1] == t[m - 1])
		{
			ans = s[n - 1] + ans;
			n--;
			m--;
		}
		else if(dp[n - 1][m] > dp[n][m - 1])
			n--;
		else
			m--;
	}

	cout << ans << endl;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e17;


int main(){
	ios_base::sync_with_stdio(false);
	int N, M, S, T;
	vector<pll> edge[2][100005];

	cin >> N >> M >> S >> T;
	S--; T--;
	rep(i,M){
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		u--; v--;
		edge[0][u].emplace_back(v, a);
		edge[0][v].emplace_back(u, a);
		edge[1][u].emplace_back(v, b);
		edge[1][v].emplace_back(u, b);
	}

	ll D[2][100005];
	Fill(D, INF);
	rep(k,2){
		int s = (k ? T : S);
		D[k][s] = 0;
		priority_queue<pll, vector<pll>, greater<pll>> que;
		que.emplace(0, s);
		while(que.size()){
			int d = que.top().X;
			int n = que.top().Y;
			que.pop();
			for(auto p: edge[k][n]) if( D[k][p.X] > D[k][n] + p.Y ){
				D[k][p.X] = D[k][n] + p.Y;
				que.emplace(D[k][p.X], p.X);
			}
		}
	}

	priority_queue<pll> ans;
	rep(i,N){
		ll cost = D[0][i] + D[1][i];
		ans.emplace( (ll)1e15 - cost, i );
	}

	rep(i,N){
		while( ans.top().Y < i ) ans.pop();
		cout << ans.top().X << endl;
	}

	return 0;
}

Measured memory_bytes: 19964
#include<bits/stdc++.h>
using namespace std;long h,w,a,b,c,d,D[10]={0,1,1,0,-1,1,-1,-1},t[10],i;map<long,long>m;main(){cin>>h>>w>>a;for(*t=(h-2)*(w-2);cin>>a>>b;i=0)for(;i<9;)if((c=a+D[i])>1&(d=b+D[++i])>1&c<h&d<w)t[c=m[c*w+d]++]--,t[c+1]++;for(;i<10;)cout<<t[i++]<<" ";}

Measured memory_bytes: 58496
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const int MOD = 1e9+7;
//}}}

int a[100000];

int main(){
  ll A, B, C, K;
  cin >> A >> B >> C >> K;

  ll ans = 0;
  if(K % 2){
    ans = -A + B;
  }else{
    ans = A - B;
  }
  //cout << "Unfair" << endl;

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


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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007

int main(){

    int n,m;

    cin >> n >> m;

    int T = 1900*m + 100*(n-m);

    ll res = T * (1 << m);

    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

const int MAX_C = 51;
long long Com[MAX_C][MAX_C];

void calc_com() {
    memset(Com, 0, sizeof(Com));
    Com[0][0] = 1;
    for (int i = 1; i < MAX_C; ++i) {
        Com[i][0] = 1;
        for (int j = 1; j < MAX_C; ++j) {
            Com[i][j] = (Com[i-1][j-1] + Com[i-1][j]);
        }
    }
}

int main(){
    int N,A,B;cin >> N >> A >> B;
    vector<LL> v(N);
    rep(i,N)cin >> v[i];
    vector<int> ct(N+1,0);
    vector<int> rui(N+1,0);
    sort(rall(v));

    // 配列vに格納された数字が大きい順に何種類が何個あるかチェック
    int tmp = 1;
    ct[1] = 1;
    for(int i = 1;i < N;++i){
        if(v[i] != v[i-1])tmp++;
        ct[tmp]++;
    }
    rui[0] = 0;
    for(int i = 1;i <= N;++i){
        rui[i] = rui[i-1] + ct[i];
    }

    // 前処理
    calc_com();

    // 累積和から必要なindexを得る
    int ind = 0;
    double mean = 0;
    LL ans = 0;
    if(rui[1] >= B){    // B part
        for(int i = A;i <= B;++i){
            ans += Com[rui[1]][i];
        }
        mean = v[0];
    }
    else{               // A part
        if(rui[1] >= A){    // Aの例外
            for(int i = A;i <= rui[1];++i){
                ans += Com[rui[1]][i];
            }
            mean = v[0];            
        }
        else{
            for(int i = 1;i < rui.size();++i){
                if(rui[i] >= A){
                    ind = i;
                    break;
                }
            }
            int a = rui[ind] - rui[ind - 1];
            int b = A - rui[ind - 1];
            ans = Com[a][b];
            rep(i,A)mean += (double)v[i];
            mean /= (double)A;
        }
    }

    cout << std::fixed << std::setprecision(7) << mean << endl;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

//試してて御免

const int cm = 1 << 17;
char ci[cm];
char *cn = ci + cm;
inline char getcha() { 
	if (cn - ci == cm) { fread(ci, 1, cm, stdin); cn = ci; }
	char ret = *cn;
	cn++;
	return ret;
}

inline int getint() {
	if (cn - ci + 25 > cm) {
		char C = getcha();
		int A = C - '0';
		while ((C = getcha()) >= '0') A = A * 10 + C - '0';
		return A;
	}
	else {
		char C = *cn;
		cn++;
		int A = C - '0';
		while ((C = *cn) >= '0') {
			A = A * 10 + C - '0';
			cn++;
		}
		cn++;
		return A;
	}
}

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


	int N, X;
	N = getint();
	X = getint();

	int A = 0;
	ll kotae = 0;
	rep(i, N) {
		int B = getint();
		if (A + B > X) {
			kotae += A + B - X;
			B = X - A;
		}
		A = B;
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;

const int dx[9] = { 1, 1, 1, 1, 1, 2, 2, 2, 3 };
const int dy[9] = { 2, 1, 0, -1, -2, 1, 0, -1, 0 };

typedef pair <int, int> PII;
typedef pair <PII, PII> Node;
typedef priority_queue <Node, vector<Node>, greater<Node> > Queue;

int main() {
    int w, h;
    while ( cin >> w >> h && w && h ) {
        char M[61][31];
        int MT[2][61][31];
        for ( int i = 0; i < h; i++ ) {
            for ( int j = 0; j < w; j++ ) {
                for ( int k = 0; k < 2; k++ ) {
                    MT[k][i][j] = 1<<24;
                }
            }
        }
        for ( int i = 0; i < h; i++ ) {
            for ( int j = 0; j < w; j++ ) {
                cin >> M[i][j];
            }
        }

        Queue Q;
        for ( int i = 0; i < h; i++ ) {
            for ( int j = 0; j < w; j++ ) {
                if ( M[i][j] != 'S' ) continue;
                for ( int k = 0; k < 2; k++ ) {
                    Node start_node( PII( 0, k?1:-1 ), PII( i, j ) );
                    Q.push( start_node );
                    MT[k][i][j] = 0;
                }
            }
        }

        bool ok = false;
        while ( !Q.empty() ) {
            Node node = Q.top();
            Q.pop();

            int t = node.first.first;
            int l = node.first.second;
            int r = node.second.first;
            int c = node.second.second;

            if ( M[r][c] == 'T' ) {
                cout << t << endl;
                ok = true;
                break;
            }

            for ( int i = 0; i < 9; i++ ) {
                int nr = r + dy[i] * l;
                int nc = c + dx[i] * l;
                if ( nr < 0 || nr >= h || nc < 0 || nc >= w ) continue;
                if ( M[nr][nc] == 'X' ) continue;
                int nt = t + M[nr][nc] - '0';
                if ( M[nr][nc] == 'S' || M[nr][nc] == 'T' ) nt = t;
                int nl = l * -1;
                // cout << i << ": " << t << ", " << l << ", " << r << ", " << c << " -> ";
                // cout << nt << ", " << nl << ", " << nr << ", " << nc << endl;
                int ind = ( nl == 1 ? 0 : 1 );
                if ( nt >= MT[ind][nr][nc] ) continue;
                MT[ind][nr][nc] = nt;
                Node next_node( PII( nt, nl ), PII( nr, nc ) );
                Q.push( next_node );
            }
        }

        if ( !ok ) cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 0
# include <stdio.h>
# include <math.h>
# include <stdlib.h>


int main(){
    long long int n, k;
    scanf("%lld %lld", &n, &k);

    if (n < k){
        long long int menos = k - n;
        
        if (menos < n)
            printf("%lld\n", menos);
        else
            printf("%lld\n", n);
    }
    else if (n%k == 0)
        printf("0\n");

    else{
        long long int a = n%k;
        printf("%lld\n", k - a);
    }
    return 0;
}


Measured memory_bytes: 128