akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
            #include <chrono>
          
            using namespace std;
            using namespace std::chrono; 
         
            typedef long long int ll;
         
            #define MOD (ll)(1e9+7)
            #define endl "\n"
            #define pb push_back
            #define TEST_CASES  ll t;cin>>t;while(t--)
            #define forn(i,a,n) for (int i = a; i < n; ++i)
            #define f first
            #define s second
            #define all(x) x.begin(), x.end()


            
            ll powD(ll x,ll y){
              ll res = 1;
              while(y > 0){
                if(y & 1)
                  res = (res*x);
                x = (x*x);
                y = y>>1;
              }
              return res;
            }

            int main()
            {
              ios_base::sync_with_stdio(false);
              cin.tie(NULL);
              int n,m,k;
              cin>>n>>m>>k;
              vector<ll> a(n+1,0),b(m+1,0);
              forn(i,1,n+1){
                int x;
                cin>>x;
                a[i] = a[i-1] + x;
              }
              forn(i,1,m+1){
                int x;
                cin>>x;
                b[i] = b[i-1] + x;
              }
              int cnt = 0;
              int sum = 0;
              forn(i,0,n+1)
              {
                if(a[i] > k)
                  break;
                else{
                  int curr = i;
                  int add = upper_bound(all(b),k-a[i])-b.begin()-1;
                  if(add != -1)
                    curr += add;
                  cnt = max(cnt,curr);
                }
              }
              cout<<cnt<<endl;


            }

            
          


Measured memory_bytes: 6364
#include "iostream"
using namespace std;
int main(){
  int a[3];
  int c[3];
  for(int i=0;i<3;i++){
    cin>>a[i];
  }
  int v=0;
  for(int i=0;i<3;i++){
    for(int j=i+1;j<3;j++){
      c[v]=a[i]+a[j];
      v+=1;



    }
  }
  int d=c[0];
  for(int i=1;i<3;i++){
    if(c[i]<d){
      d=c[i];
    }
  }
  cout<<d<<endl;

}


Measured memory_bytes: 3632
#include <string>
#include <iostream>
using namespace std;
int main(){
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if(A * B >= C * D){
		cout << A * B;
	}else if(A * B < C * D){
		cout << C * D;
	}
	return 0;
}

Measured memory_bytes: 256
def MI(): return map(int, input().split())
MOD=10**9+7
def nCr(n,k):
  tmp=1
  for i in range(n-k+1,n+1):
    tmp*=i
    tmp%=MOD
  for i in range(1,k+1):
    tmp*=pow(i,MOD-2,MOD)
    tmp%=MOD
  return tmp
N,A,B=MI()
ans=pow(2,N,MOD)-1-nCr(N,A)-nCr(N,B)
print(ans%MOD)

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

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  string s;
  cin >> n >> s;
  vector <vector <ll>> v(n, vector <ll> (26, 0));
  rep(i, n) {
    ll a = s.at(i) - 'A';
    if (i) {
      v.at(i) = v.at(i-1);
      v.at(i).at(a)++;
    } else {
      v.at(i).at(a)++;
    }
  }
  ll res = 0;
  rep(i, n) {
    for (ll j = i+1; j < n; j++) {
      if (s.at(i) != s.at(j)) {
        if (2*j-i < n) {
          if (s.at(i)==s.at(2*j-i) || s.at(j)==s.at(2*j-i)) {
            ll a = 'R' + 'G' + 'B' - s.at(i) - s.at(j) - 'A';
            res += v.at(n-1).at(a) - v.at(j).at(a);
          } else {
            ll a = 'R' + 'G' + 'B' - s.at(i) - s.at(j) - 'A';
            res += v.at(n-1).at(a) - v.at(j).at(a) - 1;
          }
        } else {
          ll a = 'R' + 'G' + 'B' - s.at(i) - s.at(j) - 'A';
          res += v.at(n-1).at(a) - v.at(j).at(a);
        }
      }
    }
  }
  cout << res << endl;
}

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

#define fs first
#define sc second
#define mp make_pair
#define pb emplace_back
#define sz(s) ((int) s.size ())
#define all(s) s.begin (), s.end ()

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef unsigned long long ull;

const ll linf = (ll) 1e18;

const int pw = 997;
const int N = 100009;
const int inf = (int) 1e9;
const int mod = (int) 1e9 + 7;

const double eps = 1e-10;
const double pi = 3.1415926535897932384626433832795;

inline void prepare () {

}
inline void solve () {
        int a, b; cin >> a >> b;
        if (a == 1) {
                a += 13;
        }
        if (b == 1) {
                b += 13;
        }
        if (a < b) {
                puts ("Bob");
        } else if (a == b) {
                puts ("Draw");
        } else {
                puts ("Alice");
        }
}
int main () {
        #ifdef FSTREAM
                #define name ""
                freopen (name".in", "r", stdin);
                freopen (name".out", "w", stdout);
        #endif // FSTREAM
        int tests = 1;
        prepare ();
	while (tests--) {
                solve ();
        }
}


