akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC optimize("-ffloat-store")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define endl "\n"
#define f(i,a,b) for(int i=a;i<b;i++)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define mod 1000000007
#define inf  1e18
#define ps(x,y)   fixed<<setprecision(y)<<x
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define inp(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main() 
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
    FIO;
    // int t;
    // cin>>t;
    // while(t--)
    // {
        ll n,x,t;
        cin>>n>>x>>t;
        ll count=0;
        if(n%x==0)
        cout<<(n/x)*t;
        else
        {
            while(n>0)
            {   
                n=n-x;
                count++;
            }
            cout<<count*t;
        }
    // }
return 0;   
}

Measured memory_bytes: 3572
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = 0;
		for(int i = 1; i <= N; i++)
			if(sc.nextInt() % 2 == 1 && i % 2 == 1)
				ans++;
		System.out.println(ans);
	}

}


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

int main(void){
  int N, M;
  int a[60], b[60];
  int cnt[60] = {0};
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    cin >> a[i] >> b[i];
  }
  for(int i = 0; i < M; i++){
    cnt[a[i] - 1]++;
    cnt[b[i] - 1]++;
  }
  for(int i = 0; i < N; i++){
    cout << cnt[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int n; cin >> n;
    int sum=0;
    vector<int> a(n+2); //0, a1, ..., an, 0
    REP(i, n){
        cin >> a[i+1];
        sum += abs(a[i]-a[i+1]);
    }
    sum += abs(a[n] - a[n+1]);
    REP(i, n) cout << sum - abs(a[i+1]-a[i+2]) - abs(a[i]-a[i+1]) + abs(a[i]-a[i+2]) << endl;
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200001;
const ll inf=(ll)1e18;
ll n,a[N],k,num=0;

int Find(int now,ll x)
{
	int l=now+1,r=n,best=now;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(a[now]*a[mid]<=x) l=mid+1,best=mid;
		else r=mid-1;
	}
	return best;
}

int Find2(int now,ll x)
{
	int l=now+1,r=n,best=n+1;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(a[now]*a[mid]<=x) r=mid-1,best=mid;
		else l=mid+1;
	}
	return best;
}

bool check(ll x)
{
	ll ret=0;
	for(int i=1;i<n;i++)
	{
		if(a[i]>=0) ret+=Find(i,x)-i;
		else ret+=n-Find2(i,x)+1;
		if(x==-12) cout<<ret<<endl;
	}
	return ret>=k;
}

