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

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int h = sc.nextInt();
        int w = sc.nextInt();
        
        char[][] field = new char[h][w];
        
        for(int i = 0; i < h; i++){
            String s = sc.next();
            for(int j = 0; j < w; j++){
                field[i][j] = s.charAt(j);
            }
        }
        
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(field[i][j] == '#'){
                    try{ if(field[i+1][j] == '#') continue; }catch(Exception e){}
                    try{ if(field[i-1][j] == '#') continue; } catch(Exception e){}
                    try{ if(field[i][j+1] == '#') continue;} catch(Exception e){}
                    try{ if(field[i][j-1] == '#') continue;} catch(Exception e){}
                    
                    System.out.println("No");
                    return;
                }
            }
        }
        
        System.out.println("Yes");
    }
}


Measured memory_bytes: 23124
from sys import setrecursionlimit
setrecursionlimit(2 * 10 ** 9)

n, m, k = map(int, input().split())

def dfs(u):
    if visited[u]:
        return

    visited[u] = True

    for v in graph[u]:
        s.add(v)
        dfs(v)

graph = {i: set() for i in range(n)}
blocks = {i: set() for i in range(n)}

for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1

    graph[a].add(b)
    graph[b].add(a)

for _ in range(k):
    c, d = map(int, input().split())
    c -= 1
    d -= 1

    blocks[c].add(d)
    blocks[d].add(c)

ans = [0] * n

visited = [False] * n

for u in range(n):
    if not visited[u]:
        s = set()

        dfs(u)

        l = len(s)

        for i in s:
            ans[i] += l - 1
            ans[i] -= len(blocks[i].intersection(s))
            ans[i] -= len(graph[i].intersection(s))

print(*ans)

Measured memory_bytes: 106992
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
 
using namespace std;
 
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
 
const ll INF=1e9+7;

int main(){
    string s,t;
    cin >> s >> t;
    ll n=s.length();
    ll m=t.length();
    vector<char> a(n);
    vector<char> b(m);
    
    rep(i,n){
        a[i]=s[i];
    }
    rep(i,m){
        b[i]=t[i];
    }
    sort(a.begin(),a.end());
    sort(b.rbegin(),b.rend());
    ll len=min(n,m);
    ll judge=2;
    rep(i,len){
        ll p=(ll)(a[i]-'a');
        ll q=(ll)(b[i]-'a');
        if(p>q){
            judge=0;
            break;
        }
        else if(p==q){
            
        }
        else{
            judge=1;
            break;
        }
    }
    if(judge==0) cout << "No" << endl;
    else if(judge==1) cout << "Yes" << endl;
    else{
        if(n>=m){
            cout << "No" << endl;
        }
        else{
            cout << "Yes" << endl;
        }
    }
    return 0;
} 

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int x;
	cin >> x;
	cout << (((x==3)||(x==5)||(x==7))?"YES":"NO") << endl;
	return 0;
}


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

int main(){
	int N,K;
  	cin >> N >> K;
  	vector<int> p(N);
  	for(int i=0;i<N;++i){
    	cin >> p[i];
    }
  	sort(p.begin(),p.end());
  	int sum=0;
   	for(int i=0;i<K;++i){
    	sum+=p[i];
    }
  	cout << sum << endl;
}

Measured memory_bytes: 3564
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{

    public static void Main( )
    {
        int N = int.Parse( Console.ReadLine( ) );
        var input = Console.ReadLine( ).Split( ).Select( int.Parse ).ToArray( );
        var eachNumberCount = input.GroupBy( x => x ).ToDictionary( x => x.Key, x => x.Count( ) );
        var resultMemo = new Dictionary<int, long>( );

        for ( int i = 0; i < N; i++ )
        {
            int exceptValue = input[ i ];
            eachNumberCount[ exceptValue ] -= 1;

            if ( resultMemo.ContainsKey( eachNumberCount[ exceptValue ] ) )
            {
                Console.WriteLine( resultMemo[ eachNumberCount[ exceptValue ] ] );
                eachNumberCount[ exceptValue ] += 1;
                continue;
            }
            long result = Calc( eachNumberCount );
            Console.WriteLine( result );
            resultMemo[ eachNumberCount[ exceptValue ] ] = result;

            eachNumberCount[ exceptValue ] += 1;
        }

    }

    public static long Calc( Dictionary<int, int> dict )
    {
        var choseWay = dict.Select( x => nCm( x.Value, 2 ) ).Sum( );
        return choseWay;
    }

    public static long nCm( int n, int m )
    {
        long numerator = 1;
        for ( int i = n; i > n - m; i-- ) numerator *= i;
        long denominator = 1;
        for ( int i = m; i >= 1; i-- ) denominator *= i;
        return numerator / denominator;
    }
}


