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

using namespace std;

int main() {
	int n, prv, len;
	char teks[15];
	bool valid = true;
	string kata;
	map<string, int> peta;
	scanf("%d\n%s\n", &n, teks);
	kata = teks;
	peta[kata] = 1;
	len = kata.size();
	prv = teks[len - 1];
	for (int i = 1; i < n; i++) {
		scanf("%s\n", teks);
		kata = teks;
		if ((peta.count(kata) > 0) || (teks[0] != prv)) {
			valid = false;
			break;
		}
		peta[kata] = 1;
		len = kata.size();
		prv = teks[len - 1];
	}
	if (valid)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#coding:utf-8
k = int(input())
num = [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]
print(num[k-1])

Measured memory_bytes: 3060
/* A - Takahashikun, The Strider */

#include <bits/stdc++.h>
using namespace std;

int gcd(int a, int b){
  int r;
  r = a % b;
  if(r == 0) return b;
  else return gcd(b, r);
}

int main(){
  int X;
  cin >> X;
  cout << 360 / gcd(X, 360) << endl;
}

Measured memory_bytes: 3616
import numpy as np
N = int(input())
arr1 = np.array(list(map(int,input().split())))
arr2 = arr1 % 2
s = 0
while 1 not in arr2:
  arr1 = arr1 // 2
  arr2 = arr1 % 2  
  s += 1

print(s)                


Measured memory_bytes: 20872
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		vector<vector<int>>nums(2);
		for (int i = 0; i < N; ++i) {
			int a; cin >> a;
			nums[0].emplace_back(a);
		}
		for (int i = 0; i < 2 * N; ++i) {
			if (find(nums[0].begin(), nums[0].end(), i + 1) == nums[0].end()) {
				nums[1].emplace_back(i + 1);
			}
		}
		for (int i = 0; i < 2; ++i) {
			sort(nums[i].begin(), nums[i].end());
		}
		if (!N)break;
		int pl = 0;
		int base = -1;
		while (1) {
			auto it = upper_bound(nums[pl].begin(), nums[pl].end(), base);
			if (it == nums[pl].end()) {
				base = -1;
				
			}
			else {
				base = *it;
				nums[pl].erase(it);
				
			}
			pl = !pl;
			bool ok = true;
			for (int i = 0; i < 2; ++i) {
				if (nums[i].empty())ok = false;
			}
			if (!ok)break;
		}
		for (int i = 0; i < 2; ++i) {

			cout << nums[!i].size() << endl;
		}
		
	}
	
	return 0;
}

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

typedef long long ll;

ll md = 1000000007;

vector<ll> a;
vector<ll> b;
vector<ll> c;

int main(int, char**) 
{
	ll a ,b;
	std::cin >> a >> b;
	ll c = a - 2 * b;
	if ( c < 0 ) c = 0;
	cout <<  c << endl;
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

void rec(int n, string s, int i) {
    n--;
    if (n == 0) {
        cout << s << endl;;
        return;
    }
    for (int j = 0; j <= (i+1); j++) {
        char c = 'a' + j;
        rec(n, s + c, max(i, j));
    }
}

int main(){
    int N;
    cin >> N;
    
    rec(N, "a", 0);
    
    return 0;
}

Measured memory_bytes: 1536
def main_function():
    from sys import stdin
    from sys import stdout
    input = stdin.readline
    print = stdout.write

    modulo = pow(10, 9) + 7
    n, k = list(map(int, input().split()))
    ans = 0
    tmp = 1
    for i in range(1, k):
        tmp -= i * 2
    for i in range(k, n + 2):
        ans += i * n + tmp
        tmp -= i * 2
        ans %= modulo
    print(f'{ans % modulo}')


if __name__ == '__main__':
    main_function()

Measured memory_bytes: 9176
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int n, a[100010];
vi solve_naive(){
	vi ans(n),  aprev(n); rep(i, n) aprev[i] = a[i];
	rep(it, n){
		int mx = -1, mxi, mx2 = -1, mx2i;
		rep(i, n) if(a[i] > mx) mx = a[i], mxi = i;
		rep(i, mxi) if(a[i] > mx2) mx2 = a[i], mx2i = i;
		if(mx2 < 0){
			rep(i, n) ans[mxi] += a[i];
			break;
		}
		int cnt = 0;
		for(int i = mxi; i < n; i++){
			cnt += max(0, a[i] - mx2);
			a[i] = min(a[i], mx2);
		}
		ans[mxi] += cnt;
	}
	rep(i, n) a[i] = aprev[i];
	return ans;
}
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	cin >> n;
	rep(i, n) cin >> a[i+1];
	//dbg(solve_naive());
	n++;
	vi idx;
	int prev = -1;
	rep(i, n) if(a[i] > prev){
		prev = a[i];
		idx.pb(i);
	}
	set<pi> vals;
	vector<ll> ans(n);
	for(int ii = idx.size() - 1, j = n - 1; ii > 0; ii--){
		int i = idx[ii - 1];
		while(j > i){
			if(a[j] >= a[i]) ans[idx[ii]] += a[j] - a[idx[ii]];
			else vals.emplace(-a[j], j);
			j--;
		}
		set<pi> dels;
		for(auto it = vals.begin(); it != vals.end() && -it->first >= a[i]; it++){
			dels.insert(*it);
			ans[idx[ii]] += -it->first - a[idx[ii]];
		}
		for(auto it : dels) vals.erase(it);
		
		ans[idx[ii]] += (n - 1ll - i - vals.size()) * (a[idx[ii]] - a[i]);
	}
	rep(i, n-1) cout << ans[i+1] << endl;
	
	return 0;
}

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

