akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
/*        string[] input = ReadLine().Split(' ');
        long a = long.Parse(input[0]);
        long b = long.Parse(input[1]);
        long c = long.Parse(input[2]);
        long d = long.Parse(input[3]);*/
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        int c = int.Parse(ReadLine());
//        int d = int.Parse(ReadLine());
        string a = ReadLine();
//        string b = ReadLine();
//        string c = ReadLine();
//        string ko = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        int check = 0;
        while(a.Length>0){
            string b = a.Substring(0,1);
            int m = a.Length;
            a = a.Replace(b,"");
            int n = a.Length;
            if(m-n>1){
                check++;
            }
        }
        if(check==0){
            WriteLine("yes");
        }else{
            WriteLine("no");
        }
    }
}

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

double A, B, X;
int main(){
    scanf("%lf %lf %lf", &A, &B, &X);
    X /= A;
    if(X==B*A){
        printf("0\n"); return 0;
    }
    if(X>=(A*B)/2) {
        double bottom = (B) - (X) / (A);
        double ang = 90 - atan((A) / (2.0 * bottom)) * (180 / M_PI);
        printf("%.6lf\n", ang);
    } else{
        double s = 2.0*X/B;
        double ang = atan(B/s)*(180/M_PI);
        printf("%.6lf\n", ang);
    }
    return 0;
}

Measured memory_bytes: 256
n=input()
s=len(n)
d=int((s-1)/2)
p=int((s+3)/2)
m=n[::-1]
n1=n[0:d]
n2=n1[::-1]
n3=n[p-1:]
n4=n3[::-1]
if n==m and n1==n2 and n3==n4:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

ret = False
for i in range(N):
    for j in range(N):
        if i + M > N or j + M > N:
            continue
        f = True
        for k in range(M):
            for l in range(M):
                if A[i + k][j + l] != B[k][l]:
                    f = False
                    break
            if not f:
                break
        if f:
            ret = True
if ret:
    print('Yes')
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define pb push_back
#define lp(j, n)  for(int j=0; j<(int)(n); ++j)
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
#define F first
#define S second
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int,int> > vpii;
typedef map<int, int> mii;
const ll N=1e5+5;
ll arr[N];//A[N]  ;
bool visited[N]={};
int main()
{

  int n,m,count(0);
  cin>>n>>m;
  int A[m+5]={0} , x=n;
  while(n--)
  {
      int k ;
      cin>>k;
      for(int i=0 ;i<k &&cin>>arr[i] ; i++)
      {
          A[arr[i]]++;
      }
  }
    for(int i=0 ; i<=m ; i++)
       {
           if(A[i]==x)
            count++;
       }
           cout<<count;
 go;
}


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

int main() {
int a,b,k;
  cin >>a>>b>>k;
  int s = __gcd(a,b);
  int p =0;
  for(int i=1;i<=s;i++){
   if(s%i ==0){
    p++;
     if(p == k){
      cout<<s/i<<endl;
       return 0;
     }
   }
  }
  }


Measured memory_bytes: 256
def submit():
    n = int(input())
    plist = list(map(int, input().split()))
    
    curr_min = float('inf')
    ans = 0
    for p in plist:
        if p <= curr_min:
            curr_min = p
            ans += 1

    print(ans)


if __name__ == "__main__":
    submit()

Measured memory_bytes: 24744
#include<stdio.h>
int main(){
int a,x[40],h,f,i,n;
while(scanf("%d",&n),n){
for(i=0;i<n-1;i++)
scanf("%d ",&x[i]);
scanf("%d",&x[n-1]);
f=32;
while(1){
for(i=0;i<n;i++){
f-=(f-1)%5;
printf("%d\n",f);
if(f>=x[i])
f-=x[i];
else f=0;
printf("%d\n",f);
if(f==0)break;
}
if(f==0)break;
}
}
return 0;
}

Measured memory_bytes: 0
package main

import (
	"fmt"
)

func main() {
	var to10,ans,mnt int
	
	max := 0
	for i := 0; i < 5; i++ {
		fmt.Scan(&mnt)
		ans += mnt
		to10 = (10 - mnt % 10) % 10
		ans += to10
		if max < to10 {
			max = to10
		}
	}
	ans -= max
	fmt.Println(ans)

}

