akhauriyash/Code-Regression huggingface dataset:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
CSF = [LIST() for i in range(N-1)]

for i in range(N):
    time = 0
    for j in range(i, N-1):
        if time < CSF[j][1]:
            time = CSF[j][1]
        elif time % CSF[j][2] == 0:
            pass
        else:
            time += CSF[j][2] - time % CSF[j][2]
        time += CSF[j][0]
    print(time)




Measured memory_bytes: 5840
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
 
#define pb push_back
#define mk make_pair
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pf(a) printf("%d\n",a);
#define pfl(a) printf("%lld\n",a);
#define TEST int test; cin >> test;while(test--)
#define ii pair<int,int>
#define iil pair<ll,ll>
#define loop(i,a,b) for(int i = a ; i < b ; i++)
#define INF 2147483647
 
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const double pi = acos(-1.0);
 
 
ll n, m, x;
 
void solve()
{
   cin >> n;
   ll x = n%10;
   if(x == 2 || x == 4 || x == 5 || x == 7 || x == 9) cout << "hon" << endl;
   else if(x == 3) cout << "bon" << endl;
   else cout <<"pon" << endl;
}
 
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
    return 0;
}

Measured memory_bytes: 3576
s = input()
i = 1
now = s[0]
ans = 1
while i <=len(s)-1:
    if i >=len(s):
        break
    if len(now)==2:
        now = s[i]
        i += 1
        ans+=1
        continue
    if len(now)==1:
        if now != s[i]:
            now = s[i]
            i +=1
            ans+=1
        else:
            if i+2 <= len(s):
                now = s[i:i+2]
                ans +=1
            i +=2
            continue
print(ans)

Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5+5;
int prenum[maxn],prexor[maxn];
long long ans,n;

bool check(int l,int r) {
	if (prenum[r] - prenum[l-1] == (prexor[r] ^ prexor[l-1])) return true;
	return false;
}

void solve(int beg) {
	int l,r,ret;
	l = beg; r = n;
	while (l <= r) {
		int mid = (l+r)/2;
		if (check(beg,mid)) {
			l = mid+1;
			ret = mid;
		}else{
			r = mid-1;
		}
	}
	ans += ret-beg+1;
}

