akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n;
    cin >> n;
    
    vector<vector<P>> G(n);
    rep(i, n-1) {
        ll a, b, cost;
        cin >> a >> b >> cost;
        a--;  b--;
        G[a].pb(make_pair(b, cost));
        G[b].pb(make_pair(a, cost));
    }

    ll q, k;
    cin >> q >> k;
    k--;
    
    vl dist(n, -1);  // dist[v] : 頂点vの根からの距離
    queue<ll> Q;
    const ll root = k;
    dist[root] = 0;
    Q.push(root);
    while(!Q.empty()) {
        ll v = Q.front();
        Q.pop();
        for(auto p : G[v]) {
            ll u = p.first;
            ll cost = p.second; 
            if(dist[u] != -1) {
                continue;
            }
            dist[u] = dist[v] + cost;
            Q.push(u);
        }
    }
    
    vl ans(q);
    rep(i, q) {
        ll x, y;
        cin >> x >> y;
        x--;  y--;
        ans[i] = dist[x] + dist[y];
    }

    rep(i, q) {
        out(ans[i]);
    }
    
    re0;
}

Measured memory_bytes: 10752
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int x = scn.nextInt();
		int y = scn.nextInt();
      	int t = 0;
      	int c = 0;
      	String ans = "No";
      	for(int i=0; i<=x; i++){
          int num = i*2 + (x-i)*4;
          if(num==y) ans = "Yes";
        }
      	System.out.println(ans);
	}
}

Measured memory_bytes: 35720
#include <bits/stdc++.h>
    using namespace std;
int main(){
	long long a[1001][3];
	long long b[1001],c,d=0;
	int i,j,k,l,n,m,u;
	scanf("%d%d",&n,&m); 
	for(i=1;i<=n;i++)scanf("%lld%lld%lld",&a[i][0],&a[i][1],&a[i][2]);
	for(i=-1;i<2;i+=2){
	for(j=-1;j<2;j+=2){
		for(k=-1;k<2;k+=2){
		for(l=1;l<=n;l++){
		b[l]=i*a[l][0]+j*a[l][1]+k*a[l][2];		}
		sort(b+1,b+1+n);
		c=0;
		for(u=n;u>n-m;u--){
		c+=b[u];
		}
		if(c>d)d=c;
	}
	
}
}
printf("%lld",d);
return 0;
}


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

int main() {
    int n; cin >> n;
    vector<vector<pair<int, bool>>> data(n, vector<pair<int, bool>>());
    for(int i = 0; i < n; i++) {
        int k; cin >> k;
        while(k--) {
            int u;
            bool kind;
            cin >> u >> kind;
            data[i].push_back({--u, kind});
        }
    }

    int ans = 0;
    for(int mask = 0; mask < (1 << n); mask++) {
        bool f = true;

        for(int i = 0; i < n; i++) {
            if(!(mask & (1 << i))) continue;
            for(auto &p : data[i]) {
                int u = p.first;
                bool kind = p.second;
                f &= ((bool) (mask & (1 << u)) == kind);
            }
        }

        ans = max(ans, __builtin_popcount(mask) * f);
    }

    cout << ans;
}

Measured memory_bytes: 256
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  n %= 10;
  if(n == 2 ||n == 4 ||n == 5 ||n == 7 ||n == 9)printf("hon\n");
  else if(n == 0 ||n == 1 ||n == 6 ||n == 8) printf("pon\n");
  else printf("bon\n");
  return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n, r;
    cin >> n >> r;
    if (n >= 10)
        OP(r);
    else
        OP(r + 100 * (10 - n));
    return 0;
}

Measured memory_bytes: 256
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int sum=0;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    int s=0;
    int mini=1e18;
    for(int i=0;i<n-1;i++)
    {
        s+=arr[i];
        int diff=abs(s-(sum-s));
        mini=min(mini,diff);
    }
    cout<<mini<<endl;
}




Measured memory_bytes: 1792
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
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; }

void solve(std::string T){
    ll ans = 0;
    ll N = T.length();
    REP(i, N) if(T[i] == '?') T[i] = 'D';
    cout<<T<<endl;
}
int main(){
    std::string T;
    std::cin >> T;
    solve(T);
    return 0;
}


