akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

typedef struct{
	char suit;
	int num;
	int exist;
} st_card;

st_card card[52] =
{
	{ 'S', 1, 0 },
	{ 'S', 2, 0 },
	{ 'S', 3, 0 },
	{ 'S', 4, 0 },
	{ 'S', 5, 0 },
	{ 'S', 6, 0 },
	{ 'S', 7, 0 },
	{ 'S', 8, 0 },
	{ 'S', 9, 0 },
	{ 'S', 10, 0 },
	{ 'S', 11, 0 },
	{ 'S', 12, 0 },
	{ 'S', 13, 0 },
	{ 'H', 1, 0 },
	{ 'H', 2, 0 },
	{ 'H', 3, 0 },
	{ 'H', 4, 0 },
	{ 'H', 5, 0 },
	{ 'H', 6, 0 },
	{ 'H', 7, 0 },
	{ 'H', 8, 0 },
	{ 'H', 9, 0 },
	{ 'H', 10, 0 },
	{ 'H', 11, 0 },
	{ 'H', 12, 0 },
	{ 'H', 13, 0 },
	{ 'C', 1, 0 },
	{ 'C', 2, 0 },
	{ 'C', 3, 0 },
	{ 'C', 4, 0 },
	{ 'C', 5, 0 },
	{ 'C', 6, 0 },
	{ 'C', 7, 0 },
	{ 'C', 8, 0 },
	{ 'C', 9, 0 },
	{ 'C', 10, 0 },
	{ 'C', 11, 0 },
	{ 'C', 12, 0 },
	{ 'C', 13, 0 },
	{ 'D', 1, 0 },
	{ 'D', 2, 0 },
	{ 'D', 3, 0 },
	{ 'D', 4, 0 },
	{ 'D', 5, 0 },
	{ 'D', 6, 0 },
	{ 'D', 7, 0 },
	{ 'D', 8, 0 },
	{ 'D', 9, 0 },
	{ 'D', 10, 0 },
	{ 'D', 11, 0 },
	{ 'D', 12, 0 },
	{ 'D', 13, 0 },
};

int main( void )
{
	int i, n, num, offset;
	char suit;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++){
		scanf(" %c %d", &suit, &num);
		
		switch( suit ){
			case 'S': offset = 0; break;
			case 'H': offset = 13; break;
			case 'C': offset = 26; break;
			case 'D': offset = 39; break;
			default: return 0;
		}
		
		card[offset + num - 1].exist = 1;
	}
	
	for(i = 0; i < 52; i++){
		if(card[i].exist == 0){
			printf("%c %d\n", card[i].suit, card[i].num);
		}
	}

    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int idx;
vector<vi> G;
vi C;
vi res;

