akhauriyash/Code-Regression huggingface dataset:
import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextInt()
    val a = cin.nextInt()
    val b = cin.nextInt()
 
    if ((b-a)%2 == 0) {
        println("Alice")
    } else {
        println("Borys")
    }
}

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

int main(){
    long D, N;
    cin >> D >> N;

    long result = 1;

    for(int i = 0; i < D; i ++){
        result *= 100;
    }
    if(N == 100){
        N += 1;
    }
    result *= N;
    
    
    cout << result << endl;  
    
    return 0;
}

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


int main(){
  int N;
  cin >> N;
  vector<vector<int>> H(N, vector<int>(2, 0));
  for(int ii=0; ii<N; ii++){
    string s;
    cin >> s;
    for(auto c : s){
      if(c=='(') H[ii][0]++;
      else H[ii][0]--;
      H[ii][1] = min(H[ii][1], H[ii][0]);
    }
  }

  sort(H.begin(), H.end(), [](vector<int>& a, vector<int>& b){
    if(a[0]>0 && b[0]>0) return a[1] > b[1];
    if(a[0]<=0 && b[0]<=0) return a[1]-a[0] < b[1]-b[0];
    if(a[0]>0 && b[0]<=0) return true;
    if(a[0]<=0 && b[0]>0) return false;
  });

  long long int height=0;
  for(auto& h : H){
    if(height + h[0] < 0){
      cout << "No" << endl;
      return 0;
    }
    if(height + h[1] < 0){
      cout << "No" << endl;
      return 0;
    }
    height += h[0];
  }
  cout << (height==0?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 57824
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int X, Y;
        public long MOD = 1000000007;
        public int[] used;
        public long[,] DP;

        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                X = line[0];
                Y = line[1];
            }
            Console.WriteLine(X + Y/2);
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13396
import math
import itertools
N = int(input())
town = []
kyori = []
for i in range(N):
  x,y = map(int, input().split())
  town.append([x,y])
  
for route in itertools.permutations(town, N):
  L = 0
  for i in range(N-1):
    L = L + math.sqrt((route[i+1][0]-route[i][0])**2 + (route[i+1][1]-route[i][1])**2)
  kyori.append(L)

print(sum(kyori)/math.factorial(N))


Measured memory_bytes: 4404
#include<stdio.h>
#define max 1000

int main(){
  int m,n,u,k,i,j;
  int a[max][max];
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&m);
      a[u-1][m-1]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n-1;j++){
      printf("%d ",a[i][j]);
    }
    printf("%d\n",a[i][j]);
  }

  return 0;
}



Measured memory_bytes: 2108
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)

Alice = 0
Bob = 0
for i in range(N):
  temp = A.pop(0)
  if i % 2 == 0:
    Alice += temp
  else:
    Bob += temp

print(str(Alice - Bob))

Measured memory_bytes: 9116
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll tonum(string s)
{
	ll cur = 0; ll t = 1;
	for(int i = s.length()-1; i>=0; i--)
	{
		cur += (s[i]-'0')*t;
		t*=10;
	}
	return cur;
}