Measured memory_bytes: 72388
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<complex>
#include<iomanip>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)
#define pi 3.14159265358979

int main(void){
	int z;
	for(;;){
	cin >> z;
	if(z==0) break;

	int m=0;
	for(int x=1;2*x*x*x<=z*z*z;x++){
	for(int y=x;y<z;y++){
	if(x*x*x+y*y*y<=z*z*z){
	if(m<x*x*x+y*y*y) m=x*x*x+y*y*y;
	}
	else break;
	}
	}

	cout << z*z*z-m << endl;

	}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n;
  int k;
  cin >> n >> k;
  vector<int> d(k);
  rep(i, k) cin >> d[i];
  vector<int> e(k);
  int ans = n;
  while(true){
    bool ok = true;
    string s = to_string(ans);
    rep(i, s.length()){
      rep(j, d.size()){
        if(s[i] - '0' == d[j]){
          ok = false;
          break;
        }
      }
    }
    if(ok) break;
    ans++;
  }
  cout << ans << endl;
}

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

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

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/

#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)

// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif


template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

#endif

#define mod 1000000007
//typedef pair<int, int> P;
#define INF (1LL<<60)




void solve(){
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A), b(B);
    rep(i,A) cin >> a[i];
    rep(i,B) cin >> b[i];
    int ans = *min_element(ALL(a)) + *min_element(ALL(b));
    while(M--){
        int x, y, c;
        cin >> x >> y >> c;
        ans = min(ans, a[x-1]+b[y-1]-c);
    }
    cout << ans << endl;
}

signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
  using namespace std;
  long long pwr(long long x, int e){
    if(e==0)
      return 1;
    long long tmp=pwr(x, e/2);
    tmp*=tmp;
    if(e%2)
      tmp*=x;
    return tmp;
  }
  int main(){
    long long n, k;
    while(cin>>n>>k){
      cout<<k*pwr(k-1, n-1)<<endl;
    }
    return 0;
  }





Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <climits>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main()
{
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	rep(i, n) cin >> a[i] >> b[i] >> c[i];

	int abest = 0, bbest = 0, cbest = 0;
	int atemp, btemp, ctemp;
	rep(i,n){
		//i日にaをしたときの最高値
		atemp = max(bbest, cbest) + a[i];
		btemp = max(cbest, abest) + b[i];
		ctemp = max(abest, bbest) + c[i];

		abest = atemp;
		bbest = btemp;
		cbest = ctemp;
 	}

	cout << max(max(abest, bbest), cbest) << endl;

}


Measured memory_bytes: 1408
from sys import stdin


def input():
    return stdin.readline()[:-1]


def intput():
    return int(input())


def sinput():
    return input().split()


def intsput():
    return map(int, sinput())


# Code

x = intput()

h = x // 100

if x - h * 100 in range(5 * h + 1):
    print(1)
else:
    print(0)


Measured memory_bytes: 2940
// How to derive the area of a polygon.
// https://imagingsolution.net/math/calc_n_point_area/

import java.awt.*;
import java.util.Scanner;

public class Main {
  private static double solve(int n, Point[] points) {
    double sum = 0;
    for (int i = 0; i < n; i++) {
      if (i == n - 1) {
        sum += points[i].getX() * points[0].getY() - points[0].getX() * points[i].getY();
      } else {
        sum += points[i].getX() * points[i + 1].getY() - points[i + 1].getX() * points[i].getY();
      }
    }
    return Math.abs(sum) / 2;
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int t = 1;
    while (true) {
      int n = Integer.parseInt(sc.nextLine());
      if (n == 0) break;
      Point[] points = new Point[n];
      for (int i = 0; i < n; i++) {
        points[i] = new Point();
        String[] xy = sc.nextLine().split(" ");
        points[i].setLocation(Integer.parseInt(xy[0]), Integer.parseInt(xy[1]));
      }
      double sum = solve(n, points);
      System.out.println((t++) + " " + String.format("%.1f", sum));
      sc.nextLine();
    }
    sc.close();
  }
}



Measured memory_bytes: 27904
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(long long int i=0;i<p;i++)
#define reep(i,p) for(long long int i=1;i<=p;i++)
#define ll long long

using namespace std;

long long int modpow(long long int a, long long int n, long long int mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){

ll int N;
cin >> N;

ll int M;
M=1000000007;

ll int X,Y,Z;
 X = modpow(10,N,M);
 Y = modpow(9,N,M);
 Z = modpow(8,N,M);
 Y = (Y*2)%M;
 ll int ans;
 ans = (((X+Z)%M)-Y)%M;
 if(ans<0){
	 ans += M;
 }
 else{}
 cout << ans;











	return 0;

}



Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;

