akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true) {
			int n = sc.nextInt();/* 太郎の手札の枚数 */
			int m = sc.nextInt();/* 花子の手札の枚数 */
			if(n == 0) break;

			/* それぞれの手札 */
			int[] taro = new int[n], hanako = new int[m];
			/* それぞれの合計 */
			int taro_sum = 0, hanako_sum = 0;
			for(int i = 0; i < n; i++) {
				taro[i] = sc.nextInt();
				taro_sum += taro[i];
			}
			for(int i = 0; i < m ; i++) {
				hanako[i] = sc.nextInt();
				hanako_sum += hanako[i];
			}
			
			int diff = taro_sum - hanako_sum;
			
			boolean _break = false;
			if(diff == 0) {
				for(int i = 0; i < n; i++) {
					for(int j = 0; j < m; j++) {
						if(taro[i] == hanako[j]) {
							System.out.println(taro[i] + " " + hanako[j]);
							_break = true;
							break;
						}
					}
					if(_break) break;
				}
			}else {
				for(int i = 0; i < n; i++) {
					for(int j = 0; j < m; j++) {
						int d = (taro[i] - hanako[j]) * 2;
						if(diff == d) {
							System.out.println(taro[i] + " " + hanako[j]);
							_break = true;
							break;
						}
					}
					if(_break) break;
				}
			}
			if(!_break) System.out.println("-1");
		}
	}
}



Measured memory_bytes: 29328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

bool ok(ll W,ll H,ll x,ll y){
    return 0<=x&&x<=W&&0<=y&&y<=H;
}
void solve(){
    ll W,H,x,y,r;cin>>W>>H>>x>>y>>r;
    if(ok(W,H,x+r,y)&&ok(W,H,x-r,y)&&ok(W,H,x,y+r)&&ok(W,H,x,y-r))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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



Measured memory_bytes: 3204
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,ans=0;
    cin>>n;
    map<int,int> s;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        s[a-1]++;
    }
    for(auto x:s){
        if(x.second%2==1)ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 4864
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int get_score(ll* men){
	int score=0;

	ll tmp = *men;
	tmp >>= 3;
	while(tmp > 0){
		if(tmp | 1){
			score++;
		}
		tmp >>= 1;
	}
	*men = *men & ((1<<3) - 1);

	return score;
}

int main(){

	string str;
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;

		string str;
		ll men=0;
		int c=0;
		int score=0;
		while(cin >> str){
			if(str == "OUT"){
				c++;
			}
			else if(str == "HIT"){
				men <<= 1;
				men |= 1;

				score += get_score(&men);
			}
			else if(str == "HOMERUN"){
				men <<= 1;
				men |= 1;
				men <<= 3;

				score += get_score(&men);
			}

			if(c==3){
				cout << score << endl;
				c=0;
				score=0;
				men=0;
			}
		}
	}
}

Measured memory_bytes: 0
# 初期入力
import sys
from collections import Counter
input = sys.stdin.readline
N,K = (int(x) for x in input().split())
d=[-1]*K
#A=[[0]for i in range(K)]
A=[] #菓子持ってる人
#hito_kasi ={i:set for i in range(K)}
for i in range(K):
    d[i] = int(input())
    A.extend(list(map(int, input().split())))
    
#
hito_kasi   =Counter(A)
hito_all    =set(i for i in range(1,N+1))
kasi_motteru= set(hito_kasi.keys())
ans         =hito_all - kasi_motteru
print(len(ans))

Measured memory_bytes: 9484
#include <iostream>
#include <vector>
#include <stack>
#include <string>
#include <cctype>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
  long long n,ans,i,j;
  cin >> n;
  long long r = sqrt(n) + 1;
  for(r = r; 0 <= r; r--){
    if(n % r == 0){
      i = r;
      j = n / r;
      break;
    }
  }
  ans = i + j - 2;
  cout << ans;
}


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

#define ran 101101

int n, m;
vector<int> e[ran];
int S, T;
int d[ran][3];
int q[ran*2*3], l, r;

void upd(int pos, int rem, int val) {
	if(d[pos][rem]>=0) return;
	d[pos][rem] = val;
	q[r++] = pos;
	q[r++] = rem;
}

int main() {
	scanf("%d%d", &n, &m);
	for(int i=0;i<m;i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		e[x].push_back(y);
	}
	scanf("%d%d", &S, &T);
	
	memset(d, -1, sizeof d);
	l = r = 0;
	upd(S, 0, 0);
	while(l<r) {
		int cur = q[l++];
		int rem = q[l++];
		for(int i=0;i<(int)e[cur].size();i++) {
			int nxt = e[cur][i];
			upd(nxt, (rem+1)%3, d[cur][rem]+1);
		}
	}
	if(d[T][0]==-1) puts("-1");
	else printf("%d\n", d[T][0]/3);
	
	return 0;
}

