akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
import java.util.Map.Entry;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        final Map<Integer, Long> counts = new HashMap<>();
        int[] A = new int[N];
        for(int i = 0 ; i < N ; i++){
                A[i] = sc.nextInt();
                counts.put(A[i], 0L);
        }

        final Solver solver = new Solver();
        solver.solve(N, A, counts);
    }
}

class Solver {
    public void solve(int N, int[] A, Map<Integer, Long> counts) {
        for (int i = 0; i < N; i++) {
            counts.put(A[i], counts.get(A[i]) + 1);
        }

        long total = 0;
        for (Map.Entry<Integer, Long> count : counts.entrySet()) {
            long c = count.getValue();
            total += c * (c - 1) / 2;
        }

        for (int i = 0; i < N; i++) {
            long ans = total;

            long c = counts.get(A[i]);
            ans -= c - 1;

            System.out.println(ans);
        }
    }
}



Measured memory_bytes: 110228
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(" ").Select(x => int.Parse(x) + 1).ToList();

            var xList = new int[(int)1e6];
            for (var i = 0; i < n; i++)
            {
                xList[a[i]]++;
                xList[a[i] + 1]++;
                xList[a[i] - 1]++;
            }
            Console.WriteLine(xList.Max());
        }
    }
}


Measured memory_bytes: 36400
L, R = map(int, input().split())
left = L%2019
right = R%2019
if R-L>2017 or left > right:
    print(0)
else:
    l = [i for i in range(left, right+1)]
    ans = 9999
    for i in range(len(l)-1):
        for j in range(i+1, len(l)):
            mo = l[i]*l[j]%2019
            if mo<ans:
                ans = mo
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
struct cl{int v[4],x,y;};
int dx[9]={0,0,0,0,0,1,-1,2,-2};
int dy[9]={0,1,-1,2,-2,0,0,0,0};
int valid(int x,int y){
	return 0<=x&&x<3&&0<=y&&y<3;
}
bool operator<(const cl& x,const cl& y){
	rep(i,4) if(x.v[i]!=y.v[i]) return x.v[i]<y.v[i];
	return x.x*4+x.y<y.x*4+y.y;
}
bool operator==(const cl& x,const cl& y){
	rep(i,4) if(x.v[i]!=y.v[i]) return false;
	return x.x*4+x.y==y.x*4+y.y;
}
int main(){
	while(true){
		int N;
		cin>>N;
		if(N==0) break;
		cl be;
		rep(i,4) be.v[i]=0;
		be.x=1,be.y=1;
		vector<cl> vc,nvc;
		vc.pb(be);
		rep(i,N){
			int f[4][4];
			rep(j,4) rep(k,4) cin>>f[j][k];
			for(auto cloud:vc){
				int v[4];
				rep(j,4) v[j]=cloud.v[j]+1;
				int x=cloud.x,y=cloud.y;
				if(x==0&&y==0) v[0]=0;
				if(x==0&&y==2) v[1]=0;
				if(x==2&&y==0) v[2]=0;
				if(x==2&&y==2) v[3]=0;
				bool can=true;
				rep(ii,2) rep(jj,2) if(f[x+ii][y+jj]) can=false;
				rep(j,4) if(v[j]==7) can=false;
				if(!can) continue;
				rep(j,9){
					int nx=x+dx[j],ny=y+dy[j];
					if(!valid(nx,ny)) continue;
					cl hoge;
					rep(k,4) hoge.v[k]=v[k];
					hoge.x=nx,hoge.y=ny;
					nvc.pb(hoge);
				}
			}
			sort(all(nvc));
			nvc.erase(unique(all(nvc)),nvc.end());
			vc=nvc;
			nvc.clear();
//			show(vc.size());
		}
		cout<<(vc.size()?1:0)<<endl;
	}
}

Measured memory_bytes: 1480
#include <bits/stdc++.h>
using namespace std;
using graph = vector<vector<int>>;

