akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/


ll ppow(ll n,ll k){
  ll ret=1; while(k){ if(k&1)ret=ret*n; n=n*n; k>>=1; }
  return ret;
}

vector<P> e[60];
vector<int> es;
bool dfs(int x, int g, int p){
  if(x==g){
    return true;
  }
  for(auto to:e[x]){
    if(to.F==p) continue;
    if(dfs(to.F, g, x)){
      es.emplace_back(to.S);
      return true;
    };
  }
  return false;
}

int main(){
  int n;
  cin >> n;
  rep(i,n-1){
    int a,b; cin >> a >> b; a--; b--;
    e[a].push_back({b,i});
    e[b].push_back({a,i});
  }

  int m;
  cin >> m;
  vector<ll> eset(m,0);
  rep(i,m){
    int a,b;
    cin >> a >> b; a--; b--; 
    es.clear();
    dfs(a, b, -1);
    for(auto it:es){
      eset[i] |= 1LL<<it;
    }
  }

  ll ans = ppow(2,n-1);
  REP(i,1,1<<m){
    ll mask = 0;
    rep(j,m)if(bit(i,j)){
       mask |= eset[j];
    }
    int cnt = __builtin_popcountll(mask);
    int flag = __builtin_popcount(i);
    ll tmp = ppow(2,n-1-cnt); //or 1LL<<(n-1-cnt)
    if(flag%2){ ans -= tmp; } else { ans += tmp; }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Shrinking
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int INF = 1 << 30;

/* typedef */

/* global variables */

int pps[26], maxls[26];

/* subroutines */

/* main */

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

  memset(pps, -1, sizeof(pps));
  memset(maxls, -1, sizeof(maxls));

  int n = s.size();
  for (int i = 0; i < n; i++) {
    int ci = s[i] - 'a';
    int l = i - pps[ci] - 1;
    if (maxls[ci] < l) maxls[ci] = l;
    pps[ci] = i;
  }
  for (int ci = 0; ci < 26; ci++) {
    int l = n - pps[ci] - 1;
    if (maxls[ci] < l) maxls[ci] = l;
  }
  //for (int ci = 0; ci < 26; ci++) printf("%d ", maxls[ci]); putchar('\n');

  int minl = INF;
  for (int i = 0; i < 26; i++)
    if (maxls[i] >= 0 && minl > maxls[i]) minl = maxls[i];
  printf("%d\n", minl);
  return 0;
}


Measured memory_bytes: 256
/*#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll sum[1000005],val[1000005],ans;
int n,a[200005];
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
vector<int>d[1000005];
int main(){
	scanf("%d",&n);
	rep(i,n) scanf("%d",&a[i]);
	for(int i=1;i<=1000000;i++) for(int j=i;j<=1000000;j+=i) d[j].pb(i);
	for(int ii=n-1;ii>=0;ii--){
		vector<int>&dv = d[a[ii]];
		rep(i,dv.size()){
		        val[dv[i]] += sum[dv[i]]*a[ii]%mod;
		        if(val[dv[i]] >= mod) val[dv[i]] -= mod;
		        sum[dv[i]] += a[ii];
		        if(sum[dv[i]] >= mod) sum[dv[i]] -= mod;
		}
	}
	for(int i=1000000;i>=1;i--){
	    for(int j=2*i;j<=1000000;j+=i){
	        val[i] -= val[j];
	    }
	    ans += (val[i]%=mod) * modpow(1LL*i,mod-2)%mod;
	}
	cout << (ans%mod+mod)%mod << endl;
}

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

const int maxn = 1e5 + 10;
vector<int> G[maxn];
int c[maxn], cnt[2];
bool bi;

void dfs(int now, int co) {
    c[now] = co; ++cnt[co];
    for (int u : G[now]) {
        if (c[u] == c[now]) {
            bi = false;
            continue;
        }
        if (c[u] != -1) continue;
        dfs(u, co ^ 1);
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;
        G[a].push_back(b); G[b].push_back(a);
    }
    bi = true;
    memset(c, -1, sizeof(c));
    dfs(1, 0);
    // cout << bi << endl;
    if (bi) return cout << cnt[0] * 1ll * cnt[1] - m << endl, 0;
    cout << n * 1ll * (n - 1) / 2 - m << endl;
    return 0;
}


Measured memory_bytes: 7040
import java.util.Scanner;

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

	int X = N;

	int fx = 0;


	while(N>=10) {

		fx += N%10;

		N /= 10;

	}

	fx += N;

	if(X%fx == 0) System.out.println("Yes");

	else System.out.println("No");
}

}

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

int main()
{
    long long n,m,s;
    scanf("%lld%lld",&n,&m);
    s=0;
    if(2*n<=m)
    {
        s=s+n;
        m=m-2*n;
        s=s+m/4;
    }
    else
    {
        s=m/2;
    }
    printf("%lld\n",s);
    return 0;
}


Measured memory_bytes: 384
N = int(input())
AB = []
for i in range(N):
    ab = list(map(int, input().split()))
    AB.append(ab)
AB.sort(key=lambda x:x[1])
time = 0
for i in AB:
    time += i[0]
    if time > i[1]:
        time = "over"
        break
if time == "over":
    print("No")
else:
    print("Yes")

Measured memory_bytes: 53612
open Printf
open Scanf

let solve s =
  let l = List.sort compare @@ List.map (fun i -> String.get s i) [0;1;2;3] in
  match l with
    a::b::c::d::_ when a = b && c = d && b <> c -> "Yes"
  | _ -> "No"

let () =
  scanf "%s " solve |> printf "%s\n"


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef pair<int, int> P;

template<typename T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return (a * b) / gcd(a, b);
}

int main()
{
    ll A, B, C; cin >> A >> B >> C;
    ll count = 0;
    while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
        ll next_a = (B + C) / 2;
        ll next_b = (A + C) / 2;
        ll next_c = (A + B) / 2;
        if (A == next_a && B == next_b && C == next_c) {
            count = -1;
            break;
        }
        A = next_a, B = next_b, C = next_c;
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int[] val = new int[N];
    ArrayList<Integer[][]> list = new ArrayList<>();
    for(int i = 0; i < N; i++){
      val[i] = Integer.parseInt(sc.nextLine());
      Integer[][] num = new Integer[val[i]][2];
      for(int j = 0; j < val[i]; j++){
        String[] S = sc.nextLine().split(" ");
        num[j][0] = Integer.parseInt(S[0]);
        num[j][1] = Integer.parseInt(S[1]);
      }
      list.add(num);
    }
    
    int max = 0;
    c : for(int i = 0; i < Math.pow(2,N); i++){
      long M = Long.parseLong(Integer.toBinaryString(i));
      String bit = String.format("%015d", M);
      for(int j = 0; j < N; j++){
        int L = val[j];
        if(bit.charAt(15-j-1) == '0'){
          continue;
        }
        Integer[][] num = list.get(j);
        for(int k = 0; k < L; k++){
          int P = num[k][0];
          if(bit.charAt(15-P) != num[k][1]+'0'){
            continue c;
          }
        }
      }
      int count = 0;
      for(int j = 1; j <= N; j++){
        if(bit.charAt(15-j) == '1'){
          count++;
        }
      }
      if(count > max){
        max = count;
      }
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 47956
def bubbleSort(A):
    flag = 1
    count = 0
    while flag:
        flag = 0
        for j in range(len(A)-1,0,-1):
            if A[j] < A[j-1]:
                A[j],A[j-1] = A[j-1],A[j]
                flag += 1
                count += 1

    return [count,A]

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

answer = bubbleSort(lst)

print(" ".join(map(str,answer[1])))
print(answer[0])


Measured memory_bytes: 5604
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;

    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            string s;
            cin >> s;
            if (s == "snuke") {
                cout << (char)('A' + x) << y + 1 << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())

a = list(map(int, input().split()))

dp = [''] * (k + 1)

for i in range(a[0]):
    dp[i] = 'Second'

for x in a:
    dp[x] = 'First'

for i in range(1, k + 1):
    if dp[i] != '':
        continue

    dp[i] = 'Second'
    for x in a:
        if x > i:
            continue
        if dp[i-x] == 'Second':
            dp[i] = 'First'
            break

print(dp[-1])


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

#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair

typedef long long ll;

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cerr.tie(0);
	
	int N, X; cin >> N >> X;
	int res = 0;
	for (int i=0; i<N; i++) {
		int a; cin >> a;
		res = gcd(abs(a-X), res);
	}
	cout << res;
}


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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    int N;
    cin >> N;
    int t,a;
    ll tn=1,an=1;
    for (int i = 0; i < N; i++){
        cin >> t >> a;
        ll n = max((tn+t-1)/t,(an+a-1)/a);
        tn = t * n;
        an = a * n;
    }
    cout << tn + an << endl;




    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    string s;
    cin >> s;
    string t;
    cin >> t;
    int cnt = 0;
    REP(i,3){
        if(s[i] == t[i]) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
class PrimeNumber
  def initialize n
    @n = n
    @list = (0...n).map{|i| true}
    @list[0] = false
  end

  def set_list
    n = Math.sqrt(@n).to_i
    n.times do |i|
      next if !@list[i]
      div = i + 1
      (2 * i + 1).step(@n - 1, i + 1) do |j|
        @list[j] = false if !@list[j] || (j + 1) % div == 0
      end
    end
  end

  def prime? n
    false if @n < n
    @list[n]
  end

  def number_of_prime(limit)
    @list.take(limit).count(true)
  end
end

prime = PrimeNumber.new(999999)
prime.set_list

while line = gets do
  n = line.to_i
  puts prime.number_of_prime n
end

Measured memory_bytes: 20104
#include <cstring>
#include <cstdio>
#define MOD 1000000007
struct Matrix
{
	int arr[3][3];
	Matrix()
	{
		memset(arr, 0, sizeof(arr));
	}
	inline int *operator [](const int &x)
	{
		return arr[x];
	}
	inline Matrix operator *(Matrix &a)
	{
		Matrix res;
		for (int i = 0; i < 3; i++)
		{
			for (int j = 0; j < 3; j++)
			{
				for (int k = 0; k < 3; k++)
					res[i][k] = (res[i][k] + (long long)arr[i][j] * a[j][k]) % MOD;
			}
		}
		return res;
	}
} ans, trans, ban;
int arr[100005];
int main()
{
	// freopen("AGC013-E.in", "r", stdin);
	int n, m, cur = 1;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++)
		scanf("%d", arr + i);
	arr[m] = n;

	ans[0][0] = ans[0][2] = 1;
	ans[0][1] = 2;

	trans[0][0] = trans[0][2] = trans[1][1] = trans[1][2] = trans[2][0] = 1;
	trans[0][1] = trans[2][1] = trans[2][2] = 2;

	ban[0][0] = ban[0][2] = ban[1][1] = ban[1][2] = ban[2][2] = 1;
	ban[0][1] = 2;

	for (int i = 0; i <= m; i++)
	{
		int x = arr[i] - cur;
		auto tmp = trans;
		while (x)
		{
			if (x & 1)
				ans = ans * tmp;
			tmp = tmp * tmp;
			x >>= 1;
		}
		if (i == m)
			break;
		ans = ans * ban;
		cur = arr[i] + 1;
	}
	printf("%d\n", (ans[0][2] + MOD) % MOD);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string n;
    cin >> n;
    bool flag = false;
    if(n[0]==n[1] and n[0]==n[2]){
        flag = true;
    }else if (n[1]==n[2] and n[1]==n[3]){
        flag = true;
    }
    if (flag == true){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
x, y = map(int, input().split())
if (x in a and y in a) or(x in b and y in b) or(x in c and y in c):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 61932
#include <iostream>
#include <vector>
using namespace std;
 
const int MAX = 200010;
int N, M;
bool visit0[MAX], visitN[MAX];
 
int main(int argc, const char * argv[]) {
  cin >> N >> M;
  int a[M], b[M];
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    if (a[i] == 0) visit0[b[i]] = true;
    if (b[i] == 0) visit0[a[i]] = true;
    if (a[i] == N - 1) visitN[b[i]] = true;
    if (b[i] == N - 1) visitN[a[i]] = true;
  }
  
  bool flag = false;
  for (int i = 0; i < N; i++) {
    if (visit0[i] && visitN[i]) flag = true;
  }
  
  // 解答
  cout << (flag ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    
  return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>

int main(void){
    unsigned long long a,b,c,d,e,f;
    scanf("%llu %llu %llu",&a,&b,&c);
    d=a*b;
    e=b*c;
    f=c*a;
    if((a*b*c)%2==0){
        printf("0\n");
        return 0;
    }
    else if(d<=e&&d<=f){
        printf("%llu\n",d);
    }
    else if(e<=f){
        printf("%llu\n",e);
    }
    else{
        printf("%llu\n",f);
    }
    return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, t;
	cin >> n >> t;
	int ans = INF;
	REP(i, n) {
		int a, b;
		cin >> a >> b;
		if (b <= t)ans = min(ans, a);
	}
	if (ans == INF)cout << "TLE" << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 256
/*AOJ 0020*/

#include<iostream>
using namespace std;

char changeSmallToLarge(char str){

	if(str>='a' && str<='z'){
		return str - 32;
	}
	else{
		return str;
	}
}

int main(){
	
	char str[1000];

	cin.getline(str,1000);

	for(int i=0;str[i]!='\0';i++){
		str[i] = changeSmallToLarge(str[i]);
	}

	cout<<str<<endl;

	return 0;
}

Measured memory_bytes: 0
h,w=map(int,input().split())
c=[list(map(int,input().split()))for i in range(10)]
a=[list(map(int,input().split()))for i in range(h)]

for _ in range(10):
  for i in range(10):
    for j in range(10):
      if i==j:
        continue
      for k in range(10):
        if i==k or k==j:
          continue
        if c[i][k]+c[k][j]<c[i][j]:
          c[i][j]=c[i][k]+c[k][j]
          
ans=0
for i in range(h):
  for j in range(w):
    if a[i][j]==-1:
      continue
    ans+=c[a[i][j]][1]
    
print(ans)

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

void solve()
{
	char c; cin >> c;
	if (c >= 'A' and c <= 'Z') cout << "A";
	else cout << "a";

}
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll t = 1; //cin >> t;
	while (t--)
		solve();
	return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> f(10, -100000);
  f[0] = 0;
  int n; cin >> n;
  for(int i = 0; i < n; i++){
  	vector<int> nf = f;
    int x; cin >> x;
    for(int j = 0; j < 10; j++){
    	nf[(j + x)%10] = max(nf[(j + x)%10], f[j] + x);
    }
    f = nf;
  }
  int ans = 0;
  for(int i = 1; i < 10; i++) ans = max(ans, f[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define re return
#define ee endl
using namespace std;
int main()
{
int x,y,i,j,k;
   cin>>x>>y;
   if(y%2!=0)
   {
       cout<<"No"<<ee;
       re 0;
   }
   if(y/x>=2&&y<=4*x)
   {
       cout<<"Yes"<<ee;
       re 0;
   }
   else
   {
       cout<<"No"<<ee;
       re 0;
   }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N),rui(N+1);

    for(ll i = 0;i < N;i++)
        cin >> A.at(i);

    for(ll i = 0;i < N;i++){
        rui.at(i+1) = rui.at(i) + A.at(i);
        //cout << rui.at(i+1) << endl;
    }
    ll min = INF;

    for(ll i = 1;i < N;i++){
        ll sa = rui.at(N) - rui.at(i);
        ll sa2 = abs(sa - rui.at(i));
        if(sa2 < min)
            min = sa2;
    }

    cout << min << endl;

}

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

min_power = 10**10

#どこの座標で集会をするか
for i in range(1,101):
    power = 0
    for j in X:
        power += (j-i)**2
    min_power = min(min_power,power)

print(min_power)

Measured memory_bytes: 3064
import numpy as np

n  = int(input())
a = np.array(list(map(int,input().split())))


ret = 0
i = 0
while i < len(a):
    j = i
    while j < n -1 and a[j] <= a[j+1]:
        j += 1
    h = i
    while h < n - 1 and a[h] >= a[h +1]:
        h += 1
    i = max(h,j) + 1
    ret += 1

print(ret)


Measured memory_bytes: 23084
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,x=MI()
lis=LI()
ans=0
lis=[0]+lis+[0]
for i in range(n+1):
    #print(lis[i]+lis[i+1])
    if lis[i]+lis[i+1]>x:
        ans+=lis[i+1]+lis[i]-x
        lis[i+1]-=lis[i+1]+lis[i]-x
print(ans)
    
    
    

    
    

            

    
    
        


Measured memory_bytes: 15144
s = str(input().strip())
t = str(input().strip())

pos = [[] for _ in range(30)]

for i, v in enumerate(s):
    pos[ord(v) - ord('a')].append(i + 1)

pre = 0
ans = 0
from bisect import bisect_right

for i in t:
    g = ord(i) - ord('a')
    p = bisect_right(pos[g], pre)
    if p >= len(pos[g]):
        if len(pos[g]):
            ans += len(s)
            pre = pos[g][0]
            continue
        else:
            print(-1)
            exit(0)
    pre = pos[g][p]

ans += pre
print(ans)

Measured memory_bytes: 45808
#include <iostream>
#include <algorithm>
using namespace std;
long long f[100000],a[100000];
int n,k;
int main()
{
    cin>>n>>k;
    for (int i=0;i<n;++i) cin>>a[i];
    f[0]=0;
    for (int i=1;i<n;++i) {
        f[i]=10000000000;
        for (int j=i-1;j>=max(0,i-k);--j){
            f[i]=min(f[j]+abs(a[i]-a[j]),f[i]);}
    }
    cout<<f[n-1];
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int mx=0, cnt=0;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='R') cnt++;
        else cnt=0;
        mx = max(mx, cnt);
    }
    cout<<mx;
}