int dfs(int v, int pv){
    int ret = 0;
    for(auto& nv : G[v]){
        if(nv == pv) continue;
        ret += dfs(nv, v);
    }
    res[v] = C[idx++];
    if(pv != -1){
        ret += res[v];
    }
    return ret;
}

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

    int n; cin >> n; 
    G = vector<vi>(n);
    rep(loop, n-1){
        int a, b; cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    C = vi(n);
    for(auto& e : C) cin >> e;
    sort(_all(C));

    res = vi(n);
    cout << dfs(0, -1) << endl;
    rep(v, n){
        cout << (v ? " ":"") << res[v];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1536
import copy

def j(n):
    if n:print("yes")
    else:print("no")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)

a,b = ips()
s = 1
n=0
while s<b:
    s+=(a-1)
    n+=1
print(n)


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

int main() {
    int K;
    cin >> K;
    string S;
    cin >> S;
    
    int s = S.size();
    if ( s <= K ){
        cout << S << endl;
    } else {
        for ( int i = 0; i < K; ++i){
            cout << S.at(i);
        }
        cout << "..." << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#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,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define reverse(s) reverse(s.begin(), s.end());
#define p pair<int,int>
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }

unsigned int randxor()
{
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t;
	t = (x ^ (x << 11)); x = y; y = z; z = w; return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}


int main() {
	int x, y;
	cin >> x >> y;
	cout << x + y / 2 << endl;
	return 0;

}
	

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

int n;

int a[110];

int main()
{
	cin >> n;
	int c = 10000;
	for(int i = 0; i < n;i++){
		cin >> a[i];
	}
	int res = 0;
	for (int i = 0;i < n-1;i++)
	{
		if (a[i] == a[i+1]){
			res++;
			a[i+1] = ++c;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	long long int a,b,i,d,res=0;
	
	cin>>a;
	vector<int> c(a);
	for(i=0;i<a;i++){
		cin>>c[i];
		c[i]-=i-100;
	}
	sort(c.begin(),c.end());
	b=c[a/2];
	for(i=0;i<a;i++)res+=abs(c[i]-b);
	cout<<res;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N;
   cin >> N;
   int a[N], b[N], c[N];
   for (int i = 0; i < N; i++) {
      cin >> a[i];
      a[i]--;
   }
   for (int i = 0; i < N; i++) {
      cin >> b[i];
   }
   for (int i = 0; i < N - 1; i++) {
      cin >> c[i];
   }
   int ans = 0;
   for (int i = 0; i < N; i++) {
      ans += b[a[i]];
      if (i == 0) continue;
      if (a[i] == a[i - 1] + 1) ans += c[a[i - 1]];
   }
   cout << ans << endl;
   return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  int n;cin>>n;
  int a[n+10];rep(i,0,n)cin>>a[i];

  int seq=1;
  int ans=0;
  rep(i,0,n-1){
    if(a[i]==a[i+1])seq++;
    else{
      ans+=seq/2;
      seq=1;
    }
  }
  if(seq!=1)ans+=seq/2;

  out(ans);

  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <math.h>
#include <deque>
#include <queue>
#include <map>
#include <iterator>
#include <set>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

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

	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i += 2) {
		int cnt = 0;
		for (int j = 1; j <= i; j++) {
			if (i % j == 0) cnt++;
		}
		if (cnt == 8) ans++;
	}
	cout << ans << endl;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v),end()
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;

template<typename A,typename B> inline void chmin(A &a,B b){if(a>b) a=b;}
template<typename A,typename B> inline void chmax(A &a,B b){if(a<b) a=b;}
//-----------------------------------------------------------------------

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

    while(true)
    {
        int n; cin>>n;
        if(n==0) break;

        int cnt=0;
        for(int i=1;i<=n/2;i++){
            for(int j=i+1;j<n;j++){
                int sum=(i+j)*(j-i+1)/2;
                if(sum==n) cnt++;
            }
        }
        cout<<cnt<<endl;
    }
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define DUMP(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<": "<<(x)<<" (L"<<__LINE__<<")"<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;
using ll = long long;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int main() {
    int H, W; cin >> H >> W;
    vstring a(H);
    rep(i, H) cin >> a[i];
    cout << string(W+2, '#') << endl;
    rep(i, H) {
        cout << "#" << a[i] << "#" << endl;
    }
    cout << string(W+2, '#') << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll fc[1001001]={1ll},nv[1001001]={1ll},w[1001001];

ll rwpw(ll a, ll p){
	ll ret = 1ll;
	while(p){
		if(p%2){
			mul_mod(ret,a);
		}
		mul_mod(a,a);
		p /= 2;
	}
	return ret;
}

ll comb(int n, int k){
	ll ret = fc[n];
	if(n<k){
		return 0ll;
	}
	mul_mod(ret,nv[k]);
	mul_mod(ret,nv[n-k]);
	return ret;
}

int main(void){
	int n,i,p,q;
	ll tmp,ans=0ll;
	cin >> n;
	for(i=0; i<n; ++i){
		fc[i+1] = fc[i];
		mul_mod(fc[i+1],i+1);
		nv[i+1] = rwpw(fc[i+1],MOD-2);
	}
	--n;
	for(i=1; i<=n; ++i){
		p = i; q = n-i;
		w[i] = comb(p-1,q);
		mul_mod(w[i],fc[p]);
		mul_mod(w[i],fc[q]);
		tmp = w[i];
		add_mod(tmp,MOD-w[i-1]);
		mul_mod(tmp,i);
		add_mod(ans,tmp);
	}
	cout << ans << endl;
	return 0;
}


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

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

 int a=0,w=0,t=0,r=0;

 for (size_t i = 0; i < n; i++)
 {
     string s;
     cin>>s;
     if(s=="AC")a++;
     else if(s=="WA")w++;
     else if(s=="TLE")t++;
     else r++;
 }
 

cout<<"AC x "<<a<<endl;
cout<<"WA x "<<w<<endl;
cout<<"TLE x "<<t<<endl;
cout<<"RE x "<<r<<endl;

    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

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

  int c[12];
  int a[12][12];
  rep(i, n) {
    cin >> c[i];
    rep(j, m) cin >> a[i][j];
  }

  int ans = 1 << 30;

  rep(i, (1 << n)) {
    vector<int> v(m, 0);
    int sum = 0;
    rep(j, n) if ((i >> j) & 1) {
      sum += c[j];
      rep(k, m) v[k] += a[j][k];
    }
    bool f = true;
    rep(j, m) if (v[j] < x) f = false;

    if (f) ans = min(ans, sum);
  }

  if (ans == (1 << 30)) ans = -1;

  cout << ans << endl;
}


Measured memory_bytes: 3636
h,n = map(int,input().split())
d = []
mp = []
for _ in range(n):
    a,b = map(int,input().split())
    d.append(a)
    mp.append(b)

h_m = max(d)+h+1
dp = [[float("inf")]*h_m for x in range(n+1)]
dp[0][0] = 0

for i in range(n):
    for j in range(h_m):
        if j<d[i]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = min(dp[i+1][j-d[i]]+mp[i],dp[i][j])

print(min(dp[n][h:h_m]))

Measured memory_bytes: 311688
def create(num)
  Array.new(num){ Array.new(num) }
end

def input(array, num)
  num.times do |i|
    input = gets.chomp.split('')
    input.each_with_index do |c, j|
      array[i][j] = c
    end
  end
end

n, m = gets.chomp.split(' ').map(&:to_i)

a = create(n)
b = create(m)
input(a, n)
input(b, m)

def check(a, b, i, j)
  b.length.times do |k|
    b.length.times do |l|
      return false if a[i+k][j+l] != b[k][l]
    end
  end
  true
end

(n-m+1).times do |i|
  (n-m+1).times do |j|
    is_match = check(a, b, i, j)
    if is_match
      puts 'Yes'
      exit
    end
  end
end
puts 'No'

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372036854775807ll;

void solve()
  {
   int n;
   cin>>n;
   for(int i=1; i<=9 ;i++){
     if(n%i == 0 && n/i<=9)
       {
        cout<<"Yes";
        return;
       }
   }
   cout<<"No";
  } 
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
 
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n,p;
	while(cin>>n>>p){
		if(n==0 && p==0) break;
		int hv[100]={},tn=0,cp=p;
		while(1){
			if(cp==1 && hv[tn]==p-1){
				cout<<tn<<endl;
				break;
			}
			if(cp==0){
				swap(cp,hv[tn]);
			}
			else {
				hv[tn]++; 
				cp--;
			}

			tn=(tn+1)%n;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.*;
class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    String s = sc.next();
    // 99の長さの "_" を作る
	String repeated = new String(new char[99]).replace("\0", "_");
	String v = s + repeated; // s の後ろに "_" を99個連結する。
	String x = v.substring(k,k+1); // 数値 k + 1番目の文字列を取り出す
	if("_".equals(x)){ // k + 1 番目が _ であれば s のまま出力
		System.out.println( s );
	}else{
        String r = s.substring(0,k); 
		System.out.println( r + "..."  );
	}
  }
}


Measured memory_bytes: 39896
//بسم الله الرحمن الرحيم
///   ***   ---   |||		 In the name of ALLAH		|||   ---   ***   ///
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define el << endl
#define PI 3.141592653589793238
#define _test_ int t; cin >> t; while(t--)
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define file() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
ll gcd ( ll  a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }
int dx[]={0,0,+1,-1,+1,-1,-1,+1};
int dy[]={+1,-1,0,0,+1,-1,+1,-1};
///*......................*//* LET'S BEGIN (-_^) *//*............................///
const int mx= 2e5+123;
int n,a[mx],m=INT_MIN;
ll ans ;

void _case_()
{
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        m=max(m,a[i]);
        if(a[i]<m)
                ans+=m-a[i];
    }
    cout << ans el;
}

int main()
{

    optimize();
    //_test_
      _case_();
    return 0;

}

///////////*  N A Y E M  *///////////

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

int main()
{
    int n;
    cin>>n;
    vector <double> a(n);
    rep(i,n)
    {
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    double sum = (a[0]+a[1])/2;;
    for(int i=2;i<n;i++)
    {
       sum=(sum+a[i])/2;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
        int a = 0, b = 0;
        string s1;
        cin >> s1; 
        for (auto c : s1)
                if (c == 'A')
                        a++;
                else
                        b++;
        if (a && b)
                cout << "Yes";
        else 
                cout <<"No";
        cout << endl;
        return 0;
}

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

int main()
{
	ios::sync_with_stdio(false);
	
	string a,b,c;
	cin>>a>>b>>c;
	int d=0,e=0,f=0;
	char s='a';
	
	for(int i=0;i<a.size()+b.size()+c.size();i++)
	{
		if(s=='a')
		{
			s=a[d];
			if(d==a.size())
			{
				cout<<"A"<<endl;
				return 0;
			}
			d++;
		}
		if(s=='b')
		{
			s=b[e];
			if(e==b.size())
			{
				cout<<"B"<<endl;
				return 0;
			}
			e++;
		}
		if(s=='c')
		{
			s=c[f];
			if(f==c.size())
			{
				cout<<"C"<<endl;
				return 0;
			}
			f++;
		}
	}
	
	return 0;
}

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

int arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
    int K;
    cin>>K;
    cout<<arr[K-1];
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
	"strings"
)

func mapf(f interface{}, list interface{}) interface{} {
	fv, listv := reflect.ValueOf(f), reflect.ValueOf(list)

	if fv.Kind() != reflect.Func || listv.Kind() != reflect.Slice {
		return nil
	}

	len := listv.Len()
	ret := reflect.MakeSlice(reflect.SliceOf(fv.Type().Out(0)), len, listv.Cap())

	for i := 0; i < len; i++ {
		v := fv.Call([]reflect.Value{listv.Index(i)})
		ret.Index(i).Set(v[0])
	}

	return ret.Interface()
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()

	arr, _ := mapf(strconv.Atoi, strings.Split(scanner.Text(), " ")).([]int)
	a, b, c := arr[0], arr[1], arr[2]

	n := 0
	for ; a <= b; a++ {
		if c%a == 0 {
			n++
		}
	}

	fmt.Println(n)
}



Measured memory_bytes: 1304
/*
	Nishant Singh
	nishant.ns19@gmail.com
*/
#include <bits/stdc++.h>
#include <functional> 
#include <iostream> 

// ******** Big Integer ********
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// #define ll1024  int1024_t
// ******** Big Integer ********

// ******** Using PBDS ********
// #include <ext/pb_ds/assoc_container.hpp> // Common file 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ook order_of_key    //count of strictly smaller elements
// #define fbo find_by_order   //find element at an index 
// ******** Using PBDS ********

using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vll vector<ll>
#define vec vector
#define setcount(x) __builtin_popcountll(x)
#define f first
#define s second
#define mp make_pair
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define REV(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define in insert
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
#define pq priority_queue
#define ffl fflush(stdout)
#define mset multiset
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define ub upper_bound
#define lb lower_bound 
#define ln "\n"
#define Y "YES"
#define N "NO"
ll const mod=1e9 + 7;
ll const inf=2e18;

// ******** Using PBDS ********
// typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//                 os; 
// ******** Using PBDS ********

inline ll add(ll a,ll b) 
{ 
	return (a%mod + b%mod + mod)%mod; 
}

inline ll mul(ll a,ll b) 
{ 
	return (a%mod * b%mod + mod)%mod; 
}

inline ll sub(ll a,ll b) 
{ 
	return (a%mod - b%mod + mod)%mod; 
}

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

ll modexp(ll x, ll n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}

ll modinv(ll n)
{
	return modexp(n,mod-2);
}

// ******** GLOBAL VARIABLES ********


// ******** GLOBAL VARIABLES ********

void solve(){
	string s;
	cin>>s;
	ll mx=0;
	if(s[0]=='R' && s[1]=='R' &&s[2]=='R')
		cout<<3<<ln;
	else if((s[0]=='R' && s[1]=='R') || (s[1]=='R' &&s[2]=='R'))
		cout<<2<<ln;
	else if(s[0]=='R' || s[1]=='R' || s[2]=='R')
		cout<<1<<ln;
	else
		cout<<0<<ln;
}  

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll T=1;
	// cin>>T; 	
	for(int t=1;t<=T;t++)
	{
		// cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<pair<int,int>> A(N);
  for(int i=0;i<N;i++){
    int X,L;
    cin>>X>>L;
    A[i]=make_pair(X+L,X-L);
  }
  sort(A.begin(),A.end());
  int k=0,r=0;
  for(int i=0;i<N;i++){
    r=A[i].first;
    k++;
    for(i++;i<N;i++)
      if(A[i].second>=r){
        i--;
        break;
      }
  }
  cout<<k<<endl;
}

Measured memory_bytes: 3976
use std::io;

fn main() {
    loop {
        let mut s = String::new();
        io::stdin().read_line(&mut s).expect("");
        s = s.trim().to_string();
        if s == "0" {
            break;
        }
        let mut sum = 0;
        for c in s.chars() {
            let x = match c {
                t @ '0'...'9' => t as i32- '0' as i32,
                _ => 0
            };
            sum += x;
        }
        println!("{}", sum);
    }
}


Measured memory_bytes: 5036
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
long long num[1000000];
int main()
{
    ll n,a,x=1e10,d=0,l=0;
    cin >> n;
    for (int i = 1; i <= n;++i)
    {
        cin >> num[i];
        a = abs(num[i]);
        d += a;
        if(num[i]<0)
        {
            ++l;
            
        }
        if(a<x)
        x = a;
    }
    if(l&1)
        cout << d - 2*x;
    else
        cout << d;
}

Measured memory_bytes: 3968
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int  N, ans=0, abcount =0, acount=0, bcount=0;
  std::cin >> N;
  range(i, N) {
    string s;
    std::cin >> s;
    if(s[0]=='B' && s[s.length()-1]=='A') abcount++;
    else if(s[0]=='B') bcount++;
    else if(s[s.length()-1]=='A') acount++;
    range(j, s.length()-1) if(s[j]=='A') if(s[j+1]=='B') ans++;
  }
  if(abcount==0){
    std::cout << ans+min(acount, bcount) << '\n';
  }else{
   std::cout << ans + (acount==0&&bcount==0?abcount-1:abcount+min(acount, bcount)) << '\n';
  }
  return 0;
}


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

int main() {
  int h,w;
  cin >> h >> w;
  
  string hedder_footer;
  for(int i = 0; i < w+2; i++){ hedder_footer += "#"; }
  cout << hedder_footer << endl;
  
  vector<string> vec(h);
  for (int i = 0; i < h; i++){
    cin >> vec.at(i);
    vec.at(i).insert(0,"#");
    vec.at(i) += '#';
    cout << vec.at(i) << endl;
  }
  
  cout << hedder_footer << endl;
}


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

int main()
{
    char a[10] = {0}, b[10] = {0}, c[10] = {0};
    scanf("%s%s%s", a, b, c);
    int lena = strlen(a), lenb = strlen(b);
    if (a[lena - 1] == b[0] && b[lenb - 1] == c[0])
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  
  int count = 0;
  for(int i = 0; i < 4; i++){
    if(s[i] == '+') count++;
    else count--;
  }
  
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

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

#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}

#define trace(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma=strchr(names+1,',');
    cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1,args...);
}

int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

int n,q;
vector<int> adj[M];
int value[M];

void dfs(int v, int par){
    for(auto u: adj[v]){
        if(u==par) continue;
        value[u]+=value[v];
        dfs(u,v);
    }
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> q;
    rep(i,1,n){
        ll a,b;
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    rep(i,1,q+1){
        int p,x;
        cin >> p >> x;
        value[p]+=x;
    }
    dfs(1,0);
    for(int i=1; i<=n; i++) cout << value[i] << " ";
    return 0;
}

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

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	int x = n / k;
	ll an = (ll)x * x * x;
	if (!(k & 1)){
		x = (n + (k >> 1)) / k;
		an += (ll)x * x * x;
	}
	printf("%lld\n", an);
}

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

def solve(S: int):
    S = list(map(int, list(str(S))))
    count = collections.defaultdict(int)

    count[0] = 1
    tmp = ''
    prev_modulo = 0
    for idx, s in enumerate(S[::-1]):
        prev_modulo = (s * pow(10, idx, 2019) + prev_modulo) % 2019
        count[prev_modulo] += 1

    result = 0
    for k, v in count.items():
        result += v * (v-1) // 2
    print(result)
    return


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

if __name__ == '__main__':
    main()


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

using namespace std;

int main()
{
    int n;
    
    while (scanf("%d", &n) && n){
        int I[257];
        
        for (int i = 1; i <= n; i++) scanf("%d", I + i);
        
        pair<int, pair<int, int> > res = make_pair(20, make_pair(20, 20));
        double mini = 1e30;
        for (int S = 0; S <= 15; S++){
            for (int A = 0; A <= 15; A++){
                for (int C = 0; C <= 15; C++){
                    int R[257];
                    int occ[256] = {0};
                    R[0] = S;
                    for (int i = 1; i <= n; i++){
                        R[i] = (A * R[i - 1] + C) % 256;
                    }
                    
                    for (int i = 1; i <= n; i++){
                        occ[(I[i] + R[i]) % 256]++;
                    }
                    
                    double H = 0;
                    for (int i = 0; i < 256; i++){
                        if (occ[i] != 0){
                            double X = occ[i] * 1.0 / n;
                            H -= X * log2(X);
                        }
                    }
                    if (H - mini < -1e-10){
                        res = make_pair(S, make_pair(A, C));
                        mini = H;
                    }
                }
            }
        }
        
        printf("%d %d %d\n", res.first, res.second.first, res.second.second);
    }
    
    return (0);
}

Measured memory_bytes: 1212
#include <cassert>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <limits>
#include <numeric>
#include <iterator>

using namespace std;



int main(){
  ios::sync_with_stdio(false);
  int n; // 1 .. 1000
  vector<int> w; // 1 .. 10^4
  cin >> n;
  for(int i = 0; i<n; ++i){int w_i; cin >> w_i; w.push_back(w_i);}
  
  vector<int> w2i(10000, -1);
  vector<int> w_sorted(w);
  sort(w_sorted.begin(), w_sorted.end());
  for(int i=0; i<n; ++i){
    w2i[w_sorted[i]] = i;
  }
  
  vector<bool> checked(10000, false);
  
  const int gm = *min_element(w.begin(), w.end()); //global minimum
  
  int ans = 0;
  for(int i = 0; i<n; ++i){
    if(checked[w[i]]) continue;
    else{
      checked[w[i]]=true;
      //cout << ">>" <<  w[i] << endl;
      
      int w_nxt  = w[w2i[w[i]]];
      int cm = w[i]; //minimum in cycle
      int c_size = 1;
      int c_wght = w[i];

      for(;w_nxt != w[i]; w_nxt=w[w2i[w_nxt]]){
	checked[w_nxt]=true;
	//cout << ">>" <<  w_nxt << endl;
	c_wght += w_nxt;
	++c_size;
	cm = min(cm, w_nxt);
      }
      
      int without_borrowing
	= cm * (c_size-2) + c_wght;
      int with_borrowing
	= gm * (c_size-2) + (c_wght-cm+gm) + 2 * (cm + gm);
	
      ans += min (with_borrowing, without_borrowing);
      //cout << ": "  << ans << endl;
    }
  }
  

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

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

def get_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=(n//i):
                divisors.append(n//i)
    return divisors

divs = get_divisors(N)
divs.sort()
if len(divs)%2==1:
    idx = (len(divs)-1) // 2
    print(2 * (divs[idx] - 1))

else:
    idx = len(divs)//2 - 1
    print(divs[idx] - 1 + divs[idx + 1] - 1)


Measured memory_bytes: 38896
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    String[] str = sc.nextLine().split(" ");
    int fiveCount = 0;
    int sevenCount = 0;
    
    for (String val : str) {
      if (val.equals("5")) fiveCount++;
      if (val.equals("7")) sevenCount++;
    }
    
    System.out.println((fiveCount == 2 && sevenCount == 1) ? "YES": "NO");
  }
}

Measured memory_bytes: 23636
// 8/29 リアルタイム参加
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};


int main() {
    int N, M;
    cin >> N >> M;

    UnionFind uf(N);

    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a, b);
    }

    int max_size = 0;
    rep(i, N) {
        max_size = max(uf.size(i), max_size);
    }

    cout << max_size << endl;
    return 0;
}

Measured memory_bytes: 4048
import sys
input = sys.stdin.readline

n = int(input())
a = [int(x) for x in input().split()]

mean = sum(a) / n

ans = [200, 200]

for i in range(n):
    if abs(mean - a[i]) < ans[1]:
        ans = [i, abs(mean - a[i])]

print(ans[0])


Measured memory_bytes: 38448
#include <stdio.h>

int gcm(int a, int b)
{
  int r;
  while (b > 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}

int main()
{
  int a, b, g, l;
  while (scanf("%d%d", &a, &b) != EOF) {
    g = gcm(a, b);
    l = a / g * b;
    printf("%d %d\n", g, l);
  }
  return 0;
}

Measured memory_bytes: 596
#include<stdio.h>

int S[1000000],n;
int binarySearch(int key){
  int left=0,right=n,M;
  while(left < right){
    M = (left + right)/2;
    if(key==S[M])return 1;
    if(key>S[M])left=M+1;
    else if(key<S[M])right = M;
  }
  return 0;
}

int main(){
  int i,q,k,C=0;

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

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&k);
    if(binarySearch(k))C++;
  }
  printf("%d\n",C);
}



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

