akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main()
{
	while (true) {
		int N, T, L, B;

		cin >> N >> T >> L >> B;

		if (N == 0 && T == 0 && L == 0 && B == 0) {
			break;
		}

		vector<char> board(N + 1, '0');

		rep(i, L) {
			int temp;

			cin >> temp;

			board[temp] = 'L';
		}

		rep(i, B) {
			int temp;

			cin >> temp;

			board[temp] = 'B';
		}

		vector<vector<double>> dp(N + 1, vector<double>(T + 2, 0));

		dp[0][0] = 1;

		rep(turn, T) {
			rep(pos, N) {
				if (dp[pos][turn] == 0) {
					continue;
				}

				for (int i = 1; i <= 6; i++) {
					int npos = pos + i;
					int nturn = turn + 1;

					if (npos > N) {
						npos = N - (npos - N);
					}

					if (board[npos] == 'B') {
						npos = 0;
					}
					else if (board[npos] == 'L') {
						nturn++;
					}

					dp[npos][nturn] += dp[pos][turn] / 6;
				}
			}
		}

		double ans = 0;

		for (int i = 1; i <= T; i++) {
			ans += dp[N][i];
		}
		
		cout << fixed << ans << endl;
	}

	return 0;
}

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

using namespace std;
int n,m,x,y,vis[100009];
vector<int>v[100009];
int dp[100009];
int DFS(int node)
{
    if(dp[node]!=-1)
        return dp[node];
    dp[node]=0;
    for(int i=0;i<v[node].size();i++)
    {
            dp[node]=max(dp[node],DFS(v[node][i])+1);
    }
    return dp[node];
}
int main()
{
    cin>>n>>m;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        x--;y--;
        v[x].push_back(y);
    }
    int mx=0;
    for(int i=0;i<n;i++)
    {
        mx=max(DFS(i),mx);
    }
    cout<<mx;
}


Measured memory_bytes: 8192
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<pii,int> ppiii ;
typedef unsigned long long ull ;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;

int main(){
	string str;
	int H,W;
	cin >> H >> W;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin>>str;
			
			if(str=="snuke"){
				char c='A';
				c=c+j;
				cout<<c<<i+1<<endl;
				
			}
		}
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			long X = scan.nextLong();
			
			
			long a = 100;
			int count = 0;
			while(true) {
				
				a = (long)((double)a*1.01);
				count++;
				
				if(X<=a)break;
			}
			
			
			System.out.println(count);
			
		}
		
		
	}
		

}


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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    int r = N - 1 - i;
    if (S.at(i) != S.at(r)) cnt++;
  }
  cout << cnt / 2 << "\n";
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;




int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================

	ll S,C;
	cin >> S >> C;


	if (S * 2 >= C) {
		cout << C / 2;
	}
	else {
		cout << (C - S * 2) / 4 + S;
	}



}	




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  vector<int> d(5);
  int k;
  cin >> d[0] >> d[1] >> d[2] >> d[3] >> d[4] >> k;

  string answer = "Yay!";

  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      if (k < d[j] - d[i]) {
        answer = ":(";
        break;
      }
    }
    if (answer == ":(") {
      break;
    }
  }
   
  cout << answer << endl;
 
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

class Program
{
    void Run()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int l = sc.NextInt();
        int min = 1 << 19;
        int sum = 0;
        int res = 0;
        for (int i = 0; i < n; i++)
            sum += l + i;
        for (int i = 0; i < n; i++)
        {
            int s = 0;
            for (int j = 0; j < n; j++)
            {
                if (i == j) continue;
                s += l + j;
            }
            int d = Math.Abs(sum - s);
            if (d < min)
            {
                min = d;
                res = s;
            }
        }
        Console.WriteLine(res);
    }
    
    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)

    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 11220
H, W, N, *A = map(int, open(0).read().split())

ret = [[0 for i in range(W+2)] for j in range(H+2)]
for i in range(H+2):
  for j in range(W+2):
    if i == 0:
      ret[i][j] = 1
      continue
    if i == H+1:
      ret[i][j] = 1
      continue
    if j == 0:
      ret[i][j] = 1
      continue
    if j == W+1:
      ret[i][j] = 1
      continue

ret[1][1] = 1

x = 1
y = 1
dx = 1
dy = 0