Measured memory_bytes: 3600
#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<ll,ll> 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;

const long long mod = 1000000007;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a,b;
    cin>>a>>b;
    if(a%3==0 && a>0){
        cout<<"Possible"<<endl;
    }
    else if(b%3==0 && b>0){
        cout<<"Possible"<<endl;
    }
    else if((a+b)%3==0 && a+b>0){
        cout<<"Possible"<<endl;
    }
    else{
        cout<<"Impossible"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
a,b=s1()

x=int(a)
y=int(b[0]+b[2:])

ans=(x*y)//100
print(ans)

Measured memory_bytes: 9252
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

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

typedef long long ll;
typedef vector<int> VI;

int dp[1010][1010];
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string s, t; cin >> s >> t;
    int n=s.size(), m=t.size();
    
    for(int i=0; i<=n; ++i){
        for(int j=0; j<=m; ++j){
            dp[i][j]=1e9;
        }
    }
    for(int i=0; i<=n; ++i){
        dp[0][i] = i;
    }
    for(int i=0; i<=m; ++i){
        dp[i][0] = i;
    }
    int x;
    for(int i=1; i<=m; ++i){ //t
        for(int j=1; j<=n; ++j){ //s
            if(s[j-1]==t[i-1]) x=0;
            else x=1;
            dp[i][j] = min(dp[i-1][j]+1, min(dp[i][j-1]+1, dp[i-1][j-1]+x));
        }
    }

    cout << dp[m][n] << endl;
	return 0;
}