int main(){
    int n,tmp;

    cin >> n;

    int max = 0;
    int ans = 0;

    for(int i = 0;i<n;i++){
        cin >> tmp;
        ans += tmp;
        if(max<tmp) max = tmp;
    }

    ans -= max/2;

    cout << ans << endl;

    return 0;
}

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

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vector<vector<t>>;
typedef long long ll;
typedef vc<int> vi;
typedef vvc<int> vvi;
typedef pair<int, int> pi;

#define uset unordered_set
#define umap unordered_map

#define endl "\n"

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()

#define all(a) a.bg, a.ed

template <class t, class u>
ostream &operator<<(ostream &os, const pair<t, u> &p) {
    return os << "( " << p.first << ", " << p.second << " )";
}

template <class t>
ostream &operator<<(ostream &os, const vc<t> &v) {
    os << "[ ";
    for (int i = 0; i < v.size(); i++) {
        os << v[i];
        if (i != v.size() - 1) {
            os << ", ";
        }
    }
    return os << " ]";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // cout << fixed << setprecision(18);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution

    string s;
    long long k;
    cin >> s >> k;
    // K < 2^days
    --k;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '1') {
            if (i == k) {
                cout << (char)s[i];
                return 0;
            }
        } else {
            cout << (char)s[i];
            return 0;
        }
    }
    cout << (char)s[0];
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t,temp;
	long long int n;
	cin>>s>>t;
	n=t.size();
	for(int i=0;i<n-1;i++)
	temp=temp+t[i];
	if(s==temp)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	
}

Measured memory_bytes: 3604
# 候補者 0..n-1 のn人
loop do
  n, stone_num = gets.chomp.split(" ").map{ |item| item.to_i }
  max_stone_nume = stone_num
  if n == 0 && stone_num == 0
    break
  end
  candidates = [0]*n
  index = 0
  loop do
    if index == candidates.length
      index = 0
    end
    if stone_num > 0
      stone_num -= 1
      candidates[index] += 1
      if candidates[index] == max_stone_nume
        puts index
        break
      end
    elsif candidates[index] > 0
      stone_num += candidates[index]
      candidates[index] = 0
    end
    index += 1
  end
end



Measured memory_bytes: 6848
from collections import Counter


def main():
    n = int(input())
    s = input()
    cnt = Counter(s)
    ans = cnt["R"] * cnt["G"] * cnt["B"]
    for gap in range(1, (n - 1) // 2 + 1):
        for i in range(n - gap * 2):
            if set([s[i], s[i + gap], s[i + 2 * gap]]) == {"R", "G", "B"}:
                ans -= 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9360
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }

    val arr = BooleanArray(n) { false }
    repeat(k) {
        val d = readLine()!!.toInt()
        val a = readLine()!!.split(' ').map { it.toInt() }
        a.forEach { aa->
            arr[aa-1] = true
        }
    }

    var ans = 0
    arr.forEach {
        if (!it) ans++
    }

    println(ans)

}


Measured memory_bytes: 39224
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
#define REP(i, a, b) for(int i = int(a); i <= int(b); i++)
#define LOOP(i, v) for(int i = 0; i < v.size(); i++)
#define EPS 1e-9
#define INF 1e12
#define debug(x) cerr << "DEBUG : " << (#x) << " => " << (x) << endl

int main()
{
  int x;
  scanf("%d", &x);
  printf("%d\n", x/3);
  
  return 0;
}

Measured memory_bytes: 384
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int mod = 1000000000 + 7;
vector<int> v;
class Calc
{
    // 宣言
    long long a;

    public:
        // 素因数分解
        void decompositPrime(long long a);
};

/*
 * 素因数分解
 */
void Calc::decompositPrime(long long n)
{
    // 割る数の初期値
    a = 2;
    // √n ≧ a ( n ≧ a * a ) の間ループ処理
    while (n >= a * a) {
        // a で割り切れたら、a は素因数
        // そして、割られる数を a で割る
        // a で割り切れなかったら、 a を 1 増加させる
        if (n % a == 0) {
            //printf("%d * ", a);
             v.push_back(a);
            n /= a;
        } else {
            a++;
        }
    }
    // 最後に残った n は素因数
    v.push_back(n);
    //printf("%d\n", n);
}