int main(){
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    int max_x = -100, min_y = 100;
    int xi, yi;
    //vector<int> vx(n);
    //vector<int> vy(m);
    for(int i = 0; i < n; ++i){
        cin >> xi;
        if(max_x < xi) max_x = xi;
    }
    for(int j = 0; j < m; ++j){
        cin >> yi;
        if(yi < min_y) min_y = yi;
    }

    bool nowar = false;
    for(int z = -100; z <=100; z++){
        if(x < z && z <=y && max_x < z && z <= min_y){
            nowar = true;
            break;
        }
    }
    if(nowar){
        cout << "No War";
    }else{
        cout << "War";
    }
    cout << endl;
}

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	int x,y;
	cin>>x>>y;
	int ans=4*x-y;
	if(ans%2==0 && ans>=0 && ans<=y)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(k,i,n) for(long long i=k;i<n;++i)
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    ll N,max_a=0,a,c_max,imax,nemax_a;
    cin>>N;
    rep(0,i,N){
        cin>>a;
        if(max_a<a){
            c_max=1;
            nemax_a=max_a;
            max_a=a;
            imax=i;
        }else if(max_a==a){
            ++c_max;
        }else if(nemax_a<a){
            nemax_a=a;
        }
    }
    rep(0,i,N){
        if(c_max==1 && i==imax)cout<<nemax_a<<endl;
        else cout<<max_a<<endl;
    }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

