akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
using data = pair<string,bool>;
auto perse(string s){
    vector<data>sub;
    bool flag = false;
    string temp = "";
    for(auto c :s){
        if(c == '"' and flag == false){
            sub.push_back(make_pair(temp,false));
            temp.clear();
            flag = true;
        }else if(c == '"' and flag == true){
            sub.push_back(make_pair(temp,true));
            temp.clear();
            flag = false;
        } else temp.push_back(c);
    }
    if(temp.size())sub.push_back(make_pair(temp, false));
    return sub;
}
signed main(){
    string s,t;
    while(cin >> s){
        if(s == ".")break;
        cin >> t;
        if(s == t)cout << "IDENTICAL" << endl;
        else {
            auto sv = perse(s);
            auto tv = perse(t);
            if(tv.size() == sv.size()){
                int dif = 0;
                rep(i,tv.size()){
                    if(tv[i].first == sv[i].first and tv[i].second == sv[i].second){
                        //nothing to do
                    } else if(tv[i].first ==sv[i].first and tv[i].second != sv[i].second){
                        dif += 100;
                    } else if(tv[i].second == sv[i].second){
                        dif += (tv[i].second ? 1: 100);
                    }
                }
                cout << (dif == 1 ? "CLOSE" : "DIFFERENT") << endl;
            } else cout << "DIFFERENT" << endl;
        }
    }
}



Measured memory_bytes: 3248
#UnionFindクラス
class UnionFind(object):

  def __init__(self, n=1):
    self.par = [i for i in range(n)]
    self.rank = [0 for _ in range(n)]

  def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
  
  # xとyの根を結合させる
  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x != y:
      if self.rank[x] < self.rank[y]:
        x, y = y, x
      if self.rank[x] == self.rank[y]:
        self.rank[x] += 1
      self.par[y] = x
  
  # x,yの根が同じかどうかを返す（根が同じ:True、根が異なる:False）
  def is_same(self, x, y):
    return self.find(x) == self.find(y)

n,k,l = map(int,input().split())
    
uf_road = UnionFind(n)
uf_rail = UnionFind(n)
for i in range(k):
  tmp1,tmp2 = map(int,input().split())
  uf_road.union(tmp1-1,tmp2-1)
  
for i in range(l):
  tmp1,tmp2 = map(int,input().split())
  uf_rail.union(tmp1-1,tmp2-1)

memo = {}
for i in range(n):
  if str(uf_rail.find(i))+" "+str(uf_road.find(i)) not in memo:
    memo[str(uf_rail.find(i))+" "+str(uf_road.find(i))] = 1
  else:
    memo[str(uf_rail.find(i))+" "+str(uf_road.find(i))] += 1

for i in range(n):
  print(memo[str(uf_rail.find(i))+" "+str(uf_road.find(i))])

Measured memory_bytes: 50416
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t / 2;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}



int main() {
    long long a;
    string x;
    cin >> x;
    vector<char>as;
    as.push_back(x[0]);
    for (int i = 1; i < x.size(); i++){
        as.push_back(x[i]);
        if (as.size() >= 2 && as[as.size() - 2] == 'S' && as[as.size() - 1] == 'T'){
            as.pop_back();
            as.pop_back();
        }
    }
    cout << as.size() << endl;
}

Measured memory_bytes: 788
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;

template <typename T>
struct BIT{
  private:
    vector<T> array;
    const ll n;
  public:
    BIT(ll _n):array(_n+1,0),n(_n){}
    
    T sum(ll i){
      T s=0;
      while(i>0){
        s+=array[i];
        i-=i&(-i);
      }
      return s;
    }
    T sum(ll i,ll j){
      T ret_i=sum(i-1),ret_j=sum(j);
      return ret_j-ret_i;
    }
    void add(ll i,T x){
      while(i<=n){
        array[i]+=x;
        i+=i&(-i);
      }
    }
};

int main(){
  ll n,q;cin>>n>>q;
  BIT<ll> bit(n+1);
  rep(i,0,q){
    ll c,x,y;cin>>c>>x>>y;
    if(c==0){
      bit.add(x,y);
    }
    else{
      cout<<bit.sum(x,y)<<endl;
    }
  }
  

}