int main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	ll l=-inf,r=inf,ans=-1;
	while(l<=r)
	{
		ll mid=(l+r)>>1;
		if(check(mid)) r=mid-1,ans=mid;
		else l=mid+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5244
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
 int a,b;
 int main()
 {
     cin>>a>>b;
     if ((a%3==0) || (b%3==0) || ((a+b)%3==0)) cout<<"Possible"<<endl;
     else cout<<"Impossible"<<endl;
 }

Measured memory_bytes: 256
N = int(input())
S = input()

rcost = 0
lcost = S.count('E')
if S[0] == 'E':
    lcost -= 1
ans = lcost

for i in range(N-1):
        if S[i] == 'W':
            rcost += 1
        if S[i+1] == 'E':
            lcost -= 1
        ans = min(ans, rcost+lcost)
    
print(ans)

Measured memory_bytes: 3676
import sys
x1,y1,x2,y2 = list(map(int, input().split()))

x3 = x2 + (y1 - y2)
y3 = y2 - (x1 - x2)
x4 = x3 + (y2 - y3)
y4 = y3 - (x2 - x3)

print(x3,y3,x4,y4)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
bool is_prime(lli x) {
  for(lli i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}
int main() {
  lli A,B,C=INF,D=0,E=0,F=0,G=0,H=0,N,M;
  string S,K,L;
  cin >> N >> M;
  vector<lli>P(N),Q(N-M+1);
  rep(i,0,N)cin >> P[i];
  Sort(P);
  rep(i,M-1,N)Q[i-M+1]=P[i]-P[i-M+1];
  Sort(Q);
  Out(Q[0]);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define push_back pb

using namespace std;

typedef long long ll;

void solve(){
    string s,t;
    bool res=true;
    cin>>s>>t;
    int x=s.size();
    for(int i=0;s[i];i++){
        if(s[i]!=t[i]){
            res=false;
            break;
        }
    }
    if(res){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
}

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

    //freopen("in.txt", "r", stdin);

    solve();


    return 0;
}


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

using namespace std;


const int N = 100005;

int a[N];
int f[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  f[0] = 0;
  f[1] = abs(a[1] - a[0]);
  for (int i = 2; i < n; i++) {
    f[i] = f[i - 1] + abs(a[i] - a[i - 1]);
    f[i] = min(f[i], f[i - 2] + abs(a[i] - a[i - 2]));
  }
  printf("%d\n", f[n - 1]);
  return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = []
a.append(input())
a.append(input())
a.append(input())

cnt = 0
for i in range(n):
  if a[0][i] == a[1][i] and a[1][i] == a[2][i]:
    cnt += 0
  elif a[0][i] == a[1][i] and a[0][i] != a[2][i]:
    cnt += 1
  elif a[0][i] == a[2][i] and a[0][i] != a[1][i]:
    cnt += 1
  elif a[1][i] == a[2][i] and a[0][i] != a[1][i]:
    cnt += 1
  else:
    cnt += 2

print(cnt)

Measured memory_bytes: 3064
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 100000;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int,P> PP;
typedef pair<int,PP> PPP;
struct edge { int to;  int cost; };
int b[25];
int a[25][25];
signed main() {
	int n, m, c; cin >> n >> m >> c;
	rep(i, m)cin >> b[i];
	rep(i, n)rep(j, m)cin >> a[i][j];
	int cnt = 0;
	rep(i, n) {
		int sum = 0;
		rep(j, m)sum += a[i][j] * b[j];
		sum += c;
		if (sum > 0)cnt++;
	}
	cout << cnt << endl;
	}

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

int main() {
 string str;
 cin >> str;
  
 char a = str.at(0);
 char b = str.at(1);
 char c = str.at(2);
  
  if(a=='R'&& b=='R' && c=='R'){
    cout << '3';
  }
  else if(a=='R'&& b=='R' && c=='S'||a=='S'&& b=='R' && c=='R'){
    cout << '2';
  }
  else if(a=='S'&& b=='S' && c=='S'){
    cout << '0';
  }
  else{
    cout << '1';
 }
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define cs(ele) cout<<ele<<'\n'
int main()
{

  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin>>n;
  vector<int> d(10050,0);
  for(int i=1; i<=105; i++){
    for(int j=1; j<=105; j++){
        for(int k=1; k<=105; k++){
            ll a=i*i+j*j+k*k+i*j+k*j+i*k;
            //cout<<a<<endl;
            if(a<10050){d[a]++; }//cout<<d[a]<<endl;}
        }
    }
  }
  for(int i=1; i<=n; i++){
    cout<<d[i]<<endl;
  }

    return 0;
}

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

int main(){
    int n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0)sum+=i;
    }
    cout<<sum<<endl;
    return 0;
}

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

using namespace std;

int main()
{
    long long n,k;
    cin>>n>>k;
    if(k>=n){
        cout<<min(n,abs(n-k))<<endl;
    }
    else{
        long long val;
        if(n%k==0)val=(n/k)*k;
        else      val=((n/k)+1)*k;
        cout<<abs(n-val)<<endl;
    }
}


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

vector<int> divisor(int N) {
  vector<int> res;
  for (int i = 1; i * i <= N; i++) {
    if (N % i == 0) {
      res.push_back(i);
      if (i != N / i) {
        res.push_back(N / i);
      }
    }
  }
  return res;
}

int main() {

  int N;
  cin >> N;  

  int answer = 0;

  vector<int> res;

  for (int i = 1; i <= N; i++) {
    if (i % 2 == 1) {
      res = divisor(i);
      if (res.size() == 8) {
        answer++;
      }
    }
  }
  
  cout << answer << endl;

}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
ans = 'Yes'
current = h[-1]
for i in reversed(range(n-1)):
  if current >= h[i]:
    current = h[i]
    continue
  elif current == h[i]-1:
    current = h[i]-1
    continue
  else:
    ans = 'No'
    break
print(ans)

Measured memory_bytes: 63856
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef long double LD;

const int MOD = 1e9 + 7;

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

	LL X;
	cin >> X;

	LL res11 = X/LL(11);
	LL res = res11*2LL;
	if (X - res11 * LL(11) > 6) res += 2LL;
	else if (X - res11 * LL(11) > 0) res += 1LL;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    long long a,b,n;
    cin>>a>>b>>n;
    ll l=1ll;
    ll r=n;
    ll ans=LONG_MIN;
    while(l<=r)
    {
        ll mid=(l+r)/2;
        ll temp=(ll)(floor(double(a*mid)/(double)b))-(a*(floor((double)mid/(double)b)));       
        if(ans<=temp)
        {
            ans=max(ans,temp);
            l=mid+1;
        }
        else
            r=mid-1;
    }  
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long int ULL;
typedef long long LL;
typedef long double LD;

LL mod = 1000000007;

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

	vector<vector<pair<LL, LL>> > data(n, vector<pair<LL, LL>> (0));

	for (int i = 0; i < n; ++i) {
		LL A;
		cin >> A;

		for (int j = 0; j < A; ++j) {
			LL x, y;
			cin >> x >> y;
			pair<LL, LL> p(x, y);
			data[i].push_back(p);
		}
	}
	LL ans = 0;
	for (int i = 0; i < pow(2, n); ++i) {
		LL x = i;
		vector<LL> tr(n, 0);
		LL pos = 0, c1 = 0;
		while (x != 0) {
			tr[pos] = x%2;
			c1 += x%2;
			x/=2;
			pos++;
		}
		bool poss = true;

		for (int j = 0; j < n; ++j) {
			for (auto &e : data[j]) {
				if ((tr[j] && (tr[e.first-1] != e.second)) ) {
					poss = false;
					break;
				}
			}
			if (!poss)
				break;
		}

		if (poss) {
			ans = max(ans, c1);
		}
	}
	cout << ans << endl;

}

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

int main(){
    ll a;
    long double b;
    cin >> a >> b;
    cout << (ll)(a*b) << endl;
    return 0;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
Int n,ans=0;
vector<Int> a(202),u(202,0);
Int tmp=0;
const Int BEET = 35;
void dfs(Int x){
  //cout<<x<<endl;
  if(x==BEET){
    Int res=tmp;
    //cout<<res<<":"<<endl;
    for(Int i=BEET;i<=n;i++){
      //cout<<"i "<<i;
      if(u[i]) continue;
      if((i&1)==0&&BEET<=i/2) continue;
      if(i*2<=n&&!u[i*2]){
	// rm i / rm i*2 / get
	res+=max({0LL,a[i],a[i]+a[i*2]});
      }else{
	// rm / get
	res+=max({0LL,a[i]});
      }
    }
    //cout<<endl;
    ans=max(ans,res);
    return;
  }
  
  if(u[x]){
    dfs(x+1);
    return;
  }

  // get x
  tmp+=a[x];
  dfs(x+1);
  tmp-=a[x];

  // rm x and its mul
  for(Int i=x;i<=101;i+=x) u[i]++;
  dfs(x+1);
  for(Int i=x;i<=101;i+=x) u[i]--;
}
signed main(){
  cin>>n;
  for(Int i=1;i<=n;i++) cin>>a[i];

  //assert(n<BEET);
  dfs(1);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    System.out.println(Math.max(a*b,c*d));

  }
  

  
}


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

int main() {
  uint32_t N = 0, C = 0, K = 0;
  std::cin >> N >> C >> K;

  std::vector<uint32_t> T(N);
  for (auto &&t : T) std::cin >> t;
  std::sort(T.begin(), T.end());

  uint32_t sum = 1, first = T[0], riders = 1;
  for (size_t i = 1; i < N; i++) {
    if (riders == C || first + K < T[i]) {
      sum++;
      riders = 1;
      first = T[i];
    } else {
      riders++;
    }
  }

  std::cout << sum << std::endl;

  return 0;
}

Measured memory_bytes: 640
import scala.io.StdIn.readLine
import scala.collection.mutable.ArrayBuffer

case class Dice(var d:Seq[String]) {
  private val s = Array(4,0,2,3,5,1)
  private val w = Array(2,1,5,0,4,3)
  private val h = Array(0,2,4,1,3,5)
  private val buf = ArrayBuffer.empty[Seq[String]]

  def rotateAll() = {
    buf += d
    buf += s.map(d)
    buf += s.map(s).map(d)
    buf += s.map(s).map(s).map(d)
    buf += w.map(d)
    buf += w.map(w).map(w).map(d)

    buf += h.map(d)
    buf += s.map(s).map(s).map(h).map(d)
    buf += w.map(h).map(d)
    buf += w.map(w).map(w).map(h).map(d)
    buf += s.map(h).map(d)
    buf += s.map(s).map(h).map(d)

    buf += h.map(h).map(d)
    buf += s.map(s).map(s).map(h).map(h).map(d)
    buf += w.map(h).map(h).map(d)
    buf += w.map(w).map(w).map(h).map(h).map(d)
    buf += s.map(h).map(h).map(d)
    buf += s.map(s).map(h).map(h).map(d)

    buf += h.map(h).map(h).map(d)
    buf += s.map(s).map(s).map(h).map(h).map(h).map(d)
    buf += w.map(h).map(h).map(h).map(d)
    buf += w.map(w).map(w).map(h).map(h).map(h).map(d)
    buf += s.map(h).map(h).map(h).map(d)
    buf += s.map(s).map(h).map(h).map(h).map(d)
  }

  def getAllRot = buf.toArray
  def getFaces = d
}

object Main extends App {
  val faces1 = readLine.split(" ")
  val faces2 = readLine.split(" ").toSeq
  val dice1 = Dice(faces1)

  dice1.rotateAll()
  if(dice1.getAllRot.contains(faces2))
    println("Yes")
  else
    println("No")
}

Measured memory_bytes: 44136
#include <bits/stdc++.h>
 
using namespace std;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = 4*atan(1);
typedef long long ll;
typedef pair<int,int> pii;
int n;
void solve() {
	cin >> n;
	ll sum = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0|| i % 5 == 0) continue;
		sum += i;
	}
	printf("%lld\n",sum);
}
int main() {
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	// int t;
	// cin >> t;
	// for (int i = 1; i <= t; i++) { 
		// cout << "Case #" << i << ": ";
		solve();
	// }
}