Measured memory_bytes: 9344
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0 ; i < n ; i++ ){
            a[i] = sc.nextInt();
        }
        sc.close();
        for(int i = 0 ; i < n - k ; i++ ){
            if(a[i] < a[i + k]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }
    }
}


Measured memory_bytes: 60436
#include <bits/stdc++.h>
using namespace std;
int main ()
{
	long long int arr[6],var;
    for (int i=1;i<=5;i++)
    {
    	cin>>arr[i];
    }
    for (int i=1;i<=5;i++)
    {
    	if (arr[i]==0)
        {
        	var=i;
            break;
        }
     }
     cout<<var;
     return 0;
}
        
        
    
    

Measured memory_bytes: 3596
def main():
    x = int(input())
    gojo = [int(i**5) for i in range(-1100, 1100)]
    for i, v1 in enumerate(gojo):
        x1 = i - 1100
        for j, v2 in enumerate(gojo):
            x2 = j - 1100
            if v1 - v2 == x:
                print(x1, x2)
                return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9220
import heapq

x, y, a, b, c = map(int, input().split())
p = [int(s) for s in input().split()]
q = [int(s) for s in input().split()]
r = [int(s) for s in input().split()]

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

que = []
for i in range(x):
    heapq.heappush(que, p[i])

for i in range(y):
    heapq.heappush(que, q[i])

for i in range(c):
    if que[0] > r[i]:
        break
    heapq.heappop(que)
    heapq.heappush(que, r[i])

print(sum(que))


Measured memory_bytes: 23528
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	ps := ReadFloats(N)

	dp := make([][]float64, N+1)
	for i, _ := range dp {
		dp[i] = make([]float64, N+1)
	}

	dp[0][0] = 1
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			dp[i+1][j+1] += dp[i][j] * ps[i]
			dp[i+1][j] += dp[i][j] * (1 - ps[i])
		}
	}
	fmt.Println(Sum(dp[N][N/2+1:]...))
}