int main(){
    //std::stack<int> stack;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        string a,b;
        cin >> a >> b;
        int asize = a.size();
        int bsize = b.size();
        int mat[asize+1][bsize+1];
        a = " " + a;
        b = " " + b;
        mat[0][0] = 0;
        for(int i = 1; i <= asize; i++){
            mat[i][0] = 0;
        }
        for(int i = 1; i <= bsize; i++){
            mat[0][i] = 0;
        }
        for(int j = 1; j <= asize; j++){
            for(int k = 1; k <= bsize; k++){
                if(a[j] == b[k]){
                    mat[j][k] = mat[j-1][k-1]+1;
                }else{
                    mat[j][k] = max(mat[j-1][k], mat[j][k-1]);
                }
            }
        }
        // for(int i = 0; i <= asize; i++){
        //     for(int j = 0; j <= bsize; j++){
        //         cout << mat[i][j] << " ";
        //     }
        //     cout << endl;
        // }
        cout << mat[asize][bsize] << endl;
    }
    //cout << ans << endl;
    return 0;
}






Measured memory_bytes: 7012
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

typedef long long ll;

#define vi std::vector<int>
#define vl std::vector<ll>
#define floop(n) for(int i = 0; i < n; ++i)
#define print(x) std::cout << x << std::endl;

const ll INF = 1e18;

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

    if(N%1000 == 0)
    {
        print(0);
    }
    else
        print((((N/1000)+1)*1000)-N);

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <utility>
#include <string.h>
#include <math.h>
using namespace std;
typedef long long int ll;
const ll mod = 998244353;
const ll INF = 1e9 + 5;

ll check(ll n, ll i)
{
	while (n % i == 0)
		n /= i;
	if (n % i == 1)
		return 1;
	else
		return 0;
}

void solve()
{
	ll n, k, cnt=2;
	cin >> n;
	k = n - 1;
	if (n <= 4)
	{
		if (n == 2)
		{
			cout << 1 << endl;
			return;
		}
		if (n == 3)
		{
			cout << 2 << endl;
			return;
		}
		if (n == 4)
		{
			cout << 3 << endl;
			return;
		}
	}

	for (ll i = 2; i <= sqrt(k); i++)
		if (k % i == 0 && i != sqrt(k))
			cnt += 2;
		else if (i == sqrt(k))
			cnt++;

	for (ll i = 2; i <= sqrt(n); i++)
		if (n % i == 0)
			if (check(n, i))
				cnt++;

	cout << cnt << endl;
}

int main()
{
//	int t;
//	cin >> t;
//	while(t-->0)
	solve();
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VB=vector<bool>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define print(x) std::cout<<x<<"\n"
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = lcm(a, v[i]);} return a;}
VI Bit2Vector(const ll bit, ll n) {	VI s;	rep(i,n) if (bit & (1 << i)) s.push_back(i); return s;}