struct Segmenttree{
    int n;
    vector<long long> node;

    Segmenttree(vector<long long> v){
        n = (int)(v.size());
        node.resize(2*n);
        for(int i=0;i<n;i++) node[i+n] = v[i];
        for(int i=n-1;i>=0;i--) node[i] = node[i<<1] + node[i<<1|1];
    }
    //i番目の要素にxを足す
    void update(int i,long long x){
        i += n;
        node[i] += x;
        while(i>1){
            i >>= 1;
            node[i] = node[i<<1] + node[i<<1|1];
        }
    }
    //[l,r)の要素の和を求める
    long long query(int l,int r){
        long long res = 0;
        l += n; r += n;
        while(l<r){
            if(l&1) res += node[l++];
            if(r&1) res += node[--r];
            l >>= 1; r >>= 1;
        }
        return res;
    }
    //i番目の要素にアクセス
    long long getval(int i){
        return node[i+n];
    }
};

int main(){
    int n,q;
    cin >> n >> q;
    Segmenttree seg(vector<ll>(n,0));
    while(q--){
        int t,x,y;
        cin >> t >> x >> y;
        if(t==0){
            --x;
            seg.update(x,y);
        }else{
            --x;--y;
            cout << seg.query(x,y+1) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5132
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	parts := strings.Split(s, "/")
	y, _ := strconv.Atoi(parts[0])
	m, _ := strconv.Atoi(parts[1])
	d, _ := strconv.Atoi(parts[2])
	if y <= 2019 {
		if m < 4 {
			fmt.Println("Heisei")
			return
		} else if m == 4 {
			if d <= 30 {
				fmt.Println("Heisei")
				return
			}
		}
	}
	fmt.Println("TBD")
}


Measured memory_bytes: 640
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define show_table(n, k, table) rep(i,n){ rep(j,k) cout << table[i][j] << " "; cout << endl;}

template<class T> void chmax(T& a,const T& b){a=max(a,b);}
template<class T> void chmin(T& a,const T& b){a=min(a,b);}

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 100005;

int main(){
  ll N; cin >> N;
  int ans = -INF,temp;
  rep(i,17){
    // i+1桁目を1つ下げて,それ以下i桁を全て9
    temp = 0;
    ll cmp = 1LL;
    rep(j,i) temp += 9, cmp *= 10LL;
    if(N<cmp-1) break;
    // cout << i << " "  << temp << " " <<  cmp << " " << N/cmp << endl;
    cmp = N / cmp;
    temp += max(cmp%10 - 1,0LL);
    cmp /= 10LL;
    REP(j,i+1,17){
      temp += cmp%10; cmp *= 10LL;
    }
    ans = max(ans,temp);
  }
  temp = 0;
  while(N>0) temp += N%10, N /= 10LL;
  ans = max(ans,temp);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

int N,sx,sy,field[8][9],dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
char c;

void bomb(int x,int y){
	field[y][x]=0;
	for(int i=0;i<4;i++){
		for(int j=1;j<4;j++){
			int nx=x+dx[i]*j,ny=y+dy[i]*j;
			if(nx>=0&&nx<8&&ny>=0&&ny<8&&field[ny][nx]==1)bomb(nx,ny);
		}
	}
}

int main(){
	cin>>N;
	for(int h=0;h<N;h++){
		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				cin>>c;
				field[i][j]=c-'0';
			}
		}
		cin>>sx>>sy;
		bomb(sx-1,sy-1);
		cout<<"Data "<<h+1<<":"<<endl;
		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				cout<<field[i][j];
			}
			cout<<endl;
		}
	}
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;