func Sum(slice ...float64) float64 {
	sum := .0
	for _, v := range slice {
		sum += v
	}
	return sum
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadFloats(n int) []float64 {
	v := make([]float64, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 76928
# include<stdio.h>

int main(void){
  int n;
  scanf("%d", &n);
  int i;
  int a[n];
  int sum = 0;
  for(i=0;i<n;i++){
    scanf("%d", &a[i]);
  }
  sum = a[0];
  for(i=1;i<n;i++){
    sum = sum^a[i];
  }
  if(sum == 0){
    printf("Yes");
  }else{
    printf("No");
  }
}

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

int main(){
	int N, M, Q;
	cin >> N >> M >> Q;
	vector <vector<int>> x(N,vector<int>(N,0));	//区間(l,r)を動く列車の数
	vector <vector<int>> c(N,vector<int>(N+1,0));	//累積和
	//prepare x
	for (int i = 0; i < M; i++){
		int l, r;
		cin >> l >> r;
		x[l-1][r-1]++;
	}
	//prepare c
	for (int i = 0; i < N; i++){
		c[i][0] = 0;
		for (int j = 1; j < N+1; j++){
			c[i][j] = c[i][j-1] + x[i][j-1];
		}
	}
	//各クエリ(p,q)に対するansを出力
	for (int i = 0; i < Q; i++){
		int p, q;
		int ans = 0;
		cin >> p >> q;
		for (int j = p; j <= q; j++){
			ans = ans + c[j-1][q] - c[j-1][p-1];
		}
		cout << ans << endl;
	}
	return 0;
} 

Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long M = sc.nextLong();
		if (Math.abs(N-M)>1) {
			System.out.println(0);
			return ;
		}

		if (M>N) {
			long temp =N;
			N = M;
			M = temp;
		}
		long sum = 1;
		for (int i=0;i<N;i++) {
			sum = (sum *(N-i))%1000000007;
			if (M-i>0) {
				sum = (sum *(M-i))%1000000007;
			}
		}
		if (N==M) {
			sum = (sum*2)%1000000007;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int ctoi(const char c){
	if('0' <= c && c <= '9') return (c-'0');
	return -1;
}

int main(){
  string N;
  cin >> N;
  int sum = 0;
  for(int i=0; i<N.length(); ++i){
    sum += ctoi(N[i]) % 9;
  }
  if(sum%9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3728
#include<stdio.h>
#include<math.h>

struct Point{
  double x, y;
};

void Koch(int n, Point a, Point b){
  if(n == 0) return;

  Point s, t, u;
  double TH=M_PI*60.0/180.0;

  s.x=(2.0*a.x+1.0*b.x)/3.0;
  s.y=(2.0*a.y+1.0*b.y)/3.0;

  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*b.y)/3.0;

  u.x=(t.x-s.x)*cos(TH)-(t.y-s.y)*sin(TH)+s.x;
  u.y=(t.x-s.x)*sin(TH)+(t.y-s.y)*cos(TH)+s.y;

  Koch(n-1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  Koch(n-1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  Koch(n-1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  Koch(n-1, t, b);
}

int main(){
  Point a, b;
  int n;
  scanf("%d", &n);

  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;

  printf("%.8f %.8f\n", a.x, a.y);
  Koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);

  return 0;
}



Measured memory_bytes: 2716
#include <bits/stdc++.h>
#define ll long long

using namespace std;


int main() {
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    int a;
    cin>>a;
    vector<int>vec(a);
    for(int &x:vec)
        cin>>x;
    ll ans=(ll)1e18;
    for(int i=-100;i<=100;i++){
        ll s=0;
        for(int x:vec){
            s+=pow((x-i),2);
        }
        ans=min(ans,s);
    }
    cout<<ans;
}

Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
int n,m,mod;
int dp[311][311];
int C[311][311];
int pre[311][311];
void upd(int &x,int v){x=(x+v)%mod;}
int main()
{
	cin>>n>>m>>mod;
	for(int i=0;i<=300;i++)dp[0][i]=1,pre[0][i]=i+1;
	for(int i=1;i<=300;i++)dp[i][0]=0;
	for(int i=0;i<=300;i++)
	{
		C[i][0]=C[i][i]=1;
		for(int j=1;j<i;j++)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	for(int i=1;i<=300;i++)
	{
		for(int j=1;j<=300;j++)
		{
			for(int k=1;k<=i;k++)
			{
				upd(dp[i][j],1ll*dp[i-k][j]*pre[k-1][j-1]%mod*C[i-1][k-1]%mod);
			}
			pre[i][j]=(pre[i][j-1]+dp[i][j])%mod;
		}
	}
	cout<<dp[n][m]<<endl;
	return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
int main(){

		char s[11]={0};
		scanf("%s",s);

		if(s[0]=='A'&&s[1]!='C'&&s[strlen(s)-1]!='C'){
				int i=0;
				int count=0;
				//puts("OK1");
				for(i=1;i<strlen(s);i++){
						if(s[i]=='C'){
								count++;
				//				puts("OK2");
						}
						if(count>=2){
				//				puts("OK3");
								break;
						}
						if(('A'<=s[i]&&s[i]<='B')||('D'<=s[i]&&s[i]<='Z'))
						{
				//				puts("OK4");
								break;
						}
				}
				/*
				if(i<strlen(s)-1)puts("OK6");
				if(i>strlen(s)-1)puts("OK7");*/
				if(i==strlen(s)&&count==1){
				//		puts("OK5");
						puts("AC");
						return 0;
				}
		}

		puts("WA");
		return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n = sc.nextInt();
		int[] x=new int[n];
		int[] y=new int[n+1];
		for(int i=0;i<n;i++){
			x[i] = sc.nextInt();
			y[x[i]] = i+1;
		}
		for(int i=1;i<=n;i++)
			System.out.print(y[i]+" ");
	}
}


Measured memory_bytes: 51712
a = list(map(int, input().split()))
b = []
for i in range(a[2]):
    if a[0] <= (a[0] + i) <= a[1]:
        b.append(a[0] + i)
for i in range(a[2]):
    if (a[1] - i) not in b and a[0] <= (a[1] - i) <= a[1]:
        b.append(a[1] - i)
b.sort()
for i in range(len(b)):
    print(b[i])

Measured memory_bytes: 3064
/*
* Author : MaxSally
*/
/********   All Required Header Files ********/
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i <= k ; ++i)
#define rrep(i, j, k) for (int i = j; i >= k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
#define inf (int) (1e9 + 7)
#define epsi 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 998244353
#define read(type) readInt<type>()
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define left tuyiuoi
#define right fgjhk
#define ss second
#define ff first
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) rep(i, l, r) cout << a[i] << " "; cout << endl
#define Flag(n) cout << "here " << n << endl
const double pi=acos(-1.0);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

const int N = 200005;
ll a[N], fact[N], invFactorial[N];
ll n, m, k;

ll fastMultiplication(ll a, int b){
    ll ans = 1;
    while(b > 0){
        if(b & 1){
            ans = (ans * a) % mod;
        }
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

int main(){
    io;
   // freopen("input.txt", "r", stdin);
    cin  >> n >> m >> k;
    fact[0] = 1;
    invFactorial[0] = 1;
    rep(i, 1, n){
        fact[i] = (fact[i - 1] * i) % mod;
        invFactorial[i] = fastMultiplication(fact[i], mod - 2);
    }
    ll ans = 0;
    rep(i, 0, k){
        ll C = (((fact[n - 1] * invFactorial[i]) % mod) * invFactorial[n - 1 - i]) % mod;
        ans = (ans + (((C * m) % mod) * fastMultiplication(m - 1, n - 1 - i)) % mod) % mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 6760
#include<cstdio>
inline int read(){
	char ch=getchar();
	int o=0;
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9'){
		o=(o<<3)+(o<<1)+(ch^48);
		ch=getchar();
	}
	return o;
}
inline void write(int x){
	if(x>9)write(x/10);
	putchar(x%10^48);
}
int n;
int main(){
	n=read();
	write(n*n*n);
}

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

    bool flag = false;

    rep(i, S.size()) {
        repd(j, i, S.size()) {
            string tmp = "";
            rep(k, i) {
                tmp += S[k];
            }
            repd(k, j + 1, S.size()) {
                tmp += S[k];
            }
            if (tmp == "keyence") {
                flag = true;
                break;
            }
        }
        if (flag) break;
    }
    if (S == "keyence") flag = true;

    if (flag) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

using ll = long long;
const int MOD = 998244353;

ll powmod(ll a, ll b) {
  a %= MOD;
  ll res = 1;
  while (b > 0) {
    if (b % 2 == 1) res = res * a % MOD;
    a = a * a % MOD;
    b /= 2;
  }
  return res;
}
ll f[200005];
void cominit() {
  f[0] = 1;
  for (int i = 0; i < 200000; i++) f[i + 1] = f[i] * (i + 1) % MOD;
}

ll nCr(int n, int r) {
  if (n < r) return 0;
  if (n < 0 or r < 0) return 0;
  return f[n] * powmod(f[r] * f[n - r], MOD - 2) % MOD;
}

int main() {
  ll n, m, k;
  cin >> n >> m >> k;
  cominit();
  ll ans = 0;
  for (int i = 0; i < k + 1; i++) {
    ll res = nCr(n - 1, i);
    res *= m * powmod(m - 1, n - i - 1) % MOD;
    res %= MOD;
    ans = (ans + res) % MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 5196
const p = 1000000007;
var
  a: array [1..300000] of int64;
  n, i, j, s, ans: longint;
function add(x, y: longint): longint; inline;
begin
  inc(x, y);
  if x >= p then dec(x, p);
  exit(x);
end;
function mul(x, y: longint): longint; inline;
begin
  exit(int64(x) * y mod p);
end;
begin
  read(n);
  for i := 1 to n do read(a[i]);
  for i := 0 to 59 do
  begin
    s := 0;
    for j := 1 to n do inc(s, (a[j] shr i) and 1);
    ans := add(ans, mul(mul(s, n - s), int64(1) shl i mod p));
  end;
  writeln(ans);
end.


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

typedef long long ll;

const int MAX_N = 1e5 + 5;;
int n, m, ans;
bool red[MAX_N];
int cnt[MAX_N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m;
	red[0] = true;
	for (int i = 0; i < n; i++)
		cnt[i] = 1;

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

		cnt[v]--;
		cnt[u]++;
		if (red[v] == false)
			continue;

		red[u] = true;
		if (cnt[v] == 0)
			red[v] = false;
	}

	for (int i = 0; i < n; i++)
		ans += red[i];

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

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int n,k;
ll a[1100];
vector<ll> v;
ll ans;

void f(int m){
  if(m<0) return;
  int res=0;
  ans+= 1LL<<m;
  for(auto u:v){
    if((ans&u)==ans)
      res++;
  }
  if(res<k) ans-=1LL<<m;
  f(m-1);
}

int main(){
  cin>>n>>k;
  FOR(i,1,n+1){
    cin>>a[i];
    a[i]+=a[i-1];
  }

  FOR(i,1,n+1){
    rep(j,i){
      v.PB(a[i]-a[j]);
    }
  }

  f(40);
  cout<<ans<<endl;
}


Measured memory_bytes: 6384
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
using namespace std;

int main(void){
    int n;
    int s[200005];
    long long int sum[200005];
    scanf("%d",&n);
    for(int i=0; i<n; i++){
        scanf("%d",&s[i]);
    }
    for(int i=1; i<=n; i++){
        sum[i]=sum[i-1]+s[i-1];
    }
    map<long long int,long long int> m;
    long long int ans=0;
    for(int i=0; i<=n; i++){
        ans+=m[sum[i]];
        m[sum[i]]++;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 15104
#include<stdio.h>

int main() {
  int N, M, K, A, cnt = 0;
  int x[30] = {};
  scanf("%d %d", &N, &M);
  for(int i = 0; i < N; i++) {
    scanf("%d", &K);
    for(int j = 0; j < K; j++) {
      scanf("%d", &A);
      x[A-1]++;
    }
  }
  
  for(int i = 0; i < M; i++) {
    if(x[i] == N) {
      cnt++;
    }
  }
  printf("%d\n", cnt);
}
      

Measured memory_bytes: 128
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  ll n,m;
  cin >> n >> m;
  vector<pair<ll, ll>> value(n);
  rep(i, n){
    ll a,b;
    cin >> a >> b;
    value[i] = make_pair(a, b);
  }
  sort(value.begin(), value.end());
  ll drink = 0, ans = 0;
  for(ll i = 0; i < n; i++){
    if(drink < m){
      ll num = value[i].second;
      num = min(m - drink, num);
      ans += value[i].first * num;
      drink += num;
    }else break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll x[200010],y[200010];
int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n){
		ll a,b;
		scanf("%lld%lld",&a,&b);
		x[i]=a+b;
		y[i]=a-b;
	}
	sortup(x,n);
	sortup(y,n);
	printf("%lld",max(x[n-1]-x[0],y[n-1]-y[0]));
}

Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int,int>;

const int mx = 3e5+5;

int lazy[mx<<2], t[mx<<2];

void updateLazy(int p, int l, int r){
    t[p] = max(t[p], lazy[p]);
    if(l != r){
        lazy[p<<1] = max(lazy[p<<1], lazy[p]);
        lazy[p<<1|1] = max(lazy[p<<1|1], lazy[p]);
    }lazy[p] = 0;
}

int query(int p, int l, int r, int idx){
    if(lazy[p]) updateLazy(p, l, r);
    if(l>r) return 0;
    if(l == r) return t[p];
    int m = (l + r)/2;
    if(idx <= m)
        return query(p<<1, l, m, idx);
    return query(p<<1|1, m+1, r, idx);
}

void update(int p, int l, int r, int i, int j, int v){
    if(lazy[p]) updateLazy(p, l, r);
    if(l>r || l>j || r<i) return;
    if(l>=i && r<=j){
        lazy[p] = v;
        updateLazy(p, l, r);
        return;
    }
    int m = (l+r)/2;
    update(p<<1, l, m, i, j, v);
    update(p<<1|1, m+1, r, i, j, v);
    t[p] = max(t[p<<1], t[p<<1|1]);
}

int main(){

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

    int n, k; cin >> n >> k;

    int u, v, ans=0;
    for(int i=0; i<n; i++){
        int x; cin >> x;
        u=max(0,x-k); v=min(mx-1, x+k);
        int y = 1+query(1, 0, mx-1, x);
        update(1, 0, mx-1, u, v, y);
        ans = max(ans, y);
    }cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 11780
#include<iostream>
#include<iomanip>
#define pi 3.141592653589793238

using namespace std;


int main() {

	double a = 0;
	double l = 0;
	double s = 0;

	cin >> a;

	l = 2 * pi * a;
	s = a * a * pi;

	cout << fixed;
	cout << setprecision(1000);

	cout << s << " " << l << endl;

	return 0;
}


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

int main(){
	int a,b;
	cin >> a >> b;

	if((a + b) % 2 == 0){
		cout << (a+b)/2 << endl;
	}else{
		cout << (a + b + 1)/2 << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int N;
  int simen[1000];
  int i, j;
  int value, newValue;
  int data1[1000000], data2[1000000];

  for(i = 0; i < 1000; i++) {
    simen[i] = i*(i+1)*(i+2)/6;
  }

  data1[0] = 0;
  for(i = 1; i < 1000000; i++) {
    data1[i] = 999999;
    for(j = 1; j <= i; j++) {
      if(simen[j] > i) break;
      newValue = data1[i-simen[j]]+1;
      if(newValue < data1[i]) data1[i] = newValue;
    }
  }

  data2[0] = 0;
  for(i = 1; i < 1000000; i++) {
    data2[i] = 999999;
    for(j = 1; j <= i; j++) {
      if(simen[j] > i) break;
      if(simen[j] % 2 == 0) continue;
      newValue = data2[i-simen[j]]+1;
      if(newValue < data2[i]) data2[i] = newValue;
    }
  }

  while(1) {
    scanf("%d", &N);
    if(N == 0) break;
    printf("%d %d\n", data1[N], data2[N]);
  }
  return 0;
}

Measured memory_bytes: 8028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n,k;
  cin >> n >> k;
  vec a(n);
  for(ll i=0;i<n;i++) cin >> a[i];
  sort(a.begin(),a.end());
  ll ok=n,ng=-1;
  while(ng+1<ok) {
    ll m=(ok+ng)/2;
    mat dp(n+1,vec(k));
    dp[0][0]=1;
    for(ll i=0;i<n;i++) {
      for(ll j=0;j<k;j++) {
        dp[i+1][j]|=dp[i][j];
        if(i!=m&&j+a[i]<k) {
          dp[i+1][j+a[i]]|=dp[i][j];
        }
      }
    }
    ll f=0;
    for(ll i=max(k-a[m],0LL);i<k;i++) {
      if(dp[n][i]) f=1;
    }
    if(f) ok=m;
    else ng=m;
  }
  cout << ng+1 << endl;
}

Measured memory_bytes: 198736
#include<map>
#include<cstdio>
#include<string>
#include<vector>
#include<numeric>
#include<iostream>
#include<algorithm>

#define	pb			push_back
#define	rep(i,n)	for(int i=0;i<n;i++)

using namespace std;

typedef	vector<int>	vi;

struct Data{
	int id_dlr,val,t;
	Data(){}
	Data(int ID,int V,int T):id_dlr(ID),val(V),t(T){}
	bool isSameDealer(const Data &d){ return id_dlr==d.id_dlr; }
};

bool lt(const Data &d1,const Data &d2){
	if(d1.val!=d2.val)	return d1.val<d2.val;
	return d1.t<d2.t;
}

bool gt(const Data &d1,const Data &d2){
	if(d1.val!=d2.val)	return d1.val>d2.val;
	return d1.t<d2.t;
}

int n_dlr,n_itm;
vector<Data> lst_sell[1000],lst_buy[1000];
vi itm_hist[1000];
int dlr_sell[1000],dlr_buy[1000];

void deal(int id_itm){
	rep(i,lst_sell[id_itm].size()){
		Data a=lst_sell[id_itm][i];
		rep(j,lst_buy[id_itm].size()){
			Data b=lst_buy[id_itm][j];
			if(!a.isSameDealer(b) && a.val<=b.val){
				int val=(a.val+b.val)/2;
				dlr_sell[a.id_dlr]+=val;
				dlr_buy[b.id_dlr]+=val;
				itm_hist[id_itm].pb(val);
				lst_sell[id_itm].erase(lst_sell[id_itm].begin()+i);
				lst_buy[id_itm].erase(lst_buy[id_itm].begin()+j);
				return;
			}
		}
	}
}

int main(){
	for(int n;cin>>n,n;){
		n_dlr=0,n_itm=0;
		rep(i,n){
			lst_sell[i].clear(),lst_buy[i].clear();
			itm_hist[i].clear();
			dlr_sell[i]=dlr_buy[i]=0;
		}

		map<string,int> f_dlr,f_itm;
		string f_dlr_inv[1000],f_itm_inv[1000];
		rep(i,n){
			string dlr,type,itm;
			int val;	cin>>dlr>>type>>itm>>val;

			if(f_dlr.count(dlr)==0)	f_dlr_inv[n_dlr]=dlr,f_dlr[dlr]=n_dlr++;
			if(f_itm.count(itm)==0)	f_itm_inv[n_itm]=itm,f_itm[itm]=n_itm++;
			int id_dlr=f_dlr[dlr],id_itm=f_itm[itm];

			if(type=="SELL"){
				lst_sell[id_itm].pb(Data(id_dlr,val,i));
				sort(lst_sell[id_itm].begin(),lst_sell[id_itm].end(),lt);
			}
			else{	// BUY
				lst_buy[id_itm].pb(Data(id_dlr,val,i));
				sort(lst_buy[id_itm].begin(),lst_buy[id_itm].end(),gt);
			}
			deal(id_itm);
		}

		vector<string> ans;
		rep(i,n_itm)if(!itm_hist[i].empty()){
			int vmin=*min_element(itm_hist[i].begin(),itm_hist[i].end());
			int vmax=*max_element(itm_hist[i].begin(),itm_hist[i].end());
			int vavg=accumulate(itm_hist[i].begin(),itm_hist[i].end(),0)/itm_hist[i].size();
			char s[128];	sprintf(s,"%s %d %d %d",f_itm_inv[i].c_str(),vmin,vavg,vmax);
			ans.pb(s);
		}
		sort(ans.begin(),ans.end());
		rep(i,ans.size())	cout<<ans[i]<<endl;
		cout<<"--"<<endl;

		ans.clear();
		rep(i,n_dlr){
			char s[128];	sprintf(s,"%s %d %d",f_dlr_inv[i].c_str(),dlr_buy[i],dlr_sell[i]);
			ans.pb(s);
		}
		sort(ans.begin(),ans.end());
		rep(i,ans.size())	cout<<ans[i]<<endl;
		cout<<"----------"<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 30
#define LLINF LLONG_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}
ll power(ll x,ll n){ll a=1;REP(i,n)a*=x;return a;}

int N;

int main()
{
  cin >> N;
  vector<ll> T(N,0);
  vector<ll> A(N,0);
  REP(i,N) cin >> T[i];
  REP(i,N) cin >> A[i];
  ll mh = max(T[N-1],A[0]);
  REP(i,N)
  {
    if(mh != max(T[i],A[i]))
    {
      cout << 0 << endl;
      return 0;
    }
  }
  bool f = true;
  REP(i,N)
  {
    if(T[i]== mh && A[i] == mh) f = false;
  }
  if(f)
  {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 1;
  ll pre = 0;
  REP(i,N-1)
  {
    if(T[i]>pre)
    {
      pre = T[i];
      continue;
    }
    if(A[i]==A[i+1]) ans = (ans*min(T[i],A[i]))%MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>

using namespace std;

int top = 0;
int arr[200];

void push(int x){
  top++;
  arr[top] = x;
}

int pop(){
  top--;
  return arr[top + 1];
}

int main(){
  char x[10];
  int a, b;

  while(scanf("%s", x) != EOF){
    if(x[0] == '+'){
      a = pop();
      b = pop();
      push(a + b);
    }else if(x[0] == '-'){
      a = pop();
      b = pop();
      push(b - a);
    }else if(x[0] == '*'){
      a = pop();
      b = pop();
      push(a * b);
    }else{
      push(atoi(x));
    }
  }

  cout << pop() << endl;

  return 0;
}



Measured memory_bytes: 3244
M=10**9+7
def d(x,y) x.zip(y).reduce(0){|s,(a,b)|s+a*b} end
def mul(x,y)
	y=y.transpose
	[[d(x[0],y[0])%M,d(x[0],y[1])%M],[d(x[1],y[0])%M,d(x[1],y[1])%M]]
end
h,w,k=gets.split.map(&:to_i)
k-=1
m=$<.map{|e|e.chomp.chars};mt=m.transpose
c=m.count{|s|s[0]=='#'&&s[-1]=='#'}
d=mt.count{|s|s[0]=='#'&&s[-1]=='#'}
if d>0
	(p 1;exit) if c>0
	c,m,w=d,mt,h
end
a=b=0
m.each{|s|w.times{|i|
	a+=1 if s[i]=='#'
	b+=1 if i<w-1&&s[i]=='#'&&s[i+1]=='#'
}}
b=0 if c==0&&d==0
e=[[1,0],[0,1]]
m=[[a,-b],[0,c]]
while k>0
	e=mul(e,m) if k%2>0
	m=mul(m,m)
	k/=2
end
p (e[0][0]+e[0][1])%M

Measured memory_bytes: 89212
#include<stdio.h>
int main(){
	int n,x,t,c=0;
	scanf("%d%d%d",&n,&x,&t);
	while(n>x){
		n=n-x;
		c++;
	}
	c=c+1;
	int ans=c*t;
	printf("%d",ans);
}

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

int main(){
  int N,M;
  cin>>N>>M;
  vector<string> A(N),B(M);
  for(string &s:A)
    cin>>s;
  for(string &s:B)
    cin>>s;
  for(int i=0;i<N-M+1;i++){
    for(int j=0;j<N-M+1;j++){
      bool bo=false;
      for(int k=0;k<M;k++){
        for(int l=0;l<M;l++)
          if(A[i+k][j+l]!=B[k][l]){
            bo=true;
            break;
          }
        if(bo)
          break;
      }
      if(bo)
        continue;
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

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

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;

// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
// bool debug=false;

/*---------------------------------------------------*/

int main() {
    const int MAX = 2000001;
    int T, D, L;
    while(1) {
        cin >> T >> D >> L;
        if(T == 0 && D == 0 && L == 0) break;

        int x, p = 0;
        int ans = 0;
        for(int i = 0; i < T - 1; i++) {
            cin >> x;
            if(L <= x) p = D;
            p--;
            if(0 <= p) ans++;
        }
        cin >> x;
        cout << ans << endl;
    }
}



Measured memory_bytes: 3124
#include <bits/stdc++.h> 
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-6
using namespace std;
typedef long long ll;
const int mods = 998244353;
const int maxn = 2e3+10;

ll n,k;

inline long long read() {
    long long tmp=0, fh=1; char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') fh=-1; c=getchar();}
    while (c>='0'&&c<='9') tmp=tmp*10+c-48, c=getchar();
    return tmp*fh;
}

int main() {
	cin>>n>>k;
	if(k!=n) cout<<"No"<<endl;
	else cout<<"Yes"<<endl; 
}

Measured memory_bytes: 256
n = int(input())
Sum = 0.5 * n * (1 + n)
# n < 3やn < 5のときでもint(n/3) = int(n/5) = 0のため問題なし
Sum3_5 = 0.5*(int(n/3)*(3+3*int(n/3))+int(n/5)*(5 + 5*int(n/5)))
Sum15 = 0.5 * (int(n / 15) * (15 + int(n / 15) * 15))
# 問題の回答が整数値のため
print(int(Sum-Sum3_5+Sum15))

Measured memory_bytes: 61728
#include <iostream>
#include <algorithm>
#include <numeric>
using namespace std;
int main(){
    int n, a[3], b, sum;
    sum = 0;
    cin >> n;
    for(int i=1;i<=n;i++){
        a[0] = i;
        for(int j=1;j<=n;j++){
            a[1] = j;
            for(int k=1;k<=n;k++){
                a[2] = k;
                b = gcd<int, int>(a[0], a[1]);
                sum += gcd<int , int>(a[2], b);
            }
        }
    }
    cout << sum;

    return 0;
}

Measured memory_bytes: 3636
X1,Y1,X2,Y2 = map(int, input().split())

X3 = X2-(Y2-Y1)
Y3 = Y2+(X2-X1)
X4 = X3+(X1-X2)
Y4 = Y3+(Y1-Y2)
print(X3,Y3,X4,Y4)

Measured memory_bytes: 9056
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, k, a, g, m;
int gcd(int a, int b){
	while(b){
		a %= b;
		swap(a,b);
	}
	return a;
}
int main(){
	scanf("%d%d", &n, &k);
	rep(i,n){
		scanf("%d", &a);
		m = max(m,a);
		g = gcd(a,g);
	}
	puts(m < k || k % g ? "IMPOSSIBLE" : "POSSIBLE");
}

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

int main(){
  int a, b;
  string s, ans;
  cin >> s;
  a = (s.at(0) - '0')*10 + s.at(1) - '0';
  b = (s.at(2) - '0')*10 + s.at(3) - '0';
  
  if((a > 12 || a == 0) && b <= 12 && b > 0) ans = "YYMM";
  else if((b > 12 || b == 0) && a <= 12 && a > 0) ans = "MMYY";
  else if(a <= 12 && a > 0 && b <= 12 && b > 0) ans = "AMBIGUOUS";
  else ans = "NA";
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, m;
  cin >> n >> m;

  ll sum = 0;
  rep(i,m){
    ll x;
    cin >> x;
    sum += x;
  }

  ll ans = n - sum;
  if(ans < 0) {
    puts("-1");
    return 0;
  }

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


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long llint;

string s;
void solve(){
  cin >> s;
  llint n=int(s.size());
  llint len=2;
  llint ans=0;
  for(int i=0;i<n;i++){
    if(len==2){
      len=1;
      ans++;
    }
    else{
      if(s[i]!=s[i-1]){
        len=1;
        ans++;
      }
      else{
        if(i<n-1){
          len=2;
          ans++;
          i++;
        }
      }
    }
  }
  cout << ans << endl;

}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


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

int main(){
    int n, m;
    cin >> n;
    m = n * 3;
    int A[m];
    REP(i, m) cin >> A[i];

    sort(A, A + m);

    long long ans = 0;
    for(int i = n; i < m; i += 2) ans += A[i];
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1408
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, C, K = (int(i) for i in input().split())
    T = [int(input()) for i in range(N)]
    T.sort()
    from collections import deque
    que = deque([])
    ans = 0
    for t in T:
        if que and que[0] < t:
            for _ in range(C):
                if que:
                    que.popleft()
                else:
                    break
            ans += 1
        que.append(t+K)
        if len(que) >= C:
            for _ in range(C):
                if que:
                    que.popleft()
                else:
                    break
            ans += 1
    if que:
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 43992
// Problem : C - Multiple Clocks
// Contest : AtCoder - AtCoder Beginner Contest 070
// URL : https://atcoder.jp/contests/abc070/tasks/abc070_c
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int n;cin>>n;
vi v(n);cin>>v;
int lcm=v[0];
for(int i=1;i<n;i++)
{
	int x=__gcd(lcm,v[i]);
	lcm=(lcm/x*v[i]);
}
cout<<lcm;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n,k;

void input(){
    cin >> n >> k;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    ll ans = 0;
    for(int b=1;b<=n;++b){
        int p = n / b;
        int r = n % b;
        ans += p * max(0, b-k) + max(0, r-k+1);
        ans -= max(0, 1-k);
    }
    cout << ans << endl;
    return 0;
}

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

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif


#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1)
#define ld long double
#define prime (1000000000 + 7)

using namespace std;

#define INF 1000000000

vll h(string s){
	ll p1 = 1000000000 + 7, p2 = 1000000000 + 9, q = 31;

	ll n = s.size();
	vll res(n);

	res[0].ff = (s[0]-'a' + 1)%p1;
	res[0].ss = (s[0]-'a' + 1)%p1;
	for(int i = 1; i < n; ++i){
		res[i].ff = ((s[i]-'a' + 1)%p1 + (res[i-1].ff * q)%p1 )%p1;
		res[i].ss = ((s[i]-'a' + 1)%p2 + (res[i-1].ss * q)%p2 )%p2;
	}


	return res;
}

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

	ll n, res = 0;
	cin >> n;
	vl vet(n);

	for(auto&p : vet){
		cin >> p;
	}

	for(int i = 0; i < n; ++i){
		for(int j = i + 1; j < n; ++j){
			res += vet[i]*vet[j];
		}
	}

	cout << res << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, char> Pc;
typedef pair<int, string> Ps;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
const int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const string dir8[8] = {"U", "RU", "R", "RD", "D", "LD", "L", "LU"};

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX 100000
#define INFTY (1<<30)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.y) < EPS && fabs(y - p.y) < EPS; } };
typedef Point Vector;
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a));}
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
struct Segment { Point p1, p2; };
typedef Segment Line;
struct Node { int data; Node *left, *right; Node(int data) : data(data), left(NULL), right(NULL) {} };
// clang-format on

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll A, B, N;
  cin >> A >> B >> N;
  ll x = 0;
  if (N >= B) {
    x = B - 1;
  } else {
    x = N;
  }
  ll ans = floor((A * x) / (double)B) - A * floor((x) / (double)B);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3220
import sys
n,m = map(int,input().split())
ls = list(map(int,input().split()))
ls.sort()
if n >= m:
    print(0)
    sys.exit()
for i in range(m-1):
    ls[i] = ls[i+1]-ls[i]
del ls[-1]
ls.sort()
if n == 1:
    print(sum(ls))
else:
    ls = ls[:-(n-1)]
    print(sum(ls))


Measured memory_bytes: 52904