akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();   
        int N = r.i();
        long[] A = r.ll();
        long x = 0;
        for(int i = 0, j = 1; i < N; i++, j = -j)
            x += j*A[i];
        StringBuilder sb = new StringBuilder();
        sb.append(x);
        sb.append(" ");
        for(int i = 0; i < N-1; i++){
            sb.append(x = -x+2*A[i]);  
            sb.append(" ");
        }
        println(sb);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 46596
let hoge = readLine()!.split(separator: " ").compactMap { Int($0) }
let n = hoge[0]
let x = hoge[1]
let m = hoge[2]

var pointers = [Int: Int]()
var array: [Int] = [x]
var cycle: (Int, Int)? = nil
for i in 0..<n-1 {
    let ai = (array.last! * array.last!) % m
    array.append(ai)

    // To be 0
    if ai == 0 {
        break
    }

    // To be cycle
    if let element = pointers[ai] {
        cycle = (element, array.count)
        break
    } else {
        pointers[ai] = array.count
    }
}

if let cycle = cycle {
    let firstValue = array[0..<cycle.0].reduce(0) { $0 + $1 }

    let repeatCount = (n - cycle.0) / (cycle.1 - cycle.0)
    let repeatValue = array[cycle.0..<cycle.1].reduce(0) { $0 + $1 } * repeatCount

    let lastCount = (n - cycle.0) % (cycle.1 - cycle.0)
    let lastValue = array[cycle.0..<(cycle.0 + lastCount)].reduce(0) { $0 + $1 }

    print(firstValue + repeatValue + lastValue)
} else {
    print(array.reduce(0, { $0 + $1 }))
}


Measured memory_bytes: 11912
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;



signed main(){
	int H, W;
	cin >> H >> W;
	int M;
	cin >> M;
	vector<int>tate(H), yoko(W);
	vector<int>h(M), w(M);
	REP(i, M) {
		cin >> h[i] >> w[i];
		--h[i]; --w[i];
		tate[h[i]]++;
		yoko[w[i]]++;
	}
	int t = *max_element(ALL(tate));
	int y = *max_element(ALL(yoko));
	//out(t, y);
	vector<int>TATE(H), YOKO(W);
	REP(i, H) {
		if(tate[i] == t) TATE[i] = 1;
	}
	REP(i, W) {
		if(yoko[i] == y) YOKO[i] = 1;
	}
	int tmp = accumulate(ALL(TATE), 0ll) * accumulate(ALL(YOKO), 0ll);
	//out(tmp);
	int ans = t + y;
	REP(i, M) {
		if(TATE[h[i]] && YOKO[w[i]]) --tmp;
	}
	if(tmp) out(ans);
	else out(ans - 1);
}

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

int count(long n)
{
  int res = 0;
  while (0 < n)
  {
    res++;
    n /= 10;
  }
  return res;
}

int main()
{
  long N;
  cin >> N;
  int ans = INT16_MAX;
  for (long i = 1; i * i <= N; i++)
  {
    if (N % i == 0)
    {
      int tmp = max(count(i), count(N / i));
      if (tmp < ans)
        ans = tmp;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;

	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var n = p[0];
		var x = p[1];
		var t = p[2];
		var r = n/x;
		if(n%x>0)
		{
			r++;
		}
		Console.WriteLine(r*t);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}


Measured memory_bytes: 27548
#include<bits/stdc++.h>
using namespace std;
string fun(int x,int y,string s)
{
	string temp;
	for(int i=x;i<=y;i++)
	{
		temp.push_back(s[i]);
	}
	return temp;
}
bool check(string s)
{
	string temp=s;
	reverse(temp.begin(), temp.end());
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=temp[i])
			return false;
	}
	return true;
}
bool check_strong(string s1,string s2,string s)
{
	if(check(s)==true and check(s1)==true and check(s2)==true)
		return true;
	else
		return false;
}
int main()
{
	string s;
	cin>>s;
	int n=s.size();
	int index1=0,index2=(n-1)/2;
	index2--;
	int index3=(n+3)/2;
	index3--;
	int index4=n;
	index4--;
	string s1=fun(index1,index2,s);
	string s2=fun(index3,index4,s);
	if(check_strong(s1,s2,s))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	
	int A,B,C,D,i,j=0,MAX=0,MIN=100;
	int a[4];
	int b[2];
	cin>>A>>B>>C>>D;
	a[0]=A;a[1]=B;a[2]=C;a[3]=D;

	if(D<=A||B<=C){cout<<"0";}
	else{
		for(i=0;i<=3;i++){
          if(MAX<a[i]){MAX=a[i];}
		  if(MIN>a[i]){MIN=a[i];}
        }
      if(A==C||B==D){
        if(B-A<=D-C){b[0]=B-A;b[1]=0;}
        if(B-A>D-C){b[0]=D-C;b[1]=0;}
      }
      
      
      else{
		for(i=0;i<=3;i++){
			if(a[i]!=MAX&&a[i]!=MIN){
              b[j]=a[i];j++;
			}
		}
      }
		if(b[0]<=b[1]){cout<<b[1]-b[0];}
		if(b[1]<b[0]){cout<<b[0]-b[1];}
                            }
return 0;
}

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