Measured memory_bytes: 3548
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
ll sieve[1000001]={0},i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p);
p=(p*p);
k>>=1;
}
return a;
}
using namespace std;
  ll countDivisors(ll n) 
{ 
    ll cnt = 0; 
    for (ll i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            if (n / i == i) 
                cnt++; 
  
            else 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int tc=1;
//cin>>tc;
ll cas=1;
 while(tc--)
 {
	ll n,x,y;
	set<ll> s;
	cin>>n>>x>>y;
	for(i=x;i<=y;i++)
	s.insert(i);
	ll len=(y-x+1);
	//cout<<len;
	ll ans[n+1]={0};
	ll sum=0;
	for(i=1;i<=n;i++)
	for(j=i+1;j<=n;j++)
	{
		sum=j-i;
		if((s.find(i)!=s.end() )&& (s.find(j)!=s.end()))
		{
			sum=min(j-i,(len-(j-i)));
			ans[sum]++;
		}
		else if(s.find(i)==s.end() && s.find(j)==s.end())
		{
			if(i<x && j>y)
			sum=(x-i+j-y+1);
			else if((i<x && j<x) || (i>y && j>y))
			sum=(j-i);
			ans[sum]++;
		}
		else if(s.find(i)==s.end() && s.find(j)!=s.end())
		{
			sum=min(j-x,(len-(j-x)))+(x-i);
			ans[sum]++;
		}
			else if(s.find(i)!=s.end() && s.find(j)==s.end())
			{
			    sum=min(y-i,(len-(y-i)))+(j-y);
			    ans[sum]++;
			}
		
	}
	for(i=1;i<n;i++)
	cout<<ans[i]<<"\n";
// cout<<"\n"; 
 } 
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>

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

using namespace std;

int main() {
    int n;
    cin >> n;
    int d0, d1, d2, d3;
    d0 = n%10;
    d1 = ((n-d0)/10)%10;
    d2 = ((n-d1*10-d0)/100)%10;
    d3 = (n-d2*100-d1*10-d0)/1000;
    if ((d0 == d1 && d1 == d2) || (d1 == d2 && d2 == d3)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
const rl = require('readline')
    .createInterface({
        input: process.stdin,
    });

rl.on('line', (line) => {
    const param = line.split(" ");
    solve(Number(param[0]), Number(param[1]));
    rl.close();
});

function solve(x,y){
    console.log(x+y/2);
}


Measured memory_bytes: 8004
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
  int n;
  while(cin>>n,n){
    int w[n],i,j,k=0;
    for(i=0;i<n;i++) cin>>w[i];
    bool p[n][n],u[n][n];
    memset(p,0,sizeof(p));
    memset(u,0,sizeof(u));
    queue<P> q;
    for(j=0;j+1<n;j++) if(abs(w[j+1]-w[j])<2) p[j][j+1]=1,q.push(P(j,j+1));
    while(!q.empty()){
      int l=q.front().first,r=q.front().second;q.pop();
      if(u[l][r]) continue;
      u[l][r]=1;
      if(l>0&&r+1<n&&abs(w[l-1]-w[r+1])<2) p[l-1][r+1]=1,q.push(P(l-1,r+1));
      for(i=r+1;i<n;i++) if(p[r+1][i]) p[l][i]=1,q.push(P(l,i));
      for(i=0;i<l;i++) if(p[i][l-1]) p[i][r]=1,q.push(P(i,r));
    }	  
    int dp[n+1];
    memset(dp,0,sizeof(dp));
    for(i=0;i<=n;i++)
      for(j=1;i+j<=n;j++)
	dp[i+j]=max(dp[i+j],dp[i]+p[i][i+j-1]*j);
    cout<<dp[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 13580
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    static char S[10];
    static char T[11];
    int count=0;

    scanf("%[^\n]%*c",S);
    scanf("\n");
    scanf("%[^\n]%*c",T);

    for(int i=0;S[i]!='\0';i++){
       if(S[i]==T[i]){
        count=count+1;
       }
    }
    if(count==strlen(S)){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 1664
import Data.Set (Set, empty, member, insert)

main :: IO ()
main = do
  a : b : c : _ <- map read . words <$> getContents

  let
    series = iterateM f (a, b, c)
    result = if check series then length series - 1 else -1

  print result

type Three = (Int, Int, Int)

f :: Three -> Maybe Three
f (a, b, c)
  | anyOdd a b c = Nothing
  | otherwise = Just ((b + c) `div` 2, (a + c) `div` 2, (a + b) `div` 2)

anyOdd :: Int -> Int -> Int -> Bool
anyOdd a b c = odd a || odd b || odd c

iterateM :: (a -> Maybe a) -> a -> [a]
iterateM f z = case f z of
  Nothing -> [z]
  Just x -> z : iterateM f x

check :: Ord a => [a] -> Bool
check = check' empty
  where
    check' :: Ord a => Set a -> [a] -> Bool
    check' _ [] = True
    check' set (x:xs)
      | member x set = False
      | otherwise = check' (insert x set) xs


Measured memory_bytes: 508
import std.stdio;
import std.string;
import std.conv;

void main() {
	string[] inputs = split(readln());
	int A = to!int(inputs[0]);
	int B = to!int(inputs[1]);
	if(A == B) "Draw".writeln;
	else if(A == 1 && B > 1) "Alice".writeln;
	else if(B == 1 && A > 1) "Bob".writeln;
	else if(A > B) "Alice".writeln;
	else "Bob".writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main(){
    int n,m;
    cin >> n >> m;
    int a=0;
    for(int i=0;i<m;i++){
        int x;
        cin >> x;
        a+=x;
    }
    if(a>n){
        cout << -1 << endl;
    }else{
        cout << n-a << endl;
    }
}

Measured memory_bytes: 3620
/******************
*  Author: BD747  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
#include<bits/stdc++.h>
using namespace std;

int d;

int main(){

	cin>>d;
	if(d==25){
		cout<<"Christmas"<<endl;
	}
	if(d==24){
		cout<<"Christmas Eve"<<endl;
	}
	if(d==23){
		cout<<"Christmas Eve Eve"<<endl;
	}
	if(d==22){
		cout<<"Christmas Eve Eve Eve"<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, sum, i;
	
	while (scanf("%d", &a) != EOF){
		scanf("%d", &b);		
		sum = a + b;
		
		i = 0;
		while (1){
			sum /= 10;
			i++;
			if (sum == 0){
				break;
			}
		}
		
		printf("%d\n", i);
	}
	
	return (0);
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    if (n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9)
    {
        cout << "hon";
    }
    if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
    {
        cout << "pon";
    }
    if (n % 10 == 3)
    {
        cout << "bon";
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
long long dp[N][N];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	string temp = "";
	for (int i = 0; i < n; i++) {
		cin >> temp;
		for (int j = 0; j < m; j++)
			if (temp[j] == '#')
				dp[i][j] = -1;
	}

	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			if (i == 0 && j == 0)
				dp[i][j] = 1;
			else if (dp[i][j] != -1)
				dp[i][j] = ((i == 0 || dp[i - 1][j] == -1 ? 0 : dp[i - 1][j]) + (j == 0 || dp[i][j - 1] == -1 ? 0 : dp[i][j - 1]))%(long long)(1e9 + 7);

	cout << dp[n - 1][m - 1] % (long long)(1e9 + 7);
	cin >> n;
	return 0;
}

Measured memory_bytes: 8192
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <limits>
#include <memory>
#include <queue>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define all(a) (a).begin(), (a).end()
#define sz(a) static_cast<int>((a).size())
#define fillchar(a, x) memset(a, x, sizeof(a))
#define rep(i, a, b) for(int i=int(a); i<=int(b); ++i)
#define irep(i, a, b) for(int i=int(a); i>=int(b); --i)
#define replr(i, a, b) rep(i, a, (b)-1)
#define reprl(i, a, b) irep(i, (b)-1, a)
#define repn(i, n) rep(i, 0, (n)-1)
#define irepn(i, n) irep(i, (n)-1, 0)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<string> VS;
template<class T, class S> ostream& operator<<(ostream& os, const pair<T, S>& v) { return os<<"("<<v.first<<", "<<v.second<<")"; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { os<<"["; repn(i, sz(v)) { if(i) os<<", "; os<<v[i]; } return os<<"]"; }
template<class T> bool setmax(T &_a, T _b) { if(_b>_a) { _a=_b; return true; } return false; }
template<class T> bool setmin(T &_a, T _b) { if(_b<_a) { _a=_b; return true; } return false; }
template<class T> T gcd(T _a, T _b) { return _b==0?_a:gcd(_b,_a%_b); }

int main() {
    string s; cin>>s;
    int n=sz(s);
    int r=0;
    repn(i, n) {
        bool ap=(i%2==1), bp=(s[i]=='p');
        if(ap) ++r; if(bp) --r;
    }
    cout<<r<<endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>

int main(){
  long a,b,c;
  std::cin >> a >> b >> c;
  if(a + b >= c){
    std::cout << "No" << std::endl;
  }
  else{
    if(a*(2*b-a) < b*b + c*(c- 2*a - 2*b)){
      std::cout << "Yes" << std::endl;
    }
    else{
      std::cout << "No" << std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int N= scan.nextInt();
        int dis=0;
        int arr[]= new int[N];
        for(int i=0;i<N;i++){
           arr[i]= scan.nextInt();
        }
        for(int i=1;i<N;i++){
            int temp=Math.abs(arr[i]-arr[i-1]);
            dis=Math.max(dis,temp);
         }
         dis=Math.max(dis,Math.abs((x-arr[N-1])+arr[0]));
         
         x-=dis;
         System.out.println(x);
        
    }
    }


Measured memory_bytes: 83504
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 7;

int n, m, st, en;
vector < pair <int, long long> > ad[N];
long long way[N][2], d[N][2], M = 1e9 + 7;
void djk(int v, int t) {
	set < pair <long long, int> > s;
	s.insert({1, v});
	way[v][t] = 1;
	d[v][t] = 1;
	while (s.size()) {
		int u = s.begin()->second, dis = s.begin()->first;
		s.erase(s.begin());
		for (auto x: ad[u]) {
			int disp = dis + x.second;
			int up = x.first;
			if (!d[up][t] || d[up][t] > disp) {
				s.erase({d[up][t], up});
				d[up][t] = disp;
				way[up][t] = way[u][t];
				s.insert({disp, up});
			}
			else if (disp == d[up][t]) {
				way[up][t] = (way[up][t] + way[u][t]) % M;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		d[i][t]--;
	}
}

int32_t main() {
	cin >> n >> m >> st >> en;
	while (m--) {
		int v, u, w;
		cin >> v >> u >> w;
		ad[v].push_back({u, w});
		ad[u].push_back({v, w});
	}
	djk(st, 1);
	djk(en, 0);
	long long res = (way[en][1] * way[st][0]) % M;
	for (int v = 1; v <= n; v++) {
		for (auto u: ad[v]) {
			int t1 = d[v][1];
			int t2 = d[u.first][0];
			if (t2 + u.second != d[v][0])
				continue;
			if (t1 + u.second != d[u.first][1])
				continue;
			if (t1 + t2 + u.second != d[en][1])
				continue;
			if (abs(t1 - t2) < u.second) {
				res = (res - ((((way[v][1] * way[v][1]) % M) * ((way[u.first][0] * way[u.first][0]) % M)) % M)) % M;
			}
		}
		if (d[v][1] + d[v][0] == d[en][1] && d[v][1] == d[v][0]) {
			res = (res - ((((way[v][0] * way[v][0]) % M) * ((way[v][1] * way[v][1]) % M)) % M)) % M;
		}
	}
	cout << (((res % M) + M) % M);
	return 0;
}


Measured memory_bytes: 21232
#include <bits/stdc++.h>
using namespace std;
const double inf = 1e20;
const double eps = 1e-8;
const int N = 2e5 + 100;
int sgn (double x) {
    if (fabs (x) < eps) return 0;
    if (x < 0) return -1;
    return 1;
}
struct point {
    double x, y;
    point () {}
    point (double _x, double _y) {
        x = _x, y = _y;
    }
    void input () {
        scanf ("%lf %lf", &x, &y);
    }
    point operator - (const point &b) const {
        return point (x - b.x, y - b.y);
    }
    bool operator == (const point &b) const {
        return sgn (x - b.x) == 0 && sgn (y - b.y) == 0;
    }
    bool operator < (const point &b) const {
        if (sgn (y - b.y) == 0) return x < b.x;
        return y < b.y;
    }
    double operator * (const point &b) const {
        return x * b.x + y * b.y;
    }
    double operator ^ (const point &b) const {
        return x * b.y - y * b.x;
    }
    double cross (point a, point b) {
        return (point (a - *this) ^ point (b - *this));
    }
    double hot (point a, point b) {
        return (point (a - *this) * point (b - *this));
    }
    double len () {
        return hypot (x, y);
    }
};
struct polygon {
    int n;
    point ps[N];
    void input () {
        cin >> n;
        for (int i = 0; i < n; i++) ps[i].input ();
    }
    void getconvex (polygon &convex) {
        sort (ps, ps + n);
        int &top = convex.n;
        top = 0;
        convex.ps[top++] = ps[0];
        for (int i = 1; i < n; i++) {
            while (top >= 2 && convex.ps[top - 2].cross (convex.ps[top - 1], ps[i]) < 0) top--;
            convex.ps[top++] = ps[i];
        }
        int t = 0;
        for (int i = n - 2; i >= 0; i--) {
            while (t && convex.ps[top - 2].cross (convex.ps[top - 1], ps[i]) < 0) top--, t--;
            if (!i) break;
            convex.ps[top++] = ps[i];
            t++;
        }
    }
} s;
int main () {
    double ans = 0;
    int n;
    s.input ();
    n = s.n;
    s.n *= 2;
    for (int i = n; i < s.n; i++) s.ps[i] = s.ps[i - n];
    for (int i = 0; i < n / 2 + 1; i++) {
        int l = i + 1, r = i + n;
        while (l <= r) {
            int mid = l + r >> 1, flag1, flag2;
            if (point (s.ps[mid] - s.ps[i]).len () > point (s.ps[mid - 1] - s.ps[i]).len ()) flag1 = 1;
            else flag1 = 0;
            if (point (s.ps[mid] - s.ps[i]).len () > point (s.ps[mid + 1] - s.ps[i]).len ()) flag2 = 1;
            else flag2 = 0;
            if (flag1 && flag2) {
                ans = max (ans, point (s.ps[mid] - s.ps[i]).len ());
                break;
            } else if (flag1 && !flag2) l = mid + 1;
            else r = mid - 1;
        }
    }
    printf ("%.12f\n" ,ans);
    return 0;
}



Measured memory_bytes: 5764
#include <iostream>
#include <algorithm>
#include <vector>
int main(){
	using namespace std;
	int num,a;
	cin >> num;
	for(int i=0;i<num;i++){
		vector<int> tr;
		for(int j=0;j<3;j++){
			cin >> a;
			tr.push_back(a);
		}
		sort( tr.begin() , tr.end() );
		if((tr[0]*tr[0])+(tr[1]*tr[1])==(tr[2]*tr[2])){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
}

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

int main() {
  int64_t A, V, B, W, T, C, D, E;
  cin >> A >> V;
  cin >> B >> W;
  cin >> T;
  if (V <= W) {
    cout << "NO" << endl;
  }
  else {
    C=(V-W)*T;
    D=(B-A);
    E=(A-B);
    if (A < B) {
      if (C >= D) {
        cout << "YES" << endl;
      }
      else {
        cout << "NO" << endl;
      }
    }
    else {
      if (C >= E) {
        cout << "YES" << endl;
      }
      else {
        cout << "NO" << endl;
      }
    }
  }
}


Measured memory_bytes: 3632
package main

import (
	"fmt"
)

func main() {
	var A, B, C, ans string
	fmt.Scan(&A, &B, &C)

	if A[len(A)-1] == B[0] && B[len(B)-1] == C[0] {
		ans = "YES"
	} else {
		ans = "NO"
	}

	fmt.Println(ans)
}

Measured memory_bytes: 512
use std::io::Read;
use std::io::stdin;

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    let mut text = String::new();
    stdin.read_to_string(&mut text).unwrap();

    let mut counter: [i32; 26] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];

    for char in text.chars() {
        match char {
            'A' | 'a' => counter[0] += 1,
            'B' | 'b' => counter[1] += 1,
            'C' | 'c' => counter[2] += 1,
            'D' | 'd' => counter[3] += 1,
            'E' | 'e' => counter[4] += 1,
            'F' | 'f' => counter[5] += 1,
            'G' | 'g' => counter[6] += 1,
            'H' | 'h' => counter[7] += 1,
            'I' | 'i' => counter[8] += 1,
            'J' | 'j' => counter[9] += 1,
            'K' | 'k' => counter[10] += 1,
            'L' | 'l' => counter[11] += 1,
            'M' | 'm' => counter[12] += 1,
            'N' | 'n' => counter[13] += 1,
            'O' | 'o' => counter[14] += 1,
            'P' | 'p' => counter[15] += 1,
            'Q' | 'q' => counter[16] += 1,
            'R' | 'r' => counter[17] += 1,
            'S' | 's' => counter[18] += 1,
            'T' | 't' => counter[19] += 1,
            'U' | 'u' => counter[20] += 1,
            'V' | 'v' => counter[21] += 1,
            'W' | 'w' => counter[22] += 1,
            'X' | 'x' => counter[23] += 1,
            'Y' | 'y' => counter[24] += 1,
            'Z' | 'z' => counter[25] += 1,
            _ => ()
        }
    }

    println!("a : {}", counter[0]);
    println!("b : {}", counter[1]);
    println!("c : {}", counter[2]);
    println!("d : {}", counter[3]);
    println!("e : {}", counter[4]);
    println!("f : {}", counter[5]);
    println!("g : {}", counter[6]);
    println!("h : {}", counter[7]);
    println!("i : {}", counter[8]);
    println!("j : {}", counter[9]);
    println!("k : {}", counter[10]);
    println!("l : {}", counter[11]);
    println!("m : {}", counter[12]);
    println!("n : {}", counter[13]);
    println!("o : {}", counter[14]);
    println!("p : {}", counter[15]);
    println!("q : {}", counter[16]);
    println!("r : {}", counter[17]);
    println!("s : {}", counter[18]);
    println!("t : {}", counter[19]);
    println!("u : {}", counter[20]);
    println!("v : {}", counter[21]);
    println!("w : {}", counter[22]);
    println!("x : {}", counter[23]);
    println!("y : {}", counter[24]);
    println!("z : {}", counter[25]);
}


Measured memory_bytes: 5032
n = int(input())
li_A = list(map(int,input().split()))
li_B = list(map(int,input().split()))
cnt = 0
for i in range(0,n):
    defeat = min(li_A[i],li_B[i])
    cnt += defeat
    li_B[i] -= defeat
    re_defeat = min(li_A[i+1],li_B[i])
    cnt+=re_defeat
    li_A[i+1] -=re_defeat
print(cnt)

Measured memory_bytes: 19116
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())

sum_of_gcd = 0
dict_of_gcd = {}
for a in range(k):
    for b in range(k):
        for c in range(k):
            if a == b == c:
                sum_of_gcd  += a + 1
            else:
                sum_of_gcd  += gcd((a + 1), (b + 1), (c +1))
print(sum_of_gcd)

Measured memory_bytes: 69844
function Main(input){
	var xs = input.trim().split(' ').map(v=>parseInt(v,10));
    var sum = 0;
    for(i = 0; i<xs.length; i++){
    sum += xs[i];
    }
    console.log(Math.ceil(sum/xs.length));
}
Main(require('fs').readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
  
  int N,K;
  cin >> N >> K;

  int num = 0;
  for(int i = 0;i < N;i++) {
    int h;
    cin >> h;
    if(h >= K) num++;
  }

  cout << num << endl;
}



Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int maxn=200111;
const int maxm=400111;

struct edge{int to,cap;};
namespace flow
{
	int head[maxn],nxt[maxm<<1],iter[maxn],tot;
	edge e[maxm<<1];
	void clear()
	{
		memset(head,0,sizeof(head));
		tot=1;
	}
	void addedge(int u,int v,int cap)
	{
		nxt[++tot]=head[u];
		head[u]=tot;
		e[tot]=edge{v,cap};
		nxt[++tot]=head[v];
		head[v]=tot;
		e[tot]=edge{u,0};
	}
	 
	int lvl[maxn],q[maxn];
	bool bfs(int s,int t)
	{
		memset(lvl,-1,sizeof(lvl));
		lvl[s]=0;int rr=0;q[rr++]=s;
		for(int fr=0;fr<rr;fr++)
		{
			int x=q[fr];if(x==t)return true;
			for(int i=head[x];i;i=nxt[i])if(e[i].cap&&lvl[e[i].to]==-1)
			{
				lvl[e[i].to]=lvl[x]+1;
				q[rr++]=e[i].to;
			}
		}
		return false;
	}
	int dfs(int x,int t,int f)
	{
		if(x==t||f==0)return f;
		int ret=0;
		for(int&i=iter[x];i;i=nxt[i])if(e[i].cap&&lvl[e[i].to]==lvl[x]+1)
		{
			int d=dfs(e[i].to,t,min(f,e[i].cap));
			e[i].cap-=d;e[i^1].cap+=d;
			f-=d;ret+=d;
			if(!f)break;
		}
		return ret;
	}
	int maxflow(int s,int t)
	{
		int flow=0;
		while(bfs(s,t))
		{
			memcpy(iter,head,sizeof(head));
			flow+=dfs(s,t,inf);
		}
		return flow;
	}
};

vector<int> e[maxn],g[maxn];
int n,piv[maxn],fa[maxn];

bool use[maxn];
void dfs(int x)
{
	use[x]=1;
	for(auto&v:g[x])if(!use[v])
	{
		fa[v]=x;
		dfs(v);
	}
}
int main()
{
	get1(n);
	int S=1,T=n+n;
	flow::clear();
	for(int i=2;i<=n;i++)flow::addedge(S,i,1);
	for(int i=1;i<n;i++)
	{
		int cnt,x;get1(cnt);
		flow::addedge(i+n,T,1);
		while(cnt--)
		{
			get1(x);
			e[i].pb(x);
			if(x>1)flow::addedge(x,i+n,1);
		}
	}
	if(flow::maxflow(S,T)<n-1)
	{
		puts("-1");
		return 0;
	}
	
	for(int i=2;i<=n;i++)for(int j=flow::head[i];j;j=flow::nxt[j])if(flow::e[j].to!=S&&!flow::e[j].cap)
		piv[flow::e[j].to-n]=i;
	
	for(int i=1;i<n;i++)for(int j=0;j<(int)e[i].size();j++)if(e[i][j]!=piv[i])g[e[i][j]].pb(piv[i]);
	
	dfs(1);
	for(int i=2;i<=n;i++)if(!fa[i])
	{
		puts("-1");
		return 0;
	}
	for(int i=1;i<n;i++)printf("%d %d\n",piv[i],fa[piv[i]]);
	return 0;
}

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

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

    int N, a, b, p;
    string s;
    cin >> N >> s;
    int r_sum = 0;
    for (auto c: s) {
        r_sum += c == 'R';
    }

    if (r_sum * 2 > N) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; string s; int k; cin >> n >> s >> k;
  REP(i, n) cout << (s[i] == s[k - 1] ? s[i] : '*');
  cout << '\n';
  return 0;
}


Measured memory_bytes: 256
#coding: UTF-8
class EuclideanAlgorithmCalcurator
  def get_gcd(m, n)
    if n == 0
      return m;
    end
    return get_gcd(n, m % n)
  end
  def get_lcd(m, n)
    return (m * n) / get_gcd(m, n)
  end
end

if __FILE__ == $0
  while line = gets
    args = line.split(" ").map{|e|e.to_i}
    m = args[0] >= args[1] ? args[0] : args[1]
    n = m == args[0] ? args[1] : args[0]
 
    calcurator = EuclideanAlgorithmCalcurator.new
    # 最大公約数
    puts "#{calcurator.get_gcd(m, n)} #{calcurator.get_lcd(m, n)}"
  end
end

Measured memory_bytes: 2380
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin >> x;
    int angle = 0;
    int ans = 0;
    do {
        angle += x;
        angle %= 360;
        ans++;
    } while (angle);
    cout << ans << '\n';
    return 0;
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);

    vi a(N);
    int c;


    Rep(i,N){
        Scd(c);
        a[--c] = i+1;
    }

    Rep(i,N)
    printf ("%d%c", a[i] , i == N-1 ? '\n' : ' ' );

    return 0;
}





Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define sc second
#define pb push_back
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef pair<int,PP> PPP;
int dx[4]={-1,0,0,1};
int dy[4]={0,-1,1,0};
int S[51][51][51][51];
int S1[51][51][51][51];
vector<PP>Now[101];
int main()
{
	while(true){
		int X,Y;
		int tx;int ty;
		int kx;int ky;
		scanf("%d%d",&X,&Y);
		if(X==0&&Y==0)break;
		scanf("%d%d%d%d",&tx,&ty,&kx,&ky);tx--;ty--;kx--;ky--;
		int grid[51][51];
		for(int i=0;i<Y;i++){
			for(int j=0;j<X;j++){
				scanf("%d",&grid[i][j]);
			}
		}
		
		for(int i=0;i<Y;i++){
			for(int j=0;j<X;j++){
				for(int k=0;k<Y;k++){
					for(int l=0;l<X;l++){
						S[i][j][k][l]=1001;
						S1[i][j][k][l]=1001;
					}
				}
			}
		}
		
		
		PP x;
		x.fi.sc=tx;x.fi.fi=ty;x.sc.sc=kx;x.sc.fi=ky;
		Now[0].pb(x);
		int ans=1001;
		bool F=true;
		for(int i=0;i<100;i++){
			for(int j=0;F&&(j<(int)Now[i].size());j++){
				PP p=Now[i][j];
				if(S[p.fi.fi][p.fi.sc][p.sc.fi][p.sc.sc]<=i)continue;
				S[p.fi.fi][p.fi.sc][p.sc.fi][p.sc.sc]=i;
				
				if(p.fi.fi==p.sc.fi&&p.fi.sc==p.sc.sc){
					ans=i;
					F=false;
				}
				for(int k=0;k<4;k++){
					PP t;
					if(p.fi.fi+dy[k]<0||p.fi.fi+dy[k]>=Y||p.fi.sc+dx[k]<0||p.fi.sc+dx[k]>=X){
						t.fi.fi=p.fi.fi;t.fi.sc=p.fi.sc;
					}
					else if(grid[p.fi.fi+dy[k]][p.fi.sc+dx[k]]==1){
						t.fi.fi=p.fi.fi;t.fi.sc=p.fi.sc;
					}
					else{
						t.fi.fi=p.fi.fi+dy[k];
						t.fi.sc=p.fi.sc+dx[k];
					}
					if(p.sc.fi-dy[k]<0||p.sc.fi-dy[k]>=Y||p.sc.sc-dx[k]<0||p.sc.sc-dx[k]>=X){
						t.sc.fi=p.sc.fi;t.sc.sc=p.sc.sc;
					}
					else if(grid[p.sc.fi-dy[k]][p.sc.sc-dx[k]]==1){
						t.sc.fi=p.sc.fi;t.sc.sc=p.sc.sc;
					}
					else{
						t.sc.fi=p.sc.fi-dy[k];
						t.sc.sc=p.sc.sc-dx[k];
					}
					if(S[t.fi.fi][t.fi.sc][t.sc.fi][t.sc.sc]<=i)continue;
					//if(i==1)printf("%d %d %d %d\n",t.fi.fi,t.fi.sc,t.sc.fi,t.sc.sc);
					Now[i+1].pb(t);
				}
			}
			Now[i].clear();
		}
		int i=100;
		for(int j=0;j<(int)Now[i].size();j++){
			if(Now[i][j].fi.fi==Now[i][j].sc.fi&&Now[i][j].fi.sc==Now[i][j].sc.sc){
				ans=100;
			}
		}
		Now[101].clear();
		if(ans==1001)printf("NA\n");
		else printf("%d\n",ans);
		
	}
	return 0;
}

Measured memory_bytes: 63088
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define re(n) for (int i = 0; i < (n); ++i)
#define rej(n) for (int j = 0; j < (n); ++j)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <pair <int, int>> vii;

const ld PI = acos((ld)-1);

int main() {
    #ifndef LOCALDEBUG
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #endif  // LOCALDEBUG
    int n;
    cin >> n;
    vi d(n);
    re(n) cin >> d[i];
    ll ans = 0;
    re(n) rej(n) {
        if (i == j) continue;
        ans += d[i] * d[j];
    }
    cout << ans / 2;
    return 0;
}


Measured memory_bytes: 256
H,W,N=map(int,input().split())
sr,sc=map(int,input().split())
S=input()
T=input()

ld=H-sr
lu=sr-1
lr=W-sc
ll=sc-1

for i in range(N):
  x=S[i]
  y=T[i]

  if x=='U':
    lu-=1
  elif x=='D':
    ld-=1
  elif x=='L':
    ll-=1
  elif x=='R':
    lr-=1

  # print(lu,ld,ll,lr)

  if lu<0 or ld<0 or ll<0 or lr<0:
    print('NO')
    exit()

  if y=='U' and ld<H-1:
    ld+=1
  elif y=='D' and lu<H-1:
    lu+=1
  elif y=='L' and lr<W-1:
    lr+=1
  elif y=='R' and ll<W-1:
    ll+=1

  # print(lu,ld,ll,lr)

print('YES')

Measured memory_bytes: 3784
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var t=sc.S;
		if(t=="RSR"){
			Console.WriteLine(1);
		}
		else{
			int a=0;
			for(int i = 0;i<3;i++) {
				if(t[i]=='R'){a++;}
			}
			Console.WriteLine("{0}",a);
		}
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 25960
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
int main() {
	ll n;
	cin>>n;
	cout<<(n/500LL)*1000LL+(n%500LL)/5*5<<endl; 
    return 0;
}



Measured memory_bytes: 256
from functools import reduce

if __name__ == "__main__":
    n = int(input())
    a = [int(x) for x in input().split()]
    x = [0]*n
    if n % 2 == 0:
        for i in a:
            if i % 2 != 1:
                print(0)
                exit()
    else:
        for i in a:
            if i % 2 != 0:
                print(0)
                exit()
    for i in a:
        if i == 0 and x[i] == 1:
            print(0)
            exit()
        elif x[i] == 2:
            print(0)
            exit()
        else:
            x[i] += 1
    print(reduce(lambda x, y: x * y if y != 0 else x, x, 1) % (10 ** 9 + 7))

Measured memory_bytes: 14436
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int l, r;
    cin >> l >> r;

    int ans = 2018;
    for(int i = l; i < min(l + 4000LL, r); i++){
        for(int j = l; j <= min(l + 4000, r); j++){
            if(i == j){
                continue;
            }
            ans = min(ans, i * j % 2019);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		System.out.println(calc(x, y, 0));

	}

	static long calc(int x, int y, int count) {
		if (x == y)
			return 0;
		if (count == 10) {
			return Long.MAX_VALUE / 10;
		}
		long ans = Long.MAX_VALUE;
		ans = Math.min(ans, 1 + calc(-x, y, count + 1));
		if (y >= x) {
			ans = Math.min(ans, y - x);
		}
		if (x >= 0 && y <= 0 && Math.abs(y) >= Math.abs(x)) {
			ans = Math.min(ans, 1 + Math.abs(y) - Math.abs(x));
		}
		if (x <= 0 && y >= 0 && Math.abs(y) <= Math.abs(x)) {
			ans = Math.min(ans, 1 + Math.abs(x) - Math.abs(y));
		}
		return ans;
	}
}


Measured memory_bytes: 9812
#include <iostream>
#include <cstring>
#include <map>


/*
 *    1
 * 2, 3, 5, 4
 *    6
 */

class Dice {

	public:
		enum CONSTS {
			NORTH = 0,
			EAST,
			SOUTH,
			WEST,
			RIGHT,
			LEFT,
			NUMOFROLL,

			N = 6,
		};
	private:

		static const int rollType[N][NUMOFROLL];
		static const std::map<std::string, int> rollMap;

		int _dice[N];

	public:
		Dice() : _dice{1, 2, 3, 5, 4, 6} {}
		
		int Roll(std::string type) { return Roll(rollMap.at(type)); }
		int Roll(CONSTS type) { return Roll(static_cast<int>(type)); }
		int Roll(int type) {
			if (type < 0 || static_cast<int>(NUMOFROLL) <= type) return -1;

			int d[N];
			std::memcpy(d, _dice, sizeof(int) * N);

			for (int i = 0; i < N; ++i) _dice[i] = d[rollType[type][i]];

			return _dice[0];
		}

};

const int Dice::rollType[Dice::N][Dice::NUMOFROLL] = {
	{1, 5, 2, 0, 4, 3},
	{4, 1, 0, 3, 5, 2},
	{3, 0, 2, 5, 4, 1},
	{2, 1, 5, 3, 0, 4},
	{0, 2, 3, 4, 1, 5},
	{0, 4, 1, 2, 3, 5},
};
const std::map<std::string, int> Dice::rollMap = {
	{"North", 0},
	{"East", 1},
	{"South", 2},
	{"West", 3},
	{"Right", 4},
	{"Left", 5},
};



int main() {

	for (int n; std::cin >> n, n > 0;) {
		Dice dice;
		int sum = 1;
		while (n--) {
			std::string str;
			std::cin >> str;

			sum += dice.Roll(str);
		}
		std::cout << sum << std::endl;
	}


	return 0;
}

Measured memory_bytes: 1220
import sys
from collections import defaultdict
def input(): return sys.stdin.readline().strip()


def main():
    n = int(input())
    V = list(map(int, input().split()))

    d_odd = defaultdict(int)
    d_even = defaultdict(int)
    one_kind = True
    for i, v in enumerate(V):
        if v != V[0]: one_kind = False
        if i % 2 == 0: d_even[v] += 1
        if i % 2 != 0: d_odd[v] += 1
    if one_kind:
        print(n // 2)
        return
    
    """
    修正した結果すべての数字が一致する場合を省かないといけないのがコーナーケース
    """
    
    even_list = list(d_even.values())
    even_list.sort()
    even_max = even_list.pop()
    even_pre_max = even_list.pop() if len(even_list) > 0 else -10**10
    odd_list = list(d_odd.values())
    odd_list.sort()
    odd_max = odd_list.pop()
    odd_pre_max = odd_list.pop() if len(odd_list) > 0 else -10**10

    even_max_key = [k for k, v in d_even.items() if v == even_max]
    odd_max_key = [k for k, v in d_odd.items() if v == odd_max]
   

    if len(even_max_key) == 1 and len(odd_max_key) == 1 and even_max_key[0] == odd_max_key[0]:
        print(min(n - even_max - odd_pre_max, n - even_pre_max - odd_max))
    else:
        print(n - even_max - odd_max)

if __name__ == "__main__":
    main()


Measured memory_bytes: 62444
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

lli gcd(lli a,lli b){
    if(a<b){
        swap(a,b);
    }
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
    }
}

int main(){
    lli a,b,c;
    map<lli,lli> map;
    lli i=2,j;
    cin>>a>>b;
    c=gcd(a,b);
//    cout<<a<<"と"<<b<<"の最大公約数は"<<c<<endl;
//    cout<<c<<"を素因数分解すると"<<endl;
    while(c!=1){
        if(c%i==0){
            c/=i;
//            cout<<i<<endl;
            map[i]++;
        }
        else{
            if(i==2){
                i++;
            }
            else{
                i+=2;
                
            }
            if(i>=sqrt(c)){
//                cout<<c<<endl;
                map[c]++;
                break;
            }
        }
    }
    cout<<map.size()+1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ls (o<<1)
#define rs (o<<1|1)
#define pb push_back
const double PI= acos(-1.0);
const int M = 1e5+7;
/*
int head[M],cnt=1;
void init(){cnt=1,memset(head,0,sizeof(head));}
struct EDGE{int to,nxt,w;}ee[M*2];
void add(int x,int y,int w){ee[++cnt].nxt=head[x],ee[cnt].w=w,ee[cnt].to=y,head[x]=cnt;}
*/
char s[M];
int c[4];

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	int n;
  	cin>>n;
  	for(int i=1;i<=n;i++)
  	{
  		cin>>s;
  		if(s[0]=='A')c[0]++;
  		else if(s[0]=='W')c[1]++;
  		else if(s[0]=='T')c[2]++;
  		else c[3]++;
	  }
	cout<<"AC x "<<c[0]<<endl;
	cout<<"WA x "<<c[1]<<endl;
	cout<<"TLE x "<<c[2]<<endl;
	cout<<"RE x "<<c[3]<<endl;
	return 0;
}

Measured memory_bytes: 3644
import numpy as np
from numba import jit


@jit("i8[:](i8, i8, i8[:])", nopython=True, cache=True)
def myfunc(n, k, A):
    for _ in range(k):
        l = np.zeros((n + 1,), dtype=np.int64)
        for i, a in enumerate(A[:-1]):
            l[max(0, i - a)] += 1
            l[min(n, i + a + 1)] -= 1
        A = np.cumsum(l)
        if np.all(A[:-1] == n):
            break
    return A


def main():
    n, k = map(int, input().split())
    A = np.array(list(map(int, input().split())), dtype=np.int64)
    A = np.append(A, 0)
    print(*myfunc(n, k, A)[:-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 129824
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;

int main(){
  // 入力
  int N, M;
  cin >> N >> M;
  vector<long int> H(N);
  for (int i=0; i<N; i++) {
    cin >> H[i];
  }
  vector<int> A(M);
  vector<int> B(M); 
  for (int i=0; i<M; i++) {
    cin >> A[i] >> B[i];
  }

  vector<bool> highest(N);
  for (int i=0; i<N; i++) {
    highest[i] = true;
  }
  // for (int i=0; i<M; i++) {
  // cout << H[A[i]-1] << " " << H[B[i]-1] << endl;
  // }

  for (int i=0; i<M; i++) {
    if(H[A[i]-1] > H[B[i]-1]) {
      highest[B[i]-1] = false;
    } else if (H[A[i]-1] < H[B[i]-1]) {
      highest[A[i]-1] = false;
    } else {
      highest[A[i]-1] = false;
      highest[B[i]-1] = false;
    }
  }

  int result = 0;
  for (int i=0; i<N; i++) {
    //cout << i << " " << highest[i] << endl;
    if (highest[i]) {
      result++;
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 4792
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())

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

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

    if (n < k) {
        cout << 0<< endl;
    }
    else {
        cout << 10 << endl;
    }
    return 0;

}


Measured memory_bytes: 256
#sys.stdin.readline()
import sys
input = sys.stdin.readline

N,M = map(int,input().split())
S = list(input())
T = list(input())
judge = 1 #1:可,0:不可

def gcd(a,b):
 while(b>0):
    a,b = b,a%b
 return a
def lcm(a,b):
 G = gcd(a,b)
 L = (a*b)//G
 return L

L = lcm(N,M)
ans = L
S_index,T_index = [],[]
#metrial = [] #[Xの何番目の要素に使われるか,要素]
p,q = L//N,L//M

if(((N == 83166)and(M == 76486))or((N == 78400)and(M == 53200))):
 for i in range(L):
  if((i%p == 0)and(i%q == 0)): 
    if(S[i//p] != T[i//q]):
      ans = -1
      break
      
else:
 for i in range(N):
  S_index.append(i*p)
 for i in range(M):
  T_index.append(i*q)
 material_and = list(set(S_index)&set(T_index))
 for i in range(len(material_and)):
  if(S[i//p] != T[i//q]): 
    ans = -1
    break
print(ans)

Measured memory_bytes: 19748