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

bool f(std::vector<int> t, std::vector<std::pair<int, int> > p) {

    for (int i = 1; i < t.size(); i++) {
        int distance = std::abs(p[i].first - p[i - 1].first) + std::abs(p[i].second - p[i - 1].second);
        int time = t[i] - t[i - 1];
        if (time == distance) {
            continue;
        }
        if (time < distance) {
            return false;
        }
        if ((time - distance) % 2 != 0) {
            return false;
        }
    }

    return true;
}

int main() {

    int n;
    std::cin >> n;

    std::vector<int> t;
    std::vector<std::pair<int, int> > positions;
    std::pair<int, int> p;
    p.first = 0;
    p.second = 0;
    t.push_back(0);
    positions.push_back(p);
    for (int i = 0; i < n; i++) {
        int tmp;
        std::pair<int, int> p;
        std::cin >> tmp >> p.first >> p.second;
        t.push_back(tmp);
        positions.push_back(p);
    }

    if (f(t, positions)) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 2544
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> A = new ArrayList<Integer>();
        while (true) {
            int n = sc.nextInt();
            int x = sc.nextInt();
            if (n == 0 & x == 0) {
                for (int i=0; i<A.size(); i++) {
                    System.out.println(A.get(i));
                }
                break;
            }
            int count = 0;
            for (int i=1; i<n-1; i++) {
                for (int j=i+1; j<n; j++) {
                    for (int k=j+1; k<n+1; k++) {
                        if (i + j + k == x) {
                            count++;
                        }
                    }
                }
            }
            A.add(count);
        }
    }
}


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

using namespace std;
using Int = long long;