int main() {
    stack<int> S1;
    stack<pair <int, int> > S2;
    char ch;
    int sum = 0;

    for (int i = 0; cin >> ch ; i++) {
        if( ch == '\\' ) S1.push(i);
        else if( ch == '/' && S1.size() > 0){
            int j = S1.top(); S1.pop();
            sum += i - j;
            int a = i - j;
            while( S2.size() > 0 && S2.top().first  > j ){
                a += S2.top().second; S2.pop();
            }
            S2.push(make_pair(j, a));
        }
    }

    vector<int> ans;
    int t = 0;
    while( S2.size() > 0 ) { ans.push_back(S2.top().second); S2.pop(); }
    reverse(ans.begin(), ans.end());
    cout << sum << endl;
    cout << ans.size();
    for (int i = 0; i < ans.size(); i++) {
        cout << " ";
        t += ans[i];
        cout << ans[i];
    }
    cout << endl;

    return 0;
}

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

#define pb(a) push_back((a))
#define mp(a, b) make_pair((a), (b))
#define REP(a, b) for (ll i = (a); i < (b); i++)
#define REP2(a, b) for (ll j = (a); j < (b); j++)
#define REPE(a, b, c, d) \
	REP(a, b)            \
	for (ll j = (c); j < (d); j++)
#define REPV(a, b, c) for (ll(a) = b; (a) < (c); (a)++)
#define IREP(a, b) for (ll i = (a); i >= (b); i--)
#define IREP2(a, b) for (ll j = (a); j >= (b); j--)
#define IREPV(a, b, c) for (ll(a) = b; (a) >= (c); (a)--)
#define all(v) (v).begin(), (v).end()
#define Trvs(c) for (auto &it : c)
#define INF INT_MAX
#define sz(x) x.size()
#define flash                         \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);
#define F first
#define S second
#define MOD 1000000007

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;

auto cmp = [](pair<ll, pair<ll, ll>> a, pair<ll, pair<ll, ll>> b) {
	if (a.F == b.F)
		return a.S.F > b.S.F;
	return a.F > b.F;
};
//decltype(cmp)
//set<,decltype(cmp)> st(cmp);
void solve()
{
	ll a, b;
	cin >> a >> b;
	cout << a * b;
}