string cut(string s, int l, int r)
{
	string ans;
	for(int i = l; i <= r; i++)
	{
		ans += s[i];
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s;
	cin >> s;
	int n = s.length();
	if(n == 1)
	{
		cout << s; return 0;
	}
	ll ans = 0;
	for(int i = 0; i < (1<<(n-1)); i++)
	{
		int l = 0;
		for(int j = 0; j < n - 1; j++)
		{
			if(i&(1<<j))
			{
				//cout << i << ' ' << l << ' ' << j << '\n';
				ans += tonum(cut(s, l, j));
				//cout << tonum(cut(s,l,j)) << '\n';
				l = j + 1;
			}
		}
		ans += tonum(cut(s,l,n-1));
	}
	cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
#define N 500010
#define M 2000010
ll n,a[N],c[N],cs[N];
ll sum(ll l,ll r){
  return cs[r+1]-cs[l];
}
vector<ll> v[M];
ll f[N],g[N];
void solve(ll k){
  ll m=v[k].size();
  for(int i=0;i<=m;i++)f[i]=g[i]=0;
  g[0]=1;
  ll bef=0;
  for(int i=0;i<m;i++){
    mad(f[i+1],f[i]*(1+sum(bef,v[k][i]))); mad(g[i+1],f[i]*sum(bef,v[k][i]));
    mad(f[i+1],g[i]); mad(g[i+1],g[i]);
    bef=v[k][i];
  }
  if(k==-1){
    for(int i=0;i<=m;i++)cout<<f[i]<<" ";cout<<endl;
    for(int i=0;i<=m;i++)cout<<g[i]<<" ";cout<<endl;
  }
}
ll po(ll x,ll y){
  ll res=1;
  for(;y;y>>=1){
    if(y&1)res=res*x%mod;
    x=x*x%mod;
  }
  return res;
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    c[0]=0;
    for(int i=0;i<n;i++)c[i+1]=c[i] xor a[i];
    for(int i=0;i<=n;i++){
      v[c[i]].push_back(i);
    }
    for(int i=0;i<=n+1;i++)cs[i]=0;
    for(int i=0;i<v[0].size();i++){
      cs[v[0][i]+1]++;
    }
    //for(int i=0;i<=n;i++)cout<<c[i]<<" ";cout<<endl;
    for(int i=0;i<=n+1;i++)cs[i]+=cs[i-1];
    if(c[n]==0){
      ll ans=0;
      for(int k=1;k<M;k++){
	if(v[k].size()==0)continue;
	solve(k);
	//cout<<k<<":"<<f[v[k].size()]<<endl;
	mad(ans,f[v[k].size()]);
      }
      mad(ans,po(2,v[0].size()-2));
      ans%=mod; if(ans<0)ans+=mod;
      cout<<ans<<endl;
    }
    else{
      v[c[n]].pop_back();
      solve(c[n]); 
      ll ans=g[v[c[n]].size()];
      if(v[c[n]].size()>0){
	ll bef=v[c[n]].back();
	mad(ans,f[v[c[n]].size()]*sum(bef,n));
      }
      ans%=mod; if(ans<0)ans+=mod;
      cout<<ans<<endl;
    }
    return 0;
}


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

int main()
{
    double a, b, h, m;
    double adeg, bdeg, diff;
    double ans;
    double radiff;
    cin >> a >> b >> h >> m;
    adeg = m * 6;           //aの角度
    bdeg = (h * 60 + m) / 2; //bの角度
    diff = abs(adeg - bdeg);
    if (diff > 180)
    {
        diff = 360 - diff;
    }
    if(adeg==bdeg){
        cout << abs(a-b) << endl;
        return 0;
    }
    radiff = (double)((diff * PI) / 180);
    ans = (double)(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(radiff));
    ans = sqrt(ans);

    cout << setprecision(11) << ans << endl;

    return 0;
}

Measured memory_bytes: 4164
#include <iostream>
#include <cstdlib>
#include <cstdio>
#define N 3011
using namespace std;
struct apple{
	int v,nxt;
}edge[N*4];
int indexx[N],tot,n,val[N];
void addedge(int x,int y){
	edge[++tot].v=y;
	edge[tot].nxt=indexx[x];
	indexx[x]=tot;
}
int dfs(int u,int fa){
	int t=indexx[u],vv,sum=val[u];
	while(t){
		vv=edge[t].v;
		if(vv!=fa){
			int k=dfs(vv,u);
			if(!k && val[vv]<val[u]) return 1;
		}
		t=edge[t].nxt;
	}
	return 0;
}
int main(){
	int x,y;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&val[i]);
	for(int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		addedge(x,y);
		addedge(y,x);
	}
	for(int i=1;i<=n;i++){
		int k=dfs(i,0);
		if(k ) printf("%d ",i);
	}
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int n; cin>>n;
  int cnt = 0;
  rep(i,n){
    int a; cin>>a;
    if(a%2) cnt++;
  }
  if(cnt%2) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;

  return 0;
}


Measured memory_bytes: 256
n, k = [int(i) for i in input().split()]
s = input()

ans = 0
lblocks = 0
# if s[0] == "L":
#     lblocks += 1
flag = False
if s[0] == "L":
    flag = True
for i,v in enumerate(s):
    if i == 0:
        continue
    if s[i] == s[i-1]:
        ans += 1
    if s[i] == "L":
        if not flag:
            lblocks += 1
            flag = True
    else:
        flag = False
if lblocks == 0:
    print(n-1)
else:
    if lblocks < k:
        print(n-1)
    else:
        print(ans+k+k)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];
    ll ans = 1;

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

    for(int i = 0; i < N; ++i){
        if((long double)log10(ans) + (long double)log10(A[i]) > 18
         || ans*A[i] > 1000000000000000000){
            ans = -1;
            break;
        }
        ans *= A[i];
    }

    cout << ans << endl;
}


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

int partition(vector<int>& A, int p, int r) {
  int x = A[r];
  int i = p - 1;
  for (int j = p; j < r; j++) {
    if (A[j] <= x) {
      i++;
      int tmp = A[j];
      A[j] = A[i];
      A[i] = tmp;
    }
  }
  int tmp = A[i + 1];
  A[i + 1] = A[r];
  A[r] = tmp;
  return i + 1;
}

int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  int index = partition(A, 0, n - 1);
  for (int i = 0; i < n; i++) {
    if (i == index) {
      cout << '[' << A[i] << ']';
    } else cout << A[i];
    if (i == n - 1) {
      cout << endl;
    } else cout << ' ';
  }
};



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

int main()
{
  int i,j,n,**a,u,k,v;
  scanf("%d",&n);
  a = (int**)malloc(sizeof(int*) * n);
  for (i = 0; i < n; i++) {
    a[i] = (int*)malloc(sizeof(int) * n);
    for(j = 0; j < n; j++) a[i][j] = 0;
  }
  for (i = 0; i < n; i++) {
    scanf("%d",&u);
    scanf("%d", &k);
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      a[u-1][v-1] = 1;
    }
  }

  for (i = 0; i < n; i++) {
    for(j = 0; j < n-1; j++) printf("%d ", a[i][j]);
    printf("%d\n",a[i][j]);
  }

  
  return 0;
}