Measured memory_bytes: 3760
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("Heisei")
    else:print("TBD")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())


n = ip()                              #入力整数1つ
#n,k= (int(i) for i in input().split())      #入力整数横2つ
#n,x,y = (int(i) for i in input().split())    #入力整数横3つ
#n,a,b,c= (int(i) for i in input().split())  #入力整数横4つ
a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
print(max(a)-min(a))

Measured memory_bytes: 13380
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

from math import gcd

def getlist():
	return list(map(int, input().split()))

num = 10 ** 6 + 1
L = [1 for i in range(num)]; L[0] = 0; L[1] = 0
plist = []
for i in range(num):
	if L[i] == 1:
		plist.append(i); c = 2
		while i * c <= num - 1:
			L[i * c] = 0; c += 1

#処理内容
def main():
	N = int(input())
	A = getlist()
	GCD = A[0]
	for i in range(N):
		GCD = gcd(GCD, A[i])

	if GCD != 1:
		print("not coprime")
		return

	B = []
	for i in A:
		if i != 1:
			B.append(i)

	B.sort()
	table = [0] * (10 ** 6 + 1)
	for i in B:
		table[i] += 1

	for i in plist:
		val = 0
		c = 1
		while i * c <= 10 ** 6:
			val += table[i * c]
			c += 1		

		if val >= 2:
			print("setwise coprime")
			return

	print("pairwise coprime")


if __name__ == '__main__':
	main()

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, A[200100], B[200100];
std::vector<int> v;

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

    for(int i=1;i<=N;++i){
        std::cin >> A[i];
    }

    for(int i=N;i>=1;--i){
        int c = 0;

        for(int j=2*i;j<=N;j+=i){
            c += B[j];
        }

        c %= 2;

        B[i] = (c ^ A[i]);

        if(B[i] > 0){
            v.emplace_back(i);
        }
    }

    int M = v.size();

    std::cout << M << std::endl;

    for(int i=0;i<v.size();++i){
        std::cout << v[i] << " \n"[i + 1 == v.size()];
    }
}