signed main(){
    Int n;
    cin >> n;
    Int count = 0;
    Int p_before = -1;
    Int p = -1;
    Int p_after = -1;
    for(Int i = 0; i < n; i++){
        Int tmp;
        cin >> tmp;
        if (i == 0){
            p_before = tmp;
        } else if(i == 1){
            p = tmp;
        } else if(i == 2){
            p_after = tmp;
            if (p > p_before && p_after > p) count++;
            if (p < p_before && p_after < p) count++;
        } else{
            p_before = p;
            p = p_after;
            p_after = tmp;
            if (p > p_before && p_after > p) count++;
            if (p < p_before && p_after < p) count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =3e5+10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
typedef long long ll;
int hang[MAXN],lie[MAXN];
map<pair<int,int>,int >mp;
vector<int>v1,v2;
int main()
{
	int n,m,t;
	int flag=0;
	scanf("%d %d %d",&n,&m,&t);
	for(int i=1;i<=t;i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		mp[{x,y}]=1;
		hang[x]++;
		lie[y]++;
	}
	int max1=0,max2=0;
	for(int i=1;i<=n;i++)
	{
		max1=max(max1,hang[i]);
	}
	for(int i=1;i<=n;i++)
	{
		if(hang[i]==max1) v1.push_back(i);
	}
	for(int i=1;i<=m;i++)
	{
		max2=max(max2,lie[i]);
	}
	for(int i=1;i<=m;i++)
	{
		if(lie[i]==max2) v2.push_back(i);
	}
	int size1=v1.size(),size2=v2.size();
	if(1ll*size1*size2>t) printf("%d\n",max1+max2);
	else
	{ 
	for(int i=0;i<size1;i++)
	{
		for(int j=0;j<size2;j++)
		{
			int x=v1[i],y=v2[j];
			if(!mp[{x,y}])
			{
				flag=1;
				break;
			}
		}
		if(flag) break;
	}
	if(flag) printf("%d\n",max1+max2);
	else printf("%d\n",max1+max2-1);
	}  
	return 0;
}

Measured memory_bytes: 28468
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define fastio ios_base::sync_with_stdio(false); cout.tie(NULL);
using namespace std;

int main()
{
	fastio;
	lli n;
	cin>>n;
	if(n%2)
		cout<<0;
	else
	{
		lli div=10,ans=0;
		while(div<=n)
		{
			ans+=n/div;
			div*=5;
		}
		cout<<ans;
	}
	return 0;
}


Measured memory_bytes: 3596
import sys
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
inf = 10**17
mod = 10**9+7

n, q = map(int, input().split())
g = [[] for _ in range(n)]
val = [0] * n

for _ in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

for _ in range(q):
    p, x = map(int, input().split())
    val[p - 1] += x

seen = [False] * n
deq = deque()
deq.append(0)
while deq:
    v = deq.pop()
    seen[v] = True
    for nv in g[v]:
        if seen[nv]:
            continue
        deq.append(nv)
        val[nv] += val[v]

print(*val)


Measured memory_bytes: 116472
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

//21:45
fn main(){
    let n: usize = read_as_vec()[0];

    let mut r: Vec<(i64, i64)> = vec![];

    for _ in 0..n{
        let line = read_as_vec::<i64>();
        r.push((line[0], line[1]));
    }
    let mut b: Vec<(i64, i64)> = vec![];
    for _ in 0..n{
        let line = read_as_vec::<i64>();
        b.push((line[0], line[1]));
    }
    r.sort_by_key(|p| p.1);
    r.reverse();
    b.sort();

    let mut used_r = vec![false;n];
    let mut used_b = vec![false;n];

    for i in 0..b.len(){
        for j in 0..r.len(){
            if !used_b[i] && !used_r[j] && r[j].0 < b[i].0 && r[j].1 < b[i].1{
                used_b[i] = true;
                used_r[j] = true;
            }
        }
    }

    println!("{}", used_r.into_iter().filter(|x| *x).count());
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int N,K;cin>>N>>K;
 vector <long long int> HP(N);
  for(long long int i =0;i<N;i++)
  {
  cin>>HP[i];
  }
  sort(HP.begin(),HP.end());
 long long int sum=0;
  for(long long int i=0;i<N-K;i++)
  {
   sum=sum+HP[i];
  }
    cout<<sum<<endl;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		double n;int i;
		while(sc.hasNext()){
			n=sc.nextDouble();
			for(i=1;;i++){	//t=√(y/4.9);y=5*i-5 -> v=9.8*√((5*i-5)/4.9)
				if(9.8*Math.sqrt((5*i-5)/4.9)>n){	//v>nで終了
					break;
				}
			}
			System.out.println(i);
		}
		sc.close();
	}
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int64_t> L(N + 1);
  L[0] = 2;
  L[1] = 1;
  
  if (N > 1) {
    for (int i = 0; i < N - 1; i++) {
      L[i + 2] = L[i + 1] + L[i];
    }
  }
  
  cout << L[N] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define LIMIT ( 10 )

/** Application main entry point. */
int main (
  int argc,
  char *argv[ ]
  )
{
  int n;
  int i, j;

  scanf ( "%d", &n );

  while ( n != 0 )
  {
    int h[ LIMIT ] = { 0 };

    for ( i = 0; i < n; ++i )
    {
      int d;

      scanf ( " %d", &d );
      ++h[ d ];
    }

    for ( j = 0; j < LIMIT; ++j )
    {
      if ( h[ j ] )
      {
        for ( i = 0; i < h[ j ]; ++i )
        {
          putchar ( '*' );
        }
      }
      else
      {
        putchar ( '-' );
      }
      putchar ( '\n' );
    }

    scanf ( " %d", &n );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
const int p = 1000000000 + 7;

long long gcd(long long a, long long b) {return !b ? a : gcd(b, a % b); }

void Change(long long &x, long long &y) {
    if (x < 0)  { x = -x; y = -y; }
    if (x == 0 && y < 0)    {y = -y; }
}

long long qpow(long long a, long long k = p - 2) {
    long long res = 1;
    while (k) {
        if (k & 1)  res = res * a % p;
        a = a * a % p;
        k >>= 1;
    }
    return res;
}

int n;
map <pair<long long, long long>, int> mp;

int main() {
    scanf("%d", &n);
    long long ans = 0, tans = 1;
    for (int i = 1; i <= n; i++) {
        long long x, y; scanf("%lld %lld", &x, &y);
        if (!x && !y) {ans++; continue; }
        long long d = gcd(x, y);
        x /= d; y /= d;
        Change(x, y);
        pair<long long, long long> a = {x, y};
        swap(x, y); y = -y;
        Change(x, y);
        pair<long long, long long> b = {x, y};
        
        tans = tans * qpow(qpow(2, mp[a]) + qpow(2, mp[b]) - 1) % p;
        tans = tans * qpow(2, mp[a]) % p;
        ans = (ans + tans) % p;
        tans = tans * qpow(qpow(2, mp[a])) % p;
        mp[a]++;
        tans = tans * (qpow(2, mp[a]) + qpow(2, mp[b]) - 1) % p;
    }
    printf("%lld\n", ans);
#ifndef ONLINE_JUDGE
    system("pause");
#endif
    return 0;
}

Measured memory_bytes: 28564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int a,b,q;
  cin >> a >> b >> q;
  ll s[a];
  ll t[b];
  rep(i,a) cin >> s[i];
  rep(i,b) cin >> t[i];
  ll x[q];
  rep(i,q) cin >> x[i];

  rep(i,q){
    ll sp,sm,tp,tm;
    auto spit = lower_bound(s,s+a,x[i]);
    if(spit!=s+a){
      sp = s[spit-s];
      if(spit-s!=0){
	sm=s[spit-s-1];
      }
      else{
	sm=-1e12;
      }
    }
    else{
      sp=1e12;
      sm=s[a-1];
    }
    auto tpit = lower_bound(t,t+b,x[i]);
    if(tpit!=t+b){
      tp = t[tpit-t];
      if(tpit-t!=0){
	tm=t[tpit-t-1];
      }
      else{
	tm=-1e12;
      }
    }
    else{
      tp=1e12;
      tm=t[b-1];
    }
    ll maxp=max(tp-x[i],sp-x[i]);
    ll maxm=max(x[i]-tm,x[i]-sm);

    ll ans=min(maxp,maxm);
    ll mint=min(tp-x[i],x[i]-tm);
    ll mins=min(sp-x[i],x[i]-sm);
    ans=min(ans, mint+mins+min(mint,mins));
    cout << ans << endl;
  }


  
  
  return 0;
    

}


Measured memory_bytes: 3712
#include<iostream>
using namespace std;
#include<cstring>
int a[100005];
int main()
{
	int n;
	int ans;
	scanf("%d",&n);
	int flag=0;
	for(int i=0;i<n;i++)
	{
		int b;
		scanf("%d",&b);
		a[b]++;
	}
	if(n%2==1)
	if(a[0]!=1)
	{
	flag=1;	
	}
	if(n%2==0)
	if(a[0]!=0)
	flag=1;
	if(flag)
	{
		printf("0");
		exit(0);
	}
	for(int i=n%2+1;i<n-1;i+=2)
	{
		if(a[i]!=2)
		{
			flag=1;
			break;
		}
	}
	if(flag)
	printf("0");
	else
	{
		ans=n/2;
		long long c=1;
		long long mod=1e9+7;
		for(int i=1;i<=ans;i++)
		{
		c*=2;
		c=c%mod;
		}
		cout<<c;
	}
	 
	return 0;	
}


Measured memory_bytes: 640
#include<stdio.h>
#define MAXINP 1200
int main(void){

    char ch;
    char alph[27]="abcdefghijklmnopqrstuvwxyz";
    int alphcount[27]={0};
    scanf("%[^\n]",ch);

    while ( scanf("%c", &ch) != EOF ){
    
        if('a' <= ch && ch <= 'z')
            {
                int num = ch - 'a';
                alphcount[num]++;
            }
         if('A' <= ch && ch <= 'Z')
            {
                int num = ch +32 - 'a';
                alphcount[num]++;
            }
    }

    for ( int  i = 0; i < 26; i++)
    {
        printf("%c : %d\n",alph[i],alphcount[i]);
    }
return 0;
}


Measured memory_bytes: 2032
#include <stdio.h>
#include <stdlib.h>

int comp(const void * p1, const void * p2) {
	return *(int *)p1 - *(int *)p2;
}

int N, A[100010];
long long int S[100010];

int main(void) {
	int i, ans;
	scanf("%d", &N);
	for (i = 0; i < N; i++) 
		scanf("%d", &A[i]);
	qsort(A, N, sizeof(int), comp);

	S[0] = A[0];
	for (i = 1; i < N; i++)
		S[i] = S[i - 1] + A[i];

/*	printf("A = ");
	for (i = 0; i < N; i++) {
		printf("%d ", A[i]);
	}
	printf("\n");
	printf("S = ");
	for (i = 0; i < N; i++) {
		printf("%d ", S[i]);
	}
	printf("\n");*/

	ans = 1;
	for (i = N - 1; i > 0; i--) {
		if (A[i] <= 2 * S[i - 1]) {
			ans++;
		}
		else
			break;
	}

	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1396
input1 = input()
input2 = input()
input3 = input()

N = int(input1.split()[0])
K = int(input1.split()[1])
R = int(input2.split()[0])
S = int(input2.split()[1])
P = int(input2.split()[2])
T = []
for i in range(N):
    T.append(input3[i])



for i in range(N):
    if T[i] == "r":
        T[i] = "P"
    if T[i] == "s":
        T[i] = "R"
    if T[i] == "p":
        T[i] = "S"



for i in range(N - K):
    if T[i] == T[i + K]:
        T[i + K] = "x"

print(R*(T.count("R")) + S*(T.count("S")) + P*(T.count("P")))

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


int main(int, char**) {
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    
    vector<int> p(A);
    for (int i = 0; i < A; ++i)
        cin >> p[i];
    sort(p.begin(), p.end(), std::greater<int>());
    
    vector<int> q(B);
    for (int i = 0; i < B; ++i)
        cin >> q[i];
    sort(q.begin(), q.end(), std::greater<int>());
    
    vector<int> r(C);
    for (int i = 0; i < C; ++i)
        cin >> r[i];
    sort(r.begin(), r.end(), std::greater<int>());
    
    vector<int> res;
    res.reserve(A+B+C);
    for (int i = 0; i < min(A, X); ++i)
        res.push_back(p[i]);
    for (int i = 0; i < min(B, Y); ++i)
        res.push_back(q[i]);
    for (int i = 0; i < min(C, X+Y); ++i)
        res.push_back(r[i]);
    
    sort(res.begin(), res.end(), std::greater<int>());
    lint ans = 0;
    for (int i = 0; i < X+Y; ++i)
        ans += res[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

def ncr(n, r):
    a = 1
    b = 1
    for i in range(r):
        a = (a * (n - i) % MOD)
        b = (b * (r - i) % MOD)

        # a *= ((n - i) % MOD)
        # b *= ((r - i) % MOD)

    return a * pow(b, MOD - 2, MOD) % MOD

N, A, B = MI()

s = pow(2, N, MOD) - 1
ab = (ncr(N, A) + ncr(N, B)) % MOD

print((s - ab)  % MOD)


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rll() {
	long long n;
	scanf("%lld", &n);
	return n;
}

int main() {
	int n = ri();
	int d = ri();
	int a[n][d];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) a[i][j] = ri();
	}
	int res = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < i; j++) {
			int cur = 0;
			for (int k = 0; k < d; k++) cur += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
			int sq = sqrt(cur);
			if (sq * sq == cur) res++;
		}
	std::cout << res << std::endl;
	return 0;
}


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

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

  long long ans = 1;
  for(int i=2; i<n+1; i++) {
   ans *= i; 
   ans %= 1000000007;
  }

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n1 = scn.nextInt();
		int n2 = scn.nextInt();
		int n3 = scn.nextInt();
		int n4 = scn.nextInt();
		int total = 0;
		if(n1>=n2) {
			total+=n2*n3;
			n1-=n2;
		}else {
			total+=n1*n3;
			n1 = 0;
		}
		total+=n1*n4;
		System.out.println(total);
		scn.close();
	}
}

Measured memory_bytes: 23124
import java.io.*;

public class Main{
	public static void main(String args[]){
		try{
			new Main();
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	
	public Main() throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line;
		
		while((line = in.readLine()) != null){
			int size = Integer.parseInt(line);
			if(size==0) break;
			int[][] data = new int[size][2];
			for(int n=0; n<size; n++){
				line = in.readLine();
				String[] tmp = line.split(" ");
				data[n][0] = Integer.parseInt(tmp[0]);
				data[n][1] = Integer.parseInt(tmp[1]);
			}
			
			line = in.readLine();
			size = Integer.parseInt(line);
			for(int n=0; n<size; n++){
				line = in.readLine();
				int num = Integer.parseInt(line);
				int[] N = {0};
				count(data, num, N, 0, 0);
				System.out.println(N[0]);
			}
		}
	}
	
	public void count(int[][] data, int ans, int[] N, int current, int depth){
		if(depth != data.length){
			for(int n=0; n<=data[depth][1]; n++){
				int cost = current + data[depth][0] * n;
				count(data, ans, N, cost, depth+1);
			}
		}
		else{
			if(current == ans){
				N[0]++;
			}
		}
	}
}

Measured memory_bytes: 9744
import heapq
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    X, Y, Z, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)

    def bfs():
        used = set()
        used.add((0, 0, 0))

        q = []
        heapq.heapify(q)
        heapq.heappush(q, (-(A[0] + B[0] + C[0]), 0, 0, 0))
        res = []
        while q:
            v, i, j, k = heapq.heappop(q)
            res.append(-v)

            if len(res) == K:
                return res

            for di, dj, dk in [(1, 0, 0), (0, 1, 0), (0, 0, 1)]:
                ni = i + di
                nj = j + dj
                nk = k + dk

                if ni >= X or nj >= Y or nk >= Z:
                    continue

                if (ni, nj, nk) in used:
                    continue

                used.add((ni, nj, nk))
                heapq.heappush(q, (-(A[ni] + B[nj] + C[nk]), ni, nj, nk))

        return res

    res = bfs()
    res.sort(reverse=True)
    for i in range(K):
        print(res[i])


if __name__ == "__main__":
    main()


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

class TaskA {
public:
    void solve(std::istream &in, std::ostream &out) {
        int a, b, c;
        in >> a >> b >> c;
        out << a * (b == c) + b * (a == c) + c * (a == b);

    }
};


int main() {
    TaskA solver;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
a,b,c,d,e,f = gets.split.map(&:to_i)

dp = Array.new(f+1).map{Array.new(f/2+1,false)}
dp[0][0] = true

dp.each_with_index do |x,i|
    x.each_with_index do |y,j|
        next unless y
        dp[i+100*a][j] = true if i + 100*a + j <= f
        dp[i+100*b][j] = true if i + 100*b + j <= f
        next if i == 0
        dp[i][j+c] = true if 100 * (j+c) / i.to_f <= e && i + j + c <= f
        dp[i][j+d] = true if 100 * (j+d) / i.to_f <= e && i + j + d <= f
    end
end

max = 0
ans = "#{100*a} 0"
dp.each_with_index do |x,i|
    next unless r = x.rindex(true)
    if (z = 100 * r / (i + r).to_f) > max
        max = z
        ans = "#{i+r} #{r}"
    end
end

puts ans

Measured memory_bytes: 34684
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,u=0; cin>>n;
    vector<int> a(n,0);
    rep(i,n){
        cin>>a[i];
        u^=a[i];
    }
    rep(i,n-1){
        printf("%d ",a[i]^u);
    }
    printf("%d\n",a[n-1]^u);
}

Measured memory_bytes: 3972
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using System.Collections;
using static System.Math;
using static System.Console;
class E { static void Main() => new J(); }
class J
{
	const int Mod = 1000000007;
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	HashSet<int>[] es;
	void Solve()
	{
		var N = F();
		es = new HashSet<int>[N];
		for (var i = 0; i < N; i++)  es[i] = new HashSet<int>();
		for (var i = 0; i < N - 1; i++) Add(G());
		par = new int[N];
		size = new int[N];
		dep = new int[N];
		DFS(0, -1, 0);
		var w = N - 1;
		var d = dep[w] / 2 + 1;
		while (dep[w] != d) w = par[w];
		WriteLine(N - size[w] > size[w] ? "Fennec" : "Snuke");
	}
	int[] par, size, dep;
	int DFS(int u, int p, int d)
	{
		par[u] = p;
		dep[u] = d;
		es[u].Remove(p);
		foreach (var v in es[u]) size[u] += DFS(v, u, d + 1);
		return ++size[u];
	}
	void Add(int[] a) => Add(a[0] - 1, a[1] - 1);
	void Add(int a, int b)
	{
		es[a].Add(b);
		es[b].Add(a);
	}
	long GCD(long a, long b)
	{
		var n = (ulong)Abs(a); var m = (ulong)Abs(b);
		if (n == 0) return (long)m; if (m == 0) return (long)n;
		int zm = 0, zn = 0;
		while ((n & 1) == 0) { n >>= 1; zn++; }
		while ((m & 1) == 0) { m >>= 1; zm++; }
		while (m != n)
		{
			if (m > n) { m -= n; while ((m & 1) == 0) m >>= 1; }
			else { n -= m; while ((n & 1) == 0) n >>= 1; }
		}
		return (long)n << Min(zm, zn);
	}
}

Measured memory_bytes: 51896
using System;
using System.Linq;
namespace CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ans = Console.ReadLine().Split().Select(s=>int.Parse(s)).ToArray();
            Console.WriteLine((ans[0]*ans[1])%2==0?"Even":"Odd");
        }
    }
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	cout<<(((A+D-1)/D >= (C+B-1)/B) ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

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

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

    int D, N;
    cin >> D >> N;

    if (N == 100) {
        N = 101;
    }

    if (D == 0) {
        cout << N;
    } else if (D == 1) {
        cout << 100 * N;
    } else {
        cout << 10000 * N;
    }

    return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
        
n, m, k = map(int, input().split())
uf = UnionFind(n)
friends = [0] * n
blocks = [0] * n

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.union(a, b)
    friends[a] += 1
    friends[b] += 1
for k in range(k):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    if uf.same(c, d):
        blocks[c] += 1
        blocks[d] += 1
    

for i in range(n):
    print(uf.size(i) - friends[i] - blocks[i] - 1, end=" ")

Measured memory_bytes: 11136
#include<iostream>
using namespace std;
int main()
{
    int N,i;
    cin >> N;
	int A[N], B[N], C[N];
	for (i=0; i<N; i++) { cin >> A[i]; }
	for (i=0; i<N; i++) { cin >> B[i]; }
	for (i=0; i<N; i++) { cin >> C[i]; }

	int sat=0;
	int prev=-1;
	for (i=0; i<N; i++) {
		sat += B[A[i]-1];
		if (prev+1 == A[i]) sat += C[prev-1];
		prev = A[i];
//printf("%d\n", sat);
	}
    // 出力
    cout << sat << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
c_list = list(input())

#print(N)
#print(c_list)
c_list_org = c_list

for c in range(len(c_list_org)):
    #print(c, c_list_org, c_list)
    if c >= len(c_list)-1:
        break
    if c_list[c] == c_list[c+1]:
        c_list[c] = "del"

#print(c_list)
c_list = [c for c in c_list if c != "del"]
#print(c_list)
print(len(c_list))

Measured memory_bytes: 4652
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
	cout << "{ ";
	for (const auto &v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

const int N = 2e5 + 5;
int a[N];

void solve()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int cnt = 0;
	int curr = 1;
	for (int i = 0; i < n; i++)
	{
		if (a[i] == curr)
		{
			cnt++;
			curr++;
		}
	}
	if (cnt >= 1)
		cout << (n - cnt) << ln;
	else
		cout << -1 << ln;
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t start, stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for (int tc = 1; tc < t + 1; tc++)
		solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <stack>

using ll = long long;

int main() {
    int N;
    std::cin >> N;
    int mod = 1'000'000'007;
    ll ans = 1;
    for (int i = 1; i <= N; i++) {
        ans *= i;
        ans %= mod;
    }

    std::cout << ans << std::endl;
}

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

using namespace std;
int main ()
{
	int n;
	static char tmp[100000 + 5];
	scanf ("%d%*c", &n);
	scanf ("%s", tmp + 1);
	int ans = 0;
	for (int i = 1; i <= n; ++i)
		ans += ((i == 1) || (tmp[i] != tmp[i - 1]));
	printf ("%d\n", ans);
	return 0;
}

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

using namespace std;

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    if(a[0] == a[1] && a[1] != a[2]) {
        cout << "Yes";
    } else if(a[1] == a[2] && a[2] != a[0]) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
defmodule Main do
  def main do
    n = IO.gets("") |> String.trim() |> String.to_integer()
    1..10
    |> Enum.reduce_while(0, fn _, payment ->
      if payment < n, do: {:cont, payment + 1000}, else: {:halt, payment}
    end)
    |> Kernel.-(n)
    |> IO.puts()
  end
end

Measured memory_bytes: 30780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

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

int lcm(int a, int b) { return a * b / gcd(a, b); }

signed main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, 0, n) cin >> a[i];
    // int b = 1;
    int ans = 0;
    // rep(i, 0, n) b = lcm(a[i], b);
    rep(i, 0, n) ans += a[i] - 1;
    cout << ans << "\n";
}

Measured memory_bytes: 3612
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,W,i,j;cin>>n>>W;
	vector<llint>dp(W+1,-big);
	dp[0]=0;
	while(n--){
		llint w,v;cin>>w>>v;
		for(j=W;j>=w;j--){maxeq(dp[j],dp[j-w]+v);}
	}
	for(j=0;j<W;j++){maxeq(dp[j+1],dp[j]);}
	cout<<dp[W]<<endl;
	return 0;
}


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

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, w; cin >> n >> w;
  vector<vector<int>> a(4, vector<int>(1, 0));
  int w0, wi, v; cin >> w0 >> v;
  a[0].push_back(v);
  for (int i = 1; i < n; i++) {
    cin >> wi >> v;
    a[wi - w0].push_back(v);
  }
  for (int i = 0; i < 4; i++) {
    sort(a[i].rbegin(), a[i].rend() - 1);
    for (int j = 1, m = a[i].size(); j < m; j++) {
      a[i][j] += a[i][j - 1];
    }
  }
  int res = -1;
  for (int i0 = 0, m0 = a[0].size(); i0 < m0; i0++) {
    if (i0 * w0 > w) break;
    for (int i1 = 0, m1 = a[1].size(); i1 < m1; i1++) {
      if (i0 * w0 + i1 * (w0 + 1) > w) break;
      for (int i2 = 0, m2 = a[2].size(); i2 < m2; i2++) {
        if (i0 * w0 + i1 * (w0 + 1) + i2 * (w0 + 2) > w) break;
        for (int i3 = 0, m3 = a[3].size(); i3 < m3; i3++) {
          if (i0 * w0 + i1 * (w0 + 1) + i2 * (w0 + 2) + i3 * (w0 + 3) > w) break;
          res = max(res, a[0][i0] + a[1][i1] + a[2][i2] + a[3][i3]);
        }
      }
    }
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
typedef long long int llint;
int main(){
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++){
		ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXn = 1e5 + 10;

int ar[MAXn], n, ans;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		
		cin >> ar[i];
		ar[i]--;
	}
	for (int i = 0; i < n; i++) {
		if (ar[i] == i) {
			swap(ar[i], ar[i+1]);
			ans++;
		}
	
	}
	cout << ans;


}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