int main(){
    int64_t n, ans = 0, cnt;
    cin >> n;
    vector<int64_t> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    for(int i = 0; i < n; i++){
        cnt = 0;
        while(v[i] >= v[i + 1] && i < n - 1){
            cnt++;
            i++;
        }
        ans = max(cnt, ans);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    char a, b;
    cin >> a >> b;
    if (a == 'H') {
        cout << (b == 'H' ? 'H' : 'D') << "\n";
    }
    else {
        cout << (b == 'H' ? 'D' : 'H') << "\n";
    }
}

Measured memory_bytes: 256
/* "The world is full of obvious things which nobody by any chance ever observes." */


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define mod 1000000007
#define pi  3.14159265358979323846
#define pb push_back
#define mk make_pair
#define popcnt(a) _Generic((a), int: __builtin_popcount(a), \  long long: __builtin_popcountll(a))  
#define precise(x) cout<<fixed<<setprecision(10)<<x
#define test cout<<"#";
#define input freopen("input.txt", "r", stdin)
#define output freopen("output.txt", "w", stdout) 

const ll inf = 1e18L + 2;

ll ans[1000001];

ll solve(vector<ll> &v, ll n)
{
    if(n==1)
        return 0;
    if(n==2)
        return abs(v[n-1] - v[n-2]);
    if(ans[n]!=-1)
        return ans[n];
    return ans[n] = min(solve(v, n-1) + abs(v[n-1] - v[n-2]), solve(v, n-2) + abs(v[n-1] - v[n-3]));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    vector<ll> v(n);
    memset(ans, -1, sizeof(ans));
    for(ll x = 0; x < n; x++)
        cin>>v[x];
    cout<<solve(v, n);
}

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

int main() {
	int n;cin>>n;
	vector<int> h(n);
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	vector<int> c(n,0);
	int ans=0;
	for(int i=n-2;i>=0;i--){
		if(h[i]>=h[i+1]){
			c[i]=c[i+1]+1;
		}
		ans=max(ans,c[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import math
import bisect
from functools import lru_cache
import itertools

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def main():
    # A, B, C = [int(a) for a in input().split()]
    # A = [int(a) for a in input().split()]
    X = int(input())
    # A = [int(a) for a in input().split()]
    # T1, T2, T3 = [int(a) for a in input().split()]
    if 400 <= X < 600:
        print(8)
    elif 600 <= X < 800:
        print(7)
    elif 800 <= X < 1000:
        print(6)
    elif 1000 <= X < 1200:
        print(5)
    elif 1200 <= X < 1400:
        print(4)
    elif 1400 <= X < 1600:
        print(3)
    elif 1600 <= X < 1800:
        print(2)
    elif 1800 <= X < 2000:
        print(1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 68400
#include <stdio.h>
#include <stdlib.h>
#include <math.h>



int main()
{
	int K=0,A=0,B=0,OK=0;
	
	scanf("%d",&K);

	scanf("%d %d",&A,&B);
	
	int i;
	
	for(i=A;i<=B;i++){
		if(i%K==0){
			OK=1;
			break;
		}
	}
	
	if(OK==1){
		printf("OK");
	}
	else{
		printf("NG");
	}

	return 0;
}


Measured memory_bytes: 1732
n=int(input())
a=[int(i) for i in input().split()]
d={}
for i in range(n):
    d[a[i]]=d.get(a[i],0)+1
tot=0
v=list(d.values())
for i in v:
    tot+=(i*(i-1)//2)
for i in range(n):
    num=a[i]
    o=d[a[i]]
    print(tot-o+1)


Measured memory_bytes: 25768
n,a,b = map(int,input().split())
mod = 10**9+7
ans = pow(2,n,mod)-1
inv_t = [0]+[1]
for i in range(2,b+1):
  inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod]
nCk = [1]*(b+1)
for i in range(1,b+1):
  nCk[i]=(((nCk[i-1]*(n-i+1))%mod)*inv_t[i])%mod
ans -= nCk[a]+nCk[b]
print(ans%mod)

Measured memory_bytes: 18864
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int n, w;
  cin >> n >> w;
  vector<pair<int, long long>> p(n);
  for (int i = 0; i < n; i++)
    cin >> p[i].first >> p[i].second;
  long long dp[n + 1][n * 1000 + 1];
  long long INF = 1000000000000000000LL;
  for (int i = 0; i <= n * 1000; i++)
    dp[0][i] = INF;
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= n * 1000; j++) {
      dp[i + 1][j] = dp[i][j];
      if (j - p[i].second < 0)
        continue;
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - p[i].second] + p[i].first);
    }
  }

  long long ans = 0;
  for (long long i = 0; i <= n * 1000; i++) {
    if (dp[n][i] <= w) {
      ans = max(ans, i);
    }
  }
  cout << ans << endl;
  return 0;
}


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

int swapCount = 0;
void bubbleSort(int* A, int n){
	bool flag = true;
	while(flag){
	flag = false;
		for(int j = n - 1; j >= 1; j--){
			if(A[j] < A[j - 1]){
				int temp = A[j - 1];
				A[j-1] = A[j];
				A[j] = temp;
				swapCount++;
				flag = true;
			}
		}
	}
}

int main(){
	int n = 0; 
	cin >> n;
	int A[n];
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	bubbleSort(A, n);
	cout << A[0];
	for(int i = 1; i < n; i++){
		cout << ' ' << A[i];
	}
	cout << '\n' << swapCount << '\n';
	return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>
int main()
{
    int n,D,X,i;
    scanf("%d%d%d",&n,&D,&X);
    int sz[n];
    for(i=0; i<n; i++)
        scanf("%d",&sz[i]);

    for(i=0;i<n;i++)
    {
        X=X+(D-1)/sz[i]+1;
    }
    printf("%d",X);
}

Measured memory_bytes: 128
//Never stop chasing!-MdSourav.
#include <bits/stdc++.h>

#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll                    long long int
#define ls             long int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)       __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define fact(n)        ll x=1;for(ll i=1;i<=n;i++){x=(x*i);}
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define INF 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;

double pi=3.14159265358979323846;
typedef vector<ll> vll ;
typedef vector<int> vii ;

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}

void solve()
{
      ll n,m,k;
        cin>>n>>m>>k;
        vector<ll>a(n);
        vector<ll>b(m);
        for(int i=0;i<n;i++)
            cin>>a[i];
        for(int i=0;i<m;i++)
            cin>>b[i];
        vector<ll>sumA(n+1);
        vector<ll>sumB(m+1);
        for(int i=0;i<n;i++)
            sumA[i+1]=sumA[i]+a[i];
        for(int i=0;i<m;i++)
            sumB[i+1]=sumB[i]+b[i];
        int total=0;
        for(int i=0;i<=n;i++){
            ll other=k-sumA[i];
            if(other<0)
                continue;
            int l=lower_bound(sumB.begin(),sumB.end(),other)-sumB.begin();
            if(l>m || sumB[l]>other)
                --l;
//            cout<<other<<" "<<l<<" "<<i<<" "<<"\n";
            total=max(total,i+l);
        }
        cout<<total;

}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    ll test_case=1;
   // cin>>test_case ;
    while(test_case--)
	{
		 solve();
	}

	return 0;
}

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