void Main()
{
	ll n,m,l; ll res=0;
	string s,t,u; string sres="No or NO";

	cin>>s;
	sres=s.substr(0,3);


	cout << sres << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 3644
#include<stdio.h>
#include<stdlib.h>
#define S 100000
#define T 50000

int main()
{
  int n,q,i,j,cnt = 0;
  int A[S],B[T];
  int left,right,mid;

  scanf("%d",&n);
  if(n > 100000)exit(1);
  for(i = 0 ; i < n ; i++){
    scanf("%d",&A[i]);
    if(A[i] < 0 || A[i] > 1000000000)exit(1);
    else if(A[i - 1] > A[i])exit(1);
  }

  scanf("%d",&q);
  if(q > 50000)exit(1);
  for(i = 0 ; i < q ; i++){
    scanf("%d",&B[i]);
    if(B[i] < 0 || B[i] > 1000000000)exit(1);
    for(j = 0 ; j < i ; j++){
        if(B[i] == B[j])exit(1);
    }
  }

  for(i = 0 ; i < q ; i++){
  left = 0;
  right = n;
      while(left < right){
          mid = (left + right) / 2;
          if(A[mid] == B[i]){
              cnt++;
              break;
          }
          else if(B[i] < A[mid])right = mid;
          else left = mid + 1;
      }
  }

  printf("%d\n",cnt);
  return 0;
}



Measured memory_bytes: 2384
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main() {
    int n;
    cin >> n;
    vi a(3);
    rep(i, 3) cin >> a[i];

    vi ans;

    vector<P> q;
    rep(i, n){
        string s; cin >> s;
        if(s == "BC") q.eb(1, 2);
        else if(s == "AC") q.eb(0, 2);
        else q.eb(0, 1);
    }
    
    auto add = [&](int x, int y){
        a[x]++;
        a[y]--;
        ans.pb(x);
    };
    
    q.eb(0, 1); // 番兵
    
    rep(i, n){
        int x = q[i].fi;
        int y = q[i].se;
        if(!a[x] && !a[y]){
            puts("No");
            return;
        }
        if(!a[x]) add(x, y);
        else if(!a[y]) add(y, x);
        else{
            int nx = q[i+1].fi;
            int ny = q[i+1].se;
            if(x == nx || x == ny){
                add(x, y);
            }else{
                add(y, x);
            }
        }
    }
    
    cout << "Yes" << endl;
    for(auto i : ans) cout << char('A' + i) << endl;
	return;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 4812
import java.util.*;
  
  class Main{
  	public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      String input =sc.nextLine();
           
      if(input.equals("SUN"))System.out.println('7');
      if(input.equals("MON"))System.out.println('6');
      if(input.equals("TUE"))System.out.println('5');
      if(input.equals("WED"))System.out.println('4');
      if(input.equals("THU"))System.out.println('3');
      if(input.equals("FRI"))System.out.println('2');
      if(input.equals("SAT"))System.out.println('1');
    }
  }

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

bool solve()
{
    ll H,W,N,h0,w0;
    string S,T;
    ll inf = 1LL << 60;
    cin >> H >> W >> N;
    cin >> h0 >> w0;
    h0 -= 1;
    w0 -= 1;
    cin >> S;
    cin >> T;
    ll Sl = w0;
    ll Sr = w0;
    ll Su = h0;
    ll Sd = h0;
    for (ll i = 0; i < N; ++i) {
        switch (S[i]) {
            case 'L': Sl -= 1; break;
            case 'R': Sr += 1; break;
            case 'U': Su -= 1; break;
            case 'D': Sd += 1; break;
        }
        if (Sl < 0) return false;
        if (Su < 0) return false;
        if (Sr >= W) return false;
        if (Sd >= H) return false;
        switch (T[i]) {
            case 'L': Sr = max(0LL, Sr-1); break;
            case 'R': Sl = min(W-1, Sl+1); break;
            case 'U': Sd = max(0LL, Sd-1); break;
            case 'D': Su = min(H-1, Su+1); break;
        }
    }
    return true;
}

int main()
{
    if (solve()) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


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

#define rep3(i, s, n ,a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(1){
        c -= b;
        if(c<=0){
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if(a<=0){
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DDerangement solver = new DDerangement();
        solver.solve(1, in, out);
        out.close();
    }

    static class DDerangement {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            int res = 0;

            for (int i = 0; i < n - 1; i++) {
                if (a[i] == i + 1) {
                    int tmp = a[i];
                    a[i] = a[i + 1];
                    a[i + 1] = tmp;
                    res++;
                }
            }
            if (a[n - 1] == n) res++;

            out.println(res);

        }

    }
}



Measured memory_bytes: 47776
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var s = Input().ToInt();
		
		if(s[0]*500>=s[1])
		{
			Console.WriteLine("Yes");
		}
		else
		{
			Console.WriteLine("No");
		
		}
		
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 11092
use proconio::input;
use proconio::marker::Chars;
use std::cmp;

#[allow(non_snake_case)]
fn main() {
    input! {
        S: Chars,
        T: Chars,
    }

    let mut ans = 1001;
    let sl = S.len();
    let tl = T.len();
    for i in 0..=(sl - tl) {
        let mut cnt = tl;
        for j in 0..tl {
            if S[i + j] == T[j] {
                cnt -= 1;
            }
        }
        ans = cmp::min(ans, cnt);
    }

    println!("{}", ans);
}


Measured memory_bytes: 2160
s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans)

Measured memory_bytes: 9396
s=input()
l=len(s)
ans=[1]*l
for i in range(l-2):
    if s[i]==s[i+1]=="R":
        ans[i+2]+=ans[i]
        ans[i]=0
for i in range(l-1,1,-1):
    if s[i]==s[i-1]=="L":
        ans[i-2]+=ans[i]
        ans[i]=0
print(*ans)