Measured memory_bytes: 3368
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
#define N 101010
void build(){

}
LL n , c , k , t[ N ] , s[ N ];
void init(){
  n = getint();
  for( int i = 1 ; i <= n ; i ++ )
    t[ i ] = getint();
  sort( t + 1 , t + n + 1 );
  for( int i = 1 ; i <= n ; i ++ )
    s[ i ] = s[ i - 1 ] + t[ i ];
}
void solve(){
  int ans = 0;
  for( int i = 1 ; i <= n ; i ++ ){
    int til = i;
    while( til < n ){
      LL sum = s[ til ];
      int bl = til + 1 , br = n , ba = til;
      while( bl <= br ){
        int mid = ( bl + br ) >> 1;
        if( t[ mid ] <= sum + sum )
          ba = mid , bl = mid + 1;
        else
          br = mid - 1;
      }
      if( ba == til ) break;
      til = ba;
    }
    if( til == n ) ans ++;
  }
  printf( "%d\n" , ans );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 1792
#coding:UTF-8
def Stack(A):
    p=[]
    symbol=["+","-","*"]
    for i in range(len(A)):
        if A[i] in symbol:
            if A[i]=="+":
                p.append(p.pop()+p.pop())
            elif A[i]=="-":
                p.append(-p.pop()+p.pop())
            else:
                p.append(p.pop()*p.pop())
        else:
            p.append(int(A[i]))
    
    print(p[0])
  
if __name__=="__main__":
    a=input()
    A=a.split(" ")
    Stack(A)

Measured memory_bytes: 7708
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  ll A,B;
  cin >> A >> B;
  cout << A*B <<endl;
    return 0;
}

Measured memory_bytes: 3636
//能否成功地把球全部放入容器内 
#include<iostream>
#include<cstring>
using namespace std;
int a[100];
int aa[100],aaa[100];//分别表示两边的容器 
int main(){
	int t;
	cin>>t;
	while(t--){
		memset(a,0,sizeof(a));
		memset(aa,0,sizeof(aa));//左边 
		memset(aaa,0,sizeof(aaa));//右边 
		for(int i=1;i<=10;i++)
			cin>>a[i];
		aa[1]=a[1],aaa[0]=a[0];
		int p1=0,p2=0;//aa aaa的下标
		int i;
        for(i=2;i<=10;i++){
            if(a[i]>aa[p1])
                aa[++p1]=a[i];
            else if(a[i]>aaa[p2])
                aaa[++p2]=a[i];
            else{
                cout<<"NO"<<endl;
                break;
            }
        }
        if(i>10)
            cout<<"YES"<<endl;
    }
}


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)

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

    cout << N*N*N << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    char s;
    cin >> s;
    s++;
    cout << s << endl;
    solve();
    return 0;
}



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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)

int main() {
	ll n, m , c;
    cin >> n >> m >> c;
    ll b[m];
    ll a[n][m];
    REP(i,m){
        cin >> b[i];
    }
    REP(i,n){
        REP(j,m){
            cin >> a[i][j];
        }
    }
    int correct = 0;
    REP(i,n){
        ll sum = 0;
        REP(j,m){
            sum += a[i][j] * b[j];
        }
        sum += c;
        if( sum > 0 ){
            correct ++;
        }
    }
    cout << correct << endl;
}


Measured memory_bytes: 256
// JAI MAHAKAAL @hitu04
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define ll  long long
//#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  cin>>n>>a>>b;
 string s;
 char r;
 rep(i,n,a+1)
 {
   if(i%b==0) m++;
 }
 cout<<m;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