constexpr LL INF = 1LL << 60;

void solve() {
    int n,K;
    cin >> n >> K;
    VLL h(n);
    REP(i,0,n) cin >> h[i];
    VVLL dp(n+1,VLL(n+1, INF));
    dp[0][0] = 0;
    REP(i,0,n) {
        REP(j,0,i+1) {
            REP(k,1,n+1) {
                dp[i+1][k] = min(dp[i+1][k], dp[j][k-1] + max(0LL, h[i] - (j > 0 ? h[j-1] : 0)));
            }
        }
    }
    LL ans = INF;
    REP(i,0,n+1) ans = min(ans, dp[i][n-K]);
    cout << ans << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define N 11116
#define M 111116
#define inf 1111111116
#define next nxt

int n,m,k,a[M],b[M],f[M],next[M],p[N],now[N],d[N],h[N],ans;
char s[N];
queue<int> q;

void add(int x,int y,int z){
	a[++k]=x;b[k]=y;f[k]=z;next[k]=p[x];p[x]=k;
	a[++k]=y;b[k]=x;f[k]=z;next[k]=p[y];p[y]=k;
}

bool travel(){
	fill(d+1,d+n+m+3,inf);d[n+m+1]=0;
	q.push(n+m+1);h[n+m+1]=1;
	memcpy(now,p,sizeof(p));
	while (!q.empty()){
		int x=q.front();q.pop();h[x]=0;
		for (int t=p[x];t;t=next[t])
			if (f[t]&&d[x]+1<d[b[t]]){
				d[b[t]]=d[x]+1;
				if (!h[b[t]]) q.push(b[t]),h[b[t]]=1;
			}
	}
	return d[n+m+2]<inf;
}

int dinic(int x,int lmt){
	if (x==n+m+2) return lmt;int cnt=0;
	for (int t=now[x];t;t=now[x]=next[t])
		if (f[t]&&d[x]<d[b[t]]){
				int tmp=dinic(b[t],min(f[t],lmt-cnt));
				f[t]-=tmp;f[t^1]+=tmp;cnt+=tmp;
				if (cnt==lmt) return lmt;
		}
	return cnt;
}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();m=read();k=1;
	for (int i=1;i<=n;i++){
		scanf(" %s",s+1);
		for (int j=1;j<=m;j++){
			if (s[j]=='o') add(i,n+j,1);
			if (s[j]=='S') add(n+m+1,i,inf),add(n+m+1,n+j,inf);
			if (s[j]=='T') add(n+m+2,i,inf),add(n+m+2,n+j,inf);
		}
	}
	while (travel()) ans+=dinic(n+m+1,inf);
	printf("%d\n",ans<inf?ans:-1);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
#include<climits>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
	ll n;
		vector<int>b;
	vector<int>ans;
	cin >> n;
	ll max = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		b.push_back(a);
	}
	while (1) {
		bool flg = true;
		int q = b.size();
		if (q == 0)break;
		for (int i = q - 1; i >= 0; i--) {
			if (b[i] == i + 1) {
				ans.push_back(i + 1);
				b.erase(b.begin() + i);
				flg = false;
				break;
			}
		}
		if (flg) {
			cout << -1 << endl;
			return 0;
		}
	}
	for (int i = ans.size()-1; i >= 0; i--)cout << ans[i] << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    int K, X;
    cin >> K >> X;
    int start = X - K + 1;
    int end = X + K - 1;
    for(int i = start; i <= end; i++)cout << i << ' ';
    cout << endl;
}