int main() {
    long long N;
    cin >> N;
    long long res = N + 1 - 2;  // (a, b) = (1, N)
    for (long long a = 1; a * a <= N; ++a) {
        if (N % a == 0) res = min(res, a + N / a - 2);
    }
    cout << res << endl;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {

	public static void main(String[] args) {
			
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int ans = 0;
		while (X >= 500) {
			ans += 1000;
			X -= 500;
		}
		while (X >= 5) {
			ans += 5;
			X -= 5;
		}
		System.out.println(ans);
	}
}

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

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

int main() {
    long a, b;
    scanf("%ld %ld", &a, &b);
    long x = a * b / gcd(a, b);
    printf("%ld\n", x);
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<ll>;

ll df(ll a, ll b)
{
    if (b < 0) a = -a, b = -b;
    return a / b - (a % b < 0);
}

ll dc(ll a, ll b)
{
    if (b < 0) a = -a, b = -b;
    return a / b + (a % b > 0);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, h;
    cin >> n >> h;
    vi v;
    ll mx = 0;
    for (int i = 0; i < n; ++i)
    {
        ll a, b;
        cin >> a >> b;
        mx = max(mx, a);
        v.push_back(b);
    }
    sort(all(v));
    reverse(all(v));
    while (!v.empty() && v.back() <= mx)
        v.pop_back();

    ll k = accumulate(all(v), 0);
    ll rem = h - k;
    if (rem > 0)
    {
        int sol = dc(rem, mx);
        h -= sol * mx;
        int r = 0;
        while (h > 0)
            h -= v[r], r++;
        cout << sol + r;

    }
    else
    {
        int sol = 0;
        while (h > 0)
            h -= v[sol], sol++;
        cout << sol;
    }
}


Measured memory_bytes: 1400
n = list(str(input()))
a = n[2:]
b = a[:-1]
count = 0
cindex = []
for i in range(len(b)):
    if b[i] == "C":
        count += 1
        cindex.append(i)
if n[0] != "A" or count != 1:
    print("WA")
else:
    del n[0]
    del n[cindex[0] + 1]
    m = "".join(n)
    if m.islower():
        print("AC")
    else:
        print("WA")

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD = 1e9 + 7;
int main() {
  ll a,b,c;
  cin>>a>>b>>c;
  if(a==b && b==c){
    cout<<"No"<<endl;
  }else if(a==b || a==c || b==c){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

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

// Template START
#define endl "\n"
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
const int mod = (int)1e9 + 7 ;
#define vv(T) vector<vector<T>>
#define vvv(T) vector<vector<vector<T>>>
template<class T>
auto matrix( int r, int c, T v ){
    return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
template<class T>
auto matrix( int o1, int o2, int o3, T v ){ 
    return vector<vector<vector<T>>>( o1, vector<vector<T>>( o2, vector<T>( o3, v ) ) ) ;
}
// Template END

int power( int x, int n ){
    if( n == 0 ) return 1 ;
    else if( n & 1 ) return ( x * power( (x*x) % mod, n / 2 ) ) % mod ;
    return power( (x*x) % mod, n / 2 ) % mod ;
}
int ans = 0 ;
signed main(){
    int n ; cin >> n ;
    vector<int> a(n) ;
    for(int i = 0 ; i < n ; i++) cin >> a[i] ;
    sort( all(a), greater<int>() ) ;
    if( n == 2 ){
        cout << a[0] ;
        return 0 ;
    }
    for(int i = 1 ; i < n ; i++){
        ans += a[i/2] ;
    }
    cout << ans ;
    return 0 ;   
}


Measured memory_bytes: 4836
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int n, k, ans; cin >> n >> k;
    ans = 1;
    while(n > 0)
    {
        if (ans + k > ans * 2)
        {
            ans *= 2;
        }
        else
        {
            ans += k;
        }
        n--;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,n)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
using li = long int;
using ull= unsigned long long;
using vi = vector<li>;
using vs = vector<string>;


int main()
{
    int a[3];
    rep(i,3)cin>>a[i];
    sort(a,a+3);
    cout<<a[0]+a[1]<<endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

const ll MOD = 998244353;

int r[4003], b[4003];
ll dp[2][4003][4003];

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i++){
        if(s[i] == '0') r[i] += 2;
        if(s[i] == '1'){
            r[i]++;
            b[i]++;
        }
        if(s[i] == '2') b[i] += 2;
        r[i + 1] += r[i];
        b[i + 1] += b[i];
    }
    for(int i = n; i < n * 2; i++){
        r[i + 1] = r[i];
        b[i + 1] = b[i];
    }
    dp[0][0][0] = 1;
    for(int i = 1; i <= n * 2; i++){
        for(int j = 1; j <= min(i, r[i - 1]); j++)
            dp[i % 2][j][i - j] = (dp[i % 2][j][i - j] + dp[(i + 1) % 2][j - 1][i - j]) % MOD;
        for(int j = 1; j <= min(i, b[i - 1]); j++)
            dp[i % 2][i - j][j] = (dp[i % 2][i - j][j] + dp[(i + 1) % 2][i - j][j - 1]) % MOD;
    }
    cout << dp[0][r[n * 2]][b[n * 2]] << endl;
}

Measured memory_bytes: 250112
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

vector<int>E[101010];
int deg[101010];
int N, M;
void unable() {
	puts("No");
	exit(0);
}
void able() {
	puts("Yes");
	exit(0);
}

int used[101010];
int dfs(int now, int st, int ot, int fl,int from) {
	int ok = 0;
	fore(x, E[now]) {
		if (x == st && fl == 0 && from != st)return 1;
		if (!used[x]) {
			used[x] = 1;
			int c;
			if (x == ot)c = dfs(x, st, ot, 1,now);
			else c = dfs(x, st, ot, fl,now);
			if (c)ok = 1;
		}
	}
	return ok;
}

int check() {
	int st = -1;
	int ot = -1;
	for (int i = 0; i < N; i++) {
		if (deg[i] == 4) {
			if (st == -1)st = i;
			else ot = i;
		}
	}
	used[st] = 1;
	return dfs(st, st, ot, 0,-1);
}

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

	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		E[a].pb(b);
		E[b].pb(a);
		deg[a]++;
		deg[b]++;
	}

	int cnt4 = 0;
	int cntmore = 0;
	for (int i = 0; i < N; i++) {
		if (deg[i] % 2)unable();
		if (deg[i] >= 6)cntmore++;
		if (deg[i] == 4)cnt4++;
	}
	if (cntmore)able();

	int c;
	if (cnt4 >= 3)able();
	else if (cnt4 == 2)c = check();
	else unable();

	if (c)able();
	else unable();

	return 0;
}


Measured memory_bytes: 10496
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        w: usize,
        wv: [(usize, usize); n],
    }

    let inf = 1_000_000_000_000_000;
    let max_v = n * 1000;

    // dp[item][v]: 価値vを超えるようにitem番目までの品物を選んだときの、重さの総和の最小値
    let mut dp = vec![vec![inf; max_v + 10]; n + 1];
    dp[0][0] = 0;

    for item in 0..n {
        for v in 0..max_v + 1 {
            let weight = wv[item].0;
            let value = wv[item].1;

            if v >= value {
                dp[item + 1][v] = std::cmp::min(dp[item + 1][v], dp[item][v - value] + weight);
            }

            dp[item + 1][v] = std::cmp::min(dp[item + 1][v], dp[item][v]);
        }
    }

    let mut ans = 0;
    for i in 0..max_v + 1 {
        if dp[n][i] <= w {
            ans = std::cmp::max(ans, i);
        }
    }

    println!("{}", ans);
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  double max = ((double)a[n-1] / 2);
  double min = 999999999;
  int minI = 0;
  for(int i = 0; i < n; i++){
    if(min > abs(a[i]-max)){
      min = abs(a[i]-max);
      minI = i;
    }
  }
  cout << a[n-1] << " " << a[minI];
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
int n;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    ll res=0;
    for (int i=1; i<=n; i++){
        if (i%3!=0 && i%5!=0) res+=(ll)i;
    }
    
    cout<<res;
    
    return 0;
}

