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

int main(){
    string sa,sb,sc;
    cin >> sa >> sb >> sc;
    char s = sa[0];
    size_t a = 1;
    size_t b = 0;
    size_t c = 0;
    int cc=0b111;
    while(cc==0b111){
        if(s=='a'){
            if(a<sa.size()){
                s=sa[a++];
            }else{
                a=string::npos;
                cc&=0b110;
            }
        }else if(s=='b'){
            if(b<sb.size()){
                s=sb[b++];
            }else{
                b=string::npos;
                cc&=0b101;
            }
        }else if(s=='c'){
            if(c<sc.size()){
                s=sc[c++];
            }else{
                c=string::npos;
                cc&=0b011;
            }
        } 
    }
    
    if(cc==0b110){
        cout <<'A';
    }else if(cc==0b101){
        cout <<'B';
    }else{
        cout <<'C';
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
//#include <bits/stdc++.h>
#include<cstring>
#include<iostream>
using namespace std;
int main() {
	int N;
	string S;
	cin >> N >> S;
	int mx = 0;

	//cout << S.size() << endl;
	string a, b;

	for (int i = 1; i<N; i++) {
		int cnt = 0;
		//cout << S.substr(0, i) << "-" << i << " and " << S.substr(i, N - i) << " " << N - i << endl;
		 for(int j=0;j<26;j++){
		     char x = 'a' + j;
		     //cout << x << endl;
		      if( S.substr(0,i).find(x) != string::npos && S.substr(i, N-i).find(x) != string::npos ){
		          //cout << "find " << x << " " << S.substr(0,i) << " " << S.substr(i, N-i) << endl;
		          cnt++;
		      }
		 }
		mx = max(mx, cnt);
	}
	cout << mx << endl;
	//cin >> N;
	return 0;
}

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

using namespace std;
const int kMaxN = 1e5 + 10;
typedef long long int64;

void solve() {
	int n;
	cin >> n;

	vector<int> a(n+1);

	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}

	int64 ans = (1LL<<60);

	for (int par = 0; par < 2; ++par) {
		int64 tans = 0, sum = 0;
		for (int i = 1; i <= n; ++i) {
			sum += a[i];
			if ((par == 0 && i % 2 == 1) || (par == 1 && i % 2 == 0)) {
				if (sum <= 0) {
					tans += -sum + 1;
					sum = 1;
				}
			} else {
				if (sum >= 0) {
					tans += sum + 1;
					sum = -1;
				}
			}
		}
		ans = min(ans, tans);
	}

	cout << ans << "\n";
}

void reset() {
}

int main() {
	int tests = 1;

	for (;tests; --tests) {
		solve();
	}
}

Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <vector>
#include <climits>
#include <algorithm>
#include <random>
#include <cstring>
#include <cstdio>
#include <map>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i, a, n) for(register int i = a; i <= n; ++ i)
#define per(i, a, n) for(register int i = n; i >= a; -- i)
#define ONLINE_JUDGE
using namespace std;
typedef long long ll;
const int mod=1e9+7;
template<typename T>void write(T x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}
 
template<typename T> void read(T &x)
{
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};
ll ksm(ll a,ll n){//看是否要mod 
	ll ans=1;
	while(n){
		if(n&1) ans=(ans*a)%mod;
		a=a*a%mod;
		n>>=1;
	}
	return ans%mod;
}
const int maxn=1e6+10;
ll t[maxn],a[maxn];
ll n;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	//===========================================================
	read(n);
	rep(i,1,n) read(t[i]),read(a[i]);
	ll post=t[1],posa=a[1];
	rep(i,2,n){
		if(t[i]>=post&&a[i]>=posa){
			post=t[i],posa=a[i];
		}
		else if(t[i]>=post){
			ll bei=posa%a[i]==0?posa/a[i]:posa/a[i]+1;
			posa=a[i]*bei,post=t[i]*bei;
		}
		else if(a[i]>=posa){
			ll bei=post%t[i]==0?post/t[i]:post/t[i]+1;
			post=bei*t[i],posa=bei*a[i];
		}
		else{
			ll bei1=post%t[i]==0?post/t[i]:post/t[i]+1;
			ll bei2=posa%a[i]==0?posa/a[i]:posa/a[i]+1;
			ll bei=max(bei1,bei2);
			posa=a[i]*bei,post=t[i]*bei;
		}
	}
	write(posa+post);
	//===========================================================
	return 0;
}