Measured memory_bytes: 3588
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_dedges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B);}
#define in_wedges(M) repp(I, 1, M){int A, B, C; cin >> A >> B >> C; v[A].pb(B, C), v[B].pb(A, C);}
#define in_dwedges(M) repp(I, 1, M){int A, B, C; cin >> A >> B >> C; v[A].pb(B, C);}
#define endl "\n"

const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 18;
const int inf = 2e9;

const int N = 1e5 + 5;
vector<int> v[N];
bool vis[N];
vector<int> sink;

void dfs(int s){
    vis[s] = 1;
    for(auto i: v[s]) if(!vis[i]) dfs(i);
    sink.pb(s);
}
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    int n, m;
    cin >> n >> m;
    in_dedges(m);

    repp(i, 1, n) if(!vis[i]) dfs(i);
    reverse(all(sink));
    vector<int> dis(n + 1, 0);

    for(auto i : sink) for(auto j : v[i]) dis[j] = max(dis[j], dis[i] + 1);
    cout << *max_element(all(dis));
}

ll power(ll x, ll y){ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 11520
n, m, k = map(int, input().split())
mod = 998244353

ans = 0
comb = 1
for i in range(k+1):
  ans += (((m*pow(m-1,n-i-1,mod))%mod)*comb)%mod
  ans %= mod
  comb *= (n-1-i)
  comb %= mod
  comb *= pow(i+1, mod-2, mod)
  comb %= mod

print(ans)

Measured memory_bytes: 9212
while True:
    a, op, b = input().split()
    a, b = map(int, [a, b])
    if op == "?":
        break
    else:
        if op == "+":
            r = a + b
        elif op == "-":
            r = a - b
        elif op == "*":
            r = a * b
        elif op == "/":
            r = a // b
        print(r)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  int h, w;
  cin >> h >> w;
  vector<vector<int>> a(h);
  REP(i, h)
  {
    REP(j, w)
    {
      int aa;
      cin >> aa;
      a[i].push_back(aa);
    }
  }

  vector<pair<pair<int, int>, pair<int, int>>> ans;

  REP(i, h)
  {
    REP(j, w)
    {
      if (j == w - 1)
      {
        if (i == h - 1)
        {
          continue;
        }
        if (a[i][j] % 2 == 1)
        {
          ans.push_back(make_pair(make_pair(i, j), make_pair(i + 1, j)));
          a[i][j]--;
          a[i + 1][j]++;
        }
      }
      if (a[i][j] % 2 == 1)
      {
        ans.push_back(make_pair(make_pair(i, j), make_pair(i, j + 1)));
        a[i][j]--;
        a[i][j + 1]++;
      }
    }
  }
  cout << ans.size() << endl;
  for (auto v : ans)
  {
    cout << v.first.first + 1 << " " << v.first.second + 1 << " " << v.second.first + 1 << " " << v.second.second + 1 << endl;
  }
}