Measured memory_bytes: 3192
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int score=sc.nextInt();
		long dp[][][] = new long[55][55][2605];
		dp[0][0][0]=1;
		int mod = 1000000007;
		for(int i=0; i<n; i++) {
			for(int j=0; j<=i; j++) {
				for(int k=0; k<=score; k++) {
					{
						int nj=j;
						dp[i+1][nj][k+nj*2] += dp[i][j][k];
						dp[i+1][nj][k+nj*2] %=mod;
					}
					{
						int nj=j+1;
						dp[i+1][nj][k+nj*2] += dp[i][j][k];
						dp[i+1][nj][k+nj*2] %=mod;
					}
					{
						int nj=j;
						int x=j*2;
						long y = dp[i][j][k] * x;
						y %= mod;
						dp[i+1][nj][k+nj*2] += y;
						dp[i+1][nj][k+nj*2] %= mod;
					}
					if(j>=1) {
						int nj=j-1;
						int x=j*j;
						long y = dp[i][j][k] * x;
						y %= mod;
						dp[i+1][nj][k+nj*2] += y;
						dp[i+1][nj][k+nj*2] %= mod;
					}
				}
			}
		}
		System.out.println(dp[n][0][score]);
		sc.close();
	}
}


Measured memory_bytes: 103220
#include <iostream>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
using ll = long long;

using namespace std;