namespace MyProgram{
    class AtCoder{
        static void Main(){
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            int A = input[0];
            int B = input[1];
            int C = input[2];
            int X = input[3];
            int Y = input[4];
            int min_price=A*X+B*Y;
            for(var i=0;i<=Math.Max(X,Y);i++){
                int price = i*2*C + Math.Max(X-i,0) * A+ Math.Max(Y-i,0) * B;
                min_price = Math.Min(min_price,price);  
            }
            Console.WriteLine(min_price);

        }
    } 
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  string s;
  cin >> s;

  if (s.front() != 'A') {
    cout << "WA" << '\n';
    return 0;
  }

  int fst_c_idx = -1;
  for (int i = 2; i < s.size() - 1; ++i) {
    if (s[i] == 'C') {
      fst_c_idx = i;
      break;
    }
  }

  if (fst_c_idx < 0) {
    cout << "WA" << '\n';
    return 0;
  }

  bool ans = true;
  for (int i = 1; i < s.size(); ++i) {
    if (i == fst_c_idx) {
      continue;
    }

    if (s[i] >= 'A' && s[i] <= 'Z') {
      ans = false;
      break;
    }
  }

  cout << (ans ? "AC" : "WA") << '\n';
  return 0;
}

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

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define setIO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
#define trav(e, x) for (const auto &(e) : (x))
#define pb(x) push_back(x)
#define eb(x...) emplace_back(x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define lc(i) 2*i
#define rc(i) 2*i+1
//#define int long long
using namespace std;
using ii = pair<int, int>;
using vi = vector<int>;
using vb = vector<bool>;
using vii = vector<ii>;
using vivi = vector<vi>;