Measured memory_bytes: 6400
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.nextLine());

        for (int i = 0; i < N; i++) {
            String S = sc.nextLine();

            int B = 0;
            int C = 0;
            boolean flag = true;

            for (int j = 0; j < 10; j++) {
                int A = Integer.parseInt(S.split(" ")[j]);

                if (A > B) {
                    B = A;
                } else if (A > C) {
                    C = A;
                } else {
                    flag = false;
                    break;
                }
            }
            System.out.println((flag)? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 26060
from math import gcd
n=int(input())
mod=10**9+7
d1=dict()
d2=dict()
zero=0
zeroa=0
zerob=0
for _ in range(n):
    a,b=map(int,input().split())
    if a==0 and b==0:
        zero+=1
    elif a==0 and b!=0:
        zeroa+=1
    elif a!=0 and b==0:
        zerob+=1
    else:
        g=gcd(abs(a),abs(b))
        na=a//g
        nb=b//g
        if na<0:
            na=-na
            nb=-nb
        if (na,nb) not in d1 and (na,nb) not in d2:
            d1[(na,nb)]=1
            d2[(-nb,na)]=0
            d2[(nb,-na)]=0
        elif (na,nb) in d1:
            d1[(na,nb)]+=1
        else:
            d2[(na,nb)]+=1
#print(d1)
#print(d2)
d1=list(d1.items())
ans=pow(2,zeroa,mod)+pow(2,zerob,mod)-1
ans%=mod
for (a,b),cnt1 in d1:
  cnt2=0
  cnt2+=d2[(-b,a)]
  cnt2+=d2[(b,-a)]
  ans*=pow(2,cnt1,mod)+pow(2,cnt2,mod)-1
  ans%=mod
ans+=zero
ans=(ans+mod-1)%mod
print(ans)
#print(zeroa,zerob)

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

multiset<int> edge[100005];
int memo[100005],f=0;

void dfs(int now)
{
	for (auto i = edge[now].begin(); i != edge[now].end(); ++i)
	{
		if (memo[*i]==1)
		{
			f=1;
		}
		else if (memo[*i]==-1)
		{
			memo[*i]=0;
			edge[*i].erase(now);
			dfs(*i);
		}
	}
}

int main(int argc, char const *argv[])
{
	int n,m;
	cin>>n>>m;
	int a,b;
	for (int i = 0; i < m; ++i)
	{
		cin>>a>>b;--a;--b;
		edge[a].insert(b);
		edge[b].insert(a);
	}
	int s=-1,cnt=0;
	for (int i = 0; i < n; ++i)
	{
		if (edge[i].size()%2==1)
		{
			cout<<"No\n";
			return 0;
		}
		else if (edge[i].size()>=6)
		{
			cnt=100;
		}
		else if (edge[i].size()==4)
		{
			++cnt;
			if (cnt==1)
			{
				s=i;
			}
			else
			{
				edge[i]={};
			}
		}
	}
	if (cnt>=3)
	{
		cout<<"Yes\n";
		return 0;
	}
	else if (cnt<=1)
	{
		cout<<"No\n";
		return 0;
	}
	for (int i = 0; i < n; ++i)
	{
		memo[i]=-1;
	}
	memo[s]=1;
	dfs(s);
	if (f==1)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return 0;
}


Measured memory_bytes: 16640
#include<bits/stdc++.h>
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;
inline ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}	
int main()
{
	IO;
	int n;
	cin>>n;
	ll ans=0;
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=n;j++){
			for(ll k=1;k<=n;k++){
				ans+=gcd(i,gcd(j,k));
			}
		}
	}
	cout<<ans<<endl;
 	return 0;
}







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

using namespace std;
const double PI = M_PI;
double square(double a){
	return (double)a*a;
}
double dist(pair<double,double> a, pair<double,double> b){
	return sqrt(square(a.first-b.first)+square(a.second-b.second));
}
pair<double,double> point(double lenght, double deg){
	double x,y;
	x = lenght*sin(deg*PI/180);
	y = lenght*cos(deg*PI/180);
	return make_pair(x,y);
}

int main()
{
	double a,b,h,m;
	cin >> a >> b >> h >> m;
	double deg_h = 30*h+(double)(m/2.0);
	double deg_m = 6*m;
	cout <<setprecision(13)<< dist(point(a,deg_h),point(b,deg_m));
	return 0;
}


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

using namespace std;

#define INF 1e9

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

    long long a,b,c,k;

    cin>>a>>b>>c>>k;

    long long ans=a-b;

    if(k%2==1)ans*=-1;

    if(abs(ans)>1e18)cout<<"Unfair"<<endl;

    else cout<<ans<<endl;

}

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

int gcd(int a, int b) { return (a % b) ? gcd(b, a % b) : b; }
int gcd3(int a, int b, int c) { return gcd(gcd(a, b), c); }

