akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

//問題文より、入力される英文の最大の長さ
#define MAXLENGTH 1200

int main(void)
{
	//line_countは入力された行数を、alphabet_countはa～zの出現個数を格納
	int i;
	int row, column, row_count;
	int alphabet_count[26] = {0};
	char str[MAXLENGTH][MAXLENGTH];

	row_count = 0;
	//読み込み終了まで英文を読み込む
	while(fgets(str[row_count], MAXLENGTH, stdin) != NULL){
		row_count++;
	}

	//入力された行数文繰り返す
	for(row = 0; row < row_count; row++){
		column = 0;
		//文の最後まで繰り返す
		while(str[row][column] != '\0'){
			//A～Zまたはa～zの出現個数をそれぞれ数える
			for(i = 0; i < 26; i++){
				if(str[row][column] == (i + 'A')){
					alphabet_count[i]++;
				}
				else if(str[row][column] == (i + 'a')){
					alphabet_count[i]++;
				}
			}
			column++;
		}
	}

	//結果を出力
	for(i = 0; i < 26; i++){
		printf("%c : %d\n", (i + 'a'), alphabet_count[i]);
	}

	return 0;
}


Measured memory_bytes: 2112
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
if(a<b && b<c){System.out.println("Yes");}
else{System.out.println("No");}}}

Measured memory_bytes: 26172
from collections import deque

S = input()
Q = int(input())
flag_reversed = False
ret = deque(S)

for _ in range(Q):
    temp = input()
    if (len(temp) < 2):
        flag_reversed = not flag_reversed
    else:
        T, F, C = [x for x in temp.split(" ")]
        F = int(F)
        add_begin = True
        if (F == 2):
            add_begin = False
        if (flag_reversed):
            add_begin = not add_begin
        if (add_begin):
            ret.appendleft(C)
        else:
            ret.append(C)

ret = ''.join(ret)

if (flag_reversed):
    ret = ''.join(reversed(ret))
print(ret)

Measured memory_bytes: 8564
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int N, R;
  cin >> N >> R;
  if (N >= 10) {
    cout << R << endl;
  }
  else {
    cout << R + 100 * (10 - N) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int a, b; cin >> a >> b;

    if(a<=8 && b<=8){
        cout << "Yay!" << endl;
        return 0;
    }
    
    cout << ":(" << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {

            var ab = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToList();
            var s = Console.ReadLine().ToCharArray();

            int i, j;
            for (i = 0; i < ab[0]; i++)
            {
                if (s[i] == '-')
                {
                    Console.WriteLine("No");
                    return;
                }
            }

            if (s[i] != '-')
            {
                Console.WriteLine("No");
                return;
            }

            foreach (var item in s.Skip(i+1))
            {
                if (item == '-')
                {
                    Console.WriteLine("No"); 
                    return;
                }
            }

            Console.WriteLine("Yes");
        }
    }
}


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

// 最大公約数
ll GCD( ll a, ll b )
{
    if ( a % b == 0 )
    {
        return min(a,b);
    }
    else
    {
        return GCD(b,a % b);
    }
}

int main( void )
{
    ll a,b;
    cin >> a >> b;
    ll ans;
    
    if ( a > b )
        ans = a * b / GCD(a,b);
    else
        ans = a * b / GCD(b,a);
    
    cout << ans << endl;
}

Measured memory_bytes: 256
//namespace problems {
//    vector<string> solve(string str) {
//        if (str.size() == 1) return {str};
//        int z = 0;
//        int e = 0;
//        for (auto &c: str) {
//            if (c == '1') e++;
//            else z++;
//        }
//        if (e != z) return {str};
//        return {str.substr(0,1), str.substr(1,str.size()-1)};
//    }
//}
//
//#include <iostream>
//#include <vector>
//#include <complex>
//
//using std::cin;
//using std::cout;
//using std::endl;
//using std::vector;
//using std::string;
#include <complex>
#include <iostream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <functional>
#include <iterator>
#include <tuple>
#include <set>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++) {
        int val;
        cin >> val;
        v.push_back(val);
    }
    
    long long sum = 0;
    
    for (int i = 0; i < n-1; i++) {
        for (int j = i+1; j < n; j++) {
            sum += v[i] * v[j];
        }
    }
    
    cout << sum << endl;
    
     return 0;
}




Measured memory_bytes: 256
N, M, X = map(int, input().split())
CA = [list(map(int, input().split())) for i in range(N)]
min_can = set()


def cal_score(bought_books):
    global CA
    global M
    global N
    global X
    algo_Q = [0]*M
    cost = 0
    for i in range(N):
        if bought_books[i] == 1:
            for j in range(1, M+1):
                algo_Q[j-1] += CA[i][j]
            cost += CA[i][0]
    flag = True
    for i in range(M):
        if algo_Q[i] < X:
            flag = False
            break
    if flag:
        global min_can
        min_can.add(cost)
    return 0