int main()
{
	flash


	// seive(100000);
	// calculatepi();
	// ll t;
	// cin >> t;
	// while (t--)
	solve();
	return 0;
}


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

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

    ll ans = 1000;
    ll mini = 300, maxi = 0;
    rep(i, n) {
        mini = min(mini, a[i]);
        maxi = max(maxi, a[i]);
        if (i + 1 >= n || a[i] >= a[i + 1]) {
            if (mini == maxi) {
                if (a[i] > a[i + 1]) {
                    mini = 300;
                    maxi = 0;
                }
                continue;
            }
            ans += (maxi - mini) * ll(ans / mini);
            mini = 300;
            maxi = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    for(int i=0;i<n;i++){
        if(a==b-1){
            cout<<"Borys"<<endl;
            return 0;
        }
        a++;
        if(a==b-1){
            cout<<"Alice"<<endl;
            return 0;
        }
        b--;
        if(a==b-1){
            cout<<"Borys"<<endl;
            return 0;
        }
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MOD = 2019;
int main(){
    string s;
    cin>>s;
    int n = s.length();
    int suf = 0;
    int power_of_ten = 1;
    vector<int> ctn_suf(MOD);
    long long answer = 0;
    ctn_suf[suf]++;
    for(int i = n - 1;i>= 0;i--){
        int digit = s[i] - '0';
        suf = (suf + digit * power_of_ten) % MOD;
        power_of_ten = 10 * power_of_ten % MOD;
        answer += ctn_suf[suf];
        ctn_suf[suf]++;
    }
    cout<<answer<<endl;
    return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
struct mint {
    ll x;
    mint(ll x = 0):x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct combination {
    // vector size : n + 1
    vector<mint> fact, ifact;
    // precaliculation O(n)
    combination(int n):fact(n+1), ifact(n+1) {
        assert(n < mod);
        // 0! = 1;
        fact[0] = 1;
        // 1! = 0! * 1 ... n! = (n-1)! * n
        for (int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
        // 1/n! = n!^(-1)
        ifact[n] = fact[n].inv();
        // (n-1)!^(-1) = n!^(-1) * n ... 0!^(-1) = 1!^(-1) * 1
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i] * i;
    }
    // combination O(1)
    // nCk = n! / (k! * (n-k)!)
    //     = n! * k!^(-1) * (n-k)!^(-1)
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n-k];
    }
};
/* global variables */
/* function */
/* main */
int main() {
    int n, k;
    cin >> n >> k;
    if (n < k) { cout << 0 << '\n'; return 0; }
    mint ans = 0;
    combination c = combination(1000);
    for (int i = 0; i <= k; i++) {
        mint tmp = i;
        tmp = tmp.pow(n);
        tmp *= c(k, i);
        if ((k - i) % 2) ans -= tmp;
        else ans += tmp;
    }
    cout << ans << '\n';
}


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

int main() {
  int a,b,c,d;
  cin >> a >>b>>c>>d;

  if (a+b > c+d) {
    cout << "Left" << endl;
  }
  else if(a+b < c+d){
  cout << "Right" << endl;
  }
  else {
    cout << "Balanced"<<endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(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; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    cin >> n;
    cout << n/3 << endl;
}

Measured memory_bytes: 256
s=input()
t=input()
dp=[[0]*(len(t)+1) for _ in range(len(s)+1)]
for i in range(len(s)):
  for j in range(len(t)):
    if s[i]==t[j]:
      dp[i+1][j+1]=dp[i][j]+1
    else:
      dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])
len_=dp[len(s)][len(t)]
s_now=len(s)
t_now=len(t)
ans=''
if len_==0:
  print(ans)
  exit()
while len_>0:
  if s[s_now-1]==t[t_now-1]:
    ans=ans+s[s_now-1]
    len_+=-1
    s_now+=-1
    t_now+=-1
    
  else:
    if dp[s_now][t_now]==dp[s_now][t_now-1]:
      t_now=t_now-1
    elif dp[s_now][t_now]==dp[s_now-1][t_now]:
      s_now=s_now-1
ans=ans[::-1]
print(ans)



Measured memory_bytes: 144192
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include <cstdlib>
#define pii pair<ll,ll>
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define mem(i,a) memset(i,a,sizeof(i))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
const int DMAX=500000+5;
const int MOD=998244353;
template<class T> inline void read(T &x){
    x=0; 
    T f=1;
    char ch=getchar();
    while(ch<'0' || ch>'9'){
        if(ch=='-'){
            f=-1;
        }
        ch=getchar();
    }
    while(ch<='9' && ch>='0'){
        x=x*10+(ch-'0');
        ch=getchar();
    }
    x*=f;
}

int main(){
    int n,m;
    cin>>n>>m;
    cout<<n*m<<endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define INF 1e18
typedef long long ll;
typedef pair<int, int> P;

int main(){
  int a,b;
  cin>>a>>b;
  for(int i=0;i<=a;i++){
    int t=i*2;
    int c=b-t;
    if(c%4==0 && c/4+i==a){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 3632
n = int(raw_input())
a = map(int, raw_input().split())
 
ans = 0
temp = 0
for i in xrange(n-1):
    if a[i] >= a[i+1]:
        temp = temp + 1
    else:
        ans = max(ans, temp) 
        temp = 0
 
print max(ans, temp)

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

int main()
{
	int n, w;
	while (cin >> n >> w, n + w){
		int cnt[11] = {0};
		int m = 0;
		int l = 0;
		for (int i = 0; i < n; i++){
			int v;
			cin >> v;
			cnt[v / w]++;
			m = max(m, cnt[v / w]);
			l = max(l, v / w);
		}
		
		double res = 0.01;
		for (int i = 0; i <= l; i++){
			res += (double)(l - i) / l * ((double)cnt[i] / m);
		}
		
		cout << res << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1232
//
//  main.cpp
//  ABC154E
#include <iostream>
#include<vector>
#include<string>
using namespace std;
int main(int argc, const char * argv[]) {
    string S;
    cin >>S;
    int K;
    cin >> K;
    unsigned long length=S.length(); // 入力された数値の桁数
    vector<vector<int>>dp1(length+1,vector<int>(4));
    vector<vector<int>>dp0(length+1,vector<int>(4));
    // 初期値
    // dp1 未満
    dp1.at(0).at(0)=0;
    dp1.at(0).at(1)=0;
    dp1.at(0).at(2)=0;
    dp1.at(0).at(3)=0;
    // dp0 一致
    dp0.at(0).at(0)=1;
    dp0.at(0).at(1)=0;
    dp0.at(0).at(2)=0;
    dp0.at(0).at(3)=0;
    // 入力した数値の先頭（右端）は必ず０ではない
    dp0.at(1).at(0)=1;
    vector<int>n(length+1);
    n.at(0)=0;
    for (int i=1; i<=length; i++) {
        n.at(i) =S[i-1]-'0'; // 各桁の数値をnにセット
    }
    int r1; // 繰り返しの数
    int r2;
    for (int i=1; i<=length; i++) {
        if(n.at(i)>0){
            r1=n.at(i)-1;
            r2=1; // 入力した数値の該当する桁が０でないとき
        }else{
            r1=0;
            r2=0; // 入力した数値の該当する桁が０のとき
        }
        dp1.at(i).at(0)=1;
        dp1.at(i).at(1)=dp1.at(i-1).at(0)*9+dp1.at(i-1).at(1)+dp0.at(i-1).at(0)*r1+dp0.at(i-1).at(1)*r2;
        dp1.at(i).at(2)=dp1.at(i-1).at(1)*9+dp1.at(i-1).at(2)+dp0.at(i-1).at(1)*r1+dp0.at(i-1).at(2)*r2;
        dp1.at(i).at(3)=dp1.at(i-1).at(2)*9+dp1.at(i-1).at(3)+dp0.at(i-1).at(2)*r1+dp0.at(i-1).at(3)*r2;
        //
        dp0.at(i).at(0)=0; // dp0.at(i).at(0)は常に０
        // 各桁の数が０なら前の桁までの情報をコピーする。
        if(n.at(i)==0){
            dp0.at(i).at(1)=dp0.at(i-1).at(1);
        } else{
            dp0.at(i).at(1)=dp0.at(i-1).at(0);
            dp0.at(i).at(0)=0;
        }
        if(n.at(i)==0){
            dp0.at(i).at(2)=dp0.at(i-1).at(2);
        }else{
            dp0.at(i).at(2)=dp0.at(i-1).at(1);
        }
        if (n.at(i)==0) {
            dp0.at(i).at(3)=dp0.at(i-1).at(3);
        }else{
            dp0.at(i).at(3)=dp0.at(i-1).at(2);
        }
    }
    cout<<dp1.at(length).at(K)+dp0.at(length).at(K)<<endl;
    return 0;
}


Measured memory_bytes: 256
use std::collections::*;
use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: i64,
        k: i64,
    }

    let x = n - (n/k)*k;

    println!("{}", min(x, (x - k).abs()));

}


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

int main(){
    int64_t l, r;
    cin >> l >> r;
    if(r-l > 2020){
        cout << 0 << endl;
    }else{
        int64_t ans = 2018;
        for(int64_t i=l; i<=r-1; i++){
            for(int64_t j=i+1; j<=r; j++){
                ans = min(ans, (i*j)%2019);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 10000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main() 
{ 
    fastio
    ll x;
    cin>>x;

    ll ans = 0;
    ans += (x/500)*1000;
    x = x%500;
    ans += (x/5)*5;
    cout<<ans<<endl;
} 

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

string dp[101][101][2];//zero, one, 0or1

int main(){
    for(int y=1;y<=100;y++) dp[0][y][1]=string(y,'1');
    for(int x=1;x<=100;x++){
        if(x%2){
            dp[x][0][0]=string(x,'0');
        }else{
            dp[x][0][1]=string(x,'0');
        }
    }
    for(int x=1;x<=100;x++){
        for(int y=1;y<=100;y++){
            if(dp[x-1][y][1]!=""){
                dp[x][y][0]="0"+dp[x-1][y][1];
            }else{
                dp[x][y][0]="";
            }
            dp[x][y][1]="1"+dp[x][y-1][0];
            if(dp[x-1][y][0]!="") dp[x][y][1]=min(dp[x][y][1], "0"+dp[x-1][y][0]);
            if(dp[x][y-1][1]!="") dp[x][y][1]=min(dp[x][y][1], "1"+dp[x][y-1][1]);
        }
    }

    int N;
    cin>>N;
    vector<int> V;
    int zero=0, one=0;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        if(a==0){
            zero++;
        }else if(a==1){
            one++;
        }else{
            V.push_back(a);
        }
    }
    sort(V.begin(),V.end());
    string s;
    int victim=-1;
    if(zero%2==1&&!one){
        if(V.size()>0){
            victim = V.front();
            V.erase(V.begin());
            one++;
        }
    }
    int n = V.size();
    if(n>=2&&V[n-2]==2&&V[n-1]==3) swap(V[n-2],V[n-1]);
    for(auto v:V){
        cout<<v<<endl;
    }
    if(zero%2&&!one){
        s+=dp[zero][one][0];
    }else{
        s+=dp[zero][one][1];
    }
    for(auto c:s){
        if(victim!=-1&&c=='1') c='0'+victim;
        cout<<c<<endl;
    }

    return 0;
}

Measured memory_bytes: 6032
#include <iostream>
#include <utility>
#include <vector>

using namespace std;
using int64 = long long;
using P = pair<int64,int64>;

int main() {
    int64 n,m;
    cin >> n >> m;
    vector<P> ab;
    for (int i=0; i<n; i++) {
        int64 a,b;
        cin >> a >> b;
        ab.emplace_back(a,b);
    }

    sort(ab.begin(), ab.end());

    int64 ans = 0;
    for (auto p : ab) {
        int64 a,b;
        tie(a,b) = p;
        ans += a * min(m,b);
        m -= b;
        if (m <= 0) break;
    }

    cout << ans << endl;
}


Measured memory_bytes: 2420
#include<stdio.h>
#include<vector>
#include<math.h>
#include<cstring> 
#include<algorithm>
#include<iostream>
#include<string>
using namespace std;
const int MAXN = 1e5 + 7;
int ans[MAXN];
int v1[MAXN];
int v2[MAXN];
bool cmp(int a, int b)
{
	return a > b;
}
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &ans[i]);
		if (i % 2 == 0)
			v1[ans[i]]++;
		else
			v2[ans[i]]++;
	}
	int x=0, y=0;
	for (int i = 1; i <= n; i++)
	{
		if (v1[ans[i]] > v1[x])
		{
			x = ans[i];
		}
		if (v2[ans[i]] > v2[y])
		{
			y = ans[i];
		}
	}
	sort(v1, v1 + MAXN, cmp);
	sort(v2, v2 + MAXN, cmp);
	if (x != y)
	{
		cout << n - v1[0] - v2[0] << endl;
	}
	else
	{
		cout << min(n - v1[0] - v2[1], n - v1[1] - v2[0]) << endl;
	}
	return 0;
}


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

using namespace std;

template<typename K, typename V>
multimap<V,K> invertMap(map<K,V> const &map)
{
	multimap<V,K> multimap;
	for (auto const &pair: map) {
		multimap.insert(std::make_pair(pair.second, pair.first));
	}
	return multimap;
} //exp multimap<int,int> multimap = invertMap(w);
bool sf(string a,string b)
{
	if (b.find(a)!=string::npos)
		return true;
	return false;
}
#define ff first
#define ss second
#define ll long long
#define em emplace_back
#define mk make_pair
#define um unordered_map
#define iox ios::sync_with_stdio(false),cin.tie(0)
#define debug() system("pause");
#define debugv(opx) cout<<endl;for(auto x:opx)cout<<x<<" ";cout<<endl;
#define cox(opx); for(auto& x:opx)


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






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin>>N;
	vector<int> vec(N);
	for(int i=0; i<N; i++){
		cin>>vec[i];
	}
	long long int ans=100000000;
	for(int i=-100; i<200; i++){
		long long int sum=0;
		for(int k=0; k<N; k++){
			sum+=(vec[k]-i)*(vec[k]-i);
		}
		ans=min(ans,sum);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a[10],b=0,c=0,d[3],e=0;

  while(cin >> a[b]){
    if(b==10)break;
    b++;
  }

  sort(a,a+10);

  for(e=9;e!=6;e--){
    cout << a[e] <<endl;
  }
}

Measured memory_bytes: 1180
#include<stdio.h>
#include<ctype.h>
int main(void)
{
int ch;
int counter[26]={};
 while(scanf("%c",&ch)!=EOF){
   if (islower(ch)){
     int num=ch-'a';
     counter[num]++;
   }
   else if (isupper(ch)){
     int num=ch-'A';
     counter[num]++;
   }
 }
 
 int i;
 for(i=0;i<26;i++){
   printf("%c : %d\n",i+'a',counter[i]);
 }
 return 0;
}

Measured memory_bytes: 544
const lines = [];
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
reader.on("line", function (line) {
  lines.push(line);
});

reader.on("close", function () {
  const num = lines[0] as string;
  let mochis = new Map();

  for (let i = 1; i < lines.length; i++) {
    const key = lines[i];
    // console.log(key);
    mochis.set(key, "a");

    // (<any>Object).assign(mochis, JSON.parse(JSON.stringify(`${key}:a`)));
  }

  //   console.log(mochis);
  console.log(mochis.size);
});


Measured memory_bytes: 7628
#include <iostream>
using namespace std;
int main(){
    int a[9],b[9],c[9];
    int i=0;
    
    for(i=0;i<6;i++){
        cin>>a[i];
    }
    for(i=0;i<6;i++){
        cin>>b[i];
    }
    for(i=0;i<6;i++){
        cin>>c[i];
    }
    
    a[6]=a[0]*3600+a[1]*60+a[2];
    a[7]=a[3]*3600+a[4]*60+a[5];
    a[8]=a[7]-a[6];
    
    b[6]=b[0]*3600+b[1]*60+b[2];
    b[7]=b[3]*3600+b[4]*60+b[5];
    b[8]=b[7]-b[6];
    
    c[6]=c[0]*3600+c[1]*60+c[2];
    c[7]=c[3]*3600+c[4]*60+c[5];
    c[8]=c[7]-c[6];
    
    cout<<a[8]/3600<<" ";
    cout<<(a[8]-a[8]/3600*3600)/60<<" ";
    cout<<a[8]%60<<endl;
    
    cout<<b[8]/3600<<" ";
    cout<<(b[8]-b[8]/3600*3600)/60<<" ";
    cout<<b[8]%60<<endl;
    
    cout<<c[8]/3600<<" ";
    cout<<(c[8]-c[8]/3600*3600)/60<<" ";
    cout<<c[8]%60<<endl;
    
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb2l(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const ll N=1000005;
bool prime[1000005];

void s(){
    mems(prime,true);
    for(int i=2;i*i<N;i++){
        if(prime[i]){
        for(ll j=2*i;j<N;j+=i){
                prime[j]=false;
        }
        }
    }
}
void solve(){
ll n;
cin>>n;
s();
prime[0]=false;
prime[1]=false;
for(ll i=n;i<N;i++){
if(prime[i]){
    cout<<i;
    return ;


}
}
//cout<<ans;

}

int main(){
    ll t=1;
//cin>>t;
    while(t--){
     solve();
     cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 1280
//  Created by conan1024hao in 2020.
//  Copyright © 2020 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e17
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????统一类型        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,r;cin>>n>>r;
    if(n>=10){
        cout<<r<<endl;
    }
    else{
        cout<<r+100*(10-n)<<endl;
    }
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------








Measured memory_bytes: 256
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n;
  while(1){
    scanf("%d\n",&n);
    if(n==0){
      break;
    }
    int a,b,i;
    vector<int> x(216010);
    string s;
    for(i=0;i<n;i++){
      getline(cin,s);
      a=3600*((s[0]-'0')*10+(s[1]-'0'))+60*((s[3]-'0')*10+(s[4]-'0'))+((s[6]-'0')*10+(s[7]-'0'));
      b=3600*((s[9]-'0')*10+(s[10]-'0'))+60*((s[12]-'0')*10+(s[13]-'0'))+((s[15]-'0')*10+(s[16]-'0'));
      x[a]++,x[b]--;
    }
    for(i=0;i<=216005;i++){
      x[i+1]=x[i]+x[i+1];
    }
    int ans=0;
    for(i=0;i<=216005;i++){
      if(x[i]>ans){
        ans=x[i];
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}


Measured memory_bytes: 4124
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

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

Measured memory_bytes: 19228
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;
typedef pair<int,int> P;
int n;
vector<int> xid,yid;
int fie[401][401];
int l[51],r[51],t[51],b[51];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};

void bfs(int x,int y){
	queue <P> que;
	que.push(P(x,y));
	fie[x][y]=1;
	while(que.size()){
		P q=que.front();
		que.pop();
		for(int i=0;i<4;i++){
			int nx=q.first+dx[i],ny=q.second+dy[i];
			if(nx>=0 && nx<400 && ny>=0 && ny<400){
				if(fie[nx][ny]==0){
					fie[nx][ny]=1;
					que.push(P(nx,ny));
				}
			}
		}
	}
}

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		xid.clear();
		yid.clear();
		memset(fie,0,sizeof(fie));
		for(int i=0;i<n;i++){
			scanf("%d %d %d %d",&l[i],&t[i],&r[i],&b[i]);
			l[i]*=2;
			r[i]*=2;
			t[i]*=2;
			b[i]*=2;
			for(int j=-1;j<=1;j++){
				xid.push_back(l[i]+j);
				xid.push_back(r[i]+j);
				yid.push_back(t[i]+j);
				yid.push_back(b[i]+j);
			}
		}
		sort(xid.begin(),xid.end());
		xid.erase(unique(xid.begin(),xid.end()),xid.end());
		sort(yid.begin(),yid.end());
		yid.erase(unique(yid.begin(),yid.end()),yid.end());
		for(int i=0;i<n;i++){
			int id=lower_bound(xid.begin(),xid.end(),l[i])-xid.begin();
			l[i]=id;
			id=lower_bound(xid.begin(),xid.end(),r[i])-xid.begin();
			r[i]=id;
			id=lower_bound(yid.begin(),yid.end(),t[i])-yid.begin();
			t[i]=id;
			id=lower_bound(yid.begin(),yid.end(),b[i])-yid.begin();
			b[i]=id;
			for(int j=l[i];j<=r[i];j++){
				fie[j][t[i]]=-1;
				fie[j][b[i]]=-1;
			}
			for(int j=b[i];j<=t[i];j++){
				fie[l[i]][j]=-1;
				fie[r[i]][j]=-1;
			}
		}
		int cnt=0;
		for(int i=0;i<400;i++){
			for(int j=0;j<400;j++){
				if(fie[i][j]==0){
					bfs(i,j);
					cnt++;
				}
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 1696
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mid (l+r>>1)
typedef long long ll;
template<typename T>inline T read(){
	T x=0,f=1;char c=getchar();
	for(;c<'0'||c>'9';f=c=='-'?-1:1,c=getchar());
	for(;c>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0',c=getchar());
	return x*f;
}
const int maxs=1<<19,maxn=2e5+5;
int n,v,lg,s,lt[maxs],rt[maxs],a[20][maxn],cnt[20];
ll x[maxn];
int S(int opt,int k,int x){
	int l=1,r=cnt[k];
	while(r-l>1)
		if(a[k][mid]<x||(opt&&a[k][mid]==x))l=mid+opt;
		else r=mid-1+opt;
	int r1=opt?l:r,r2=opt?r:l,f=opt?1:-1;
	if(a[k][r1]*f>x*f)return a[k][r1]+1-opt;
	return a[k][r2]+1-opt;
}
int main(){
	n=read<int>();v=read<int>();
	lg=ceil(log2(v))+1+(ceil(log2(v))==log2(v));s=(1<<lg)-1;
	for(int i=1;i<=n;i++)x[i]=read<ll>(),x[i-1]=x[i]-x[i-1];x[n]=0;
	for(int i=1;i<=lg;i++){
		cnt[i]=1;
		for(int j=1;j<=n;j++)
			a[i][cnt[i]]=j,cnt[i]+=(x[j]>v>>(i-1));
	}
	if(cnt[1]>lg){for(int i=0;i<n;i++)puts("Impossible");return 0;}
	memset(rt,0,sizeof(rt));
	for(int i=0;i<=s;i++)lt[i]=n+1;
	for(int i=0;i<=s;i+=2)
		for(int j=2;j<=lg;j++){
			int s0=1<<j-1;
			if(i&s0)continue;
			rt[i|s0]=std::max(rt[i|s0],S(1,j,rt[i]));
			lt[i|s0]=std::min(lt[i|s0],S(0,j,lt[i]-1));
		}
	for(int i=1;i<=cnt[1];i++){
		int f=0,b=a[1][i-1]+1,e=a[1][i];
		if(i==1)b=1;
		for(int s0=0;s0<=s&&(!f);s0+=2)f=(b<=rt[s0]+1&&e>=lt[s-s0-1]-1);
		for(int j=b;j<=e;j++)puts(f?"Possible":"Impossible");
	}
    return 0;
}

Measured memory_bytes: 23680
from ctypes import *
import subprocess as sp
from operator import itemgetter
import sys

set_code = r"""
#include <set>

std::set<int> s;

void add(int x) {
    s.insert(x);
}

bool find(int x) {
    return s.find(x) != s.end();
}

void remove(int x) {
    s.erase(x);
}

bool empty() {
	return s.empty();
}

int getMin() {
	return *s.begin();
}
"""

class CppSet:
	counter = 0

	def __init__(self):
		lib_name = './hoge{}.so'.format(CppSet.counter)
		code_file_name = "tmp.cpp"
		with open(code_file_name, "w") as f:
			f.write(set_code)

		CppSet.counter += 1
		sp.Popen(['g++', '-fPIC', '-shared', '-std=c++11', code_file_name, '-o', lib_name]).communicate()

		lib = CDLL(lib_name)
		self.add = getattr(lib, "_Z3addi")
		self.find = CFUNCTYPE(c_bool, c_int)(
						("_Z4findi", lib),
						((1, "x"), )
					)
		self.remove = getattr(lib, "_Z6removei")
		self.empty = CFUNCTYPE(c_bool)(
						("_Z5emptyv", lib),
						()
					)

		self.getMin = CFUNCTYPE(c_int)(
						("_Z6getMinv", lib),
						()
					)

def main():
	N, Q = map(int, sys.stdin.readline().split())
	tmp = [tuple(map(int, sys.stdin.readline().split())) for _ in range(N)]
	stx = [(s - x, 1, x) for s, t, x in tmp] + [(t - x, -1, x) for s, t, x in tmp]
	stx.sort()
	
	D = [int(sys.stdin.readline()) for _ in range(Q)] 
	ans = [-1]*Q

	idx = 0
	stx_len = len(stx)
	se = CppSet()
	for i, d in enumerate(D):
		while idx < stx_len:
			t, com, x = stx[idx]
			if t > d:
				break
			if com == 1:
				se.add(x)
			else:
				se.remove(x)
			idx += 1
		ans[i] = (-1 if se.empty() else se.getMin())

	print(*ans, sep='\n')

if __name__ == "__main__":
	main()


Measured memory_bytes: 111388
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  	int K, S;
    cin >> K >> S;

    int cnt = 0;
    for(int i=0;i<=K;i++){
      for(int j=0;j<=K;j++){
        if(S-i-j<=K && 0<=S-i-j) cnt++;
      }
    }
    cout << cnt <<endl;

  	return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string s;
  cin >> s;

  ll n = s.size();
  ll beginIndex, rIndex, lIndex, endIndex, rNum, lNum;
  beginIndex = 0;
  vll ans(n, 0);
  REP(i, n){
    if(s[i-1] == 'R' && s[i] == 'L'){
      rIndex = i-1;
      lIndex = i;
    }
    if((s[i-1] == 'L' && s[i] == 'R') || i == n-1){
      if(i == n-1)
        endIndex = i+1;
      else
        endIndex = i;
      rNum = rIndex - beginIndex + 1;
      lNum = endIndex - rIndex - 1;
      ans[rIndex] = rNum/2 + rNum%2 + lNum/2;
      ans[lIndex] = lNum/2 + lNum%2 + rNum/2;
      beginIndex = endIndex;
    }
  }

  REP(i, n)
    cout << ans[i] << ' ';
  cout << "\n";


  
  
}


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

using namespace std;

int N, M;
vector<int> MapData, DiceInfo;

int main() {
	int num, curPos, cnt;

	while (cin >> N >> M, N) {
		MapData.clear();
		for (int i = 0; i < N; ++i) {
			cin >> num;
			MapData.push_back(num);
		}
		DiceInfo.clear();
		for (int i = 0; i < M; ++i) {
			cin >> num;
			DiceInfo.push_back(num);
		}
		--N;
		cnt = 0;
		curPos = 0;
		while (curPos < N) {
			curPos += DiceInfo[cnt++];
			if (curPos >= N) {
				break;
			}
			curPos += MapData[curPos];
		}
		cout << cnt << endl;
	}

	return 0;
}


Measured memory_bytes: 3048
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 1e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
int n, q;
vii edges[200005];
int prt[200005];
ll ans[200005];
ll weight[200005];
void dfs(int now)
{
    ans[now] += weight[now];
    for (auto nex : edges[now])
    {
        if (nex == prt[now])
            continue;
        prt[nex] = now;
        ans[nex] += ans[now];
        dfs(nex);
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> q;
    rep(i, n - 1)
    {
        prt[i] = -1;
        weight[i] = 0;
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        edges[u].eb(v);
        edges[v].eb(u);
        ans[i] = 0;
    }
    ans[n - 1] = weight[n - 1] = 0;
    prt[n - 1] = -1;
    rep(xx, q)
    {
        int p, x;
        cin >> p >> x;
        p--;
        weight[p] += x;
    }
    dfs(0);
    rep(i, n) cout << ans[i] << " ";
    cout << ENDL;
}


Measured memory_bytes: 26624
#include <stdio.h>

int main() {
  int i,j,N,v,k=0,l=0,flag=1;
  int minj;
  int A[100];

  scanf("%d", &N);

  for (i = 0; i < N; i++) {
    /* code */
    scanf("%d", &A[i]);
  }
  if (flag==1) {


  for ( i = 0; i < N-1; i++) {
    /* code */
    minj=i;
    flag=0;
    for (j = i; j < N; j++) {
      /* code */
      if (A[j] < A[minj]){
        minj=j;
      }


    }
  if(A[i]!=A[minj]){
    v=A[i];
    A[i]=A[minj];
    A[minj]=v;
    k++;
    }

  }
}
  printf("%d", A[0]);

  for ( i = 1; i < N; i++) {
    printf(" %d", A[i]);
  }
  printf("\n");
  printf("%d\n", k);
  return 0;
}



Measured memory_bytes: 2104
#!/usr/bin/env python3
import sys
from bisect import bisect_left
from bisect import bisect_right


def solve(N: int, Q: int, S: str, l: "List[int]", r: "List[int]"):
    aclist = [] 
    end = N - 1
    for i in range(end):
        if S[i] == 'A' and S[i+1] == 'C':
            aclist.append(i)

    len_ac = len(aclist)

    for i in range(Q):
        res = 0
        begin = l[i] - 1
        end   = r[i] - 2

        s_start = bisect_left(aclist,begin)
        s_end   = bisect_right(aclist,end)

        print(s_end-s_start)
            


# Generated by 1.1.4 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
    Q = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    l = [int()] * (Q)  # type: "List[int]" 
    r = [int()] * (Q)  # type: "List[int]" 
    for i in range(Q):
        l[i] = int(next(tokens))
        r[i] = int(next(tokens))
    solve(N, Q, S, l, r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 13956
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
 
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    int x;
    cin >>x;
    a.at(x-1) = i+1;
  }

  rep(i,n) cout << a.at(i) << " ";
  cout << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <cstdio>
using namespace std;

int main() {
	int N,i,j,k,l,m,n,o,p,sum,cnt;
  int A[2][100];
  int B[100]={};
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[0][i]);}
  for(i=0;i<N;i++){
    scanf("%d",&A[1][i]);}
  for(j=0;j<N;j++){
    for(i=0;i<=j;i++){
    B[j]+=A[0][i];}
    for(k=j;k<N;k++){
      B[j]+=A[1][k];}
  }
  sort(B,B+N);

  printf("%d",B[N-1]);
  return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n = list(input().rstrip())
    n = [0] + n
    n = n[::-1]
    ln = len(n)
    res = 0
    a = 0
    for i in range(ln):
        s = int(n[i])
        s += a
        if 0<=s<=4:
            res += s
            a = 0
        elif 6<=s:
            res += 10-s
            a = 1
        else:
            if int(n[i+1])>=5:
                res += 10-s
                a = 1
            else:
                res += s
                a = 0
            
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 19940
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

a,b,t = map(int,input().split())

print(b*(t//a))












Measured memory_bytes: 3060