int main()
{
	int k;
	cin >> k;
	ll sum = 0;
	for (int a = 1; a <= k; a++) {
		for (int b = 1; b <= k; b++) {
			for (int c = 1; c <= k; c++) {
				sum += gcd3(a, b, c);
			}
		}
	}
	cout << sum << endl;
	return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

ll inf=__LONG_LONG_MAX__/3;

int main()
{
    ll h,n,ans=inf;
    cin>>h>>n;
    vector<ll> a(n),b(n);
    for (int i = 0; i < n; i++)
    {
        cin>>a[i]>>b[i];
    }
    vector<ll> dp(50000);
    for (int i = 1; i < 50000; i++)
    {
        dp[i]=inf;
    }
    for (ll waza = 0; waza < n; waza++)
    {
        for (ll nowPlace = 0; nowPlace < h; nowPlace++)
        {
            dp[nowPlace+a[waza]]=min(dp[nowPlace+a[waza]], dp[nowPlace]+b[waza]);
            if(nowPlace+a[waza]>=h)
            {
                ans=min(ans,dp[nowPlace+a[waza]]);
            }
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			for(;;) {
				String str = sc.nextLine();
				if(str.contentEquals("0")) break;
				int sum = 0;
				for(int i = 0;i<str.length();i++) {
					sum += str.charAt(i)-48;
				}
				System.out.println(sum);
			}
		}
	}
}


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

struct Edge {
    int to;
    ull weight;
    Edge (int t, ull w) : to(t), weight(w) {};
};
using Tree = vector<vector<Edge>>;

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

    Tree T(N);
    int ai, bi;
    ull ci;
    rep(i, N-1) {
        cin >> ai >> bi >> ci;
        ai--, bi--;
        T[ai].push_back(Edge(bi, ci));
        T[bi].push_back(Edge(ai, ci));
    }

    int Q, K;
    cin >> Q >> K;

    ull dist[N];
    bool seen[N];
    rep(i, N) dist[i] = 0, seen[i] = false;
    queue<int> que;
    que.push(--K);

    while (que.size() > 0) {
        int v;
        v = que.front(), que.pop();
        seen[v] = true;
        for (auto e : T[v]) {
            if (seen[e.to] == false) {
                dist[e.to] = dist[v] + e.weight;
                que.push(e.to);
            }
        }
    }

    int xi, yi;
    rep(i, Q) {
        cin >> xi >> yi;
        xi--, yi--;
        cout << dist[xi] + dist[yi] << endl;
    }

    return 0;
}



Measured memory_bytes: 10112
void main()
{
    long n = rdElem;
    Edge[][] edge = new Edge[][](n);
    foreach (i; 0 .. n-1)
    {
        long a, b;
        rdVals(a, b);
        --a, --b;
        edge[a] ~= Edge(b, i), edge[b] ~= Edge(a, i);
    }

    long[] list = new long[n-1];
    list[] = -1;

    void dfs(long x, long from, long color)
    {
        long c = 1;
        foreach (e; edge[x])
        {
            if (e.to == from) continue;
            if (c == color) ++c;
            list[e.idx] = c;
            dfs(e.to, x, c);
            ++c;
        }
    }

    dfs(0, -1, -1);

    list.reduce!max.writeln;
    foreach (l; list)
    {
        l.writeln;
    }
}

struct Edge
{
    long to, idx;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 18812
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define fi first
#define se second
using namespace std;
using pii = pair<int,int>;
using vi = vector<int>;
using ll = long long;

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

    int table[] = {6000, 4000, 3000, 2000};
    for (int i=0; i<4; ++i) {
        int t, n;
        cin >> t >> n;
        --t;
        outl(table[t] * n);
    }
}




Measured memory_bytes: 3140
X,N = map(int, input().split())
P = list(map(int, input().split()))

if len(P) == 0:
  print(X)
else:
  for i in range(0,10000):
    if P.count(X-i) == 0:
      print(X-i)
      break
    elif P.count(X+i) == 0:
      print(X+i)
      break
    else:
      continue

Measured memory_bytes: 9184
import math

a,b,x=map(int,input().split())

if x<a*a*b/2:
    a2=2*x/a/b
    t=math.atan(b/a2)*180/math.pi
    print(t)
else:
    t=math.atan(2*(b-x/a/a)/a)*180/math.pi
    print(t)
    

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
typedef long long ll;
using namespace std;
int main(){
    ll h;
    cin >> h;
    int i=0;
    ll cnt = 0;
    while(h>0){
        h = h/2;
        i++;
        }
        cnt = pow(2,i)-1;
        cout <<cnt<< endl;
        }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};
const int NMAX=1e+6+10;
mint fact[NMAX],infac[NMAX];
void Make_Fact(){
  fact[0]=fact[1]=1;
  for(int i=2;i<=NMAX-1;++i){
    fact[i]=fact[i-1]*(mint)i;
  }
}
void Make_InvFact(){
  infac[0]=infac[1]=1;
  for(int i=2;i<=NMAX-1;++i){
    infac[i]=infac[i-1]/(mint)i;	
  }
}
mint Comb(ll n,ll k){
  if(n<0||k<0||n-k<0) return 0;
  return fact[n]*infac[k]*infac[n-k];
}