def next_book(book_list):
    global N
    global M

    if len(book_list) == N:
       return cal_score(book_list)
    book_list.append(0)
    next_book(book_list)
    book_list.pop(-1)

    book_list.append(1)
    next_book(book_list)
    book_list.pop(-1)
    return 0


book_list = []
next_book(book_list)
if set() == min_can:
    print(-1)
else:
    print(min(min_can))


Measured memory_bytes: 9360
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n:String = read::<String>().chars().map(|c| if c == '1' {
        '9'
    }else {
        '1'
    }).collect();
    println!("{}",n);
}

Measured memory_bytes: 4352
from collections import Counter 
import sys

N = int(input())
A = list(map(int, input().split()))

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

A.sort()
if A[0] != 1:
    d = prime_factorize(A[0])
    dlist = list(Counter(d).keys())
    for i in dlist:
        for j in range(1,N):
            if A[j] % i != 0:
                break
            if j == N-1:
                print("not coprime")
                sys.exit()


cnt = [0] * (10 ** 6)
for i in A:
    a = prime_factorize(i)
    alist = list(Counter(a).keys())
    for j in alist:
        cnt[j] += 1
        if cnt[j] >= 2:
            print("setwise coprime")
            sys.exit()

print("pairwise coprime")


Measured memory_bytes: 197436
def m():
    s = str(input())
    if s[0] != "A":
        return "WA"
    if s[2:len(s)-1].count("C") != 1:
        return "WA"
    for c in s[1:]:
        if c == "C":
            continue
        if c.isupper():
            return "WA"
    return "AC"


print(m())


Measured memory_bytes: 2940
N = int(input())
A = [0]+list(map(int, input().split()))
ans = 0
tree = []
presum = 0
for i, elt in enumerate(A[:0:-1]):
    presum += elt
    tree += presum,
vertices = []
last = .5
for i,elt in enumerate(tree[::-1]):
    last = min(2*(last-A[i]), elt)
    ans += int(last)
    if last <= 0:
        break
if last > 0 and last == A[-1]:
    print(ans)
else:
    print(-1)

    


Measured memory_bytes: 20140
#include<bits/stdc++.h>
using namespace std;
int sum1[1000000];
int mod(int a){
    if(a>=0)
        return a;
    else
        return (-1*a);
}
int sum(int i,int h[],int n)
    {
        if(sum1[i]!=(-1))
            return sum1[i];
        else
        {
            sum1[i]=min(sum(i+1,h,n)+mod(h[i]-h[i+1]),sum(i+2,h,n)+mod(h[i]-h[i+2]));
            return sum1[i];
        }
    }
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++)
        {
            cin>>h[i];
        }
    for(int i=0;i<1000000;i++)
    {
        sum1[i]=-1;
    }
    sum1[n-1]=0;
    sum1[n-2]=mod(h[n-1]-h[n-2]);
    cout<<sum(0,h,n);
}


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

