akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(void){
	int N, K;

	cin >> N >> K;

	int s = 1;
	for (int i = 0; i < N; i++){
		if (s <= K){
			s *= 2;
		}
		else {
			s += K;
		}
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
t0, x0, y0 = map(int, input().split())
flag = True
if (x0+y0)%2 != t0%2 or x0+y0 > t0:
    flag = False
for _ in range(N-1):
    t1, x1, y1 = map(int, input().split())
    if (x1+y1-x0-y0)%2 != (t1-t0)%2 or (x1+y1-x0-y0) > t1-t0:
        flag = False
    t0, x0, y0 = t1, x1, y1
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 45288
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
#include<map>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

//----------------------------------------



int main(void)
{
	float n;
	cin >> n;
	float d;

	cin >> d;

	float s = n / (2 * d + 1);

	cout << ceil(s) << endl;
}

Measured memory_bytes: 256
//Zory-2018
//*******************头文件*******************
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
int mymax(int x,int y) {return x>y?x:y;}
int mymin(int x,int y) {return x<y?x:y;}
//*******************全局常量*******************
const int MAXN=110000;
const int INF=0x3f3f3f3f;
//*******************全局定义*******************
struct nod
{
	int hou;
	
	int val;
	int mi,mx;
	int jo;//-1,0,1
}p[MAXN];
struct edge
{
	int y,g;
}e[2*MAXN];
//*******************实现*******************
int ln=0;
void ins(int x,int y)
{
	ln++;
	e[ln].y=y;
	e[ln].g=p[x].hou;
	p[x].hou=ln;
}
bool bk=1;
void dfs(int x,int fa)
{
	if(bk==0) return;
	
	for(int k=p[x].hou;k>0;k=e[k].g)
	{
		int y=e[k].y;
		if(y==fa) continue;
		dfs(y,x);
		if(p[x].jo!=-1 and p[x].jo==p[y].jo)
		{
			bk=0;
			return;
		}//本来相邻或者递推得来
		p[x].mi=mymax(p[x].mi,p[y].mi-1);
		p[x].mx=mymin(p[x].mx,p[y].mx+1);
		if(p[y].jo!=-1) p[x].jo=p[y].jo^1;//信息的合并
	}
	
	if(p[x].jo!=-1 and p[x].mi==p[x].mx and p[x].mi%2!=p[x].jo)
	{
		bk=0;
		return;
	}//检查
	if(p[x].mi>p[x].mx)
	{
		bk=0;
		return;
	}
}
void dfs2(int x,int fa)
{
	if(p[x].val==-1)
	{
		if(fa==0)
		{
			if(p[x].mi%2==p[x].jo) p[x].val=p[x].mi;
			else p[x].val=p[x].mi+1;
		}
		else
		{
			if(p[x].mi<=p[fa].val-1 and p[fa].val-1<=p[x].mx) p[x].val=p[fa].val-1;//debug
			else p[x].val=p[fa].val+1;
		}
	}
	
	for(int k=p[x].hou;k>0;k=e[k].g)
	{
		int y=e[k].y;
		if(y==fa) continue;
		dfs2(y,x);
	}
}
//*******************主函数*******************
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		p[i].hou=0;
		p[i].val=-1;
		p[i].mi=-INF;p[i].mx=INF;
		p[i].jo=-1;
	}
	for(int i=1;i<=n-1;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		ins(x,y);ins(y,x);
	}
	int k;scanf("%d",&k);
	for(int i=1;i<=k;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		p[a].val=p[a].mi=p[a].mx=b;
		p[a].jo=b%2;
	}
	
	dfs(1,0);//自下而上
	if(bk==0) printf("No\n");
	else
	{
		printf("Yes\n");
		dfs2(1,0);//自上而下
		for(int i=1;i<=n;i++) printf("%d\n",p[i].val);
	}
}

Measured memory_bytes: 10624
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, l;