Measured memory_bytes: 7148
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

using ll = long long;
using namespace std;
using P = pair<int,int>;
ll mod=1e9+7;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

int main(){
  int N;
  cin>>N;
  if (N < 1200){
    cout << "ABC" << endl;
  }else if(N < 2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n, m;
    cin >>  n >> m;
  	vector<vector<int> > G(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    vector<int> prev(n);
    vector<int> dist(n, -1);
    queue<int> que;
    dist[0] = 0;
    que.push(0);

    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue;
            dist[nv] = dist[v] + 1;
            prev[nv] = v;
            que.push(nv);
        }
    }
    cout << "Yes" << endl;
    for (int i = 1; i < n; i++) {
        cout << prev[i]+1 << endl;
    }


}

Measured memory_bytes: 10676
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}";
  return o;
}


int main() {
  int N,M;
  cin >> N >> M;
  string S; cin >> S;
  vector<int> g(1,1);
  // rep2(i,1,N+1) {
  //   if (S[i]==S[i-1]) g[g.size()-1]++;
  //   else g.push_back(1);
  // }
  // reverse(g.begin(),g.end());
  reverse(S.begin(),S.end());
  vector<int> ans;
  
  rep(i,N) {
    for (int j=M;j>0;j--) {
      if (i+j>N) continue;
      if (S[i+j]=='0') {
        ans.push_back(j);
        i = i+j-1;
        break;
      }
      if (j==1){
        cout << -1 << endl;
        return 0; 
      }
    }
  }
  reverse(ans.begin(),ans.end());
  for (auto p:ans) cout << p << ' ';
  cout << endl;
}

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