int main() {
    Int x, k, d; cin >> x >> k >> d;
    if (x < 0) x *= -1;
    Int syo, amari;
    syo = (Int)x / d;
    amari = (Int)x % d;
    if (syo > k) {
        cout << (Int)x-(Int)(k*d) << endl;
        return 0;
    }
    
    Int syo_p = abs(amari-d);

    if (((k-syo) % 2) == 0) {
        cout << amari << endl;
    }
    else {
        cout << syo_p << endl;
    }
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

int main(int argc, void **arg)
{
    long long n, i;
    long long a[100];
    double x = 0;

    scanf("%lld", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
    }

    for (i = 0; i < n; i++)
    {
        x += 1.0 / (long double)a[i];
    }
    x = 1 / x;

    printf("%lf\n", x);


    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

// constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
// constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL n;
    cin >> n;
    //--n;
    string ans;
    //ans += 'a' + n % 26;
    while (n > 0) {
        --n;
        ans += 'a' + n % 26;
        n /= 26;
    }
    reverse(all(ans));
    cout << ans << endl;
}

signed main() {
    solve();
    
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<ll> acc(N + 1, 0);
    rep(i, N) {
        if (i + 1 < N && S[i] == 'A' && S[i + 1] == 'C') {
            acc[i + 1] += acc[i] + 1;
        } else {
            acc[i + 1] = acc[i];
        }
    }
    rep(q, Q) {
        int l, r;
        cin >> l >> r;
        r--;
        l--;
        cout << acc[r] - acc[l] << '\n';
    }

}

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


Measured memory_bytes: 1872
#include <stdio.h>

int main(void) {
    int sum, m, f, r;
    while(scanf("%d %d %d", &m, &f, &r), ~m || ~f || ~r) {
        if(m < 0 || f < 0 || (sum = m + f) < 30) {
            printf("F\n");
        } else if(sum > 79) {
            printf("A\n");
        } else if(sum > 64) {
            printf("B\n");
        } else if(sum > 49 || r > 49) {
            printf("C\n");
        } else {
            printf("D\n");
        }
    }
    return 0;
}

Measured memory_bytes: 584
#include<algorithm>
#include<stack>
#include<ctime>
#include<cstring>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<queue>
using namespace std;
inline int read(){
	int num=0,f=1;char x=getchar();
	while(x<'0'||x>'9'){if(x=='-')f=-1;x=getchar();}
	while(x>='0'&&x<='9'){num=num*10+x-'0';x=getchar();}
	return num*f;
}
int main(){
	int n=read();
	if(n>=30)puts("Yes");
	else puts("No"); 
	return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    vector<int> moti(n);
    for(int i=0;i<n;i++) cin>>moti[i];
    
    int tmp=0,ans=0;
    sort(moti.begin(),moti.end());
    for(int i=0;i<n;i++){
        if(tmp<moti[i]){
            tmp=moti[i];
            ans++;
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args)
	{
		Scanner in=new Scanner(System.in);
		String s=in.nextLine();
		String t=in.nextLine();
		boolean flag=true;
		for(int i=0;i<s.length();i++)
		{
			if(s.charAt(i)!=t.charAt(i))
				flag=false;
		}
		System.out.println((flag?("Yes"):("No")));
	}
}

Measured memory_bytes: 35692
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}




int main(){
    string S;
    cin>>S;

    if(S[0] == S[1] || S[1] == S[2] || S[2] == S[3])cout << "Bad" << endl;
    else cout <<"Good" << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>
#include <bitset>

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
const double EPS=1e-8;
bool EQ(double a,double b){
  return abs(a-b)<EPS;
}

typedef vector<ll> vec;
typedef vector<vec> mat;

void fastStream(){
  cin.tie(0);
  std::ios_base::sync_with_stdio(0);
}

ll mod;
mat mulm(mat &A,mat &B){
  mat C(A.size(),vec(B[0].size()));
  for(int i=0;i<(int)A.size();i++){
    for(int k=0;k<(int)B.size();k++){
      for(int j=0;j<(int)B[0].size();j++){
        C[i][j]=(C[i][j]+A[i][k]*B[k][j])%mod;
      }
    }
  }
  return C;
}

mat pow(mat A,ll n){
  mat B(A.size(),vec(A.size()));
  for(int i=0;i<(int)A.size();i++){
    B[i][i]=1;
  }
  while(n>0){
    if(n&1)B=mulm(B,A);
    A=mulm(A,A);
    n>>=1;
  }
  return B;
}

ll N,M,A,B,C,T;
ll SS[1001];
int main(){
  fastStream();
  while(cin>>N>>M>>A>>B>>C>>T&&(N|M|A|B|C)){
    mod=M;
    for(int i=0;i<N;i++)cin>>SS[i];
    mat AA(N,vec(N,0));
    AA[0][0]=B;
    if(N>1)AA[0][1]=C;
    for(int i=1;i<N-1;i++){
      AA[i][i-1]=A;
      AA[i][i]=B;
      AA[i][i+1]=C;
    }
    if(N-2>=0)
      AA[N-1][N-2]=A;
    AA[N-1][N-1]=B;
    vec v(N,0);
    for(int i=0;i<N;i++)v[i]=SS[i];
    mat res=pow(AA,T);
    vector<ll> ans(N,0);

    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        ans[i]+=(res[i][j]*v[j])%mod;
        ans[i]%=mod;
      }
    }
    for(int i=0;i<N;i++){
      cout<<ans[i];
      if(i==N-1)cout<<endl;
      else cout<<' ';
    }
    
  }
  
  
  return 0;
}

Measured memory_bytes: 1328
def solve():
    S = input()

    N = len(S) + 1
    t = [0] * N
    for i in range(N-1):
        if S[i] == '<':
            t[i+1] = t[i]+1
    
    for i in range(N-2, -1, -1):
        if S[i] == '>':
            t[i] = max(t[i], t[i+1] + 1)

    print(sum(t))
if __name__ == '__main__':
    solve()

Measured memory_bytes: 46320
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
using namespace std;

int n, m;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> m;
	cout << (n * (n - 1)) / 2 + (m * (m - 1)) / 2 << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DBP
#define deb(...) fprintf(stderr,__VA_ARGS__)
#else
#define deb(...) 0
#endif
#define fst first
#define snd second
#define fore(x,a,b) for(int x=(a), qwerty=(b); x<qwerty; x++)
#define pb push_back
#define mset(a,v) memset((a),(v),sizeof(a))
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) int((a).size())
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

const int N=301;
int n,a,f[3];
double dp[N][N][N],EPS=1e-9;

double solve(int i,int j,int k) {	
	if(!(i+j+k))return 0;
	if(dp[i][j][k]>0-EPS)return dp[i][j][k];
	double p=1-(1.*(n-i-j-k)/n);
	double res=0;
	if(i)res+=(1.*i/n)*solve(i-1,j,k);
	if(j)res+=(1.*j/n)*solve(i+1,j-1,k);
	if(k)res+=(1.*k/n)*solve(i,j+1,k-1);
	//cout<<"res: "<<res<<endl;
	res=(res+1)/p;
	//cout<<"res: "<<res<<endl;
	//cout<<i<<" "<<j<<" "<<k<<" : "<<res<<" "<<p<<endl;
	dp[i][j][k]=res;
	return res;
}