//   cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, a, b, c, cnt[50] = {0}, s;
int main()
{

    char ch;

    cin >> n >> m;

    for(i = 0; i < n; ++i)
    {
        for(j = 0; j < m; ++j)
        {
            cin >> ch;
            cnt[ch - 'a']++;
        }
    }
    a = (n % 2) * (m % 2);
    b = (n / 2) * (m % 2) + (m / 2) * (n % 2);
    c = (n / 2) * (m / 2);
    for(i = 0; i < 26; ++i)
    {
        if(cnt[i] % 2 == 1 && a != 0)
        {
            a = 0;
            cnt[i]--;
        }
    }
    for(i = 0; i < 26; ++i)
    {
        if(cnt[i] % 2 == 0)
            cnt[i] /= 2;
        else
        {
            cout << "No";
            return 0;
        }
    }
    for(i = 0; i < 26; ++i)
    {
        if(cnt[i] % 2 == 1 && b != 0)
        {
            b--;
            cnt[i]--;
        }
    }
    for(i = 0; i < 26; ++i)
    {
        if(cnt[i] % 2 == 0)
            cnt[i] /= 2;
        else
        {
            cout << "No";
            return 0;
        }
    }
    for(i = 0; i < 26; ++i)
    {
        if(cnt[i] > c)
        {
            cnt[i] -= c;
            c = 0;
        }
        else
        {
            c -= cnt[i];
            cnt[i] = 0;
        }
        if(cnt[i] != 0 && b != 0)
        {
            b -= cnt[i] * 2;
            cnt[i] = 0;
        }
    }
    if(a + b + c == 0)
        cout << "Yes";
    else
        cout << "No";


return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main()
{
    fastio;
    string a,b;
    cin>>a>>b;
    bool f=true;
    if(b.length()-a.length()!=1) f=false;
    for(ll i=0;i<a.length();++i){
        if(b[i]!=a[i]){
            f=false;
        }
    }
    if(f) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

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

		boolean[] arr = new boolean[55000];
		int limit = (int)Math.sqrt(arr.length);
		arr =  prime(arr, limit);

		while(sc.hasNext()) {
			int t = sc.nextInt();
			prev_next_prime(arr, t);
		}

		sc.close();

	}

	private static void prev_next_prime(boolean[] arr, int t) {
		int p = t;
		int n = t;

		do {
			p--;
		}while(arr[p]);

		do {
			n++;
		}while(arr[n]);

		System.out.printf("%d %d\n",p ,n);


	}

	private static boolean[] prime(boolean[] arr, int limit) {
		for (int j = 2 ; j <= limit; j++) {
			for(int k = 2; k * j < arr.length; k++) {
				arr[k * j] = true;
			}
		}

		return arr;
	}

}


Measured memory_bytes: 26536
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<char> s(n);
    for ( int i = 0; i < n; i++) {
        cin >> s.at(i);
    }
    if (s.at(k - 1) == 'A') s.at(k - 1) = 'a';
    else if (s.at(k - 1) == 'B') s.at(k - 1) = 'b';
    else s.at(k - 1) = 'c';
    for (int i = 0; i < n; i++) {
        cout << s.at(i);
    }
    cout << endl;
}

Measured memory_bytes: 256
import sys
from pprint import pprint

s = sys.stdin.readline().strip()
t = sys.stdin.readline().strip()

len_s = len(s)
len_t = len(t)
# print(len_s, len_t)

cand = []
for i in range(0, len_s - len_t + 1):
    a = list(s)
    flag = True
    for j in range(len_t):
        # print(s[i+j], t[j])
        if s[i+j] == "?":
            a[i+j] = t[j]
        elif s[i+j] != t[j]:
            flag = False
            break
    if flag:
        cand.append(a)

if cand:
    print("".join(cand[-1]).replace("?", "a"))
    sys.exit()
else:
    print("UNRESTORABLE")

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

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


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    
    
    // int road[3][3];
    // for(int i;i<3;i++){
    //     for(int j = 0; j < 3; j++)
    //     {
    //         cin >> road[i][j];
    //     } 
    // }

    int cnt = 0;
    int a = 0;
    for(int j = 0; j < 6; j++)
    {
        cin >> a;
        cnt += a;
    } 

    if(cnt == 15){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}

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

using namespace std;

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

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

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

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

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


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

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


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

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

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

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

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

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


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

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文
int main() {
	int a, b;
	cin >> a >> b;
	dump((a + b) % 24)
}

Measured memory_bytes: 256
H, W = map(int, input().split())
N = int(input())
A = [int(a) for a in input().split()]
X = [[-1] * W for _ in range(H)]
k = 0
c = 0
for i in range(H):
    for j in range(W)[::(-1 if i&1 else 1)]:
        X[i][j] = k+1
        c += 1
        if c >= A[k] and k < N-1:
            k += 1
            c = 0
for x in X:
    print(*x)

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