class LCA {
	using pii = pair<int, int>;
	const int n;
	vector<int> depth, dde, par, heavy, head;
	int dfs(int v, int prev, const graph& G) {
		par[v] = prev;
		int ma = 0, res = 1;
		for (auto to : G[v]) if (to != prev) {
			depth[to] = depth[v] + 1;
			int size = dfs(to, v, G);
			res += size;
			if (size > ma) {
				ma = size;
				heavy[v] = to;
			}
		}
		return res;
	}
public:
	LCA(const graph& G, int rt = 0)
		: n(G.size()), depth(n), dde(n), par(n), heavy(n, -1), head(n) {
		dfs(rt, -1, G);
		queue<int> q;
		q.push(rt);
		head[rt] = rt;
		while (!q.empty()) {
			int v = q.front(); q.pop();
			while (v != -1) {
				for (auto to : G[v]) if (to != par[v] && to != heavy[v]) {
					q.push(to);
					dde[to] = dde[v] + 1;
					head[to] = to;
				}
				if (heavy[v] != -1) {
					dde[heavy[v]] = dde[v];
					head[heavy[v]] = head[v];
				}
				v = heavy[v];
			}
		}
	}
	int calc(int u, int v) {
		if (dde[u] > dde[v]) swap(u, v);
		while (dde[u] < dde[v]) v = par[head[v]];
		while (head[u] != head[v]) u = par[head[u]], v = par[head[v]];
		return depth[u] < depth[v] ? u : v;
	}
	int dist(int a, int b) {
		return depth[a] + depth[b] - depth[calc(a, b)] * 2;
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n;
	cin >> n;
	graph G(n);
	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int c;
			cin >> c;
			G[i].push_back(c);
			G[c].push_back(i);
		}
	}
	LCA lca(G);
	int q;
	cin >> q;
	while (q--) {
		int u, v;
		cin >> u >> v;
		printf("%d\n", lca.calc(u, v));
	}
	return 0;
}



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

long GCD(long a, long b){
    if(b == 0l) return a; 
    if(a < b) return GCD(b, a);
    else return GCD(b, a%b);
}

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

typedef pair<long, long> P;

int main()
{   
    int N; cin >> N;
    vector<P> A(N);
    REP(i, N){
        long a, b; cin >> a >> b;
        if(a==0l && b==0l){
            A[i].first = a;
            A[i].second = b;
        }else if(a==0l && b!=0l){
            A[i].first = 0l;
            A[i].second = 1l;
        }else if(a!=0l && b==0l){
            A[i].first = 1l;
            A[i].second = 0l;
        }else{
            long g = GCD(abs(a), abs(b));
            a = a/g;
            b = b/g;
            if(a >= 0l){
                A[i].first = a;
                A[i].second = b;
            }else{
                A[i].first = -a;
                A[i].second = -b;
            }
        }
    }
    sort(A.begin(), A.end());
    //REP(i, N) cout << A[i].first << " " << A[i].second << endl;
    bool check[200005];
    int para[200005], perp[200005];
    int zero;
    int ind = 0;
    REP(i, N) para[i] = 0, perp[i] = 0;
    REP(i, N) check[i] = false;
    if(A[0].first==0l && A[0].second==0l){
        int end = (int)(upper_bound(A.begin(), A.end(), A[0]) - A.begin());
        for(int j=0; j<end; j++) check[j] = true;
        zero = end;
        //cout << zero << endl;
    }
    REP(i, N){
        if(!check[i]){
            int end = (int)(upper_bound(A.begin(), A.end(), A[i]) - A.begin());
            for(int j=i; j<end; j++) check[j] = true;
            para[ind] = end-i;
            //cout << end-i << " ";
            P p;
            p.first = abs(A[i].second);
            if(A[i].second >= 0l) p.second = -abs(A[i].first);
            else p.second = abs(A[i].first);
            int start = (int)(lower_bound(A.begin(), A.end(), p) - A.begin());
            end = (int)(upper_bound(A.begin(), A.end(), p) - A.begin());
            for(int j=start; j<end; j++) check[j] = true;
            perp[ind] = end-start;
            //cout << end-start << endl;
            ind++;
        }
    }
    long mod = 1000000007;
    long ans = 1l;
    REP(i, ind){
        long temp = modpow(2l, (long)para[i], mod);
        temp += modpow(2l, (long)perp[i], mod); temp %= mod;
        temp--; if(temp < 0l) temp += mod;
        ans *= temp; ans %= mod;
    }
    ans--;
    if(ans < 0l) ans += mod;
    ans += zero; ans %= mod;
    cout << ans << endl;

    return 0;
}



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