Measured memory_bytes: 632
#include<bits/stdc++.h>
using namespace std;
 
typedef pair< char, char > Pi; // 2個
typedef pair< Pi, Pi > Pii; // 4個
typedef pair< Pii, Pii > Piii; // 8個
typedef pair< Piii, int > Piiii; // 9個
 
int n;
vector< char > barabara(10);
map< Piiii, char > dp;
 
 
vector< vector< char > > mask;
 
char manzyu(vector< char >& mans)
{
  if(dp.find(Piiii(Piii(Pii( Pi(mans[1], mans[2]), Pi(mans[3], mans[4])), Pii(Pi(mans[5], mans[6]), Pi(mans[7], mans[8]))), mans[9])) != dp.end()) return(dp[Piiii(Piii(Pii( Pi(mans[1], mans[2]), Pi(mans[3], mans[4])), Pii(Pi(mans[5], mans[6]), Pi(mans[7], mans[8]))), mans[9])]);
  char ret = 0;
  for(int i = 0; i < mask.size(); i++) {
    if(mans[1] >= mask[i][1] && mans[2] >= mask[i][2] && mans[3] >= mask[i][3] && mans[4] >= mask[i][4] && mans[5] >= mask[i][5] && mans[6] >= mask[i][6] && mans[7] >= mask[i][7] && mans[8] >= mask[i][8] && mans[9] >= mask[i][9]) {
      for(int j = 1; j < 10; j++) {
        mans[j] -= mask[i][j];
      }
      ret = max(ret, (char)(manzyu(mans) + 1));
      for(int j = 1; j < 10; j++) {
        mans[j] += mask[i][j];
      }
    }
  }
  return(dp[Piiii(Piii(Pii( Pi(mans[1], mans[2]), Pi(mans[3], mans[4])), Pii(Pi(mans[5], mans[6]), Pi(mans[7], mans[8]))), mans[9])] = ret);
}
 
 
 
void isten(vector< char >& ret, int digit, int sum) {
  if(digit <= 0 || sum > 10) {
    return;
  } else if(sum == 10) {
    mask.push_back(ret);
    return;
  } else {
    isten(ret, digit - 1, sum);
    ret[digit]++;
    isten(ret, digit, sum + digit);
    ret[digit]--;
  }
}
 
int main() {
  vector< char > buff(10, 0);
  isten(buff, 9, 0);
 
  while(cin >> n, n) {
    for(int i = 1; i < 10; i++) barabara[i] = 0;
    dp.clear();
    for(int i = 0; i < n; i++) {
      int m;
      cin >> m;
      barabara[m]++;
    }
 
    int prad = 0;
    for(int i = 1; i <= 4; i++) {
      int cost = min(barabara[i], barabara[10 - i]);
      prad += cost;
      barabara[i] -= cost;
      barabara[10 - i] -= cost;
    }
    prad += barabara[5] / 2;
    barabara[5] -= barabara[5] / 2 * 2;
     
    cout << (int)manzyu(barabara) + prad << endl;
  }
}

Measured memory_bytes: 4492
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ll long long int
#define fast ios_base::sync_with_stdio(false)
#define fast_input cin.tie(NULL)
#define fast_output cout.tie(NULL)
#define vi vector<long long int> 
#define F first
#define S second
#define pb push_back
#define f(a,j,b) for(int a=j;a<b;a++)
void solve()
{
   string s,t;
   cin>>s>>t;
   ll dp[s.length()+1][t.length()+1];
   ll n=s.length();
   ll m=t.length();
   f(i,0,n+1)
   {
	   dp[i][0]=0;
   }
   f(i,0,m+1)
   {
	   dp[0][i]=0;
   }
   f(i,1,n+1)
   {
	   f(j,1,m+1)
	   {
		   if(s[i-1]==t[j-1])
		   {
			   dp[i][j]=dp[i-1][j-1]+1;
		   }
		   else
		   {
			   dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		   }
		//    cout<<dp[i][j]<<" ";
	   }
	//    cout<<endl;
   }
   vi in;
   ll l=n,r=m;
   while(dp[l][r]>0)
   {
	   if(s[l-1]==t[r-1])
	   {
		   in.pb(l);
		   l--,r--;
	   }
	   else
	   {
		   if(dp[l][r-1]>dp[l-1][r])
		     r--;
		   else
		   {
			   l--;
		   }  
	   }
	   
   }
   string ans;
   for(ll d:in)
   {
	    //    cout<<d<<" ";
           ans.pb(s[d-1]);
   }
   reverse(ans.begin(),ans.end());
   cout<<ans<<endl;
}
int main() {
	fast;
	fast_input;
	fast_output;
	// ll t;
	// cin>>t;
	// f(i,t)
	// {
    //   cout<<"Case #"<<i+1<<":"<<" ";
	     solve();
	// }
	return 0;
}

Measured memory_bytes: 70656
N = int(input())