int main() {
    char c;
    cin >> c;
    string vowels("aiueo");
    if (vowels.find(c) != string::npos) {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int len = s.length();
  bool a = (len % 2 == 0), b = (s[0] == s[len - 1]);
  cout << (a ^ b ? "Second" : "First") << endl;
  return 0;
}


Measured memory_bytes: 512
//入出力等基本
#include <iostream>
#include <string>

#define 中心() main()
#define 返 return
#define 入力(a) cin >> a
#define 出力(a) cout << a << endl
#define 如果(a) if(a)
#define 他 else
#define 部分文字列(m,s,t) m.substr(s,t) 

using namespace std;

typedef int 整;
typedef long long 整数;
typedef string 文字列;

整数 s,t;

整 中心(){
    文字列 m;
    入力(m);
    文字列 n = 部分文字列(m,0,4);
    如果(n == "YAKI") 出力("Yes");
    他 出力("No");
    返 0;
}

Measured memory_bytes: 504
//Author : Prakhar Asaiya
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<b;++i)
#define REPN(i,a,b) for(int i=a;i<=b;++i)
#define REPV(i,a,b) for(int i = a; i>= b; --i)
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define with_tests int t; cin>>t; while(t--){ solve(); }
#define without_tests solve();
#define ll long long
#define INF 100000000
#define ff first
#define ss second
const int M=1e9+7;

void solve()
{
	int n;
	cin>>n;
	vector<int> A(n), B(n), C(n);
	REP(i,0,n)
	{
		cin>>A[i]>>B[i]>>C[i];
	}
	vector<vector<int> > dp(n, vector<int> (3));
	dp[0][0] = A[0];
	dp[0][1] = B[0];
	dp[0][2] = C[0];
	REP(i,1,n)
	{
		dp[i][0] = A[i] + max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = B[i] + max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] = C[i] + max(dp[i-1][1], dp[i-1][0]);
	}
	cout<<max({dp[n-1][0], dp[n-1][1], dp[n-1][2]})<<"\n";
}

int main()
{/*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#*/
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  //with_tests;
  without_tests;
  return 0;
}


Measured memory_bytes: 9788
S=str(input())
for i in range(20000):
    if S[-7:]=="dreamer":
        S=S[:-7]
    if S[-6:]=="eraser":
        S=S[:-6]
    if S[-5:]=="dream" or S[-5:]=="erase":
        S=S[:-5]
    if S[-7:]!="dreamer" and S[-6:]!="eraser" and S[-5:]!="dream" and S[-5:]!="erase":
        break
if len(S)==0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265358979323846264338327950L
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " = " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
        __f(comma+1, args...);
    }
#else
#define debug(...)
#endif
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
const ll L = 3e3 + 5;
ll dp[L][L][6];
ll val[L][L];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	ll r, c, k;
 	cin >> r >> c >> k;
 	for (ll i = 0; i < k; i++) {
 		ll a, b, c;
 		cin >> a >> b >> c;
 		val[a][b] = c;
 	}
 	for (ll i = 1; i <= r; i++) {
 		for (ll j = 1; j <= c; j++) {
	 		for (ll k = 0; k < 4; k++) dp[i][j][k] = max(dp[i][j - 1][k], dp[i - 1][j][4]);
 			if (val[i][j] != 0) {
 				ll v = val[i][j];
 				for (ll k = 1; k < 4; k++) {
 					dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k - 1] + v);
 				}
 				dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j][4] + v);
 			}
	 		ll temp = 0;
	 		for (ll k = 0; k < 4; k++) temp = max(temp, dp[i][j][k]);
	 		dp[i][j][4] = temp;
 		}
 	}
 	cout << dp[r][c][4] << endl;
	return 0;
}

Measured memory_bytes: 496480
n,lim = map(int,input().split())
v,w = [0]*n,[0]*n
for i in range(n):
  v[i],w[i] = map(int,input().split())
dp = [[0]*(lim+1) for _ in range(n+1)]
for i in range(n):
  for j in range(lim+1):
    if w[i] > j:
      dp[i+1][j] = dp[i][j]
    else:
      dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i])
print(dp[n][lim])


Measured memory_bytes: 25500
def west(d):
	tmp=d[4]
	d[4]=d[1]
	d[1]=d[3]
	d[3]=d[6]
	d[6]=tmp