Measured memory_bytes: 2432
program sample
    implicit none
    character(100)::s,t
    integer(8) :: i,j,m,n,x(26),a
    integer(8),allocatable :: y(:)
  
    read(*,*) s
    x(:)=0
  
    n=len_trim(s)
    do i=1,n
        t=s(i:i)
        call alfnumber(t,a)
        x(a)=x(a)+1

    end do

    do i=1,26

        if (mod(x(i),2)/=0)then
            write(*,*)'No'
            stop
        endif
    end do
    write(*,*)'Yes'
    stop
    contains
    subroutine alfnumber(st,a)
        implicit none
        character,intent(in) :: st
        integer(8),intent(out) ::  a
        integer::i
        character(1)::ch(26)
        ch=(/'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'/)
        do i=1,26
            if(st .eq. ch(i))then
                a=i
                return
            end if
        end do 
        end subroutine alfnumber
end program sample
  



Measured memory_bytes: 2824
#include <stdio.h>
#include <stdlib.h>
#define swap(Type, X, Y) {Type tmp = X, X = Y, Y = X;}

typedef long long ll;

ll n;
ll a[100005];
ll attack;

ll gcd(int n, int m)
{
    if (n > m) {
        swap(int, n, m);
    }

    while (n) {
        ll r = m % n;
        m = n;
        n = r;
    }

    return m;
}

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

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

    attack = gcd(a[0], a[1]);
 

    for (int i = 2; i < n; i++) {
        attack = gcd(attack, a[i]);
    }

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

    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const double pi=3.1415926536;
#define fo(i,n) for( ll int i=0;i<n;++i)
#define fos(j,i,n) for(ll int j=i;j<n;++j)
#define N 100004
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define abs(x) ((x)<0?(-(x)):(x))
#define dis(k) cout << k << endl
#define forr(i,n) for( ll int i= n-1;i>=0;--i)
#define dbg(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define ve vector
#define fi first
#define se second
#define setzero(a) memset(a,0,sizeof(a))
#define setinf(a) memset(a,0x7F,sizeof(a))
typedef ve< ll > vi;
typedef ve< vi > vvi;
typedef pair< ll ,ll > ii;


//weird debugging stuff
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
		sim > struct rge { c b, e; };
		sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
		sim > auto dud(c* x) -> decltype(cerr << *x, 0);
		sim > char dud(...);
		struct debug {
#ifdef LOCAL
			~debug() { cerr << endl; }
			eni(!=) cerr << boolalpha << i; ris; }
		eni(==) ris << range(begin(i), end(i)); }
		sim, class b dor(pair < b, c > d) {
			ris << "(" << d.first << ", " << d.second << ")";
		}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


/*Don't just sit and hope that God will solve this
  fucking do something, try to observe or solve it a different way.
  Use that pen and paper.
  If nothing works take a deep breath and start again.*/


void solve(){
	string s,t;
	cin >> s >> t;
	ll n=s.length(),m=t.length();
	vvi dp(n+1,vi (m+1,0));
	vvi wh(n+1,vi (m+1,-1));
	fos(i,1,n+1){
		fos(j,1,m+1){
			if(s[i-1]==t[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
				wh[i][j]=2;
			}
			else if(dp[i][j-1]>dp[i-1][j]){
				dp[i][j]=dp[i][j-1];
				wh[i][j]=1;
			}
			else {
				dp[i][j]=dp[i-1][j];
				wh[i][j]=0;
			}
		}
	}
	string ans="";
	ll x=n,y=m;
	while(wh[x][m]!=-1){
		if(wh[x][y]==2){
			ans+=s[x-1];
			x--;
			y--;
		}
		else if(wh[x][y]==1) y--;
		else x--;
	}
	reverse(all(ans));
	dis(ans);


	
}

int main(){
	fast;
	int t=1;
	int tt=1;
	//cin >> t;

	while(t--){
		//cout << "Case #" << tt << ": " ;
		tt++;
		solve();
	}
	return 0;
}



Measured memory_bytes: 144076
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,b = LI()
    if b%a == 0:
        print(a+b)
    else:
        print(b-a)
    return

#B
def B():
    n,m = LI()
    d = defaultdict(int)
    for i in range(n):
        l = LI()
        for j in range(1,len(l)):
            d[l[j]] += 1
    ans = 0
    for i in d.values():
        if i == n:
            ans += 1
    print(ans)
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

#define REP(i,e,s) for(register int i=e; i<=s; i++)
#define DREP(i,e,s) for(register int i=e; i>=s; i--)
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)