int main() {
    int a,b,c;
    cin>>a>>b>>c;
    int ans;
    ans = c-a+b;
    if(ans < 0) ans = 0;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3640
/**
 *    +--+--+--++--++--In the name of ALLAH--++--++--+--+--+
 *
 *    author:  skmonir
 *    created: 11-Jul-2020 18:05:40
**/

#include <bits/stdc++.h>

using namespace std;

#define endl                '\n'
#define TN                  typename
#define mod                 1000000007LL
#define len(x)              (int) x.size()
#define all(x)              x.begin(), x.end()
#define rall(x)             x.rbegin(), x.rend()
#define mem(x, y)           memset(x, y, sizeof x)
#define FOR(x, l, r)        for (int x = l; x <= r; ++x)
#define ROF(x, l, r)        for (int x = l; x >= r; --x)

template <TN T> inline void INT(T &n) {
    n = 0; int f = 1; int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> inline void umin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void umax(T &a, T b) {a = a > b ? a : b;}
template <TN T, TN W> inline void INT(T &x, W &y) {INT(x), INT(y);}
template <TN T, TN W, TN Q> inline void INT(T &x, W &y, Q &z) {INT(x, y), INT(z);}

const int N = 1e5 + 7;
const int inf = 1e9 + 7;

inline int sq(int x) {
    return x * x;
}

int solve() {
    int n; cin >> n;
    vector<int> res(n + 1);
    FOR (i, 1, 100) FOR (j, 1, 100) FOR (k, 1, 100) {
        int m = sq(i) + sq(j) + sq(k) + i * j + j * k + k * i;
        if (m > n) {
            break;
        }
        ++res[m];
    }

    FOR (i, 1, n) {
        printf("%d\n", res[i]);
    }

    return 0;
}

int main() {
    int tests = 1, CaseNo = 0;
    // INT(tests);
    while (tests--) {
        //printf("Case %d: ", ++CaseNo);
        solve();
    }
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF =1000000000000000;

int n, sum = 0, nya = 0 ,x,y;

int main(){
  cin >> n;
  int a[n];
  REP(i,n){
    cin >> a[i];
    sum+=a[i];
  }
  
  REP(i,n){
    nya += a[i];
    if(nya >= sum/2){
      x=abs(sum - 2*nya);
      y=abs(x - 2*a[i]);
      cout<< min(x,y) <<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
n, x = map(int, input().split())
m = []
for i in range(n):
  m += [int(input())]

m.sort()
x -= sum(m)
donuts = len(m)
for i in range(n):
  q = x // m[i]
  for j in range(q):
    if x >= m[i]:
      donuts += 1
      x -= m[i]
    else:
      break
  if x < m[i]:
    break

print(donuts)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long;
main(){
  int n;cin>>n;
  vector<ll> a(n);
  for(auto&f:a)cin>>f;
  map<ll,ll> cnt1,cnt2;
  for(int i=0;i<n;i+=2)cnt1[a[i]]++;
  for(int i=1;i<n;i+=2)cnt2[a[i]]++;
  
  pair<ll,ll> cnt1_max(0,0),cnt1_next(0,0);
  pair<ll,ll> cnt2_max(0,0),cnt2_next(0,0);
  for(const auto&elem:cnt1){
    if(elem.second>cnt1_max.second){
      if(cnt1_max.second>cnt1_next.second)cnt1_next=cnt1_max;
      cnt1_max=elem;
    }
    else if(elem.second>cnt1_next.second)cnt1_next=elem;
  }
  for(const auto&elem:cnt2){
    if(elem.second>cnt2_max.second){
      if(cnt2_max.second>cnt2_next.second)cnt2_next=cnt2_max;
      cnt2_max=elem;
    }
    else if(elem.second>cnt2_next.second)cnt2_next=elem;
  }
  
  ll num=n/2;
  if(cnt1_max.first==cnt2_max.first){
    ll ans1=0,ans2=0;
    ans1+=num-cnt1_max.second;
    ans1+=num-cnt2_next.second;
    ans2+=num-cnt1_next.second;
    ans2+=num-cnt2_max.second;
    cout<<min(ans1,ans2)<<endl;
  }
  else {
    ll ans=0;
    ans+=num-cnt1_max.second;
    ans+=num-cnt2_max.second;
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 7296
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;

const ll mod = 1000000007;

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

	if ((a + d - 1) / d >=  (c + b - 1) / b) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;

	}
	return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define ll long long
#define lb(x) (x & -x)
#define N (200005)
 
using namespace std;
 
int sum[N],k,n,tot;
ll hsh[N],a[N],ans;

inline int gi(){
	int x=0,q=1; char ch=getchar();
	while ((ch<'0' || ch>'9') && ch!='-') ch=getchar();
  	if (ch=='-') q=-1,ch=getchar();
  	while (ch>='0' && ch<='9') x=x*10+ch-48,ch=getchar();
  	return q*x;
}

void add(int x){
	for (;x<=tot;x+=lb(x)) sum[x]++;
}

int query(int x){
	int res=0;
	for (;x;x-=lb(x)) res+=sum[x];
	return res;
}

int main(){
  	n=gi(),k=gi();
  	for (int i=1;i<=n;++i) a[i]=a[i-1]+gi();
  	for (int i=1;i<=n;++i) a[i]-=1LL*k*i,hsh[i]=a[i];
  	hsh[tot=n+1]=0,sort(hsh+1,hsh+tot+1);
	tot=unique(hsh+1,hsh+tot+1)-hsh-1;
  	for (int i=0;i<=n;++i){
  		a[i]=lower_bound(hsh+1,hsh+tot+1,a[i])-hsh;
  		ans+=query(a[i]),add(a[i]);
	}
	cout<<ans; return 0;
}

Measured memory_bytes: 7516
s = list(input())
stack = []
for i in s:
    if i == "S":
        stack.append(i)
    if i =="T":
        if len(stack) == 0:
            stack.append(i)
        elif stack[-1] == "T":
            stack.append(i)
        elif stack[-1] == "S":
            stack.pop()
print(len(stack))





Measured memory_bytes: 6432
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    string s;
    cin >> s;
    for (int i = s.size() - 2; i >= 0; i -= 2)
    {
        int a = i / 2;
        bool f = true;
        for (int j = 0; j < a; j++)
        {
            if (s[j] != s[j + a])
                f = false;
        }
        if (f)
        {
            cout << i << endl;
            return 0;
        }
    }
}

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

char alp[26];

int N;
string S;

int main() {
    for (int i = 0; i < 26; i++) {
        alp[i] = (char)((int)'A' + i);
    }
    cin >> N;
    cin >> S;
    for (int i = 0; i < S.length(); i++) {
        int n = (int)S[i] - (int)'A';
        (n + N < 26) ? S[i] = S[i] + N : S[i] = S[i] - 26 + N;
    }
    cout << S;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int ans = floor(n / 1.08);
    int ans2 = ceil(n / 1.08);
    if(floor(ans * 1.08) == n)
        cout << ans << endl;
    else if(floor(ans2 * 1.08) == n)
        cout << ans2 << endl;
    else
        cout << ":(" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    while(cin >> n) {
        int b = 0;
        rep(i, n) {
            int a; cin >> a;
            b += a % 2;
        }
        cout << (b % 2 ? "NO" : "YES") << endl;
    }
}


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

#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcd(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int n, m;
  cin >> n >> m;
  vt<int> a(n);
  rep(i, 0, n) cin >> a[i];
  vt<pi> vec(m);
  rep(i, 0, m) {
    int b, c;
    cin >> b >> c;
    vec[i] = {c, b};
  }

  sort(all(a));
  sort(rall(vec));
  int idx = 0;
  rep(i, 0, m) {
    while(idx < n && vec[i].second > 0 && a[idx] < vec[i].first) {
      a[idx] = vec[i].first;
      idx++; vec[i].second--;
    }
  }

  i64 ans = 0;
  rep(i, 0, n) {
    ans += a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n,m;
  int k;
  bool ans = false;
  
  scanf("%d%d%d",&n,&m,&k);

  for(int i=0;i<=n;i++){
    for(int j=0;j<m;j++){
      int t = i * j + (n-i) * (m-j);
      ans |= t == k;
    }
  }


  if(ans){
    puts("Yes");
  }else{
    puts("No");
  }
  
  return 0;
}


Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	//adjMatrix[u][v] = 1 if there is an edge from u to v, otherwise 0
	private int[][] adjMatrix;
	//adjWeight[u][v] -- the weight of the edge from u to v if there is one
	private int[][] adjWeight;
	//if a node is settled (e.g., processed in the Dijkstra's algorithm)
	private Boolean[] ifSettled;
	public Graph() { totalVertex = 0; }
	public int getTotalVertex() { return totalVertex; }
	//load graph from standard input
	public void loadAdjMatrix() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjMatrix = new int[totalVertex][totalVertex];
		adjWeight = new int[totalVertex][totalVertex];
		ifSettled = new Boolean[totalVertex];
		int i, j;
		for(i = 0; i < totalVertex; i ++) {
			ifSettled[i] = false;
			for(j = 0; j < totalVertex; j ++) {
				adjMatrix[i][j] = adjWeight[i][j] = 0;
			}
		}
		int u, v;
		for(i = 0; i < totalVertex; i ++) {
			u = in.nextInt();
			int degree = in.nextInt();
			for(j = 0; j < degree; j ++) {
				v = in.nextInt(); 
				adjMatrix[u][v] = 1;
				adjWeight[u][v] = in.nextInt();
			}	
		}
		in.close();
	}
	//return weight of the edge from u to v if there is one
	public int getWeight(int u, int v) {
		return adjWeight[u][v];
	}
	//return neighbors of u as a LinkedList
	public LinkedList<Integer> getNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if(adjMatrix[u][v] == 1) tmp.add(v);
		}
		return tmp;
	}
	//return unsettled neighbors of u as a LinkedList
	public LinkedList<Integer> getUnsettledNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if((adjMatrix[u][v] == 1) && (ifSettled[v] == false)) tmp.add(v);
		}
		return tmp;
	}
	//return the unsettled node that has the smallest dist
	public int getUnsettledNearest(int[] dist) {
		int md = Integer.MAX_VALUE;
		int mv = -1;
		int v;
		for(v = 0; v < totalVertex; v ++) {
			if((ifSettled[v] == false) && (dist[v] < md)) {
				md = dist[v];
				mv = v;
			}
		}
		return mv;
	}
	
	public int[] Dijkstra(int s) {
		LinkedList<Integer> linker = new LinkedList<Integer>();

		for(int i = 0; i < totalVertex; i ++) 
			linker.add(i);
		int[] distance = new int[totalVertex];
		for(int i = 0; i < totalVertex; i ++) 
			distance[i] = Integer.MAX_VALUE;
		distance[s] = 0;
		while(linker.isEmpty() == false) {
			int u = getUnsettledNearest(distance);
			if(distance[u] == Integer.MAX_VALUE) 
				break;
			linker.remove(linker.indexOf(u));
			ifSettled[u] = true;
			Iterator<Integer> iter = 
					getUnsettledNeighbors(u).iterator();
			while(iter.hasNext()) {
				int v = iter.next();
				int t = distance[u] + getWeight(u, v);
				if(t < distance[v]) distance[v] = t;
			}
		}
		return distance;
	}
}