int main()
{
  Make_Fact();
  Make_InvFact();
  ll x,y;
  cin >> x >> y;
  if((x+y)%3!=0){
    cout << 0 << "\n";
  }
  else{
    ll num = (x+y)/3;
    ll d = abs(x-y);
    if(d>num){
      cout << 0 << "\n";
    }
    else{
      mint res=Comb(num,(num-d)/2);
      cout << res.x << "\n";
    }
  }
  return 0;
}


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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

int main(){
    ll N,K;
    cin >> N >> K;
    cout << min(N%K,K-N%K);
}


Measured memory_bytes: 256
k = int(input())
m = 7
if(k%2==0):
  print("-1")
else:
  i = 1
  while True:
    m = m%k
    if(m==0):
      print(i)
      break  
    if(i>k):
      print("-1")
      break
    m *= 10
    m += 7
    i += 1



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

int main(){
	int a, b, d, r;
	double a2, b2, f;
	cin >> a >> b;
	a2 = a;
	b2 = b;
	d = a / b;
	r = a % b;
	f = a2 / b2;
	printf("%d %d %.5lf", d,r,f);
	 }
	

Measured memory_bytes: 1176
#include<bits/stdc++.h>
#define ll long long 
#define inf 0x7fffffff
#define infll 0x7fffffffffffffff
#define clr(c) memset(c,0,sizeof(c))
using namespace std;
int mod=998244353;
const int M=1e6+10;
const int N=3e5+10;
inline ll read(){
    ll b=1,sum=0; char c=getchar();
    while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
    while(isdigit(c)){sum=sum*10+c-'0'; c=getchar();}
    return b*sum;
}
int T,n,m,k;
int ans;
int a[N];
int main()
{
    int i,j;
	ans=0;
	n=read();m=read();
	if(m>=n) printf("unsafe");
	else printf("safe");
	
	printf("\n");
    return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, a;
	cin >> n;
	set<ll> s;
	string ans = "YES";
	zep(i, 0, n){
		cin >> a;
		if(s.find(a) != s.end()){
			ans = "NO";
		}
		s.insert(a);
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 9600
import math
n = int(input())  
x = [0] * n
y = [0] * n
for i in range(0,n):
    # print(i,c,s[i:i+1],x)
    (x[i],y[i]) = map(int,input().split())  
    # print(x[i],y[i]) 

    
sum=float(0)
for i in range(0,n-1):
    for j in range(i+1,n):
        sum = sum + math.sqrt((x[i] - x[j])**2 + (y[i] - y[j])**2)

av = float(sum) / ( n / 2 )
print(av)

Measured memory_bytes: 3064
def main():
    n = int(input())
    t = list(map(int, input().split()))
    a = list(map(int, input().split()))

    is_certain, h = [0 for i in range(n)], t[:]
    is_certain[0] = 1
    for i in range(1, n):
        if t[i] > t[i-1]:
            is_certain[i] = 1

    if is_certain[-1] and h[-1] != a[-1]:
        print(0)
        exit()
    else:
        h[-1] = a[-1]
        is_certain[-1] = 1

    for i in range(n-2, -1, -1):
        if a[i] > a[i+1]:
            if is_certain[i] and h[i] != a[i]:
                print(0)
                exit()
            else:
                h[i] = a[i]
                is_certain[i] = 1
        elif is_certain[i] and a[i] < h[i]:
            print(0)
            exit()
        else:
            h[i] = min(h[i], a[i])

    ans = 1
    for i in range(n):
        if not is_certain[i]:
            ans = ans * h[i] % 1000000007

    print(ans)


if __name__ == '__main__':
    main()


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

#define ll long long
#define ld long double
#define mod 1000000007LL
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define endl '\n'
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define pb(x) push_back(x)
#define fo(i, a, n) for (i = (a); i < (n); i++)
#define foe(i, a, n) for (i = (a); i <= (n); i++)
// clang-format off
#define vin(a) for (ll i = 0; i < sz(a); i++) { cin >> a[i]; } 
#define vout(a) for (auto x : a) { cout << x << " "; }
#define sws                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0)
// clang-format on
#define pd(x) cout << x
#define sd(x) cin >> x
#define nl cout << endl
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define foreach(i, a)                                                          \
  for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
// int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
void solve() {
  ll m, n;
  ll i, j;
  string s;
  cin >> s;
  n = s.length();
  if (s[n - 1] == 's')
    s += "es";
  else
    s += 's';
  cout << s << endl;
}

int main() {
  sws;
  solve();
  return 0;
}

Measured memory_bytes: 3652