int read() {
	int x=0,f=1,ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int num_length(int a) {
	int ans=0;
	while(a) {
		ans++;
		a/=10;
	}
	return ans;
}

int main() {
	int n=read(),ans=0;
	REP(i,1,n) {
		if(num_length(i)%2==1) ans++; 
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
    ll N; cin >> N;
    ll h, n, w;
    ll N_ch = 1;
    ll N_mo = N;
    for(ll i = 1; i <= 3500; i++){ // h
        for(ll j = 1; j <= 3500; j++){ // n
            ll cn = 4*i*j - N*j - N*i;
            ll mo = N*i*j;
            if(cn <= 0) continue;
            if(mo % cn != 0) continue;
            else{
                ll k = mo / cn;
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int N;
    int T[100];
    int M;
    
    scanf("%d",&N);
    for(int i = 0;i<N;i++){
        scanf("%d",&T[i]);
    }
    scanf("%d",&M);
    for(int i = 0;i<M;i++){
        int index,t,sum = 0;
        scanf("%d%d",&index,&t);
        for(int j = 0;j<N;j++){
            if(j == index-1){
                sum += t;
            }
            else{
                sum += T[j];
            }
        }
        printf("%d\n",sum);
    }
}


Measured memory_bytes: 128
# import itertools
# import math
import sys
sys.setrecursionlimit(500*500)
# import numpy as np

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# H, W, K = map(int, input().split())
# A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# S = input()

# d = sorted(d, reverse=True, key=lambda x:x[0])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

edges = [list(map(int,input().split())) for _ in range(N-1)]
tree = [[] for _ in range(N + 1)]

for edge in edges:
    tree[edge[0]].append([edge[1], edge[2]])
    tree[edge[1]].append([edge[0], edge[2]])

# print(tree)

depth = [-1] * (N + 1)
depth[1] = 0

def dfs(tree, s):
    for l in tree[s]:
        if depth[l[0]] == -1:
            depth[l[0]] = depth[s] + l[1]
            dfs(tree, l[0])

dfs(tree, 1)

# print(depth)

for l in depth[1:]:
    if l % 2 == 0:
        print(1)
    else:
        print(0)


Measured memory_bytes: 98568
#include <iostream>

using namespace std;

int main()
{
	int n, d=0;
	cin >> n;
	int x=n;
	while(n>0)
	{
		d+=n%10;
		n/=10;
	}
	if(x%d==0)
	cout << "Yes" << endl;
	else
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	
	int A, B, add, min, mul;
	
	cin >> A >> B;	
	add = A + B;
	min = A - B;
	mul = A * B;
	
	if (min >= mul && min >= add) {
		
		cout << min;
	}
	else if (mul >= min && mul >= add) {
		
		cout << mul;
	}
	else if (add >= min && add >= mul) {
		
		cout << add;
	}
}

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

int main()
{
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		S[i] = 'x';
	}
	cout << S << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n, m, l;
	cin >> n >> m >> l;

	int** a = new int*[n];
	for (int i = 0; i < n; i++)
	{
		a[i] = new int[m];
	}

	int** b = new int*[m];
	for (int i = 0; i < m; i++)
	{
		b[i] = new int[l];
	}


	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> a[i][j];
		}
	}

	for (int i = 0; i < m; i++)
	{
		for (int j = 0; j < l; j++)
		{
			cin >> b[i][j];
		}
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < l; j++)
		{
			long sum = 0;
			for (int k = 0; k < m; k++)
			{
				sum += a[i][k] * b[k][j];
			}
			cout << (j == 0 ? "" : " ") << sum;
		}
		cout << endl;
	}
}


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

int main(){
  int a,b;
  cin >> a >> b ;
  
  if (a == b){
    cout << "Draw" << endl;
    return 0;
  }
  if (a == 1) a = 14;
  if (b == 1) b = 14;
  if ( a < b) cout << "Bob" << endl;
  else cout << "Alice" << endl;
  
  
  return 0;

}


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

int main() {
  string str ;
  cin >> str ;
  int x,y,z;
    x=y=z=0;

  int i;
  for(i=0;i<3;i++){
  char d = str.at(i); // char型の値が得られる
    
    if (d == 'a'){
      x++;
    }
    else if (d =='b'){
      y++;
    }
    else if (d == 'c'){
      z++;
    }

  }
  if ( x==1 && y == 1 && z==1){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}



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

template <typename Monoid, typename OperatorMonoid = Monoid>
struct LazySegmentTree
{
  using F = function<Monoid(Monoid, Monoid)>;
  using G = function<Monoid(Monoid, OperatorMonoid)>;
  using H = function<OperatorMonoid(OperatorMonoid, OperatorMonoid)>;
  using P = function<OperatorMonoid(OperatorMonoid, int)>;

  int sz;
  vector<Monoid> data;
  vector<OperatorMonoid> lazy;
  const F f = [](int a, int b) { return a + b; };
  const G g = [](int a, int b) { return a + b; };
  const H h = [](int a, int b) { return a + b; };
  const P p = [](int a, int b) { return a * b; };
  const Monoid M1 = 0LL;
  const OperatorMonoid OM0 = 0LL;

  void init(int n)
  {
    sz = 1;
    while (sz < n)
      sz <<= 1;
    data.assign(2 * sz, M1);
    lazy.assign(2 * sz, OM0);
  }

  void set(int k, const Monoid &x)
  {
    data[k + sz] = x;
  }

  void build()
  {
    for (int k = sz - 1; k > 0; k--)
    {
      data[k] = f(data[2 * k + 0], data[2 * k + 1]);
    }
  }

  void propagate(int k, int len)
  {
    if (lazy[k] != OM0)
    {
      if (k < sz)
      {
        lazy[2 * k + 0] = h(lazy[2 * k + 0], lazy[k]);
        lazy[2 * k + 1] = h(lazy[2 * k + 1], lazy[k]);
      }
      data[k] = g(data[k], p(lazy[k], len));
      lazy[k] = OM0;
    }
  }

  Monoid update(int a, int b, const OperatorMonoid &x, int k, int l, int r)
  {
    propagate(k, r - l);
    if (r <= a || b <= l)
    {
      return data[k];
    }
    else if (a <= l && r <= b)
    {
      lazy[k] = h(lazy[k], x);
      propagate(k, r - l);
      return data[k];
    }
    else
    {
      return data[k] = f(update(a, b, x, 2 * k + 0, l, (l + r) >> 1),
                         update(a, b, x, 2 * k + 1, (l + r) >> 1, r));
    }
  }

  Monoid update(int a, int b, const OperatorMonoid &x)
  {
    return update(a, b, x, 1, 0, sz);
  }

  Monoid query(int a, int b, int k, int l, int r)
  {
    propagate(k, r - l);
    if (r <= a || b <= l)
    {
      return M1;
    }
    else if (a <= l && r <= b)
    {
      return data[k];
    }
    else
    {
      return f(query(a, b, 2 * k + 0, l, (l + r) >> 1),
               query(a, b, 2 * k + 1, (l + r) >> 1, r));
    }
  }

  Monoid query(int a, int b)
  {
    return query(a, b, 1, 0, sz);
  }

  Monoid operator[](const int &k)
  {
    return query(k, k + 1);
  }
};

int main()
{
  i64 N, Q;
  string S;
  cin >> N >> S >> Q;
  vector<LazySegmentTree<i64>> seg(26);
  for (i64 i = 0; i < 26; i++)
    seg[i].init(N);
  for (i64 i = 0; i < N; i++)
    seg[S[i] - 'a'].set(i, 1);
  for (i64 i = 0; i < 26; i++)
    seg[i].build();
  for (i64 _ = 0; _ < Q; _++)
  {
    i64 type;
    cin >> type;
    if (type == 1)
    {
      i64 i;
      char c;
      cin >> i >> c;
      i--;
      if (S[i] != c)
      {
        seg[S[i] - 'a'].update(i, i + 1, -1);
        seg[c - 'a'].update(i, i + 1, 1);
        S[i] = c;
      }
    }
    else
    {
      i64 l, r;
      cin >> l >> r;
      i64 ans = 0;
      for (i64 i = 0; i < 26; i++)
      {
        if (0 < seg[i].query(l - 1, r))
          ans++;
      }
      cout << ans << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 429060
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		int n,w; cin >> n >> w;
		if(n==0&&w==0)break;
		int a[100]={};
		int ma=0;
		for(int i=0;i<n;i++){
			int x; cin >> x;
			a[x/w]++;
			ma=max(ma,a[x/w]);
		}
		double ans=1e-2;
		int right=99;
		while(a[right]==0)right--;
		for(int i=0;i<=right;i++){
			ans+=(right-i)*1.0/right*a[i]/ma;
		}
		printf("%.12f\n", ans);
	}
}


Measured memory_bytes: 3112
f=lambda x,y:abs(x[0]-y[0])+abs(x[1]-y[1])
N,M=map(int,input().split())
l=[tuple(map(int,input().split())) for _ in range(N)]
m=[tuple(map(int,input().split())) for _ in range(M)]
for i in l:
  print(min([(f(i,j),k+1) for (k,j) in enumerate(m)])[1])

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int main(){

  int n,sum = 0;
  scanf("%d",&n);

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

  qsort(p,n,sizeof(int),sort);

  for(int i = 0; i < n-1; ++i){
    sum += p[i];
  }
  sum += p[n-1] / 2;

  printf("%d",sum);


  return 0;
}


Measured memory_bytes: 1732
#include<iostream>
using namespace std;
int main(){
    int n,m,a,b;
    cin >> n >> m;
    int A[101][101] = {};
    int B[101] = {};
    int C[101] = {};
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin >> a;
            A[i][j] = a;
        }
    }
    
    for(int i = 1; i <= m; i++){
        cin >> b;
        B[i] = b;
    }
    
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            C[i] += A[i][j] * B[j];
        }
        
        cout << C[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define int long long
const int maxn = 310;
using namespace std;
int G[maxn][maxn];
int n,m,i,j,k,ans;
bool acs = 1;
signed main() {
	scanf("%d",&n);
	for(int i = 1;i <= n;i++) {
		for(int j = 1;j <= n;j++) {
			scanf("%d",&G[i][j]);
		}
	}
	for(int i = 1;i <= n;i++) {
		for(int j = 1;j <= n;j++) {
			if(i == j) continue; bool flag = 1;
			for(int k = 1;k <= n;k++) {
				if(k != i && k != j) {
					if(G[i][j] >  G[i][k] + G[k][j]) acs = 0;
					if(G[i][j] == G[i][k] + G[k][j]) flag = 0;
				}
			}
			ans += flag * G[i][j];
		}
	}
	printf("%lld",acs ? ans >> 1: -1);
	return 0;
}

Measured memory_bytes: 1024
<?php
$n = intval(fgets(STDIN));
$eleven = floor($n/(5+6));
$n-=$eleven * 11;
$count = $eleven * 2;
if($n == 0){
}elseif($n <= 6){
    $count++;
}else{
    $count+=2;
}
printf("%d", $count);


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

int main(){
	int n;
	cin >> n;
	int ans=0;
	for(int i=1; i<n+1;i++){
		if((0<i && i<10) || (100<=i && i<1000) || (10000<=i && i<100000)){
			ans++;
		}

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

		


Measured memory_bytes: 256
import sys
import random
input = sys.stdin.readline


def solve(n, s):
    sub = [int(s[i])-1 for i in range(n)]
    
    table = [0]*(n+1)
    p = 2
    for i in range(len(bin(n))-1):
        for j in range(p, n+1, p):
            table[j] += 1
        p *= 2
    
    for i in range(n):
        table[i+1] += table[i]
    
    ans = 0
    for i in range(n):
        if sub[i]%2:
            judge = table[n-1]-table[n-1-i]-table[i]
            if not judge:
                ans += 1
    
    
    if ans%2:
        res = 1
    else:
        if 1 in sub:
            res = 0
        else:
            res = 0
            for i in range(n):
                if sub[i]:
                    judge = table[n-1]-table[n-1-i]-table[i]
                    if not judge:
                        res += 1
            return res%2*2
    
    return res
    
    
def main():
    n = int(input())
    s = input()
    
    ans = solve(n, s)
    print(ans)
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 58056
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};



struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
combination C(100000);
int main() {
    int S; cin >> S;
    if ( S <= 2 ) {
        cout << 0 << endl;
        return 0;
    }
    // group分け
    int g = (S+2) / 3;
    if (g == 1) {
        cout << 1 << endl;
        return 0;
    }
    //余り
    int r = S % 3;
    mint ans = 0;
    if (r > 0) {
        ans += C(g-1+r-1, r);
        g--;
    }else {
        ans = 1;
    }
    while (g > 0) {
        r += 3;
        ans += C(g-1+r-1, r);
        g--;
    }
    cout << ans.x << endl;

}


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}

int main() {
  int a[5],k;
  REP(i,5){
  	cin>>a[i];
  }
  cin>>k;
  bool isValid=true;
  REP(i,4){
    FOR(j,i+1,5){
      if(max(a[j],a[i])-min(a[i],a[j])>k){
        isValid=false;
      }
    }
  }
  cout << (isValid?"Yay!":":(") << endl;
}


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

using namespace std;

const int N = int(1e8) + 7;

void init(){

}

void solve(){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    printf("%d\n", min(a*b, c));
}

const bool mtc = false;

int main(){
    int t;
    if(mtc){
        scanf("%d", &t);
        while(t--) solve();
    }
    else solve();
}



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

int main()
{
    int n;
    int a[305],k;
    int ans = 0;
    scanf("%d",&n);
    for(int i = 0; i < 2*n; i++)
        scanf("%d",&a[i]);
    sort(a,a+2*n);
    for(int i = 0; i < 2*n; i+=2)
        ans += a[i];
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 504
# dp[h][x] 縦から h 列目を通過した (横棒を通った場合も含む) 直後に
#          左から x 本目の縦棒にいる場合の数

def main():
    H,W,K = map(int,input().split())

    if W == 1:
        print(1)
        return

    division = 1000000007
     
    amida = [[] for i in range(W+1)]
    amida[1] = ['0', '1']
    for x in range(2, W):
        for b in amida[x-1]:
            if b[-1] == '0':
                amida[x].append(b + '1')
            amida[x].append(b + '0')

    all_count = len(amida[W-1])
    bar = [0] * (W+1)
    for i in range(W-1):
        bar[i+1] = len(list(filter(lambda t:t[i] == '1', amida[W-1])))

    dp = [[0 for i in range(W+2)] for j in range(H+1)]
    dp[0][1] = 1
    for y in range(1,H+1):
        for x in range(1,W+1):
            dp[y][x] = dp[y-1][x-1] * bar[x-1] \
                     + dp[y-1][x+1] * bar[x] \
                     + dp[y-1][x] * (all_count - bar[x] - bar[x-1])

        #for x in range(1,W+1):
        #    print('%15d' % dp[y][x], end='')
        #print()
    print(dp[H][K] % division)

main()


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

using Lint=long long;

int main()
{
   Lint N,K; cin>>N>>K;
   Lint ok=0,ng=K+1;
   while(ng-ok>1){
      Lint X=(ok+ng)/2;
      Lint prev=X,sum=X,cnt=1;
      while(cnt<N and prev>1){
         Lint cur=prev/2;
         sum+=cur;
         prev=cur;
         cnt++;
      }
      (sum<=K? ok:ng)=X;
   }
   cout<<ok<<endl;
   return 0;
}



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

int main(){
  int i,sum=0;
  char number[1001];

  while(1){

  scanf("%s",number);
  if(number[0]=='0') break;

  for(i=0;i<strlen(number);i++){
    sum+=number[i]-'0';
  }

  printf("%d\n",sum);
  sum=0;
  }


  return 0;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,k,n)　for(int i=(k);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    return (x*y);
}

#define WA printf("WA\n");
int main()
{
    ll n,sum=0;
    cin >> n;
    vll a(n),rui(1,0);
    rep(i,n){
        cin >> a[i];
        sum += a[i];
        rui.push_back(sum);
    }

    sort(all(rui));
    //rep(i,SIZE(rui))cout << rui[i] << " ";
    //cout << endl;
    
    ll ans=0,count=1;
    rep(i,SIZE(rui)-1){
        if(rui[i] == rui[i+1])count++;
        else{
            ans += (count*(count-1))/2;
            count=1;
        }
    }
    ans += count*(count-1)/2;

    cout << ans << endl;

    return 0;
}


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

int t[114514];
int x[114514];
int y[114514];

int main() {
	t[0] = 0;
	x[0] = 0;
	y[0] = 0;
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> t[i] >> x[i] >> y[i];
	for (int i = 1; i <= n; i++) {
		if (abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]) > t[i] - t[i - 1]) {
			cout << "No" << endl;
			return 0;
		}
		else if (abs(abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]) - t[i] + t[i - 1])% 2 == 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    long long n,a[100000],m=0,ma=0;
    cin>>n;
    cin>>a[0];
    for(int i=1;i<n;i++)
    {
        cin>>a[i];
        if(a[i]>a[i-1])
        {
            ma=max(ma,m);
            m=0;
        }
        else{
            m++;
        }
    }
    ma=max(ma,m);
    printf("%d",ma);
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

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

		int res = (number+1) / 2;

		if(res >= num) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21972
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    int A, B, T; cin >> A >> B >> T;

    int sum = 0;
    for(int i=1; i<21; i++){
        if (i > T) break;
        if (i % A == 0) sum += B;
    }

    int ans = sum;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque
import sys


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


a = I()
b = I()
c = I()
d = I()
ans = a if a <= b else b
ans += c if c <= d else d
print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <map>

class RollingHash{
private:
    #define rep(i, n) for(int (i) = (0); (i) < (n); ++(i))
    using LLi = long long int;
    using V_LLi = std::vector<LLi>;
    // 32ビット以下の 素数
    const V_LLi mod = {static_cast<LLi>(1e9) + 7, static_cast<LLi>(1e9) - 117};
    std::vector<LLi> base = {9999991, 799976819}; // 原始元

    std::vector<std::vector<V_LLi>> power; // power[k][i][j] = (base[i])^k in mod[j]

    // ハッシュ値 | hash[range][i][j] : base[i], mod[j] 下での [0, range) の ハッシュ値
    std::vector<std::vector<V_LLi>> hash;



    const int n; // 入力文字列の大きさ
    std::string S; // 入力文字列
public:
    // コンストラクタ
    RollingHash(std::string &S_): n(S_.size()){
        S = S_; init();
    }
    // 初期化
    inline void init(){
        // 大きさの確保
        power.resize( n+1, std::vector<V_LLi>(2, V_LLi(2, 1)));
        hash.resize(n+1, std::vector<V_LLi>(2, V_LLi(2, 0)));

        // 初期条件
        // power[0][0] = 1; power[0][1] = 1;
        // hash[0] = {{0, 0}, {0, 0}};

        rep(itr, n) rep(i, 2) rep(j, 2){
                power[itr+1][i][j] = (power[itr][i][j] * base[i]) % mod[j];
                hash[itr+1][i][j]  = (hash[itr][i][j]  * base[i] + S[itr]) % mod[j];
        }
    }

    // ハッシュ値の取得 : [left, right) in 0-indexed
    inline LLi getHash(int left, int right, int b_id = 0, int m_id = 0){
        LLi res = hash[right][b_id][m_id] 
            - hash[left][b_id][m_id] * power[right-left][b_id][m_id] % mod[m_id];
        if(res < 0) res += mod[m_id];
        return res;
    }

    inline LLi getHash_Length(int start, int length, int b_id = 0, int m_id = 0){
        return getHash(start, start+length, b_id, m_id);
    }

    // sa..., と sb... の長さLの文字列が等しいかをHashを用いて判定
    inline bool sameOf(int a, int b, int L){
        rep(i, 2) rep(j, 2) if(getHash(a, a+L) != getHash(b, b + L)) return false;
        return true;
    }

    // LCP of { S[a:] and S[b:] } in 0-indexed
    inline int getLCP(int a, int b){
        if(a > b) std::swap(a, b);
        int ok = 0, ng = n - b + 1;
        while(ng - ok > 1){
            int lngth = (ok + ng) / 2;
            if(sameOf(a, b, lngth)) ok = lngth;
            else ng = lngth;
        }
        return ok;
    }

    inline bool findCP(int length){
        using pll = std::pair<LLi, LLi>;
        std::map<std::pair<pll, pll>, int> theHash;
        for(int x = 0; x + length <= n; x++){
            pll lp = {getHash_Length(x, length, 0, 0), getHash_Length(x, length, 0, 1)};
            pll rp = {getHash_Length(x, length, 1, 0), getHash_Length(x, length, 1, 1)};
            std::pair<pll, pll> P = {lp, rp};
            if(theHash.find(P) != theHash.end()) {
                if(x - theHash[P] >= length) return true;
            }
            else theHash[P] = x;
        }
        return false;
    }



    #undef rep
};





std::string s;

int main(void){
    int n; std::cin >> n >> s;
    RollingHash RollingStones(s);

    int ok = 0, ng = (n >> 1) + 1;
    while(ng - ok > 1){
        int mid = (ok + ng) >> 1;
        if(RollingStones.findCP(mid)) ok = mid;
        else ng = mid;
    }

    std::cout << ok << '\n';
    
    
    return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ios();
    int n;
    cin >> n;
    vector<int> v(n);
    REP(i, n){
        int a;
        cin >> a;
        v[a-1] = i+1;
    }
    
    ll ans = 0;
    set<int> st;
    st.insert(0);
    st.insert(n+1);

    REP(i, n){
        int p = v[i];
        auto itr = st.upper_bound(p);
        int r = *itr;
        itr--;
        int l = *itr;
        ans += (ll)(i+1) * (r-p)*(p-l);
        st.insert(p);
    }

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


Measured memory_bytes: 10368
from sys import stdin
import sys
import math

N = int(input())

def f(a, b):
    return len(str(max(a, b)))

minimum = float('inf')

for a in range(1, int(math.sqrt(N))+1):
    if N % a == 0:
        minimum = min(minimum, f(a, N // a))

print(minimum)


Measured memory_bytes: 3060
{-# LANGUAGE BangPatterns #-}

import           Data.Char

main :: IO ()
main = solve <$> getLine >>= print

solve :: String -> Int
solve xs = let (y:ys) = digitToInt <$> xs in go 0 y ys
    where
        go !a !y []     = a + y
        go !a !y (z:zs) = go (a + y) z zs + go a (y * 10 + z) zs


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long n, a, b; cin >> n >> a >> b;
    if (a > b) swap(a, b);
    if ((b - a) % 2 == 0) cout << (b-a) / 2 << endl;
    else {
        long long ans = 2e18;
        {
            // to 1
            long long c = a;
            long long d = b - a - 1;
            ans = min(ans, c + d / 2);
        }

        {
            // to n
            long long c = n - b + 1;
            long long d = b - a - 1;
            ans = min(ans, c + d / 2);
        }

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

Measured memory_bytes: 256
import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

N, A, B = map(int, input().split())

MOD = 10 ** 9 + 7

def myPow(x, n, MOD):
    if n == 0:
        return 1

    res = 1
    while(n > 0):
        if n & 1 == 1:
            res = res * x % MOD

        x = x * x % MOD
        n = n >> 1

    return res


ans = pow(2, N, MOD)
ans -= 1

def cumprod(arr, MOD):
    L = len(arr)
    Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]
        arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]
        arr[n] %= MOD
    return arr.ravel()[:L]


def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64)
    x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64)
    x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv


fact, fact_inv = make_fact(B + 10, MOD)

arr = cumprod(list(range(N, N-B, -1)), MOD)

a = arr[A - 1] * fact_inv[A]
a %= MOD
b = arr[B-1] * fact_inv[B]
b %= MOD

# print(mb)
# print(fact_inv)

'''
a = ma * fact_inv[A]
a %= MOD

b = mb * fact_inv[B]
b %= MOD
'''

ans -= (a + b)
ans %= MOD

print(ans)


Measured memory_bytes: 30864
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;

int main(int argc, char *argv[]) {
  int n;
  string yes = "YES";
  string no = "NO";

  cin >> n;
  vector<string> result;
  int tri[3];
  for (int i = 0; i < n; i++) {
    cin >> tri[0] >> tri[1] >> tri[2];
    sort(tri, tri+3);
    int hoge = pow(tri[0], 2) + pow(tri[1], 2);
    result.push_back(pow(tri[2], 2) == hoge ? yes : no);
  }
  for (int i = 0; i < n; i++)
    cout << result[i] << endl;
  return 0;
}

Measured memory_bytes: 1232
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = []
for _ in range(M):
    x, y, c = map(int, input().split())
    d.append((x-1, y-1, c))

ans = min(a) + min(b)

for x, y, c in d:
    ans = min(ans, a[x]+b[y]-c)
print(ans)

Measured memory_bytes: 29484
S = input()
if len(S) == 2:
  if S[0] == S[1]:
    print(1, 2)
  else:
    print(-1, -1)
  exit()

for i in range(2, len(S)):
  if S[i-2] == S[i-1] or S[i-1] == S[i] or S[i-2] == S[i]:
    print(i-1, i+1)
    break
else:
  print(-1, -1)

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

#define rep(i, n) for(int i=0; i < (n); ++i)
#define ll long long

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    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 { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    v<pair<int, int>> stu;
    rep(i,n) {
        int a; cin >> a;
        stu.push_back(make_pair(a, i));
    }
    sort(stu.begin(), stu.end());
    rep(i,n) {
        cout << stu[i].second + 1<< ' ';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1780
import sys
sys.setrecursionlimit(10**6)
N = int(input())
A, B = map(int,input().split())
P = [int(x) for x in input().split()]
ans = 0
a, b, c = 0, 0, 0
for p in P:
    if p <= A:
        a += 1
    elif A < p <= B:
        b += 1
    else:
        c += 1

print(min(a, b, c))

Measured memory_bytes: 3064
import java.util.Scanner;

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

        int[] a = new int[3];
        for (int i = 0; i < 3; i++) {
            a[i] = sc.nextInt();
        }
        long n = sc.nextLong();

        if(n % 2 == 0){
            System.out.println(a[0] - a[1]);
        } else {
            System.out.println(a[1] - a[0]);
        }

    }
}


Measured memory_bytes: 22996
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


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

	int a;
	cin>>a;
	int t=0;
	loop(i,2,10000000){
		int c=0;
		while(a%i==0){
			a/=i;
			c++;
		}
		loop(i,1,1000){
			if(c>=i)c-=i,t++;
			else break;
		}
	}
	if(a-1)t++;
	cout<<t<<endl;
}


Measured memory_bytes: 3644
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;
    // diverta2019 b
    static void solve(InputReader in, PrintWriter out){
        long r = in.ni(), g = in.ni(), b = in.ni(), n = in.ni();
        long ans = 0;
        for (long i = 0; i <= 3000; i++) {
            for (long j = 0; j <= 3000; j++) {
                long rem = n-i*r-j*g;
                if(rem >= 0 && rem%b==0) ans++;
            }
        }
        out.println(ans);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 21460