int main()
{
    string S;
    cin >> S;
    if(S.at(2) == S.at(3) && S.at(4) == S.at(5)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Read();
            var k = ReadLong();
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i].ToString() != "1")
                {
                    WriteLine(s[i]);
                    return;
                }
                else
                {
                    if(k==i+1)
                    {
                        WriteLine(1);
                        return;
                    }
                }
            }
            WriteLine(1);
        }
        

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
    }
}


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

using namespace std;

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

	long double r;
	cin >> r;
	cout << fixed << setprecision(10) << 4*r*asin(1) << '\n'; 

	return 0;
} 

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

int main() {
  int rein=0;
  string str;
  cin>>str;
  if(str.at(0)=='R'){
   if(str.at(1)=='R'){
    if(str.at(2)=='R'){
     rein=3;
    }
    else
      rein=2;
   }
   else
     rein=1;
  }
  else{
   if(str.at(1)=='R'){
    if(str.at(2)=='R'){
     rein=2;
    }
    else{
     rein=1;
    }
   }
   else{
    if(str.at(2)=='R'){
     rein=1;
    }
   }
  }
  cout<<rein<<endl;
}


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

using namespace std;

int main(){
	int n, k, happy = 0;
	string s;
	cin >> n >> k >> s;
	for(int i = 0; i < n; i++){
		if(i == 0 && s[i] == 'L') continue;
		if(i == n-1 && s[i] == 'R') continue;
		if(s[i] == 'L' && s[i-1] == 'L') happy++;
		if(s[i] == 'R' && s[i+1] == 'R') happy++;
	}
	cout << min(n-1, happy+2*k) << "\n";
	return 0;
}


