akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main (String[] args) {
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        long h = sc.nextLong();
        long[] a = new long[n];
        long[] b = new long[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextLong();
            b[i] = sc.nextLong();
        }
        Arrays.sort(a);
        Arrays.sort(b);
        int ia = n - 1, ib = n - 1;
        long v, r = 0;
        while((ia >= 0 || ib >= 0) && h > 0){
            if(ia < 0){
                h -= b[ib];
                r++;
                ib--;
            }
            else if(ib < 0){
                v = h / a[ia] + (h % a[ia] != 0 ? 1 : 0);
                h -= v * a[ia];
                r += v;
                ia--;
            }
            else{
                if(a[ia] > b[ib]) {
                    v = h / a[ia] + (h % a[ia] != 0 ? 1 : 0);
                    h -= v * a[ia];
                    r += v;
                    ia--;
                }
                else {
                    h -= b[ib];
                    r++;
                    ib--;
                }
            }
        }
        System.out.println(r);
    }
}


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

int main(){
  int N,ans = 0;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A.at(i);
    if (A.at(i) % 2 != 0) ans++;
  }
  cout << (ans % 2 == 0 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 640
import random
import numpy as np
import sys
d = int(input())
c = list(map(int, input().split()))
s = []
for i in range(d):
    temp = list(map(int, input().split()))
    s.append(temp)
s = np.array(s)
c = np.array(c)
#print(s)
#with open('output.txt', 'w') as f:
'''dice = list(range(26))
w = list(map(lambda x: x*x, c))
samples = random.choices(dice, k=d, weights=w)
for one in samples:
    print(one+1, file=f)'''
def p(text):
    print(text)

with open('output.txt', 'w') as f:
    for i in range(d):
        if max(s[i])>10000:
            if random.random()>0.3:
                #増やす
                p(s[i].argmax()+1)
            else:
                #ランダム
                p(int(random.random()*26+1))
        else:
            #減少を抑える
            dice = list(range(26))
            w = c**3
            samples = random.choices(dice, k=1, weights=w)
            for one in samples:
                p(one+1)
            #print(c.argmax()+1, file=f)

Measured memory_bytes: 27432
def solve(a,i,sa,sb):
	if 2*sa >= all: return 2*sa-all
	if 2*sb >= all: return 2*sb-all
	return min(solve(a,i+1,sa+a[i],sb),solve(a,i+1,sa,sb+a[i]))
	
while 1:
	n = input()
	if n == 0: break
	a = sorted(map(int,raw_input().split()))[::-1]
	all = sum(a)
	print solve(a,1,a[0],0)

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

int main()
{
    string s;
    cin >> s;
    set<char> st;
    for (auto c : s) {
        st.insert(c);
    }
    if (st.size() == 3) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LOCAL
#pragma region Macros
typedef long long ll;
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    ll ans=0,pre=0;
    for (int i=0;i<N;++i){
        int A; cin >> A;
        if (pre<=A) pre=A;
        else ans+=pre-A;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
const int maxn=2e6;
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
	ll k,n;
	cin>>k>>n;
	vector<ll> v(n);
	rep(i,n) cin>>v[i];
	set<ll> st;
	ll sum=0;
	repA(i,1,n-1)
	{
		sum+=(v[i]-v[i-1]);
		st.insert(v[i]-v[i-1]);
	}
	st.insert(v[0]+k-v[n-1]);
	sum+=(v[0]+k-v[n-1]);
	ll ans=sum-*st.rbegin();
	cout<<ans<<"\n";
	return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



Measured memory_bytes: 4764
#include <stdio.h>

int main()
{
	int a, b, c;
	scanf("%d %d %d",&a, &b, &c);
	if ((a==c && b==a && b==c)||(a!=c && b!=a && b!=c)){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	
	return 0;
}

Measured memory_bytes: 2068
#include<bits/stdc++.h>
using namespace std;
#define int        long long
#define nn         100005

struct item{
    int wt,val;
};
int n,cap;
item obj[nn];

int solve(){
    int dp[n+1][cap+1];
    for(int w=0;w<=cap;w++){
        dp[1][w] = 0;
    }

    dp[1][obj[1].wt] = obj[1].val;

    for(int i=2;i<=n;i++){
        for(int w=0;w<=cap;w++){
            dp[i][w] = dp[i-1][w];
            if(obj[i].wt > w)
                continue;
            dp[i][w] = max(dp[i][w], obj[i].val + dp[i-1][w-obj[i].wt]);
        }
    }

    return *max_element(dp[n], dp[n] + cap + 1);
}

int32_t main() {
    cin>>n>>cap;
    for(int i=1;i<=n;i++){
        cin>>obj[i].wt>>obj[i].val;
    }
    cout<<solve();
}


Measured memory_bytes: 78336
#include <stdio.h>
int main() {
    int a, b, c, temp;

    scanf("%d %d %d", &a, &b, &c);
    
    if (a > b) {
        temp = a;
        a = b;
        b = temp;
    }

      if (a > c) {
        temp = a;
        a = c;
        c = temp;
    }

      if (b > c) {
        temp = b;
        b = c;
        c = temp;
    }

    printf("%d %d %d\n", a, b, c);
    
    return 0;
}

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

def main():
    N, M = map(int, input().split())
    A = [-1] + [int(input()) for i in range(M)] + [N + 1]

    mod = 10**9+7 #出力の制限
    N = 10**5
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル
    for i in range( 2, N + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )

    d = [0] * (len(A) - 1)
    for i in range(len(A) - 1):
        if A[i+1] - A[i] == 1:
            print(0)
            exit(0)
        d[i] = A[i+1] - 1 - (A[i] + 1)

    ans = 1
    for dd in d:
        if dd > 1:
            tmp = 0
            for j in range(dd//2 + 1):
                tmp += cmb(dd - j, j, mod, g1, g2)
            ans *= tmp

    print(ans % 1000000007)

if __name__ == '__main__':
    main()


Measured memory_bytes: 20632
package main

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

const INFINITY = math.MaxInt64/2 - 1

func exec(stdin *Stdin, stdout *Stdout) {
	n := stdin.Read()
	for _, ch := range n {
		if ch == '7' {
			stdout.Println("Yes")
			return
		}
	}
	stdout.Println("No")
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), INFINITY)
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}

func Min(a int, b ...int) int {
	for _, v := range b {
		if v < a {
			a = v
		}
	}
	return a
}

func Max(a int, b ...int) int {
	for _, v := range b {
		if a < v {
			a = v
		}
	}
	return a
}

func Abs(x int) int {
	if x > 0 {
		return x
	} else {
		return x * -1
	}
}

func Pow(x, y int) int {
	z := 1
	for y > 0 {
		if y%2 == 0 {
			x *= x
			y /= 2
		} else {
			z *= x
			y -= 1
		}
	}
	return z
}

func CreateMatrix(x, y int) [][]int {
	matrix := make([][]int, x)
	for i := 0; i < x; i++ {
		matrix[i] = make([]int, y)
	}
	return matrix
}


Measured memory_bytes: 1764
/*
Written By mafailure
*/
//In the name of God
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less
using namespace std;
using namespace __gnu_pbds;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
//#define int long long 
// int dx[]={-1,1,0,0}; int dy[]={0,0,1,-1};
// int dx[]={2,2,-2,-2,1,1,-1,-1}; int dy[]={1,-1,1,-1,2,-2,2,-2};
const long long mod = 1e9 + 7;
const double eps=1e-9;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef vector< pair< int, int > > vii;
typedef map<int, int> mii;
typedef pair<int, ii> pip;
typedef pair<ii, int> ppi;
#define arrinp(arr,init,final,size,type) type* arr=new type[size];for(int i=init;i<final;i++)cin>>arr[i];
#define cr2d(arr,n,m,t) t**arr=new t*[n];for(int i=0;i<n;i++)arr[i]=new t[m];
#define w(t) int t;cin>>t; while(t--)
#define takeInp(n) int n;cin>>n;
#define fr(i,init,final) for(int i=init;i<final;i++)
#define frr(i,init,final) for(int i=init;i>=final;i--)
#define Fr(i,final) for(int i=0;i<final;i++)
#define Frr(i,first) for(int i=first;i>=0;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define debug(x) cerr<<">value ("<<#x<<") : "<<x<<endl;
#define setb __builtin_popcount
#define lsone(n) (n&(-n))
#define rlsone(n) (n&(n-1))
#define clr(a,b) memset(a,b,sizeof(a))
const int inf= INT_MAX;
//struct point_i{int x,y;};
struct point_i{int x,y;
point_i(){ x=0; y=0;}
point_i(int x_,int y_){x=(x_);y=(y_) ;}
};

struct point 
{
	float x,y;
	point (){x=y=0.0;}
	point (float x_,float y_){x=(x_); y=(y_);}
	bool operator < (point other) const{
	  if(fabs(x-other.x)>eps)return x<other.x;
	  return y<other.y;
		
		}
	bool operator == (point other) const {
		return fabs(other.x-x)<=eps&& fabs(other.y-y)<=eps;
		}
	
} ;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>  ordered_set; 
vi init(string s)
{
	istringstream sin(s);
	int n;
	vi arr;
	while(sin>>n)arr.push_back(n);
	return arr;
}
int power(int x, int y)
{ 
	if(y==0)return 1;
	int u=power(x,y/2);
	u=(u*u)%mod;
	if(y%2)u=(x*u)%mod;
	return u;
    
}
int gcd(int a,int b)
{
	if(a<b)return gcd(b,a);
	return (b==0?a:(a%b?gcd(b,a%b):b));
}
int gcd_e(int a,int b,int &x,int &y)
{
	
	if(b==0){x=1; y=0; return a;}
	int x1,y1;
	int p=gcd_e(b,a%b,x1,y1);
	x=y1;
	y=x1-(a/b)*y1;
	return p;
}
signed main()
{
	IOS                   
	
	int n;
	cin>>n;
	cout<<1-n<<endl;
	
}



Measured memory_bytes: 3612
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
 
ans = 0
for itr, b in enumerate(B):
  rem = b
  for i in range(2):
    dam = min(rem, A[itr + i])
    A[itr + i] -= dam
    ans += dam
    rem -= dam
print(ans)


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

using Graph=vector<vector<int>>;
int main(){
    int n;
    cin>>n;
    Graph g(n);
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    function<int(int,int)> dfs=[&](int v,int pre){
        int sum=0;
        bool zero=false;
        for(auto to:g[v]){
            if(pre!=to){
                int tmp=dfs(to,v);
                if(!tmp){
                    if(!zero) zero=true;
                    else sum++;
                }
                else{
                    sum+=tmp;
                }
            }
        }
        return sum;
    };
    int x=-1;
    for(int i=0;i<n;i++) if(g[i].size()>=3){
        x=i;break;
    }
    if(x==-1){
        cout<<1<<endl;
        return 0;
    }
    cout<<dfs(x,-1)<<endl;
    return 0;
}


Measured memory_bytes: 10752
#include <iostream>
using namespace std;
int main(){
    int a,b,c,i;
    cin>>i;
    for(int n=0;n<i;n++){
        cin>>a>>b>>c;
        if(a*a == b * b + c * c){
            cout<<"YES"<<endl;
        }else if(b*b == a * a + c * c){
            cout<<"YES"<<endl;
        }else if(c*c == b * b + a * a){
            cout<<"YES"<<endl;
        }else{cout<<"NO"<<endl;}
    }
    return 0;
}

Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    if (c - a - b < 0)
    {
        cout << "No" << endl;
    }
    else if (4 * a * b < (c - a - b) * (c - a - b))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

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

	cin >> N >> M;
	vector<long long int>by(N*2 + 1, 1);
	vector<long long int>rev(N*2 + 1, 1);
	for (int i = 2; i <= N*2; i++) {
		by[i] = by[i - 1] * i;
		by[i] %= MOD;
		rev[i] = power(by[i], MOD - 2, MOD);
	}
	if (M + 1 >= N) {
		cout << by[N * 2 - 1] * rev[N] % MOD*rev[N - 1] % MOD << endl;
		return 0;
	}
	long long int ans = 1;
	for (int i = 1; i <= M; i++) {
		long long int add = by[N] * rev[N - i] % MOD*rev[i] % MOD * by[N - 1] % MOD*rev[N - i - 1] % MOD*rev[i] % MOD;
		ans += add;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//priority_queue<int> pque;
//priority_queue<int, vector<int>, greater<int>> pque;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;

int main(void){
    int X,Y;
    cin >> X >> Y;
    cout << X + Y / 2 << endl;
}


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

inline void fastin(int &num) {
    int c;
    num = 0;
    c = getchar_unlocked();
    for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num<<3) + (num<<1) + c - 48;
}

inline void fastout(int n) {
    int N = n, rev, count = 0;
    rev = N;
    if (N == 0) { putchar_unlocked('0'); putchar_unlocked('\n'); return ;}
    while ((rev % 10) == 0) { ++count; rev /= 10;}
    rev = 0;
    while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;}
    while (rev != 0) { putchar_unlocked(rev % 10 + '0'); rev /= 10;}
    while (count--) putchar_unlocked('0');
}

int main(){    
    int n, c; fastin(n); fastin(c);
    int D[40][40];
    int C[510][510];

    for (int i = 0; i < c; ++i){
        for (int j = 0; j < c; ++j) fastin(D[i][j]);
    }

    for (int i = 0; i < n; ++i){
        for (int j = 0; j < n; ++j) fastin(C[i][j]);
    }

    int sum0[40] = {}, sum1[40] = {}, sum2[40] = {};

    for (int i = 1; i <= c; ++i){
        for (int j = 0; j < n; ++j){
            for (int k = 0; k < n; ++k){
                if ((j + k) % 3 == 0){
                    sum0[i] += D[C[j][k] - 1][i - 1];
                }
                else if ((j + k) % 3 == 1){
                    sum1[i] += D[C[j][k] - 1][i - 1];
                }
                else if ((j + k) % 3 == 2){
                    sum2[i] += D[C[j][k] - 1][i - 1];
                }
            }
        }
    }

    int ans = 1e9;

    for (int i = 1; i <= c; ++i){
        for (int j = 1; j <= c; ++j){
            for (int k = 1; k <= c; ++k){
                if (i != j && j != k && k != i){
                    ans = min(ans, sum0[i] + sum1[j] + sum2[k]);
                }
            }
        }
    }

    fastout(ans);
    
    return 0;
}


Measured memory_bytes: 1280
import sys
def main():
    input = sys.stdin.readline()
    N, A, B = map(int,input.split())
    #print('N:%d A:%d B: %d' % (N,A,B)) 

    answer = []
    for i in range(N+1):
        s = sum( map(int,list(str(i)) )) # list of int -> sum
        if s >= A and s <= B: answer.append(i)
        #print('i:%d s:%d' % (i,s))
    print(sum(answer))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3296
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll K;
    cin >> K;
    ll now = 0;
    loop(i, 10000000)
    {
        now *= 10;
        now += 7;
        now %= K;
        if (now % K == 0)
        {
            putout(i + 1);
            return 0;
        }
        if (i >= 2 * K)
        {
            putout(-1);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3540
// AOJ 2413: Tree Planting
// 2017.12.8 bal4u@uu

#include <stdio.h>

char m[1001][2005];
char sr[1001], sc[1001];

int main()
{
	int h, w, r, c;
	char buf[12], *p;

	fgets(buf, 12, stdin);
	sscanf(buf, "%d%d", &h, &w);
	for (r = 0; r < h; r++) {
		fgets(p=m[r], 2005, stdin);
		for (c = 0; c < w; c++, p+=2) {
			if (*p == '0') sr[c] = 1-sr[c], sc[r] = 1-sc[r];
		}
	}
	for (r = 0; r < h; r++) {
		p = m[r];
		if (*p & 1) putchar('0'+(sc[r]^sr[0]));
		else        putchar('1'-(sc[r]^sr[0]));
		for (c = 1; c < w; c++) {
			putchar(' ');
			p += 2;
			if (*p & 1) putchar('0'+(sc[r]^sr[c]));
			else 		putchar('1'-(sc[r]^sr[c]));
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;
signed main(){
  int a,b;
  cin>>a>>b;
  if(a<=8&&b<=8){cout<<"Yay!"<<endl;}
  else{cout<<":("<<endl;}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define inf 1e18 
 
using namespace std;
 
signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif
    
    IOS;
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3664
# -*- coding: utf-8 -*-

import sys
import os

N = int(input())

for i in range(N):
    n = int(input())
    s = str(n)
    A = list(s)

    B = sorted(A)
    C = sorted(B, reverse=True)

    b = int(''.join(B))
    c = int(''.join(C))
    print(c - b)

Measured memory_bytes: 7644
#include <bits/stdc++.h>
using namespace std;
//#define MOD 1000000007
#define MOD 998244353
#define INF 100000000000000009
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int A,B,C;
    cin >> A >> B >> C;
    if(A>B)swap(A,B);
    if(A<C && C<B){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

func main() {
	if readInt()+readInt()+readInt() >= 22 {
		fmt.Println("bust")
	} else {
		fmt.Println("win")
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
import java.util.*;

public class Main {

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

        int even4 = 0;
        int even2 = 0;
        int odd = 0;

        for (int i = 0 ; i < n; i++) {
            int num = sc.nextInt();

            if (num % 4 == 0) {
               even4++;
            } else if (num % 2 == 0) {
                even2++;
            } else {
                odd++;
            }
        }

        if (even2 != 0) {
            odd++;
        }

        String ans = (even4 >= odd - 1) ? "Yes" : "No";

        System.out.println(ans);

    }

}


Measured memory_bytes: 47568
/*************************************************************************
 > File Name: A.cpp
 > Author: codecode
 > Mail: 2466734364@qq.com
 > Created Time: 2020.1.26.20:00
 ************************************************************************/
#include<bits/stdc++.h>
using namespace std;
long long h,a,ans;
int main(){
	cin>>h>>a;
	if(h%a==0)ans=h/a;
	else ans=h/a+1;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
/*単一始点最短経路*/
#include <stdio.h>
#include <stdlib.h>
#define N 3000
#define INFTY 999999999
#define NIL -1000000
#define BLACK 1
#define WHITE 2
 
typedef struct{
  int u;
  int k;
  int v[N];
  int c[N];
}Node;
 
 
void dijkstra(int n, Node w[n], int d[n], int color[n], int pi[n]){
  int i,j,u;
  int min;
  for(i = 0; i < n; i++){
    d[i] = INFTY;
    pi[i] = NIL;
    color[i] = WHITE;
  }
  d[0] = 0;
 
  while(1){
    min = INFTY;
    for(i = 0; i < n; i++){
      if(color[i] != BLACK && d[i] < min){
        min = d[i];
        u = i;
      }
    }
    if(min == INFTY)
      break;
 
    color[u] = BLACK;
 
    for(j = 0; j < 1000; j++){
      if(color[j] != BLACK && d[u] + w[u].c[j] < d[j] && w[u].c[j] != INFTY){
        pi[j] = u;
        d[j] =  d[u] + w[u].c[j];
      }
    }
  }
}
 
int main(){
  int k,n, u, tmp;
 
  scanf("%d", &n);

  Node w[n];
 
  for(int i = 0; i < n; i++)
    for(int j = 0; j < 3000; j++)
      w[i].c[j] = w[i].v[j] = INFTY;
 
  int d[n];
  int color[n];
  int pi[n];
 
  for(int i = 0; i < n; i++){
    scanf("%d%d", &w[i].u, &w[i].k);
    for(int j = 0; j < w[i].k; j++){
      scanf("%d", &tmp);
      w[i].v[tmp] = tmp;
      scanf("%d", &w[i].c[tmp]);
    }
  }
 
  dijkstra(n, w, d, color, pi);
 
  for(int i = 0; i < n; i++){
    printf("%d %d\n", w[i].u, d[i]);
  }
  return 0;
}



Measured memory_bytes: 4136
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

string s;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> s;
}

int solve(){
    ll N = s.length()+1;
    vector<ll> a(N,0LL);
    for (int i = 0; i < N-1; i++) if(s[i]=='<') a[i+1]=a[i]+1LL;
    for (int i = N-2; i >= 0; i--) if(s[i]=='>') a[i]=max(a[i],a[i+1]+1LL);
    ll ans = accumulate(a.begin(),a.end(),0LL);
    DBG(N)
    DBG(a)

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

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 4764
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define pb push_back
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO  freopen("C:\\Users\\sourav\\Documents\\cp files\\input.txt", "r", stdin); freopen("C:\\Users\\sourav\\Documents\\cp files\\output.txt", "w", stdout); 
#define maxn 1000000
 
using namespace __gnu_pbds;
using namespace std;
 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;


signed main()
{
	
 	FLASH
 	int n;
 	cin>>n;
 	int arr[n][3];
 	int dp[n][3];
 	for (int i = 0; i < n; ++i)
 	{
 		/* code */
 		cin>>arr[i][0]>>arr[i][1]>>arr[i][2];

 	}
 	memset(dp , 0 , sizeof(dp));
 	dp[0][0] = arr[0][0];
 	dp[0][1] = arr[0][1];
 	dp[0][2] = arr[0][2];

 	for(int i = 1; i <n; i++)
 	{
 		for(int j = 0; j < 3; j++)
 		{
 			for(int k = 0; k < 3; k++)
 			{
 				if(k!= j)
 				{
 					dp[i][j] = max(dp[i][j] , dp[i - 1][k] + arr[i][j]);
 				}
 			}
 			//dp[i][j]
 		}
 	}
 	cout<<max(max(dp[n - 1][0] , dp[n - 1][1]) , dp[n - 1][2]);
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

template <class Abel> struct BIT {
  vector<Abel> dat[2];
  Abel UNITY_SUM = 0;                     // to be set

  /* [1, n] */
  BIT(int n) { init(n); }
  void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }

  /* a, b are 1-indexed, [a, b) */
  inline void sub_add(int p, int a, Abel x) {
    for (int i = a; i < (int)dat[p].size(); i += i & -i)
      dat[p][i] = dat[p][i] + x;
  }
  inline void add(int a, int b, Abel x) {
    sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
  }

  /* a is 1-indexed, [a, b) */
  inline Abel sub_sum(int p, int a) {
    Abel res = UNITY_SUM;
    for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
    return res;
  }
  inline Abel sum(int a, int b) {
    return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
  }

  /* debug */
  void print() {
    for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
    cout << endl;
  }
};


int main(){
  ll N, D, A; cin >> N >> D >> A;
  vector<P> enemy(N);
  rep(i, N) cin >> enemy[i].first >> enemy[i].second;
  sort(enemy.begin(), enemy.end());
  vector<ll> x(N), h(N);
  rep(i, N) {x[i] = enemy[i].first; h[i] = enemy[i].second;}

  BIT<ll> bit(N + 10);
  rep(i, N){
    bit.add(i + 1, i + 2, h[i]); //1-indexed
  }
  ll ans = 0;
  for (int i = 0; i < N; ++i){
    ll cur = bit.sum(i + 1, i + 2);
    if (cur <= 0) continue;
    ll need = (cur + A - 1) / A;

    ll right = x[i] + D * 2;
    int id = upper_bound(x.begin(), x.end(), right) - x.begin();

    bit.add(i + 1, id + 1, -need * A);
    ans += need;
  }
  cout << ans << endl;
}


Measured memory_bytes: 9600
#include<stdio.h>
int main(void){
	int idx[100100]={0};
	long sum=0;
	int a,n,q,b,c;
	int i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		idx[a]++;
		sum+=a;
	}
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d%d",&b,&c);
		sum+=(c-b)*idx[b];
		idx[c]+=idx[b];
		idx[b]=0;
		printf("%ld\n",sum);
	}
	return 0;
}


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

using namespace std;

int main(){
    int N,L,sum=0,max=200,n;
    cin >> N >> L;
      for(int i=0;i<N;i++){
        if(abs(i+L)<max){
            n=i;
            max = abs(i+L);
        }
        }
    for(int i=0;i<N;i++){
        if(i==n){
        }else{
        sum += (L+i);
    }
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
class DisjointSet
{
public:
    vector<int> rank,p; //rank?????????, p?????¶??????

    DisjointSet() {}
    DisjointSet(int size) {
        //init
        rank.resize(size, 0);
        p.resize(size, 0);
        for (int i = 0; i < size; i++) {
            p[i] = i;
            rank[i] = 0;
        }
    }
    bool same(int x,int y) { return findSet(x)==findSet(y);}
    void unite(int x,int y) { link(findSet(x),findSet(y)); }
    void link(int x,int y)
    {
        rank[x]>rank[y]?p[y]=x:p[x]=y;
        if(rank[x]==rank[y]) rank[y]++;
    }

    int findSet(int x)
    {
        int r=x;
        while(p[r]!=r)
            r=p[r];

        return r;
    }
};
int main()
{
    int n,q;
    cin>>n>>q;
    DisjointSet ds(n);
    for(int i=0;i<q;i++)
    {
        int order,x,y;
        cin>>order>>x>>y;
        switch(order)
        {
            case 0: ds.unite(x,y);break;
            case 1: cout<<(ds.same(x,y)?1:0)<<endl;break;
        }
    }
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N;	
  string S;
  cin>>N;
  for(int i=0;i<N;i++)
  {
	 cin>>S;
	 if(S=="Y"){cout<<"Four"<<endl;break;}
	 if(i==N-1)cout<<"Three"<<endl;
  }
 
}

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

int main() {
  int64_t x;
  cin>>x;

  int64_t now = 100;
  int ans = 0;

  while(now<x) {
    now = int64_t(now*1.01);
    ans++;
  }

  cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main()
{
    int a,b,k,f=0;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            f=1;
            break;
        }
    }
    if(f)
        cout<<"OK"<<endl;
    else
        cout<<"NG"<<endl;
}


Measured memory_bytes: 3128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    int n = Integer.parseInt(r.readLine());
    String[] sl = r.readLine().split("[\\s]+");
    int[] x = new int[n];
    int[] st = new int[n];
    for(int i = 0; i < n; i++)
    {
      x[i] = Integer.parseInt(sl[i]);
      st[i] = x[i];
    }
    
    Arrays.sort(st);

    int a = st[(n - 1) / 2];
    int b = st[n / 2];
    
    for(int i = 0; i < n; i++)
    {
      System.out.println(x[i] <= a ? b : a);
    }

  }

}


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

int main(){
	string s;
	long long k;
	cin >> s >> k;
	
	bool a = true;
	for(int i = 0 ; i+1 < s.size() ; i ++){
		if(s[i] != s[i+1])a = false;
	}
	if(a){
		cout << (s.size()*k)/2 << endl;
		return 0;
	}
	
	vector<int> vec;
	char pre = '.';
	int cnt = 0;
	for(int i = 0 ; i < s.size() ; i++){
		if(s[i] == pre)cnt ++;
		else{
			pre = s[i];
			if(cnt > 0){
				vec.push_back(cnt);
			}
			cnt = 1;
		}
		//cout << i << " " << cnt << endl;
	}
	/*for(int i = 0 ; i < vec.size() ; i ++){
		cout << vec[i] << " ";
	}cout << endl;*/
	vec.push_back(cnt);
	
	/*for(int i = 0 ; i < vec.size() ; i ++){
		cout << vec[i] << " ";
	}cout << endl;*/
	
	long long ret = 0;
	if(s[0] == s[s.size()-1]){
		ret += vec[0]/2;
		ret += vec[vec.size()-1]/2;
		ret += (k-1)*((vec[0]+vec[vec.size()-1])/2);
		for(int i = 1 ; i+1 < vec.size() ; i ++){
			ret += k*(vec[i]/2);
		}
	}
	else {
		for(int i = 0 ; i < vec.size() ; i ++){
			ret += k*(vec[i]/2);
		}
	}
	cout << ret << endl;
}

Measured memory_bytes: 256
#include<cstdio>

#include<algorithm>
using namespace std;

int main(){
    int n;
    int arr[105];
    while(scanf("%d",&n)!=EOF){
        for(int i=0;i<n;i++)
            scanf("%d",&arr[i]);
        int ans = 1e9;
        for(int i=-100;i<101;i++){
            int cnt = 0;
            for(int j=0;j<n;j++){
                cnt += (i-arr[j])*(i-arr[j]);
            }
            ans = min(ans,cnt);
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 128
@this_month = {}
@last_month = {}

target = @this_month

gets(nil).split("\n").each do |line|
  if line.chomp == ''
    target = @last_month
    next
  end
  company, count = line.split(',').map(&:to_i)
  target[company] = 0 unless target[company]
  target[company] += 1
end

ans = {}
@this_month.each do |company, count|
  if @last_month[company]
    ans[company] = @this_month[company] + @last_month[company]
  end
end

ans.sort.each do |company, count|
  puts "#{company} #{count}"
end

Measured memory_bytes: 6092
init = input().split(" ")
n = int(init[0])
m = int(init[1])

class problem():
  right_or_wrong = 0
  mistake = 0
  
  def set_right(self):
    self.right_or_wrong = 1
  
  def set_wrong(self):
    self.mistake += 1
  
  def check(self, result):
    if result == "AC":
      self.set_right()
    elif result == "WA" and self.right_or_wrong == 0:
      self.set_wrong()

if m == 0:
  print("0 0")
  exit()

result = {}
for i in range(m):
  score = input().split(" ")
  p = int(score[0])
  s = score[1]
  if p not in result:
    result[p] = problem()
  result[p].check(s)

ans = [0, 0]
for v in result.values():
  if v.right_or_wrong == 1:
    ans[0] += 1
    ans[1] += v.mistake

print(" ".join([str(i) for i in ans]))

Measured memory_bytes: 29424
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)


template<typename T>
struct MP {
  int n;
  T t;
  std::vector<int> a;
  MP() {}
  MP(const T& t): t(t) {
    n = t.size();
    a = std::vector<int>(n+1);
    a[0] = -1;
    int j = -1;
    for (int i = 0; i < n; ++i) {
      while (j != -1 && t[j] != t[i]) j = a[j];
      j++;
      a[i+1] = j;
    }
  }
  int operator[](int i) { return a[i];}
  std::vector<int> findAll(const T& s) {
    vector<int> res;
    int j = 0;
    for (int i = 0; i < s.size(); ++i) {
      while (j != -1 && t[j] != s[i]) j = a[j];
      j++;
      if (j == n) {
        res.push_back(i-j+1);
        j = a[j];
      }
    }
    return res;
  }
};

template<class T> using V = vector<T>;
template<class T> using V2 = V<V<T>>;

void solve(){
  int n; string s; cin >> n >> s;
  int nl = 0, nr = n/2 + 1, nm; string sa, sb;
  while(nr-nl>1){
    nm = (nl+nr)/2;
    if(sa.size()){
      sb = sa;
      sa = "";
    }
    FOR(i,0,n-nm){
      MP<string> mp( s.substr(i,nm) );
      vector<int> tbl = mp.findAll( s.substr(i+nm,n-nm-i) );
      if(!tbl.empty()){
        sa = s.substr(i,nm);
        break;
      }
    }
    if(sa.size()) nl = nm;
    else nr = nm;
  }
  //if(sa.empty()) sa = sb;
  cout << nl << '\n';
}

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

Measured memory_bytes: 384
n, a, b = map(int, input().split())

turn = n //(a+b)
rest = n%(a+b)

if turn == 0:
  if n >= a:
    print(a)
  else:
    print(n)
else:
  if rest >= a:
    print((turn + 1) * a)
  else:
    print(turn * a + rest)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using PP = pair<int, P>;
const int INF = 2e9;
struct edge { P to; int cost; };
signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  map<P, vector<edge> > G;
  map<P, int> d;
  for (int i = 0; i < m; i++) {
    int p, q, c; cin >> p >> q >> c;
    p--; q--;
    G[P(p, 0)].push_back(edge{P(p, c), 1});
    G[P(p, c)].push_back(edge{P(p, 0), 0});
    G[P(q, 0)].push_back(edge{P(q, c), 1});
    G[P(q, c)].push_back(edge{P(q, 0), 0});
    G[P(p, c)].push_back(edge{P(q, c), 0});
    G[P(q, c)].push_back(edge{P(p, c), 0});
    d[P(p, c)] = d[P(q, c)] = INF;
  }
  for (int i = 0; i < n; i++) d[P(i, 0)] = INF;
  priority_queue< PP, vector<PP>, greater<PP> > pq;
  d[P(0, 0)] = 0;
  pq.push(PP(0, P(0, 0)));
  while (not pq.empty()) {
    PP pp = pq.top(); pq.pop();
    P p = pp.second;
    if (d[p] < pp.first) continue;
    for (auto&& i : G[p]) {
      if (d[p] + i.cost >= d[i.to]) continue;
      d[i.to] = d[p] + i.cost;
      pq.push(PP(d[i.to], i.to));
    }
  }
  cout << (d[P(n - 1, 0)] == INF ? -1 : d[P(n - 1, 0)]) << '\n';
  return 0;
}

Measured memory_bytes: 92468
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int N=1e5+5;
int n,m,lcm=1,a[N];


signed main(){
	read(n);read(m);
	m*=2;
	for(int i=1,x;i<=n;i++){
		lcm=lcm/__gcd(lcm,read(a[i]))*a[i];
		if(lcm>m){
			write(0);
			return 0;
		}
	}
	for(int i=1;i<=n;i++) if(lcm/a[i]%2==0){
		write(0);
		return 0;
	}
	write((m/lcm+1)/2);
}

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

using namespace std;
int main()
{
int d,n;
cin>>d>>n;
if(d==0){
        if(n!=100)cout<<n;
else cout<<n+1;
}
if(d==1){
        if(n!=100)cout<<100*n;
else cout<<100*(n+1);
}
if(d==2){
        if(n!=100)cout<<10000*n;
else cout<<10000*(n+1);
}
}


Measured memory_bytes: 256