Measured memory_bytes: 256
N = int(input())

ans = ''
for i in range(1,99):
    if N <= 26**i:
        N-=1
        for j in range(i):
            ans = chr(ord('a')+(N%26)) + ans
            N = N // 26
        break;
    else:
        N -= 26**i

print(ans)


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}

#define deb(x) cout << '>' << #x << ':' << x << endl;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define END '\n'
#define inf 9e18
#define ff first
#define ss second
#define pb push_back

void solve(){
    string s;
    cin >> s;
    cout << s.substr(0, 5) << " " << s.substr(6, 7) << " " << s.substr(14, 5);

}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h> 
#define ll long long
#define F first
#define FF first.first
#define FS first.second
#define S second
#define pb push_back
using namespace std;
const int N=1000006, INF=1e16;
 
ll n, q=1, m, a[15][15], b[15], f[N], o, k, t, x, y, X, z, u, h, mx, mn, ans, Ans=INF;
pair<ll,ll> p[N];
string s, S;
vector<int> v[N], V;
 
main(){ios_base::sync_with_stdio(false), cin.tie(0);
   	
//	cin>>q;
   	
   	while(q--){ans=o=0;
   		cin>>n>>m>>X;
   		
   		for (int i=1; i<=n; i++){
   			cin>>a[i][0];
   			for (int j=1; j<=m; j++){
   				cin>>a[i][j];
			}
		}
		k=(1<<n);
		for (int i=0; i<k; i++){
			for (int j=1; j<=m; j++)b[j]=-X;o=0;
			x=i;
			while(x){o++;
				if(x%2){
					ans+=a[o][0];
					for (int j=1; j<=m; j++)
						b[j]+=a[o][j];
				}
				x/=2;
			}
			for (int j=1; j<=m; j++){
				if(b[j]<0)u=1;
			}
			if(!u){
				Ans=min(Ans, ans);
			}u=ans=0;
		}
		if(Ans==INF)cout<<-1;
		else cout<<Ans;
	}
	
}

Measured memory_bytes: 27100
#include <iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(void){
    long a,b,c,k;
    long sum=0;
    cin >> a >> b >> c >> k;
    if(k<=a){
        sum=k;
    }else  if(k>a &&k<=a+b){
        sum=a;
    }else if(k>a+b && k<=a+b+c){
        sum=2*a+b-k;
    }else if((a+b+c)<k){
        sum=a-c;
    }
    cout << sum;
}

Measured memory_bytes: 3632
/*
 * atcoder/abc113_2nd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

#define MOD 1000000007
template <class T> void madd(T &a, T b){ if((a+=b)>=MOD) a-=MOD; }
template <class T> void msub(T &a, T b){ if((a+=MOD-b)>=MOD) a-=MOD; }

/*
 * S
 * |-| |
 * | |-|
 *     K
 *
 * S
 * | | |   | |-|
 * K
 *
 * |0|1|2|3|4|5|6|
 * 縦棒の間に横棒を入れる場所はは最大7つ. ただし、隣接することは出来ない.
 * [0: (1<<W)) のビットパターンのうち、隣接したビットが立っているものを除けば全パターン列挙可能.
 *
 * 高さh_nにおいて、w_mの位置にいる場合、移動可能なのは3通り. (h_n+1, w_m-1), (h_n+1, w_m), (h_n+1, w_m+1)
 * パターン列挙中にこの3パターンと一致する場合 dp[h_n+1][w_m-1] += dp[h_n][w_m]
 *
 * dpの初期値はh=0, w=0が1、その他0
 *
 * 座標と横棒のインデックスが紛らわしいので整理しておく.
 *
 * 0 1 2 3 4 5 6 7
 * |0|1|2|3|4|5|6|  0
 *                  1
 */
int H, W, K;
ll dp[110][10] = {0};
void print() {
  loop(h,0,H+1) {
    loop(w,0,W) {
      cout << dp[h][w] << " ";
    }
    cout << endl;
  }
}

