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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n, k;
ll gr, gs, gp;
string t;

int ir = 0, is = 1, ip = 2;
char r = 'r', s = 's', p = 'p';

ll dp[MAX_N][3];

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &k);

  scanf("%d %d %d", &gr, &gs, &gp);

  cin >> t;

  for (int i = 0; i < n; ++i) {
    if (i < k) {
      if (t[i] == r) {
        dp[i][ir] = 0LL;
        dp[i][is] = 0LL;
        dp[i][ip] = gp;
      } else if (t[i] == s) {
        dp[i][ir] = gr;
        dp[i][is] = 0LL;
        dp[i][ip] = 0LL;
      } else if (t[i] == p) {
        dp[i][ir] = 0LL;
        dp[i][is] = gs;
        dp[i][ip] = 0LL;
      }
    } else {
      if (t[i] == r) {
        dp[i][ir] = max(dp[i - k][is], dp[i - k][ip]) + 0LL;
        dp[i][is] = max(dp[i - k][ir], dp[i - k][ip]) + 0LL;
        dp[i][ip] = max(dp[i - k][ir], dp[i - k][is]) + gp;
      } else if (t[i] == s) {
        dp[i][ir] = max(dp[i - k][is], dp[i - k][ip]) + gr;
        dp[i][is] = max(dp[i - k][ir], dp[i - k][ip]) + 0LL;
        dp[i][ip] = max(dp[i - k][ir], dp[i - k][is]) + 0LL;
      } else if (t[i] == p) {
        dp[i][ir] = max(dp[i - k][is], dp[i - k][ip]) + 0LL;
        dp[i][is] = max(dp[i - k][ir], dp[i - k][ip]) + gs;
        dp[i][ip] = max(dp[i - k][ir], dp[i - k][is]) + 0LL;
      }
    }
  }

  ll ans = 0;

  for (int i = 0; i < k; ++i) {
    ans += max(dp[n - 1 - i][ir], max(dp[n - 1 - i][is], dp[n - 1 - i][ip]));
  }

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

  return 0;
}


Measured memory_bytes: 2816
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
int n, x;
signed main() {
	cin >> n >> x;
	int g = gcd(n, x);
	n = n / g, x = x / g;
	cout << 3 * (n - 1) * g << endl;
	ggr
}


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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod =1000000009;




