akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

bool isprime(int x){
    for(int i=2;i*i<=x;i++){
        if(x%i == 0) return false;
    }
    return true;
}

int main(){
    int x;
    cin>>x;
    int p = x;
    while(!isprime(p)) p++;
    cout<<p<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int H, W;
    cin >> H >> W;
    vector<vector<int>> d(10, vector<int>(10));

    rep(i, 10) {
        rep(j, 10) {
            cin >> d[i][j];
        }
    }

    rep(k, 10) {
        rep(i, 10) {
            rep(j, 10) {
                chmin(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    int ans = 0;
    rep(i, H) {
        rep(j, W) {
            int A;
            cin >> A;
            if (A == -1) continue;
            ans += d[A][1];
        }
    }

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

Measured memory_bytes: 256
from collections import *
import sys
try: inp = raw_input
except: inp = input
def err(s):
    sys.stderr.write('{}\n'.format(s))

def ni():
    return int(inp())

def nl():
    return [int(_) for _ in inp().split()]
N = inp()
if '7' in N:
    print('Yes')
else:
    print('No')


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

void A()
{
  int K, A, B;
  cin >> K >> A >> B;
  
  for( int i = A/K; i < B/K+1; ++i ){
  	if( A <= K*i && K*i <= B ){
      cout << "OK" << endl;
      return;
    }
  }

  cout << "NG" << endl;
}

void B()
{
  long long int X;
  cin >> X;
  
  long long int base = 100;
  long long int ans = 0;
  while( true ){
    ++ans;
    base = base * 1.01;
    
    if( X <= base ){
      cout << ans << endl;
      return;
    }
  } 
}

void C()
{
  int N, M, Q;
  cin >> N >> M >> Q;
  
  vector<int> a(Q), b(Q), c(Q), d(Q);
  for( int i = 0; i < Q; ++i )
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  
  vector<int> tmp(10);
  long long int zns = 0, ans = 0;    
  for( int i0 = 1; i0 <= M; ++i0 )
    for( int i1 = i0; i1 <= M; ++i1 )
      for( int i2 = i1; i2 <= M; ++i2 )
        for( int i3 = i2; i3 <= M; ++i3 )
          for( int i4 = i3; i4 <= M; ++i4 )
            for( int i5 = i4; i5 <= M; ++i5 )
              for( int i6 = i5; i6 <= M; ++i6 )
                for( int i7 = i6; i7 <= M; ++i7 )
                  for( int i8 = i7; i8 <= M; ++i8 )
                    for( int i9 = i8; i9 <= M; ++i9 ){
                      tmp[0] = i0; tmp[1] = i1; tmp[2] = i2; tmp[3] = i3; tmp[4] = i4;
                      tmp[5] = i5; tmp[6] = i6; tmp[7] = i7; tmp[8] = i8; tmp[9] = i9;
                      for( int i = 0; i < Q; ++i )
	                    if( tmp[b[i]-1] - tmp[a[i]-1] == c[i] ) zns += d[i];
                      if( ans < zns ) ans = zns;
                      zns = 0;
                    }
  
  cout << ans << endl;
}

int main()
{
  //A();
  //B();
  C();
  
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>

using namespace std;

int main(){
  string s;
  cin >> s;
  int answer = 700;
  for (int i = 0;i<s.size();i++) {
    if(s[i] == 'o')
    {
      answer += 100;
    }
  }
  cout << answer << endl;
}


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

using namespace std;
using ll=long long;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    constexpr ll inf=10000000;
    vector<ll> a(n);
    vector<ll> dp(n+4,inf);
    for(auto &b : a)cin>>b;
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    for(int i=2;i<n;++i){
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1792
<?php
list($s, $t) = fscanf(STDIN, '%s %s');
list($a, $b) = fscanf(STDIN, '%d %d');
list($u) = fscanf(STDIN, '%s');

if ($u === $s) {
    --$a;
} else {
    --$b;
}

echo sprintf('%d %d', $a, $b);


Measured memory_bytes: 4604
#include "stdio.h"

int main(void)
{
    int ensyu=0;
    int kensu=0;
    int i;

    scanf("%d",&ensyu);
    scanf("%d",&kensu);

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

    int a[kensu];
    for(i=0;i<kensu-1;i++)
    {
        a[i]=m[i+1]-m[i];
    }
    a[kensu-1] = ensyu-m[kensu-1]+m[0];

    int maxa=0;
    for(i=0;i<kensu;i++)
    {
        if(maxa <a[i])
        {
            maxa = a[i];
        }
    }

    int kyori=0;
    for(i=0;i<kensu;i++)
    {
        kyori= kyori+a[i];
    }
    kyori=kyori-maxa;

    printf("%d",kyori);
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n, p;
    cin >> n >> p;
    int n0, n1;
    n0 = n1 = 0;
    rep(i, n) {
        int a;
        cin >> a;
        if(a % 2 == 0) n0++;
        else n1++;
    }
    ll ans = 0;
    if(p % 2 == 0) {
        if(n1 == 0) ans = pow(2, n0);
        else ans = pow(2, n0 + n1 -1);
    } else {
        if(n1 == 0) ans = 0;
        else ans = pow(2, n0 + n1 - 1);
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
    int n,m;
    cin>>n>>m;
    priority_queue<int>q;
    rep(i,n){
        int a;
        cin>>a;
        q.push(a);
    }
    rep(i,m){
        int a=q.top(); q.pop();
        q.push(a/2);
    }
    ll ans=0;
    rep(i,n){
        ans+=q.top(); q.pop();
    }
    cout<<ans<<endl;

}

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

using namespace std;
int arr[4];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

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

    return 0;
}


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

int main() {
	// your code goes here
	int n;
	int x;
	cin>>n;
	vector<int> v(n);
	for(int i=0;i<n;i++){
		cin>>x;
		v[i]= x;
	}
	
	int count =0;
	for(int i=1;i<n-1;i++){
		if((v[i-1]<v[i] && v[i+1]>v[i]) || (v[i-1]>v[i] && v[i+1]<v[i])){
			count++;
		}
	}
	
	cout<<count<<"\n";
	return 0;
	
}

Measured memory_bytes: 384
from collections import deque


def calc_area(chars):
    s1 = deque()
    s2 = deque()
    area = 0

    for idx, char in enumerate(chars):
        if char == "\\":
            s1.append(idx)
        elif char == "/":
            if s1:
                left_idx = s1.pop()
                sub_area = idx - left_idx
                area = area + sub_area
                while s2 and left_idx < s2[-1][0]:
                    sub_area += s2.pop()[1]
                s2.append((left_idx, sub_area))
    return area, s2


def main():
    chars = input()
    area, s2 = calc_area(chars)
    print(area)
    text = ""
    count = 0
    while s2:
        text += " " + str(s2.popleft()[1])
        count += 1
    print(str(count) + text)


if __name__ == "__main__":
    main()



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

def solve():
    ABC = list(map(int, input().split()))
    n5 = 0
    n7 = 0
    for n in ABC:
        if n == 5:
            n5 += 1
        elif n == 7:
            n7 += 1
    
    if n5==2 and n7==1:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    solve()


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <string.h>

#define W_MAX 52
#define H_MAX 52

int f[H_MAX][W_MAX];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

void dfs1(int x,int y);
void dfs2(int x,int y);

using namespace std;

int main(void)
{
	int w,h;
	char c;
	int i1,i2;
	int count1,count2;

	while(1){
		cin >> w >> h;
		if(w+h==0) break;

		memset(f,-1,sizeof(f));

		for(i1=1;i1<=h;i1++){
			for(i2=1;i2<=w;i2++){
				cin >> c;
				if(c=='.') f[i1][i2]=0;
				else if(c=='B') f[i1][i2]=1;
				else if(c=='W') f[i1][i2]=2;
			}
		}

		for(i1=1;i1<=h;i1++){
			for(i2=1;i2<=w;i2++){
				if(f[i1][i2]==1) {
					f[i1][i2]=-1;
					dfs1(i2,i1);
				}
				else if(f[i1][i2]==2){
					f[i1][i2]=-1;
					dfs2(i2,i1);
				}
			}
		}

		count1=0;
		count2=0;
		for(i1=1;i1<=h;i1++){
			for(i2=1;i2<=w;i2++){
				if(f[i1][i2]==3) count1++;
				else if(f[i1][i2]==4) count2++;
			}
		}
		cout << count1 << " " << count2 << endl;
	}

	return 0;


}

void dfs1(int x,int y)
{
	int i1;
	int xx,yy;

	for(i1=0;i1<4;i1++){
		xx=x+dx[i1];
		yy=y+dy[i1];

		if(f[yy][xx]==0 || f[yy][xx]==4){
			f[yy][xx]+=3;
			dfs1(xx,yy);
		}
	}
}

void dfs2(int x,int y)
{
	int i1;
	int xx,yy;

	for(i1=0;i1<4;i1++){
		xx=x+dx[i1];
		yy=y+dy[i1];

		if(f[yy][xx]==0 || f[yy][xx]==3){
			f[yy][xx]+=4;
			dfs2(xx,yy);
		}
	}
}

Measured memory_bytes: 1212
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;

lint gcd(lint a, lint b) {
    lldiv_t apb = lldiv(a, b);
    return b ? gcd(b, a%b) : a;
}
lint lcm(lint a, lint b) {
    lint t = a * b;
    if (t < 0) return -1;
    return a / gcd(a, b) * b;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(N);
    rep(i, N) {
        int x;
        cin >> x;
        a[i] = x / 2;
    }

    lint l = a[0];
    for (int i = 1; i < N; i++) {
        l = lcm(l, a[i]);
        if (l > M) {
            cout << "0" << endl;
            return 0;
        }
        if (l < 0) {
            cout << "0" << endl;
            return 0;
        }
    }

    rep(i, N) {
        if (l % (2 * a[i]) != a[i]) {
            cout << "0" << endl; return 0;
        }
    }

    lint res = (M - l);
    res /= l;
    res /= 2;
    res++;

    cout << res << endl;
    return 0;
}


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

int main(){
  string S;
  cin>>S;
  int j=0;
  for(int i=0;i<S.size();i++)
    if(S[i]==to_string(i%2)[0])
      j++;
  cout<<min(j,(int)S.size()-j)<<endl;
}

Measured memory_bytes: 512
S = input()
INC = '<'
DEC = '>'
icnt = 0
dcnt = 0
mode = DEC
ans = 0
for c in S:
  if mode == DEC:
    if c == DEC:
      dcnt += 1
    elif c == INC:
      if icnt <= dcnt:
        ans += (dcnt + 1) * dcnt // 2
      else:
        ans += icnt + dcnt * (dcnt - 1) // 2
      icnt = 1
      mode = INC
  elif mode == INC:
    if c == INC:
      icnt += 1
    elif c == DEC:
      ans += icnt * (icnt - 1) // 2
      dcnt = 1
      mode = DEC
if mode == INC:
  ans += (icnt + 1) * icnt // 2
elif mode == DEC:
  if icnt <= dcnt:
    ans += (dcnt + 1) * dcnt // 2
  else:
    ans += icnt + dcnt * (dcnt - 1) // 2
print(ans)

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

#define ll long long
#define ull unsigned long long
#define mod 998244353
#define INF 1 << 30
#define MAX (1 << 20)
#define NINF (-(1 << 30))
#define triplet pair<pair<int, int>, int>

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

    ll a, b, c, d;

    cin >> a >> b >> c >> d;

    cout << max(max(a*c, b*d), max(a*d, b*c)) << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define H first
#define R second

typedef pair<int, int> pii;

int main ( void )
{
	int n, m;
	
	while (cin >> n, n)
	{
		int h, r;
		vector<pii> iv, jv;
		
		for (int i = 0; i < n; ++i)
		{
			cin >> h >> r;
			iv.push_back(make_pair(h, r));
		}
		
		cin >> m;
		
		for (int i = 0; i < m; ++i)
		{
			cin >> h >> r;
			jv.push_back(make_pair(h, r));
		}
		
		for (int i = jv.size()-1; i >= 0; --i)
		{
			pii ip = iv[iv.size()-1], jp = jv[i];
			
			if (ip.H < jp.H && ip.R < jp.R) 
			{
				iv.push_back(jp);
				continue;
			}
			
			ip = iv[0];
			if (jp.H < ip.H && jp.R < ip.R)
			{
				iv.insert(iv.begin(), jp);
				continue;
			}
			
			for (int j = iv.size()-2; j >= 0; --j)
			{
				pii &f = iv[j], &b = iv[j+1]; // front, back
				
				if (f.H < jp.H && f.R < jp.R && jp.H < b.H && jp.R < b.R)
				{
					iv.insert(iv.begin()+(j+1), jp);
					break;
				}
				if (f.H <= jp.H && f.R <= jp.R && jp.H < b.H && jp.R < b.R)
				{
					f = jp;
					break;
				}
			}
		}

		cout << iv.size() << endl;
	}

	return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

#define mod 1000000007

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);

	int minI = 1, maxI = 1;
	for(int i = 1; i < n; i++) {
		cin >> a[i];
		minI = (a[i] < a[minI]) ? i : minI;
		maxI = (a[i] > a[maxI]) ? i : maxI;
	}
	int piv = minI;
	if (a[minI] + a[maxI] > 0) {
		piv = maxI;
	}

	cout << 2 * n - 1 << endl;
	for(int i = 1; i <= n; i++) {
		cout << piv << " " << i << endl;
	}
	if (a[piv] > 0) {
		for(int i = 1; i <= n - 1; i++) {
			cout << i << " " << i + 1 << endl;
		}
	}
	else {
		for(int i = n; i >= 2; i--) {
			cout << i << " " << i - 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[2100];
int dp[2100][2100][2];
int n;
int solve(int a,int b,int c){
	if(~dp[a][b][c])return dp[a][b][c];
	if(max(a,b)==n-1){
		return dp[a][b][c]=ABS(p[a]-p[b]);
	}
	int ret=0;
	int ch=max(a,b)+1;
	if(c==0){
		ret=max(solve(ch,b,1),solve(ch,b,0));
	}else{
		ret=min(solve(a,ch,1),solve(a,ch,0));
	}
	return dp[a][b][c]=ret;
}
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	n=a+2;
	p[0]=b;
	p[1]=c;
	for(int i=0;i<a;i++)scanf("%d",p+i+2);
	for(int i=0;i<2100;i++)for(int j=0;j<2100;j++)dp[i][j][0]=dp[i][j][1]=-1;
	printf("%d\n",solve(0,1,0));
}

Measured memory_bytes: 34816
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int N; cin >> N;
    set<string> st;

    vector<string> w(N);
    rep(i,N){
        cin >> w[i];

        if(st.count(w[i])){
            cout << "No" << endl;
            return 0;
        }

        if(i){
            if(w[i][0] != w[i-1][w[i-1].size()-1]){
                cout << "No" << endl;
                return 0;
            }
        }

        st.insert(w[i]);
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<char> vc;
typedef map<long long,long long> mpi;
#define vbi vector<bool> 
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define endl '\n'
#define cnl cout<<endl;
#define frr(i,b) for(ll i=0; i<b;i++)
#define fb(i,b) for(ll i=b-1; i>=0; i--)
#define pi  3.141592653589793238
#define ms(x,v) memset(x,v,sizeof(x))
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define deb(x) cout<<#x<<" = "<<x<<"\n";
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
const int N = 2e5 + 5;
ll i,j,k;
void solve()

{
 
 ll a,b; cin>>a>>b;
 ll x=__gcd(a,b);
 ll y= (a*b);
 ll ans=y/x;
 cout<<ans<<endl;
 return ; 
 
}
signed main(){
   
 //CASET
         solve();
  

 
    return 0;
}



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

int main()
{
    map<string,ll>mp;
    mp["SUN"] = 7;
    mp["MON"] = 6;
    mp["TUE"] = 5;
    mp["WED"] = 4;
    mp["THU"] = 3;
    mp["FRI"] = 2;
    mp["SAT"] = 1;

    string s;
    cin>>s;
    cout<<mp[s];
    return 0;
}


Measured memory_bytes: 256
import itertools
n = int(input())
plis = list(map(int, input().split()))
qlis = list(map(int, input().split()))
lis = list(itertools.permutations(range(1, n+1)))
n = 1
for i in lis:
    if list(i) == plis:
        a = n
    if list(i) == qlis:
        b = n
    n += 1
print(abs(a-b))

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

#define INF 1e9
using namespace std;
using ll = long long;

int main() {

    ll N, X; cin >> N >> X;

    ll tmp = 0;

    vector<ll> m(N);
    for (int i = 0; i < N; ++i) {
        cin >> m[i];
        tmp += m[i];
    }

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

    ll ans = N;

    tmp += m[0];

    while (tmp <= X) {
        ++ans;
        tmp += m[0];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */
/* include {{{ */
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
using namespace std;
/* }}} */

// #define int long long

/* cpp template {{{ */
/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}
inline bool inside(int y, int x, int H, int W) {return (y >= 0 && x >= 0 && y < H && x < W);}

/* }}} */

int n;
int a[100];
ll dp[101][21];

ll dfs(int now, int sum)
{
  if (!(0 <= sum && sum <= 20)){
    return 0;
  }

  if (dp[now][sum] != -1){
    return dp[now][sum];
  }
  
  if (now == n - 1){
    if (sum == a[n - 1]){
      return 1;
    } else {
      return 0;
    }
  }
  
  return dp[now][sum] = dfs(now + 1, sum - a[now]) + dfs(now + 1, sum + a[now]);
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  memset(dp, -1, sizeof(dp));

  cin >> n;
  REP(i, n) cin >> a[i];

  print(dfs(1, a[0]));

  return (0);
}

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

int main(){
    ll q, c, x;
    set<ll> s;
    cin >> q;
    for(ll i = 0; i < q; i++){
        cin >> c >> x;
        if (c == 0){
            s.insert(x);
            cout << s.size() << endl;
        }else{
            if (s.find(x) != s.end()){
                cout << "1" << endl;
            }else{
                cout << "0" << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 12456
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main() {
	string s; cin >> s;
	int k; cin >> k;
	vector<string> v;

	for (int l = 0; l < s.size(); l++) {
		for (int r = 1; r <= k; r++) {
			v.push_back(s.substr(l, r));
		}
	}
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());

	cout << v[k - 1] << endl;
	return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

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

vi G[N];
bool yes[N], ok = true;
int color[N], mx[N], mn[N], d[N];

int root;

void dfs(int u, int p = -1, int depth = 0) {
	d[u] = depth;
	if(yes[u]) {
		mn[u] = color[u] + d[u];
		mx[u] = color[u] - d[u];
		if((color[u] + depth) % 2 != color[root] % 2)
			ok = false;
	}
	int mxx = -INF, mnn = INF;
	for(int v:G[u]) if(v != p ){
		dfs(v, u, depth + 1);
		mnn = min(mnn, mn[v]);
		mxx = max(mxx, mx[v]);
	}
	if(mxx > mnn - 2 * d[u]) ok = false;
	if(yes[u]) {
		if(mxx > mx[u]) ok = false;
		if(mnn < mn[u]) ok = false;
	}
	mx[u] = max(mx[u], mxx);
	mn[u] = min(mn[u], mnn);
}

bool can(int u, int val, int p) {
	if(yes[u]) return val == color[u];
	int mymn = val + d[u];
	int mymx = val - d[u];
	int mxx = -INF, mnn = INF;
	for(int v:G[u]) if(v != p){
		mnn = min(mnn, mn[v]);
		mxx = max(mxx, mx[v]);
	}
	if(mxx > mymx) return false;
	if(mnn < mymn) return false;
	return true;
}

void dfs1(int u, int p = -1) {
	for(int v:G[u]) if(v != p) {
		if(can(v, color[u]+1, u)) {
			color[v] = color[u] + 1;
		} else{
			color[v] = color[u] - 1;
		}
		dfs1(v, u);
	}
}

signed main()
{
	IO_OP;
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
		mx[i] = -INF, mn[i] = INF;
	for(int i=0;i<n-1;i++) {
		int u, v;
		cin >> u >> v;
		G[u].PB(v);
		G[v].PB(u);
	}
	int k;
	cin >> k;
	for(int i=0;i<k;i++) {
		int v, c;
		cin >> v >> c;
		yes[v] = 1;
		color[v] = c;
		root = v;
	}
	dfs(root);
	if(!ok) {
		cout << "No" << endl;
		return 0;
	}
	dfs1(root);
	cout << "Yes" << endl;
	for(int i=1;i<=n;i++)
		cout << color[i] << endl;
}





Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    ll x;
    cin>>x;
    ll p1=x/500,p2;
    x=x%500;
    p2=x/5;
    cout<<p1*1000+p2*5<<endl;
}

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

def count_kuro(c, bit_i, bit_j):
    list_i = []
    for i in range(H):
        if bit_i>>i&1:
            list_i.append(i)
    list_j = []
    for j in range(W):
        if bit_j>>j&1:
            list_j.append(j)

    tansaku = [
        (i,j) for i in range(H) for j in range(W)
        if i in list_i and j in list_j
    ]

    return sum([c[dot[0]][dot[1]]=='#' for dot in tansaku])


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

c = []
for i in range(H):
    c.append(list(input()))

count = 0
for bit_i in range(2**H):
    for bit_j in range(2**W):
        num_kuro = count_kuro(c, bit_i, bit_j)
        if num_kuro == K:
            count+=1

print(count)

Measured memory_bytes: 9260
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	S := getString()
	m := make([]int, 26)
	for _, v := range S {
		m[v-'a'] = 1
	}
	ans := "None"
	for i := 0; i < 26; i++ {
		if m[i] == 0 {
			ans = string('a' + i)
			break
		}
	}
	out(ans)
}


Measured memory_bytes: 896
import java.util.*;
class Main {
    public static void main (String[] args){
        Scanner sc = new Scanner(System.in);
        while(true) {
            int H = sc.nextInt(), W = sc.nextInt();
            if(H == 0 && W == 0) break;
            for(int i = 0; i < H; i++) {
                for(int j = 0; j < W; j++) {
                    if((i==0) || (i==(H-1)) || (j==0) || (j==W-1)) {
                        System.out.print("#");
                    }else{
                        System.out.print(".");
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 34248
#include <iostream>

using namespace std;

int main()
{
    long long N;
    cin >> N;

    long long cnt = 0, prev = 0;

    while (true)
    {
        if (cnt * cnt > N)
        {
            cout << prev << endl;
            break;
        }
        prev = cnt * cnt;
        cnt++;
    }

    return 0;
}

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

int main(void){
  int n,m;cin>>n>>m;
  vector<int> p(m),y(m);
  vector<vector<int>> py(n,vector<int>(0));
  for(int i=0; i<m; ++i){ cin>>p[i]>>y[i]; py[p[i]-1].push_back(y[i]);}
  for(int i=0; i<n; ++i) sort(py[i].begin(), py[i].end());
  for(int i=0; i<m; ++i) y[i]=1+lower_bound(py[p[i]-1].begin(),py[p[i]-1].end(),y[i])-py[p[i]-1].begin();
  for(int i=0; i<m; ++i) printf("%06d%06d\n",p[i],y[i]);
  return 0;
}


Measured memory_bytes: 9356
#include<iostream>
#include<cstring>
#include<string>
#include <bitset>
#include <type_traits>
#include <string>
#include <climits>



using namespace std;

int main(){
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif

	string s, t;

	cin >> s;
	cin >> t;

	// cout << s << endl;
	// cout << t << endl;

	int mini = numeric_limits<int>::max();
	int now = 0;

	for(int i=0;i<s.length()-t.length()+1;i++){
		now = 0;
		for(int k=0;k<t.length();k++){
			if(s[i+k]!=t[k]){
				now++;
			}
		}
		if(now<mini){
			mini = now;
		}
	}

	cout << mini << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    string s[n];
    for(int i = 0; i < n; i++){
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }
    sort(s, s+n);
    unsigned long long ans = 0;
    int left = 0;
    int right = 0;
    long long tmp = 0;
    for(int i = 0; i < n-1; i++){
        if(s[i] != s[i+1]){
            right = i+1;
            tmp = right - left;
            ans += tmp * (tmp-1) / 2;
            left = i+1;
        }
    }
    right = n;
    tmp = right - left;
    ans += tmp * (tmp-1) / 2;
    cout << ans <<endl;
    return 0;
}


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

int main(){ 
    vector<char>a(3);
    vector<char>b(3);
    vector<char>c(3);
    for(int i=0;i<3;i++)cin >> a[i];
    for(int i=0;i<3;i++)cin >> b[i];
    for(int i=0;i<3;i++)cin >> c[i];
    cout << a[0]<<b[1] << c[2] << endl;
 }

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

int main(){
  int A,B,C,flag=0;
  cin >> A >> B >> C;

  for(int i=1;i<101;i++){
    if(A*i%B==C){
      flag=1;
    }
  }
  if(flag==1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
<?php
  fscanf(STDIN, "%d %d", $dobutsu, $ashi);
  for($i = 0;$i <= $dobutsu;$i++) {
      $tsuru = $i;
      $kame = $dobutsu - $tsuru;
    
      if($ashi === ($tsuru * 2 + $kame * 4)) {
        echo "Yes";
        exit(0);
      }
  }
  echo "No";

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

const int mas_num = 753;

int main() {
  string s; cin >> s;
  int min_diff = 1000;
  
  for (int i = 0; i < s.size() - 2; ++i) {
    int n = stoi(s.substr(i, 3));
    min_diff = min(min_diff, abs(n - mas_num));
  }
  
  cout << min_diff << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void W(int line[],int temp[]){
    line[0]=temp[2];
    line[3]=temp[0];
    line[5]=temp[3];
    line[2]=temp[5];
}
void S(int line[],int temp[]){
    line[1]=temp[0];
    line[5]=temp[1];
    line[4]=temp[5];
    line[0]=temp[4];
}
void E(int line[],int temp[]){
    line[2]=temp[0];
    line[5]=temp[2];
    line[3]=temp[5];
    line[0]=temp[3];
}
void N(int line[],int temp[]){
    line[1]=temp[5];
    line[0]=temp[1];
    line[4]=temp[0];
    line[5]=temp[4];
}
int main(void){
    int line[6],i,t,temp[6];
    char ope[101];
    for(i=0;i<6;i++)
        scanf("%d",&line[i]);
    scanf("%s",ope);
    t=0;
    while(ope[t]){
        for(i=0;i<6;i++)
            temp[i]=line[i];
        if(ope[t]=='W')
            W(line,temp);
        else if(ope[t]=='S')
            S(line,temp);
        else if(ope[t]=='E')
            E(line,temp);
        else
            N(line,temp);
        t++;
    }
    printf("%d\n",line[0]);
    return 0;
}



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

int main(){
    long long n,k,c,d,sum = 0,ans;
    cin >> n >> k;
    map<long long,int> a;

    for(int i = 0;i < n;i++){
        cin >> c >> d;
        a[c] += d;
    }
    for(auto m : a){
        ans = m.first;
        sum += m.second;
        if(sum >= k)break;
    }
    cout << ans << endl;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  if(a>=13)	cout << b << endl;
  else if(a>5)	cout << b/2 << endl;
  else	cout << 0 << endl;
  
  return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>

int main(){
  int w,h,x,y,r;
  scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
  if(x-r<0 || y-r<0 || x+r>w || y+r>h) printf("No\n");
  else printf("Yes\n");
  return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  string s;
  cin >> s;
  string t = "ATGC";

  ll n = SZ(s), m = SZ(t);

  ll ans = 0;
  REP(i, n) {
    ll cnt = 0;
    FOR(j, i, n) {
      bool ok = true;
      REP(k, m) {
        if (s[j] == t[k]) {
          cnt++;
          break;
        }
        if (k == m - 1) {
          ok = false;
        }
      }
      if (!ok) break;
    }
    ans = max(ans, cnt);
  }
  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 REP(i,n) for(int i=1;i<=n;i++)
typedef long long ll;
const ll MOD = 1000000007;

//A:0 C:1 G:2 T:3
ll dp[105][4][4][4];

int main(){
	int n;
	cin >> n;
	
	//dp初期条件,最初の二桁は何を使っても良い。
	rep(j,4){
		rep(k,4){
			rep(l,4){
				dp[2][j][k][l] = 1;
			}
		}
	}
	
	dp[2][1][2][0] = dp[2][2][1][0] = dp[2][1][0][2] = 0;
	
	for (int i = 2; i < n-1; ++i) {
		rep(j,4){
			rep(k,4){
				rep(l,4){
					rep(m,4){
							if(m == 1 && l == 2 && k == 0) continue; //AGC
							if(m == 2 && l == 1 && k == 0) continue; //ACG
							if(m == 1 && l == 0 && k == 2) continue; //GAC
							if(m == 1 && k == 2 && j == 0) continue; //AG?C
							if(m == 1 && l == 2 && j == 0) continue; //A?GC
							dp[i+1][m][l][k] += dp[i][l][k][j] % MOD;
					}
				}
			}
		}
	}
	
	ll ans = 0;
	
	rep(j,4){
		rep(k,4){
			rep(l,4){
				ans += dp[n-1][j][k][l];
				ans %= MOD;
			}
		}
	}
	
	cout << ans  << endl;
	
    return 0;
}

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

using namespace std;

long long int dp[51][51][2501]={0,};

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n,a,t;
	vector <int> v;

	cin >> n >> a;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		v.push_back(t);
	}

	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++)
	{
		dp[i][1][v[i-1]] = 1;
		for(int j=1;j<=i;j++)
		{
			for(int k=0;k<=2500;k++)
			{
				dp[i][j][k] += dp[i-1][j][k];
				if(k-v[i-1]>=0)
				{
					dp[i][j][k] += dp[i-1][j-1][k-v[i-1]];
				}
			}
		}
	}
	/*
	for(int i=1;i<=3;i++)
	{
		for(int j=1;j<=3;j++)
		{
			for(int k=0;k<=3;k++)
			{
				cout << dp[i][j][k] << ' ';
			}
			cout << '\n';
		}
		cout << '\n';
	}
	cout << '\n';
	*/
	
	long long int res = 0;
	for(int i=1;i<=n;i++)
	{
		res += dp[n][i][i*a];
	}
	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 51072
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
int main() {
string S="";
int Q;
cin>>S>>Q;
map<int,string> SS;
int p=0;
int q=1;
int r=0;
for(int i=0;i<Q;i++){
  int t,f;
  char C;
  cin >>t;
  if(t==1){
  r++;
  }else{
    cin>>f>>C;
  if((f==1&r%2==0)|(f==2&r%2==1)){
    SS[p]=C;
  	p--;
  }else{
  SS[q]=C;
    q++;
  }
  }
}
  string ansa="";
  string ansb="";;
  for(int i=p+1;i<q;i++){
  if(i<=0){ansa+=SS[i];}else{ansb+=SS[i];}
  }
  string ans=ansa+S+ansb;
if(r%2==1){reverse(ans.begin(),ans.end());}
  cout<<ans;
}

Measured memory_bytes: 23044
#include <bits/stdc++.h>
using namespace std;
inline void solve(){
	string s,t;cin>>s>>t;
	bool f=1;
	int i;
	for(i=0;i<s.length();i++){
		if(s[i]==t[i]){
			continue;
		}
		else {f=0;cout<<"No";break;}
	}
	if(f)cout<<"Yes\n";
	return;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	solve();
	return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n;
  cin >> n;
  vector<int> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (xs[i] == count + 1) {
      count++;
    }
  }
  int ans = n - count;
  if (count == 0) ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 1024
object Main extends App {
  @scala.annotation.tailrec
  def loop(i: Int, ints: Seq[Int]): String = ints match {
    case Seq() => "Yes"
    case x :: xs if x <= i + 1 => loop(x min i, xs)
    case _ => "No"
  }

  val sc = new java.util.Scanner(System.in)
  val i :: ints = Seq.fill(sc.nextInt())(sc.nextInt()).reverse
  println(loop(i, ints))
}

Measured memory_bytes: 54732
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int N; cin >> N;
VI A(N); rep(i, 0, N) cin >> A[i];

ll cnt=0;
int right = 0, sum=0;
rep(left, 0, N){
    while(right < N && (sum ^ A[right]) == (sum + A[right])){
        sum += A[right];
        ++right;
    }
    cnt += right - left;
    if (left == right) ++right;
    else sum -= A[left];
}

cout << cnt << "\n";

return 0;
}

// 境界，出力文字列 チェック



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<map>
#include<queue>


using namespace std;
#define mod 1000000007
#define ll long long 

ll n, k;
ll arr[409];
ll pre[409];
ll dp[409][409];

ll solve(int idx, int jdx) {
	if(idx == jdx)
		return 0;

	if(idx > jdx)
		return 0;
	if(dp[idx][jdx] != -1)
		return dp[idx][jdx];

	ll ans = 1e18;

	for(int i = idx; i < jdx; i++) {
		ans = min(ans, solve(idx , i) + solve(i + 1, jdx) + pre[ jdx + 1] - pre[idx]);
	}
	return dp[idx][jdx] = ans;
}


int main() {
	memset(dp, -1, sizeof(dp));
	cin>>n;
	pre[0] = 0;
    for(int i = 0; i < n; i++) {
    	scanf("%lld", &arr[i]);
    	pre[i + 1] = pre[i] + arr[i];
    }
    cout<<solve(0, n-1)<<endl;
}

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

int main(void){

    int N, A,B;
    scanf("%d %d %d",&N, &A, &B);
    A = N*A;
    if(A>B){
        printf("%d\n",B);
    }
    else{
        printf("%d\n",A);
    }
    return 0;
}

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

int A[500010];

int main() {
    string S;
    cin >> S;

    rep(i, S.size()+1) A[i] = 0;
    
    for (int i=0; i<S.size(); i++) {
        if (S[i] == '<') A[i+1] = A[i] + 1;
    }
    for (int i=S.size()-1; i>=0; i--) {
        if (S[i] == '>') A[i] = max(A[i], A[i+1]+1);
    }

    ll ans = 0;
    rep(i, S.size()+1) ans += A[i];

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



Measured memory_bytes: 2820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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; }






int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	sort(a.begin(),a.end());
	vector<pii> b(m);
	rep(i,m) cin >> b.at(i).second >> b.at(i).first;
	sort(b.rbegin(),b.rend());
	int k = 0;
	rep(i,n){
		if(k < m && a.at(i) < b.at(k).first){
			a.at(i) = b.at(k).first;
			b.at(k).second--;
			if(b.at(k).second == 0) k++;
		}
	}
	ll ans = 0;
	rep(i,n) ans += a.at(i);
	cout << ans << endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int main() {
	int n;
	std::cin >> n;
	int w[n];
	for (int i = 0; i < n; i++) {
	    std::cin >> w[i];
	}
	
	int ans = 10000, ls = 0, rs = 0;
	for (int i = 1; i < n; i++) {
	    
	    ls=0, rs=0;
	    
	    for (int j = 0; j < i; j++) {
	        ls += w[j];
	        //std::cout << j << std::endl;
	    }
	    
	    for (int k = i; k < n; k++) {
	        rs += w[k];
	        //std::cout << k << std::endl;
	    }
	    //std::cout << i << " " << ls << " " << rs << " " << abs(ls- rs) << std::endl;
	    ans = min(ans, abs(ls - rs));
	}
	
	std::cout << ans << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
w, h, n = [int(i) for i in input().split()]
W = set(range(w))
H = set(range(h))
for i in range(n):
    x, y, a = [int(i) for i in input().split()]
    if a == 1:
        W &= set(range(x, w))
    elif a == 2:
        W &= set(range(0, x))
    elif a == 3:
        H &= set(range(y, h))
    elif a == 4:
        H &= set(range(0, y))
print(len(W) * len(H))


Measured memory_bytes: 3064
s = input()
q = int(input())

printlist = []

for _ in range(q):
    c = list(map(str, input().split()))
    start = int(c[1])
    end = int(c[2]) + 1

    if c[0] == "print":
        printlist.append(s[start:end])
    elif c[0] == "reverse":
        r = s[start:end]
        sr = r[::-1]
        s = s[:start] + sr + s[end:]
    elif c[0] == "replace":
        r = c[3]
        s = s[:start] + r + s[end:]

for p in printlist:
    print(p)


Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
string s;
ll sum;
int main(){
   cin>>s;
   for(int i=0;i<s.size();i++)
   {
   	  sum+=s[i]-48;
   }
   if(sum%9==0)cout<<"Yes";
   else cout<<"No";


	return 0;
}


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

int main() {
    cout.tie(0)->sync_with_stdio(0);
    int N; cin >> N;
    vector<int> values(N);
    for (int& x : values) cin >> x;
    if (N == 1) {
        cout << "1\n";
    }
    else {
        sort(values.begin(), values.end());
        const int M = 2 * values.back();
        vector<int> freq(2*M+2);
        for (int X : values) {
            if (freq[X] > 0) {
                ++freq[X];
                continue;
            }
            ++freq[X];
            for (int p = 2*X; p <= 2*M; p += X)
                ++freq[p];
        }
        int res = 0;
        for (int X : values) {
            if (freq[X] != 1) continue;
            ++res;
        }
        cout << res << '\n';
    }
}


Measured memory_bytes: 19552
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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 long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

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

    int N;cin >> N;
    vector<long long> retu(N);
    vector<int> moto(30);
    for(int i = 0;i<N;i++){
        cin >> retu.at(i);
        bitset<30> B(retu.at(i));
        for(int i = 0;i<30;i++){
            if(B.test(i)) moto.at(i)++;
            moto.at(i) %= 2;
        }
    }
    for(int i = 0;i<N;i++){
        vector<int> BB;BB = moto;
        bitset<30> BIT(retu.at(i));
        for(int j = 0;j<30;j++){
            if(BIT.test(j)) BB.at(j)--;
            if(BB.at(j) < 0) BB.at(j)+=2;
            BB.at(j) %= 2;
        }
        long long ans = 0;
        long long now = 1;
        for(int j = 0;j<30;j++){
            if(BB.at(j) == 1) ans += now;
            now *= 2;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 4712
#include<iostream>
using namespace std;
int main() {
	char ch;
	int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;
	
	a=b=c=d=e=f=g=h=i=j=k=l=m=n=o=p=q=r=s=t=u=v=w=x=y=z=0;
	
	while (cin.get(ch)){
	    
	        if(ch>='A' && ch<='Z')
	            ch=ch+32;

		     if (ch == 'a')a++;
		else if (ch == 'b')b++;
		else if (ch == 'c')c++;
		else if (ch == 'd')d++;
		else if (ch == 'e')e++;
		else if (ch == 'f')f++;
		else if (ch == 'g' )g++;
		else if (ch == 'h')h++;
		else if (ch == 'i')i++;
		else if (ch == 'j')j++;
		else if (ch == 'k')k++;
		else if (ch == 'l')l++;
		else if (ch == 'm')m++;
		else if (ch == 'n')n++;
		else if (ch == 'o')o++;
		else if (ch == 'p')p++;
		else if (ch == 'q')q++;
		else if (ch == 'r')r++;
		else if (ch == 's')s++;
		else if (ch == 't')t++;
		else if (ch == 'u')u++;
		else if (ch == 'v')v++;
		else if (ch == 'w')w++;
		else if (ch == 'x')x++;
		else if (ch == 'y')y++;
		else if (ch == 'z')z++;
	}
	cout << "a : " << a << endl;
	cout << "b : " << b << endl;
	cout << "c : " << c << endl;
	cout << "d : " << d << endl; 
	cout << "e : " << e << endl;
	cout << "f : " << f << endl; 
	cout << "g : " << g << endl;
	cout << "h : " << h << endl; 
	cout << "i : " << i << endl;
	cout << "j : " << j << endl; 
	cout << "k : " << k << endl;
	cout << "l : " << l << endl;
	cout << "m : " << m << endl;
	cout << "n : " << n << endl;
	cout << "o : " << o << endl;
	cout << "p : " << p << endl;
	cout << "q : " << q << endl;
	cout << "r : " << r << endl;
	cout << "s : " << s << endl;
	cout << "t : " << t << endl;
	cout << "u : " << u << endl;
	cout << "v : " << v << endl;
	cout << "w : " << w << endl;
	cout << "x : " << x << endl;
	cout << "y : " << y << endl;
	cout << "z : " << z << endl;
	
	return 0;
}


Measured memory_bytes: 3096
# try-except is necessary for avoiding Runtime Error 
while 1:
	try:
		n,m=map(int,raw_input().split())
		if n==0:break
		v=sorted(map(int,raw_input().split()))[::-1]
		for i in range(m-1,n,m):
			v[i]=0
		print sum(v)
	except:
		pass

Measured memory_bytes: 4292
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  string S;
  cin>>N>>S;
  S.erase(unique(ALL(S)),S.end());
  cout<<S.length()<<endl;
}


Measured memory_bytes: 512
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int a[3];
int main(void){
    int p,q;cin >> p >> q;
    a[--p]++;
    a[--q]++;
    for(int i =0;i < 3;i++)if(a[i] == 0){
        cout << i+1 << endl;
    }
}


Measured memory_bytes: 256