signed main() {
	int i, j;
	
	cin >> n >> l;
	
	int ssum = 0;
	for (i = 0; i < n; i++) {
		ssum += l + i;
	}
	
	int minScore = 1145141919;
	int ans;
	for (i = 0; i < n; i++) {
		int asum = 0;
		for (j = 0; j < n; j++) {
			if (j == i) continue;
			asum += l + j;
		}
		int score = abs(ssum - asum);
		if (score < minScore) {
			minScore = score;
			ans = asum;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#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 repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#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) {
    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, d;
    cin >> N >> d;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    int ret = 0;
    rep(i, N) {
        if(A[i] - d >= 0){
            ret += A[i] - d;
        }
    }
    
    if(ret == 0) output("kusoge", 0);
    else output(ret, 0);
    return 0;
}

Measured memory_bytes: 3176
h, w, n = map(int, input().split())
from collections import defaultdict
d = defaultdict(int)
surround = [(0, 0), (1,1), (1, 0), (1, -1), (0, -1), (-1, -1), (-1, 0), (-1, 1), (0, 1)]
for _ in range(n):
    x, y  = map(int, input().split())
    x -= 1
    y -= 1
    for i in surround:
        if x + i[0] >= h or x + i[0] < 0 or y + i[1] < 0 or y + i[1] >= w:
            continue
        else:
            d[(x+i[0], y + i[1])] += 1
num = [0]*10
for key in d:
    if key[0] >= 1 and key[0] < h -1 and key[1] >= 1 and key[1] < w-1:
        num[d[key]] += 1

num[0] = (h-2)*(w-2) - sum(num)

for ans in num:
    print(ans)


Measured memory_bytes: 166924
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define MAX 200005
#define MOD 998244353
#define pb push_back
#define mp make_pair
#define f first
#define s second

ll n, m, i, j, k, t, l, r,tmp, ans, cnt,curr, flag, sum, mn, mx, mxi,x,pre,strt,en;
ll brr[MAX], arr[MAX], dp[101], dpp[101];
string s;
vector<ll> v;
string s1, s2, s3;


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

        cin>>n;
        cin>>s1>>s2>>s3;
        for(i=0;i<n;i++){
            if(s1[i]==s2[i] && s2[i]==s3[i])continue;
            if(s1[i]==s2[i] || s2[i]==s3[i] || s3[i]==s1[i])
                ans++;
            else
                ans+=2;
        }
        cout<<ans;

    
    return 0;   
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int[] a = {1,3,1,2,1,2,1,1,2,1,2,1};
		if (a[x-1] == a[y-1]) System.out.println("Yes");
		else System.out.println("No");
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll int a,b;
    cin>>a>>b;
    
    ll int c = 1;
    ll int cnt = 0;
    // ll int temp = 
    while(c < b)
    {
        cnt++;
        c--;
        c += a;
    }
    cout<<cnt;
    
}


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

using namespace std;

#define FOE(i, s, t) for (int i = s; i <= t; i++)
#define FOR(i, s, t) for (int i = s; i < t; i++)
#define FOD(i, s, t) for (int i = s; i >= t; i--)
#define PI 3.14159265358979323846

#define LL long long
#define mp make_pair
#define pb push_back

int a, b, h, m;

int main() {
	cin >> a >> b >> h >> m;
	
	double hdx = a * sin((h * 1.0 / 12 + m * 1.0 / 60 / 12) * PI * 2);
	double hdy = a * cos((h * 1.0 / 12 + m * 1.0 / 60 / 12) * PI * 2);
	
//	printf("%.9f %.9f\n", hdx, hdy);
	
	double mdx = b * sin(m * 1.0 / 60 * PI * 2);
	double mdy = b * cos(m * 1.0 / 60 * PI * 2);
	
//	printf("%.9f %.9f\n", mdx, mdy);

	double dx = hdx - mdx;
	double dy = hdy - mdy;
	
//	printf("?? %.9f %.9f\n", dx, dy);
	
	double ret = sqrt(dx * dx + dy * dy);
	
	printf("%.13f\n", ret);
}

Measured memory_bytes: 4060
# coding: utf-8
# Your code here!

import sys
from collections import deque, Counter
import bisect
import math
from itertools import accumulate, product, permutations, combinations, groupby
from fractions import gcd 
import heapq
sys.setrecursionlimit(10**6)
#input = sys.stdin.readline #文字列入力のときは注意

#n = int(input())
#s = input()
#a = [int(i) for i in input().split()]
#m = [[int(i) for i in input().split()] for j in range(n)] # 縦「n」行

n = int(input())

ans = 0
for x in range(1,10**6+1):
    if n%x != 0: continue
    m=n//x-1
    if x >= m: continue
    ans += m
    
print(ans)        





Measured memory_bytes: 5324
/********************************************************************************
	
	Code by a weak man who named CYJian, and he hopes the code can get more points.

	Algorithm: 

 ********************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO AND SOME FUNCTIONS
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define ra read_alpha()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline char read_alpha() { char c = ge; while(!isalpha(c) && c != EOF) c = ge; return c; }
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

vector<int>b[310];
int a[310][310];
int ban[310];
int sz[310];
int p[310];

int main() {
#ifdef LOCAL
	FILE("");
#endif

	int n = ri, m = ri;
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++)
			a[i][j] = ri;
		b[a[i][1]].push_back(i);
		sz[a[i][1]]++;
		p[i] = 1;
	}
	int mi = n;
	for(int i = 1; i < m; i++) {
		int t = 0;
		for(int j = 1; j <= m; j++)
			if(!ban[j] && sz[j] > sz[t])
				t = j;
		chkmin(mi, sz[t]), ban[t] = 1;
		for(auto u : b[t]) {
			for(int&j = p[u]; j <= m; j++) {
				if(!ban[a[u][j]]) {
					sz[a[u][j]]++;
					b[a[u][j]].push_back(u);
					break;
				}
			}
		}
	} cout << mi << endl;
	return 0;
}

Measured memory_bytes: 1536
var a,b,c,sum;
function Main(input){
    i=input.split("\n")
    a=i[1].split(" ").map(Number);
    b=i[2].split(" ").map(Number);
    c=i[3].split(" ").map(Number);
    solve(0,0)
    console.log(ans)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
function solve(nowi,sum){
    if(nowi>0&&a[nowi-1]===a[nowi]-1){sum+=c[a[nowi]-2];}
    sum+=b[a[nowi]-1]
    if(nowi>=a.length-1){
        ans=sum}
    else solve(nowi+1,sum);
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;

#define TT template<typename T>
#define ET(T) typename T::value_type
TT inline T sq(T x){return x*x;}
TT inline T In(){T x;cin>>x;return x;}
TT inline int ubnd(T&v,ET(T) x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT inline int lbnd(T&v,ET(T) x){return lower_bound(begin(v),end(v),x)-begin(v);}
TT inline void sort(T&v){sort(begin(v),end(v));}
TT inline void revs(T&v){reverse(begin(v),end(v));}
TT inline void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT inline void inpt(T&v,int n,function<ET(T)()>f=In<ET(T)>){for(v.reserve(n);n--;v.emplace_back(f()));}
TT inline void show(T&v,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),cout<<x;cout<<e;}
#undef TT
#undef ET

inline void fast_io(){ios::sync_with_stdio(0); cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline string instr(){string x;cin>>x;return x;}
inline ll pow_mod(ll a, ll k, ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a, ll p){return pow_mod(a,p-2,p);}

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

int main()
{
  int n, m;
  while (cin >> n >> m, n){
    ld table[128][128];
    for (int i = 0; i < n; i++){
      for (int j = 0; j < n; j++){
        cin >> table[i][j];
      }
    }
    ld dp[128][128];
    for (int i = 0; i <= m; i++){
      for (int j = 0; j < n; j++){
        dp[i][j] = 0;
      }
    }
    for (int i = 0; i < n; i++){
      dp[1][i] = 1.0;
    }
    for (int i = 2; i <= m; i++){
      for (int j = 0; j < n; j++){
        for (int k = 0; k < n; k++){
          dp[i][j] = max(dp[i][j], dp[i - 1][k] * table[k][j]);
        }
      }
    }
    printf("%.2Lf\n", *max_element(dp[m], dp[m] + n));
  }
  return (0);
}

// priority_queue queue deque front top push pop map set stringstream max_element min_element insert count find get tie make_tuple

Measured memory_bytes: 1640
n,a,b = map(int,input().split())
if (a-b)%2 == 0:
    print(abs(a-b)//2)
else:
    if abs(a-1) <= abs(n-b):
        # b -= abs(a-1)
        if (a-b)%2 == 1:
            b -= 1
            print(abs(a-1)+abs(a-b)//2+1)
        else:
            print(abs(a-1)+abs(a-b)//2)
    else:
        # a += abs(n-b)
        if (a-b)%2 == 1:
            # b += 1
            a += 1
            print(abs(n-b)+abs(a-b)//2+1)
        else:
            print(abs(n-b)+abs(a-b)//2)



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

int main() {
int N,M,C;
int ans = 0;

cin >> N >> M >> C;
vector<int> B(M);
for(int i=0;i<M;++i){
  cin >> B.at(i);
}
vector<vector<int>> A(N,vector<int>(M));
for(int i=0;i<N;++i){
  for(int j=0;j<M;++j){
    cin >> A.at(i).at(j);
  }
}
for(int i=0;i<N;++i){
  int sum = 0;
  for(int j=0;j<M;++j){
    sum += A.at(i).at(j) * B.at(j);
  }
  if(sum+C > 0) ans += 1;
}
cout << ans << endl;
}


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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P = pair<int, int>;

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

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

//---------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------

set<i64> memo;

void dfs(i64 cur) {
    rep(i, 0, 10) {
        auto a = cur % 10L;
        if (abs(a - i) > 1) {
            continue;
        }
        auto next = cur * 10L + i;
        if (next > 3234566667L) {
            return;
        }
        memo.insert(next);
        dfs(next);
    }
}

signed main() {
    memo.insert(3234566667L);
    int K;
    cin >> K;
    rep(i, 1, 10) {
        memo.insert(i);
        dfs(i);
    }
    int cnt = 0;
    for (const auto& a : memo) {
        cnt++;
        if (cnt == K) {
            cout << a << "\n";
            return 0;
        }
    }
}


Measured memory_bytes: 4992
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a,op,b = ns().split()
if op == "+":
    print(int(a) + int(b))
if op == "-":
    print(int(a) - int(b))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int n, m = -1e9; scanf("%d", &n);
  v2i v(n, v1i(10)), u(n, v1i(11));
  rep(i, n) rep(j, 10) scanf("%d", &v[i][j]);
  rep(i, n) rep(j, 11) scanf("%d", &u[i][j]);
  rep(i, 1 << 10){
    if(i == 0) continue;
    int t = 0;
    rep(j, n){
      int x = 0;
      rep(k, 10) if(i & 1 << k && v[j][k] == 1) ++x;
      t += u[j][x];
    }
    m = max(m, t);
  }
  printf("%d\n", m);
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		
	Scanner sc = new Scanner(System.in);
	int x,y;
	int copy = 0;
	
	   for(int i = 1; true; i++){
		   x = sc.nextInt();
		   y = sc.nextInt();
		   if(x == 0 && y == 0) break;
		   
		   else if(x > y){
			   copy = x;
			   x = y;
			   y = copy;
		   }
		   System.out.println(x + " " + y);
	   }
	sc.close();
	}
}



Measured memory_bytes: 34128
#include <iostream>
#include <vector>

using namespace std;

int main() {

	long long int n;
	cin >> n;

	vector<int> furui(55556, 1);

	furui[0] = furui[1] = 0;

	for (long long int i = 2; i*i <= 55555; i++) {
		if (furui[i] == 1) {
			for (long long int j = 2; i*j <= 55555; j++) {
				furui[i*j] = 0;
			}
		}
	}

	vector<long long int> a2;

	long long int sum = 7;

	cout << 7;
	n--;
	//a2.push_back(7);

	for (long long int j = 17;; j+=10) {
		if (n > 0) {
			if (furui[j] == 1) {
				cout << " " << j;
				n--;
				//sum += j;
				//a2.push_back(j);
			}
		}
		else {
			break;
		}
	}

	cout << endl;

	/*
	for (long long int j = 0; j < a2.size(); j++) {
		cout << sum - a2[j] << endl;
	}*/

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
typedef long long ll;
#define all(a)  (a).begin(), (a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i = 0; i < n; i++)
#define repR(i,n) for(int i = n; i >= 0; i--)
#define FOR(i,m,n) for(int i = m; i < n; i++)
#define PB push_back
#define MP make_pair
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
    int x; cin >> x;
    string res;
    if(x == 7 || x == 5 || x == 3)res = "YES";
    else res = "NO";
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll a, b;
	cin >> a >> b;
	for(ll i = 0; i <= 100000; i++){
		if((ll)(i * 0.08 + 1e-7) == a && (ll)(i * 0.1 + 1e-7) == b){
			cout << i << '\n';
			return 0;
		}
	}
	cout << -1 << '\n';

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N,X;
    cin >> N >> X;
    auto x = InputVec(N);
    x.push_back(X);
    sort(x.begin(),x.end());
    ll res = x[1]-x[0];
    for (int i = 2; i < N+1; ++i) {
        res = __gcd(res,x[i]-x[i-1]);
    }
    cout << res << endl;

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }


int n,m,q;
vector<ll> a,b,c,d;

ll calc(const vector<int> &A){
    ll res = 0;
    rep(i,q) {
        if(A[b[i]]-A[a[i]] == c[i]) res += d[i];
    }
    return res;
}

void dfs(vector<int> &A,ll &res) {
    if(A.size()==n+1){
        ll tmp = calc(A);
        chmax(res,tmp);
        return;
    }
    ll ba = A.back();
    for(int add = ba;add <= m;add++) {
        A.push_back(add);
        dfs(A,res);
        A.pop_back();
    }
}

ll solve() {
    ll res = 0;
    vector<int> A({1});
    dfs(A,res);
    return res ;
}
int main(void){
    // Your code here!
    while(cin >> n >> m >> q){
        a.resize(q);b.resize(q);c.resize(q);d.resize(q);
        rep(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i];
        cout << solve() << endl;
    }
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define dl double
#define mod 1000000007
#define sz 200005
#define szz 35

using namespace std;

class code
{
public:
    ll v,f;
};

code pari[sz];

bool cmp(code c1, code c2)
{
    return c1.f<c2.f;
}

int main()
{
    ll n,arr[sz],k,x;

    scanf("%lld %lld",&n,&k);

    memset(arr, 0, sizeof(arr));

    for(ll i=1; i<=n; i++)
    {
        scanf("%lld",&x);

        arr[x]++;
    }

    ll m=0;

    for(ll i=1; i<=n; i++)
    {
        if(arr[i])
        {
            pari[m].v=i;
            pari[m].f=arr[i];
            m++;
        }
    }

    //printf("m = %lld\n",m);

    sort(pari, pari+m, cmp);

    ll cnt=0;

    for(ll i=0; i<m-k; i++)
    {
        //printf("%lld\n",pari[i].v);
        cnt+=pari[i].f;
    }

    printf("%lld\n",cnt);

    return (0);
}




Measured memory_bytes: 4992
fun main(args: Array<String>) {
    val line = readLine()!!.trim()
    val n = line.toInt()

    val line2 = readLine()!!.trim()
    val josis = line2.split(" ").map {it.toInt()}

    val bukas: MutableList<Int> = (0..n-1).map {0}.toMutableList()
    for (josi in josis) {
        bukas[josi - 1] += 1
    }

    bukas.forEach {
        println("${it}")
    }
}

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

struct Edge{
    int from,to,cost;
};
const int SIZE=1000;

class UnionFind{
    vector<int> par,rank;
    public:
    UnionFind(int n):par(n),rank(n){
        iota(par.begin(),par.end(),0);
    }
    int find(int x){
        if(par[x]==x) return x;
        else return par[x]=find(par[x]);
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    void unite(int x,int y){
        x=find(x),y=find(y);
        if(rank[x]<rank[y]) par[x]=y;
        else{
            if(rank[y]==rank[x]) rank[x]++;
            par[y]=x;
        }
    }
};

using Graph=vector<vector<Edge>>;
int solve(int n,int m){
    vector<int> h(n);
    for(int i=0;i<n;i++) cin>>h[i];

    {
        set<int> x;
        for(int i=0;i<n;i++) x.insert(h[i]);
        int idx=1;
        for(auto &e:x){
            for(int i=0;i<n;i++) if(h[i]==e) h[i]=idx;
            idx++;
        }
    }

    Graph g(n);
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        g[a].push_back(Edge{a,b,c});
        g[b].push_back(Edge{b,a,c});
    }
    // cerr<<"Input finished"<<endl;
    vector<vector<int>> sinks(SIZE);
    for(int i=0;i<n;i++) sinks[h[i]].push_back(i);
    UnionFind u(n);
    vector<int> land(n,false);
    vector<int> isok(SIZE);
    int cnt=-1;
    for(int t=SIZE-1;t>=0;t--){
        cnt+=sinks[t].size();
        for(auto &v:sinks[t]){
            // cerr<<t<<" "<<v<<endl;
            land[v]=true;
            for(auto &e:g[v]){
                // cerr<<"@"<<e.from<<" "<<e.to<<endl;
                if(land[e.from] && land[e.to] && !u.same(e.from,e.to)){
                    // cerr<<"Hoy"<<endl;
                    u.unite(e.from,e.to);
                    // cerr<<"Hi"<<endl;
                    cnt--;
                }
                // cerr<<"Nui"<<endl;
            }
        }
        isok[t]=cnt<=0;
    }
    // cerr<<"masaka"<<endl;
    int beft=SIZE;
    for(int i=0;i<SIZE;i++){
        if(!isok[i]){
            beft=i;
            break;
        }
    }
    // cerr<<"Beft finished "<<beft<<endl;
    cnt=0;
    int res=0;
    u=UnionFind(n);
    fill(land.begin(),land.end(),false);
    vector<Edge> edges;
    for(int t=beft;t<SIZE;t++){
        for(auto &v:sinks[t]){
            land[v]=true;
            for(auto &e:g[v]){
                if(land[e.from] && land[e.to]){
                    edges.push_back(e);
                }
            }
        }
    }
    for(int t=beft-1;t>=0;t--){
        for(auto &v:sinks[t]){
            land[v]=true;
            for(auto &e:g[v]){
                if(land[e.from] && land[e.to]){
                    edges.push_back(e);
                }
            }
        }
        sort(edges.begin(),edges.end(),[](Edge lhs,Edge rhs){return lhs.cost<rhs.cost;});
        for(auto &e:edges){
            if(!u.same(e.from,e.to)){
                cnt++;
                u.unite(e.from,e.to);
                res+=e.cost;
            }
        }
        edges.clear();
    }
    // assert(cnt==n-1);
    return res;
}
int main(){
    int n,m;
    while(cin>>n>>m,n){
        cout<<solve(n,m)<<endl;
    }
    return 0;
}


Measured memory_bytes: 4184
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, K;
    cin >> N >> K;
    int l[N];
    for (int i = 0; i < N; i++) cin >> l[i];

    sort(l, l + N, greater<int>());

    int max_len = 0;
    for (int i = 0; i < K; i++)
    {
        max_len += l[i];
    }

    cout << max_len << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10, inf = 0x3f3f3f3f, mod = 1e9 + 7;

int a[maxn], b[maxn];
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    int A, B, M;
    cin >> A >> B >> M;
    for (int i = 1; i <= A; ++i) cin >> a[i];
    for (int i = 1; i <= B; ++i) cin >> b[i];
    int ans = inf;
    for (int i = 1; i <= M; ++i){
        int x, y, c;
        cin >> x >> y >> c;
        ans = min(ans, a[x] + b[y] - c);
    }
    ans = min(ans, *min_element(a + 1, a + 1 + A) + *min_element(b + 1, b + 1 + B));
    cout << ans << endl;
//    fclose(stdin);
//    fclose(stdout);
    return 0;
}


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