Measured memory_bytes: 3656
import sys

sys.setrecursionlimit(10000)

def check_island(h,w):
	#print(h,w)
	for i in [-1,0,1]:
		for j in [-1,0,1]:
			if (H>(h+i)>=0) and (W>(w+j)>=0) and (c[h+i][w+j]==1):
				c[h+i][w+j] = 0
				check_island(h+i, w+j) 

while(True):
	W, H = map(int,input().split())
	if W==0 and H == 0 : break
	c = [list(int(i) for i in input().split()) for i in range(H)]
	count = 0
	for i in range(H):
		for j in range(W):
			if c[i][j]==1:
				count+=1
				check_island(i,j)
	print(count)



Measured memory_bytes: 8020
import { readFileSync } from 'fs'
import { reverse } from 'dns'
import { start } from 'repl'
 
let lines: string[] = [];
const reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
 
reader.on('line', function (line: string) {
    lines.push(line);
});
reader.on('close', function () {
    let [x, y] = lines[0].split(' ').map( _ => parseInt(_))

    if(y % 2 == 1) {
        console.log('No')
    } else {
        if(x * 4 >= y && 2 * x <= y) {
            console.log('Yes')
        } else {
            console.log('No')
        }
    }

});

Measured memory_bytes: 30040
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(sign i=(sign)a;i<=(sign)b;++i)
#define Fordown(i,a,b) for(sign i=(sign)a;i>=(sign)b;--i)
const int N=2000+10,inf=2100000000;
inline sign read()
{
	sign ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
ll a[10],w[10],f[10];
ll ans,n,k;
void init()
{
	For(i,1,4)scanf("%lld",&a[i]);
	scanf("%lld",&n);
	n*=4;
}
void work()
{
	//a[2]=min(a[1]*2,a[2]);
	//a[3]=min(min(a[1]*4,a[2]*2),a[3]);
	a[4]=min(min(a[1]*8,a[2]*4),min(a[3]*2,a[4]));
	w[1]=1;w[2]=2;w[3]=4;
	if(n>=8)
	{
		k=n/8;
		n%=8;
		ans+=a[4]*k;
	}
	if(n>0)
	{
		For(i,1,n)f[i]=inf;
		For(i,1,3)
		{
			For(j,w[i],n)
			{
				f[j]=min(f[j],f[j-w[i]]+a[i]);
			}
		}
	}
	printf("%lld\n",ans+f[n]);
}
int main()
{
	init();
	work();
	return 0;
}


Measured memory_bytes: 384
n = int(input())

k = 2
f = [1,4,16]
r = [{"AG":0,"GA":0,"AC":0,"AGG":0,"A":0,"G":0},
     {"AG":0,"GA":0,"AC":0,"AGG":0,"A":1,"G":1},
     {"AG":1,"GA":1,"AC":1,"AGG":0,"A":4,"G":4,"ATG":0,"AGT":0,"AT":1}]
while k < n:
    k += 1
    r.append({})
    r[k]["AC"] = r[k-1]["A"]-r[k-1]["GA"]
    r[k]["GA"] = r[k-1]["G"]
    r[k]["AG"] = r[k-1]["A"]
    r[k]["AGG"] = r[k-1]["AG"]
    r[k]["A"] = f[k-1]
    r[k]["G"] = f[k-1]-r[k-1]["AC"]
    r[k]["ATG"] = r[k-1]["AT"]
    r[k]["AT"] = r[k-1]["A"]
    r[k]["AGT"] = r[k-1]["AG"]
    f.append(0)
    f[k] = f[k-1]*4 - r[k-1]["AG"] - r[k-1]["GA"] - r[k-1]["AC"] - r[k-1]["AGG"] - r[k-1]["ATG"] - r[k-1]["AGT"]
print(f[n]%(10**9+7))

Measured memory_bytes: 3188
#include <stdio.h>
int i,x,n,q,a,v,aaa=0,vvv=0,vv[9000],f[1000001],prev[1000001],next[1000001];
int main(void){
	scanf("%d %d",&n,&q);
	for(i=0;i<=n;i++){f[i]=0;prev[i]=0;next[i]=0;}
	for(i=0;i<9000;i++)vv[i]=0;
	
	for(;q>0;q--){
		scanf("%d %d",&a,&v);

		x=f[a];

		if(x>0){
			if(vv[x]==a){
				if(next[a]>0){vv[x]=next[a];}
				else vv[x]=0;
			}
			next[prev[a]]=next[a];
			prev[next[a]]=prev[a];
			prev[0]=0;next[0]=0;
		}

		f[a]+=v;x+=v;
		
		if(x>0){
			if(a<vv[x] || vv[x]==0){
				prev[a]=0;
				next[a]=vv[x];
				prev[vv[x]]=a;
				prev[0]=0;
				vv[x]=a;
			}
			else{
				i=vv[x];
				while(a>next[i] && next[i]>0){i=next[i];}
				prev[a]=i;
				next[a]=next[i];
				prev[next[i]]=a;
				next[i]=a;
				prev[0]=0;
			}
		}else{prev[a]=0;next[a]=0;}

		if(v>0){if(x>vvv || (x==vvv && a<aaa)){vvv=x;aaa=a;}}
		else if(a==aaa){
			for(i=vvv; vv[i]<1 && i>0 ;i--);
			vvv=i;
			aaa=vv[i];
		}

		printf("%d %d\n",aaa,vvv);
	}
	
	return 0;
}

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

int c[9][9];
int x[9], y[9];
int main() {
    int n; cin >> n;
    string s; cin >> s;
    for (int i = 0; i < n - 1; ++i) {
        ++c[s[i] - '1'][s[i + 1] - '1'];
    }
    for (int i = 0; i < 9; ++i) for (int j = 0; j < 9; ++j) {
        // cerr << i << ' ' << j << ' ' << c[i][j] << '\t';
    }
    array<int, 9> idx, res;
    iota(begin(idx), end(idx), 0);
    int mn = 1e9;
    do {
        int curr = 0;
        for (int i = 0; i < 9; ++i) {
            x[idx[i]] = i / 3;
            y[idx[i]] = i % 3;
        }
        for (int i = 0; i < 9; ++i) for (int j = 0; j < 9; ++j) {
            curr += c[idx[i]][idx[j]] * (abs(x[idx[i]] - x[idx[j]]) + abs(y[idx[i]] - y[idx[j]]));
        }
        // cerr << curr << endl;
        if (curr < mn) {
            // cerr << curr << endl;
            mn = curr;
            res = idx;
        }
    } while (next_permutation(begin(idx), end(idx)));
    for (int i = 0; i < 9; i += 3) {
        cout << res[i] + 1 << res[i + 1] + 1 << res[i + 2] + 1 << "\n";
    }
    return 0;
}



Measured memory_bytes: 3280
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll K;
  cin >> K;
  if (K % 2 == 0 || K % 5 == 0)
    cout << -1 << endl;
  else {
    ll po = 7;
    if (po % K == 0) {
      cout << 1 << endl;
      return 0;
    }
    REP(i, 2e7) {
      po = ((po * 10) + 7) % K;
      // cout << po << endl;
      if (po % K == 0) {
        cout << i + 2 << endl;
        return 0;
      }
    }
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3648
a, b, c, d = map(int, input())
ops = ['+', '-']
for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            formula = "{}{}{}{}{}{}{}".format(a, op1, b, op2, c, op3, d)
            if eval(formula) == 7:
                print("{}=7".format(formula))
                exit()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,a[202020],b[202020];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++)
	{
		scanf("%d",&b[i]);
	}
	reverse(b,b+n);
	for(int i=0;i<n;i++)
	{
		if(a[i]!=b[i])
		{
			continue;
		}
		bool ok=false;
		for(int j=0;j<n;j++)
		{
			if(i==j)
			{
				continue;
			}
			if(a[i]!=b[j] && a[j]!=b[i])
			{
				swap(b[i],b[j]);
				ok=true;
				break;
			}
		}
		if(!ok)
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	for(int i=0;i<n;i++)
	{
		printf("%d ",b[i]);
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 5388
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a[4],b[4];
	int s=0;
	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++){
		if(a[i]==b[i])
		s++;
	}
	cout<<s;
	return 0;
} 

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

int main(){
    int A,B,C; // 1 <= A, B <= 100, 0 <= C < B
    cin >> A >> B >> C;
    bool ret = false;
    for (int i = 0; i < B; i ++){
        if((A*(i+1)) % B == C){
            ret = true;
        }
    }
    if (ret)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 3584
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define sl(x) scanf("%ld", &x)
#define ss(x) scanf("%s", x)
#define pl(x) printf("%ld\n", x)
#define ps(x) printf("%s\n", x)
 
#define INF 100000000000
#define MOD 1000000007
 
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))