def east(d):
	tmp=d[4]
	d[4]=d[6]
	d[6]=d[3]
	d[3]=d[1]
	d[1]=tmp

def north(d):
	tmp=d[1]
	d[1]=d[2]
	d[2]=d[6]
	d[6]=d[5]
	d[5]=tmp

def south(d):
	tmp=d[1]
	d[1]=d[5]
	d[5]=d[6]
	d[6]=d[2]
	d[2]=tmp

def spin(d):
	tmp=d[2]
	d[2]=d[3]
	d[3]=d[5]
	d[5]=d[4]
	d[4]=tmp

def kaiten(d, op):
	if   op == "W": west(d)
	elif op == "E": east(d)
	elif op == "N": north(d)
	elif op == "S": south(d)

def inputDice():
	return list(map(int,("-1 "+input()).split()))

def equal(da, db):
	for op in list("NWWWN-"):
		for i in range(4):
			if(da[1]==db[1] and da[2]==db[2] and da[3]==db[3] and da[4]==db[4] and da[5]==db[5] and da[6]==db[6]):
				return True
			spin(db)
		kaiten(db,op)
	return False

def yes(d):
	for i in range(n):
		for j in range(i):
			if equal(d[i], d[j]):
				return False
	return True

n=int(input())

d=[inputDice() for i in range(n)]

if yes(d):
	print("Yes")
else:
	print("No")


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N, x[55], y[55];

int main()
{
    cin >> N;
    map<pair<int, int>, int> mp;

    for (int i = 0; i < N; i++)
    {
        cin >> x[i] >> y[i];
    }

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (i == j)
                continue;
            pair<int, int> p = make_pair(x[i] - x[j], y[i] - y[j]);
            mp[p]++;
        }
    }
    int mx = 0;
    for (auto &p : mp)
        mx = max(mx, p.second);
    cout << N - mx << endl;
}

Measured memory_bytes: 384
#https://atcoder.jp/contests/abc152/submissions/9635583
#[popcount]
#http://zh-wang.github.io/blog/2015/05/13/popcount-in-ruby/
#http://www.mwsoft.jp/programming/java/java_lang_integer_bit_count.html
#http://sifi-border.hatenablog.com/entry/2018/11/14/031049

def dfs(v, tv, pp = -1)
  return true if v == tv
  @edge[v].each do |n, path|
    next if n == pp
    if dfs(n, tv, v)
      @es << path
      return true
    end
  end
  return false
end

#64bit
def popcount(v)
  v = (v&0x5555555555555555) + ((v>>1)&0x5555555555555555)
  v = (v&0x3333333333333333) + ((v>>2)&0x3333333333333333)
  v = (v&0x0f0f0f0f0f0f0f0f) + ((v>>4)&0x0f0f0f0f0f0f0f0f)
  v = (v&0x00ff00ff00ff00ff) + ((v>>8)&0x00ff00ff00ff00ff)
  v = (v&0x0000ffff0000ffff) + ((v>>16)&0x0000ffff0000ffff)
  v = (v&0x00000000ffffffff) + ((v>>32)&0x00000000ffffffff)
end

n = gets.to_i
@edge = Array.new(n+1){[]}
(n - 1).times do |path|
  a, b = gets.split.map(&:to_i)
  @edge[a] << [b, path]
  @edge[b] << [a, path]
end

m = gets.to_i
mm = m.times.map{gets.split.map(&:to_i)}
pathes = Array.new(m, 0)
@es = []
mm.each_with_index do |ary, i|
  a, b = ary[0], ary[1]
  a, b = b, a if a < b
  @es = []
  dfs(a, b)
  @es.each do |path|
    pathes[i] |= (1 << path)
  end
end

ans = 0
(1<<m).times do |i|
  mask = 0
  m.times do |j|
    mask |= pathes[j] if (i >> j) & 1 == 1
  end
  white = popcount(mask)
  now = 1 << (n - 1 - white)
  if popcount(i) % 2 == 0
    ans += now
  else
    ans -= now
  end
end
p ans

Measured memory_bytes: 1916
n,k=map(int,input().split())
p=list(map(int,input().split()))
#p=sorted(p,reverse=True)
saidai=0

for i in range(n):
    p[i]=(p[i]+1)/2
#print(p)
gokei=0
for i in range(k):
    gokei+=p[i]