Measured memory_bytes: 512
o=->a,n{n<1?1:a**n[0]*o[a,n/2]**2%M}
eval'N,A,B='+`dd`.split*?,
a=o[A*=t=o[A+B,-2+M=10**9+7],N]
b=o[B*=t,N]
f=g=1,*(1...N).map{|i|g=g*i%M}
h=g
N.times{|i|$.=($.+o[g*f[i],M-2]*(a+b)*100*t*h=h*(N+i)%M)%M
a=a*B%M
b=b*A%M}
p$.

Measured memory_bytes: 3712
import java.util.*;

public class Main{
   public static void main(String[] args) {
	  Scanner sc =new Scanner(System.in);
while(!sc.hasNext("0")){
	HashMap<String,String> h = new HashMap<String,String>();
	int n=sc.nextInt();
	for(;n>0;n--) h.put(sc.next(), sc.next());
	int m=sc.nextInt();
	for(;m>0;m--){
	String s=sc.next();
	if(h.containsKey(s))s=h.get(s);
	System.out.print(s);
	}
	System.out.println();
}
}
}

Measured memory_bytes: 70328
#include<stdio.h>
int main(void)
{
  int a,b,c;
  scanf("%d %d",&a,&b);
  while(a>0){
    b=b%a;
    if(a>=b) {
      c=a;
      a=b;
      b=c;
    }
    // printf("%d %d\n",a,b);   
  }
  printf("%d\n",b);
  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)
#include "string"

const int inf = 1e9;
int32_t main() { 
	boost;
	int n,m;
	cin>>n>>m;
	int N = (1<<n);
	int dp[N];
	fill_n(dp,N,inf);
	int a,b;
	dp[0] = 0;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		int mask = 0;
		for(int j=0,tt;j<b;j++){
			cin>>tt;
			tt--;
			mask |= (1<<tt);
		}
		for(int j=0;j<N;j++)
			dp[j|mask] = min(dp[j|mask],dp[j]+a);
	}
	if(dp[N-1] == inf)
		cout<<-1<<endl;
	else
		cout<<dp[N-1]<<endl;
}	

Measured memory_bytes: 256
#include <iostream>

int lcs(std::string x, std::string y)
{
  int m = x.length();
  int n = y.length();
  int cs[m + 1][n + 1];

  for (int i = 0; i < m + 1; ++i)
    cs[i][0] = 0;
  for (int j = 1; j < n + 1; ++j)
    cs[0][j] = 0;

  for (int i = 1; i < m + 1; ++i)
  {
    for (int j = 1; j < n + 1; ++j)
    {
      if (x[i - 1] == y[j - 1])
        cs[i][j] = cs[i - 1][j - 1] + 1;
      else
        cs[i][j] = std::max(cs[i - 1][j], cs[i][j - 1]);
    }
  }

  return cs[m][n];
}

int main()
{
  int q;
  std::cin >> q;

  std::string x, y;
  for (int i = 0; i < q; ++i)
  {
    std::cin >> x >> y;
    std::cout << lcs(x, y) << std::endl;
  }

  return 0;
}


Measured memory_bytes: 7008
# -*- coding: utf-8 -*-

S = input()

a_num = 0
b_num = 0
c_num = 0
for i in S:
    if i == "a":
        a_num = a_num + 1
    elif i == "b":
        b_num = b_num + 1
    elif i == "c":
        c_num = c_num +1

if a_num == 1 and b_num == 1 and c_num == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream> 
#include <cstring>
#include <cstdio>
using namespace std;
int main()
{
	//ios::sync_with_stdio(false);
	int a, b, c;
	while(~scanf("%1d%1d%1d", &a, &b, &c)) {
		if(a == c) puts("Yes");
		else puts("No");
	}
	
	return 0;
}

Measured memory_bytes: 256
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