const int N = 1e5 + 5, MOD = 1e9 + 7, INF = 1e9 + 5;

signed main() {
    FAST_IO;
//    setIO("input.txt", "output.txt");

    int n;
    cin >> n;
    vii rolls(n);
    for (int i = 0; i < n; i++) cin >> rolls[i].first >> rolls[i].second;
    for (int i = 0; i <= n - 3; i++) {
        int cnt = 0;
        for (int j = i; j < i + 3; j++) {
            if (rolls[j].first == rolls[j].second) cnt++;
//            cout << rolls[j].first << " " << rolls[j].second << "\n";
        }
        if (cnt == 3) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main() {
	string str;
	int counter[2] = {0};
	int hantei = 0;

	getline(cin, str);
	
	for (int i = 0; i < str.length(); i++) {
		if (str[i] == '.' || str[i] == ',' || str[i] == ' ') {
			if (2 < counter[0] && counter[0] < 7 && hantei == 1) {
				cout << " " << str.substr(counter[1],counter[0]);
			} else if (2 < counter[0] && counter[0] < 7 && hantei == 0) {
				cout << str.substr(counter[1],counter[0]);
				hantei = 1;
			}
			counter[0] = 0;
		} else {
			if (counter[0] == 0) {
				counter[1] = i;
			}
			counter[0]++;
		}
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll) (1e9)
#define mod (ll) (1e9 + 7)
#define endl "\n"
#define tt ll testcase; cin>>testcase; while(testcase--)
 
int main(){
	fast;
	ll n, W;
	cin>>n>>W;
	int w[n], v[n];
	ll lim = 0;
	for(int i=0; i<n; i++){
		cin>>w[i]>>v[i];
		lim += v[i];
	}
	//dp[i] = min weight in value exactly i +

	vector<int>dp(lim+1, INF);
	dp[0] = 0;
	for(int i = 0; i<n; i++){
		for(int j = lim; j>=0; j--){
			if(j >= v[i]){ 
				dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
			}
		}
	}
	int ans = 0;
	for(int i=1; i<=lim; i++){
		if(dp[i] <= W){
			ans = max(ans, i);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define dbug(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef long long ll;
typedef pair<ll, ll> pll;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  return is;
}


int main(){

  int a,b,c;

  vector<int> r(3);

  cin>>r;

  SORT(r);

  if(r[1]==5&&r[0]==5&r[2]==7)
  {std::cout << "YES" << '\n';}
  else{
    std::cout << "NO" << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define forn(a,b,c) for(int a=b;a<=c;a++)
#define ford(a,b,c) for(int a=b;a>=c;a--)
#define f first
#define s second
typedef pair<int,int> pii;
const int N=2e5+5;
const int mod=998244353;
ll t[N],a[N];int n,h[N];
void update(int x,ll val) {
      while(x<=n) {
        t[x]=max(t[x],val);  x+=(x&-x);
      }
}
ll query(int x) {
     ll mx=0;
     while(x>0)  {
            mx=max(mx,t[x]);  x-=(x&-x);
     }
     return mx;
}
int main()
{
    scanf("%d",&n);
    forn(i,1,n){
        scanf("%d",&h[i]);
    }
    forn(i,1,n){
        scanf("%lld",&a[i]);
    }
    forn(i,1,n){
        ll best=query(h[i]-1);
        update(h[i],best+a[i]);
    }
    printf("%lld\n",query(n));
    return 0;
}


Measured memory_bytes: 4096