for i, a in enumerate(A, 1):
  if i == 1:
    a -= 1
  while a > 0:
    _x = x + dx
    _y = y + dy
    if ret[_y][_x]:
      if dx == 1:
        dx = 0
        dy = 1
        continue
      if dx == -1:
        dx = 0
        dy = -1
        continue
      if dy == 1:
        dx = -1
        dy = 0
        continue
      if dy == -1:
        dx = 1
        dy = 0
        continue
    else:
      ret[_y][_x] = i
      x = _x
      y = _y
      a -= 1
      
for i in range(H):
  print(*ret[i+1][1:W+1])


Measured memory_bytes: 42608
let N = Int(readLine()!)!
let S = Array(readLine()!)

var count = 0
var numberOfCharacters = Array(repeating: 0, count: 3)
for i in 0 ..< N {
    switch S[i] {
    case "R":
        numberOfCharacters[0] += 1
    case "G":
        numberOfCharacters[1] += 1
    case "B":
        numberOfCharacters[2] += 1
    default:
        break
    }
    guard i + 1 < N else { continue }
    for j in i + 1 ..< N {
        let k = 2 * j - i
        guard k < N else { continue }
        if S[i] != S[j] && S[i] != S[k] && S[j] != S[k] {
            count += 1
        }
    }
}

print(numberOfCharacters.reduce(1, *) - count)


Measured memory_bytes: 7904
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  int M = a[n-1];
  if(n == 2) printf("%d %d\n",a[1],a[0]);
  else{
    int ans = 0;
    REP(i,n-1){
      if(abs(2*a[i] - M) < abs(2*ans - M)) ans = a[i];
    }
    printf("%d %d\n",M,ans);
  }
  return 0;
}


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

int main(){
  int a, b, c, tmp;
  cin >> a >> b >> c;
  while (a > b || b > c){
  if (a > b){
    tmp = a;
    a = b;
    b = tmp;
  }
  if (b > c){
    tmp = b;
    b = c;
    c = tmp;
  }
  }

  cout << a << " " << b << " " << c << endl;

return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(), v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 1;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        int a[n];
        for(int &it : a){
            cin >> it;
        }
        int ans = INF;
        for(int i = -200; i <= 200; i++){
            int curr = 0;
            for(int &j : a){
                curr += (i - j) * (i - j);
            }
            ans = min(ans, curr);
        }
        cout << ans << '\n';
    }
}

Measured memory_bytes: 34588
n = int(input())
words = ['' for i in range(n)]
flag = True
for i in range(n):
    word = input()
    if i == 0:
        words[i] = word
    elif word not in words and words[i-1][-1] == word[0]:
        words[i] = word
    else:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#define MAX 1000
#define Rep(i,m,n) for(i=m;i<n;i++)
#define rep(i,n) Rep(i,0,n)
using namespace std;
	int main(){
		short n,i,j,s[MAX][MAX],min,max;
		char u[MAX][MAX];
		while(cin>>n,n){
			max=0;
			rep(i,n)
				cin>>u[i];
			rep(i,n)
			rep(j,n)
			{
				if(u[i][j]=='.')
					s[i][j]=1;
				else s[i][j]=0;
			}
			Rep(i,1,n)
				Rep(j,1,n){
					if(s[i][j]==1){
						min=n;
						if(min>s[i][j-1])
							min=s[i][j-1];
						if(min>s[i-1][j])
							min=s[i-1][j];
						if(min>s[i-1][j-1])
							min=s[i-1][j-1];
						s[i][j]=min+1;
					}
					if(s[i][j]>max)
					max=s[i][j];
				}
			cout<<max<<endl;
		}
		return 0;
	}

Measured memory_bytes: 1544
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,h,w;
  cin >> n >> h >> w;
  int cnt=0;
  for(int i=0;i<n;i++){
    int a,b;
    cin >> a >> b;
    if(a>=h&&b>=w){
      cnt++;
    }
  }
  cout << cnt << endl;
}

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

using namespace std;

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  string s; cin >> s;
  if(s[1] == 'B') s[1] = 'R';
  else s[1] = 'B';
  cout << s << endl;
}


Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<map>
#include<iterator>
#include<algorithm>
#include<cstring>
#include<set>
#include<cstdlib>
#include<cmath>
using namespace std;
int main()
{
	long long int a, b, c, d, i, j, k;
	cin >> a;
	d = a / 500;
	d = 1000 * d;
	a = a % 500;
	d = d + (a / 5)*5;
	cout << d << endl;
	return 0;
}

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

long long gcd(long long a,long long b){
    if(a<b) swap(a,b);
    long long r;
    while(r=a%b){
      a=b;
      b=r;
    }
    return b;
}