int main() {
	scanf("%lld",&n);
	for (int i = 1; i <= n; i++) {
		int num; scanf("%d",&num);
		prenum[i] = prenum[i-1]+num;
		prexor[i] = prexor[i-1]^num;
	}
	for (int i = 1; i <= n; i++) {
		solve(i);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5300
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    char s[101];

    cin >> s;

    for (int i = 0; s[i]; ++i)
    {
        if ((i + 1) % 2 == 0 && s[i] == 'R')
        {
            cout << "No\n";
            return 0;
        }
        else if ((i + 1) % 2 == 1 && s[i] == 'L')
        {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
main(){
    ll n,m;
    string s,t;
    cin>>n>>m>>s>>t;
    ll g=gcd(n,m);
    for(ll i=0;i<g;i++)if(s[i*n/g]!=t[i*m/g]){
        cout<<-1;
        return 0;
    }
    cout<<n*m/g;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(short i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
const short MAX_H=50,MAX_W=50;
const short INF=1e4;
short dp[MAX_H+1][MAX_W+1];
char s[MAX_W+1];
int main(){
	short H,W;
	scanf("%hd %hd",&H,&W);
	REP(i,H+1){
		REP(j,W+1){
			dp[i][j]=INF;
		}
	}
	REP(i,H){
		scanf("%s",s);
		REP(j,W){
			dp[i+1][j+1]=s[j]-'0';
		}
	}
	FOR(i,1,H+1){
		FOR(j,1,W+1){
			if (i-1 || j-1){
				dp[i][j]+=min(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	printf("%u\n",dp[H][W]);
	return 0;
}

Measured memory_bytes: 1200
seq = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input(""))
print(seq[k-1])

Measured memory_bytes: 3060
#include<stdio.h>

int main()

{
    long long a, i, sum=0 ;

    scanf("%lld", &a) ;

    for(i=0 ; i<=a ;i++)
    {
        if(i%3!=0 && i%5!=0)
        {
            sum=sum+ i;
        }
    }

    printf("%lld", sum);

    return 0;

}


Measured memory_bytes: 1704
from sys import stdin

n, m = map(int, stdin.readline().split())
A = []
B = []
for _ in range(n):
    A.append(stdin.readline().strip())
for _ in range(m):
    B.append(stdin.readline().strip())


def is_in(B, A):
    def cmp(A, B, x, y):
        for i in range(m):
            for j in range(m):
                if A[i+y][j+x] != B[i][j]:
                    return False
        return True

    x_shift = len(A[0]) - len(B[0])
    y_shift = len(A) - len(B)
    for x in range(0, x_shift+1):
        for y in range(0, y_shift+1):
            result = cmp(A, B, x, y)
            if result:
                return True
    return False

if is_in(B, A):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3316
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            if (a >= 3200)
            {
                Console.WriteLine(s);

            }
            else
            {
                Console.WriteLine("red");
            }

        }
        //static void Main(string[] args)
        //{
        //    var temp = new Atcoder.ABC130.D();
        //    temp.Run();
        //}

    }
}

Measured memory_bytes: 13140
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

ll naive2(VI w) {
	ll N = w.size();
	ll K = 0;
	while(1) {
		bool p=0;
		REP(i, N) if(w[i]>=N) {
			p=1;
			ll co = w[i]/N;
			w[i]-=co*N;
			REP(j, N) if(j!=i) {
				w[j]+=co;
			}
			K += co;
		}
		if(!p) break;
	}
	return K;
}

int main() {
	//ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		VI w(N);
		REP(i, N) cin>>w[i];
		
		cout<<naive2(w)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
a= [int(i) for i in input().split()] 
b= sorted([int(i) for i in input().split()] )
c= sorted([int(i) for i in input().split()] )
x =0
for z in range(-100,101):
    if a[2] < z <= a[3]:
       if b[-1]<z:
         if c[0]>=z:
              x = 1
if x == 0:
    print("War") 
if x == 1:
    print("No War")



Measured memory_bytes: 3064
import java.util.*;

public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char[] C = S.toCharArray();
    if (C[0] == C[1] && C[1] == C[2]) System.out.println("No");
    else System.out.println("Yes");
    
  }
}


Measured memory_bytes: 23892
#?±±???(?????????)?????\???
deck = input()
#????????????(-)????±±????????\?????????????????§??????
while deck != "-":
    #?????°?????\???
    times = int(input())
    #????????????????????????
    shuffle = list(deck)
    #?????????????????????????´?
    deck_length = len(deck)
    #times????????°???????????£?????????
    for i in range(times):
        #????????§?????????????????\????????????????????§?????£?????????
        val = int(input())
        shuffle = shuffle[val:] + shuffle[:val]
    #???????????????
    print("".join(shuffle))
    #?¬?????±±????????\???
    deck = input()

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

int main() {
	int N;
	cin >> N;
	vector <double> A(N);
	double sum = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		A[i] = 1 /A[i];
		sum += A[i];
	}

	cout << 1 / sum << endl;
}

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


int gcd(int x,int y){
	if(!y)return x;
	return gcd(y,x%y);
}

int N,A[1000000];
bool K[1000001];

int main(){
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	int t=0;
	for(int i=0;i<N;i++){
		t=gcd(t,A[i]);
	}
	if(t==1){
		for(int i=0;i<N;i++){
			for(int j=2;j*j<=A[i];j++){
				if(A[i]%j==0){
					if(K[j]){
						puts("setwise coprime");
						return 0;
					}
					K[j]=true;
					while(A[i]%j==0){
						A[i]/=j;
					}
				}
			}
			if(A[i]!=1){
				if(K[A[i]]){
					puts("setwise coprime");
					return 0;
				}
				K[A[i]]=true;
			}
		}
		puts("pairwise coprime");
	}
	else{
		puts("not coprime");
	}
}


Measured memory_bytes: 7468
const main = arg => {
  const [a,b,c,d] = arg.trim().split(' ').map(x => BigInt(x));
  let max = a * c
  if (a * d > max) max = a * d
  if (b * c > max) max = b * c
  if (b * d > max) max = b * d
  console.log(max.toString())
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29556
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    int x, y;
    cin >> x >> y;
    for (int a = 0; a <= x; a++) {
        int b = x - a;
        int d = a * 2 + b * 4;
        if (d == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3636
def solve():
    N, M = list(map(int, input().split()))
    s = [0] * (N+1)
    
    for _ in range(M):
        l, r = list(map(int, input().split())) 
        s[l] += 1
        if r+1 != N+1:
            s[r+1] -= 1
    
    cnt = 0
    ruiseki = [0]
    for i in range(1, N+1):
        ruiseki.append(ruiseki[i-1] + s[i])
        if ruiseki[i] == M:
            cnt += 1

    print(cnt)

if __name__ == "__main__":
    solve()

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

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define zeroend __builtin_ctz
#define ones __builtin_popcount
#define ends "\n"
#define space ' '
typedef long long ll;
typedef pair<int, int> pii;

/*
void solve(int i, int j, string s){
	if(i==0)
		ans.insert(s2.substr(0, j)+s);
	else if(j==0)
		ans.insert(s1.substr(0, i)+s);
	else if(s1[i-1]==s2[j-1])
		solve(i-1, j-1, s1[i-1]+s);
	else{
		if(dp[i-1][j]<=dp[i][j-1])
			solve(i-1, j, s1[i-1]+s);
		if(dp[i-1][j]>=dp[i][j-1])
			solve(i, j-1, s2[j-1]+s);
	}
}*/


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

	for(int i=1; i<n; ++i){
		for(int j=0; j<i; ++j){
			if(a[j]>a[i]&&low[i]<high[j]+1)
				low[i]=high[j]+1;
			else if(a[j]<a[i]&&high[i]<low[j]+1)
				high[i]=low[j]+1;
		}
		ans=max({ans, low[i], high[i]});
	}

	cout << ans << ends;


*/

const int N = 1000, M = 1e9+7;

ll dp[N+1][N+1];
//array<ll, 3> dp;
//set<string> ans;
//vector<int> low(N, 1), high(N, 1);
//ll v[N], m[N];

int n, m;
string s[N];

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

	for(int i=0; i<n; ++i)
		cin >> s[i];
	dp[1][1]=1;
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=m; ++j)
			if((i!=1||j!=1) && s[i-1][j-1]=='.')
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%M;


	cout <<	dp[n][m] << space;

}

Measured memory_bytes: 13312
import sys
from collections import deque

input = sys.stdin.readline
H, W = map(int, input().split())

grid = []
for _ in range(H):
    grid.append(list(input().strip()))

q = deque()
# x, y, count, pre color
q.append((0, 0, 1 if grid[0][0] == "#" else 0, grid[0][0]))

visited = [[-1 for _ in range(W)] for _ in range(H)]
ans = float("inf")
while q:
    x, y, count, pre = q.popleft()
    # print(x, y, count, pre)
    v_score = visited[y][x]
    if v_score != -1 and v_score <= count:
        continue
    visited[y][x] = count

    for dx, dy in ((1, 0), (0, 1)):
        nx = x + dx
        ny = y + dy
        nc = count
        if nx < 0 or W <= nx or ny < 0 or H <= ny:
            continue
        n_color = grid[ny][nx]
        if n_color != pre and n_color == "#":
            nc += 1
        if nx == W-1 and ny == H-1:
            ans = min(ans, nc)
            print(ans)
            sys.exit()
        else:
            if visited[ny][nx] != -1 and visited[ny][nx] <= nc:
                continue
            if count == nc:
                q.appendleft((nx, ny, nc, n_color))
            else:
                q.append((nx, ny, nc, n_color))

# print(visited)
print(ans)  

Measured memory_bytes: 74816
#include <stdio.h>

int main() {

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

    int counter = 0;
    for (int i = n; i >= 1; i--) {

        if (i % 2 == 1) {

            int cnt = 1;
            int half = i / 2;
            //printf("%d %d\n", i, half);
            for (int j = half; j >= 1; j--) {

                if (i % j == 0) {
                    cnt++;
                }

            }

            //printf("%d %d\n",i, cnt);

            if (cnt == 8) {
                counter++;
            }

        }

    }
    printf("%d", counter);

    return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;

	vector<int> X(N);

	rep(i, 0, N)
	{
		cin >> X[i];
	}

	int ans = INF;
	rep(i, 0, 110)
	{
		int sum = 0;
		rep(j, 0, N)
		{
			sum += (i - X[j])*(i - X[j]);
		}
		chmin(ans, sum);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    char c[2][4];
    int i, s;

    scanf("%s", c[0]);
    scanf("%s", c[1]);

    s=0;
    for (i=0; i<3; i++) {
        if (c[0][i]==c[1][2-i]) s++;
    }

    if (s==3)   printf("YES\n");
    else        printf("NO\n");

    return 0;
}

Measured memory_bytes: 128
spot = [int(input()) for i in range(5)]
k = int(input())

D = True

for i in range(len(spot)):
    for j in range(i+1, len(spot)):
        if spot[j] - spot[i] > k:
            D = False

if D:
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll=long long ;
map<ll,ll>mp;
void calculate(ll n)
{
	while(n%2==0)
	{
		mp[2]++;
		n /= 2;
	}
	for(ll i=3;i<=sqrt(n);i+=2)
	{
		while(n%i==0)
		{
			mp[i]++;
			n /= i;
		}
	}
	if(n>2)
	{
		mp[n]++;
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,i,j,k,ct=0;
	cin>>n;
	if(n==1)
	{
		cout<<0;
		return 0;
	}
	calculate(n);
	for(auto it=mp.begin();it!=mp.end();it++)
	{
		ll a=1,b=1,c=-(it->second);
		c *= 2;
		ll k=(b*b)-(4*a*c);
		//cout<<k<<" ";
		ll x1=(-b+sqrt(k))/(2*a);
		ll x2=(-b-sqrt(k))/(2*a);
		if(x1>0) ct += x1;
		if(x2>0) ct += x2;
	}	
	cout<<ct;
	return 0;
}

Measured memory_bytes: 3672
object Main{
  def main(args: Array[String]){
    if (sys.env.getOrElse("TEST", "")=="1"){
      println(test());
    }else{
      val input=io.Source.stdin.getLines().mkString("\n");
      println(solve(input).trim());
    }
  }
 
  /*def solve(input:String):String={
    val List(n,y)=input.split(" ").map(_.toInt).toList;
    for (a <- 0 to n){
      for (b <- 0 to n-a){
        val c=n-a-b;
        if(a*10000+b*5000+c*1000==y){
          return s"${a} ${b} ${c}";
        }
      }
    }

    "-1 -1 -1"
  }*/

  def solve(input:String):String={
    val List(n,y)=input.split(" ").map(_.toInt).toList;
    val (a,b,c)=f(n,y,(0,0,y/1000));

    s"${a} ${b} ${c}"
  }

  def f(n:Int,y:Int,v:(Int,Int,Int)):(Int,Int,Int)={
    val (a,b,c)=v;
    if (a + b + c == n) {
        (a,b,c)
    }else if (a+b+c < n) {
        (-1,-1,-1)
    }else if( c >= 5 && n + 4 <= a + b + c) {
        f(n,y,(a,b+1,c-5))
    } else if (b >= 2 ){
        f(n,y,(a+1,b-2,c))
    } else {
        (-1,-1,-1)
    }
  }
 
  val tests=List("""9 45000""" -> """0 9 0""",
    """20 196000""" -> """-1 -1 -1""",
"""1000 1234000"""->"""14 27 959""",
"""2000 20000000"""->"""2000 0 0""");
 
  def test():String= {
    return tests.map{case (i,o)=>(i.trim(),o.trim())}.zipWithIndex.map{case ((input,outputExpect),i)=>{
      val output=solve(input).trim();
      s"test${i+1}:"+(if(output==outputExpect){
        "Passed"
      }else{
        s"Failed\nexpect:\n${outputExpect}\noutput:\n${output}"
      })
    }}.mkString("\n");
  }
}

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

#define SPEED cin.tie(0);ios::sync_with_stdio(false);
template <class T> void chmax(T& a, const T b){a=max(a,b);}

int main() {
    SPEED
    int N; cin >> N;
    vector<int> V(N+1),W(N+1);
    for(int i = 1; i <= N; ++i) cin >> V[i] >> W[i];

    //O(Q)
    constexpr int nl = 1<<10,nr=1<<8,L_max=100001;
    vector<int> msb(nl,0);
    for(int i = 1; i < nl; ++i) msb[i]=31-__builtin_clz(i);

    vector<int> bit_w_dp(nl,0);
    vector<int> bit_v_dp(nl,0);
    vector<vector<int>> dp(nl,vector<int>(L_max,0));
    //前計算
    int m = min(nl,N+1);
    for(int n = 1; n < m; ++n) {
        int k = 2*n;
        vector<int> l;
        while(k/=2) l.push_back(k);
        int sz=l.size();
        //bit全探索
        for(int i = 1; i < (1<<sz); ++i) {
            bit_w_dp[i]=bit_w_dp[i^(1<<msb[i])]+W[l[msb[i]]];
            bit_v_dp[i]=bit_v_dp[i^(1<<msb[i])]+V[l[msb[i]]];
            if(bit_w_dp[i]<=L_max) chmax(dp[n][bit_w_dp[i]],bit_v_dp[i]);
        }
        //累積max
        for(int i = 1; i < L_max; ++i) {
            chmax(dp[n][i],dp[n][i-1]);
        }
    }

    int Q; cin >> Q;
    string ans_str="";

    //クエリ
    while(Q--) {
        int p,L,l_idx=0;; cin >> p >> L;
        vector<int> r;
        p *= 2;
        while(p/=2) {
            if(p<nl) chmax(l_idx,p);
            else r.push_back(p);
        }
        int sz = r.size(),ans=dp[l_idx][L];
        //bit全探索
        for(int i = 1; i < (1<<sz); ++i) {
            bit_w_dp[i]=bit_w_dp[i^(1<<msb[i])]+W[r[msb[i]]];
            bit_v_dp[i]=bit_v_dp[i^(1<<msb[i])]+V[r[msb[i]]];
            if(bit_w_dp[i]<=L) chmax(ans,dp[l_idx][L - bit_w_dp[i]]+bit_v_dp[i]);
        }
        ans_str += to_string(ans)+"\n";
    }
    cout << ans_str;

    return 0;
}


Measured memory_bytes: 408236
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    scanf("%d",&n);
    if(n==2) return cout<<-1<<endl,0;
    if(n==3) return puts("aa.\n..a\n..a"),0;
    vector<string> q={"aabc","ddbc","bcaa","bcdd"},
            p={"aabbc","cdd.c","c..ba","a..ba","accdd"},
            h={".llkkj","iihh.j","ggfe..","..fedd","c...ba","c...ba"},
            s={".nnmmll","kkjji..","hhggi..","f....ed","f....ed","....cba","....cba"};
    vector<vector<char>> ans(n,vector<char>(n,'.'));
    fr(i,n/4){
        fr(I,4) fr(J,4){
            ans[4*i+I][4*i+J]=q[I][J];
        }
    }
    if(n%4==1) fr(i,5) fr(j,5) ans[n-5+i][n-5+j]=p[i][j];
    if(n%4==2) fr(i,6) fr(j,6) ans[n-6+i][n-6+j]=h[i][j];
    if(n%4==3) fr(i,7) fr(j,7) ans[n-7+i][n-7+j]=s[i][j];
    fr(i,n){
        fr(j,n) printf("%c",ans[i][j]);
        puts("");
    }
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;

ll n;
vector<vector<char>> s(100001);
vector<string> ss;

void input(void){
    cin>>n;
    rep(i,n){
        rep(j,10){
        char c;
        cin>>c;
        s[i].push_back(c);
    }
    }
}

void solve(void){
	rep(i,n){
    sort(all(s[i]));
	}
	rep(i,n){
		string aa="";
		rep(j,10){
		aa+=s[i][j];
		}
		ss.push_back(aa);
	}
	sort(all(ss));
	ll ans=0,a=0;
    rep(i,n-1){
        if(ss[i]==ss[i+1])a++;
        else{
            ans+=(a*(a+1))/2;
            a=0;
        }
    }
    ans+=a*(a+1)/2;
    cout<<ans<<endl;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

Measured memory_bytes: 12788
def main():
    length = int(input())
    distance = list(map(int, input().split()))
    count_distance = {}
    for d in distance:
        if d in count_distance:
            count_distance[d] += 1
        else:
            count_distance[d] = 1
    count_distance = sorted(count_distance.items(), key=lambda x: x[0])
    answer = 0
    mod = 998244353
    if distance[0] == 0 and count_distance[0][1] == 1:
        answer = 1
        for i in range(1, len(count_distance)):
            if count_distance[i][0] == count_distance[i - 1][0] + 1:
                answer = (answer * pow(count_distance[i - 1][1], count_distance[i][1], mod)) % mod
            else:
                answer = 0
                break
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 21724
#include <stdio.h>
int main(){
    int a,b;
    int i,j;
    for(;;){
        scanf("%d %d",&a,&b);
        if(a==0&&b==0) break;
        for(i=0;i<a;i++){
            for(j=0;j<b;j++){
                if(i==0||i==a-1||j==0||j==b-1) printf("#");
                else printf(".");
            }
            puts("");
        }
        puts("");
    }
    return 0;
}


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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

//昇順
int asc(const void* a, const void* b){
    return *(int*)a-*(int*)b;
}

//降順
int desc(const void* a, const void* b){
    return *(int*)b-*(int*)a;
}

int main(void){
    int N,K;
    scanf("%d%d",&N,&K);

    //それぞれN以下の自然数の中で、もともとKの倍数と2倍して初めてKの倍数になるものの数
    long k1=0;
    long k2=0;
    for(int i=1;i<=N;i++){
        if(i%K==0) k1++;
        else if((i*2)%K==0) k2++;
    }


    long ans=(k1*k1*k1)+(k2*k2*k2);
    printf("%ld\n",ans);

    return 0;
}

//a+b,b+c,c+aがKの倍数→2*a,2*b,2*cがKの倍数

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int R;
  cin >> R;
  
  if (R < 1200){
    cout << "ABC" << endl;
  }
  else if ( R >= 1200 && R < 2800){
    cout << "ARC" << endl;
  }
  else{
    cout << "AGC" << endl;
  }
}

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

int main() {
    map<int,int> m;
    int n,k;
    cin >> n>>k;
    cout << (n%k==0? n/k:n/k + 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> G(n);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> ans(n,-1);
  queue<int> que;
  ans.at(0)=0;
  que.push(0);
  while(!que.empty()){
    int v=que.front();
    que.pop();
    for(int nv: G[v]){
      if(ans.at(nv)!=-1){
        continue;
      }
      ans.at(nv)=v;
      que.push(nv);
    }
  }
  cout << "Yes" << endl;
  for(int i=1;i<n;i++){
    ans.at(i)++;
    cout << ans.at(i)<< endl;
  }
}

Measured memory_bytes: 10172
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	int N;
	while (cin >> N, N) {
		int S = N * (N + 1) / 2;
		vector<long long> v(S);
		for (int i = 0; i < S; ++i) cin >> v[i];
		long long G = -1;
		vector<long long> evens;
		long long oddmin = ~(1LL << 63);
		for (int i = 0; i < S; ++i) {
			if (v[i] % 2 == 0) {
				if (G == -1) G = v[i];
				else G = gcd(G, v[i]);
				evens.push_back(v[i]);
			}
			else {
				oddmin = min(oddmin, v[i]);
			}
		}
		sort(evens.begin(), evens.end());
		for (int i = 0; i < N; ++i) evens[i] /= G;
		long long coeff = oddmin / evens[0] / evens[1];
		long long sqcoeff = sqrt(coeff + 0.5);
		cout << G / sqcoeff << endl;
		for (int i = 0; i < N; ++i) {
			if (i) cout << ' ';
			cout << evens[i] * sqcoeff;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3320
def main():
	N = int(input())
	S = input()
	dpe = [0]*(N+1)
	dpw = [0]*(N+1)

	for i in range(N):
		if S[i] == "E" and i > 0:
			dpe[i-1] += 1
		elif S[i] == "W" and i < N-1:
			dpw[i+1] += 1

	for i in range(N-1, 0, -1):
		dpe[i-1] += dpe[i]

	for i in range(N-1):
		dpw[i+1] += dpw[i]

	ans = 3*(10**5)
	for i in range(N):
		ans = min(ans, dpe[i]+dpw[i])

	print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 27040
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll,ll>
#define pint pair<int,int>
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 500010
#define endl '\n'
#define mp make_pair
#define INF INT_MAX
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define setbits(x) __builtin_popcountll(x)            //counts no of ones in binary representation
#define w(t)     int t; cin>>t; while(t--)
#define pi 3.141592653589793238
#define sortt(v)  sort(v.begin(),v.end())
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;

bool isprime(ll n){			//to check whteher no is prime or not
	if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

int main(){
	fast;
	ll n;
	cin>>n;
	char c[n];
	forn(i,n)	cin>>c[i];
	ll low=0,high=n-1;
	ll ans=0;
	while(low<high){
		if(c[low]=='R'){
			low++;
			continue;
		}
		if(c[high]=='W'){
			high--;
			continue;
		}
		swap(c[low],c[high]);
		low++;
		high--;
		ans++;
	}
	cout<<ans;
	//cout<<"Case #"<<x<<": "<<y<<endl;
}

/*for(int i=2;i<=n;i++){
			if(v[i].size()==0)	break;
			for(int j=0;j<v[i].size();j++){
				cout<<v[i-1][0]<<' '<<v[i][j]<<endl;
			}
		}*/

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

#define int long long
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define reps(i, n) for (int (i) = 1; (i) <= (n); (i)++)
typedef vector<int> vint;
typedef pair<int, int> pint;
constexpr double PI = 3.141592653589793238462643383279;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
        cerr << fixed << setprecision(20);
    };
} init;

int A, B, C;
signed main() {
    cin >> A >> B >> C;
    if (A & 1 && B & 1 && C & 1) { cout << min({A * B, A * C, B * C}) << endl; }
    else { cout << 0 << endl; }
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std;
int n,m,ans=0x3f3f3f3f;
int a[100000+5];
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n-m+1;i++){
		int j=m+i-1;
		ans=min(ans,min(abs(a[i])+abs(a[j]-a[i]),abs(a[j])+abs(a[j]-a[i])));
	}
	if(ans==0x3f3f3f3f) cout<<0<<endl;
	cout<<ans<<endl;
}

Measured memory_bytes: 640
/*
********************
Author : MIHIR ARORA
********************
*/
#include <bits/stdc++.h>
using namespace std;
#define fast cin.tie(NULL); cout.tie(NULL); 
#define input int n; scanf("%d",&n); int*arr = new int[n];  for(int i=0;i<n;i++) scanf("%d",&arr[i]);  
#define inputs int n; scanf("%d",&n); char str[n];   cin>>str;   

typedef long long int ll;
const int mod=1e9+7; 
ll add(ll a, ll b)
{
    return (a%mod+b%mod)%mod;
}

ll mul(ll a, ll b)
{
    return ((a%mod)*(b%mod))%mod;
}

ll sub(ll a, ll b)
{
    return ((a%mod) - (b%mod))%mod;
}
int n;
inline int rec(int arr[100000][3], int idx , int taken, int cache[100001][3])
{
  if(idx==n)
      return 0; 
    if(cache[idx][taken]!=-1)
        return cache[idx][taken]; 
    int ans=-1e9; 
   for(int i=0;i<3;i++)
   {
       if(i!=taken)
       {
           ans= max(ans, arr[idx][i] + rec(arr,idx+1,i,cache)); 
       }
   }
    
  cache[idx][taken] =  ans; 
    return ans; 
}
inline void solve()
{

    cin>>n; 
    int arr[n][3]; 
    for(int i=0;i<n;i++)
        for(int j=0;j<3;j++)
            cin>>arr[i][j]; 
    int cache[100001][3];
    memset(cache,-1,sizeof(cache)); 
  cout<<  rec(arr,0,3,cache); 
    
}
int main()
{ 
    fast; 

        solve();
 
    
    
}

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



int main() {
    long long H, W;
    cin >> H >> W;

    long long box = H * W;
    if (box == 1) cout << 1 << endl;
    else if (H == 1 || W == 1) cout << 1 << endl;
    else if (box % 2 ==0) cout << box/2 << endl;
    else cout << box /2 + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
import math
n,c,d= map(int, input().split())
mod = pow(10,9)+7

def comb(n,k):
    x=1
    y=1
    for i in range(1,k+1):
        x*=(n+1-i)
        x%=mod
        y*=i
        y%=mod
    return x*pow(y,mod-2,mod)


ans=(pow(2,n,mod)-1-comb(n,c)-comb(n,d))%mod
print(ans)

Measured memory_bytes: 38512
n,q = map(int,input().split())
s = input()
t = [0]*(n+1)
for i in range(n):
    t[i+1] = t[i] +(1 if s[i:i+2] == "AC" else 0)
for i in range(q):
    l,r = map(int , input().split())
    print(t[r-1]-t[l-1])



Measured memory_bytes: 9284
using System.Text;
using System;

public class P
{
    public int x { get; set; }
    public int y { get; set; }
}

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var sb = new StringBuilder();
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var a = new int[n, n];
            makeMS(a, n);
            print(a, n, sb);
            Console.Write(sb);
        }
    }
    static void print(int[,] a, int n, StringBuilder sb)
    {
        var b = new string[n, n];
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
                sb.Append(string.Format("{0,4}", a[i, j]));
            sb.Append("\n");
        }
    }
    static P getNXNY(int[,] a, int n, int x, int y)
    {
        var nx = x + 1;
        var ny = y + 1;
        LA1:;
        if (nx >= n) nx = 0;
        if (ny >= n) ny = 0;
        if (ny < 0) ny = n - 1;
        if (a[nx, ny] == 0) return new P { x = nx, y = ny };
        else { nx++; ny--; }
        goto LA1;
    }
    static void makeMS(int[,] a, int n)
    {
        var p = 1;
        var x = n / 2 + 1; var y = n / 2;
        a[x, y] = p++;
        while (p <= n * n)
        {
            var t = getNXNY(a, n, x, y);
            var nx = t.x;
            var ny = t.y;
            a[nx, ny] = p++;
            x = nx; y = ny;
        }
    }
}



Measured memory_bytes: 19944
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [a, b, n] <- getIntList
    let (pa, qa) = a `divMod` b
        (pn, qn) = n `divMod` b
        qx = if pn == 0 then qn else b-1
    print $ pa * qx + (qa * qx) `div` b

Measured memory_bytes: 3780
import itertools
n,m,q = map(int, input().split())
a = list()
b = list()
c = list()
d = list()
for i in range(q):
    hoge,hoge2,hoge3,hoge4 = map(int, input().split())
    a.append(hoge)
    b.append(hoge2)
    c.append(hoge3)
    d.append(hoge4)
l = list(range(1,m+1))
x = list(itertools.combinations_with_replacement(l,n))
max_point = 0
bestlist=0
for i in x:
    point = 0
    for j in range(q):
        if i[b[j]-1] - i[a[j]-1] == c[j]:
            point += d[j]
    max_point = max(point, max_point)
print(max_point)



Measured memory_bytes: 21656
def main():
    import numpy as np
    n, l = map(int,input().split())
    inlis = []
    taishou = 10 *10000
    flag = 0

    for i in range(l, l+n):
        if taishou > np.abs(i):
            taishou = np.abs(i)
            if i < 0:
                flag = 1
        inlis.append(i)
    if flag == 0:
        print(sum(inlis) - taishou)
    else:
        print(sum(inlis) + taishou)

    
        

    
if __name__ == "__main__":
    main()


Measured memory_bytes: 27144
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

require 'prime'

a,b = inp
pr = Prime.prime_division(a)
ans = 0
pr.each do |d|
  if(b%d[0] == 0)
    ans += 1
  end
end
p ans + 1

Measured memory_bytes: 2300
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 1010000;
const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;

//typedef pair<int, int> P;

const int MAX_V = 2020;
const int MAX_LOG_V = 15;
vector<int> G[MAX_V];
int root;

int parent[MAX_LOG_V][MAX_V];
int depth[MAX_V];

void dfs(int v, int p, int d) {
	parent[0][v] = p;
	depth[v] = d;
	for (int i = 0; i < G[v].size(); i++) {
		if (G[v][i] != p)dfs(G[v][i], v, d + 1);
	}
}

void init(int V) {
	dfs(root, -1, 0);
	for (int k = 0; k + 1 < MAX_LOG_V; k++) {
		for (int v = 0; v < V; v++) {
			if (parent[k][v] < 0)parent[k + 1][v] = -1;
			else parent[k + 1][v] = parent[k][parent[k][v]];
		}
	}
}

int lca(int u, int v) {
	if (depth[u] > depth[v]) {
		swap(u, v);
	}
	for (int k = 0; k < MAX_LOG_V; k++) {
		if ((depth[v] - depth[u]) >> k & 1) {
			v = parent[k][v];
		}
	}
	if (u == v)return u;
	for (int k = MAX_LOG_V - 1; k >= 0; k--) {
		if (parent[k][u] != parent[k][v]) {
			u = parent[k][u];
			v = parent[k][v];
		}
	}
	return parent[0][u];
}
int dist(int a, int b) {
	int par = lca(a, b);
	return depth[a] + depth[b] - 2 * depth[par];
}


int N, K;
int A[100010], B[100010];
signed main() {
	cin >> N >> K;
	
	REP(i, N-1) {
		cin >> A[i] >> B[i];
		A[i]--; B[i]--;
		G[A[i]].pb(B[i]);
		G[B[i]].pb(A[i]);
	}
	root = 0;
	init(N);
	int ans = INF;
	if (K % 2 == 0) {
		REP(i, N) {
			int res = 0;
			REP(j, N) {
				if (j == i)continue;
				if (dist(i, j) > K / 2)res++;
			}
			ans = min(ans, res);
		}
	}
	else {
		REP(i, N - 1) {
			int res = 0;
			int l = A[i], r = B[i];
			REP(j, N) {
				if (j == l || j == r)continue;
				int d = min(dist(l, j), dist(r, j));
				if (d > (K - 1) / 2)res++;
			}
			ans = min(ans, res);
		}
	}
	print(ans);
	/*while (true) {
		int x, y; cin >> x >> y;
		pe(depth[x]); print(depth[y]);
		print(lca(x, y));
	}*/
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
LL mod=1000000007;
LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


vector<int> fact;
vector<int> inver(200001);
 
int combi(int n,int r){
    if(n<r||n<0||r<0) return 0;
    return fact[n]%mod*inver[n-r]%mod*inver[r]%mod;
}
 
 
int fpow(int a, int n){
    int x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}
 
void set_combi(){
    int s=1;
    fact.push_back(1);
    for(int i=1;i<mod;i++){
        s*=i;
        s%=mod;
        fact.push_back(s);
    }
    inver[mod-1]=fpow(fact[mod-1],mod-2);
    for(int i=mod-1;i>=1;i--){
        inver[i-1]=inver[i]*i%mod;
    }
}
 

int main(){
    int p;cin >> p;
    mod = p;
    set_combi();
    vector<int> a(p);
    for (int i = 0; i < p; i++) {
        cin >> a[i];
    }
    vector<int> b(p,0);
    for (int i = 0; i < p; i++) {
        if(a[i]){
            int t = 1;
            for (int j = 0; j < p; j++) {
                b[p-j-1] = (b[p-j-1] - (combi(p-1,p-j-1) * t %p) + p)%p;
                t = (t * (-i) %p + p)%p;
            }
            b[0] = (b[0] + 1)%p;
        }
    }
    for (int i = 0; i < p; i++) {
        cout << b[i] << (i==p-1?"\n":" ");
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
 int A,B;
  cin>>A>>B;
  int ans=A+B;
  if(ans<=A-B)
    ans=A-B;
  if(ans<=A*B)
    ans=A*B;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
/*void bsort(int a[],int n){
  int i,j;
  for(i=0;i<n-1;i++){
    for(j=n-1;j>i;j--){
      if(a[j-1]>a[j]){
        int temp=a[j];
        a[j]=a[j-1];
        a[j-1]=temp;
      }
    }
  }
}*/

/*void qsort(int x[ ], int left, int right)
{
    int i, j;
    int pivot;

    i = left;
    j = right;

    pivot = x[(left + right) / 2];

    while (1) {

        while (x[i] < pivot)
            i++;

        while (pivot < x[j])
            j--;
        if (i >= j)
            break;

        int temp=x[j];
        x[j]=x[i];
        x[i]=temp;

        i++;
        j--;
    }
}*/
int int_sort( const void * a , const void * b ) {
  /* 引数はvoid*型と規定されているのでint型にcastする */
  if( *( int * )a < *( int * )b ) {
    return -1;
  }
  else
  if( *( int * )a == *( int * )b ) {
    return 0;
  }
  return 1;
}
int main(void){
  int n,i;
  int min=100000;
  int max=0;
  scanf("%d",&n);
  int d[n];
  for(i=0;i<n;i++){
    scanf("%d",&d[i]);
  }
  for(int j=0;j<n;j++){
    if(d[j]<min){
      min=d[j];
    }
    if(d[j]>max){
      max=d[j];
    }
  }
  //bsort(d,n);
  qsort(d,n,sizeof(d[0]),int_sort);
  for(i=0;i<n;i++){

  }
  printf("\n%d",d[n/2]-d[n/2-1]);
  return 0;
}


Measured memory_bytes: 892
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto s = readln.chomp;
  if (s.length < 4) writeln("No");
  else if (s[0..4] != "YAKI") writeln("No");
  else writeln("Yes");
}


Measured memory_bytes: 256
import sys
import math
import bisect
from sys import stdin,stdout
from math import gcd,floor,sqrt,log
from collections import defaultdict as dd
from bisect import bisect_left as bl,bisect_right as br

sys.setrecursionlimit(100000000)

ii     =lambda: int(input())
si     =lambda: input()
jn     =lambda x,l: x.join(map(str,l))
sl     =lambda: list(map(str,input().strip()))
mi     =lambda: map(int,input().split())
mif    =lambda: map(float,input().split())
lii    =lambda: list(map(int,input().split()))

ceil   =lambda x: int(x) if(x==int(x)) else int(x)+1
ceildiv=lambda x,d: x//d if(x%d==0) else x//d+1

flush  =lambda: stdout.flush()
ssi =lambda: stdin.readline()
sii =lambda: int(stdin.readline())
sp  =lambda x: stdout.write(str(x))

mod=1000000007


#main code
n=ii()
if n%9==0:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 9608