int main() {
	int n;
	cin >> n;
	VI p(n);
	rep(i, n) cin >> p[i];

	sort(all(p));
	p[n - 1] /= 2;

	int sum = 0;
	rep(i, n) {
		sum += p[i];
	}

	cout << sum << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int n;cin>>n;
    for(int i=n;i<=999;i++){
        if(i%111==0){
            cout<<i<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut seq = vec![(0, 0); n];
    for i in 0..n {
        let mut x = read::<i64>();
        let mut y = read::<i64>();
        if x > y {
            std::mem::swap(&mut x, &mut y);
        }
        seq[i] = (x, y);
    }
    let mut min_value = 1 << 32;
    let mut max_value = -(1 << 32);
    let mut que = vec![(0, 0); 3 * n];
    for i in 0..n {
        min_value = std::cmp::min(min_value, seq[i].0);
        max_value = std::cmp::max(max_value, seq[i].1);
        que[i * 3 + 0] = (-(1 << 32), seq[i].0);
        que[i * 3 + 1] = (seq[i].0, seq[i].1);
        que[i * 3 + 2] = (seq[i].1, 1 << 32);
    }
    que.sort();
    let mut ans = 1 << 61;
    let mut pos = 0;
    let mut right = -(1 << 32);
    for i in 0..3 * n {
        while pos < 3 * n && que[pos].0 < que[i].0 {
            right = std::cmp::max(right, que[pos].1);
            pos += 1;
        }
        if que[i].0 == -(1 << 32) || right == (1 << 32) {
            continue;
        }
        let lans = (max_value - min_value) * (right - que[i].0);
        assert!(lans >= 0);
        ans = std::cmp::min(ans, lans);
    }
    {
        let mut left = min_value;
        let mut right = max_value;
        for i in 0..n {
            left = std::cmp::max(left, seq[i].0);
            right = std::cmp::min(right, seq[i].1);
        }
        let lans = (left - min_value) * (max_value - right);
        assert!(lans >= 0);
        ans = std::cmp::min(ans, lans);
    }
    println!("{}", ans);
}


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

using namespace std;
using LLONG = long long;

int main()
{
    string w;
    cin >> w;
    map<char, int> chars;
    for (const char ch : w)
    {
        chars[ch] = 0;
    }
    for (const char ch : w)
    {
        ++chars[ch];
    }
    for (const auto &kvp : chars)
    {
        if (kvp.second % 2 == 1)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

H, W = MAP()
a = [input() for _ in range(H)]

ans = []
tate = []
yoko = []

for i in range(H):
	if a[i].count("#") >= 1:
		yoko.append(i)

for i in range(W):
	for j in range(H):
		if a[j][i] == "#":
			tate.append(i)
			break

for y in yoko:
	tmp = ""
	for t in tate:
		tmp += a[y][t]
	ans.append(tmp)

print(*ans, sep="\n")


Measured memory_bytes: 5204
#include<bits/stdc++.h>
#define For(i,j,k) for(int i=j;i<=k;++i)
using namespace std;
int read(){
	int l=1,x=0; char ch=getchar();
	while(!isdigit(ch)) {if (ch=='-') l=-1; ch=getchar();}
	while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
	return x*l;
}
int main(){
	int a=read(),b=read(),c=read();
	if ((c-b)%2==0) printf("Alice\n");
	else printf("Borys\n");
	return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

seq = [a, b, c, d, e]
ans = "Yay!"

for i in range(5):
	for j in range(i, 5):
		buf = seq[i] - seq[j]
		if abs(buf) > k:
			ans = ":("
			
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    
    ll M = C + D;
    ll E = C * 2 - abs(C - D) * (N - 2);
    
    if(B > A + (N - 1) * D || B < A - (N - 1) * D){
        output("NO");
        return 0;
    }

    if(N % 2 == 0){
        ll EE = E / 2;
        if(abs(A - B) % M < EE || abs(A - B) % M > M - EE){
            output("NO");
        }
        else output("YES");
    }
    else{
        ll EE = ((C + D) - E) / 2;
        if(abs(A - B) % M > EE && abs(A - B) % M < M - EE){
            output("NO");
        }
        else output("YES");
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod 998244353

using namespace std;

int C[10000050];
int n;

int qexp(int b, int e){
	if(e == 0) return 1;
	int half = qexp(b,e/2) % mod;
	half *= half;
	half %= mod;
	if(e % 2 == 0) return half;
	else return (half*b)%mod;
}
int inv(int x){
	return qexp(x, mod-2);
}
int32_t main(){
	cin >> n;
	C[0] = 1;
	for(int i=1; i<=n/2; ++i){
		C[i] = (C[i-1]*(n-i+1)) % mod;
		C[i] *= inv(i); C[i] %= mod;
	}
	for(int i=n; i>=n/2+1; --i){
		C[i] = C[n-i];
	}
	int ans = qexp(3,n);
	for(int i=n/2+1; i<=n; ++i){
		int sub = 2*C[i]; sub %= mod;
		sub *= qexp(2,n-i); sub %= mod;
		ans -= sub;
		ans += mod; ans %= mod;
	}
	cout << ans;
}


Measured memory_bytes: 78336
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int x;
inline void solve(){
  IN(x);
  OUT(x<1200?"ABC":"ARC");
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
//using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
using pii=pair<ll,ll>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void bulk(){}template<class H,class...T>void bulk(H&h,T&...t){cin>>h;bulk(t...);}
#define get(...) int __VA_ARGS__; bulk(__VA_ARGS__);


int main(){
    get(n,m);
	vector<vector<pii>> edge(n+1);
	rep(i,m){
	    get(l,r,dst);
	    edge[l].eb(r,dst);
	    edge[r].eb(l,-dst);
	}

	vi dist(n+1,-INF);
	range(i,1,n+1){
	    if(dist[i]!=-INF || edge[i].empty())continue;

    	dist[i]=0;
    	queue<int> q;
    	q.push(i);
    	int mn=INF,mx=-INF;
    	while(!q.empty()){
    	    int t=q.front(); q.pop();
    	    mn=min(mn,dist[t]);
    	    mx=max(mx,dist[t]);
    	    for(auto p:edge[t]){
    	        if(dist[p.fs]!=-INF){
                    if(dist[t]+p.sc!=dist[p.fs]){
        	            cout<<"No"<<endl;
        	            return 0;
                    }
    	        }else{
    	            dist[p.fs]=dist[t]+p.sc;
    	            q.push(p.fs);
    	        }
    	    }
    	}

        if(mx-mn>INF){
            cout<<"No"<<endl;
            return 0;
        }
	}
	cout<<"Yes"<<endl;
	return 0;
}


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

#define fi first
#define se second
#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 all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> p(m);
    vector<string> s(m);

    rep(i,m) cin >> p[i] >> s[i];

    map<int, bool> mp;
    map<int, int> wmp;
    int wa = 0;
    int ac = 0;
    rep(i,m) {
        auto iter = mp.find(p[i]);
        if (iter != mp.end()) {
            if (mp[p[i]]) continue;
            else {
                if (s[i]=="WA") {
                    mp[p[i]] = false;
                    wmp[p[i]] += 1;
                }
                else {
                    ++ac;
                    wa += wmp[p[i]];
                    mp[p[i]] = true;
                }
            }    
        }
        else {
            if (s[i]=="WA") {
                wmp[p[i]] += 1;
                mp[p[i]] = false;
            } else {
                ++ac;
                mp[p[i]] = true;
            }
        }
    }
    cout << ac << " " << wa << endl;
    return 0;
}














Measured memory_bytes: 11904
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ub              upper_bound
#define lb              lower_bound
#define isrt            insert
#define clr             clear
#define rsz             resize
#define ff              first
#define ss              second
#define lli             long long int
#define pb              push_back
#define pf              push_front
#define mkp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<int>
#define mii             map<lli,lli>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define INF             1e9
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define endl            "\n"


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

lli maxm(lli a, lli b)
{
    return (a >= b ? a : b);
}


lli minm(lli a, lli b)
{
    return (a <= b ? a : b);
}

lli power(lli x, lli y, lli p)
{
    lli res = 1;

    x = x % p;
    if (x == 0)
        return 0;

    while (y > 0)
    {

        if (y & 1)
            res = (res * x) % p;


        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

lli nCrmodp(lli n, lli r, lli p)
{
    if (r == 0)
        return 1;
    if (r == 1)
        return n;


    lli pro = 1, k = n;
    while (k > r)
    {
        pro *= k;
        pro %= p;
        --k;
    }

    k = 2;
    while (k <= (n - r))
    {
        pro *= power(k, (p - 2), p);
        pro %= p;
        ++k;
    }

    return pro;
}


string num_str(lli n, lli k)
{
    string str = "";
    lli x = n;
    while (x != 0)
    {
        string s = to_string(x % k);
        str = s + str;
        x /= k;
    }

    return str;
}


lli first_big(lli n, lli k, lli arr[])
{
    lli l = 0;
    lli r = n - 1;

    lli leftGreater = n;

    while (l <= r) {
        lli m = l + (r - l) / 2;

        if (arr[m] > k) {
            leftGreater = m;
            r = m - 1;
        }

        else
            l = m + 1;
    }

    return leftGreater;
}

void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main()
{
    c_p_c();

    lli n, d, x, y;
    cin >> n >> d;

    lli cnt = 0;

    d *= d;

    for (int i = 0; i < n; ++i)
    {
        cin >> x >> y;
        lli s = (x * x + y * y);

        if (s <= d)
            ++cnt;
    }
    cout << cnt << endl;

    return 0;
}

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

#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second

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

const int MOD = 1e9+7;

int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);

	int a;
	cin >> a;
	cout << !a << "\n";
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007


ll convert(string s){
	ll ans =0;
	int l = s.length();
	s+="000000000" ;
	for(int i=0;i<l+9;++i){

		if(s[i]=='.'){
			for(int j=i+1;j<=i+9;++j){
				ans=  ans*10LL + (s[j]-'0');
			}
			break;
		}
		ans=  ans*10LL + (s[i]-'0');
	}
	return ans;
}
int main(){
	//ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int i,j,k,t;
	int n;
	cin>>n;
	ll a[n+5];
	string x;
	for(i=1;i<=n;i++){
		cin>>x;
		
		a[i]= convert(x);
		//cout<<a[i]<<"\n";
	}
	ll b[20][20];
	memset(b,0,sizeof(b));
	for(i=1;i<=n;++i){
		int c=0;
		while(a[i]%2LL==0){
			a[i]/=2;
			++c;
		}
		
		int d=0;
		while(a[i]%5LL==0){
			a[i]/=5;
			++d;
		}
		//cout<<i<<"    "<<c<<"    "<<d<<"\n";
		b[min(c,18)][min(d,18)]++;
	}

	// for(i=0;i<=18;++i){
	// 	for(j=0;j<=18;++j){
	// 		cout<<b[i][j]<<" ";
	// 	}cout<<"\n";
	// }
	ll ans=0;

	for(i=0;i<=18;++i){
		for(j=0;j<=18;++j){
			for(int p=0;p<=18;++p){
				for(int q=0;q<=18;++q){
					if(((i+p)>=18)  and ((j+q)>=18)){
						if(b[i][j]*b[p][q] >0)
						//cout<<i<<" "<<j<<" "<<p<<" "<<q<<" "<<"\n";
						ans+= b[i][j]*b[p][q];
					}
				}
			}
			if((i>=9) && (j>=9)){
					ans-= b[i][j];
			}
		}
	}
	ans/=2LL;
	cout<<ans<<"\n";
	
	
	return 0;
}

Measured memory_bytes: 5048
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

int main() {
    lint n, x;
    cin >> n >> x;
    lint ans = 0;
    //とりあえず二回進む
    ans += n;
    //p:移動可能領域が作る平行四辺形の長い方、q:短い方
    lint p = max(x, n - x), q = min(x, n - x);
    //終わる直前まで進める
    while (p % q != 0) {
        ans += (p / q) * q * 2;
        p = p % q;
        swap(p, q);
    }
    //最後は2*p/q-1回進む
    ans += (p / q * 2 - 1) * q;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#define so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vii=vector<vi>;
const int MAX = 510000;
const int MOD = 1000000007;
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int n;
    cin>>n;
    unsigned long long k=1;double M=1e18;
    unsigned long long a[n];
    rep(i,n){
        cin>>a[i];
        if(a[i]==0){
            cout<<0<<endl;
            return 0;
        }
    }
    rep(i,n){
        if(a[i]*1ll>M/k){
            cout<<-1<<endl;
            return 0;
        }
        k=k*a[i];        
    }ll MM=1e18;
    if(k>MM)cout<<-1<<endl;
    else cout<<k<<endl;
}

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

int head_digit(int a) {
    int d;
    while (a) {
        d = a;
        a /= 10;
    }
    return d;
}

int tail_digit(const int a) {
    return a % 10;
}

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

    uint64_t answer = 0;

    for(int i = 1; i <= 9; ++i) {
        for(int j = 1; j <= 9; ++j) {
            uint64_t cij = 0;
            uint64_t cji = 0;

            for(int x = 1; x <= n; ++x) {
                const int head = head_digit(x);
                const int tail = tail_digit(x);

                if(tail == i && head == j) {
                    cij++;
                }

                if(tail == j && head == i) {
                    cji++;
                }
            }

            answer += cij * cji;
        }
    }

    std::cout << answer << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main()
{
   
	int r, g, b;
	cin >> r >> g >> b;

	if ((100 * r + 10 * g + b) % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

type quiz struct {
	point, p, c int
}

func intMin(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func main() {
	sc.Split(bufio.ScanWords)

	D, G := scanInt(), scanInt()
	L := make([]quiz, D)
	for i := 0; i < D; i++ {
		L[i].point, L[i].p, L[i].c = 100*(i+1), scanInt(), scanInt()
	}

	ans := 1000
	for i := 0; i < (1 << D); i++ {
		tmp := 0
		sum := 0
		for j := 0; j < D; j++ {
			if i&(1<<j) > 0 {
				sum += L[j].point*L[j].p + L[j].c
				tmp += L[j].p
			}
		}

		if sum >= G {
			ans = intMin(ans, tmp)
			continue
		}

		for j := D - 1; j >= 0; j-- {
			if i&(1<<j) == 0 {
				qNum := (G-sum)/L[j].point + intMin((G-sum)%L[j].point, 1)
				if qNum >= L[j].p {
					continue
				} else {
					tmp += qNum
					ans = intMin(ans, tmp)
					break
				}
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1776
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
use std::collections::HashMap;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let M: usize = read();
    let mut map: HashMap<usize, Vec<bool>> = HashMap::new();
    for _ in 0..M {
        let i: usize = read::<usize>();
        let mut entry = map.entry(i).or_insert(vec![]);
        (*entry).push(read::<String>() == "AC");
    }
    let mut correct: usize = 0;
    let mut penalty: usize = 0;
    for (_, v) in map {
        let mut penalty_tmp: usize = 0;
        for b in v {
            if b {
                correct += 1;
                penalty += penalty_tmp;
                break;
            } else {
                penalty_tmp += 1;
            }
        }
    }
    println!("{} {}", correct, penalty);
}


Measured memory_bytes: 15420
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
lli dp[1001][1001];

int main(){
 	ios::sync_with_stdio(0);
    cin.tie(0);
    lli a;
    cin>>a;
    lli b=a%100;
    a=a/100;
    if(a<=12 && b<=12 && a>0 && b>0){cout<<"AMBIGUOUS";return 0;}
	if(a<=12 &&a>0 &&(!( b<=12  && b>0))){cout<<"MMYY";return 0;}
	if(b<=12 &&b>0 &&(!( a<=12  && a>0))){cout<<"YYMM";return 0;}
	cout<<"NA";

	return 0;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int a, b;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> a >> b;
    if (a > 0) cout << "Positive";
    else if (b >= 0) cout << "Zero";
    else if ((b-a) % 2) cout << "Positive";
    else cout << "Negative";
    cout << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define DEBUG true
#define $(x) {if (DEBUG) {cout << #x << " = " << (x) << endl;}}

vector<PII> directions{MP(1, 0), MP(0, 1)};

int main() {
    LL H, W;
    cin >> H >> W;
    vector<vector<char>> A(H, vector<char>(W));
    REP(i, H) {
        REP(j, W) {
            cin >> A[i][j];
        }
    }
    LL h = 0, w = 0;
    while (h < H || w < W) {
        int ndir = 0, nbdir = 0;
        if (h + 1 < H && A[h + 1][w] == '#') ndir++;
        if (w + 1 < W && A[h][w + 1] == '#') ndir++;
        if (h - 1 >= 0 && A[h - 1][w] == '#') nbdir++;
        if (w - 1 >= 0 && A[h][w - 1] == '#') nbdir++;
        if (((h != H - 1 || w != W - 1) && ndir != 1) || ((h > 0 || w > 0) && nbdir != 1)) {
            cout << "Impossible" << endl;
            return 0;
        }
        if (h == H - 1 && w == W - 1) {
            cout << "Possible" << endl;
            return 0;
        }
        if (h + 1 < H && A[h + 1][w] == '#') h++;
        else w++;
    }
    cout << "Impossible" << endl;
	
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const int MOD = 1000000007; 

int main() {
    int n;
    vector<int> as(3);
    rep(i, 3) cin >> as[i];
    cin >> n;
    sort(all(as));
    int cnt = 0;
    for(int i=0; i*as[2] <= n; ++i) {
        for(int j = 0; j*as[1] + i*as[2] <= n; ++j) {
            if((n-j*as[1]-i*as[2])%as[0]==0) ++cnt;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

Measured memory_bytes: 17160
#include <bits/stdc++.h>
#define SpeeD ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
#define endl '\n'
//pair<int, int> *p=new pair<int, int>[n];
//std::vector<pair<int,int>> vp;
//v.push_back(make_pair(x,y))
//pair<int, int> p[1000001];
//string *s=new string [n];
//int freq[e];
//freq[a[i]-'a']++; freq[a[i]]++;
 using namespace std;  
ll n,t,m,c,x,y,sum,mx,mn,avg,pos,dif,j,dis;
vector<vector<int>>g;
bool vis[(int)1e5+2];
bool isPrime(int x)
{
for (int i=2;i*i<=x;i++)
if (x%i==0)
return false;
return true;
}
void dfs (int node)
{
vis[node]=true;
for (auto i : g[node])
if (!vis[i])dfs(i);
}
int main(void) 
{ 
   
        SpeeD
string s;
cin>>s;
bool f=true;
int n=  s.length();
for (int i = 0 ; i <n/2;i++)
if (s[i]!=s[n-1-i])
{
    f=false;
    break;
}
if (!f)return cout<<"No",0;
string s1=s.substr(0,(n-1)/2);
string s2=s.substr( (n+3)/2 - 1,n-((n+3)/2) +1);
//cout<<s1<<" "<<s2;
bool f1=true;
bool f2=true;
int m=s1.length();
int k = s2.length();
for (int i = 0 ; i <m/2;i++)
if (s1[i]!=s1[m-1-i])
{
    f1=false;
    break;
}
for (int i = 0 ; i <k/2;i++)
if (s2[i]!=s2[k-1-i])
{
    f2=false;
    break;
}
if (f1&&f2)cout<<"Yes";
else cout<<"No";
}

    

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

#define loop(i,a,b) for(int i=a;i<(int)(b);i++)
#define rep(i,b) loop(i,0,b)
typedef long long ll;

// 1 indexed

int main(){
    ll N;
    while(cin >> N && N){
        ll a,d;
        ll M;
        cin >> a >> d >> M;
        vector<ll> x(M), y(M), z(M);
        ll k;

        auto kth = [&](ll k){
            ll res = a;
            rep(i,k-1){
                res += d;
            }
            return res;
        };

        rep(i,M) cin >> x[i] >> y[i] >> z[i];
        set<int> s;
        s.insert(y.begin(), y.end());
        s.insert(z.begin(), z.end());
        cin >> k;

        // rep(i,5){
        //     cout << kth(i+1) << " ";
        // }
        // cout << endl;

        ll ans = -1;
        if(s.count(k)){
            map<ll,ll> m;
            for(int i : s) m[i] = i;
            rep(i,M){
                if(x[i] == 0){
                    swap(m[y[i]],m[z[i]]);
                } else {
                    m[y[i]] = m[z[i]];
                }
            }
            ans = kth(m[k]);
        } else {
            ans = kth(k);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long


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

signed main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int lc = d*c/gcd(c,d);
	// cerr << lc << endl;

	//a未満で割り切れるやつ
	a--;
	int ansa = a - (a/c + a/d) + (a/lc);
	// cerr << ansa << endl;

	//b+1未満で割り切れるやつ
	int ansb = b - (b/c + b/d) + (b/lc);
	// cerr << ansb << endl;
	cout << ansb-ansa << endl;

	// int cnt = 0;
	// LOOP1(i,b){
	// 	if((i%c) && (i%d)){
	// 		cerr << cnt++ << " " << i << endl;
	// 	}
	// }
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,k;
    cin>>n>>k;
    vector<vector<int>> g(n,vector<int>(0));
    int x,y;
    rep(i,n-1){
        cin>>x>>y;
        x --,y --;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
    }
    in ans=k;
    queue<int> que;
    vector<bool> seen(n,false);
    que.emplace(0);
    seen[0]=true;
    while(!que.empty()){
        x=que.front();
        que.pop();
        int cnt=1;
        if(x==0) cnt=0;
        for(auto z:g[x]){
            if(seen[z]) continue;
            cnt ++;
            ans *=(k-cnt);
            ans %=MOD;
            seen[z]=true;
            que.emplace(z);
        }
    }
    cout<<ans<<endl;
}/*
./problem.exe
*/

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

long long int pre[100001],pre2[100001];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>pre[i];
		pre2[i]=max(pre[i],0LL);
		pre[i]+=pre[i-1];
		pre2[i]+=pre2[i-1];
	}
	long long int ans=-1e18;
	for(int i=k;i<=n;i++){
		long long int x=pre[i]-pre[i-k];
		ans=max(ans,pre2[n]-(pre2[i]-pre2[i-k])+max(x,0LL));
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>

#define REP(i, n) for (int i = 0; i < (n); i++) 
#define ll long long

using namespace std;
//        tmp = stoi(S.substr(i,3));
int main(){

    ll AB,BC,CA;

    ll res = 0;

    cin >> AB >> BC >> CA;

    res = AB * BC / 2;

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <algorithm>
#include <stdio.h>
//#include <math.h>

using namespace std;

int main(void){
    // Your code here!
int x,y,W,H,r;    
    
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

    if( x+r<=W && y+r<=H && 0<=x-r && 0<=y-r  ){  //if( 0<=x && 0<=y && 0<=x-r && 0<=y-r ){
        puts("Yes");
    }
    else puts("No");
    
    return 0;
}



Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
 
#define 	pi 				3.14159265358979
#define 	mod 			1000000007
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(ll i = a ; i < b ; i++)
#define     repn(i, a, b)   for(ll i = a ; i > b ; i--)
#define 	mod1 			1000003
#define     mod2            998244353
#define     inf             2e18
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define     sz              size()
#define     len             length()
#define 	F 				first
#define 	S 				second
#define 	PB 				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define     pll             pair<ll, ll>
#define     vll             vector<ll>
#define     vpll            vector<pll>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define     sqr(a)          ((a)*(a))
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	print3(a) 		for(auto i : a)cout<<i<<nl;
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 
// ostringstream str1;
// str1 << n;
// string tmp = str1.str();
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }
 
double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }
 
 
// vll pwx(22);
// void cal(ll x){ pwx[0] = 1; rep(i, 1, 22)pwx[i] = x*(pwx[i-1]); }
 
/* ################################################################ */

void solve(){
    ll n;
    cin >> n;

    vector<ll> a(n);

    rep(i, 0, n)
        cin >> a[i];

    ll ans = 1000, stocks = 0, mn = a[0];



    for(ll i = 1; i < n ; i++){
        if(a[i] >= a[i-1])continue;

        if(mn < a[i-1]){
            stocks = ans/mn;
            ans += stocks*(a[i-1]-mn);
            mn = a[i];
        }
        else{
            mn = a[i];
        }
        // cout << ans << nl;
    }
    if(mn < a[n-1]){
        stocks = ans/mn;
        ans += stocks*(a[n-1] - mn);
    }

    cout << ans << nl;
}

int main(){
    // boost;
    // cal(2);
    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}

Measured memory_bytes: 3596
import java.io.*;
import java.util.*;

public class Main {
  private static String solve(int n, int k, String s) {
    char[] cs = s.toCharArray();
    cs[k - 1] = (char)(cs[k - 1] - 'A' + 'a');
    return new String(cs);
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int k = reader.nextInt();
    String s = reader.next();
    out.println(solve(n, k, s));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public int[] nextIntArray(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLongArray(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
}

class Algorithm {
  private static void swap(Object[] list, int a, int b) {
    Object tmp = list[a];
    list[a] = list[b];
    list[b] = tmp;
  }
  
  public static <T extends Comparable<? super T>> boolean nextPermutation(T[] ts) {
    int rightMostAscendingOrderIndex = ts.length - 2;
    while (rightMostAscendingOrderIndex >= 0 &&
        ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0) {
      rightMostAscendingOrderIndex--;
    }
    if (rightMostAscendingOrderIndex < 0) {
      return false;
    }
    
    int rightMostGreatorIndex = ts.length - 1;
    while (ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) >= 0) {
      rightMostGreatorIndex--;
    }
    
    swap(ts, rightMostAscendingOrderIndex, rightMostGreatorIndex);
    for (int i = 0; i < (ts.length - rightMostAscendingOrderIndex - 1) / 2; i++) {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    }
    return true;
  }
}



Measured memory_bytes: 21332
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <unordered_map>
#include <queue>
#include <math.h>
using namespace std;

int cmp(const void *a,const void *b)
{
	return *(int *)a - *(int *)b;
}

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(n);
	for(int i = 0; i < n; i ++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i ++){
		cin >> b[i];
	}
	for(int i = 0; i < n; i ++){
		cin >> c[i];
	}
	
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());
	vector<long long> br(n,0);
	long long res = 0;
	int cindex = 0;
	for(int i = 0; i < n; i++){
		while(b[i] >= c[cindex]) {
			cindex++;
			if (cindex >= n) break;
		}
		if(cindex>=n) break;
		br[i] = n - cindex;
	}
	int bindex = 0;
	long long pretemp= -1;
	long long temp = 0;
	int preindex = -1;
	for(int i = 0; i < n; i++){
		temp = 0;
		while(a[i] >= b[bindex]) {
			bindex++;
			if (bindex >= n) break;
		}
		if (bindex>=n || br[bindex] == 0) break;
		if(bindex == preindex){
			temp = pretemp;
		}
		else if (i!=0){
			temp = pretemp;
			for(int j = preindex; j < bindex; j++){
				if (br[j] == 0) break;
				temp -= br[j];
			}
		}
		else{
			for(int j = bindex; j < n; j++){
				if(br[j] == 0 ) break;
				temp += br[j];
			}
		}

		res += temp;
		pretemp = temp;
		preindex = bindex;
		if (temp == 0) break;
	}

	cout << res;
	return 0;
}
	

Measured memory_bytes: 2176