akhauriyash/Code-Regression huggingface dataset:
N, M, K = map(int, input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for j in range(M):
    b.append(b[j] + B[j])

ans = 0
j = M
for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j = j -1
    ans = max(ans, i+j)
    
print(ans)

Measured memory_bytes: 47328
#include <cstdio>
#include <cmath>
using namespace std;

double x, h;

int main() {
  while (1) {
    scanf("%lf", &x);
    scanf("%lf", &h);
    if (x == 0.0 && h == 0.0) return 0;

    printf("%f\n", x*x+x*sqrt(h*h+(x*x/4))*2);
  }
}

Measured memory_bytes: 2732
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    for i in range(26):
        for j in range(15):
            if i*4+j*7==N:
                YesNo(1)
                exit()
    YesNo(0)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long INF = 1000000000000000000;

void cout_vec(vector<long long> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

void cout_mat(vector<vector<long long>> &mat){
    for(int i=0; i<mat.size(); i++){
        vector<long long> vec = mat[i];
        cout_vec(mat[i]);
    }
}

int main(){
    int N;
    cin >> N;
    vector<long long> a(N+1,0);
    for(int i=0; i<N; i++){
        int b;
        cin >> b;
        a[i+1]=a[i]+b;
    }
    vector<vector<long long> > dp(N+1,vector<long long>(N+1,INF));
    for(int n=1; n<=N; n++){
        for(int i=0; i<=N-n; i++){
            if(n==1)dp[i][i+n]=0;
            for(int k=1; k<n; k++){
                dp[i][i+n]=min(dp[i][i+n], dp[i][i+k]+dp[i+k][i+n]+a[i+n]-a[i]);
            }
        }
    }
    //cout_mat(dp);
    cout << dp[0][N] << endl;
}

Measured memory_bytes: 1536
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  int X=-4;
  string S;
  cin>>S;
  for(int i=0;i<4;i++){
    if(S[i]=='+') X+=2;
  }
  cout<<X;
return 0;}

Measured memory_bytes: 3628
#include <iostream>

int main(int argc, const char * argv[]) {
    
    int n ;
    std::cin >> n ;
    
    for (int i=0; i<n; i++) {
        int a, b, c ;
        std::cin >> a >> b >> c ;
        if (a*a + b*b == c*c ||
            b*b + c*c == a*a ||
            c*c + a*a == b*b ) {
            printf("YES\n") ;
        } else {
            printf("NO\n") ;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3008
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(input())
    al = []
    ar = []
    bl = []
    br = []
    for i in range(n):
        a,b = map(int,ipt().split())
        ali = heapq.heappushpop(al,-a)
        ari = heapq.heappushpop(ar,a)
        heapq.heappush(ar,-ali)
        heapq.heappush(al,-ari)
        bli = heapq.heappushpop(bl,-b)
        bri = heapq.heappushpop(br,b)
        heapq.heappush(br,-bli)
        heapq.heappush(bl,-bri)
    ali = -heapq.heappop(al)
    ari = heapq.heappop(ar)
    bli = -heapq.heappop(bl)
    bri = heapq.heappop(br)
    amed2 = ali+ari
    bmed2 = bri+bli
    if n%2 == 0:
        print(bmed2-amed2+1)
    else:
        print((bmed2-amed2)//2+1)

    return

if __name__ == '__main__':
    main()


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

using namespace std;

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

	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(n - 1);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n - 1; i++) {
		cin >> c[i];
	}

	int prev = -9;
	int res = 0;
	for (int i = 0; i < n; i++) {
		res += b[a[i] - 1];
		if (prev == a[i] - 2) {
			res += c[a[i] - 2];
		}
		prev = a[i] - 1;

	}
	cout << res << '\n';

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1000000007;
const ll INF = 1000000000000000001;

int a, b, c, x;
int main(void){
    cin >> a >> b >> c >> x;
    int ans = 0;
    for (int i = 0; i <= a; i++){
        for (int j = 0; j <= b; j++){
            for (int k = 0; k <= c; k++){
                if (500 * i + 100 * j + 50 * k == x) ans++;
            }
        }
    }

    cout << ans << endl;
}

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

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

    double c = (a + b) / 2.0;
    
    if(((int) c + 1) - c < 1)
    {
        cout << (int) c + 1 << endl;
    }
    else
    {
        cout << (int) c << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n, m;
	long long int p;
	scanf("%d %d %lld", &n, &m, &p);
	int a[5003], b[5003];
	long long int c[5003];
	int i, j;
	for (i = 0; i < m; i++)
		scanf("%d %d %lld", &a[i], &b[i], &c[i]);
	for (i = 0; i < m; i++)
		c[i] -= p;
	long long int d[3003];
	for (i = 0; i < n; i++)
		d[i] = -10000000000;
	d[0] = 0;
	int u[3003];
	for (i = 0; i < n; i++)
		u[i] = 0;
	u[0] = 1;
	for (i = 0; i < m; i++)
	{
		a[i]--;
		b[i]--;
	}
	for (j = 0; j < n; j++)
	{
		for (i = 0; i < m; i++)
		{
			if (u[a[i]] > 0)
			{
				if (d[b[i]] < d[a[i]] + c[i])
					d[b[i]] = d[a[i]] + c[i];
				u[b[i]] = 1;
			}
		}
	}
	int e[3003];
	for (i = 0; i < n; i++)
		e[i] = 0;
	for (j = 0; j < n; j++)
	{
		for (i = 0; i < m; i++)
		{
			if (u[a[i]] > 0)
			{
				if (e[a[i]] > 0)
					e[b[i]] = 1;
				if (d[b[i]] < d[a[i]] + c[i])
					e[b[i]] = 1;
			}
		}
	}
	if (e[n - 1] > 0)
	{
		printf("-1\n");
		return 0;
	}
	if (d[n - 1] < 0)
		d[n - 1] = 0;
	printf("%lld\n", d[n - 1]);
	return 0;
}

Measured memory_bytes: 384
X,K,D = map(int, input().split())
X = abs(X)
if X - K*D > 0:
  print(X - K*D)
else:
  needCount = X//D
  limX = X - needCount * D
  remK = K - needCount
  minusX = limX - D
  if remK % 2 == 0:
    print(limX)
  else:
    print(abs(minusX))

Measured memory_bytes: 9116
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#define _CRT_SECURE_NO_WARNINGS
#endif
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x) {x = 0;register bool _=0;register T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void print(T n) {register bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);pc(10);}
template<typename First, typename ... Ints>
void scan(First &arg, Ints&... rest) { scan(arg);scan(rest...); }

using namespace std;
const int MM = 302;

int n;
double dp[MM][MM][MM];

double go(int i, int j, int k){
    if(dp[i][j][k] != -1)
        return dp[i][j][k];
    
    double ret = 1;
    int sum = i+j+k;
    
    if(i)
        ret += (1.0*i/n)*go(i-1, j, k);
    if(j)
        ret += (1.0*j/n)*go(i+1, j-1, k);
    if(k)
        ret += (1.0*k/n)*go(i, j+1, k-1);
    
    return dp[i][j][k] = ret/(1-(1.0*n-sum)/n);
}

int main(){
    
    for(int i = 0; i < MM; i++)
        for(int j = 0; j < MM; j++)
            for(int k = 0; k < MM; k++)
                dp[i][j][k] = -1;
    dp[0][0][0] = 0;
    scan(n);
    int a[4] = {0,0,0,0};
    for(int i = 0,s; i < n; i++){
        scan(s);
        a[s]++;
    }
    printf("%.10lf\n", go(a[1], a[2], a[3]));
    
    return 0;
}

Measured memory_bytes: 215424
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

ll INF=1e9+7;
lvector dx{1,0,-1,0},dy{0,1,0,-1}; 

ll bfs(ll h, ll w, vector<vector<char>> maze, vector<lvector> d) {
  queue<P> que;
  rep(i,h)rep(j,w) d[i][j]=INF;
  que.push(P(0,0)); d[0][0]=0;
  while(que.size()) {
    P p=que.front(); que.pop();
    if(p.first==h-1&&p.second==w-1) break;
    rep(i,4) {
      ll nx=p.first+dx[i], ny=p.second+dy[i];
      if(0<=nx&&nx<h && 0<=ny&&ny<w && maze[nx][ny]!='#' && d[nx][ny]==INF) {
        que.push(P(nx,ny));
        d[nx][ny]=d[p.first][p.second]+1;
      }
    }
  }
  return d[h-1][w-1];
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h,w,INF=1e9+7; cin>>h>>w;
  vector<vector<char>> maze(h);
  lvector d_(w,0);
  vector<lvector> d(h,d_);
  char c;
  ll dots=0;
  rep(i,h) 
  rep(j,w) {
    cin>>c; maze[i].emplace_back(c);
    if(c=='.') dots++;
  }
  ll val=1+bfs(h,w,maze,d);
  if(val==INF+1) print(-1);
  else print(dots-val);  
  return 0;
}


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

int main()
{
    string r,b;
    cin>>r>>b;
    if(r[0]==b[2]&&r[1]==b[1]&&r[2]==b[0])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


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



int main(int argc, char* argv[])
{
  using std::cin;
  using std::cout;
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int res = 0;
  for (int r = 0; r*R <= N; ++r)
  {
    for (int g = 0; g*G <= N-r*R; ++g)
    {
      const int rem = N - r*R - g*G;
      if (rem % B) continue;
      ++res;
    }
  }
  cout << res << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define pb push_back
#define pop pop_back
#define ff first
#define ss second
#define vec vector<int>
#define vec2 vector<vector<int> >
#define MOD 1000000007
typedef long long int lld;
#define rep(i,n) for(i=0;i<=n;i++)
#define repb(i,n) for(i=n-1;i>=0;i--)
#define repab(i,a,b) for(i=a;i<b;i++)
#define repba(i,a,b) for(i=b;i>=a;i--)
int gcd(int a,int b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
int main()
{
    int i;
    lld a,b,c,k;
    cin>>a>>b>>c>>k;
    lld d=0;
    lld sum=min(a,k)-max(d,k-a-b);
    cout<<sum;
    return 0;
}


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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

int c[3][3];

int main() {
    rep(i, 0, 3) rep(j, 0, 3) cin >> c[i][j];
    rep(x, -100, 200) rep(y, -100, 200) rep(z, -100, 200) {
        int b0 = c[0][0] - x;
        int b1 = c[1][1] - y;
        int b2 = c[2][2] - z;
        if (b0 + y != c[0][1]) continue;
        if (b0 + z != c[0][2]) continue;
        if (b1 + x != c[1][0]) continue;
        if (b1 + z != c[1][2]) continue;
        if (b2 + x != c[2][0]) continue;
        if (b2 + y != c[2][1]) continue;
        cout << "Yes";
        return 0;
    }
    cout << "No";
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        while (true) {
            int r0 = sc.nextInt();
            int w0 = sc.nextInt();
            int c = sc.nextInt();
            int r = sc.nextInt();
            if (r0 == 0) {
                break;
            }
            sb.append(Math.max((c * w0 - r0 + r - 1) / r, 0)).append("\n");
        }
        System.out.print(sb);
    }
}



Measured memory_bytes: 26116
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e9;
template<typename T> void cmax(T &a, T b) {a = max(a, b);}
template<typename T> void cmin(T &a, T b) {a = min(a, b);}


signed main(){
  int n;
  while(cin>>n,n){
    vector<vector<int>> mt(n);
    rep(i,n){
      int m;
      cin>>m;
      rep(j,m){
        int mm;cin>>mm;
        mt[i].push_back(mm);
      }
    }
    int k;cin>>k;
    vector<int> leak(k);
    rep(i,k)cin>>leak[i];
    int num=INF;
    bool flag=false;
    rep(i,n){
      vector<bool> ok(leak.size(),false);
      rep(j,leak.size()){
        for(auto x:mt[i]){
          if(x==leak[j]){
            ok[j]=true;
            break;
          }
        }
      }
      int ans=true;
      rep(j,ok.size())ans&=ok[j];
      if(ans&&flag==false){
        flag=true;
        num=i;
      }
      else if(ans&&flag==true){
        cout<<-1<<endl;
        goto here;
      }
    }
    cout<<(num==INF?-1:num+1)<<endl;
    here:;
  }

 return 0;
}



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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

int main() {
  ll n; cin >> n;
  vector<ll> p(n);
  vector<ll> c(n, 1);
  REP(i,n) {
    ll x;
    cin >> x;
    p[x-1] = i;
  }
  ll cnt = 1;
  FOR(i,1,n) {
    if (p[i] > p[i-1]) c[i] = c[i-1]+1;
    chmax(cnt, c[i]);
  }
  cout << n-cnt << endl;
  return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <int,int>
#define N 300005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;

int main()
{
	int a, b, t;
	cin >> a >> b >> t;
	cout << b * (t / a);
}

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

int *bubblesort(int a[]) {
	for (int i=0; i < 10; i++) {
		for (int j=0; j < 10 -1- i; j++) {
			if (a[j] < a[j+1]) {
				int temp = a[j];
				a[j] = a[j+1];
				a[j+1] = temp;
			}
		}
	}
	return a;
}

int main() {
	int a[10];
	for (int i = 0;i < 10; i++) {
		cin >> a[i];
	}
	int *b = bubblesort(a);
	for (int t=0; t<3; t++) {
		cout << b[t] << endl;
	}
} 

Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    ll N;
    cin >> N;
    vector<ll> vec(3*N);
    REP(i, 3*N) cin >> vec.at(i);
    
    // calculation
    sort(vec.begin(), vec.end(), greater<ll>());  // int big -> small
    ll i = 0, idx = 1, sum = 0;
    while (i < N) {
        sum += vec[idx];
        idx += 2;
        i++;
    }
    cout << sum << "\n";
    
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x=max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<P>;
inline int in() { int x; cin>>x; return x;}
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,sz(v))i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(sz(v))o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
template <class T> inline ll suma(const v(T)& a) 
{ ll res(0); for(auto&& x:a) res += x; return res;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
#define dame {puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;
#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
//----------------------------------------------------------------
bool graph[8][8];
int dfs(int v,int n,v(bool) visited){
    bool all_visited=true;
    rep(i,n) if(visited[i]==false) all_visited = false;
    if(all_visited) return 1;
    int ret = 0;
    rep(i,n){
        if(graph[v][i]==false) continue;
        if(visited[i]) continue;
        visited[i] = true;
        ret += dfs(i,n,visited);
        visited[i] = false;
    }
    return ret;
}
int main(int argc,char* argv[]){
    fileio
    int n = in();
    int m = in();
    rep(i,m){
        int s = in(),t = in(); s--;t--;
        graph[s][t] = true;
        graph[t][s] = true;
    }
    v(bool) visited(n,false);
    visited[0]=true;
    cout<<dfs(0,n,visited);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

VVI edge(114514, VI(0));

struct unionfind {
	vector<int> par, siz;
	unionfind(int N) : par(N), siz(N,1) {
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int root(int x) {
		while(par[x] != x) x = par[x] = par[par[x]];
		return x;
	}
	void unite(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return;
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int size(int x) {
		return siz[root(x)];
	}
};

int main() {
	int n, m, k; cin >> n >> m >> k;
    unionfind uf(n);
    int a, b;
    VI ans(n,-1);
    REP(i, m) {
	    cin >> a >> b;
        a--; b--;
	    uf.unite(a,b);
        ans[a]--; ans[b]--;
    }
    REP(i,n){
        ans[i]+=uf.size(i);
    }
    REP(i, k) {
	    cin >> a >> b;
        a--; b--;
	    if(uf.same(a,b)){
            ans[a]--; ans[b]--;
        }
    }
    REP(i,n){
        cout << ans[i] << ' ';
    }
    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define FIR first
#define SEC second
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 100000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main() {
  IN(ll,H);
  IN(ll,N);
  ll sum = 0;
  REP(i,N){
    ll x;
    cin >> x;
    sum += x;
  }
  BOUT(sum >= H);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
int main()
{
    int data[32] ={
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
    };
    int k;
    cin >> k;

    cout << data[k - 1] << endl;; 

    //cout << fixed << setprecision(10);//小数点以下10桁出力
    return 0;
}

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

int main() {
  int N,K;
  cin >> N >> K;
  int sum = 0;
  
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    
    if (K-x >=0) {
      if (x <= K-x) {
        sum += 2*x;
      }
      else {
        sum += 2*(K-x);
      }
    }
    else {
      if (x <= x-K) {
        sum += 2*x;
      }
      else {
        sum += 2*(x-K);
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
    ll m,n;
    cin>>m>>n;
    char ar[m][n];
    for(ll i=0;i<m;++i)
    {
        for(ll j=0;j<n;++j){cin>>ar[i][j];}
    }
    ll dp[m+1][n+1];
    for(ll i=0;i<m+1;++i){dp[i][0]=0;}
    for(ll i=0;i<n+1;++i){dp[0][i]=0;}
    dp[1][1]=1;
    for(ll i=1;i<m+1;++i)
    {
        for(ll j=1;j<n+1;++j)
        {
            if(i==1 && j==1){continue;}
            if(ar[i-1][j-1]=='#'){dp[i][j]=0;}
            else{dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;}
        }

    }
    cout<<dp[m][n];
}


Measured memory_bytes: 12388
n,m=[int(i) for i in input().split()]
ac=[0]*n
wa=[0]*n
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=="AC":
        if ac[p]==0:
            ac[p]=1
    else:
        if ac[p]==0:
            wa[p]+=1
    
for i in range(n):
    wa[i]=wa[i]*ac[i]
print(sum(ac),sum(wa))

Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define inf 0x3f3f3f3f
int A,B,M;
int a[N],b[N],c;
int x,y;
int main(){
	scanf("%d%d%d",&A,&B,&M);
	int minA=inf,minB=inf;
	for(int i=1;i<=A;i++){
		scanf("%d",&a[i]);
		minA=min(a[i],minA);
	}
	for(int i=1;i<=B;i++){
		scanf("%d",&b[i]);
		minB=min(b[i],minB);
	}
	int minn=inf;
	for(int i=1;i<=M;i++){
		scanf("%d%d%d",&x,&y,&c);
		minn=min(minn,a[x]+b[y]-c);
	}
	printf("%d",min(minn,minA+minB));
}

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

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i,n) cin >> d[i];
  sort(d.begin(),d.end());
  int ans = 1;
  rep(i,n-1){
    if(d[i] != d[i+1]){
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

signed main(){
	string str;
	cin >> str;
	int n = str.size();
	if(str[0] == str[n-1]){
		if(n%2 == 1)printf("Second\n");
		else printf("First\n");
	}else{
		if(n%2 == 0)printf("Second\n");
		else printf("First\n");
	}
	return 0;
}


Measured memory_bytes: 512
x=int(input())
l=[0]*(x+1)

if x==1:
    print(1)
    exit()
    
for i in range(1,x):
    for j in range(2,1000):
        if i**j>x:
            break
        l[i**j]=1

for i in reversed(range(x+1)):
    if l[i]==1:
        print(i)
        exit()


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
int white[200001];
int black[200001];
void Calc(){
	int N = rei();
	string S = res();
	for(int i=0;i<N;i++){
		if(S[i] == '.'){
			white[i+1]++;
		}
		white[i+1] += white[i];
	}
	for(int i=N-1;i>=0;i--){
		if(S[i] == '#'){
			black[i]++;
		}
		black[i] += black[i+1];
	}
	int ans = 200000000;
	for(int i=0;i<=N;i++){
		ans = min(ans,N-white[i]-black[i]);
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 2196
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String n1 = sc.next();

        if (n1.equals("RSR")) {
            System.out.println(1);
            return;
        }

        System.out.println(n1.chars().filter(c -> c == 'R').count());
    }
}


Measured memory_bytes: 35992
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;

int main(){
    CASET{
        DRII(N,D);
        int an=0;
        REPP(i,1,N){
            int D2=D^127;
            D=127;
            if(D2<D)swap(D2,D);
            an+=D2;
        }
        an+=D;
        printf("%d\n",an);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007

using namespace std;

int main(void){
    // Your code here!
    string s;
    
    cin >> s;
    if((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3]))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
        
    return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, std::string S){
    for(ll i=0; i< A; i++){
        if('0' > S[i] || '9'< S[i]) {
            cout << NO << endl;
            return;
        }
    }
    if(S[A] != '-') {
        cout << NO << endl;
        return;
    }
    for(ll i=A+1; i< A+B+1; i++){
        if('0' > S[i] || '9'< S[i]) {
            cout << NO << endl;
            return;
        }
    }
    cout << YES << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    std::string S;
    std::cin >> S;
    solve(A, B, S);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    ll N,M; cin >> N >> M;
    ll ans1=min(N,M/2);
    ll ans2=(M-(2*ans1))/4;
    cout << ans1 + ans2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <utility>
#define REP(i,A) for(int i=0;i<A;i++)

using namespace std;
using ll = long long int;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);

string S;
int N,K;
cin >> N >> K;
cin >> S;

if(S[K-1]=='A'){
    S[K-1]='a';
}else if(S[K-1]=='B'){
    S[K-1]='b';
}else{
    S[K-1]='c';
}

cout << S;

return 0;
}

Measured memory_bytes: 256
S = int(input())
fs = []
fs.append(S)
i = 2
while(True):
    if S % 2 == 0:
        ap = S / 2
    else :
        ap = 3 * S + 1
    for f in fs:
        if ap == f:
            print(i)
            exit()
    
    fs.append(ap)
    S = ap
    i += 1


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

int main() {
  string S, T;
  cin >> S >> T;
  int N = S.size();
  int M = T.size();
  reverse(S.begin(), S.end());
  reverse(T.begin(), T.end());
  bool can = false;
  int p = -1;
  for (int i = 0; i < N - M + 1; i++) {
    for ( int j = 0; j < M; j++) {
      if ( S.at(i+j) != T.at(j) && S.at(i+j) != '?') {
        break;
      }
      if (j == M - 1) {
        can = true;
        p = i;
      }
    }
    if (can) break;
  }
  if (can) {
    for ( int i = 0; i < M; i++) {
      S.at(p+i) = T.at(i);
    }
    reverse(S.begin(), S.end());
    for (int i = 0; i < N; i++) {
      if(S.at(i) == '?') S.at(i) = 'a';
    }
    cout << S << endl;
  }
  if(!can) cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
N, K  = map(int, input().split())
p = [int(i) for i in input().split()]
k = [0] * N


for i in range(N):
    P = p[i]
    k[i] = (P+1)/2

def cumsum(l):
    c = [0] * len(l)
    for i in range(len(l)):
        c[i] = c[i-1] + l[i]
    return c

c = cumsum(k)
c = [0] + c
ans = 0

for i in range(N-K+1):
    t = c[i+K] - c[i]

    if t > ans:
        ans = t

print(ans)    

Measured memory_bytes: 25704
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long a = sc.nextInt();
		long b = sc.nextInt();
		long total = 0;
		long prev = sc.nextInt();
		for (int i = 1; i < n; i++) {
			long tmp = sc.nextInt();
			total += Math.min((tmp - prev) * a, b);
			prev = tmp;
		}
		System.out.println(total);
	}
}


Measured memory_bytes: 49936
from collections import deque

n = int(input())
A = list(map(int, input().split()))
B = deque([])

if n % 2 == 0:
    for i in range(n):
        if i % 2 == 0:
            B.append(A[i])
        else:
            B.appendleft(A[i])

else:
    for i in range(n):
        if i % 2 == 0:
            B.appendleft(A[i])
        else:
            B.append(A[i])

B = list(map(str, B))
print(" ".join(B))

Measured memory_bytes: 32964
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;



int n, k, ans;
int a[100003];


int main(){

	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> a[i];

	if ((n - 1) % (k - 1) == 0)cout << (n - 1) / (k - 1) << endl;
	else cout << (n - 1) / (k - 1) + 1 << endl;



	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    int N;
    cin >> N;
    ll a = 0, b = 0, ba = 0;
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        string str;
        cin >> str;
        for(int j = 0; j < str.size()-1; j++) {
            if(str[j] == 'A' && str[j+1] == 'B') {
                ans++;
            }
        }

        if (str[0] == 'B' && str.back() == 'A') ba++;
        else if (str[0] == 'B') b++;
        else if (str.back() == 'A') a++;
    }

    if (ba != 0) ans += ba - 1;
    if (ba != 0 && a >= 1) {
        ans++;
        a--;
    }
    if (ba != 0 && b >= 1) {
        ans++;
        b--;
    }

    ans += min(a, b);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
A, B = list(map(str, input().split()))

a = int(A)
b = int(B[0])
b_ = int(B[2])
b__ = int(B[3])

c = a * b * 100
c_ = a * b_ * 10
c__ = a * b__

ans = (c + c_ + c__) // 100

print(ans)



Measured memory_bytes: 9128
n=int(input())
s=input().split()
i=0
j=0
flag=0
l=list()
while(i<n or j<n):
    if(flag==0):
        l.append(s[0][i])
        i+=1
        flag=1
    else:
        l.append(s[1][j])
        j+=1
        flag=0
for i in range(len(l)):
    print(l[i],end="")

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INI(n) scanf("%d",&n)
#define INL(n) scanf("%lld",&n)
#define INS(n) scanf("%s",s)
#define INF 10000000000
#define mod 1000000007
#define X 100000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void nCrReady(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (ll i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll nCr(ll n,ll k){return fac[n]*(finv[k]*finv[n-k]%mod)%mod;}

int main(void){
  char s[4];
  INS(s);
  if(s[0]==s[1]&&s[1]==s[2]){
    PRS("No");
  }else{
    PRS("Yes");
  }
}


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

/// Defining variable types.
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

/// Defining usable key words
#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()
#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

/// Defining constant variables.
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

/// Defining some useful lines.
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);


/// Code of debugger.
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu ()
{
    cerr << endl;
}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}

const int mx=1e5+123;
ll dp[123][mx];
ll we[mx],ve[mx],n,lim;

ll solve(ll i,ll w)
{
    if(i>n)
        return 0;

    if(dp[i][w]!=-1)
        return dp[i][w];

    ll r1=0,r2=0;

    if(w+we[i]<=lim)
        r1=ve[i]+solve(i+1,we[i]+w);
    r2=solve(i+1,w);

    dp[i][w]=max(r1,r2);

    return dp[i][w];
}


int main()
{
    optimize();

    mem(dp,-1);

    cin>>n>>lim;

    for(int i=1; i<=n; i++)
        cin>>we[i]>>ve[i];

    ll ans=solve(1,0);

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 99836
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define ld long double
#define PB push_back
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define pii pair <int , int>
#define pll pair <long long , long long>
#define FAST ios::sync_with_stdio(false);cin.tie(0);
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const ll maxn = 2e5 + 50 , N = 60000 + 20 , mod = 1e9 + 7 , INF = 1e9 + 1 , lg = 32;

int main() {
	FAST
	ll n , k , h;
	cin >> n >> k >> h;
	ll p = (n + k - 1) / k;
	cout << p * h << endl;
}


Measured memory_bytes: 3592
#include<iostream>
#include<iomanip>
#include<stdio.h>
using namespace std;

int main(){
	int a,b;
	
	cin>>a>>b;
	
	cout<<a/b<<' '<<a%b<<' ';
	printf("%.8lf\n",(double)a/b);
	return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pb emplace_back

inline void print(){return;} 
template <typename T, typename... Types> 
inline void print(T var1,Types... var2){cout<<var1<<" ";print(var2...);} 

inline void println(){cout<<"\n";} 
template <typename T, typename... Types> 
inline void println(T var1,Types... var2){cout<<var1<<" ";println(var2...);}

int mod=1e9+7;

main()
{
    //freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    
    int n;
    cin>>n;
    vector<pair<int,int>> v(n);
    for(int i=0;i<n;i++)
        cin>>v[i].second>>v[i].first;

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

    int t=0;
    for(auto i:v)
    {
        t+=i.second;

        if(t>i.first)
        {
            print("No");
            return 0;
        }
    }
    print("Yes");
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
//---------------------------------------------------------------------------//

int main(){
        string a,b,c;
        cin>>a>>b>>c;
        cout<<a.substr(0,1)+b.substr(0,1)+c.substr(0,1)<<endl;
}


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

using namespace std;
typedef long long ll;

ll N = 0, K = 0, a = 0, b = 0;
ll ans[1001] = {};

int main() {
	cin >> N;
	cin >> K;
	for (int i = 1; i <= K; i++) {
		cin >> a >> b;
		if (a < b) {
			if (a + b <= N) {
				if (a % 3 == 1)ans[i] = 1;
				if (a % 3 == 2)ans[i] = 2;
				if (a % 3 == 0)ans[i] = 3;
			}
			else {
				ans[i] = (N - b) % 3 + 1;
			}
		}
		else {
			if (a + b <= N) {
				if (a % 3 == 1)ans[i] = 1;
				if (a % 3 == 2)ans[i] = 2;
				if (a % 3 == 0)ans[i] = 3;
			}
			else {
				ans[i] = (N - b) % 3 + 1;
			}
			if (a + b <= N) {
				if (b % 3 == 1)ans[i] = 1;
				if (b % 3 == 2)ans[i] = 2;
				if (b % 3 == 0)ans[i] = 3;
			}
			else {
				ans[i] = (N - a) % 3 + 1;
			}
		}
	}
	for (int i = 1; i <= K; i++)cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {

  int N, W; cin >> N >> W;

  int w, w1 = 0, v;
  vector<vector<ll> > vs(4);
  for (int i = 0; i < N; ++i) {
    cin >> w >> v;
    if (w1 == 0) w1 = w;
    
    vs[w-w1].push_back(v);
  }

  for (int j = 0; j < 4; ++j) {
    sort(vs[j].begin(), vs[j].end(), greater<ll>());

//    cout << j << "  --  " << vs[j].size() << " -- ";
    for (int i = 1; i < vs[j].size(); i++) {
      vs[j][i] += vs[j][i-1];
//      cout << vs[j][i] << " ";
    }
//    cout << endl;
  }

  ll res = 0;
  for (ll i = 0; i <= vs[0].size(); ++i) {
    for (ll j = 0; j <= vs[1].size(); ++j) {
      for (ll k = 0; k <= vs[2].size(); ++k) {
        for (ll l = 0; l <= vs[3].size(); ++l) {

	  ll wei = w1 * i + (w1+1) * j + (w1+2)*k + (w1+3)*l;
	  if ( wei > W ) continue;

	  ll vv = 0;
	  if (i > 0) vv += vs[0][i-1];
	  if (j > 0) vv += vs[1][j-1];
	  if (k > 0) vv += vs[2][k-1];
	  if (l > 0) vv += vs[3][l-1];

	  res = max(res, vv);

        }
      }
    }
  }

  cout << res << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;
  vector<ll> B(N-1);

  for(int i = 0; i < N-1; i++){
    cin >> B[i];
  }

  ll ans = 0;
  ans += B[0];
  for(int i = 0; i < N-2; i++){
    ans += min(B[i], B[i+1]);
  }
  ans += B[N-2];

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define X first
#define Y second
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> pi4;

ll f[103][103];
bool visit[103][103];
int w, h;

void dfs(int y, int x) { 
	visit[y][x] = true;
	const int dy[] = {-1,0,1,0};
	const int dx[] = {0,1,0,-1};
	rep(i,4) {
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(0<=nx && nx<w && 0<=ny && ny<h && !visit[ny][nx] && f[y][x]==f[ny][nx]) {
			dfs(ny,nx);
		}
	}
}

int main() {
	int n;
	while(cin >> n, n) {
		vector<pi4> v(n);
		set<int> sx, sy;
		rep(i, n) {
			cin >> v[i].X.X >> v[i].Y.Y >> v[i].X.Y >> v[i].Y.X;
			sx.insert(v[i].X.X);
			sx.insert(v[i].X.Y);
			sy.insert(v[i].Y.X);
			sy.insert(v[i].Y.Y);
		}
		map<int,int> mpx, mpy;
		w=1; h=1;
		for(set<int>::iterator it=sx.begin(); it!=sx.end(); it++) {
			mpx[*it] = w++;
		}
		for(set<int>::iterator it=sy.begin(); it!=sy.end(); it++) {
			mpy[*it] = h++;
		}
		w++; h++;
		memset(f, 0, sizeof(f));
		rep(i, n) {
			int l = mpx[v[i].X.X];
			int r = mpx[v[i].X.Y];
			int b = mpy[v[i].Y.X];
			int t = mpy[v[i].Y.Y];
			ll bit = 1LL << i;
			for(int y=b; y<t; y++) {
				for(int x=l; x<r; x++) {
					f[y][x] |= bit;
				}
			}
		}
		int res = 0;
		memset(visit, 0, sizeof(visit));
		for(int y=0; y<h; y++) {
			for(int x=0; x<w; x++) {
				if( !visit[y][x] ) {
					res++;
					dfs(y,x);
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 2116
#include <stdio.h>

int main(void) {
	int a, b;
	char op;
	scanf("%d %c %d", &a, &op, &b);

	if (op == '+') {
		printf("%d\n", a + b);
	} else if (op == '-') {
		printf("%d\n", a - b);
	}

	return 0;
}

Measured memory_bytes: 128