int main(){FIN;
	mset(dp,-1);
	cin>>n;
	fore(i,0,n)cin>>a,f[a-1]++;
	cout<<setprecision(15)<<solve(f[0],f[1],f[2])<<endl;
}	

Measured memory_bytes: 213504
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 1e5+7 ;
const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
string s ;

int dp[N][13] ;
// uoto ith position have mod j 

void add(int& x , int y){
	x += y ;
	x%= MOD ;
}
void solve(){
	cin >> s ;
	ms(dp,0) ;
	int n = sz(s) ;
	int ans = 0 ;
	dp[0][0] = 1 ;
	for(int i = 0 ; i < n ; i++){
		if(s[i] == '?'){
			for(int j = 0 ; j < 13 ; j++){
				for(int k = 0 ; k < 10 ; k++){
					add(dp[i+1][(j*10+k) % 13] , dp[i][j]) ; 
				}
			}
		}
		else{
			int k = s[i] - '0' ;
			for(int j = 0 ; j < 13 ; j++){
				add(dp[i+1][(j*10+k) % 13], dp[i][j]) ;
			}
		}
	}

	cout << dp[n][5] << endl ;
}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


Measured memory_bytes: 10704
#include <iostream>

using namespace std;

int main(){
	string ss;
	cin >> ss;
	
	int n = 0, w = 0, s = 0, e = 0;
	for (int i = 0; i < ss.length(); i++){
		if (ss[i] == 'N'){
			n++;
		} else if (ss[i] == 'W'){
			w++;
		} else if (ss[i] == 'S'){
			s++;
		} else {
			e++;
		}
	}
	
	if ( (n > 0 && s == 0) || (n == 0 && s > 0) || (w > 0 && e == 0) || (w == 0 && e > 0) ){
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  string S, T;
  cin >> S >> T;
  vector<vector<int>> _s(30), _t(30);
  REP(i, S.size()) {
    _s[S[i] - 'a'].push_back(i);
    _t[T[i] - 'a'].push_back(i);
  }
  REP(i, 30) {
    char c;
    REP(j, _t[i].size()) {
      if (j == 0) {
        c = S[_t[i][0]];
        continue;
      }
      if (c != S[_t[i][j]]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  REP(i, 30) {
    char c;
    REP(j, _s[i].size()) {
      if (j == 0) {
        c = T[_s[i][0]];
        continue;
      }
      if (c != T[_s[i][j]]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 5964
#include <iostream>
#include <algorithm>

struct Team {
	std::string country;
	int score;
};
bool operator > (const Team& t1, const Team& t2) { return t1.score > t2.score; }

int main()
{
	int n; std::string sn;
	bool first = true;
	while (getline(std::cin, sn)) {
		n = std::stoi(sn);
		if (n==0) break;
		if (!first) std::cout << std::endl;
		if (first) first = false;
		Team* teams = new Team[n];
		std::string country;
		int w, l, d;
		std::string buf;
		for (int i=0; i<n; i++) {
			getline(std::cin, buf);
			int offset = 0;
			int pos = buf.find(' ', 0);
			country = buf.substr(0, pos);
			offset = pos + 1;
			pos = buf.find(' ', offset);
			w = std::stoi(buf.substr(offset, pos-offset));
			offset = pos + 1;
			pos = buf.find(' ', offset);
			l = std::stoi(buf.substr(offset, pos-offset));
			d = std::stoi(buf.substr(pos+1));
			
			teams[i].country = country;
			teams[i].score = 0;
			teams[i].score += 3*w;
			teams[i].score += d;
		}
		std::sort(teams, teams + n, std::greater<Team>() );
		for (int i=0; i<n; i++) {
			std::cout << teams[i].country << "," << teams[i].score << std::endl;
		}
		
		delete[] teams;
	}
	return 0;
}




Measured memory_bytes: 3172
n, k = map(int, input().split())
x = list(map(int, input().split()))
m = 3*10**8

for i in range(n-k+1):
    a = x[i]
    b = x[i+k-1]
    t= min(abs(a)+abs(b-a), abs(b)+abs(b-a))
    if m > t:
        m = t
print(m)

Measured memory_bytes: 20064
#include <stdio.h>
int main(void) {
char str[2];
 scanf("%2s",str);
if(str[0]=='9'||str[1]=='9'){
  printf("Yes\n");
}if(str[0]!='9'&&str[1]!='9'){
  printf("No\n");
}
	return 0;
}

Measured memory_bytes: 128
import sys
n,p=map(int,input().split())
s=input()
x=[0 for i in range(p)]
ans=0
if p==2 or p==5:
    for i in range(n):
        if int(s[i])%p==0: ans+=i+1
    print(ans)

else:
    tmp1=1
    tmp2=0
    for i in range(n-1,-1,-1):
        tmp2=(tmp1*int(s[i])+tmp2)%p
        x[tmp2]+=1
        tmp1=(tmp1*10)%p

    ans+=x[0]
    for i in range(p):
        ans+=x[i]*(x[i]-1)//2
    print(ans)

Measured memory_bytes: 41308
#include<iostream>
#include<vector>
#include<bits/stdc++.h>

using namespace std;

int  main()
{
  int n,w;
  cin>>n>>w;
  vector <int> weight(n);
  vector <long long int> cost(n);
  for(int i=0;i<n;i++)
  {
    cin>>weight[i]>>cost[i];
  }
  vector <vector <long long int> > dp(n+1,vector <long long int>(w+1));
  for(int i=1;i<n+1;i++)
  {
    for(int j=1;j<w+1;j++)
    {
      dp[i][j] = dp[i-1][j];
	  if(j-weight[i-1]>=0)
      {
        dp[i][j] = max(dp[i-1][j],dp[i-1][j-weight[i-1]]+cost[i-1]);
      }
    }
  }
  /*for(int i=0;i<n+1;i++)
  {
    for(int j=0;j<w+1;j++)
    {
      cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }*/
  cout<<dp[n][w]<<endl;
  return 0;
}

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

int main() {
  ll h,w,m;
  cin >> h >> w >> m;
  vector<pair<ll,ll>> b(m);
  //vector<vector<int>> bomb(h,vector<int>(w,0));
  vector<ll> height(h,0);
  vector<ll> width(w,0);  
  rep(i,m){
    ll x,y;
    cin >> x >> y;
    x--;
    y--;
    //b[i] = make_pair(x,y);
    height[x]++;
    width[y]++;
    b[i] = make_pair(x,y);
  }
  
  ll maxh=0,maxw=0;
  rep(i,h){
    maxh = max(maxh,height[i]);
  }
  rep(i,w){
    maxw = max(maxw,width[i]);
  }
  
  ll hnum=0,wnum=0;
  rep(i,h){
    if(height[i] == maxh){
      hnum++;
    }
  }
  rep(i,w){
    if(width[i] == maxw){
      wnum++;
    }
  }
  
  ll cnt=0;
  for(auto p : b){
    ll x,y;
    tie(x,y) = p;
    if(height[x] == maxh && width[y] == maxw) cnt++;
  }
  
  if(hnum * wnum == cnt){
    cout << (maxh+maxw-1) << endl;
  }else{
    cout << (maxh+maxw) << endl;
  }
  
  //cout << maxi << " " << maxj << endl;
  //cout << maxh << " " << maxw << endl;
  
  return(0);
}

Measured memory_bytes: 12728
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[25];
int main() {
  int N; cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> Input[i];
  }
  int ans = 0;
  for (int i = 1; i < N -1; i++) {
    if (((Input[i-1] < Input[i]) && (Input[i]< Input[i+1])) ||( ((Input[i+1] < Input[i]) && Input[i] < Input[i-1]))) {
      ans++;
    }
  }
  cout << ans << endl;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  string ans = (abs(c-a) <= d || (abs(b-a) <= d && abs(c-b) <= d)) ? "Yes" : "No";
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int cost,m,n;
	while(true){
		bool flag = false;
		cin>>cost;
		if(!cost)break;
		for(int i=0;i<12;i++){
			cin>>m>>n;
			cost -= (m-n);
			if(cost<=0&&!flag){
				cout<<i+1<<endl;
				flag = true;
			}
		}
		if(!flag)
			cout<<"NA"<<endl;
	}
  return 0;
}

Measured memory_bytes: 0
n = int(input())
t,a = map(int,input().split())
for i in range(n-1):
  pt,pa = t,a
  t,a = map(int,input().split())
  t,a = ((max((pt-1)//t,(pa-1)//a))+1)*t,((max((pt-1)//t,(pa-1)//a))+1)*a
print(t+a)

Measured memory_bytes: 38768
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(int i=0;i<n1;i++) L[i] = A[left + i];
  for(int i=0;i<n2;i++) R[i] = A[mid  + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k=left; k<right; k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if(p<r) {
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for(i=0;i<n;i++) {
    scanf("%s %d",S,&v);
    A[i].suit =  B[i].suit  = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++) {
    if(A[i].suit != B[i].suit) stable = 0;
  }

  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}

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

using namespace std;

int main() {
  int n; cin >> n;
  int a[1001];
  for(int i = 2; i <= n; ++i) a[i] = i;
  int ans = 1;
  for(int p = 2; p <= n; ++p) {
    if(a[p]==1) continue;
    int cnt = 0;
    for(int i = p; i <= n; i += p) {
      while(a[i] % p == 0) { a[i] /= p; ++cnt; }
    }
    ans = (long long)ans * (cnt + 1) % 1000000007;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

vector <int> kmp(string s, string t) { // t in s lengths
    string x = t + "#" + s;
    vector <int> pref(x.size() + 1, -1);
    for(int i = 0, j = -1; i < x.size(); i++) {
        while(j >= 0 && x[j] != x[i]) j = pref[j];
        pref[i + 1] = ++j;
    }
    return vector<int>(pref.begin() + t.size() + 2, pref.end());
}

int n, m;
string s, t;

int nxt(int &idx) {
    return idx + m - n >= m - 1 ? idx + m - n : idx + m;
}
int prv(int &idx) {
    return idx - m >= m - 1 ? idx - m : idx - m + n;
}

bool thereIsCycle(vector <int> tInS) {
    for(int i = m - 1; i <= 2 * m; i++) {
        bool cycle = true;
        int idx = i;
        do {
            cycle &= (tInS[idx] == m);
            idx = nxt(idx);
        } while(idx != i && cycle);
        if(cycle) return true;
    }
    return false;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> s >> t;

    while(s.size() < t.size())
        s = s + s;

    n = s.size();
    m = t.size();

    vector <int> tInS = kmp(s + s, t);

    if(thereIsCycle(tInS)) {
        cout << -1 << endl;
        return 0;
    }

    int ans = 0;

    for(int i = m - 1; i < m - 1 + n; i++) {
        if(tInS[i] == m)
            continue;

        int idx = prv(i), res = 0;
        while(tInS[idx] == m) {
            res++;
            idx = prv(idx);
        }
        ans = max(ans, res);
    }
    cout << ans << endl;
}


Measured memory_bytes: 25264
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    set<string> s;
    vector<string> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    bool ok = true;
    for (int i = 0; i < n; ++i)
    {
        if (s.find(a[i]) != s.end())
            ok = false;
        s.insert(a[i]);
        if (i != 0)
            if (a[i][0] != a[i - 1][a[i - 1].size() - 1])
                ok = false;
    }
    if (ok)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);

		// 文字列の入力
		String strInput = scanner.nextLine();
		for (int intLength = 0; intLength < strInput.length(); intLength++ ) {
			char charMoji = strInput.charAt(intLength);
			// 大文字なら小文字に変換して出力
			if (Character.isUpperCase(charMoji)) {
				char charResult = Character.toLowerCase(charMoji);
				System.out.print(charResult);
			// 小文字なら大文字に変換して出力
			} else if (Character.isLowerCase(charMoji)) {
				char charResult = Character.toUpperCase(charMoji);
				System.out.print(charResult);
			// どちらでもないならそのまま出力
			} else {
				System.out.print(charMoji);
			}
		}
		System.out.println();
	}

}



Measured memory_bytes: 26636
if __name__ == '__main__':

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

	cnt = 1
	while True:
		if n % k == 0:
			n = n // k
		else:
			n = n - n % k
			n = n // k
		if n // k < k:
			if n // k == 0:
				if n % k == 0:
					pass
				else:
					cnt += 1
			else:
				cnt += 2
			break
		cnt += 1
			
	print(cnt)


Measured memory_bytes: 9128
n,m,l = map(int,input().split())
a=[]
b=[]
c=[]
for i in range(n):
  a.append([int(i) for i in input().split()])
for i in range(m):
  b.append([int(i) for i in input().split()])
tb =  []
for i in range(l):
  tb_row=[]
  for vector in b:
    tb_row.append(vector[i])
  tb.append(tb_row)
for i in a:
  c_row=[]
  for j in tb:
    c_row.append(sum(x*y for (x,y)in zip(i,j)))
  c.append(c_row)
for i in c:
  print(*i)


Measured memory_bytes: 7060
#include<cstdio>
#include<vector>
#include<algorithm>
#define REP(i,a,n) for(int i = a;i < n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int in(){int x; scanf("%d",&x); return x;}
int main(void){
   int n,m;
   while(scanf("%d%d",&n,&m),n+m){
      vector<int>_point(0);
      vector<int>point(0);
      point.push_back(0);
      _point.push_back(0);
      rep(i,n){
         int x; scanf("%d",&x);
         _point.push_back(x);
         for(int j = _point.size()-1;j >= 0;j--){
            point.push_back(x+_point[j]);
         }
      }

      sort(point.begin(),point.end());

      int ma = 0;

      for(int i = 0;point[i] <= m;i++){
         if(i >= point.size()) break;

         vector<int>::iterator idx = upper_bound(point.begin(),point.end(),m-point[i]);
         if(*idx == 0) continue;
         idx -= 1;
         int num = *idx;
         ma = max(ma,point[i]+num);
      }
      printf("%d\n",ma);
   }
   return 0;
}

Measured memory_bytes: 4868
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s; cin >> s;
    int len = s.length();
    long long sum = 0, n = pow(2,len-1);
    for(int i = 0; i < n; i++){
        long long now = s[len-1]-'0', k = 10;
        for(int j = len-2; j >= 0; j--){
            if(i & (1<<(len-2 - j))) { sum += now; now = s[j]-'0'; k = 10;}
            else {now += k*(s[j]-'0'); k*=10;}
        }
        sum += now;

    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

bool ispa(string s)
{
    ll n = s.length();
    bool pos = 1;
    rep(n)
        if(s[i]!=s[n-1-i])
            pos = 0;
    return pos;        
}

int main()
{
   FAST/**/
   
   string s;
   cin>>s;
   
   bool pos = ispa(s);
   ll n = s.length();
   bool pos1 = ispa(s.substr(0,(n-1)/2));
   if(pos&&pos1)
        cout<<"Yes";
   else cout<<"No";        
   
   
   return 0;        
}  
   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int a, b; cin >> a >> b;
    int k; cin >> k;

    REP(i, k) {
        if (i % 2 == 0) {
            b += a / 2;
            a /= 2;
        } else {
            a += b / 2;
            b /= 2;
        }
    }

    cout << a << ' ' << b << '\n';
    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)

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

    int N;
    while (cin >> N, N) {
        static const complex<double> I = complex<double>(0, -1);
        using Point = complex<double>;
        vector<Point> points(N);
        REP(i, N) {
            double x, y; cin >> x >> y;
            points[i] = Point(x, y);
        }

        int ans = 1;
        REP(i, N) FOR(j, i+1, N) {
            auto x = points[i];
            auto y = points[j];
            double l_sq = norm(x - y);
            if (l_sq > 4) continue;
            for(double d : {-1, 1}) {
                Point middle = 0.5 * (x + y);
                Point dir = (x - y) * I;
                dir /= abs(dir);
                Point center = middle + d*sqrt(1 - l_sq/4)*dir;

                int count = 0;
                REP(k, N) {
                    if (norm(center - points[k]) <= 1 + 1e-10)
                        ++count;
                }
                ans = max(ans, count);
            }
        }
        cout << ans << '\n';
    }
}

Measured memory_bytes: 3280
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input1 = Console.ReadLine().Split(' ');
        int N = int.Parse(input1[0]);
        int M = int.Parse(input1[1]);
        int C = int.Parse(input1[2]);

        string[] input2 = Console.ReadLine().Split(' ');
        int[] B = new int[M];
        for(int i = 0; i < B.Length; i++)
        {
            B[i] = int.Parse(input2[i]);
        }
        int[,] A = new int[N, M];
        for (int i = 0; i < N; i++)
        {
            input2 = Console.ReadLine().Split(' ');
            for (int j = 0; j < M; j++)
            {
                A[i, j] = int.Parse(input2[j]);
            }
        }
        int c = 0;
        for(int i = 0; i < N; i++)
        {
            int sum = 0;
            for(int j = 0; j < M; j++)
            {
                sum += A[i, j] * B[j];
            }
            if (sum + C > 0)
                c++;
        }
        Console.WriteLine(c);
    }
}

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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ll MX = 1000001;

namespace Modop {
    ll modAdd(ll a, ll b) {
        return (a + b) % MOD;
    }
    
    ll modSub(ll a, ll b) {
        return (((a - b) % MOD) + MOD) % MOD;
    }
    
    ll modMul(ll a, ll b) {
        return ((a % MOD) * (b % MOD)) % MOD;
    }

    ll modExp(ll base, ll power) {
        if (power == 0) {
            return 1;
        } else {
            ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
            if (power % 2 == 1) cur = cur * base;
            cur = cur % MOD;
            return cur;
        }
    }
    
    ll modInv(ll a) {
        return modExp(a, MOD - 2);
    }
    
    ll modDiv(ll a, ll b) {
        return modMul(a, modInv(b));
    }
}

using namespace Modop;

ll N, K, ans = 1;

void solve() {
    cin >> N >> K;
    ll res = 1, other = 1;
    // precalc other spots
    for (int i = 1; i < N; i++) {
        other = modMul(other, i);
        if (i < N - 1) other = modMul(other, modInv(i));
        
    }
    
    // i is the number of empty rooms
    for (int i = 1; i <= min(N - 1, K); i++) {
        // res is how many ways there are to choose i empty rooms
        res = modMul(res, N - i + 1);
        res = modMul(res, modInv(i));
        // Each moved person can choose one of the places to stay
        
        // cout << i << " " << res << " " << other << "\n";
        ans = modAdd(ans, modMul(res, other));
        
        // Update number of places to move for next 
        other = modMul(other, modInv(i + 1));
        other = modMul(other, N - i - 1);
    }
    cout << ans;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 256
//20190617
#include <iostream>
#include <vector>
using namespace std;

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

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

    if(max<sum-max)cout << "Yes" << endl;
    else cout << "No" << endl;



    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
g = [[] for i in range(n)]
for i in range(m):
    u,v = map(int, input().split())
    g[u-1].append(v-1)
    g[v-1].append(u-1)

visited = [0] * n

def dfs(now, pre):
    if sum(visited) == n:
        return 1
    
    res = 0
    
    for i in g[now]:
        if i != pre and visited[i] == 0:
            visited[i] = 1
            res = res + dfs(i, now)
            visited[i] = 0
    
    return res

visited[0] = 1
print(dfs(0, -1))

Measured memory_bytes: 44892
#include <stdio.h>

int main() {
	int n,m,i,a,b=0;
	scanf("%d %d", &n, &m);

	for (i = 0; i < m; i++) {
		scanf("%d", &a);
		b += a;
	}

	if (b > n) { printf("-1"); return 0; }
	printf("%d",n-b);
}

Measured memory_bytes: 1720
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

pub fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

pub fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}

fn main() {
    let n = read!(usize);
    let t: Vec<u64> = read!(u64; n);

    let mut ans = t[0];
    for i in 0..(n - 1) {
        ans = lcm(ans, t[i + 1]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>
int main()
{
	
	long long m,n,s,k;
	scanf("%lld", &n);
	scanf("%lld", &m);
k=2*n;
if(k<=m)
{
	s+=n;
	s=s+(m-k)/4;
	printf("%lld", s);
}
else
{
	s=s+m/2;
	printf("%lld", s);
}

	return 0;
}

Measured memory_bytes: 128
import sys
from numpy import argmin
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
input = sys.stdin.buffer.readline

V, E = map(int, input().split())

v_from = []
v_to = []
cost = []

for _ in range(E):
    u, v, d = map(int, input().split())
    v_from.append(u)
    v_to.append(v)
    cost.append(d)

graph = csr_matrix((cost, (v_from, v_to)), [V+1, V+1])
dist, predecessors = floyd_warshall(graph, directed=False, return_predecessors=True)
dist[dist == 0] = float('inf')

dist_min = list(map(argmin, dist))

# print(dist_min)


# print(dist, predecessors)

T_max = int(input())
order = [[int(input().split()[1]) for _ in range(int(input()))] for _ in range(T_max)]

time = 0
delivering = False
distination = 1
v_next = 1

while time < T_max:
    # 配達中なら配達作業
    if delivering:
        # 途中経由地へ進む
        print(v_next)
        # 途中経由地までの残りの距離を減らす
        remaining_next -= 1
        # 到着したら次の途中経由地へ
        if remaining_next == 0:
            next_temp = predecessors[distination, v_next] # predecessors[v_next, distination]
            if next_temp != -9999:
                remaining_next = dist[v_next, next_temp]
                v_next = next_temp
        # 最終目的地までの距離を減らす
        remaining_last -= 1
        # 到着してる(はず)
        if remaining_last == 0:
            # 店に戻り終わった(目的地が店だった)
            if distination == 1:
                delivering = False
            # 店に戻る
            else:
                remaining_last = dist[distination, 1]
                v_next = predecessors[1, distination] # predecessors[distination, 1]
                remaining_next = dist[distination, v_next]
                distination = 1
        time += 1
    # 配達する目的地を決める(一番近いところ)
    else:
        idx = -1
        remaining_last = 0
        dist_temp_min = 10**18
        for i, o in enumerate(order):
            if not o:
                continue
            dst = o[0]
            # 店から配達場所までの時間(注文時間が今より後なら待たなければいけない)
            # Waiting time とかいうのがあるのでなんか重みを良い感じにする
            dist_temp = dist[1, dst] + abs(i - time) ** 2 * max(1, i - time) ** 2
            if dist_temp < dist_temp_min:
                dist_temp_min = dist_temp
                idx = i
        # オーダーが無ければ終わり
        if idx == -1:
            while time < T_max:
                print(-1)
                time += 1
            break
        # オーダーが現在時刻より遅ければ待つ
        if time < idx:
            while time < idx:
                print(-1)
                time += 1
        # 目的地等を設定
        distination = order[idx].pop()
        remaining_last = dist[1, distination]
        v_next = predecessors[distination, 1] # predecessors[1, distination]
        # print(distination, v_next)
        remaining_next = dist[1, v_next]
        delivering = True

Measured memory_bytes: 23424
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
int dp[1001][8];
main(){
	string s;
	int n,ans=0;
	cin>>n>>s;
	r(i,n)if(s[i]=='J')s[i]=0;
	 else if(s[i]=='O')s[i]=1;
	 else s[i]=2;
	dp[0][1]=1;
	r(i,n)r(j,8)if(dp[i][j])
	  r(k,8)if((j&k)&&(k&(1<<s[i])))
	    dp[i+1][k]+=dp[i][j]%10007;
	r(i,8)ans+=dp[n][i];
	cout<<ans%10007<<endl;
}

Measured memory_bytes: 3188
//B
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+10;
const int INF = 1e9+10;
int raw[maxn],f[maxn];
int main(){
	int n,k;
	cin >> n >> k;
	for(int i = 1;i <= n;i++){
		cin >> raw[i];
		f[i] = INF;
	}
	f[1] = 0;
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= k;j++){
			if(i-j > 0)f[i] = min(f[i],f[i-j] + abs(raw[i] - raw[i-j]));
		}
	}
	cout << f[n];
	return 0; 
}


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

int main(int argc, char const *argv[])
{
    int n; cin >> n;
    long long int ans = 0;
    for (int a = 1; a < n; a++)
    {
        ans += n/a;
        if (n%a == 0) ans --;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640