bool nth(ll s, int n) {
  return (s>>n)&1;
}
void solve() {
  cin >> H >> W >> K;
  dp[0][0] = 1;
  loop(h,0,H) loop(w,0,W) {
    for (ll S=0; S<(1<<(W-1)); S++) {
      bool connected = false;
      for (int i=0; i+1<W; i++) {
        connected |= nth(S, i) and nth(S, i+1);
      }
      if (connected) continue;

      // (h, w) -> (h+1, w)
      if (!nth(S, w)) {
        if (w==0) {
          madd(dp[h+1][w], dp[h][w]);
        } else {
          if (!nth(S, w-1)) madd(dp[h+1][w], dp[h][w]);
        }
      }

      // (h, w) -> (h+1, w-1)
      if (w-1>=0 and nth(S, w-1)) madd(dp[h+1][w-1], dp[h][w]);
      // (h, w) -> (h+1, w+1)
      if (w+1<W and nth(S, w)) madd(dp[h+1][w+1], dp[h][w]);
    }
  }
  // print();
  cout << dp[H][K-1] << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


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

string s, t;
vector<vector<int> > dp;

string dfs(int i, int j) {
    if(!i){
        return "";
    }
    if(dp[i-1][j] == dp[i][j]) {
        return dfs(i-1, j);
    }
    if(dp[i][j-1] == dp[i][j]) {
        return dfs(i, j-1);
    }
    return dfs(i-1, j-1) + s[i-1];
}


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

    dp.assign(s.size()+1, vector<int>(t.size()+1));
    

    rep(i, s.size()) {
        rep(j, t.size()) {
            if(dp[i][j+1] > dp[i+1][j]) {
                dp[i+1][j+1] = dp[i][j+1];
            } else {
                dp[i+1][j+1] = dp[i+1][j];
            }
            if(s[i] == t[j] && dp[i+1][j+1] < dp[i][j]+1) {
                dp[i+1][j+1] = dp[i][j]+1;
            }
        }
    }

    cout << dfs(s.size(), t.size()) << '\n';
}

Measured memory_bytes: 35968
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

		char ans = (char) (W.charAt(0)+1);

		System.out.println(ans);
	}


}


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

Measured memory_bytes: 128
import java.util.*;

class Main{
    static int digitsum(int n){
        int sum = 0;
        while(n > 0){
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

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

       int min = 100000;
       for(int i = 1; i <= N - 1; i++){
           min = Math.min(min, digitsum(i) + digitsum(N - i));
       }

       System.out.println(min);
    }
}


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

int main(){
    int n;
    cin >> n;
    int a=0;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            if(i*j==n) a=1;
        }
    }
    if(a==1)cout << "Yes"  << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
// 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<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,int> tp;
typedef vector<tp> vt;
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;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	
	int n,m;
	cin>>n>>m;
	rep(i,m){
		int a;cin>>a;
		n-=a;
	}
	if(n<=0)yes;
	else no;
}









Measured memory_bytes: 256
def dg n
  sum = 0
  while n>0 do
    sum += n%10
    n /= 10
  end
  sum
end

N,A,B = gets.strip.split.map(&:to_i)
ans = (1..N)
	.map{ |i| [i, dg(i)] }
	.select{ |d| A<=d[1] && d[1]<=B }
	.inject(0) { |sum, d| sum+d[0] }
p ans

Measured memory_bytes: 2172
#include<iostream>
using namespace std;
int gcd(int,int);

int main(){
  int a,b;
  cin>>a>>b;
  cout<<gcd(a,b)<<endl;
  return 0;
}

int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(int argc, char *argv[])
{
	long long n,max,i,ans=0;
	scanf("%lld",&n);
	long long a[n];
	for(i=0;i<n;i++)
		scanf("%lld",&a[i]);
	max=a[0];
	for(i=1;i<n;i++){
		if(a[i]>max)max=a[i];
		else ans+=max-a[i];
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 3292
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        int result[] = new int[3];

        
        result[0] = a+b;
        result[1] = a-b;
        result[2] = a*b;
      
        int max=result[0];

        
        for (int i=0; i<result.length;i++) {
            int v = result[i];
            if(v > max) {
                max=v;
            }
        }
        System.out.println(max);
        
        
        
    }
}


Measured memory_bytes: 22612
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X, Y, Z = MAP()
print(Z, X, Y)


Measured memory_bytes: 5148
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>

using namespace std;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")



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

	long long n, i, j, k, ans;
	cin >> n;
	ans = 0;
	for (i = 1; i <= n; i++) {
		if (i < n) {
			ans += (n - 1) / i;
		}
	}
	cout << ans << "\n";


	return 0;
}




Measured memory_bytes: 3596
#include <stdio.h>

int count;

void def(int n){
  int i,j,a[4],l,s,k;

  if(n==6174){
    
    printf("%d\n",count);

  }else{

    count++;
    
    a[3]=n/1000;
    a[2]=(n/100)%10;
    a[1]=(n/10)%10;
    a[0]=n%10;

    for(i=0;i<3;i++){
      for(j=0;j<3-i;j++){
	if(a[j]<a[j+1]){
	  k=a[j];
	  a[j]=a[j+1];
	  a[j+1]=k;
	}
      }
    }

    l=a[0]*1000 + a[1]*100 + a[2]*10 + a[3];
    s=a[3]*1000 + a[2]*100 + a[1]*10 + a[0];

    def(l-s);
  }
}

int main(){
  int num,ans;
  while(scanf("%d",&num),num){
count=0;
    if(num%1111==0){
      printf("NA\n");
    }else{
      def(num);
    }
  }

  return 0;
}