Measured memory_bytes: 512
// 2014/09/11 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int t;
		cin >> t;

		if(t==0)
			break;

		int n;
		cin >> n;

		int sum = 0;

		for(int i=0; i<n; i++){
			int s, f;
			cin >> s >> f;

			sum += (f-s);
		}

		if(sum>=t){
			cout << "OK" << endl;
		}
		else{
			cout << t-sum << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	while(1){
		int n,m,a;
		cin >> n >> m >> a;
		if(n==0) break;
		vector<pair<int,pii>> data;
		REP(i,m){
			int h,p,q;
			cin >> h >> p >> q;
			data.pb(mp(h,mp(p,q)));
		}
		sort(All(data));
		int rst[1001];
		REP(i,1001) rst[i] = i;
		REP(i,m){
			int p = data[i].second.first;
			int q = data[i].second.second;
			if(p>q) swap(p,q);
			swap(rst[p],rst[q]);
		}
		cout << rst[a] << endl;
	}
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,k,a[N],ji;
int solve(int now,bool dir)
{
	if((now<=0&&!dir)||(now>=n-1&&dir))return 0;
	if(dir)
		return 1+solve(now+k,dir);
	else
		return 1+solve(now-k,dir);
}
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int  i=0;i<n;i++)
		if(a[i]==1)
			ji=i;
	k--;
	int ans=solve(ji,0)+solve(ji,1);
	if(ji%k!=0&&(n-ji-1)%k!=0&&(ji%k+(n-ji-1)%k)<=k)ans--;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1408