int main() {
	long N;
	long i, j;
	long table[1001] = {0};
	long ans = 1;
	long tmp;
	
	sl(N);
	
	if(N == 1) {
		pl(1);
		return 0;
	}
	
	for(i=2;i<=N;i++) {
		tmp = i;
		for(j=2;j<=i;j++) {
			if(tmp < j) break;
			while(tmp % j == 0) {
				table[j]++;
				tmp /= j;
			}
		}
	}
	
	for(i=2;i<=N;i++) {
		ans *= (table[i] + 1);
		ans %= MOD;
	}
	
	pl(ans);
	
	return 0;
}

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

int main(){
    using namespace std;
    auto chmin = [](auto& a, auto b){return a > b && (a = b);};
    int K;
    cin >> K;
    deque<int> dfs(1, 1), dst(K, 46);
    dst[1] = 1;
    while(!dfs.empty()){
        auto i = dfs.front(), d = dst[i];
        dfs.pop_front();
        if(!i)return 0 & printf("%d\n", d);
        if(chmin(dst[i * 10 % K], d))dfs.push_front(i * 10 % K);
        if(chmin(dst[++i %= K], d + 1))dfs.push_back(i);
    }
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) ((int)(x).size())
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int inf = 1 << 30;
const ll INF = 1LL << 60;