int main() {

	int n;
	cin >> n;

	VLL a(n);
	REP(i, n)cin >> a[i];
	ll ans = 0;

	sort(ALL(a));

	int cnt = 0;
	REP(i, n)if (a[i] < 0)cnt++;
	REP(i, n)a[i] = abs(a[i]);

	sort(ALL(a));

	if (cnt % 2 == 1) {
		a[0] = -a[0];
	}

	REP(i, n)ans += a[i];

	cout << ans << endl;
	


	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

#define MAX_N 5001


/* -----------------------------------------------------------------------------
	型とクラス定義
----------------------------------------------------------------------------- */

/* -----------------------------------------------------------------------------
	大域データ
----------------------------------------------------------------------------- */
int N;			// 文字列長
char 	s[MAX_N];	// 文字列
int		A[MAX_N];	// 共通接頭辞の長さの配列

// Z-algorithm
int ZA(char *s, int A[]);

int main () {

	int len = 0;

	// 個数の読込み
	scanf("%d %s", &N, s);
	
	for(int i = 0; i < strlen(s); i++) {
		ZA(s + i, A);
		for(int j = 1; j < strlen(s + i); j++)
			len =  std::max(len, std::min(A[j], j));
	}
	printf("%d\n", len);

	return 0;
}

// Z-algorithm
// S と S[i:N-1] の最長共通接頭辞の長さ
int ZA(char *s, int A[]) {
	A[0] = strlen(s);
	int i = 1, j = 0;
	while (i < strlen(s)) {
  		while (i+j < strlen(s) && s[j] == s[i+j]) ++j;
  		A[i] = j;
  		if (j == 0) { ++i; continue;}
  		int k = 1;
  		// while (i+k < strlen(s) && k+A[k] < j) A[i+k] = A[k], ++k;
  		while (k + A[k] < j) { A[i+k] = min(A[k],j - k);  ++k; }
  		i += k; j -= k;
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	
	long long a,b; cin>>a>>b;
	ll tt = max((a*b),(a-b));
	cout<<max(tt,(a+b))<<"\n";
	
	
	
	
	
	
	
	
	
	
}

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

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

    string str = to_string(n);

    if (str.find("7") == string::npos)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    return 0;
}


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

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

int main() {
    char b;
    cin >> b;

    if (b == 'A') cout << 'T' << endl;
    else if (b == 'C') cout << 'G' << endl;
    else if (b == 'G') cout << 'C' << endl;
    else if (b == 'T') cout << 'A' << endl;

    return 0;
}

Measured memory_bytes: 3524
#include<stdio.h> 
#include<iostream> 
#include<string.h>
#include<cstring>
#include<string>
#include<math.h>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
#define cuttime ios::sync_with_stdio(false)
#define swap(x, y) x ^= y, y ^= x, x^= y
#define INF 0x3f3f3f3f
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define scan1(x) scanf("%d",&x)
#define scan2(x,y) scanf("%d%d",&x,&y)
#define scan3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scanll1(x) scanf("%lld",&x)
#define scanll2(x,y) scanf("%lld%lld",&x,&y)
#define scanll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define lowbit(x) (x&(-x))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=2e5+20;
const int MAX=10000007;
inline int read() {
    char c=getchar();int x=0,f=1;
    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 void out(int x) {   
	if(x>9) out(x/10);   
	putchar(x%10+'0'); 
} 
char s[20];
int main(){
	int k;
	cin>>k;
	ll sum=0;
	rep(i,1,k){

		rep(j,1,k){
			rep(o,1,k){
				int ll=__gcd(i,j);
				ll=__gcd(ll,o);
				sum+=ll;
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

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

int main() {
  int n, t, a;
  cin >> n >> t >> a;
  vector<int> h(n);
  double th;
  double closest = 1000000;
  int ans = 0;
  for(int i=0; i<n; i++) {
    cin >> h.at(i);
    th = t - h.at(i)*0.006;
    double temp = (a-th) * (a-th);
    if(temp < closest) {
      ans = i+1;
      closest = temp;
    }
  }
  cout << ans << endl;
  }
  

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

int main() {
    ll n, k;
    ll temp;
    cin >> n >> k;
    if(n > k){
        while(n>k){
            n%=k;
        }
        if(n==0) {
            cout << 0 << endl;
            return 0;
        }
        n = abs(n-k);
        cout << n << endl;
        return 0;
        
    }
    if(n==k) {
        cout << 0 << endl;
        return 0;
    
    }
    if(n<k){
        ll temp = n;
        n = abs(n-k);
        if(temp<n) cout << temp << endl;
        else cout << n << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var nk = Input.ar;
        WriteLine(Modulo.Pow(nk[1], nk[0]));
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

public class Modulo
{
    private static int Multiple(int num1, int num2)
        => (int)(BigMul(num1, num2) % Input.MOD);

    public static int Pow(int m, int n)
    {
        if (n == 0) return 1;
        if (n % 2 == 0) return Pow(Multiple(m, m), n / 2);
        else return Multiple(Pow(Multiple(m, m), n / 2), m);
    }

    public static int Div(int a, int b)
        => Multiple(a, Pow(b, Input.MOD - 2));

    public class Combination
    {
        private int[] _fac;
        public Combination(int num)//階乗をメモ化
        {
            _fac = new int[num + 1];
            _fac[0] = 1;
            for (var i = 1; i <= num; i++)
                _fac[i] = Multiple(_fac[i - 1], i);
        }
        public int Comb(int n, int r)
        {
            if (n < r) return 0;
            if (n == r) return 1;
            var calc = _fac[n];
            calc = Div(calc, _fac[r]);
            calc = Div(calc, _fac[n - r]);
            return calc;
        }
        public int fac(int num)
            => _fac[num];
    }

}



Measured memory_bytes: 19980
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll a, b, c;
  cin >> a >> b >> c;
  ll count = 0;
  while(count<c&&b>=a){
    b -= a;
    count++;
  }
  print(count);
}

Measured memory_bytes: 256
S = int(input())
mod = int(1e9+7)

def cmb(n, r):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

def init_cmb(Nmax):
    #mod = 10**9+7 #出力の制限
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] # 逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル

    for i in range(2, Nmax + 1):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)
    return g1, g2

g1,g2 = init_cmb(5000)

ans = 0 
for i in range(1,S//3+1):
  ans += cmb(S - 3*i + (i-1), i-1)
  ans %= mod
print(ans)

Measured memory_bytes: 9724
#include <iostream>

using namespace std;

int main(){
  unsigned long long int N;
  cin >> N;
  unsigned long long int out = 0;
  if(N==1)
    out = 0;
  if(N==2)
    out = 1;
  if(N>=3){
    out = (N-1)*N/2;
    //out += max(N%2,1%2);
  }
  cout << out << endl;
      
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int a,b,c;
  cin>>a>>b>>c;
  if(a+b+c>=22) cout<<"bust"<<endl;
  else cout<<"win"<<endl;


}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

signed main() {
	bool used[3] = {false};
	int a, b;
	cin >> a >> b;
	used[a-1]=true;
	used[b-1]=true;
	
	int i;
	for (i = 0; i < 3; i++) if (!used[i]) { cout << i + 1 << endl; }
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pi pair<int ,int >
#define pl pair<ll ,ll >
#define pb push_back
#define vl vector <long long int >
#define vi vector <int >
#define mod 1000000007
#define eps 1e-9
#define fi first
#define se second
#define _ <<" "<<
#define forn(x,	n) for(int x = 0; x < n ;++ x) 
#define forn1(x,n) for(int x = 1; x <= n ;++ x)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
void scan(){}
template<typename F, typename... R> void scan(F &f,R&... r){cin>>f;scan(r...);}
int di_; string dnms_, co_ = ",";
void debug_(){cout<<endl;}
template<typename F, typename... R> void debug_(F &f, R&... r){while(dnms_[di_] != ',')cout<<dnms_[di_++];di_++;cout<<": "<<f<<",";debug_(r...);}
#define debug(...) dnms_=#__VA_ARGS__+co_,di_=0,debug_(__VA_ARGS__)

template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}

int main(){
	IOS

	int a,b;
	cin>>a>>b;
	cout<<max({a+b,a-b,a*b});
 
	return 0;	
}

Measured memory_bytes: 256
#include<iostream>

int border[4] = { 18680908, 19120730, 19261225, 19890108 };
char* gengo[4] = { "meiji", "taisho", "showa", "heisei" };

int main()
{
	int y, m, d;
	while( std::cin >> y >> m >> d )
	{
		int n = y * 10000 + m * 100 + d;

		if( n < border[0] )
			std::cout << "pre-meiji" << std::endl;
		else if( n >= border[3] )
			std::cout << "heisei " << y - 1989 + 1 << " " << m << " " << d << std::endl;

		for( int i = 0; i != 3; ++i )
			if( border[i] <= n && n < border[i+1] )
				std::cout << gengo[i] << " " << y - border[i] / 10000 + 1 << " " << m << " " << d << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1164
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    S = [int(input()) for _ in range(N)]

    S = sorted(S)
    total = sum(S)
    if total % 10 != 0:
        return total

    sub = total
    for s in S:
        if s % 10 != 0:
            sub = s
            break

    return total - sub


if __name__ == '__main__':
    print(main())


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

from collections import defaultdict
d = defaultdict(int)

for i in a:
  d[i] += 1

ans = 0
for t in set(a):
  cnt = d[t]

  if t > cnt:
    ans += cnt
  else:
    ans += (cnt - t)

print(ans)

Measured memory_bytes: 20592
var n,i,j:longint;
    ans,now:int64;
	a,b:array[0..100007] of longint;
begin
  readln(n);
  for i:=1 to n do
	readln(a[i],b[i]);
  ans:=0;
  for i:=n downto 1 do
  begin
    now:=(b[i]-(a[i]+ans) mod b[i]) mod b[i];
    ans:=ans+now;
  end;
  writeln(ans);
end.
	

Measured memory_bytes: 896
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
cout<<min(a*b,c); 
    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  ABC
//
//  Created by Amarsanaa Davaasuren on 2019/08/31.
//  Copyright © 2019 Amarsanaa Davaasuren. All rights reserved.
//

#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
using namespace std;



class UnionFind {
public:
    vector<int> Parent;
    UnionFind(int N){
        Parent = vector<int>(N,-1);
    }
    
    int root(int node){
        if (Parent[node] < 0){
            return node;
        }
        else{
            return Parent[node] = root(Parent[node]);
        }
    }
    
    int size(int node){
        return -root(node);
    }
    
    bool connect(int A, int B){
        int Aroot = root(A);
        int Broot = root(B);
        if (Aroot != Broot){
            if (size(Aroot) < size(Broot)) swap(Aroot,Broot);
            Parent[Aroot] += Parent[Broot];
            Parent[Broot] = Aroot;
            return true;
        }
        else{
            return false;
        }
    }
};




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


int main() {
    
    int N,Q; cin >> N >> Q;
    
    vector<vector<int>> G(N);
    rep(i,N-1){
        int a,b; cin >> a >> b; a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    vector<ll> value(N);
    rep(i,Q){
        int p,x; cin >> p >> x; p--;
        value[p] += x;
    }
    
    auto dfs = [&](auto dfs, int child, int parent)-> void{
        for (int relative:G[child]) if (relative != parent){
            value[relative] += value[child];
            dfs(dfs,relative,child);
        }
    };
    
    dfs(dfs,0,-1);
    rep(i,N) cout << value[i] << (i == N - 1 ? '\n' : ' ');
}



Measured memory_bytes: 21888
#include <bits/stdc++.h>
using namespace std;
#define amod 993244853
#define mod 1e9 + 7
#define ll long long
#define all(vec, n) vec.begin(), vec.begin() + n

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

  int n, a, g;
  cin >> n;
  cin >> a;
  g = a;

  for (int i = 1; i < n; i++)
  {
    cin >> a;
    g = __gcd(a, g);
  }

  cout << g << "\n";

  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
p = list(map(int, input().split()))

s = sum((pi+1)/2 for pi in p[:K])
m = s
for i, pi in enumerate(p):
    if i < K:
        continue
    s -= (p[i-K]+1)/2
    s += (p[i]+1)/2
    if s > m:
        m = s

print(m)


Measured memory_bytes: 25060
A, B = map(int, input().split())
m = [["."] * 100 for _ in range(50)]


def fill(f, b, i, j, n):
    for k in range(5):
        for l in range(5):
            m[i + k][j + l] = b
    m[i + 1][j + 1] = f if n > 0 else b
    m[i + 1][j + 3] = f if n > 1 else b
    m[i + 2][j + 2] = f if n > 2 else b
    m[i + 3][j + 1] = f if n > 3 else b
    m[i + 3][j + 3] = f if n > 4 else b


A -= 1
B -= 1
for i in range(0, 25, 5):
    for j in range(0, 100, 5):
        n = min(5, A)
        A -= n
        fill(".", "#", i, j, n)
for i in range(25, 50, 5):
    for j in range(0, 100, 5):
        n = min(5, B)
        B -= n
        fill("#", ".", i, j, n)

print(50, 100)
for v in m:
    print("".join(v))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define lln long long int
#define IOS ios::sync_with_stdio(0);cin.tie(0);
int main(){
    IOS;
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) 
	cin>>a[i];
    lln ans=0;
    for(int i=1;i<n;i++){
        if(a[i]<a[i-1]){
            ans=ans+a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    cout<<ans<<endl;
    return 0;    
}

Measured memory_bytes: 3992
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////
 
#define fs first
#define sc second
#define pb push_back
#define len(x) ((int)(x).size())
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;
 
const ll LINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9+7;
 
/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////
 
int main(){
 
	fastio;
    int n;
    ll p;
    cin >> n >> p;
    int max_value = 0;
    vector<int> valor(n+1);
    vector<ll> peso(n+1);
    for(int i = 1; i <= n; i++){
    	cin >> peso[i] >> valor[i];
    	max_value += valor[i];
    }
	vector<vector<ll> > dp(n+1, vector<ll>(max_value+1, LINF));
	dp[0][0] = 0;
	for(int i = 1; i <= n; i++){
		dp[i-1][0] = 0;
		for(int j = 1; j <= max_value; j++){
			if(j < valor[i]) dp[i][j] = dp[i-1][j];
			else dp[i][j] = min(dp[i-1][j], dp[i-1][j-valor[i]] + peso[i]);
		}
	}
	int ans = 0;
	for(int i = max_value; i >= 0; i--){
		//cout << i << endl;
		if(dp[n][i] <= p){
			ans = i;
			break;
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 80256
//
// Created by yuu on 2019-04-23.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>

using namespace std;


int main(void){
    int N;
    string S;
    int K;

    cin>>N;
    cin>>S;
    cin>>K;

    for (int i = 0; i < N; ++i) {
        if(S[K-1] == S[i]){
            continue;
        }
        S[i] = '*';
    }


    cout<<S<<endl;

    return 0;
}

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

int main(){
    using namespace std;
    size_t N;
    cin >> N;
    vector<size_t> t(100000);
    size_t ans{0};
    for(size_t i = 0, a; i < N; ++i){
        cin >> a;
        ans += !t[a]++;
    }
    cout << ans - (~ans & 1) << endl;
}

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

using namespace std;
long long tab[100008];
pair<long long, long long> p[101];

#define f first
#define s second

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

    long long a, b, n, w;
    cin>>n>>w;

    for(int i=0; i<n; i++)
    {
        cin>>p[i].f>>p[i].s;
    }

    for(int i=0; i<n; i++)
    {
        for(int j=w+3; j>=0; j--)
        {
            if(j+p[i].f<=w && tab[j]!=0)
            {
                tab[j+p[i].f]=max(tab[j+p[i].f], tab[j]+p[i].s);
            }
        }
        tab[p[i].f]=max(tab[p[i].f], p[i].s);
    }

    long long wynik=0;

    for(int i=0; i<=w; i++)
    {
        wynik=max(wynik, tab[i]);
    }

    cout<<wynik;

    return 0;
}


Measured memory_bytes: 1024
//AOJ Insertion Sort
//20180929
//F_Naru

#include<iostream>
using namespace std;

int N;
int main(){
  cin >> N;
  int*  num = new int[N];
  for(int i=0; i<N; i++){
    cin >> num[i];
  }
  
  int v;
  int j;
  for(int i=0; i<N; i++){
    v = num[i];
    j = i - 1;
    while(j>=0 && num[j] > v){
      num[j+1] = num[j];
      j--;
    }
    num[j+1] = v;

    for(int i=0; i<N; i++) {
      cout << num[i];
      if(i<N-1) cout << " ";
    }
    cout << endl;
  }
  
  delete[] num;
}




Measured memory_bytes: 3132
#include<iostream>
#include<algorithm>

using namespace std;

#define REP(s,e) for(int i=(s);i<(e);i++)

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    
    if(b-a==c-b) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define N 1000005
typedef long long int ll;
//const int mx=1e5+7;
//int n,m;
//vector<int> a(mx),b(mx);
// vector<int> g[mx];
// int deg[mx];
//vector<int> adj[mx];
//vector<int> ans;
//---dfs--
// bool visited[mx];
// vector<ll> val(mx,0);

// void dfs(int s,int e,int c1,int c2){
// 	if(a[s]^c1!=b[s]) {ans.push_back(s), c1^=1;}
// 	for(auto u:adj[s]){
// 		if(u!=e){
// 			dfs(u,s,c2,c1);
// 		}
// 	}
// }
//---dfs---

//---primes---
// const int N = 1e7 + 10;

// bool prime[N];
 
// int spf[N];
 
// void calc(){
// 	for(int i = 2; i<1e4; i++){
// 		if(prime[i])
// 			continue;
// 		spf[i] = i;
// 		for(int j = i * i; j < N; j += i){
// 			prime[j] = 1;
// 			spf[j] = i;
// 		}
// 	}
// 	for(int i = 2; i < N; i++)
// 		if(!spf[i])
// 			spf[i] = i;
// }

// vector<pair<int,int>> getp(int x){
// 	int curr=x;
// 	vector<pair<int,int>> ans;
// 	while(curr>1){
// 		int a=spf[curr];
// 		int count=0;
// 		while(curr%a==0){ curr/=a; count++;}
// 		ans.push_back(make_pair(a,count));
// 	}
// 	return ans;
// }

// bool ispr(int n) {
// 	if(n==1) return false;
//     for (int i=2;i*i<=n;++i){
//         if(n%i==0){
//             return false;
//         }
//     }
//     return true;
// }
//---primes---

//---segment_tree---
// int upd(int t,int val,int l,int r,int y, int z){
// 	if(y<l||y>r) return tr[val];
// 	if(l==r) return tr[val]=z;
// 	int s=(l+r)/2;
// 	upd(t^1,2*val+1,l,s,y,z);
// 	upd(t^1,2*val+2,s+1,r,y,z);
// 	if(t) tr[val]=tr[2*val+1]|tr[2*val+2];
// 	else tr[val]=tr[2*val+1]^tr[2*val+2];
// 	return tr[val];
// }
//int query(){}
//---segment_tree---

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int T=1;
	//cin>>T;
	while(T--){
		ll x,k,d;
		cin>>x>>k>>d;
		x=abs(x);
		ll ans=0;
		if(x==0) {if(k%2==1) ans=d;}
		else{
			if(x>d){
				if(k<=x/d){
					ans=x-k*d;
				}
				else{
					ll p=x-d*(x/d);
					ll q=k-x/d;
					if(q%2==1) ans=abs(p-d);
					else ans=p;
				}
			}
			else{
				if(k%2==1) ans=abs(x-d);
				else ans=x;
			}
		}
		cout<<ans<<"\n";
 	}
}

Measured memory_bytes: 3680
L,R = map(int,input().split())
MOD = 2019

LENGTH = (R-L+1) / MOD
if LENGTH < 1:
    ans = float("inf")
    for i in range(L, R):
        for j in range(i+1, R+1):
            ans = min(ans, (i * j) % MOD)
    print(ans)
else:
    print(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
// https://boostjp.github.io/tips/multiprec-int.html
// https://boostjp.github.io/tips/multiprec-float.html
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;

using namespace std;

#define ll long long
const int MOD = 1e9 + 7;
#define INF 2e9

#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20)

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; }

ll n,m,k;
string s;
int main() {
    INIT();

    cin >> n;
    int cnt = 0;
    REP(i, n) {
        ll a,b;
        cin >> a >> b;
        if(a == b) {
            cnt++;
        } else {
            cnt = 0;
        }
        if(m < cnt) m = cnt;
    }
    cout << (m >= 3 ? "Yes" : "No");
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
//#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n;
  cin >> n;
  vl p(n);
  rep(i, n) cin >> p[i];
  ll cnt=n-2;
  rep2(i, 1, n-2) {
    if(p[i-1]>p[i] && p[i]<p[i+1]) cnt--;
    if(p[i-1]<p[i] && p[i]>p[i+1]) cnt--;
  }
  cout << cnt << newl;
  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 ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"Yes\n";
#define no cout<<"No\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int a,b,c,k;cin>>a>>b>>c>>k;
    int mn=0;
    while(b<=a)
    {
        mn++;
        b*=2;
    }
    while(c<=b)
    {
        mn++;
        c*=2;
    }
    yesno(mn<=k);
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
   ll n;
   cin >>n;
   ll s[n],sum=0;
   vector <ll> p;
   for(ll i=0;i<n;i++) {
     cin >>s[i];
     sum+=s[i];
   }
   sort(s,s+n);
   if(sum%10!=0) cout <<sum<<endl;
   else{
     for(ll i=0;i<n;i++){
       if((sum-s[i])%10!=0) {
         cout <<sum-s[i]<<endl;
         return 0;
       }
     }
     cout<<0<<endl;
   }
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    long int h;
    scanf("%ld", &h);

    long int ans = 0;
    long int count = 1;
    while (h != 1){
        h = h / 2;
        //printf("%d\n", h);
        //ans += count * 1;
        count *= 2;
        ans += count * 1;
    }
    printf("%ld\n", ans + 1);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
const int N=105;
const int mod=1e9+7;
const double eps=1e-8;
const double PI = acos(-1.0);
#define lowbit(x) (x&(-x))
char a[N][N],b[N][N];
int main()
{
    std::ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        cin>>a[i]+1;
    for(int j=1; j<=m; j++)
        cin>>b[j]+1;
    int yes=0;
    for(int i=1; i+m-1<=n; i++)
    {
        for(int j=1; j+m-1<=n; j++)
        {
            int flag=0;
            for(int k=i; k<=i+m-1&&k<=n; k++)
            {
                for(int l=j;l<=j+m-1&&l<=n;l++)
                {
                    if(a[k][l]!=b[k-i+1][l-j+1])
                    {
                        flag=1;
                        break;
                    }
                }
                if(flag)
                    break;
            }
            if(!flag)
            {
                yes=1;
                break;
            }
        }
        if(yes)
            break;
    }
    if(yes)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

typedef long long ll;

ll gcd(ll a, ll b){
	if(b == 0) return a;
	return gcd(b, a % b);
}

ll H, h, m, s;

int main(){
	while(cin >> H >> h >> m >> s, H || h || m || s){
		bool flg = true;
		while(flg){
			ll begin = h * 60 * 60 + m * 60 + s;
			ll end = h * 60 * 60 + (m + 1) * 60;
			
			ll nn = H * (120 * (h * 60 * 60 + m * 60) - h * 60 * 60);
			ll dd = 119 * H - 1;
			//int nn = -120 * H * (h * 60 * 60 + m * 60) + H * (h * 60 * 60);
			//int dd = 1 - 119 * H;
			bool ff = false;
			ll aann, aadd;
			for(int i = -1; i <= 1; i++){
				ll nnn = nn - i * H * 60 * 60;
				if(( H * 60  - 1) * nnn == H * 60 * (h * 60 * 60 + m * 60) * dd) continue;
				if((H - 1) * nnn == H * (h * 60 * 60) * dd) continue;
				if(begin * dd <= nnn && nnn < end * dd){
					if(!ff || (double)aann / aadd > (double) nnn / dd){
						ff = true;
						aann = nnn;
						aadd = dd;
					}
				}
			}
			if(ff){
				ll am = aann / aadd / 60;
				ll ah = am / 60;
				aann -= am * aadd * 60;
				ll g = gcd(aann, aadd);
				cout << ah << " " << am % 60 << " " << (aann / g)  << " " << aadd / g << endl;
				break;
			}

			s = 0;
			m += 1;
			if(m == 60){
				h = (h + 1) % H;
				m = 0;
			}
		}
	}
}

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

int main(){
  int n,c,i;
  for(cin>>n;n;n--){
    deque<char> d;
    string s;
    cin>>s;
    d.push_back(s[0]);
    for(i=1,c=0;i<s.size();i+=3){
      if(s[i]=='-')c++;
      else c--;
      if(c==d.size())d.push_back(s[i+2]);
      if(c==-1)d.push_front(s[i+2]),c=0;
    }
    for(i=0;i<d.size();i++)cout<<d[i];
    cout<<endl;
  }
}

Measured memory_bytes: 1200
import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val Array(a,b) = new BufferedReader(new InputStreamReader(System.in)).readLine().split("\\s+").map(_.toInt)
    System.out.println(
      if (a < b * 2) {
        0
      } else {
        a - b * 2
      }
    )
  }
}


Measured memory_bytes: 25672
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;

int main() {
    ll H, W;
    cin >> H >> W;
    ll sh, sw, gh, gw;
    cin >> sh >> sw;
    cin >> gh >> gw;
    sh--;
    sw--;
    gh--;
    gw--;

    // 道の一覧
    vector<vector<bool>> roads(H, vector<bool>(W, false));
    for (ll h = 0; h < H; h++) {
        for (ll w = 0; w < W; w++) {
            char c;
            cin >> c;
            while (c != '.' && c != '#') {
                cin >> c;
            }
            if (c == '.') {
                roads[h][w] = true;
            }
        }
    }

    vector<vector<bool>> done(H, vector<bool>(W, false));
    vector<stack<pair<ll, ll>>> diststack(H * W + 1);
    ll d = 0;
    diststack[0].push(make_pair(sh, sw));
    while (d < (ll)diststack.size()) {
        if (diststack[d].empty()) {
            d++;
            continue;
        }
        auto src = diststack[d].top();
        diststack[d].pop();
        ll h = src.first;
        ll w = src.second;
        if (h == gh && w == gw) {
            cout << d << endl;
            return 0;
        }
        if (done[h][w]) {
            continue;
        }
        done[h][w] = true;
        for (ll y = h - 2; y <= h + 2; y++) {
            for (ll x = w - 2; x <= w + 2; x++) {
                if (y >= 0 && y < H && x >= 0 && x < W && roads[y][x] && !done[y][x]) {
                    if (abs(x - w) + abs(y - h) == 1) {
                        diststack[d].push(make_pair(y, x));
                    } else {
                        diststack[d + 1].push(make_pair(y, x));
                    }
                }
            }
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 677540
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner()
	N, K := sc.NextInt(), sc.NextInt()
	H := sc.NextIntArray()
	sort.Ints(H)

	sum := 0
	for i := 0; i < N-K; i++ {
		sum += H[i]
	}
	fmt.Println(sum)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 12672
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, A: "List[int]"):
    print(N - sum(A) if N - sum(A) >= 0 else -1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9848
#include <bits/stdc++.h>
using namespace std;
 
#define ull     		unsigned long long int
#define ll      		long long int
#define loop(i,s,e)     for(ll i=(s);i<(e);i++)
#define rloop(i,s,e)    for(ll i=(s);i>=(e);i--)
#define scan(any)       for(auto &i:any) cin>>i;
#define print(any)      for(auto i:any) cout<<i<<" "; nl;
#define nl              cout<<'\n'
#define pi 3.141592654
#define hell 1000000007
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define IP(n) int n;cin>>n
#define IP2(a, b) int a,b;cin>>a>>b
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int,int>
#define piii pair<pair<int,int>,int>
#define all(v) (v).begin(), (v).end()
#define sz(x) (int)x.size()
#define set(a,n) memset(a,n,sizeof(a))
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
const int INF = 1<<29;
inline int two(int n) { return 1 << n; }
inline int last_bit(int n) { return n & (-n); }
inline int test(int n, int b) { return (n>>b)&1; }
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline void set_bit(int & n, int b) { n |= two(b); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////////////////
int main()
{
 bitset<9>b;
int ar[9];
loop(i,0,9)
  cin>>ar[i];
IP(n); 
  vi v(n);
 scan(v);
  loop(i,0,n)
    loop(j,0,9)
    if(v[i]==ar[j])
      b[j]=1;
if( (b[0]&&b[1]&&b[2]) || (b[0]&&b[3]&&b[6]) || (b[0]&&b[4]&&b[8]) ||(b[2]&&b[5]&&b[8])||(b[8]&&b[7]&&b[6])||(b[2]&&b[4]&&b[6])||(b[3]&&b[4]&&b[5])||(b[1]&&b[4]&&b[7]))
                                                                                      cout<<"Yes";
                                                                                      else
                                                                                      cout<<"No";
nl;
return 0;
}	


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

char str0[16];
char str1[16];

void solve()
{
    scanf("%s%s", str0, str1);
    int len = strlen(str1);
    str1[len - 1] = '\0';
    if (strcmp(str0, str1) == 0) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 1616
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    ll n, x;

    cin >> n >> x;

    ll res = n;

    ll a = x;
    ll b = n - x;

    while (true)
    {
        res += (b / a) * a * 2;

        if (b % a == 0)
        {
            res -= a;
            break;
        }

        ll t = b;
        b = a;
        a = t % a;
    }

    cout << res << endl;

    return 0;
}

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

int main(){
  int a,b,c,d;
  cin >>a >>b >>c >>d;
  bool can = true;
  while(true){
    c -= b;
    if(c<=0){
      break;
    }
    a -= d;
    if(a<=0){
      can = false;
      break;
    }
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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



int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    string s;
    cin>>s;
    REP(i,s.size()){
        s[i] = 'x';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3624
#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() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  string s;
  cin >> s;
  constexpr int N = 13;
  vector<ll> dp(N);
  constexpr ll mod = 1e9 + 7;
  ll mul = 1;
  dp[0] = 1;
  for (int i = s.size() - 1; i >= 0; --i) {
    vector<ll> next_dp(N);
    if (s[i] == '?') {
      for (int k = 0; k < 10; ++k) {
        for (int j = 0; j < N; ++j) {
          int index = (k * mul + j) % N;
          next_dp[index] += dp[j];  
          next_dp[index] %= mod;
        }
      }
    } else {
      int k = (int)(s[i] - '0');
      for (int j = 0; j < N; ++j) {
        int index = (k * mul + j) % N;
        next_dp[index] += dp[j];  
        next_dp[index] %= mod;
      }
    }
    mul *= 10;
    mul %= N;
    dp = next_dp;
  }
  cout << dp[5] << endl;
  return 0;
}


Measured memory_bytes: 512