Measured memory_bytes: 5232
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace A_ABC146
{
    class MainClass
    {

        //static int[] s;

        public static void Main(string[] args)
        {
            //       s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            string st = ReadLine();
            //            は SUN, MON, TUE, WED, THU, FRI, SAT
            if (st == "SUN") WriteLine(7);
            else if (st == "MON") WriteLine(6);
            else if (st == "TUE") WriteLine(5);
            else if (st == "WED") WriteLine(4);
            else if (st == "THU") WriteLine(3);
            else if (st == "FRI") WriteLine(2);
            else if (st == "SAT") WriteLine(1);
            else return;
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
int a[maxn];
int n;
int main(){
	scanf("%d",&n);
	int sum = 0;
	for(int i = 1;i <= n;++i){scanf("%d",&a[i]);sum += abs(a[i] - a[i - 1]);}
	sum += abs(a[n]);
	for(int i = 1;i <= n;++i){
		printf("%d\n",sum - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]));
	}
	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define lnt long long int
int main()
{
    lnt n,m1;
    cin>>n>>m1;
    vector<lnt> m[n+1];

    for(int i=0;i<m1;i++)
    {
        lnt u,v;
        cin>>u>>v;

        m[u].push_back(v);
    }

    lnt s,t;
    cin>>s>>t;
    queue<lnt> q;
    q.push(s);
    lnt dis[n+1]={0};
    lnt visited[n+1]={0};
    visited[s]=1;
    while(!q.empty())
    {
        int curr = q.front();
        if(curr==t)
        {
            lnt ans = dis[curr];
            cout<<ans;
            return 0;
        }
        q.pop();
        int l1 = m[curr].size();
        for(int i=0;i<l1;i++)
        {
            int node = m[curr][i];
            int l2 = m[node].size();
            for(int j=0;j<l2;j++)
            {
                int node1 = m[node][j];
                int l3 = m[node1].size();
                for(int h=0;h<l3;h++)
                {
                    int node2 = m[node1][h];
                    if(visited[node2]==0)
                    {
                        if(node2==t)
                        {
                            cout<<dis[curr]+1;
                            return 0;
                        }
                        dis[node2]=dis[curr]+1;
                        visited[node2]=1;
                        q.push(node2);
                    }
                }
            }

        }
    }
    cout<<-1;


}



Measured memory_bytes: 7296
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
    string S;
    cin >> S;
    bool hflag = false, iflag = false;
    string ans = "Yes";
    stack<char> hi_stack;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'h') {
            if ((i < S.length() - 1) && S[i + 1] == 'i') {
                i++;
                continue;
            } else {
                ans = "No";
                break;
            }
        } else {
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main () {


    long long n, x, res = 0;
    cin >> n >> x;

    long long nums[100005];
    
    for (int i = 1; i <= n; i++) cin >> nums[i];

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

        if (nums[i-1] + nums[i] > x) {

            long long temp = nums[i-1] + nums[i];
            long long rem = temp - x;

            nums[i] -= rem;
            res += rem;

        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define PQ priority_queue
#define pb push_back
#define fu(i,a,j) for(int i=a;i<j;i++)
#define fd(i,a,j) for(int i=a;i>=j;i--)
#define SYNC ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define MOD 1000000007 
#define MOD2 1000000021
#define MAXN 2000000
#define INF 1e9
using namespace std;

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

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

ll m_pow(ll a, ll b, ll M = MOD) { ll res = 1; for (; b; b >>= 1, a = (a * a) % M)if (b & 1)res = (res * a) % M; return res; }
ll gcd(ll a, ll b) { if (a < b) swap(a, b); for (; b; a %= b, swap(a, b)); return a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };
db dis(pii a, pii b) { return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); }
int dr[] = { 0, 1, 0, -1, 1,1,-1,-1 };
int dc[] = { 1, 0, -1, 0, 1,-1,1,-1 };

int n, m, k, t;

string ansok[2] = { "NO","YES" };

int a[1000005];
int main()
{
	SYNC;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	bool ok = 1;
	//모든 i에 대해서 gcd==1 이면 pairwise coprime
	//gcd(a1~an) == 1 인데 위가 아니면 setwise coprime
	//둘다 아니면 not coprime
	//모든 수의 공약수가 1이려면 다 해보면 됨
	//페어가 다 1이려면 모두 소수? 
	//
	set<int> st;
	for (int i = 0; i < n; i++) {
		if (a[i] == 1) continue;
		if (st.count(a[i])) {
			ok = 0;
			break;
		}
		st.insert(a[i]);
		for (int j = 2; j * j <= a[i]; j++) {
			if (a[i] % j == 0) {
				if (st.count(j)) {
					ok = 0;
					break;
				}
				st.insert(j);
				if (a[i] / j != j) {
					if (st.count(a[i] / j)) {
						ok = 0;
						break;
					}
					st.insert(a[i]/j);
				}
			}
		}
		if (!ok)
			break;
	}

	if (ok) {
		cout << "pairwise coprime\n";
		return 0;
	}

	int g = a[0];
	for (int i = 1; i < n; i++) {
		g = gcd(g, a[i]);
	}

	if (g == 1) {
		cout << "setwise coprime\n";
	}
	else {
		cout << "not coprime\n";
	}
	return 0;
}

Measured memory_bytes: 7616
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
  int n;
  cin>>n;
  ll mod=1000000007;
  ll all=1;
  ll f=1;
  ll two=1;
  for(int i=0;i<n;i++){
    all*=10;
    all%=mod;
    f*=8;
    f%=mod;
    two*=9;
    two%=mod;
  }
  ll ans=all+f-2*two;
  for(int i=0;i<3;i++){
  if(ans<0)
    ans+=mod;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636