int main(){
    int n;
    ll w;
    cin >> n >> w;
    map<int, VL> mp;
    ll wf;
    rep(i,n){
        int wi, vi;
        cin >> wi >> vi;
        mp[wi].push_back(vi);
        if (i == 0) wf = wi;
    }

    map<int, VL> mpsum;
    rep(i,4){
        mpsum[wf+i].push_back(0);
    }

    for(auto m: mp){
        sort(rall(m.second));
        rep(i, sz(m.second)){
            mpsum[m.first].push_back(mpsum[m.first].back() + m.second[i]);
        }
    }

    ll ans = 0;
    rep(i, sz(mpsum[wf])) rep(j, sz(mpsum[wf+1])) rep(k, sz(mpsum[wf+2])) rep(l, sz(mpsum[wf+3])){
        ll r = w - wf*i - (wf+1)*j - (wf+2)*k - (wf+3)*l;
        if (r < 0) continue;
        ll v = mpsum[wf][i] + mpsum[wf+1][j] + mpsum[wf+2][k] + mpsum[wf+3][l];
        ans = max(ans, v);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <algorithm>
using namespace std;
const int M = 100000; int Q, pn[M], pn2017[M];
int main() {
  for(int i = 2; i <= M; ++i) pn[i] = 1;
  for(int i = 2; i*i <= M; ++i) {
    if(!pn[i]) continue;
    for(int j = i*i; j <= M; j+=i) pn[j] = 0;
  }
  for(int i = 2; i <= M; ++i) {
    pn2017[i] = pn2017[i-1]+(pn[i]&&pn[(i+1)/2]);
  }
  scanf("%d", &Q);
  for(int i = 1, l, r; i <= Q; ++i) {
    scanf("%d %d", &l, &r);
    printf("%d\n", pn2017[r]-pn2017[l-1]);
  }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep( i, n ) for (ll i = 0; i < ( ll )(n); i++)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;



int main(){
    string s;
    cin>>s;
    if(s=="AAA"||s=="BBB") cout<<"No";
    else cout<<"Yes";
}


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

int main() {
    string O, E;
    cin >> O >> E;
    int ocnt = 0;
    int ecnt = 0;
    for (int i = 0; i < O.length() + E.length(); i++) {
        if ((i + 1) % 2 == 1) {
            cout << O[ocnt++];
        } else {
            cout << E[ecnt++];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let (n, m) = {
      let v: Vec<usize> = read_vec();
      (v[0], v[1])
    };
    let mut x: Vec<i64> = read_vec();
    x.sort();

    let mut diff: Vec<(i64, usize)> = Vec::new();
    for (i, now) in x.iter().enumerate() {
      if i > 0 {
        let x = x[i - 1];
        diff.push((now - x, i));
      }
    }
    diff.sort_by(|a, b| b.cmp(&a));


    let mut sum = diff.iter().fold(0, |acc, x| x.0 + acc);
    for &(l, i) in diff.iter().take(n-1) {
      sum -= l;
    }
    println!("{}", sum);
}


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

int main(){
  int D,G;
  cin >> D >> G;
  vector<pair<int,int>> p(D);
  for(int i=0;i<D;++i){
    cin >> p.at(i).first >> p.at(i).second;
  }

  int ans = 1e9;
  for(int mask=0;mask<(1 << D);++mask){
    int s = 0, num = 0, rest_max = -1;
    for(int i=0;i<D;++i){
      if(mask >> i & 1){
        //マスクで"1"だった問題をすべて解いた時の基本点と、ボーナス点を"s"に追加
        //"numには解いた問題数を追加"
        s += 100*(i+1)*p.at(i).first+p.at(i).second;
        num += p.at(i).first;
      }else{
        rest_max = i;
      }
    }
    if(s<G){
      int s1 = 100*(rest_max+1);
      int need = (G-s+s1-1)/s1;
      //解く必要のある問題数を求める
      if(need>=p.at(rest_max).first){
        //解く必要のある問題数より実際の問題数が少なかった場合"continue"する
        continue;
      }
      num += need;
    }
    ans = min(ans,num);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (sb-int:defconstant-eqx OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0))
    #'equal)
  #+swank (ql:quickload '(:cl-debug-print :fiveam) :silent t)
  #-swank (set-dispatch-macro-character
           #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
#-swank (disable-debugger) ; for CS Academy

;; BEGIN_INSERTED_CONTENTS
(declaim (ftype (function * (values fixnum &optional)) read-fixnum))
(defun read-fixnum (&optional (in *standard-input*))
  (declare #.OPT)
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (sb-impl::ansi-stream-read-byte in nil #.(char-code #\Nul) nil))))
    (let* ((minus nil)
           (result (loop (let ((byte (%read-byte)))
                           (cond ((<= 48 byte 57)
                                  (return (- byte 48)))
                                 ((zerop byte) ; #\Nul
                                  (error "Read EOF or #\Nul."))
                                 ((= byte #.(char-code #\-))
                                  (setf minus t)))))))
      (declare ((integer 0 #.most-positive-fixnum) result))
      (loop
        (let* ((byte (%read-byte)))
          (if (<= 48 byte 57)
              (setq result (+ (- byte 48) (* 10 (the (integer 0 #.(floor most-positive-fixnum 10)) result))))
              (return (if minus (- result) result))))))))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;;;
;;; Body
;;;

(defun main ()
  (declare #.OPT)
  (let* ((n (read))
         (as (make-array n :element-type 'uint32))
         (res 0)
         (current-max 0))
    (declare (uint32 n current-max)
             (uint62 res))
    (dotimes (i n) (setf (aref as i) (read-fixnum)))
    (dotimes (i n)
      (let* ((p (+ 1 current-max))
             (a (aref as i))
             (quot (floor (- a 1) p)))
        (incf res quot)
        (unless (zerop quot)
          (setf (aref as i) 1))
        (setq current-max (max current-max (aref as i)))))
    (println res)))

#-swank (main)


Measured memory_bytes: 27872
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) x.begin(),x.end()
#define db(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, n, m) for(int i = n; i >= m; i--)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;

int main(){

  int a;
  string s;
  cin >> a>>s;

  if(a>=3200){
    std::cout << s << '\n';
  }
  else{
    std::cout << "red" << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
   int n;
   scanf("%d",&n);
   ll a[n];
   for(int i=0;i<n;i++)
    cin>>a[i];
   ll dp[n];
   dp[0]=0,dp[1]=abs(a[1]-a[0]);
   for(int i=2;i<n;i++)
       dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
    cout<<dp[n-1];


}


Measured memory_bytes: 1792
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cctype>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

int main() {
  int x, y;
  int x_group, y_group;
  cin >> x >> y;

  switch(x) {
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12: x_group = 1;
             break;
    case 4:
    case 6:
    case 9:
    case 11: x_group = 2;
             break;
    case 2: x_group = 3;
            break;
  }

  switch(y) {
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12: y_group = 1;
             break;
    case 4:
    case 6:
    case 9:
    case 11: y_group = 2;
             break;
    case 2: y_group = 3;
            break;
  }

  if(x_group == y_group) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

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

int A, B;

int main(){

	cin >> A >> B;

	int ans;
	if (A < 10 && B < 10) {
		ans = A * B;
	} else {
		ans = -1;
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;
using ll = long long;


int binary_search(int *a, int v, int b, int e){
  int m = (e+b)/2;
  if(v == a[m]) return m;
  return v < a[m] ? binary_search(a, v, b, m-1) : binary_search(a, v, m+1, e);
}

int
main(void){
  int a, b;
  cin >> a >> b;

  if(a+b == 15) cout << "+" << endl;
  else if(a*b == 15) cout << "*" << endl;
  else cout << "x" << endl;

  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i <= n; ++i)

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

void solve(ll N) {
  vector<ll> num(N + 1, 1);
  FOR(i, 2, N) {
    FOR(j, 1, N / i)
      num[i * j]++;
  }

  ll ans(0);
  FOR(i, 1, N)
    ans += i * num[i];
  cout << ans << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N;
  cin >> N;

  solve(N);

  return 0;
}

Measured memory_bytes: 81336
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

vector<vector<ll>> memo;
vector<ll> w;
ll dfs(ll l, ll r) {
	if(memo[l][r]!=INF) return memo[l][r];
	if(r-l+1<2) return memo[l][r]=0;
	if(r-l+1==2) {
		if(abs(w[l]-w[r])<=1) return memo[l][r]=2;
		else return memo[l][r]=0;
	}
	ll ret=0;
	if(dfs(l+1,r-1)==r-l-1) {
		if(abs(w[l]-w[r])<=1) return memo[l][r]=r-l+1;
		else ret=max(ret,r-l-1);
	}
	FOR(i,l,r) ret=max(ret,dfs(l,i)+dfs(i+1,r));
	return memo[l][r]=ret;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1) {
		ll n;
		cin>>n;
		if(n==0) break;
		w.resize(0);
		w.resize(n);
		REP(i,n) cin>>w[i];
		memo.resize(0);
		memo.resize(n);
		REP(i,n) {
			memo[i].resize(n);
			REP(j,n) memo[i][j]=INF;
		}
		cout<<dfs(0,n-1)<<endl;
	}
}

Measured memory_bytes: 3748