public class Main {
	public static void main(String[] argv) {
		Graph g = new Graph();
		g.loadAdjMatrix();
		int[] dist = g.Dijkstra(0);
		for(int i = 0; i < g.getTotalVertex(); i ++) {
			System.out.println(i + " " + dist[i]);
		}
	}
}


Measured memory_bytes: 40116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  ll l,r;
  cin >> l >> r;
  if(l/2019 != r/2019) cout << 0 << endl;
  else
  {
      ll min = (l%2019)*((l+1)%2019)%2019;
      for(ll i = 0;i+l <= r;i++)
      {
          ll li = l + i;
          for(int j = i + 1;j + l<= r;j++)
          {
              ll lj = l+j;
              ll tmp = (li%2019)*(lj%2019)%2019;
              if(tmp < min) min = tmp;
          }
      }
      cout << min << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int n, t, mx, cnt;
int a[100005];
int m[100005];

int main()
{
    scanf("%d%d", &n, &t);
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    m[n-1] = a[n-1];
    for(int i = n-2; i >= 0; i--)
    {
        m[i] = max(a[i], m[i + 1]);
    }
    for(int i = 0; i < n; i++)
    {
        if(m[min(i + 1, n-1)] - a[i] > mx)
        {
            mx = m[min(i + 1, n-1)] - a[i];
            cnt = 1;
        }
        else if(m[min(i + 1, n - 1)] - a[i] == mx)
        {
            cnt++;
        }
    }
    printf("%d", cnt);
    return 0;
}


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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            // 入力
            //var inputArr = cin.ReadIntArray(4);
            char[] s = cin.ReadLine.ToCharArray();
            
            string result = "Good";
            char tmp = " ".ToCharArray()[0];
            foreach (char c in s)
            {
                if (tmp.Equals(c))
                {
                    result = "Bad";
                    break;
                }
                tmp = c;
            }
            WriteLine(result);

        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
#include<iostream>
using namespace std;
using uint = unsigned int;

int main() {
	uint H, W, N;
	cin >> H >> W >> N;
	
	uint K = max(H, W);
	
	if(N % K == 0) {
		cout << (N / K);
	} else {
		cout << (N / K) + 1;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll                 long long
#define ull                unsigned long long
#define pii                pair<int, int>
#define pll                pair<ll, ll>
#define mp                 make_pair
#define ff                 first
#define ss                 second
#define sz(x)              (int) x.size()
#define all(v)             v.begin(), v.end()

template <typename T> inline void smin(T &a, T b) {a = a < b ? a : b;}
template <typename T> inline void smax(T &a, T b) {a = a > b ? a : b;}
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << ", ";
	err(++it, args...);
}
 
template <typename T> inline void Int(T &n) {
	n = 0; int f = 1; register int ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
	for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
	n = n * f;
}
 
template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l); }

const int mod = (int) 1e9 + 7;
 
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll) a * b % mod;}
 
const int inf = (int) 2e9 + 5;
const ll  Inf = (ll) 2e18 + 5;
const int N   = (int) 2e5 + 5;



int solve() {
    int n, m; Int(n, m);
    std::set<int> g[n + 1];
    for(int i = 1; i <= m; i++) {
        int s, c; Int(s, c);
        g[s].insert(c);
    }
    if(n == 1 and m == 0) return printf("0\n");
    for(int i = 1; i <= n; i++) {
    	if(sz(g[i]) > 1) return printf("-1\n");
    }
    if(n == 1) return printf("%d\n", *g[1].begin());
    if(sz(g[1]) > 0 and *g[1].begin() == 0) return printf("-1\n");
    for(int i = 1; i <= n; i++) {
    	if(sz(g[i]) == 0) {
    		if(i == 1) printf("1");
    		else printf("0");
    	}
    	else printf("%d", *g[i].begin());
    }
    printf("\n");
	return 0;
}
 