int main(void){
    int N;
    cin >> N;
    vector<long long> T(N);
    for(auto& i : T) cin >> i;

    long long ans = T[0];
    for(int i=0; i<N; i++){
        ans = ans/gcd(ans, T[i])*T[i];
    }

    cout << ans << endl;

    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int main() {
	char c;
	cin >> c;
	
	string s = "aiueo";
	bool flag = false;
	inc(i, 5) { if(c == s[i]) { flag = true; } }
	
	cout << (flag ? "vowel" : "consonant") << endl;
	
	return 0;
}


Measured memory_bytes: 256
#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>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {
    
    int N;
    cin >> N;
    vector<int> V(N);
    REP(i, N) cin >> V[i];
    sort(V.begin(), V.end());
    double tmp = V[0];
    REP(i, N - 1) tmp = (tmp + V[i + 1]) / 2.0;
    cout << tmp << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int h, w;
    cin >> h >> w;
    int cnt[26] = {0};
    rep(i, h) rep(j, w) {
        char c;
        cin >> c;
        ++cnt[c-'a'];
    }
    int cnt4;
    int cnt2;
    if (!(h&1) && !(w&1)) {
        rep(i, 26) {
            //cout << cnt[i] << endl;
            if (cnt[i] % 4 != 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    else if ((h&1) && (w&1)) {
        cnt4 = h * w - h - w + 1;
        cnt2 = h + w - 1;
        bool flg1 = false;
        rep(i, 26) {
            if (cnt4 - (cnt[i] / 4) * 4 < 0) {
                cnt[i] -= cnt4;
                cnt4 = 0;
            }
            else {
                cnt4 -= (cnt[i] / 4) * 4;
                cnt[i] -= (cnt[i] / 4) * 4;
            }
            if (cnt2 - (cnt[i] / 2) * 2 < 0) {
                cnt[i] -= cnt2;
                cnt2 = 0;
            }
            else {
                cnt2 -= (cnt[i] / 2) * 2;
                cnt[i] -= (cnt[i] / 2) * 2;
            }
            if (cnt[i]) {
                if (!flg1) {
                    flg1 = true;
                }
                else {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
        if (!flg1) {
            cout << "No" << endl;
            return 0;
        }
    }
    else {
        if (h&1) {
            cnt4 = h * w - w;
            cnt2 = w;
        }
        else {
            cnt4 = h * w - h;
            cnt2 = h;
        }
        rep(i, 26) {
            //cout << cnt[i] << endl;
            if (cnt4 - (cnt[i] / 4) * 4 < 0) {
                cnt[i] -= cnt4;
                cnt4 = 0;
            }
            else {
                cnt4 -= (cnt[i] / 4) * 4;
                cnt[i] -= (cnt[i] / 4) * 4;
            }
            if (cnt[i]&1) {
                cout << "No" << endl;
                return 0;
            }
            if (cnt2 - cnt[i] < 0) {
                cout << "No" << endl;
                return 0;
            }
            cnt2 -= cnt[i];
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

int N;

int main() {
    cin >> N;
    cout << N * N * N << endl;
}

Measured memory_bytes: 256
/***************************************************
 * Problem Name : A.cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2020-05-17
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.rbegin(), v.rend())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define F first
#define S second
#define MAX 100005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm ( ll a, ll b ) {
    return ( a / __gcd ( a, b ) ) * b;
}
/************************************ Code Start Here ******************************************************/
int main () {
    //~ __FastIO;
    //~ cout << setprecision (10) << fixed;
    string n;
    cin >> n;
    int x = (int) n.size() - 1;

    if (n[x] == '2' || n[x] == '4' || n[x] == '5' || n[x] == '7'
        || n[x] == '9') cout << "hon\n";
    else if (n[x] == '3') cout << "bon\n";
    else cout << "pon\n";

    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];

  rep(i, N-K){
    if(A[K+i] > A[i]) cout << "Yes" << endl;
    else  cout << "No" << endl;
  }
}


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

int main()
{
  int n;
  int a, b, c, d;
  int combi=0;

  while(cin >> n) {
    for(a=0; a<10; a++) {
      for(b=0; b<10; b++) {
        for(c=0; c<10; c++) {
          for(d=0; d<10; d++) {
            if(a+b+c+d == n) {
              combi++;
            }
          }
        }
      }
    }
    cout << combi << "\n";
    combi=0;
  }
  return 0;
}

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

const long long MOD = 1000000007;
const int MX = 1000005;

struct Sieve{
	int n;
	vector<int> f, primes;
	Sieve(int n):n(n), f(n+1){
		f[0] = f[1] = -1;
		for(long long i = 2; i <= n; i++){
			if(f[i]) continue;
			primes.push_back(i);
			f[i] = i;
			for(long long j = i*i; j <= n; j += i){
				if(!f[j]) f[j] = i;
			}
		}
	}
	bool isPrime(int x){return f[x] == x;}
	vector<int> factorList(int x){
		vector<int> res;
		while(x != 1){
			res.push_back(f[x]);
			x /= f[x];
		}
		return res;
	}
	vector<pair<int, int>> factor(int x){
		vector<int> fl = factorList(x);
		if(fl.size() == 0) return {};
		vector<pair<int, int>> res(1, pair<int, int>(fl[0], 0));
		for(int p : fl){
			if(res.back().first == p){
				res.back().second++;
			}
			else{
				res.emplace_back(p, 1);
			}
		}
		return res;
	}
};

long long mod_pow(long long x, long long n, long long mod){
	long long res = 1;
	while(n > 0){
		if(n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Sieve sieve(1e6);
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	map<int, int> mp;
	for(int i = 0; i < n; i++){
		auto f = sieve.factor(a[i]);
		for(auto p : f){
			mp[p.first] = max(mp[p.first], p.second);
		}
	}
	long long lcm = 1;
	for(auto p : mp){
		for(int i = 0; i < p.second; i++){
			lcm = (lcm * p.first) % MOD;
		}
	}
	long long ans = 0;
	for(int i = 0; i < n; i++){
		long long b = (lcm * mod_pow(a[i], MOD-2, MOD)) % MOD;
		ans = (ans + b) % MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4984
N = 5
A = [0] * N
for i in range(N):
  A[i] = int(input())
k = int(input())

ans = 0

for i in range(N):
  for j in range(i+1, N):
    if abs(A[i] - A[j]) > k:
      ans += 1

if ans > 0:
  print(':(')
else:
  print('Yay!')

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



int main()
{
	int a[105];
	for (int i = 0; i <= 100; i++)
	{
		a[i] = 0;
	}
	int N;
	int b[100];
	
	int count = 0;
	cin >> N;
	for (int i = 1; i <= N; i++)
	{
		cin >> b[i];
		if (b[i] > i)
		{
			count++;
			break;
		}

		for (int j = N; j >= b[i] + 1; j--)
		{
			a[j] = a[j - 1];
		}

		a[b[i]] = b[i];
	}

	if (count != 0)
		cout << -1;
	else
	{
		for (int i = 1; i <= N; i++)
		{
			cout << a[i] << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define VAR(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    VAR(int, N);

    vector<pii> ps(N);
    i64 ans = 0;
    rep(i, 0, N) {
        VAR(int, a, b);
        ps[i] = { a, b };
        ans += a;
    }

    sort(all(ps), [](auto a, auto b) {
        return a.first + a.second > b.first + b.second;
    });

    for (int i = 1; i < N; i += 2) {
        ans -= ps[i].first + ps[i].second;
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 1792
#include <set>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int n,q;
	cin>>n>>q;
	set<int> ldr;
	vector<int> s(n),ss(n);
	for(int i=0; i<n; i++){
		cin>>s[i];
		ss[i]=s[i];
	}
	sort(ss.begin(),ss.end());
	for(;q--;){
		string job;
		int num;
		cin>>job>>num;
		if(job[0]=='A'){
			ldr.insert(num-1);
		}else if(job[0]=='R'){
			ldr.erase(num-1);
		}else if(job[0]=='C'){
			int result = -1;
			if(ldr.size()){
				for(int l=0,r=2000000000; r!=l;){
					int c = l + (r-l) / 2;
					
					priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> range,mergedRange;
					for(auto it=ldr.begin(); it!=ldr.end(); it++){
						range.push(make_pair(s[(*it)]-c,s[(*it)]));
					}
					while(range.size()){
						pair<int,int> top = range.top();
						range.pop();
						if(range.size() && top.second >= range.top().first){
							if(top.second >= range.top().second){
								range.pop();
							}else{
								top.second = range.top().second;
							}
							range.push(top);
						}else{
							mergedRange.push(top);
						}
					}
					int count = ss.size();
					while(mergedRange.size()){
						auto b = lower_bound(ss.begin(), ss.end(), mergedRange.top().first);
						auto e = upper_bound(ss.begin(), ss.end(), mergedRange.top().second);
						count -= e-b;
						mergedRange.pop();
					}
					
					if(num >= count){
						result = r = c;
					}else{
						if(l==c) break;
						l = c;
					}
				}
			}else if(num>=s.size()){
				result = 0;
			}
			if(result<0) cout<<"NA"<<endl;
			else cout<<result<<endl;
		}
	}
}

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

int main() {
  int A,B,C,D,E;
  cin >> A >> B >> C >> D >> E;
  
  if (A == 0){
    cout << 1 << endl;
  }
  else if (B == 0){
    cout << 2 << endl;
  }
  else if (C == 0){
    cout << 3 << endl;
  }
  else if (D == 0){
    cout << 4 << endl;
  }
  else if (E == 0){
    cout << 5 << endl;
  }
}



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

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

ll return_lcm(ll a, ll b){
    ll gcd = return_gcd(a, b);
    return a / gcd * b;
}

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

    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    map<ll,ll> mp;
    for(int i = 0; i < n; i++){
        int x = a[i];
        int cnt = 0;
        while(x % 2 == 0){
            x /= 2;
            cnt++;
        }
        mp[cnt]++;
    }
    if(mp.size() > 1) {
        cout << 0 << endl;
        return 0;
    }

    ll LCM = a[0] / 2;
    for(int i = 1; i < n; i++){
        ll x = a[i] / 2;
        LCM = return_lcm(LCM, x);
    }

    cout << (m + LCM) / LCM / 2 << endl;
}




Measured memory_bytes: 1024
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back

char N;
int p[100];
int ans=0;
signed main(){
    scanf("%lld",&N);
    rep(i,N){scanf("%lld",&p[i]);}
    rep(i,N-1){
        if(i==0)continue;
        if(((p[i]-p[i-1])*(p[i]-p[i+1])<0)||( (p[i]-p[i-1])*(p[i]-p[i+1])==0&&p[i]==max(p[i-1],p[i+1]) ))ans++;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/format.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(i, n) repr((i), 0, (n))
#define repr(i, a, t) reps((i), (a), (t), 1)
#define reps(i, a, t, s) for (long long (i) = (a); (i) < (long long)(t); (i) += (s))
#define rrep(i, n) rrepr((i), (n) - 1, 0)
#define rrepr(i, a, t) rreps((i), (a), (t), 1)
#define rreps(i, a, t, s) for (long long (i) = (a); (i) >= (long long)(t); (i) -= (s))
#define each(v, c) for (auto &&(v) : (c))
#define all(c) (c).begin(), (c).end()
using namespace std;
namespace mp = boost::multiprecision;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ml = mp::cpp_int;
template<typename T>
using optional = boost::optional<T>;
const auto none = boost::none;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  if (v.empty()) return os << "vector{}";
  os << "vector{" << *v.begin();
  for (auto it = ++v.begin(); it != v.end(); ++it)
    os << ", " << *it;
  return os << "}";
}
template<typename T>
ostream &operator<<(ostream &os, const set<T> &s) {
  if (s.empty()) return os << "set{}";
  os << "set{" << *s.begin();
  for (auto it = ++s.begin(); it != s.end(); ++it)
    os << ", " << *it;
  return os << "}";
}
template<typename S, typename T>
ostream &operator<<(ostream &os, const map<S, T> &m) {
  if (m.empty()) return os << "map{}";
  os << "map{" << (*m.begin()).first << ": " << (*m.begin()).second;
  for (auto it = ++m.begin(); it != m.end(); ++it)
    os << ", " << (*it).first << ": " << (*it).second;
  return os << "}";
}
template<typename S, typename T>
ostream &operator<<(ostream &os, const pair<S, T> &p) {
  return os << "pair{" << p.first << ", " << p.second << "}";
}

bool ok(ll a, const vector<ll> &D) {
  while (a > 0) {
    each (d, D) {
      if (a % 10 == d) return false;
    }
    a /= 10;
  }
  return true;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ifstream ifs;
  if (getenv("LOCAL") != nullptr) {
    ifs.open("src/_in.txt");
    cin.rdbuf(ifs.rdbuf());
  }

  ll N, K;
  cin >> N >> K;
  vector<ll> D(K);
  rep (i, K) {
    cin >> D[i];
  }

  repr (ans, N, 1000000) {
    if (ok(ans, D)) {
      cout << ans << "\n";
      return 0;
    }
  }
}

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

int main(){
 int n,m;
 cin >> n >> m;
 vector<int> h(n);
 vector<bool> ok(n, true);
 rep(i,n) cin >> h[i];
 rep(i,m){
 	int a,b;
 	cin >> a >> b;
 	a--;
 	b--;
 	if(h[a] >= h[b]) ok[b] = false;
 	if(h[b] >= h[a]) ok[a] = false;
 }
 int ans = 0;
 rep(i,n) if(ok[i]) ans++;
 cout << ans << endl;
}

Measured memory_bytes: 3788
#include <stdio.h>
#include <stdlib.h>
int main()
{
    long long a,b,c,d;
    while(~scanf("%lld %lld %lld %lld",&a,&b,&c,&d))
    {
        if(a*b==c*d)
        {
            printf("%lld\n",a*b);
        }
        else if(a*b>c*d)
            printf("%lld\n",a*b);
        else if(a*b<c*d)
            printf("%lld\n",c*d);
    }
    return 0;
}


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

ll N;

int main() {
    std::cin >> N;
    ll max_e=(ll)sqrt(N);
    for (int i = max_e; i > 0; i--) {
        if(N%i==0){
            std::cout << max( to_string(i).length(), to_string(N/i).length() ) << std::endl;
            return 0;
        }
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
    // int t;
    // cin>>t;
    // while(t--){
    // }
    ll n,k=1;
    cin>>n;
    while(n>0)
    {
        k*=2;
        n=n/2;
    }
    cout<<k-1<<endl;
	return 0;
}


Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)

'''
累積和
t[1] = t[0] + (if S[0]からの2文字がACなら1 or 0) → AC の C 位置なら1
t[2] = t[1] + (if S[1]からの2文字がACなら1 or 0)
t[3] = t[2] + (if S[2]からの2文字がACなら1 or 0)
t[4] = t[3] + (if S[3]からの2文字がACなら1 or 0)
t[5] = t[4] + (if S[4]からの2文字がACなら1 or 0)
t[6] = t[5] + (if S[5]からの2文字がACなら1 or 0)
t[7] = t[6] + (if S[6]からの2文字がACなら1 or 0)
t[8] = t[7] + (if S[7]からの2文字がACなら1 or 0)

# 01234567
# ACACTACG
# 011222333
'''

for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)

#print(t)

for i in range(Q):
    l, r = map(int, input().split())

    # 3, 7 なら、t[7-1] - t[3-1]
    #  → t[5]以下の数 - t[1]以下の数
    print(t[r-1] - t[l-1])

Measured memory_bytes: 7748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
#define reg register
#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
#define input(a){a=0;char c=gc();int f=1;while(c<'0'||c>'9'){if(c=='-')f=-1;c=gc();}while(c>='0'&&c<='9'){a=(a<<3)+(a<<1)+(c&15);c=gc();}a*=f;}
static char buf[1<<21],*p1=buf,*p2=buf;
char bu[1<<21],cha[20];int p,pp=-1;
#define flush(){fwrite(bu,1,pp+1,stdout),pp=-1;}
#define output(x){if(pp>1<<20)flush();if(x<0)bu[++pp]=45,x=-x;do{cha[++p]=x%10+48;}while(x/=10);do{bu[++pp]=cha[p];}while(--p);}
#define Endl bu[++pp]='\n'
#define Space bu[++pp]=' '
#define pc(c) bu[++pp]=c
const int N=100010;
int n,m,f[N],d[N];
bool ok=1;
int find(int x)
{
    if(f[x]!=x){int ff=f[x];f[x]=find(f[x]);d[x]+=d[ff];}
    return f[x];
}
int main()
{
    input(n);input(m);
    for(int i=1;i<=n;++i)f[i]=i;
    for(int i=1;i<=m;++i)
	{
        int l,r,x;
        input(l);input(r);input(x);
        int fl=find(l),fr=find(r);
        if(fl==fr&&d[l]-d[r]!=x){ok=0;break;}
        if(fl!=fr){f[fl]=fr;d[fl]=x+d[r]-d[l];}
    }
    if(ok)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 4348
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
ll arr[100000];
int main(void) {
	ll n;
	bool ans = true;
	cin >> n;
	for (ll i = 0; i < n; i++) {
		cin >> arr[i];
	}
	for (ll i = 0; i < n-1; i++) {
		if (arr[i] > arr[i + 1]) {
			arr[i + 1]++;
			if (arr[i] > arr[i + 1]) {
				ans = false;
				break;
			}
		}
	}
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 100000005
#define MAX 5001
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);
 
int a[1002][1002];
int dp[1002][1002];
int main(){
    int h, w, n;
    while(1){
    	scanf("%d%d%d", &h, &w, &n);
    	if(!h)break;
    	fill((int*)a, (int*)(a+1002), 0);
    	fill((int*)dp, (int*)(dp+1002), 0);
    	for(int i = 1;i <= h;i++)
    	for(int j = 1;j <= w;j++)scanf("%d", &a[i][j]);
    	n--;dp[1][1] = n;
    	for(int i = 1;i <= h;i++){
       		for(int j = 1;j <= w;j++){
            	dp[i][j] += dp[i][j-1]/2;
            	if(a[i][j-1] == 1)dp[i][j] += dp[i][j-1]%2;
            	dp[i][j] += dp[i-1][j]/2;
            	if(a[i-1][j] == 0)dp[i][j] += dp[i-1][j]%2;
        	}
    	}
     	
    	int y = 1, x = 1, t, f;
    	while(y <= h && x <= w){
        	f = a[y][x];
        	if(dp[y][x]%2)f = !f;
        	if(f == 0)y++;
        	else x++;
   		}
    	printf("%d %d\n", y, x);
    }
    return 0;
}

Measured memory_bytes: 11016
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define pr pair<int, int>
#define x first
#define y second
using namespace std;

template<typename T>
void read(T& n){
	char ch; int sign = 1;
	while (!isdigit(ch = getchar())) if (ch == '-') sign = -1;
	n = ch - '0';
	while (isdigit(ch = getchar())) n = n * 10 + ch - '0';
	n *= sign;
}
typedef long long ll;
const int INF = 1e9 + 7;
const int N = 222;
int n, mx, mark, x;
int cnt[12222222], match[N], vis[N];
vector<int> v[2];
struct edge{int to, nxt;} g[N*N*4];
int ghead[N], gtail(0);

void add(int l, int r){g[++gtail] = (edge){r, ghead[l]}, ghead[l] = gtail;}
bool oddprime(int x){
	rep(i, 2, sqrt(x)) if (x % i == 0) return false;
	return x > 2;
}
bool find(int x){
	vis[x] = mark;
	for (int p = ghead[x]; p; p = g[p].nxt){
		int v = g[p].to; if (vis[match[v]] == mark) continue;
		if (!match[v]||find(match[v])){
			match[v] = x; return true;
		}
	}
	return false;
}

int main(){
	read(n);
	rep(i, 1, n) read(x), cnt[x] = 1, mx = max(mx, x);
	rep(i, 1, mx + 1) if (cnt[i] ^ cnt[i-1]) v[i%2].pb(i);
	int s0 = v[0].size(), s1 = v[1].size();
	rep(i, 1, s0) rep(j, 1, s1)
		if (oddprime(abs(v[0][i-1] - v[1][j-1])))
			add(i, s0 + j);
	int ans = 0;
	rep(i, 1, s0) {mark++; if (find(i)) ans++;}
	printf("%d\n", ans + ((s0 - ans) / 2 + (s1 - ans) / 2) * 2 + (s0 - ans) % 2 * 3);
	return 0;
}

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

int main() {
  int X;
  int Y;
  cin >> X;
  Y=X;
  
  int a=0;
  int fx=0;
  for (int i=7;i>=0; i--){
    a = X/pow(10,i);
    X = X - a*pow(10,i);
    fx += a;
    //cout << a << "!" << endl;
    //cout << fx << endl;
    //cout << X << "?" << endl;
  }
  int b;
  b = Y % fx;
  if (b==0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
const ll MOD = 1e+9+7;
int n;
ll k;
int a[2010];
int main()
{
  cin >> n >> k;
  rep(i,n) cin >> a[i];

  ll res = 0;
  rep(i,n){
    ll cnt1 = 0,cnt2 = 0;
    rep(j,n){
      if(i==j) continue;
      if(i<j&&a[i]>a[j]) cnt1++;
      else if(i>j&&a[i]>a[j]) cnt2++;
    }
    ll x1 = ((k+1)*k/2)%MOD;
    ll x2 = ((k-1)*k/2)%MOD;
    ll y1 = (cnt1*x1)%MOD;
    ll y2 = (cnt2*x2)%MOD;

    res = (res+y1)%MOD;
    res = (res+y2)%MOD;
  }

  cout << res << "\n";
  
  return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int A = nextInt();
  int B = nextInt();
  if (B % A == 0) 
    cout << A+B << endl;
  else
    cout << B-A << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
x = [0 for _ in range(n)]
x[0] = s - sum(a[1::2])*2
for i in range(1, n):
    x[i] = a[i-1]*2 - x[i-1]
print(' '.join(map(str, x)))

Measured memory_bytes: 19092
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        csf: [(usize, usize, usize); n-1],
    }

    for i in 0..n {
        let mut ans = 0;

        for &(c, s, f) in csf.iter().skip(i) {
            if ans <= s {
                ans = s;
            } else {
                ans = s + (ans - s + f - 1) / f * f;
            }
            ans += c;
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 2196
#include<stdio.h>

int main() {

	long long int x[11], r, d;

	scanf("%lld%lld%lld",&r,&d,&x[0]);

	for (int i=1; i<=10; i++) {

		x[i]=r*x[i-1]-d;
		printf("%lld\n",x[i]);
	}

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
	int a,b,i,ans,fst=0;
	while(scanf("%d %d",&a,&b)){
		if(a==0&&b==0){
			break;
		}
		ans=0;
		if(fst==0)fst=1;
		else{
			puts("");
			
		}
		for(i=a;i<=b;i++){
			if(i%4==0){
				if(i%100==0){
					if(i%400==0){
						printf("%d\n",i);
						ans=1;
					}
				}else{
					printf("%d\n",i);
					ans=1;
				}
			}
		}
		if(ans==0){
			puts("NA");
		}
		
	}
	return 0;
}

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

using namespace std;

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

  vector<int> steps_to_goal(N + 1, -1);
  steps_to_goal[N] = 0;
  int steps = 1;
  int i = N;
  while (i >= 0) {
    int last_i = i;
    for (int j = i - 1; j >= max(i - M, 0); j--) {
      if (S[j] == '0') {
        steps_to_goal[j] = steps;
        last_i = j;
      }
    }
    if (last_i == i) {
      break;
    }
    i = last_i;
    steps++;
  }
  if (steps_to_goal[0] == -1) {
    cout << -1 << endl;
    return 0;
  }

  int now = 0;
  vector<int> ans;
  for (int i = 1; i < N + 1; i++) {
    if (steps_to_goal[i] != -1 and steps_to_goal[i] < steps_to_goal[now]) {
      ans.push_back(i - now);
      now = i;
    }
  }
  for (int i = 0; i < ans.size(); i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << ans[i];
  }

  return 0;
}


Measured memory_bytes: 1528
s = list(input())
t = list(input())

len_t = len(t)
ans = []
for i in range(len(s)-len(t)+1):
  flag = True
  for j in range(i, i+len_t):
    if s[j] != '?' and s[j] != t[j-i]:
      flag = False

  if flag:
    tmp = s[:i] + t + s[i+len_t:]
    for k in range(len(tmp)):
      if tmp[k] == '?':
        tmp[k] = 'a'
    ans += [''.join(tmp)]
      
if len(ans) == 0:
  print('UNRESTORABLE')
  exit()
ans = sorted(ans)
print(ans[0])


  


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

int main(){
    int n;
    scanf("%d", &n);
    rep(i, n){
        For(j, i+1, n){
            rep(k, 10)if(((i>>k)&1) != ((j>>k)&1)){
                printf("%d ", k+1);
                break;
            }
        }
        printf("\n");
    }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long int
#define INF INT_MAX
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
	chutiyaap;
	ll n,m;
	cin>>n>>m;
	ll a,b,c,d;
	cin>>a>>b;
	for(ll i=0;i<m-1;i++)
	{
		cin>>c>>d;
		a=max(a,c);
		b=min(b,d);
	}
	if(b-a+1<0)cout<<0;
	else cout<<(b-a+1);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define FOR(i,a,b) for (int i = (a) ; i <= (b); ++i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい


void Main(){
	ll a;
	cin >> a;
	cout << a + a*a + a*a*a << endl;


}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}


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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N, sum;
VL a;

signed main() {
    cin >> N;
    REP(i, N) {
        a.emplace_back(IN());
        sum += a[i];
    }
    ll ave = sum / N;
    ll ans = LINF;
    REP(loop, 2) {
        ll tmp = 0;
        REP(i, N) tmp += abs(ave - a[i]) * abs(ave - a[i]);
        ans = min(tmp, ans);
        ave++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256