int main() {
  long long N, A, B;
  cin >> N >> A >> B;
  
  long long count = (N / (A + B)) * A;
  long long tmp = N % (A + B);
  if (tmp - A <= 0) {
    count += tmp;
  } else {
    count += A;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
//shara's here
//SPEEEEEEEEEED IS KEEEEEEEEEEY
#include <bits/stdc++.h>
using namespace std;
//fold
typedef int q;
typedef double w;
typedef string s;
typedef long long ll;
//using ll = long long;
typedef long double ld;
const ll INF = 1e18 + 10;
/*#if !defined(ONLINE_JUDGE)
#include "/home/xsharawi/Desktop/cpp/debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif*/
#define push_back pb
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
//endfold
int main(){
    speed;
    s ss , dd , currl="";
    cin >> ss >> dd;
    if(ss==dd){
    	cout<<"Yes"<<endl;
    	return 0;
    }
    bool ok = false;
    int n = (int)ss.size();
    for( int i = 0 ; i < n ; i++ ){
    	s curr="";
    	char x = ss[n-1];
    	currl+=x;
    	ss.pop_back();
    	ss=x+ss;
    	if(ss==dd){
    		ok = true;
    		break;
    	}
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;



























return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
	int n, k; cin >> n >> k;
 
	vector<int> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	
	int res = 0; 
	while (res * k - res + 1 < n) {
		++res;
	}
 
	cout << res << endl;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int64_t x;
	std::cin >> x;
	int64_t cur = 100;
	int cnt = 0;
	for (; cur < x; ) {
		cur += cur / 100;
		cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 3760
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

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

int main(){
    int R;
    cin >> R;
    static const double pi = 3.14159265359;
    cout << R * 2.0 * pi << endl;

    return 0;
}


Measured memory_bytes: 3220
import numpy as np
import fractions

def main():
    N, X = map(int, input().split())
    x = np.asarray(list(map(int, input().split())))
    x = np.absolute(x - X)
    if N > 1:
        l = None
        for i, n in enumerate(x):
            if i == 0:
                l = n
            else:
                l = fractions.gcd(l, n)
        print(l)
    else:
        print(x[0])


if __name__ == '__main__':
    main()

Measured memory_bytes: 25028
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////

object Problem {
    fun gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)
    fun gcd(numbers: Iterable<Int>): Int = numbers.reduce { acc, n -> gcd(acc, n) }
    fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)
    fun gcd(numbers: Iterable<Long>): Long = numbers.reduce { acc, n -> gcd(acc, n) }

    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val A = LongArray(N) { sc.next().toLong() }
        val L = LongArray(N)
        val R = LongArray(N)
        L[0] = A[0]
        R[N - 1] = A[N - 1]
        for (i in 1 until N) {
            L[i] = gcd(L[i - 1], A[i])
            R[N - 1 - i] = gcd(R[N - 1 - i + 1], A[N - 1 - i])
        }
//        println("L=" + L.joinToString(" "))
//        println("R=" + R.joinToString(" "))

        val can = mutableListOf(L[N - 2], R[1])
        for (i in 0..N - 3) {
            val a = gcd(L[i], R[i + 2])
            can += a
        }
        pw.println(can.max()!!)
    }
}


Measured memory_bytes: 45832
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005


int main() {
    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;
    int ans = 0;
    rep(i,k){
        if(t[i] == 's')ans += r;
        if(t[i] == 'p')ans += s;
        if(t[i] == 'r')ans += p;
        int flag = 0;
        int j = i + k;
        while(j < n){
            if(t[j] != t[j-k]){
                if(t[j] == 's')ans += r;
                if(t[j] == 'p')ans += s;
                if(t[j] == 'r')ans += p;
                flag = 0;
            }else{
                if(flag == 0){
                    flag = 1;
                }else{
                    if(t[j] == 's')ans += r;
                    if(t[j] == 'p')ans += s;
                    if(t[j] == 'r')ans += p;
                    flag = 0;
                }
            }
            j += k;
        }
    }
    cout << ans << endl;
}
 
 


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define K 10000
int main(){
  int *a,*b;
  int n;
  int c[K+1]={};
  cin>>n;
  n++;
  a=(int*)malloc(sizeof(int)*n);
  b=(int*)malloc(sizeof(int)*n);

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

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

  for(int i=1;i<n-1;i++)
    cout<<b[i]<<' ';

  cout<<b[n-1]<<endl;

  return 0;
}



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

int main(){
  int N = 0;
  int i = 0;
  cin >> N;
  int A[N];
  int count = 0;
  
  while(1){
    for(i=0;i<N;i++){
      cin >> A[i];
      if(A[i]%2!=0)
        break;
      else
        A[i] /= 2;
    }
    if(A[i]%2!=0)
      break;
    else
      count++;
  }
  cout << count << endl;
  
}

Measured memory_bytes: 256
# B
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n
def db(x): 
    global debug
    if debug: print(x)
debug = False
N = getInt()
L = getIntList()
L.sort()
L.reverse()
db((N,L))
sm = 0
for i in range(1,N):
    sm += L[i]
db(sm)
if L[0]<sm: print('Yes')
else: print('No')
    

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define arep(i, v) for (auto i : v)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline void dump(T& v) {
    irep(i, v) { cout << (*i) << ((i == --v.end()) ? '\n' : ' '); }
}
inline string getline() {
    string s;
    getline(cin, s);
    return s;
}
inline void yn(const bool b) { b ? fin("yes") : fin("no"); }
inline void Yn(const bool b) { b ? fin("Yes") : fin("No"); }
inline void YN(const bool b) { b ? fin("YES") : fin("NO"); }
struct io {
    io() {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;

/* --------------------   ここまでテンプレ   -------------------- */

int main() {
    int h, w;
    cin >> h >> w;
    int ans = 0;
    multiset<int> s;
    map<int, int> m;
    rep(i, w) m[i] = i;
    rep(i, w) s.insert(0);

    rep(i, h) {
        int a, b;
        cin >> a >> b;
        a--;
        auto it = m.lower_bound(a);
        int maxr = -1;
        while (it != m.end() && it->fi <= b) {
            chmax(maxr, it->se);
            s.erase(s.find(it->fi - it->se));  //
            m.erase(it++);
        }
        if (maxr != -1 && b < w) {
            s.insert(b - maxr);
            m[b] = maxr;
        }
        int ans=-1;
        if(s.size()){
            ans=*s.begin()+i+1;
        }
        fin(ans);
    }
}


Measured memory_bytes: 22352
#include <stdio.h>

int main(void)
{
	int s, m, h;
	
	scanf("%d", &s);
	
	h = s / 3600;
	m = (s % 3600) / 60;
	s = s % 60;
	
	printf("%d:%d:%d\n", h, m, s);
		
	return 0;
}

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

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

	for (int i = 1; i <= 8; i++) {
		if (X >= 2000 - 200 * i) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3156
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#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;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vpll> vvpll;
typedef unordered_map<ll, ll> um;
typedef unordered_set<ll> us;

#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ts ll t; in(t) while (t--) solve();
#define ks ll t; in(t) FOR(i, 1, t + 1) cout << "Case #" << i << ": ", solve();
#define endl '\n'
#define ln cout << endl;
#define in(x) cin >> x;
#define out(x) cout << x << endl;
#define flush cout << flush;
#define reset(a, b) memset(a, b, sizeof(a));
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define FORI(i, a, b, c) for (ll i = a; i < b; i += c)
#define FORD(i, a, b) for (ll i = a; i > b; --i)
#define FOREACH(it, v, r) for (auto it = v.begin() + r; it != v.end(); it++)
#define FORALL(it, v) for (auto it : v)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define vin(v, x) vll v(x); FOR(i, 0, x) in(v[i])
#define all(v) v.begin(), v.end()
#define allr(v, r) v.begin(), v.begin() + r
#define showv(v) FORALL(it, v) cout << it << ' '; ln
#define prllv(v) FORALL(it, v) out(it)
#define show2d(v) FORALL(it, v) { FORALL(j, it) cout << j; ln }
#define showm(v) FORALL(it, v) cout << it.F << ": " << it.S << ", "; ln
#define sortv(v) sort(all(v));
#define revv(v) reverse(all(v));
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define gcd __gcd
#define checkbit(n, i) (n >> i) & 1
#define bitcount __builtin_popcount
#define firstbitindex __builtin_ctz
#define lastbitindex __builtin_clz
#define bitparity __builtin_parity
#define findv(v, x) (find(all(v), x) != v.end())
#define findsm(u, x) (u.find(x) != u.end())
#define findstr(s, x) (s.find(x) != string::npos)
#define sz(a) a.size()
#define precise(x) cout << fixed << setprecision(x);

const ll N = 5e4, MOD = 1e9 + 7, MAX = 1e7 + 1;
const double EPS = 1e-9, PI = acos(-1);
const int INFi = 0x7f7f7f7f;

//<<------Declare Variables Here----->>//
string s;

//<<-----Implement Functions Here---->>//
void solve()
{
	in(s)
    out((s.back() == 's' ? s + "es" : s + 's'))
}

//<<----------Start of Main---------->>//
signed main()
{
	fastio
	// ts
    solve();
}

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

#define MAXN (100010)

char str[MAXN];
int n;

int main(){
	scanf("%s", str);
	n = strlen(str);
	printf(((n & 1) ^ (str[0] == str[n - 1])) ? "First\n" : "Second\n");
	return 0;
}

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

using namespace std;

int power(int a, int r) {
  int res = 1;
  while (r > 0) {
    if (r & 1) res *= a;
    a *= a;
    r >>= 1;
  }
  return res;
}

int d2b(int n) {
  int m = 0;
  for (int i = 0; n > 0; i++) {
    m = m + n % 2 * power(10, i);
    n = n / 2;
  }
  return m;
}

string zpad(int n, int k) {
  ostringstream ss;
  ss << setw(k) << setfill('0') << n;
  string s(ss.str());
  return s;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> c(h);
  for (int i = 0; i < h; i++) {
    cin >> c[i];
  }
  int ans = 0;
  for (int i = 0; i < power(2, h); i++) {
    for (int j = 0; j < power(2, w); j++) {
      string ii = zpad(d2b(i), h);
      string jj = zpad(d2b(j), w);
      vector<string> cc = c;
      for (int k = 0; k < h; k++) {
        for (int l = 0; l < w; l++) {
          if (ii[k] == '1') {
            for (int m = 0; m < w; m++) {
              cc[k][m] = '.';
            }
          }
          if (jj[l] == '1') {
            for (int m = 0; m < h; m++) {
              cc[m][l] = '.';
            }
          }
        }
      }
      int cnt = 0;
      for (int k = 0; k < h; k++) {
        for (int l = 0; l < w; l++) {
          if (cc[k][l] == '#') cnt++;
        }
      }
      if (cnt == k) ans++;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3668
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x.append(X)
y.append(Y)

x = max(x)
y = min(y)

ans = 'War'
if x < y:
    ans = 'No War'

print(ans)

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

#define fi first
#define se second
#define pb push_back

typedef long long LL;
typedef long double LD;

const LL INF = (1LL << 60);

typedef pair<LL,int> PL;
LL prim(vector<PL> adjList[], int n);

int main() {

  ios_base::sync_with_stdio(0); cin.tie(0);

  vector<PL> adjList[10005];

  int n, m;
  cin >> n >> m;

  for (int i = 0; i < m; i++) {
    int s, t; LL w;
    cin >> s >> t >> w;

    adjList[s].push_back({w, t});
    adjList[t].push_back({w, s});
  }

  LL res = prim(adjList, n);

  cout << res << endl;

  return 0;
}

/**
 *
 * tested on http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_2_A
 */
LL prim(vector<PL> adjList[], int n) {
  LL ans = 0;

  vector<bool> visited; visited.assign(n, false);
  priority_queue<PL,vector<PL>,greater<PL>> pq; 

  pq.push({0, 0});
  while (!pq.empty()) {
    int u; LL w;
    tie(w, u) = pq.top(); pq.pop();
    
    if (visited[u])
      continue;

    visited[u] = true;
    ans += w;
    
    for (PL v : adjList[u]) {
      pq.push(v);
    }
  }

  return ans;
}


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

int main( void )
{
    int n,k,x,y;
    cin >> n >> k >> x >> y;
    
    ll ans;
    if ( k >= n )
        ans = n * x;
    else
        ans = k * x + (n - k) * y;
    
    cout << ans << endl;
}


Measured memory_bytes: 256
/*~~~~~~~~~~~~~~~~~ K++ code ~~~~~~~~~~~~~~~~~~~
in(a, b)
if(a%2==1&&b%2==1) yes()

else no()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

;;

int main(){
  ;;
    int a, b;
    cin >> a >> b;
    ;
    if(a%2==1&&b%2==1) {;cout << "Yes" << endl;;}
     
    else {;cout << "No" << endl;;};
}

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

int main(){
    double a;

    while(cin>>a){
        double sum=a;

        for(int n=2;n<=10;n++){
            if(n&1){
                sum+=a/3.0;
                a/=3.0;
            }else{
                sum+=a*2.0;
                a*=2.0;
            }
        }

        cout<<setprecision(8)<<setiosflags(ios::fixed)<<sum<<endl;
    }
    
    return 0;
}

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


int compute(int k, int n, vector<int>&dp, int arr[])
{
    if(k==0)
    return 0;
    
    int ans=0;
    // cout<<k<<" ";
    
    if(dp[k]!=-1)
        return dp[k];
        
    for(int i=0;i<n;i++)
    {
        if(arr[i]<=k)
        {
            if(compute(k-arr[i],n,dp,arr)==0)
            {ans=1;
            break;}
        }
    }
    // cout<<ans<<endl;
    return dp[k]=ans;
    
}

int main() {
// 	cout<<"GfG!";

    int N,K;
    cin>>N>>K;
    int arr[N];
    
    for(int i=0;i<N;i++)
        cin>>arr[i];
    sort(arr,arr+N);
    vector<int>dp(K+1,0);
    dp[0]=0;
    for(int i=0;i<=K;i++)
    {
        for(int j=0;j<N;j++)
        {
            if(arr[j]>i)
                break;
            if(dp[i-arr[j]]==0)
            {
                dp[i]=1;
                break;
            }
        }
    }
    if(dp[K]==1)
        cout<<"First";
    else
        cout<<"Second";
    
	return 0;
}

Measured memory_bytes: 3780
n,m=map(int,input().split())

visit=[0 for i in range(n)]
side=[[False for i in range(n)] for j in range(n)]

l=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    side[a-1][b-1]=True
    side[b-1][a-1]=True
    l[a-1].append(b-1)
    l[b-1].append(a-1)

def bfs(x,y):
    que=[0]
    visit=[0 for i in range(n)]
    done=[[0 for i in range(n)] for j in range(n)]
    visit[0]=1
    while(que):
        now=que.pop(0)
    
        for i in l[now]:
            if ((now==x and i==y) or (now==y and i==x)) or (done[now][i]==True or done[i][now]==True):
                continue
            else:
                que.append(i)
                done[now][i]=True
                visit[now]+=1
                visit[i]+=1

    flag=0

    for i in visit:
        if i!=0:
            continue                  
        else:
            flag=1
            break

    if flag==1:
        return 1
    else:
        return 0

ans=0
for i in range(n):
    for j in range(i+1,n):
        if side[i][j]==True:
            ans+=bfs(i,j)

print(ans)

Measured memory_bytes: 9252
S = input()

lst = [1 if S[0]=='<' else -1]
for i in range(1, len(S)):
    if S[i] == S[i - 1]:
        lst[-1] += 1 if S[i]=='<' else -1
    else:
        lst.append(-1 if S[i]=='>' else 1)
        
ans = [0]

for i in lst:
    if i > 0:
        ans += list(range(1,i+1))
    else:
        ans[-1] = max(ans[-1], -i)
        ans += list(range(-i-1,-1, -1))


print(sum(ans))

Measured memory_bytes: 27548
x1, y1, x2, y2 = [int(i) for i in input().split()]
dy = y2 - y1
dx = x2 - x1
y3 = y2 + dx
x3 = x2 - dy
x4 = x3 - dx
y4 = y3 - dy

print(x3, y3, x4, y4)

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

int main() {
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }

  for (auto s : {"AC", "WA", "TLE", "RE"}) {
    cout << s << " x " << mp[s] << endl;
  }
  return 0;
}


Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {
	public static void main(String[] args)  {
		Scanner sc = new Scanner((System.in));
		int r = sc.nextInt() ;
		int g = sc.nextInt();
		int b = sc.nextInt();
		int n = sc.nextInt();
		sc.close();
		int count =0;
		for(int i = 0; i <= n; i += r) {
			for(int j = 0; j + i <= n; j += g) {

					if( (n- i - j)%b == 0 ) {
						count++;
					}

			}
		}
		System.out.println(count);
	}
}

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

using ll = long long;

int main(){

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

	ll money=1000;
	ll kabu=0;
	ll ans=0;
	for(int i=0;i<n;i++){
		//手数料がないから毎回うる
		money=money+kabu*a[i];
		kabu=0;
		//次の日に株が上がる場合
		if(a[i]<a[i+1] && i!=n-1){
			kabu=money/a[i];
			money=money-kabu*a[i];
		}
		ans=max(ans,money);
	}

	cout << ans << endl;

}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

void solve(ll n, ll d){
	bool ans=true;
	ll m,in,mn,mx;
	vvl c(n);
	rep(i,n){
		cin>>m;
		c[i].push_back(0);
		rep(j,m){
			cin>>in;
			c[i].push_back(c[i].back()+in);
		}
	}
	rep(i,n){
		range(j,1,c[i].size()){
			mn=c[i][j]-d;
			mx=c[i][j-1]+d;
			if(mn>mx){
				ans=false;
				j=100000;i=n;
				continue;
			}
			rep(k,n){
				if(i==k)continue;
				auto itr=lower_bound(all(c[k]),mn);
				if(itr==c[k].end()||*itr>mx){
					ans=false;
					j=1000000;k=n;
					continue;
				}
			}
		}
	}
	Yn(ans);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,d;
	while(cin>>n>>d,n)solve(n,d);
}



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

int main()
{
    int X, A, B;
    cin>>X>>A>>B;

    if(A>=B){
        cout << "delicious" << endl;
    }
    else if(B>A&&(B-A)<=X){
        cout << "safe" << endl;
    }
    else{
        cout << "dangerous" << endl;
    }
}




Measured memory_bytes: 256
n = int(input())
s = input()
S = []
for i in s:
    S.append(i)
from collections import deque
q = deque(S)
ans = []
while q:
    c  =q.popleft()
    if not ans:
        ans.append(c)
    else:
        while ans and ans[-1]==c:
            ans.pop()
        ans.append(c)

print(len(ans))

Measured memory_bytes: 84088
#include <cstdio>
const int MAXN=1100;
const int MOD=1E9+7;
char a[MAXN][MAXN];
int f[MAXN][MAXN];
int main()
{
//	freopen("H.in", "r", stdin);
//	freopen("H.out", "w", stdout);
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i=1; i<=n; i++)
		scanf("%s", a[i]+1);
	f[0][1]=1;
	for (int i=1; i<=n; i++)
		for (int j=1; j<=m; j++)
			if (a[i][j]=='.')
				f[i][j]=(f[i-1][j]+f[i][j-1])%MOD;
	printf("%d\n", f[n][m]);
	return 0;
}

Measured memory_bytes: 5504
object Main {
  import java.util.Scanner

  def readStrings(n: Int)(implicit sc: Scanner): Array[String] = Array.fill(n) { sc.next() }
  def readInts(n: Int)(implicit sc: Scanner): Array[Int] = Array.fill(n) { sc.nextInt() }
  def readLongs(n: Int)(implicit sc: Scanner): Array[Long] = Array.fill(n) { sc.nextLong() }
  def readLineStrings(implicit sc: Scanner): Array[String] = sc.nextLine().split(' ')
  def readLineInts(implicit sc: Scanner): Array[Int] = readLineStrings.map(_.toInt)
  def readLineLongs(implicit sc: Scanner): Array[Long] = readLineStrings.map(_.toLong)

  def main(args: Array[String]): Unit = solve(new Scanner(System.in))

  def solve(implicit sc: Scanner): Unit = {
    def adjustRow(row: Seq[Int]): Seq[Int] = row.scanLeft(0){ (a, carry) => (a + carry) % 2 }.drop(1).dropRight(1)

    val Array(h, w) = readLineInts
    val a = Array.fill(h)(readLineInts)
    val b = a.map(row => row.map(aij => if (aij == 0) aij else if (aij % 2 == 0) 2 else 1))
    val moveResults: Seq[(Seq[Int], Int)] = b.map { row =>
      val moves = adjustRow(row)
      (moves, row.last + moves.lastOption.getOrElse(0))
    }
    val rowMoves = moveResults.map(_._1)
    val column = moveResults.map(_._2)
    val columnMoves = adjustRow(column)

    val rowWiseMoves = {
      for((rowMove, rowIndex) <- rowMoves.zipWithIndex;
          (moveFlag, columnIndex) <- rowMove.zipWithIndex;
          move <- Some((rowIndex + 1, columnIndex + 1, rowIndex + 1, columnIndex + 2)) if moveFlag == 1) yield move
    }
    val columnWiseMoves = {
      for ((moveFlag, rowIndex) <- columnMoves.zipWithIndex;
            move <- Some((rowIndex + 1, w, rowIndex + 2, w)) if moveFlag == 1) yield move
    }
    val moves = rowWiseMoves ++ columnWiseMoves

    println(moves.length)
    for ((a, b, c, d) <- moves) println(s"$a $b $c $d")
  }
}


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

int main()
{
  string s;
  l1 flag=0;
  cin>>s;
  for(l1 i=0;i<s.size();++i)
  {
    if(s[i]==s[i+1]&&i==2)
    {
      if(s[4]==s[5])
      	flag=1;
    }
  }
  if(flag)
    cout<<"Yes\n";
  else
    cout<<"No\n";
  return 0;
}


Measured memory_bytes: 256
def rec(x, y, z):
    if (x | y | z) & 1:
        return 0

    if x == y == z:
        return -INF

    nx = (y + z) >> 1
    ny = (z + x) >> 1
    nz = (x + y) >> 1
    return rec(nx, ny, nz) + 1


INF = float('inf')
A, B, C = map(int, input().split())
ans = rec(A, B, C)
print(ans if ans >= 0 else -1)

'''
操作ごとに最大と最小の差が詰まるので、
無限繰り返し状態のときは、a==b==cになっている
'''


Measured memory_bytes: 3064
#include <stdio.h>

#define Mod 1000000007

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

int main()
{
	int i, N, x[100001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(x[i]));
	
	long long fact[100001], ans = 0, sum = 0;
	for (i = 1, fact[0] = 1; i < N; i++) fact[i] = fact[i-1] * i % Mod;
	for (i = 1; i < N; i++) fact[i] = div_mod(fact[N-1], (long long)i, Mod);
	for (i = 1; i < N; i++) {
		sum = (sum + fact[i]) % Mod;
		ans = (ans + sum * (x[i+1] - x[i])) % Mod;
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2864
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;



int main(int argc, char* argv[])
{
    int n,m;
    scanf("%d%d", &n, &m);

    vector<int> cnt(n,1);
    vector<int> flag(n);
    flag[0]=1;
    int i;
    for(i=0; i<m; i++) {
        int a,b;
        scanf("%d%d", &a, &b); a--; b--;
        if(flag[a]) {
            if(cnt[a]>1) {
                flag[b]=1;
            }
            else {
                flag[a]=0; flag[b]=1;
            }
        }
        cnt[a]--; cnt[b]++;
    }
    int ans=0;
    for(i=0; i<n; i++) {
        if(flag[i]) ans++;
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
using namespace std;

long long n,m,ans,mod=1000000007;

long long jc(long long x)
{
	long long turn=1;
	while (x>0) turn=(turn*x--)%mod;
	return turn;
}

int main()
{
	cin>>n>>m;
	if (abs(n-m)>1)
	{
		printf("0\n");
		return 0;
	}
	if (m==n)
		ans=jc(n)*jc(n)%mod*2%mod;
	else
		ans=jc(n)*jc(m)%mod;
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=998244353;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll a,b;cin>>a>>b;
    out(a*b);
}

Measured memory_bytes: 3676
#pragma GCC target ("sse4.2")

#include<bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long
#define endl '\n'
#define N 100010

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

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

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

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

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N; 
    cin >> N;

    vector<ll> A(N);

    REP(i, N){
        cin >> A[i];
    }
    
    sort(A.begin(), A.end());

    if(N==2){
        cout << abs(A[0]-A[1]) << endl;
        return 0;
    }
    if(N==3){
        cout << max(abs(2*A[2] - A[0] - A[1]), abs(2*A[0] - A[1] - A[2])) << endl;
        return 0;
    }
    if(N==4){
        cout << abs(2*A[3]+A[2]-A[1]-2*A[0]) << endl;
        return 0;
    }

    ll plus = 0;
    ll minus = 0;
    if(N%2 == 0){
        for(ll i=0; i<=N/2-2; i++){
            minus += A[i]*2;
        }
        for(ll i=N/2+1; i<=N-1; i++){
            plus += A[i]*2;
        }
        minus += A[N/2-1];
        plus += A[N/2];
        cout << abs(plus - minus) << endl;
        return 0;
    }
    else{
        plus = 0;
        minus = 0;

        for(ll i=0; i<=(N-1)/2-2; i++){
            minus += A[i]*2;
        }
        for(ll i=(N-1)/2+2; i<=N-1; i++){
            plus += A[i]*2;
        }
    
        ll t1, t2;
        t1 = 2 * A[(N-1)/2+1] - A[(N-1)/2] - A[(N-1)/2-1];
        t2 = A[(N-1)/2+1] + A[(N-1)/2] - 2*A[(N-1)/2-1];

        cout << max(abs(plus-minus+t1), abs(plus-minus+t2)) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1024
//C
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;

int main() {
	int N;
	cin >> N;
	LL ans = 1;
	for (int i = 0; i < N; i++) {
		ans *= 10;
		ans %= MOD;
	}
	LL ans2 = 1;
	for (int i = 0; i < N; i++) {
		ans2 *= 9;
		ans2 %= MOD;
	}
	ans -= 2 * ans2;
	ans2 = 1;
	for (int i = 0; i < N; i++) {
		ans2 *= 8;
		ans2 %= MOD;
	}
	ans += ans2;
	while (ans < 0) ans += MOD;
	cout << ans << "\n";
}

Measured memory_bytes: 3640
#include<stdio.h>

int main(){
	int A,B;
	int Ans;
	scanf("%d%d",&A,&B);
	if(A>B){
		Ans=2*A-1;
	}else if(A<B){
		Ans=2*B-1;
	}else{
		Ans=2*A;
	}
	printf("%d",Ans);
	
	return(0);
}

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

using namespace std;

const int N = 1e5 + 10;
long long dp[N][3];
int p[3], a[N];

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

  int n, k, r, s;
  string t;
  cin >> n >> k >> p[0] >> p[1] >> p[2];
  for (int i = 0; i < n; ++i) {
    char c;
    cin >> c;
    a[i] = (c == 's') + (c == 'p') * 2;
    --a[i];
    if (a[i] < 0) {
      a[i] += 3;
    }
  }
  long long ans = 0;
  for (int i = 0; i < k; ++i) {
    int tot = 1;
    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    for (int j = i; j < n; j += k) {
      for (int it = 0; it < 3; ++it) {
        dp[tot][it] = 0;
      }
      ++tot;
    }
    tot = 1;
    for (int j = i; j < n; j += k) {
      for (int it1 = 0; it1 < 3; ++it1) {
        for (int it2 = 0; it2 < 3; ++it2) {
          if (it2 == it1) {
            continue;
          }
          dp[tot][it1] = max(dp[tot][it1], dp[tot - 1][it2] + p[it1] * (a[j] == it1));
        }
      }
      ++tot;
    }
    ans += max(dp[tot - 1][0], max(dp[tot - 1][1], dp[tot - 1][2]));
  }
  cout << ans;

  return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<ll> A(N + 2, 0);
    rep(i, N) cin >> A[i + 1];
    ll sum = 0;
    rep(i, N + 1){
        sum += abs(A[i + 1] - A[i]);
    }
    
    rep(i, N){
        output(sum - abs(A[i + 1] - A[i]) - abs(A[i + 2] - A[i + 1]) + abs(A[i + 2] - A[i]));
    }
    
    return 0;
}


Measured memory_bytes: 2048