int main() {
	//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int test = 1, tc = 0;
	//Int(test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
import itertools

k = int(input())
X = sorted([list(map(int, input().split())) for _ in range(k)])
for l in list(itertools.permutations(range(8))):
  flag = True
  for x in X:
    if l[x[0]] != x[1]:
      flag = False
  if flag:
    flag2= True
    check = []
    for i in range(8):
      for j in range(1,8-i):
        check.append([i+j,l[i]+j])
        check.append([i+j,l[i]-j])
    for c in check:
      if c[1] < 0 or c[1] > 8:
        continue
      else:
        if c in [[i,l[i]] for i in range(8)]:
          flag2 = False
    if flag2:
      #print(l)
      #print(X)
      #print(check)
      for i in range(8):
        tmp = ['.','.','.','.','.','.','.','.']
        tmp[l[i]] = 'Q'
        print(''.join(tmp))
      break
      


Measured memory_bytes: 10544
"use strict";const main=e=>{let t=e.split("\n"),n=[];for(let e=0;e<3;e++)n.push(t[e].split(/\s/).map(e=>e-0));let s=[0,0,0,0,0];for(let e=0;e<3;e++)s[n[e][0]]+=1,s[n[e][1]]+=1;console.log(s.every(function(e){return 3!=e})?"YES":"NO")};main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7372
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn extgcd(a: i64, b: i64, x: &mut i64, y: &mut i64) -> i64 {
    let mut d = a;
    if b == 0 {
        *x = 1;
        *y = 0;
    } else {
        d = extgcd(b, a % b, y, x);
        *y -= (a / b) * (*x);
    }
    return d;
}

fn mod_inverse(a: i64, m: i64) -> i64 {
    let mut x: i64 = 0;
    let mut y: i64 = 0;
    extgcd(a, m, &mut x, &mut y);
    (m + x % m) % m
}

struct ModFactorial {
    fact: Vec<i64>,
}

// returns n! under mod m
impl ModFactorial {
    fn new(n: i64, m: i64) -> ModFactorial {
        let mut fact = vec![1; n as usize + 1];
        for i in 2..fact.len() {
            fact[i] = (i as i64 * fact[i - 1]) % m;
        }
        ModFactorial { fact: fact }
    }
}

// returns bin[i] = nCi under mod m
struct ModBinominal {
    bin: Vec<i64>,
}

impl ModBinominal {
    fn new(n: i64, m: i64, fact: &Vec<i64>, inv_fact: &Vec<i64>) -> ModBinominal {
        let mut bin = vec![1; n as usize + 1];
        if n == 0 {
            return ModBinominal { bin: bin };
        }
        for i in 1..n + 1 {
            let a2 = inv_fact[i as usize] % m;
            let a3 = inv_fact[(n - i) as usize] % m;
            bin[i as usize] = fact[n as usize] * ((a2 * a3) % m) % m;
        }
        ModBinominal { bin: bin }
    }
}

fn h_comb(n: i64, r: i64, bins: &Vec<ModBinominal>) -> i64 {
    // nHr = n + r - 1Cr
    bins[(n + r - 1) as usize].bin[r as usize]
}

fn main() {
    let v = read_vec::<i64>();
    let big_int = 998244353i64;
    let (k, n) = (v[0], v[1]);
    let fact = ModFactorial::new(k + n + 1, big_int).fact;
    let inv_fact = (0..k + n + 1)
        .map(|x| mod_inverse(fact[x as usize], big_int))
        .collect::<Vec<_>>();
    let mut bins = Vec::with_capacity((k + n + 1) as usize);
    for i in 0..k + n + 1 {
        bins.push(ModBinominal::new(i, big_int, &fact, &inv_fact));
    }
    let total = h_comb(k, n, &bins);

    let mut answers = Vec::new();

    for i in 2..k + 2 {
        let mut ans = total;
        for j in 1..i / 2 + 1 {
            if n < j * 2 {
                break;
            }
            let mut new_section =
                bins[(i / 2) as usize].bin[j as usize] * h_comb(k, n - 2 * j, &bins);
            new_section %= big_int;
            // Inclusion-exclusion principle
            if j % 2 == 1 {
                ans += big_int - new_section;
            } else {
                ans += new_section;
            }
            ans %= big_int;
        }
        answers.push(ans);
    }
    for &ans in answers.iter() {
        println!("{}", ans);
    }
    for &ans in answers.iter().rev().skip(1) {
        println!("{}", ans);
    }
}


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

int bit[50];

int main(void) {
    memset(bit,-1,sizeof(bit));
    long long one,two;
    int n;
    scanf("%d",&n);
    scanf("%lld %lld",&one,&two);
    long long val=0;
    for(int i=2;i<n;i++) {
        long long x;
        scanf("%lld",&x);
        val^=x;
    }
    long long temp=one+two;
    temp-=val;
    if (temp<0||temp%2==1) {
        printf("-1");
        return 0;
    }
    temp/=2;
    for(int i=0;i<50;i++) {
        if (temp&(1LL<<i)) {
            bit[i]=1;
        }
    }
    long long total=one+two;
    val=0;
    for(int i=0;i<50;i++) {
        if (bit[i]==1) {
            val+=(2LL<<i);
            continue;
        }
        long long now=(total&((1LL<<(i+1))-1));
        if (now-val==0) {
            bit[i]=0;
        }
        else {
            val+=(1LL<<i);
        }
    }
    if (val!=total) {
        printf("-1");
        return 0;
    }
    long long ret=0;
    for(int i=49;i>=0;i--) {
        if (bit[i]!=-1) {
            if (bit[i]==1) {
                ret+=(1LL<<i);
            }
        }
    }
    for(int i=49;i>=0;i--) {
        if (bit[i]!=-1) {
            continue;
        }
        if (ret+(1LL<<i)<=one) {
            ret+=(1LL<<i);
        }
    }
    if (ret<=0||ret>one) {
        printf("-1");
        return 0;
    }
    printf("%lld",one-ret);
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
int32_t main()
{
	IOS;
	int a, b, c;
  	cin >> a >> b >> c;
	if(a == b && b == c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

int main(){
    // あとで消す
    //std::ifstream in("ein4.txt");
    //std::cin.rdbuf(in.rdbuf());

    string N;
    int K;

    cin >> N >> K;

    // 桁DPをやっていく
    // [桁インデックス i][以下フラグ j][状態 s] 
    // 0<= ID <|N|
    // j \in {0,1} 0:未確定 1:確定
    // s \in {0個, 1個, 2個, 3個} 4以上は消える

    int lenN = N.length();
    int numS = 4;


    // 各桁の数字を数値として保持
    vector<int> lstr(lenN);
    for(size_t i=0;i<lenN;i++) lstr.at(i) = N.at(i)-48;

    // DP用のテーブル
    vector< vector< vector<long long> > > DP(lenN, vector< vector<long long> >(2, vector<long long>(numS,0)));

    // 初期化
    DP.at(0).at(0).at(1) = 1;                   // 数字が同じなのは未確定   N
    DP.at(0).at(1).at(1) = lstr.at(0)-1;        // 数字が小さいのは確定     1,...,N-1
    DP.at(0).at(1).at(0) = 1;                   // 先頭が0なのは確定        0

    for(size_t i=1;i<lenN;i++){
        if(lstr.at(i)==0){
            DP.at(i).at(1).at(0) = DP.at(i-1).at(1).at(0);
            DP.at(i).at(1).at(1) = DP.at(i-1).at(1).at(1) + DP.at(i-1).at(1).at(0)*9;
            DP.at(i).at(1).at(2) = DP.at(i-1).at(1).at(2) + DP.at(i-1).at(1).at(1)*9;
            DP.at(i).at(1).at(3) = DP.at(i-1).at(1).at(3) + DP.at(i-1).at(1).at(2)*9;
            DP.at(i).at(0).at(0) = DP.at(i-1).at(0).at(0);
            DP.at(i).at(0).at(1) = DP.at(i-1).at(0).at(1);
            DP.at(i).at(0).at(2) = DP.at(i-1).at(0).at(2);
            DP.at(i).at(0).at(2) = DP.at(i-1).at(0).at(2);
        }else{
            DP.at(i).at(1).at(0) = DP.at(i-1).at(1).at(0) + DP.at(i-1).at(0).at(0);
            DP.at(i).at(1).at(1) = DP.at(i-1).at(1).at(1) + DP.at(i-1).at(1).at(0)*9 + DP.at(i-1).at(0).at(0)*(lstr.at(i)-1) + DP.at(i-1).at(0).at(1);
            DP.at(i).at(1).at(2) = DP.at(i-1).at(1).at(2) + DP.at(i-1).at(1).at(1)*9 + DP.at(i-1).at(0).at(1)*(lstr.at(i)-1) + DP.at(i-1).at(0).at(2);
            DP.at(i).at(1).at(3) = DP.at(i-1).at(1).at(3) + DP.at(i-1).at(1).at(2)*9 + DP.at(i-1).at(0).at(2)*(lstr.at(i)-1) + DP.at(i-1).at(0).at(3);
            DP.at(i).at(0).at(0) = 0;
            DP.at(i).at(0).at(1) = DP.at(i-1).at(0).at(0);
            DP.at(i).at(0).at(2) = DP.at(i-1).at(0).at(1);
            DP.at(i).at(0).at(3) = DP.at(i-1).at(0).at(2);
        }
    }

    cout << DP.at(lenN-1).at(1).at(K)+DP.at(lenN-1).at(0).at(K) << endl;


    return 0;
}


Measured memory_bytes: 256
local n, k = io.read("*n", "*n")
local isodd = k % 2 == 1
local hk = math.floor((k + 1) / 2)
local edge = {}
for i = 1, n do
  edge[i] = {}
end
local edgelist = {}
for i = 1, n - 1 do
  local a, b = io.read("*n", "*n")
  table.insert(edge[a], b)
  table.insert(edge[b], a)
  edgelist[i] = {a, b}
end

local function solve(st1, st2)
  local tasks = {}
  local len = {}
  for i = 1, n do
    len[i] = -1
  end
  if isodd then
    len[st1], len[st2] = 1, 1
    tasks[1] = st1
    tasks[2] = st2
  else
    len[st1] = 0
    tasks[1] = st1
  end
  for i = 1, n do
    local src = tasks[i]
    for j = 1, #edge[src] do
      local dst = edge[src][j]
      if -1 == len[dst] then
        len[dst] = len[src] + 1
        table.insert(tasks, dst)
      end
    end
  end
  local c = 0
  for i = 1, n do
    if hk < len[i] then c = c + 1 end
  end
  return c
end
local mmi = math.min
local mincnt = 1000000007
if isodd then
  for i = 1, n - 1 do
    mincnt = mmi(mincnt, solve(edgelist[i][1], edgelist[i][2]))
  end
else
  for i = 1, n do
    mincnt = mmi(mincnt, solve(i))
  end
end
print(mincnt)


Measured memory_bytes: 5240