Measured memory_bytes: 608
//organize and stay in moment - Abhinav IIIT-A
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,x,n) for(int i=x;i<n;++i)
#define ar array
#define MAXN (int)2e5+5
#define pb push_back
int mod= 998244353;
int arr[MAXN];
int as;
void input(){
  cin>>as;
  f(i,0,as) cin>>arr[i];
}
void q1(){
  string s; cin>>s;
  int a=0,b=0;
  f(i,0,3)
  s[i]=='A'  ? ++a : ++b;
  if(a&&b)
    cout<<"Yes";
  else cout<<"No";
}
void q2(){
  int n,a,b;
  cin>>n>>a>>b;
  int t=a+b;
  int q=n/t;
  int ans=q*a;
  int r=n%t;
  ans+=min(r,a);
  cout<<ans;
}
void q3(){
  int a,b; cin>>a>>b;
  for(int i=1;i<=100000;++i){
    int x=i*8; x/=100;
    int y=i*10; y/=100;
    if(x==a && y==b){
      cout<<i;
      return ;
    }
  }
  cout<<-1;
}
void q4(){
  string s; cin>>s;
  deque<int> q;
  f(i,0,s.size())
  q.push_back(s[i]);
  int Q; cin>>Q;
  int curr=0;
  while(Q--){
    int t;
    cin>>t;
    if(t==1){
      curr=1-curr;
    }else{
      // 0 0 begin
      //0 1 end
      //1 0 end
      //1 1 begin
      int f;char c; cin>>f>>c;
      if((f+curr)%2==0)
        q.push_front(c);
      else q.push_back(c);
    }
  }
  string ret="";
  while(!q.empty()){
    ret+=q.front();
    q.pop_front();
  }
  if(curr)
     reverse(ret.begin(),ret.end());
   cout<<ret;
   return ;
}
void q5(){
  int n,p; cin>>n>>p;
  string s; cin>>s;
  int ans=0;
  if(p==2){
    f(i,0,n)
    if((s[i]-'0')%2==0)
      ans+=i+1;
  }else if(p==5){
    f(i,0,n)
    if((s[i]-'0')%5==0)
      ans+=i+1;
  }else {
    int tt=1;
    int curr=0;
     map<int,int> mp;
     mp[0]++;
     for(int i=n-1;i>=0;--i){
        curr+=(s[i]-'0')*tt;
        tt*=10;
        tt%=p; curr%=p;
        ans+=mp[curr];
        ++mp[curr];
     }
  }
  cout<<ans;
}
int mod2=998244353;
void solve(){
 
}
int32_t main()
{
  int t; t=1; //cin>>t;
  while(t--) q2();
  return 0;
}


Measured memory_bytes: 256
a,b,m = map(int, input().split())

alis = list(map(int, input().split()))
blis = list(map(int, input().split()))

ans = min(alis)+min(blis)
for i in range(m):
    x,y,c = map(int, input().split())
    t = alis[x-1] + blis[y-1] -c

    ans = min(ans, t)

print(ans)

Measured memory_bytes: 24836
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

fn sadness(As: &[i64], N: usize, b: i64) -> i64 {
    let mut ans: i64 = 0;

    for i in 0..N {
        let pInd = (i + 1) as i64;
        ans += (As[i] - (b + pInd)).abs()
    }

    return ans;
}

fn main() {
    input! {
        N: usize,
        As: [i64; N],
    }

    // 答えを見た
    // 平均かと思っていたけど中央値だった…

    let mut Bs: Vec<i64> = As.iter()
        .enumerate()
        .map(|(ind, a)| a - ind as i64 - 1)
        .collect();
    Bs.sort();

    if N % 2 == 0 {
        let b1 = Bs[N / 2 - 1];
        let b2 = Bs[N / 2];
        let ans1 = sadness(As.as_slice(), N, b1);
        let ans2 = sadness(As.as_slice(), N, b2);

        let ans = std::cmp::min(ans1, ans2);
        println!("{}", ans);
    } else {
        let b = Bs[(N - 1) / 2];
        let ans = sadness(As.as_slice(), N, b);
        println!("{}", ans);
    };



}


Measured memory_bytes: 7716
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数
ll d[1000000];
ll e[3000000];

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}

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

	int h;
	int max = 0;
	int ans = 0;
	REP(i, n) {
		scanf("%d", &h);
		if (h >= max) {
			ans++;
			max = h;

		}
	}
		PRINTD(ans);
}

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

class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] strs = br.readLine().split(" ");
    Arrays.sort(strs);
    int A = Integer.parseInt(strs[0]);
    int B = Integer.parseInt(strs[1]) + Integer.parseInt(strs[2]) * 10;
    
    System.out.println(A + B);
  }
}