import math
from fractions import Fraction
n, k = map(int, input().split())
ans = Fraction()
for s in range(1, n+1):
    p = math.ceil(math.log2(k) - math.log2(s))
    if p < 1:
        ans += Fraction(1, n)
    else:
        ans += Fraction(1, n * (2 ** p))
print(float(ans))


Measured memory_bytes: 5052
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int a = scan.nextInt();
        int b = scan.nextInt();
        System.out.println(solve(a,b));
    }
    public static int solve(int a, int b) {
        int add = a + b;
        int sub = a - b;
        int max = Math.max(add,sub);
        int multi = a * b;
        max = Math.max(max, multi);
        return max;
    }
}


Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#define MAX 10000000
using namespace std;

typedef pair<int,int> P;
struct edge{
  int to,cost; edge(){}
  edge(int cost,int to):to(to),cost(cost){}
};
vector< vector<edge> > info(110);
int n,m,co[110],ttl;

void init(){
  for(int i=0;i<110;i++) co[i] = MAX;
}

int Dijkstra(){
  init();
  int s,d;
  cin >> s >> d >> ttl;
  priority_queue<P,vector<P>,greater<P> > que;
  que.push(P(0,s));
  co[s] = 0;
  while(!que.empty()){
    P p = que.top(); que.pop();
    int now = p.second,c = p.first;
    if(now == d) return c + 1;
    for(int i=0;i<info[now].size();i++){
      edge e = info[now][i];
      if(e.cost + c < co[e.to]){
	que.push(P(e.cost + c,e.to));
	co[e.to] = e.cost + c;
      }
    }
  }
  return -1;
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    int r,k,tmp;
    cin >> r >> k;
    for(int j=0;j<k;j++){
      cin >> tmp;
      info[r].push_back(edge(1,tmp));
    }
  }
  cin >> m;
  while(m--){
    int d = Dijkstra();
    if(d > ttl || d == -1) cout << "NA" << endl;
    else cout << d << endl;
  }
}

Measured memory_bytes: 1204
import math
def is_prime(n):
    if n < 2:
        return False
    if n == 2:
        return True
    if n%2 == 0:
        return False
    for i in xrange(3, int(math.sqrt(n))+1, 2):
        if n%i == 0:
            return False
    return True

m = list()
s = 0
for i in xrange(10**5):
    if is_prime(i) and is_prime((i+1)/2):
        s += 1
    m.append(s)

n = input()
for _ in xrange(n):
    s = 0
    a, b = map(int, raw_input().split())
    print m[b] - m[a-1]


Measured memory_bytes: 3948
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

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

	auto result = 1;
	for (auto i = 0; i < N; ++i)
	{
		if (result < K)
		{
			result *= 2;
		}
		else
		{
			result += K;
		}
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma region
#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 int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
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;}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void in(T&t){cin>>t;}
template<class T,class... Ts>inline void in(T&t,Ts&...ts){cin>>t;in(ts...);}
template<class T>inline void out(T t){cout<<t<<endl;}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill(T&t,const V&v){for(auto &e:t)fill(e,v);}
constexpr long long INF = 1e18;
#pragma endregion



signed main(){
	int N,M;
	in(N,M);
	auto g = mv<vector<int>>(N),gg=g;
	map<pair<int,int>,int>mp;
	REP(i,M){
		int a,b;
		in(a,b);
		a--;b--;
		g[a].push_back(b);
		mp[minmax(a,b)]=1;
	}
	auto dp = mv<double>(N);
	auto maIdx = mv(N);
	auto ma = mv<double>(N);
	RREP(i,N-1){
		for(auto e:g[i]){
			dp[i] += dp[e];
		}
		dp[i] /= g[i].size();
		dp[i] += 1.0;
	}
	for(auto e:mp){
		if(CHMAX(ma[e.first.first],dp[e.first.second]))maIdx[e.first.first]=e.first.second;
	}
	double ans = dp[0];
	REP(_,N){
		fill(dp,0.0);
		RREP(i,N-1){
			for(auto e:g[i]){
				if(i == _ && e == maIdx[_])continue;
				dp[i] += dp[e];
			}
			dp[i] /= (g[i].size()-(_ == i));
			dp[i] += 1.0;
		}
		CHMIN(ans,dp[0]);
	}
	printf("%.20f\n",ans);
}