using namespace std;

int main()
{
    int A, B;
    
    cin >> A >> B;
    
    if((A - (2 * B)) < 0){
        cout << 0 << endl;
    }
    else{
        cout << (A - (2 * B)) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;
const double PI = acos(-1);

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

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

lli nums[MAXN + 5];
vlli primes;

void sieve() {
    memset(nums, 1, sizeof(nums));

    for (int i = 2; i * i <= MAXN; i++) {
        if (nums[i]) {
            for (int j = 2 * i; j <= MAXN; j += i) {
                nums[j] = 0;
            }
        }
    }

    for (int i = 2; i <= MAXN; i++) {
        if (nums[i]) {
//            cout << i << endl;
            primes.push_back(i);
        }
    }
}
void solve() {
    sieve();
    lli x;
    cin >> x;
    cout << *(lower_bound(all(primes), x)) << endl;
}

int main()
{
    IOS;
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; i++) {
        //cout << "Case " << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 1280
N, Y = map(int, input().split())
x, y, z = 0, 0, 0
for x in range(N+1):
    for y in range(N+1-x):
        z = N - x - y
        if 10000*x + 5000*y + 1000*z == Y:
            break
    if 10000*x + 5000*y + 1000*z == Y:
        break
    x, y, z = -1, -1, -1
print(x, y, z)


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

#define REP(i, n) for (int i = 0; i < (int)n; i++)
using tii = tuple<int, int>;

int H, W, M;
int A[300001];
int B[300001];
int C[300001];
int D[300001];

int main() {
  cin >> H >> W >> M;

  REP(i, M) {
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
    C[A[i]]++;
    D[B[i]]++;
  }

  int mc = *max_element(C, C+H);
  int md = *max_element(D, D+W);
  int nmc = 0; REP(i, H) if (C[i] == mc) { nmc++; }
  int nmd = 0; REP(i, W) if (D[i] == md) { nmd++; }
  int nme = 0; REP(i, M) if (C[A[i]] == mc && D[B[i]] == md) { nme++; }

  cout << mc + md - ((nmc * nmd - nme) == 0) << endl;

  return 0;
}

Measured memory_bytes: 8288
N = int(input())
A = [int(a) for a in input().split()]

for i in range(N):
    A[i] = (A[i], i)

L = [0]*N
A.sort(reverse=True)
cnt = 0
ans = 0
for i in range(N):
    cnt += 1
    L[A[i][1]] = 1
    if A[i][1] > 0 and L[A[i][1]-1] == 1:
        cnt -= 1
    if A[i][1] < N-1 and L[A[i][1]+1] == 1:
        cnt -= 1

    if i < N-1 and A[i][0] == A[i+1][0]:
        continue
    if A[i][0] == 0:
        break
    ans = max(ans, cnt)

print(ans)


Measured memory_bytes: 20232
#include <stdio.h>
int main(){
    int i,n;
    scanf("%d",&n);
    int fib[n+2];
    fib[0]=1;
    fib[1]=1;
    for(i=2;i<n+2;i++)fib[i]=fib[i-1]+fib[i-2];
    printf("%d\n",fib[n]);
    return 0;
}

Measured memory_bytes: 596
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
A = list(map(int, readline().split()))
mod = 10 ** 9 + 7


def lcm(X, Y):
    x = X
    y = Y
    if y > x:
        x, y = y, x
    while x % y != 0:
        x, y = y, x % y
    return X * Y // y


cnt = 0
ans = 0
LCM = 1
for i in range(n):
    Q = lcm(LCM, A[i])
    cnt *= Q // LCM
    LCM = Q
    cnt += Q // A[i]
print(cnt % mod)


Measured memory_bytes: 44380
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
      	int b = in.nextInt();
      	int c = in.nextInt();
        System.out.println(c + " " + a + " " + b);
    }
 
}

Measured memory_bytes: 21844
// #include <bits/stdc++.h>
#include <cmath>
#include <iostream>
using namespace std;
using ll = long long;
ll n, m;
ll a[100005];
ll sig[2 * 100005];
ll ct[2 * 100005];
ll neg[2 * 100005];

int main () {
    ios::sync_with_stdio(false);
    cin >> n >> m;
    ll all = 0;
    
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i]--;
    }

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

        // calc operations without favorite
        ll d = a[i] - a[i - 1];
        if (d < 0) d += m;
        all += d;

        // add range
        ll l = a[i - 1];
        ll r = a[i];
        if (l > r) r += m;
        if (l + 1 >= r) continue;
        sig[l + 2]++;
        sig[r + 1]--;
        neg[r + 1] += r - l - 1;
    }

    // cout << "all: " << all << endl;
    // cout << "neg: " << endl;
    for(int i = 0; i < 2 * m; ++i) {
        // cout << neg[i] << ' ';
    }
    // cout << endl;
    ll pct = 0;
    ll cur = 0;
    // cout << "sig: " << endl;
    
    for(int i = 0; i < 2 * m; ++i) {
        // cout << sig[i] << ' ';
    }
    // cout << endl;
    // cout << "pct: " << endl;

    for(int i = 0; i < 2 * m - 1; ++i) {
        pct += sig[i];
        // cout << pct << ' ';
        cur += pct;
        cur -= neg[i];
        ct[i] = cur;
    }
    // cout << endl;
    for(int i = 0; i < 2 * m; ++i) {
        // cout << ct[i] << ' ';
    }
    // cout << endl;
    ll mmax = 0;
    // cout << endl;
    for(int i = 0; i < m; ++i) {
        ll cd = ct[i];
        if (i + m < 2 * m - 1) cd += ct[i + m];
        mmax = max(mmax, cd);
        // cout << ct[i] + ct[i + m] << endl;
    }

    cout << all - mmax << endl;
    
}

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