Measured memory_bytes: 21332
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}
int main(){
ll N;
cin>>N;
ll ans=0;
ll l[100010],r[100010];
  for(ll i=0; i<N; ++i){
  cin>>l[i]>>r[i];
  }
  for(ll i=0; i<N; ++i){
  ans+=r[i]-l[i]+1;
  }
  cout<<ans<<endl;

}



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

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

int main() {
    int n;

    cin >> n;

    (n % 2 == 0) ? (cout << n / 2 - 1 << endl) : (cout << n / 2 << endl);
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <map>
#include <algorithm>
#include <math.h>
#include <iostream>     // std::cout, std::fixed
#include <iomanip>
#include<queue>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <iostream>
#include <sstream>
#include <time.h>
using namespace std;
typedef long long ll;
vector<vector<int>> g;
vector<vector<ll>> rk;
vector<bool> vis;
vector<ll> p;

void bfs(ll s)
{
    queue<ll> q;
    q.push(s);
    vector<ll> ans;
    while (!q.empty()) {
        ll cur=q.front();
        q.pop();
        ans.push_back(p[cur]);
        vis[s]=true;
        for(auto son : g[cur])
        {
            if(vis[son])
                continue;
            vis[son]=true;
            q.push(son);
            
        }
        
    }
    sort(ans.begin(), ans.end());
    reverse(ans.begin(), ans.end());
    rk.push_back(ans);
}
int main () {
    ios_base::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    p=vector<ll> (n);
    for(int i=0;i<n;i++)
    {
        cin>>p[i];
    }
    g=vector<vector<int>>(n);
    vis=vector<bool>(n,false);
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int i=0;i<n;i++)
    {
        if(vis[i])
            continue;
        bfs(i);
    }
    ll ans=0;
    ll vhave=0;
    ll vneed=(rk.size()-2)*2+2;
    for(int i=0;i<rk.size();i++)
    {
        if(vhave==vneed)
        {
            cout<<ans;
            return 0;
        }
        ans+=rk[i][rk[i].size()-1];
        rk[i].pop_back();
        vhave++;
    }
    
    
    priority_queue<ll, std::vector<ll>, std::greater<ll> > minq;
    for(int i=0;i<rk.size();i++)
    {
        for(auto x :rk[i])
            minq.push(x);
    }
    while (vhave<vneed) {
        if(minq.empty())
        {
            cout<<"Impossible";
            return 0;
        }
        ans+=minq.top();
        minq.pop();
        vhave++;
    }
    cout<<ans;
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 10164
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

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

  return 0;
}

// EOF

Measured memory_bytes: 256
#include<iostream>
int h,w,a,b,i,j;
int main(){
  std::cin>>h>>w>>a>>b;
  for(i=0;i<h;++i){
    for(j=0;j<w;++j)std::cout<<(i<b^j<a);
    std::cout<<"\n";
  }
}


Measured memory_bytes: 1280
/*   Abhijith  */
#include<bits/stdc++.h>
#include<iomanip>
#include<cmath>
#define lld long long int
#define ld long double
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define	endl '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
     ios;
     lld n;
     cin>>n;
     vector<vector<ld> > dp(n+1,vector<ld> (n+1));
     vector<ld> p(n+1);
     rep(i,1,n)
     cin>>p[i];
     dp[1][0]=1.0-p[1];
     dp[1][1]=p[1];
     rep(i,2,n)
     {
         rep(j,0,n)
         {
             if(j==0)
             {
                 dp[i][j]=dp[i-1][j]*(1.0-p[i]);
             }
             else
             {
                 dp[i][j]=dp[i-1][j]*(1.0-p[i])+dp[i-1][j-1]*p[i];
             }
         }
     }
     ld ans=0;
     rep(j,0,n)
     {
         if(j>n-j)
         {
             ans+=dp[n][j];
         }
     }
     cout<<fixed<<setprecision(10)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 141056
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////