Measured memory_bytes: 13696
#include<cstdio>
#include<algorithm>
using namespace std;
int A,N;
int read(){
	int w=0;char c=getchar();
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') w=w*10+c-48,c=getchar();
	return w;
}
int main(){
	A=read();N=read();
	A%=500;
	if(A<=N) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
def solve():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    B = sorted(A)
    if B[-1]==B[-2]:
        for i in range(N):
            print(B[-1])
    else:
        for i in range(N):
            if A[i]==B[-1]:
                print(B[-2])
            else:
                print(B[-1])
    
solve()    

Measured memory_bytes: 14112
#include <stdio.h>
 
int main(){
    long long int G;
    scanf("%lld",&G);
 
    char name[100];
    int i=0;

    while(G!=0)
    {
        G--;
        int kt = G%26;
        name[i] ='a'+ kt;
        G/=26;
        i++;
    }
 
    for(int j=i-1;j>=0;j--)
    {
        printf("%c",name[j]);
    }

    return 0;
}


Measured memory_bytes: 1636
#include <iostream> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <algorithm>
#include <vector>
#include <queue> 
using namespace std; 
inline int gi() { 
    int data = 0, w = 1; 
    char ch = 0; 
    while (!isdigit(ch) && ch != '-') ch = getchar(); 
    if (ch == '-') w = -1, ch = getchar(); 
    while (isdigit(ch)) data = 10 * data + ch - '0', ch = getchar();
    return w * data; 
} 
const int MAX_N = 1e5 + 5; 
int N, M, a[MAX_N]; 
vector<int> G[MAX_N]; 
int ans = 0; 
int main () { 
	N = gi(), M = gi(); 
	for (int i = 1; i <= N; i++) a[i] = gi(); 
	for (int i = 1; i <= M; i++) {
		int u = gi(), v = gi(); 
		G[u].push_back(v); 
		G[v].push_back(u); 
	} 
	for (int x = 1; x <= N; x++) {
		bool fl = 1;
		for (int i = 0; i < (int)G[x].size(); i++) {
			int v = G[x][i]; 
			if (a[x] <= a[v]) { 
				fl = 0; break; 
			} 
		} 
		ans += fl; 
	} 
	cout << ans << endl; 
    return 0; 
} 

Measured memory_bytes: 8680
s = sorted(list(set(input())))

if len(s) == 1 or len(s)==3: ans = "No"
elif len(s) == 2 or len(s)==4:
    if s == ["N","S"] or s == ["E", "W"]: ans = "Yes"
    elif s == ["E", "N", "S", "W"]: ans = "Yes"
    else: ans = "No"
print(ans)

Measured memory_bytes: 9064
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }



signed main(){

    int X, Y; cin >> X >> Y;
    cout << X + Y / 2;
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Text;

class Program
{
    static void Main(string[] args) {
        var scan = new Scanner();
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(Solve(scan));
        Console.Out.Flush();
    }
    static object Solve(Scanner scan) {
        long a = scan.NextLong(), b = scan.NextLong();
        if (a == 0 || b == 0 || a < 0 && 0 < b) return "Zero";
        if (a < 0 && b < 0) {
            return (Math.Abs(a - b) + 1) % 2 == 0 ? "Positive" : "Negative";
        }
        return "Positive";
    }
}

class Scanner
{
    string[] s;
    int i;
    public Scanner() {
        s = new string[0];
        i = 0;
    }
    public string Next() {
        if (i < s.Length) return s[i++];
        string str = Console.ReadLine();
        while (str == "") str = Console.ReadLine();
        s = str.Split(' ', StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }
    public long NextLong() => long.Parse(Next());
}

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

int main()
{
    int i,sum=0,m=0;
    char S[20];
    scanf("%s",S);
    for(i=0;S[i];i++)
    {
        if(S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T')
        {
            sum++;
            if(S[i+1]=='\0')
            {
                if(sum>m)
                {
                    m=sum;
                    break;
                }
            }
        }
        else if(sum>m)
        {

            m=sum;
            sum=0;
        }
    }
    printf("%d\n",m);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
 
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;
}
ll max(ll a, ll b){
    if(a > b) return a;
    else return b;
}
 
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}

int main(void){
    int H,W; cin >> H >> W;
    vector<vector<char>> C(H,vector<char>(W));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> C[i][j];
        }
    }
    
    for(int i = 0; i < H; i++){
        for(int k = 0; k < 2; k++){
            for(int j = 0; j < W; j++){
                cout << C[i][j];
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int i;
  char s[100];
  while(fgets(s,80,stdin)!=NULL){
    while(1){
      for(i=0;s[i];i++){
	if('a'<=s[i]&&s[i]<='z'){
	  s[i]++;
	  if(s[i]=='z'+1)s[i]='a';
	}
      }
      if(strstr(s,"this")||strstr(s,"that")||strstr(s,"the"))break;
    }
    printf("%s",s);
  }
  return 0;
}

Measured memory_bytes: 524
#include <iostream>

using namespace std;

int gcd(int a, int b)
{
	int c;
	if (a < b)
		swap(a, b);

	while (b > 0)
	{
		c = a % b;
		a = b;
		b = c;
	}

	return a;
}

int main()
{
	int N, K, a;
	int gcd_v, max_v;
	cin >> N >> K;

	cin >> a;
	gcd_v = a;
	max_v = a;

	for (int i = 1; i < N; i++)
	{
		cin >> a;

		gcd_v = gcd(gcd_v, a);

		if (max_v < a)
			max_v = a;
	}

	if (max_v < K || K % gcd_v != 0)
		cout << "IMPOSSIBLE" << endl;
	else
		cout << "POSSIBLE" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){

    int  a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    
   d = a/b;
   r = a%b;
   f = 1.00000*a/b;
 
    
    
    printf("%d %d %.5lf\n",d,r,f);
    
    return 0;


    
}



Measured memory_bytes: 2100
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int A, B; cin >> A >> B; A--, B--;
  cout << "100 100" << endl;
  for(int i = 0; i < 50; ++i) {
    for(int j = 0; j < 100; ++j) {
      if(A > 0 && (i%2==0) && (j%2==1)) {
        cout << '.';
        A--;
      } else {
        cout << '#';
      }
    }
    cout << endl;
  }

  for(int i = 0; i < 50; ++i) {
    for(int j = 0; j < 100; ++j) {
      if(B > 0 && (i%2==1) && (j%2==1)) {
        cout << '#';
        B--;
      } else {
        cout << '.';
      }
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod=1e9 +7;
int main(){


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


ll n;
cin>>n;
ll a[n];
ll sum=0;
for(int i=0;i<n;i++){
	cin>>a[i];
	sum+=a[i];
}

ll sum1=0;

for(int i=0;i<n-1;i++){
	sum = sum - a[i];

	sum1 = sum1 + ((sum % mod) * (a[i] % mod)) % mod;
	sum1 = sum1 % mod;
}

cout<<sum1;

return 0;
}





Measured memory_bytes: 5208
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        BigInteger[] nums = new BigInteger[N];


        for (int i = 0; i < N; i++) {
            nums[i] = sc.nextBigInteger();
        }

        BigInteger sum = BigInteger.ZERO;
        for (int i = 1; i < N; i++) {
            if (nums[i-1].compareTo(nums[i]) > 0) {
                BigInteger b = nums[i - 1].subtract(nums[i]);

                sum = sum.add(b);
                nums[i] =nums[i].add(b);
            }
        }

        System.out.println(sum);

    }
}

Measured memory_bytes: 84236
#include <stdio.h>
#define N 100
int main(){
  int po[N][3],to[N],num=-1;
  int i,j;
  while(1){
    num+=1;
    scanf("%d %d %d",&po[num][0],&po[num][1],&po[num][2]);
    if(po[num][0]==-1&&po[num][1]==-1&&po[num][2]==-1)break;
  }
  for(i=0; i<num; i++){
    to[i]=po[i][0]+po[i][1];
    if((po[i][0]+po[i][1])<30||po[i][0]==-1||po[i][1]==-1)printf("%c\n",'F');
    else if((po[i][0]+po[i][1])>=80)printf("%c\n",'A');
    else if(to[i]>=65&&to[i]<80)printf("%c\n",'B');
    else if(to[i]>=50&&to[i]<65)printf("%c\n",'C');
    else if(to[i]>=30&&to[i]<50&&po[i][2]>=50)printf("%c\n",'C');
    else printf("%c\n",'D');
  }
  return 0;
}

Measured memory_bytes: 600
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N;
            N = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            int[] B = new int[str.Length];
            for (int i = 0; i < str.Length; ++i)
            {
                B[i] = int.Parse(str[i]);
            }

            int[] A = new int[N];
            for (int i = 0; i < N; ++i)
                A[i] = int.MaxValue;

            for (int i = 0; i < N - 1; ++i)
            {
                if (A[i] > B[i])
                    A[i] = B[i];
                if (A[i + 1] > B[i])
                    A[i + 1] = B[i];
            }
            int sum = A.Sum();

            Console.WriteLine("{0}", sum);//改行付き出力
        }
    }
}


Measured memory_bytes: 13268