if N==1:
    print(0)
elif N==2:
    print(2)
else:
    a=(10**(N))
    b1=(9**(N))
    b2 = (8 ** (N))
    c=(a-2*b1+b2)%(10**9+7)
    print(int(c))



Measured memory_bytes: 81004
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld double
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pll pair <ll,ll>
#define nl "\n"
 
int main()
{
	ios_base::sync_with_stdio(false);
	ll a,b,k;
	cin>>a>>b>>k;
	if(k<=a)
	{
		cout<<a-k<<" "<<b<<nl;
	}
	else
	{
		k-=a;
		if(k>=b)
			cout<<"0 0\n";
		else
			cout<<"0 "<<b-k<<nl;
	}
	return 0;
}

Measured memory_bytes: 256
import math
N=int(input())
A=list(map(lambda x:x-1,list(map(int,input().split()))))
B=list(map(lambda x:x-1,list(map(int,input().split()))))
a=0
for i in range(N):
    Apart=A[:i]
    order=0
    for aparts in Apart:
        if aparts<A[i]:
            order+=1
    a+=math.factorial(N-i-1)*(A[i]-order)
b=0
for i in range(N):
    Bpart=B[:i]
    order=0
    for bparts in Bpart:
        if bparts<B[i]:
            order+=1
    b+=math.factorial(N-i-1)*(B[i]-order)
print(abs(a-b))

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

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        //bytesのiterを生成
        .bytes()
        //それをas charでchar型に変換したiterを生成
        .map(|c| c.expect("failed to read char") as char)
        //c.is_whitespace()がfalseになるまで（つまり普通の文字が出るまで）iterを進めたiterを生成
        .skip_while(|c| c.is_whitespace())
        // !c.is_whitespace()がtrue, 即ち（普通の文字の間）iterを進め, 進んだところまでのiterを生成
        .take_while(|c| !c.is_whitespace())
        // それをcollect()してiterからStringを作る
        .collect();
    // parse()で任意の型に変換して返す。
    token.parse().ok().expect("failed to parse token")
}


fn read_one_line_to_vec<T: FromStr>() -> Vec<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let v: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c == &'\x0d' || c == &'\x0a')
        .take_while(|c| !(c == &'\x0d' || c == &'\x0a'))
        .collect();
    v.split_whitespace()
        .map(|c| { let string = c.to_string();
            string.parse::<T>().ok().expect("failed to parse token")})
        .collect()
}

fn main() {
    // ALDS1_3_A_Stack
    let input_data: Vec<String> = read_one_line_to_vec();
    let mut stack = Vec::<i32>::new();

    for c in input_data.into_iter() {
        match c.parse::<i32>() {
            Ok(num) => {
                stack.push(num);
            },
            Err(_function) => {
                let v1 = stack.pop().unwrap();
                let v2 = stack.pop().unwrap();
                if c == String::from("+") {
                    stack.push(v2 + v1);
                } else if c == String::from("-") {
                    stack.push(v2 - v1);
                } else if c == String::from("*") {
                    stack.push(v2 * v1);
                }
            }
        }
    }
    println!("{}", stack[0]);
}

fn print_vec(v: Vec<i32>) {
    let mut v_iter = v.iter();
    print!("{}", v_iter.next().as_ref().unwrap());
    for v in v_iter {
        print!(" {}", v)
    }
    println!();
}



Measured memory_bytes: 5036
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	ini(n);
	ins(a);
	int total = 1;
	FOR(i,1,n){
		if(a[i]!=a[i-1])total++;
	}
	out(total);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int mod = 1e9+7;
//26

int d[50][50], a[600][600], dis[3][50];
signed main(){
	int n, m, ans = INF;
	scanf("%lld%lld", &n, &m);
	rrep(i,m)rrep(j,m)scanf("%lld", &d[i][j]);
	rrep(i,n)rrep(j,n)scanf("%lld", &a[i][j]);
	
	rep(i,3)rrep(j,m){
		int tmp = 0;
		rrep(y,n)rrep(x,n){
			if((y+x)%3 == i)tmp += d[a[y][x]][j];
		}
		dis[i][j] = tmp;
	}
	
	//printf("*%lld*\n", dis[0][2]);
	rrep(i,m)rrep(j,m)rrep(k,m){
		if(i == j or j == k or i == k)continue;
		int color[] = {i, j, k}, tmp = 0;
		tmp = dis[0][i]+dis[1][j]+dis[2][k];
		//if(tmp == 0)printf("%lld %lld %lld\n", i, j, k);
		/*rrep(y,n)rrep(x,n){
			tmp += d[a[y][x]][color[(y+x)%3]];
		}*/
		//if(tmp == 2)printf("%lld %lld %lld\n", i, j, k);
		chmin(ans, tmp);
	}
	printf("%lld\n", ans);
	/*rrep(i,m){
		rrep(j,m)printf("%lld ", d[i][j]);
		printf("\n");
	}*/
	return 0;
}





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