vector<vector<int>> g, block;

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

    int N, M, K;

    cin >> N >> M >> K;

    g.resize(N);
    block.resize(N);

    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        g[x].push_back(y);
        g[y].push_back(x);

        //cerr << " + " << x << " " << y << "\n";
    }

    for (int i = 0; i < K; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        block[x].push_back(y);
        block[y].push_back(x);
    }

    vector<int> used(N, -1);

    vector<int> ans(N);

    int id = 0;
    for (int i = 0; i < N; i++) {
        if (used[i] != -1)
            continue;
        queue<int> Q;
        vector<int> comp;
        for (Q.push(i); !Q.empty();) {
            auto el = Q.front();
            Q.pop();
            used[el] = id;
            comp.push_back(el);
            
            //cerr << "? " << id << " : " << el << "\n";
            for (auto v : g[el]) {
                if (used[v] == -1) {
                    used[v] = id;
                    Q.push(v);
                }
            }
        }

        for (auto el : comp) {
            unordered_set<int> burned;
            //cerr << id << " " << el << "\n";
            for (auto v : block[el]) {
                if (used[v] == used[el])
                    burned.insert(v);
            }
            for (auto v : g[el]) {
                burned.insert(v);
            }
            ans[el] = comp.size() - 1 - burned.size();
        }

        id++;
    }

    for (int i = 0; i < N; i++) {
        cout << ans[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 16528
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int n;
	cin>>n;
    int m=n;
    int sum;
    while(m>0){
        sum+=m%10;
        m-=m%10;
        m/=10;
    }

    bool check=false;
    if(n%sum==0){
        check=true;
    }
	
    cout<< (check?"Yes":"No") <<endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
#define P pair<int,int>
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}
int sankaku(int a){
	return a*(a+1)/2;
} 
char c[15][1145];
int a[1145][15];
signed main(){
	ic(h) ic(w) ic(k)
	rep(0,i,h)rep(0,j,w)cin>>c[i][j];
	for(int bit=0;bit<(1<<h-1);bit++)rep(0,i,h-1)if(bit&(1<<i))a[bit][i]=1;
	int ans=111111;
	rep(0,i,pow(2,h-1)){
		int sum=0;
		rep(0,j,h-1)sum+=a[i][j];
		int wa[11];
		int cnt=0;
		rep(0,j,h)wa[j]=0;
		rep(0,j,w){
			int aa=1;
			int memo[11];
			rep(0,l,h)memo[l]=0;
			rep(0,l,h){
				if(l>0&&a[i][l-1]==1)aa++;	
				if(c[l][j]=='1'){
					wa[aa-1]++;
					memo[aa-1]++;
				}	
			}
			int aaa=0;
			rep(0,l,aa){
				if(wa[l]>k){
					sum++;
					aaa++;
					j-=1;
					if(memo[l]>k){
						j++;
						sum=1000000;
					}
					break;	
				}
			}
			if(aaa==1)rep(0,l,aa)wa[l]=0;		
		}
		ans=min(ans,sum);
	}
	c(ans)
}	
		


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

#define rep(i,beg,end)   for (auto i=(beg);i<(end);i++)
#define all(cont)           begin(cont), end(cont)
#define rall(cont)           rbegin(cont), rend(cont)
using ll = long long;
using vi = vector<ll>;
const ll INFMAX = LLONG_MAX;
const ll INFMIN = LLONG_MIN;
const ll MOD = 1000000007;


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; cin >> n;
	vi a(n);
	rep(i, 0, n) {
		ll t;
		cin >> t;
		a[t - 1] = i + 1;
	}
	for_each(all(a), [](auto x) { cout << x << ' '; });
	return 0;
}


Measured memory_bytes: 1664
#include<cstdio>
int a[105],n,tot;
int main()
{
    for(int i=1;i<=3;i++)
    {
        scanf("%d",&n);
        a[n]++;
    }
    for(int i=1;i<=100;i++)
    {
        if(a[i]!=0)
            tot++;
    }
    printf("%d",tot);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define int long long

#define INF 1e+9
#define MAX_V 100008


signed main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;

  long double rs = h * (360 / 12.0) + m * (1 / 2.0);
  long double rl = m * (360 / 60.0);

  long double ang = abs(rl - rs);

  long double ans = pow(a, 2) + pow(b, 2) - 2 * a * b * cos(((ang * acos(-1)) / 180.0));
  cout << fixed << setprecision(18) << sqrt(ans) << endl;
}   




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