double n,k;
double m;

double calc_m(long long num){
  double res = 0;
  while(num < k){
    num *= 2;
    res++;
  }
  return res;
}

int main() {
  cin >> n >> k;
  double ans = 0;
  double m1 = calc_m(1);
  double m_num = 1;
  for(int i = 2; i <= n; i++){
    m_num += pow(2, m1 - calc_m(i));
  }
  cout << setprecision(14) << ((m_num / pow(2, m1)) / n) << endl;
  return 0;
}

Measured memory_bytes: 256
function Main(input) {
 
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
  
    let a = BigInt(input[0].split(" ")[0])
    let b = BigInt(input[0].split(" ")[1])
    let c = BigInt(input[0].split(" ")[2])
  
    let num = a ** 2n + b ** 2n + c ** 2n - (2n * a * b) - (2n * b * c) - (2n * c * a);
    
    if ((c - a - b) > 0 && num > 0) console.log("Yes")
    else console.log("No")
    
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29596
#include <stdio.h>

int main() {
    int n, m, l, a[100][100], b[100][100], i, j, k;
    long long c;
    scanf("%d%d%d", &n, &m, &l);
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    for (i = 0; i < m; i++) {
        for (j = 0; j < l; j++) {
            scanf("%d", &b[i][j]);
        }
    }
    for (i = 0; i < n; i++) {
        for (j = 0; j < l; j++) {
            c = 0;
            for (k = 0; k < m; k++) {
                c += a[i][k] * b[k][j];
            }
            printf("%lld", c);
            if (j < l - 1) {
                printf(" ");
            } else {
                printf("\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 680
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void ans(bool x){if(x) cout<<"win"<<endl;else cout<<"bust"<<endl;}

const ll INF=1001001001;

int main(){
  int a;
  int b=0;
  rep(i,3){
    cin>>a;
    b+=a;
  }
  ans(b<=21);
}
  

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define ll long long
#define gc getchar()
using namespace std;
#define mem(a,b) memset(a,b,sizeof a)
#define upf(i,a,b) for(int i=a,i##e=b;i<=i##e;++i)
#define fup(i,a,b) for(int i=a,i##e=b;i<i##e;++i)
#define hh putchar(10)


class FIO
{
public:
	template<typename T>FIO& operator >>(T& x){ _R(x);return *this; }
	template<typename T>FIO& operator <<(T x){ _W(x);return *this; }
private:
	char f,c,a[26],i;
	template<typename T>inline void _R(T& x)
	{
		for(f=0;(c=getchar())<48;c==45&&(f=1));
		for(x=c^48;(c=getchar())>47;x=(x<<3)+(x<<1)+(c^48));
		if(f)x=-x;
	}
	template<typename T>inline void _W(T x)
	{
		if(sizeof(x)==1){ putchar(x);return; }
		if(x<0)putchar(45),x=-x;
		if(x>99) {
			for(i=0;x;x/=10)a[i++]=x%10;
			while(i--)putchar(a[i]+48);
		} else if(x>9)putchar(x/10+48),putchar(x%10+48);
		else putchar(x+48);
	}
}io;

char ch,fh;
template<class T>inline void zin(T& x) {
	for(fh=0;(ch=getchar())<48;ch==45&&(fh=1));
	for(x=ch^48;(ch=getchar())>47;)x=(x<<3)+(x<<1)+(ch^48);
	if(fh)x=-x;
} void qin(){}
template<class T,class...U>
void qin(T& head,U&...tail){zin(head);qin(tail...);}




int main()
{
	int x,y,z;
	io>>x>>y>>z;
	x-=z;
	io<<x/(y+z);
	return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n = sc.nextInt();
		String s1=sc.next();
		String s2=sc.next();
		long mod=1000000007;
		long ans=1;
		for(int i = 0; i<n;){
			if(s1.charAt(i)==s2.charAt(i)){
				if(i==0){
					ans*=3;
				}else if(s1.charAt(i-1)==s2.charAt(i-1)){
					ans*=2;
				}
				i++;
			}else{
				if(i==0){
					ans*=6;
				}else if(s1.charAt(i-1)==s2.charAt(i-1)){
					ans*=2;
				}else{
					ans*=3;
				}
				i+=2;
			}
			ans%=mod;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JButton;
import javax.swing.JScrollPane;
import java.awt.Container;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.text.BadLocationException;
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args)throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        ArrayList<Integer> numarray = new ArrayList<Integer>();
        String num = br.readLine();
        
        while(num != null){
            String[] temp = num.split("\\s");
            for(int i = 0;i<temp.length;i++){
                int temp2 = Integer.parseInt(temp[i]);
                numarray.add(temp2);
                //System.out.println(temp2);
            }
        num = br.readLine();
        }
        br.close();

        if(numarray.isEmpty() == false){
           
               for(int i = 0; i < numarray.size(); i+=2){
               int num1 = numarray.get(i);
               int i2 = i+1;
               int num2 = numarray.get(i2);
               if(num1 == 0 && num2 ==0){
                   break;
               }
               else if(num1 < num2){
                   String Ans1 = num1 + " "  + num2;
                   System.out.println(Ans1);
               }else{
                   String Ans2 = num2 + " " + num1;
                   System.out.println(Ans2);
               }
           }
        }
        
    }
}

Measured memory_bytes: 30148
import std.stdio, std.range, std.conv, std.string, std.array, std.functional, std.math;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting;
import std.container.binaryheap;
import std.typecons; 

void main()
{
    const input = readln().strip.split.to!(long[]);

    foreach(e; 1..4)
    {
        if(input[0] * input[1] * e % 2 == 1)
        {
            writeln("Yes");
            return;
        }
    }
    writeln("No");
}

Measured memory_bytes: 256
//  ⚫⚫ | ⚫➖➖ ⚫⚫ ⚫➖⚫⚫ ⚫➖⚫⚫ | ➖⚫⚫⚫ ⚫ | ⚫➖ | ⚫➖⚫ ⚫ ➖⚫⚫ | ➖⚫➖⚫ ➖➖➖ ➖⚫⚫ ⚫ ⚫➖⚫
#include<bits/stdc++.h>
#define n0_nnE int main(){
using namespace std;
typedef long long ll;
n0_nnE
	string s;cin>>s;
	ll an=0;
	for(char x:s){
		an+=x-48;}
	cout<<(an%9==0? "Yes":"No");


}

Measured memory_bytes: 3704
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a, a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ld x, ld y, ld a, ld b){ return sqrt((x-a)*(x-a) + (y-b)*(y-b)); }
void debug(ll* a, ll n) { for ( ll k = 0; k < n; k++ ){ cerr << a[k] << " ";} cout << "\n"; }
#define PI 3.14159265358979323846

int main(){
	FASTIO;
	ll n, m; cin >> n >> m;
	ll p[n]; parseArray(p, n); for ( int k = 0; k < n; k++ ) p[k]--;
	bool vis[n]; memset(vis, 0, sizeof vis);
	vector<ll> tour;
	ll cur = 0;
	while (!vis[cur]) {
		tour.pb(cur);
		vis[cur] = true;
		cur = p[cur];
	}
	//for ( int k = 0; k < sz(tour); k++ ) cout << tour[k] + 1 << " "; cout << endl;
	ll idx = 0;
	while (m && tour[idx] != cur) {
		m--;
		idx++;
	}
	if (m == 0)
		return cout << tour[idx] + 1 << endl, 0;
	//cout << "idx: " << idx << endl;
	//cout << "m: " << m << endl;
	m %= (ll)sz(tour) - idx;
	cout << tour[m + idx] + 1 << endl;
	return 0;
}

Measured memory_bytes: 7084
import collections

N = int(input())
A = list(map(int, input().split()))
C = collections.Counter(A)
Sans = 0
for num in C.values():
    Sans += num*(num-1)//2

for a in A:
    num = C[a] - 1
    ans = Sans - C[a]*(C[a]-1)//2 + num*(num-1)//2
    print(ans)


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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
using li=list<int>;
using lil=list<ll>;
using lis=list<string>;
using fli=forward_list<int>;
using fll=forward_list<ll>;
using fls=forward_list<string>;
using si=stack<int>;
using sl=stack<ll>;
using ss=stack<string>;
using qi=queue<int>;
using ql=queue<ll>;
using qs=queue<string>;
using pqi=priority_queue<int>;
using pql=priority_queue<ll>;
using pqs=priority_queue<string>;
using dqi=deque<int>;
using dql=deque<ll>;
using dqs=deque<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

template<typename T,typename U>
void Printarray2(T f,U n){
  for(int i=0;i<n;i++) cout<<f[i]<<endl;
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n,ans=0,cnt;cin>>n;
  rep2(i,1,n+1){
    cnt=0;
    rep2(j,1,i+1){
      if(i%j==0)cnt++;
    }
    //cout<<i<<" "<<cnt<<endl;
    if(i%2==1 && cnt==8)ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std ;
long long a[1000000] ;

int main() {
    long long n,x ,i ;
    cin >> n ;


    for(i=0;i<n;i++){
        cin >> x ;
        a[x-1] = i+1 ;
    }

    for(i=0;i<n;i++)
        cout << a[i] << ' ' ;
    cout << endl ;

}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    while(t)
    {
        ll n,a,b;
        cin>>n>>a>>b;
        ll sum=a+b;
        ll temp=n/sum;
        ll rem=n%sum;
        ll ans=(temp*a);
        if(rem>a)
        {
            ans+=a;
        }
        else
        {
            ans+=rem;
        }
        cout<<ans;
        t--;
    }
    return 0;
}







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

#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)

int main() {
  int N;
  cin>>N;
  bool ans=false;
 vector<int64_t>A(N);
    for(int i=0;i<N;i++)cin>>A.at(i);
  sort(A.begin(),A.end());
  for(int i;i<N-1;i++){
    if(A.at(i)==A.at(i+1))ans=true;
  }
  if(ans)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
  
}
  

        

Measured memory_bytes: 1792
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

#define pb push_back
#define lb lower_bound
#define sf scanf
#define pf printf
typedef long long ll;

inline void read(int &input)
{
	char ch;
	int value=0,sign=1;
	do{
		ch=getchar();
		if(ch=='-')
			sign=-1;
	}while(ch<'0'||ch>'9');
	while(ch>='0'&&ch<='9'){
		value=value*10+ch-'0';
		ch=getchar();
	}
	input=value*sign;
}
inline void write(int output)
{
	if(output<0){
		putchar('-');
		output*=-1;
	}
	if(output>=10)
		write(output/10);
	putchar(output%10+'0');
}
string solve(string s)
{
	if(s[0]!='A') return "WA";
	int x=0;
	for(int i=0;i<s.size();i++)
		if(s[i]=='C'){
			if(i<2||i>s.size()-2)
				return "WA";
				x++;
		}
		else if(s[i]>='B'&&s[i]<='Z')
			return "WA";
	if(x!=1) return "WA";
	return "AC";
}
int main()
{
	string s;
	cin>>s;
	cout<<solve(s);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,j;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>j;
    a[j-1]=i+1;
  }
  for(int i=0;i<n;i++)
  {
    cout<<a[i]<<" ";
  }
  return 0;
}

Measured memory_bytes: 1152