saidai=gokei
for i in range(1,n-k+1):
    gokei+=p[i+k-1]-p[i-1]
    #print(gokei)
    saidai=max(saidai,gokei)

print(saidai)


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

using ll = long long;

#define for_(i, a, b) for(int i = (a);i < (b);++i)
#define rfor_(i, a, b) for(int i = (b)-1;i >= (a);--i)
#define rep(i, n) for_(i, 0, n)
#define rrep(i, n) rfor_(i, 0, n)

int N, x;
int a[102];

int cnt;

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

  cin>>N>>x;
  rep(i, N)cin>>a[i];

  sort(a, a+N);

  rep(i, N) {
    if(x<a[i])break;
    cnt++;
    x -= a[i];
  }

  if(cnt==N && x>0)cnt--;

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

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

int main() {
	ll ans = 0;
	ll tmp;
	int n; 
	cin >> n;
	string s;
	cin >> s;
	int lw = 0, rr = n-1;
	while(lw < rr){
		while(s[lw] != 'W' && lw < rr) lw++;
		while(s[rr] != 'R' && lw < rr) rr--;
		if(s[rr] == 'R' && s[lw] == 'W'){
			s[rr] = 'W';
			s[lw] = 'R';
			ans ++;
		}
	} 
	cout << ans << endl;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#include<unordered_map>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll ans = 0;
int main() {
	cin >> N;
	vector<int>A(N);
	for (int i = 0; i < N; i++)cin >> A[i];
	int ans = *min_element(A.begin(), A.end());
	int tmp = 0;
	while (tmp != ans) {
		tmp = ans;
		for (int i = 0; i < N; i++) {
			if (A[i]%tmp)ans = min(A[i] % tmp, ans);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mxn=5010,md=924844033;
int n,k,a[mxn],fct[mxn],f[mxn][2],g[mxn][2];
int main()
{
	scanf("%d%d",&n,&k);
	fct[0]=1;
	for (int i=1;i<=n;++i)
		fct[i]=1ll*fct[i-1]*i%md;
	f[0][0]=1;
	for (int i=1;i<=n&&i<=k;++i){
		int m=(n-i)/k;
		for (int j=1;j<=m;++j)
			for (int l=n;l>=0;--l){
				f[l][0]=(f[l][0]+f[l][1])%md;
				if (l) f[l][1]=f[l-1][0];
			}
		for (int j=0;j<=n;++j)
			f[j][0]=(f[j][0]+f[j][1])%md,f[j][1]=0;
		for (int j=1;j<=m;++j)
			for (int l=n;l>=0;--l){
				f[l][0]=(f[l][0]+f[l][1])%md;
				if (l) f[l][1]=f[l-1][0];
			}
		for (int j=0;j<=n;++j)
			f[j][0]=(f[j][0]+f[j][1])%md,f[j][1]=0;
	}
	int ans=0;
	for (int i=0,flg=1;i<=n;++i,flg*=-1)
		ans=(ans+1ll*flg*f[i][0]*fct[n-i])%md;
	printf("%d\n",(ans+md)%md);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double

int ans=0;
int32_t main()
{
	IOS
	int H,W,h,w;cin>>H>>W>>h>>w;
	cout<<(H-h)*(W-w)<<endl; 
	
}
			
	
	
	
	
	

	

	

	
		


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

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

const ll mod = 1e9 + 7;
const ll IMF = 1LL << 60;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//






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

        int sz = s.size();

        vector<int> east(sz+2,0);
        vector<int> west(sz+2,0);


        for(int i = 0; i < sz; i++){
                east[i+1] = east[i];
                if(s[i] == 'E'){
                        east[i+1]++;
                }
        }
        for(int i = 0; i < sz; i++){
                west[i+1] = west[i];
                if(s[i] == 'W'){
                        west[i+1]++;
                }
        }

        int ans = 1e9;
        for(int i = 0; i < sz; i++){
                int tmp;
                tmp = (west[i] - west[0]) + (east[sz] - east[i+1]);
                ans = min(ans,tmp);
        }

        cout << ans << endl;
        return 0;

}













































Measured memory_bytes: 3076
def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


def main():
    a,b,k = map(int,input().split())
    divisor1 = set(divisor(a))
    divisor2 = set(divisor(b))
    divisor3 = divisor1 & divisor2
    divisor3 = sorted(list(divisor3))

    print(divisor3[-k])


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG

/*
 // 深さ優先探索
vector<bool> seen;
int dfs(const Graph &G, ll v) {
    seen[v] = true; // v を訪問済にする
    int score = 0; 

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー

        // 負荷さ優先探索中の処理



        dfs(G, next_v); // 再帰的に探索, 毎回mat渡してええの？
    }
    return score;
} */

/*
//桁数の計算
ll keta(ll num){
  ll ans= 0 ;
  ll rem;

  for (ll i = 4; i >= 0 ; i--){
    rem = pow(10,i);
    ans += (num / rem); 
    num = num % rem;
  }
  return ans;
}
*/


int main() {
    ll A, B, C, K, ans;
    cin >> A >> B >> C >> K;
    //vector<ll> a(N);
    
    if (K <= A){
      ans = K;
    }else if(K <= (A+B)){
      ans = A;
    }else{
      ans = 2 * A + B - K;
    }

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


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

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll h,n; cin >> h >> n;
  ll res = 0;
  rep(i,n) {ll temp; cin >> temp; res +=temp;
  }  
  if(h-res<=0) PYES
  else PNO
  return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("O3") 
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,popcnt,abm,mmx") 
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>                               
using namespace std;

#define PI acos(-1)
#define pb push_back
#define fi first
#define se second
#define TASK ""
#define move djskdfjksl
#define sz(a) (int)(a).size()
#define all(c) (c).begin(), (c).end()
#define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock()/CLOCKS_PER_SEC)

#define has(mask, i) ((mask >> i) & 1)

#ifndef LOCAL
	#define cerr if (0) cerr
#endif

typedef long long ll;
typedef long double ld;
typedef vector < int > vi;
typedef vector < ll > vll;
typedef pair < int, int > pii;
typedef vector < vi > vvi;
typedef vector < pii > vpii;
typedef vector < string > vs;

ll N, M;

void solve() {
	cin >> N >> M;
	ll ans = (1 << M) * ((N - M) * 100 + M * 1900);
	cout << ans;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef LOCAL
	assert(freopen("xxx.in", "r", stdin));
	assert(freopen("xxx.out", "w", stdout));
#else
	//freopen(TASK".in", "r", stdin);
	//freopen(TASK".out", "w", stdout);
#endif		
	solve();
#ifdef LOCAL
	TIMESTAMP;
#endif	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int K,A,B;
    cin>>K>>A>>B;

    int ans;
    if(B-A<=2 or K<A-1){
        ans=K+1;
    }
    else{
        ans=A,K-=A-1;
        ans+=(B-A)*(K/2);
        ans+=K%2;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    string S;
    cin >> N >> S;
    int ans = 1;
    char prev = S[0];
    for (int i = 1; i < N; i++)
    {
        if (prev != S[i])
        {
            ++ans;
        }
        prev = S[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int a, b; cin >> a >> b;
  int s = a-1;
  int t = b-1;
  cout << DUP(t,s) << endl;
}

Measured memory_bytes: 256
N, A, B, C, D = map(int, input().split())

# マイナス方向に遷移する回数iを全通り試す
for i in range(N):
    dMin = -D * i + C * (N - 1 - i)
    dMax = -C * i + D * (N - 1 - i)
    if A + dMin <= B <= A + dMax:
        print('YES')
        break
else:
    print('NO')


Measured memory_bytes: 2940
N=int(input())
A=list(map(int,input().split()))

S=0
a=1
M=[0]*N
for i in range(N):
    S+=A[i]*a
    a*=(-1)

a=1
for i in range(N):
    M[i]=S*a
    S=S-A[i]*a*2
    a*=(-1)

print(*M)


Measured memory_bytes: 14092
#include"bits/stdc++.h"
#define INFLL        1e18
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define DELNL        cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll=long long;
using ull=unsigned long long;
template<typename T>using pqg=priority_queue<T,vector<T>,greater<T>>;
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}

int main()
{
    ll n=in();
    map<string,ll>s;
    REP(i,n){
        string tmp;cin>>tmp;sort(ALL(tmp));
        ++s[tmp];
    }
    ll cnt=0;
    REPC(si,s){
        ll c=si.second;
        cnt+=(c-1)*c/2;
    }
    cout<<cnt<<endl;
}

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

typedef long long ll;
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0);
//#define cerr if(false)cerr
#define PRINT(x) cerr<<"\n" << (#x) << " is " << (x) << endl;
//Erase duplicates in vector
#define REMOVE_DUP(x) x.erase(unique(x.begin(), x.end()), x.end());
#define UP toupper // lowercase to uppercase;
#define DOWN tolower
#define SZ(a) (int)a.size()
#define EB emplace_back
#define PB push_back
#define REP(i, a, b) for(int i=a; i<b; i++)
#define PER(i, a, b) for(int i=a; i>=b; i--)
ostream_iterator<int> output(cout, " ");
#define MOD 1e9+7
#define INF INT_MAX;
#define lim_size 200007


void solve(){
	int n, x, y;
	cin >> n >> x >> y;
	unordered_map<int, int> m;
	for(int i=1; i<n; i++){
		for(int j=i+1; j<=n; j++){
			int dist = min(j - i, abs(i-x) + 1 + abs(j-y));
			m[dist]++;
		}
	}
	for(int i=1; i<n; i++){
		cout << m[i] << endl;
	}
}

int main(){
	FAST_IO;
	int t=1; //cin >> t;
	while(t--){
		solve();
	}
}	

Measured memory_bytes: 384
n,m,*a_l = map(int, open(0).read().split())
all_votes = sum(a_l)
boder = all_votes/(4*m)
cnt = 0
for a in a_l:
    if a >= boder:
        cnt += 1
if cnt>= m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(ll i=n;i<=N;++i)
#define rap(i,n,N) for(ll i=n;i>=N;--i)
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>>>> " << #x << " -> " << x << endl;
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define piii pair<int,pii>
#define plll pair<ll,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
//#define endl "\n"
const int MAX = 1e3+5;
const ll MAX2 = 11;
const ll MOD = 1000000007;
const ll INF = 1e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 450;

string s;

int main(){
//	cout<<fixed<<setprecision(15);
//    freopen("output.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    while(cin>>s){
    	s[3] = '8';
    	cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int a, b;
    cin >> a >> b;
    if (a > 8 || b > 8) {
        cout << ":(" << endl;
    }
    else {
        cout << "Yay!" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
using namespace std;
const string r[] = { "402351", "310542", "152304", "215043" };
int n; string s;
int main() {
	while (cin >> n, n) {
		vector<int> a = { 1, 2, 4, 3, 5, 6 };
		for (int i = 0; i < n; i++) {
			cin >> s;
			int d = 0;
			if (s[0] == 'e') d = 1;
			if (s[0] == 's') d = 2;
			if (s[0] == 'w') d = 3;
			vector<int> b = a;
			for (int j = 0; j < 6; j++) b[j] = a[r[d][j] - 48];
			a = b;
		}
		cout << a[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 3016
n = gets.chomp.to_i
s = gets.chomp.split("")


ans = s.count("R")*s.count("G")*s.count("B")

1.step(n/2) do |dis|
    0.step(n - (dis*2)-1) do |i|
    if (s[i] != s[i + dis] && s[i + dis] != s[i +  dis*2] && s[i + dis*2] != s[i])
    ans -= 1 #等間隔のRGBだったらansを-1する
    end
    end
end
puts ans

Measured memory_bytes: 14416
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	if((s.size()%2 == 0) ^ (s[0] == s[s.size()-1])) cout << "Second" << endl;
	else cout << "First" << endl;
	return 0;
}


Measured memory_bytes: 512
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
  return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

N = I()
T = [0]*N
for i in range(N):
  T[i] = I()

import fractions
ans = 1
for i in range(N):
  f = fractions.gcd(ans,T[i])
  ans = ans*T[i]//f 
print(ans)

Measured memory_bytes: 64876
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    while (true) {
      String str = stdin.next();
      if (str.equals("-")) {
        break;
      }

      int m = stdin.nextInt();
      for (int i = 0; i < m; i++) {
        int h = stdin.nextInt();
        str = str.substring(h) + str.substring(0, h);
      }
      System.out.println(str);
    }
  }

}

Measured memory_bytes: 18296