int main() {
    int N;
    cin >> N;
    map<int, int> mp;
    int a;
    for (int i = 0; i < N; i++) {
        cin >> a;
        mp[a]++;
    }

    int ans = 0;
    for (auto x : mp) {
        if (x.first > x.second) ans += x.second;
        else if (x.first < x.second) ans += x.second - x.first;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4736
class SegT():
    # originは初期データがあれば渡す
    def __init__(self, size, origin=None):
        self.size = 1
        while self.size < size: self.size *= 2
        self._data_init()
        if origin:
            for i in range(size):
                self.data[i+self.size-1] = origin[i]
            for i in range(self.size-2,-1,-1):
                self.data[i] = self.data[i*2+1] | self.data[i*2+2]

    def _data_init(self):
        self.e = pow(2, 31)-1 # 単位元
        self.data = [self.e for _ in range(self.size * 2 - 1)]

    def _calc(self, a, b):
        # ここは独自実装する
        return min(a, b)
    
    def update(self, i, x):
        i += (self.size - 1)
        self.data[i] = x
        while i > 0:
            i = (i - 1) // 2
            self.data[i] = self._calc(self.data[i*2+1], self.data[i*2+2])
        
    def get(self, a, b, node=0, l=0, r=-1):
        if r < 0: r = self.size
        if r <= a or b <= l: return self.e
        if a <= l and r <= b: return self.data[node]
        vl = self.get(a, b, node*2+1, l, (l+r)//2)
        vr = self.get(a, b, node*2+2, (l+r)//2, r)
        return self._calc(vl, vr)

N, Q = map(int, input().split())
origin = [pow(2, 31) - 1 for i in range(N)]
segt = SegT(N)

for i in range(Q):
    t, l, r = input().split()
    if t == "0":
        segt.update(int(l), int(r))
    else:
        x = segt.get(int(l),int(r)+1)
        print(x)



Measured memory_bytes: 12968
def main():
    n = int(input())
    a = list(map(int, input().split()))
    color = set()
    free = 0
    for score in a:
        if score < 3200:
            color.add(score//400)
        else:
            free += 1
    print(max(len(color),1), len(color)+free)
if __name__ == "__main__":
    main()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	int count = 0;

	while(1){
		if (n < 3) break;
		n -= 3;
		count++;
	}

	cout << count << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文
int main() {
	string a, b, c;
	cin >> a >> b >> c;
	cout << (char)(a.at(0)-'a' +'A')<< (char)(b.at(0) - 'a' + 'A') << (char)(c.at(0) - 'a' + 'A') << endl;
}

Measured memory_bytes: 256
N,M,C = map(int,input().split())

B = list(map(int,input().split()))
count = 0

for i in range(N):
    tmp = list(map(int,input().split()))
    sum = 0

    for j in range(M):
        sum += B[j]*tmp[j]
    
    if sum + C > 0:
        count += 1

print(count)


Measured memory_bytes: 3060
import java.util.*;

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

    int n = sc.nextInt();
    
    int[] t = new int[n+1];
    int[] x = new int[n+1];
    int[] y = new int[n+1];

    for (int i = 1; i <= n; i++) {
      t[i] = sc.nextInt();
      x[i] = sc.nextInt();
      y[i] = sc.nextInt();
    }

    String ans = "Yes";
    for (int i = 1; i <= n; i++) {
      // 距離と時間の可否チェック
      int dt = t[i] - (i == 1 ? 0 : t[i-1]);
      int dist = Math.abs(x[i] - (i == 1 ? 0 : x[i-1]));
      dist += Math.abs(y[i] - (i == 1 ? 0 : y[i-1]));
      if (dt < dist) {
        ans = "No";
        break;
      }

      // 距離のチェック tが奇数ならxy距離の和も奇数(逆も同じ)
      if (dt % 2 != dist % 2) {
        ans = "No";
        break;
      } 
    }

    System.out.println(ans);

  }
  
}

Measured memory_bytes: 91244
#include <iostream>
#include <stdio.h>
using namespace std;
struct food {
	char fn[21];
	int g;
	int s;
};
int f[10],an[10],m;
food fd[10],sf;

int ans(int n,int s) {
	int i;
	if (n==-1) { for (i=m-1;i>=0;i--) cout << fd[an[i]].fn << endl; return 1;}
	for (i=m-1;i>=0;i--) {
		if (f[i]==0 && fd[i].s>=s-fd[i].g) {
			f[i]=1; an[n]=i;
			if (ans(n-1,s-fd[i].g)==1) return 1; 
			f[i]=0;
		}
	}
	return 0;
}

int main() {
	int i,j,s;
	while(cin >> m) {
		if (m==0) break;
		for (i=0,s=0;i<m;i++) { f[i]=0; cin >> fd[i].fn >> fd[i].g >> fd[i].s;  s+=fd[i].g;}
		for (i=1;i<m;i++) for (j=0;j<m-i;j++) if (fd[j].g>fd[j+1].g) { sf=fd[j]; fd[j]=fd[j+1]; fd[j+1]=sf;}
        ans(m-1,s);		
	}
 return 0;
 }

Measured memory_bytes: 1160
from sys import stdin


class SegmentTree:
    # 初期化処理
    # f : SegmentTreeにのせるモノイド
    # default : fに対する単位元
    def __init__(self, size, f=lambda x,y : x+y, default=0):
        self.size = 2**(size-1).bit_length() # 簡単のため要素数Nを2冪にする
        self.default = default
        self.dat = [default]*(self.size*2) # 要素を単位元で初期化
        self.f = f

    def update(self, i, x):
        i += self.size
        self.dat[i] = x
        while i > 0:
            i >>= 1
            self.dat[i] = self.f(self.dat[i*2], self.dat[i*2+1])

    def query(self, l, r):
        l += self.size
        r += self.size
        lres, rres = self.default, self.default
        while l < r:
            if l & 1:
                lres = self.f(lres, self.dat[l])
                l += 1

            if r & 1:
                r -= 1
                rres = self.f(self.dat[r], rres) # モノイドでは可換律は保証されていないので演算の方向に注意
            l >>= 1
            r >>= 1
        res = self.f(lres, rres)
        return res


n,q   = [int(x) for x in stdin.readline().rstrip().split()]

lamb_min = lambda x,y : min(x,y)
seg = SegmentTree(n,lamb_min,2147483647)
for _ in range(q):
    c,x,y = [int(x) for x in stdin.readline().rstrip().split()]
    if c == 0:
        seg.update(x,y)
    elif c == 1:
        print(seg.query(x,y+1))


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

int n;
int x, max_e = -1;

std::map<int, int> mp;
int main() {
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x;
        max_e = std::max(x, max_e);
        mp[x]++;
    }
    ll ans = 0;
    for (int i = 0; i <= max_e; i++) {
        ll sum = 0;
        sum += mp[i-1];
        sum += mp[i];
        sum += mp[i+1];
        if (ans < sum) {
            ans = sum;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 4992
#include <iostream>

using namespace std;

void go(string& s, int n1, int n2, char c)
{
    for (int i = n1; i < n2; ++i) {
        s.push_back(c);
    }
}
void back(string& s, int n2, int n1, char c)
{
    for (int i = n2; i > n1; --i) {
        s.push_back(c);
    }
}

int main()
{
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    string ans;

    go(ans, sy, ty, 'U');
    go(ans, sx, tx, 'R');
    back(ans, ty, sy, 'D');
    back(ans, tx, sx, 'L');
    ans.push_back('L');
    go(ans, sy, ty+1, 'U');
    go(ans, sx-1, tx, 'R');
    ans.push_back('D');
    ans.push_back('R');
    back(ans, ty, sy-1, 'D');
    back(ans, tx+1, sx, 'L');
    ans.push_back('U');

    cout << ans << endl;

    return 0;
}



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

class poland{
private:
    stack<int> S;
public:
    void push_num(int num) {
        S.push(num);
    }
    int top_num() {
        return S.top();
    }
    void calc(string symbol) {
        int op2 = S.top();
        S.pop();
        int op1 = S.top();
        S.pop();
        if (symbol == "+") S.push(op1 + op2);
        if (symbol == "-") S.push(op1 - op2);
        if (symbol == "*") S.push(op1 * op2);
    }
};

int main()
{
    string s;
    poland P;
    while (cin >> s) {
        if (s == "+" || s == "-" || s == "*") {
            P.calc(s);
            continue;
        }
        P.push_num(atoi(s.c_str()));
    }
    cout << P.top_num() << endl;

    return 0;
}

Measured memory_bytes: 3188
//In the Name of ̲A̲l̲l̲a̲h̲
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll n, m;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	cout << ((n-1)*(m-1));
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000


int main(){
	
	int N;
	cin>>N;
	
	vector<long long> a(3*N);
	for(int i=0;i<3*N;i++)cin>>a[i];
	
	long long ans = 0;
	
	sort(a.begin(),a.end());
	
	for(int i=N;i<3*N;i+=2){
		ans += a[i];
	}
	
	cout<<ans<<endl;
	
	return 0;
}



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

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  int dh[] = {0,0,-1,1};
  int dw[] = {1,-1,0,0};
  for (int i = 0; i < h; i++) cin >> s[i];

  int sh,sw;
  int ans = 0;
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      if(s[i][j]=='.'){
        sh=i;
        sw=j;
      }
      else continue;
      vector<vector<int>> dist(h,vector<int>(w,-1));
      queue<pair<int,int>> que;
      dist[sh][sw] = 0;
      que.emplace(sh,sw);
      while(!que.empty()){
        int hh = que.front().first;
        int ww = que.front().second;
        que.pop();

        for (int d = 0; d < 4; d++)
        {
          int nh = hh+dh[d];
          int nw = ww+dw[d];

          if(nh<0 || nh>=h || nw<0 || nw>=w) continue;
          if(s[nh][nw]=='#') continue;

          if(dist[nh][nw]==-1){
            dist[nh][nw] = dist[hh][ww] + 1;
            que.emplace(nh,nw);
          }
        }
      }
      int dis = 0;
      for (int ii = 0; ii < h; ii++)
      {
        for (int jj = 0; jj < w; jj++)
        {
          dis = max(dis,dist[ii][jj]);
        }        
      }
      ans = max(ans,dis);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <map>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

struct Node {
  int price;
  int cnt;
  double value;

  Node(int price = -1, int cnt = -1) {
    this->price = price;
    this->cnt = cnt;
    this->value = (double) price / pow(2, cnt);
  }

  bool operator>(const Node &n) const {
    return value < n.value;
  }
};

int main() {
  int N, M;

  cin >> N >> M;
  priority_queue <Node, vector<Node>, greater<Node>> pque;

  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    pque.push(Node(a, 0));
  }

  for (int m = 0; m < M; ++m) {
    Node node = pque.top();
    pque.pop();

    pque.push(Node(node.price, node.cnt + 1));
  }

  ll ans = 0;

  while (!pque.empty()) {
    Node node = pque.top();
    pque.pop();

    ans += floor(node.value);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2420