int main()
{
    int n,m,mm,s=0,ss=0;
    cin>>n>>m;
    mm=m;
    for(int i=0;i<n;i++)
    {
        s+=m;
        m*=10;
    }
    for(int i=0;i<mm;i++)
    {
        ss+=n;
        n*=10;
    }
    if(s>ss)
        cout<<s<<endl;
    else
        cout<<ss<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    unsigned long long int n,weight,i,j;
    static unsigned long long int w[103],v[103],t[100002][103];
    cin>>n>>weight;
    for(i=0;i<n;i++)
        cin>>w[i]>>v[i];
    for(i=0;i<=weight;i++)
        t[i][0]=0;
    for(i=0;i<=weight;i++)
        t[0][i]=0;
    for(i=1;i<=weight;i++)
    {
        for(j=1;j<=n;j++)
        {
            t[i][j]=t[i][j-1];
            if(i>=w[j-1])
            {
                t[i][j]=max(t[i][j-1],t[i-w[j-1]][j-1]+v[j-1]);
            }
        }
    }
    cout<<t[weight][n]<<endl;
    return 0;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 52;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
ll sqr(ll a)
{
    return ((a % MOD) * (a % MOD)) % MOD;
}
ll msub(ll a, ll b)
{
    return ((a - b) % MOD + MOD) % MOD;
}
ll madd(ll a, ll b)
{
    return (a + b) % MOD;
}
ll mmul(ll a, ll b)
{
    return ((a % MOD) * (b % MOD)) % MOD;
}
int t;
int n, m, q;
int a[N], b[N], c[N], d[N], x[N], val[N];
ll res = 0;
void xl()
{
    ll ans = 0;
    FOR(i, 1, q)
    {
        if(x[b[i]] - x[a[i]] == c[i]) ans += d[i];
    }
    res = max(res, ans);
}
void bt(int i)
{
    if(i > n) xl();
    else
    {
        if(i == 1)
        {
            FOR(j, 1, m)
            {
                x[i] = j;
                bt(i + 1);
            }
        }
        else
        FOR(j, x[i - 1], m)
        {
            x[i] = j;
            bt(i + 1);
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    cin >> n >> m >> q;
    FOR(i, 1, q)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    bt(1);
    cout << res << endl;
  //  FOR(i, 1, q) cout << val[i] << " ";
    return 0;
}


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

#define int long long
#pragma GCC optimize ("O3")
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359


/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace __gnu_pbds;
typedef tree<pii,null_type,less <pii>,rb_tree_tag,tree_order_statistics_node_update>ind_set;
*/
///*X.find_by_order("index")
///X.order_of_key("key")



#define deb(x) cerr<<#x<< " : " <<x<<"\n";
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------

void solve()
{int x,a;cin>>x>>a;if (x<a)cout<<0;else cout<<10;

}

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    #ifdef local
    freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    #endif

    clock_t qwertyuiop = clock();
    int t=1;
    ///cin>>t;
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
    }
    #ifdef local
	{qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}


Measured memory_bytes: 256
function main(arg) {
    var args = arg.split('\n');
    var N = +args[0];
    var S = args[1];
    var K = args[2]-1;
 
    var tg = S[K];
  
    var arr = [...S].map(function(c){
        if(c !== tg) return '*'
        else return c
    }).join('')
 
    console.log(arr)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include<cstdio>
int n,m;
long long pre[200011][2],las[200011][2],x[200011],l,ans;
long long getmax(long long aa,long long bb)
{
	if(aa>bb)return(aa);
	else return(bb);
}
int main()
{
	scanf("%lld%d",&l,&n);
	for(int i=1;i<=n;i++)scanf("%lld",&x[i]);
	pre[0][0]=pre[0][1]=0; 
	for(int i=1;i<=n;i++)pre[i][0]=x[i];
	las[n+1][0]=las[n+1][1]=0;
	for(int i=n;i>=1;i--)las[i][0]=l-x[i];
	for(int i=1;i<=n;i++)pre[i][1]=pre[i-1][1]+pre[i][0];
	for(int i=n;i>=1;i--)las[i][1]=las[i+1][1]+las[i][0];
	ans=las[n][0];
	if(pre[n][0]>ans)ans=pre[n][0];
	for(int i=1;i<n;i++)
	{
		if((n-i)>i)ans=getmax(ans,pre[i][1]*2+(las[i+1][1]-las[2*i+2][1])*2-las[i+1][0]);
		else ans=getmax(ans,(pre[i][1]-pre[2*i-n][1])*2+las[i+1][1]*2-las[i+1][0]);
		if((n-i)<i)ans=getmax(ans,(pre[i][1]-pre[2*i-n-1][1])*2-pre[i][0]+las[i+1][1]*2);
		else ans=getmax(ans,pre[i][1]*2-pre[i][0]+(las[i+1][1]-las[2*i+1][1])*2);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 7936
int main(void){
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);

        if(a<b && a<c){
                if(b<c)
                        printf("%d %d %d",a,b,c);
                else
                        printf("%d %d %d",a,c,b);
        }else if(b<a && b<c){
                if(a<c)
                        printf("%d %d %d",b,a,c);
                else
                        printf("%d %d %d",b,c,a);
    }else{
                if(a<b)
                        printf("%d %d %d",c,a,b);
                else
                        printf("%d %d %d",c,b,a);
        }

        puts("");

        return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false);cin.tie(0);
#define setnow clock_t tStart;
#define setTime tStart = clock();
#define time0 (double)(clock() - tStart)/CLOCKS_PER_SEC
#define setin(x) ifstream cin(x);
#define setout(x) ofstream cout(x);
#define NMAX 30
typedef long long ll;
typedef long long int lli;
typedef pair < int, int> dbl;
const int maxInt = 1e9*2;
const lli maxLong = 1e18*2;
char a[4], b[4];
int ba,co;
int main(){
    char a, b;
    cin >> a >> b;
    if(a > b){
        cout << '>';
    } else if(a < b) {
        cout << '<';
    } else cout << '=';
    return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
///...................................*****.................................................///
///        Author :  MD. Rakibul Islam ( mmdrakibul2912@gmail.com )                         ///
///                  Department of Computer Science                                         ///
///                  & Engineering,                                                         ///
///                  Comilla University , Bangladesh.                                       ///
///...................................*****.................................................///
#define SQR(n) (n*n)
#define CHR getchar()
#define NL printf("\n")
#define PI 2.0*acos(0.0)
#define ll              long long int
#define ull             unsigned long long int
#define sc              scanf
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define pf              printf
#define MOD             1000000007
#define mx              123456789
#define Max(a,b) ((a>b)?a:b)
#define Min(a,b) ((a<b)?a:b)
#define ff first
#define D double
#define sz size()
#define ss second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
using namespace std;
int main()
{
    ll n, m, i, j, k, l=0, llx=0, lll=0;
    cin>>n>>m;
    ll cnt=0;
    //k=(max(n,m))/2;
    for(i=1;i<=m;i++)
    {
        if((n*i)%m==0)
        {
            cnt=i;
            break;
        }
    }
    cout<<n*cnt<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n;

int main(){
    cin >> n;
    if(n == 3 || n == 5 || n == 7)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
//#define int long long
#define INF 1e9
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

std::vector<bool> IsPrime;

void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}

ll MOD=1e9+7;
signed main(){
    int n;
    cin>>n;
    sieve(n);
    vector<int>v(n+5,0);
    for (size_t i = 2; i <= n; i++)
    {
        int copy=i;
        int j=2;
        while(j*j<=copy){
            if(copy%j==0) {
                copy/=j;
                v[j]++;
            }
            else j++;
        }
        v[copy]++;
        
    }
   // show(v);
    ll ans=1;
    for (int i = 0; i <= n; i++)
    {
        ans*=v[i]+1;
        ans%=MOD;
    }
    cout<<ans<<endl;
    
   
    return 0;
}

Measured memory_bytes: 256
/*
ID: markusz1
TASK: template
PROG: template
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ul;

ll n, y, a, b, c, sum;
bool found = false;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	//freopen("template.in","r",stdin);
	//freopen("template.out","w",stdout);

	cin >> n >> y;
	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= n - i; j++)
		{
			for (int k = 0; k <= n - j - i; k++)
			{
				sum = 10000 * i + 5000 * j + 1000 * k;
				if (sum == y && i + j + k == n)
				{
					a = i, b = j, c = k;
					found = true;
					break;
				}
				else if (sum >= y && i + j + k == n)
					break;
			}
			if (found)
				break;
		}
		if (found)
			break;
	}
	if (found)
		cout << a << " " << b << " " << c << '\n';
	else
		cout << "-1 -1 -1\n";
}

Measured memory_bytes: 256
program AGC002A
    implicit none
    integer(8)::a,b

    read(5,*)a,b

    if(a<=0 .and. b>=0)then
        print'(A)',"Zero"
    else if(a>0)then
        print'(A)',"Positive"
    else
        if(mod(min(0,b)-a+1,2)==1)then
            print'(A)',"Negative"
        else
            print'(A)',"Positive"
        end if
    end if
    
end program AGC002A

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

# GCD
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x

def main():
  n=I()
  l=LI()

  a=l[0]
  for x in l[1:]:
    a=gcd(a,x)

  return a

print(main())


Measured memory_bytes: 16604
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define zoom ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define precise cout.precision(8); cout << fixed;
#define seed srand(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);
using namespace std;

int main() {

    zoom;    
    ll N, W; cin >> N >> W;
    vector<pair<ll, ll> > A(N);
    for(ll i = 0; i < N; i += 1)
        cin >> A[i].first >> A[i].second;
    vector<vector<ll> > dp(N, vector<ll>(W + 1, 0));
    dp[0][A[0].first] = A[0].second;
    for(ll i = 1; i < N; i += 1) {
        for(ll j = 0; j <= W; j += 1) {
            dp[i][j] = (ll)max(dp[i][j], dp[i - 1][j]);
            if(j + A[i].first <= W)
                dp[i][j + A[i].first] = (ll)max(dp[i][j + A[i].first], dp[i - 1][j] + A[i].second);       
        }
    }
    ll ans = 0;
    for(ll i = 0; i <= W; i += 1)
        ans = (ll)max(ans, dp[N - 1][i]);
    cout << ans;
    return 0;
}

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

int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  if (U == S){
    cout << A - 1 << " " << B << endl;
  }
  else {
    cout << A << " " << B - 1 << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
char s[10][10];
int a,b,ans,cnt;
int d[2][2]={1,0,0,1};
void bfs(int x,int y)
{
   if((x==a-1)&&(y==b-1)) {ans=1;return ;}
   for(int i=0;i<2;i++)
    {
        int dx=x+d[i][0];
        int dy=y+d[i][1];
        if(s[dx][dy]=='#'&&dx>=0&&dx<a&&dy>=0&&dy<=b)
        bfs(dx,dy);
    }
}
int main()
{
    while(scanf("%d %d",&a,&b)!=EOF)
    {
        for(int i=0;i<a;i++)
         {
             scanf("%s",s[i]);
             for(int j=0;j<b;j++)
                if(s[i][j]=='#') cnt++;
         }
         ans=0;
         bfs(0,0);
         if(ans==1 && cnt==a+b-1) printf("Possible\n");
         else printf("Impossible\n");

    }
    return 0;
}


Measured memory_bytes: 128
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    string s;
    cin >> s;

    if (find(all(s), '7') != s.end()) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 3600
s=input().rstrip()
l=[]
x=list(s)
for i in range(0,len(x)):
  if x[i]=='0':
    l.append(0)
  elif x[i]=='1':
    l.append(1)
  else:
    if len(l)!=0:
      del(l[len(l)-1])
for i in range(0,len(l)):
    print(l[i],end='')

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		String s = stdIn.next();
		
		if(s.contains("N")&& !s.contains("S") || 
				s.contains("S") && !s.contains("N")||
				s.contains("W") && !s.contains("E")||
				s.contains("E") && !s.contains("W")){
			System.out.println("No");
		}else {
			System.out.println("Yes");
			
		}
		
		
		
		
	}

}


Measured memory_bytes: 21716
#include <stdio.h>

int main(void){
	int N,M;
	int T[101],X[101],P[101];
	scanf("%d",&N);
	for(int i=1;i<=N;i++) scanf("%d",&T[i]);
	scanf("%d",&M);
	for(int i=1;i<=M;i++){
		scanf("%d",&P[i]);
		scanf("%d",&X[i]);
	}
	int sum;
	for(int i=1;i<=M;i++){
		sum = 0;
		for(int j=1;j<=N;j++){
			if(j==P[i]){
				sum += X[i];
			}else{
				sum += T[j];
			}
		}
		printf("%d\n",sum);
	}
	
	return 0;
}


Measured memory_bytes: 128
## N以下の数の素数を全て列挙する
def prime_table(n):
  list = [True for _ in range(n+1)]
  list[0] = False ## 0は素数ではない
  list[1] = False ## 1は素数ではない
  i = 2
  ## 残っている最小の素数を選び、その倍数をFalseにする
  while i**2 <= n:
    if list[i]:
      j = i + i
      while j <= n:
        list[j] = False
        j += i
    i += 1
  table = [i for i in range(n+1) if list[i]]
  return table

## リストの中から"2017に似た数"を全て列挙する
## 2以外の素数は全てN=6M+1, 6M-1の形に書ける
## 前者が"似た数"の場合は「Mが偶数」が必要 ...(*)
## 後者が"似た数"の場合はN=5のみ
## まとめると、"似た数"は、3と5と(*)を満たす数
def ABC084D(prime_table):
  lst = [3, 5]
  for i in range(len(prime_table)):
    if (prime_table[i] - 1) % 12 == 0:
      if (prime_table[i] + 1) // 2 in prime_table:
        lst.append(prime_table[i])
  return lst


import bisect

Q = int(input())
LR = [list(map(int,input().split())) for i in range(Q)]


primes = prime_table(100000) ## 100000以下の素数を全て列挙
lst = ABC084D(primes) ## その中から"2017に似た数"を全て列挙
for i in range(Q):
  ans = bisect.bisect_right(lst,LR[i][1]) - bisect.bisect_left(lst,LR[i][0])
  print(ans)




Measured memory_bytes: 28620
# B

S=input()
T=input()

def check(i,T):
    ns=S[i:i+len(T)]
    res=0
    for i in range(len(T)):
        if ns[i]!=T[i]:
            res+=1
    return res

print(min([check(i,T) for i in range(len(S)-len(T)+1)]))

Measured memory_bytes: 9060
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
using namespace std;
#define INF 1000000000
typedef long long ll;

ll div_roundup(ll x, ll y){
  if(x<0) return 0;
  return (x+y-1)/y;
}

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  ll h[n];
  REP(i,n) cin >> h[i];
  ll lb = 0, ub = INF, mid;
  while(ub-lb>1){
    mid = (ub+lb)/2;
    ll cnt = 0;
    REP(i,n) cnt += div_roundup(h[i]-b*mid,a-b);
    if(cnt>mid){
      lb = mid;
    }else{
      ub = mid;
    }
  }
  cout << ub << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int []x = new int [4];
		int []y = new int [4];
		
		x[0] = sc.nextInt();
		y[0] = sc.nextInt();
		x[1] = sc.nextInt();
		y[1] = sc.nextInt();
		
		x[2] = x[1] +(y[0] - y[1]);
		y[2] = y[1] +(x[1] - x[0]);
		x[3] = x[2] +(x[0] - x[1]);
		y[3] = y[2] +(y[0] - y[1]);
		
		System.out.println(x[2]+" "+y[2]+" "+x[3]+" "+y[3]);
		
	}

}

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

int main(){
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);
    if (A + B + C >= 22) printf("bust\n");
    else printf("win\n");
    return 0;
}


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

using namespace std;


int main(){
    int n,m,cnt;
    cin>>n;
    int a[n];
    for(m=1;m<n;m++){cin>>a[m];}
    int subo[n]={};
    
    for(m=1;m<n;m++){
        subo[a[m]-1]++;

    }

    for(m=0;m<n;m++){
        cout<<subo[m]<<endl;

    }

    return 0;
    }

Measured memory_bytes: 5200
#include<stdio.h>

int main(){

int A,B;

scanf("%d %d", &A, &B);


if(A+B > A-B && A+B > A*B){


    printf("%d\n",A+B);
}
else if (A-B > A*B){
   printf("%d\n",A-B); 
}
else{
    printf("%d\n", A*B);
}


    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using ml = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

long long fastpow(long long n, long long x, long long m) {
    long long ret = 1;
    while (x) {
        if (x & 1)
            (ret *= n) %= m;
        x >>= 1;
        (n *= n) %= m;
    }
    return ret;
}

void solve() {
    int N, X, M;
    cin >> N >> X >> M;
    int sum = X;
    unordered_map<int, int> mp, su;
    REP(i, N - 1) {
        X = fastpow(X, 2, M);
        sum += X;
        if (mp.count(X) > 0) {
            int loopSize = i - mp[X];
            int t = (N - i - 2) / loopSize;
            sum += (sum - su[X]) * t;
            i += loopSize * t;
            mp.clear();
        } else {
            mp[X] = i;
            su[X] = sum;
        }
    }
    cout << sum << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 7260
#include <stdio.h>
#include <stdbool.h>

typedef struct{
    long y;
    long x;
} pos_t;

char a[512*512];
char out[128*1024*1024];

inline static long s(long y, long x, long w){
    if(y%2==0){
        return y*w+x;
    }else{
        return y*w+(w-1-x);
    }
}

inline static pos_t xy(long n, long w){
    long q = n/w;
    long r = n%w;
    pos_t t;
    t.y = q+1;
    if(q%2==0){
        t.x = r+1;
    }else{
        t.x = w-r;
    }
    return t;
}

int main(void){
    long h, w;
    scanf("%ld %ld\n", &h, &w);
    for(long i=0; i<h; i++){
        for(long j=0; j<w; j++){
            int t;
            scanf("%d", &t);
            a[s(i,j,w)] = t;
        }
    }
    bool haveCoin = false;
    long count = 0;
    size_t pos = 0;
    for(long i=0; i<h*w-1; i++){
        if(a[i]%2==1){
            haveCoin = !haveCoin;
        }
        if(haveCoin){
            const pos_t p=xy(i, w);
            const pos_t q=xy(i+1, w);
            size_t len = sprintf(out+pos, "%ld %ld %ld %ld\n", p.y, p.x, q.y, q.x);
            pos += len;
            count++;
        }
    }
    printf("%ld\n", count);
    fputs(out, stdout);
    return 0;
}


Measured memory_bytes: 6144
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
     String[] nyu=sc.nextLine().split(" ");

//     String nyu=sc.nextLine();
int A=Integer.parseInt(nyu[0]);
int B=Integer.parseInt(nyu[1]);
int C=Integer.parseInt(nyu[2]);
//int D=Integer.parseInt(nyu);

//StringBuffer sb = new StringBuffer(nyu);
//		String dst = sb.reverse().toString();

//     String nyu2=sc.nextLine();
//int E=Integer.parseInt(nyu2);



//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(C){
case 7:
case 5:
case 3:
System.out.println("YES") ;
break;
default:
System.out.println("NO") ;

break;
}
*/

//int res=Math.min((A*B),C);

//for(String tem:nyu){
//if(tem.equals("1"))res++;
//}
//int res=0;
//for(int i=0;i<300;i++){
//if(num[i]==1)res=i;
//}

//char[] c = nyu.toCharArray();


//System.out.println(nyu+"-"+line_r_2+"-"+nyu2+"-"+line_r_1);


//if(){
//double res=Math.ceil((AB)/2);

System.out.println(Math.min(A+B,Math.min(A+C,B+C)));
//}else if((int)c[0]>(int)c[2]){
//System.out.println(">");

//}else{
//System.out.println("Impossible");

//}




	}
}

Measured memory_bytes: 21844