akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
using namespace std;
#define inf 2147480000
struct hammer
{
   double x;
   double y;
}box[10001];
struct heaven
{
   int start;
   int end;
   double data;
}map[10000001];
int n,m;
int o=0;
double total;
double add(hammer a,hammer b)
{
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
int set[10001];
int size[10001];
void ini()
{
   for(int i=1;i<=n;i++)
   {
      set[i]=i;
      size[i]=1;
   }
}
int find(int a)
{
    if(set[a]==a) return a;
    set[a]=find(set[a]);
    return set[a];
}
void uni(int a,int b)
{
   if(size[a]>=size[b])
   {
      size[a]+=size[b];set[b]=a;
   }
   else 
   {
      size[b]+=size[a];set[a]=b;
   }
}
int cmp(const heaven & a,const heaven & b)
{
    if(a.data>b.data) return 1;
    else return 0;
}
int main(int argc, char *argv[])
{
    cin>>n>>m;
    ini();
    for(int i=1;i<=n;i++)
    {
       double a,b;
       scanf("%lf%lf",&a,&b);
       box[i].x=a;box[i].y=b;
    }
    for(int i=1;i<=m;i++)
    {
       int a,b;
       scanf("%d%d",&a,&b);
       o++;
       map[o].start=a;map[o].end=b;
       map[o].data=add(box[a],box[b]);
       total+=map[o].data;
    }
    sort(map+1,map+1+o,cmp);
    double sum=0;
    for(int i=1;i<=o;i++)
    {
        int a=find(map[i].start);int b=find(map[i].end);
        if(a!=b)
        {
            uni(a,b);
            sum+=map[i].data;
        }
    }
    sum=total-sum;
    printf("%.3lf\n",sum);
    return 0;
}

Measured memory_bytes: 1984
#include <bits/stdc++.h>
using namespace std;
#define int long long
#pragma region alias
#define inf LONG_MAX
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repr(i,n) for(int i=(int)(n-1);i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define sz(v) ((int)(v).size())
#define rz resize
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define vec vector
using vi=vec<int>;
using vs=vec<string>;
using ii=pair<int,int>;
#pragma endregion

// define variables here
int n;
string s;
vi r,g,b;
void solve(){
  // write code here
  cin>>n;
  cin>>s;
  rep(i,n){
    if(s[i]=='R')r.eb(i);
    else if(s[i]=='G')g.eb(i);
    else if(s[i]=='B')b.eb(i);
  }
  int ans=0;
  rep(i,n){
    rep(j,n){
      if(i>=j||s[i]==s[j])continue;

      vi target;
      if(s[i]!='B'&&s[j]!='B') target=b;
      else if(s[i]!='R'&&s[j]!='R') target=r;
      else if(s[i]!='G'&&s[j]!='G') target=g;
      else continue;

      int cnt_bigger=(int)distance(lower_bound(all(target),j),target.end());
      if(binary_search(all(target),2*j-i))cnt_bigger--;
      ans+=cnt_bigger;
    }
  }
  cout<<ans<<endl;
}

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

Measured memory_bytes: 3664
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int get_match_id(int a, int b, int n){
    if(a>b)
    {
        swap(a, b);
    }
    int base = 0;
    if(a>1) {
        base = (n + (n-a+2)) * (a-1) / 2;
    }
    return base + b;
}

int dp[1000001];
int check_depth(map<int,vector<int>> &edges, int src, int n, set<int> &hist) {
    int max_depth = 0;
    if(dp[src] != 0) return dp[src];
    for(int next: edges[src]) {
        //dump(next)
        if(hist.find(next) != hist.end()) return 1 << 30;
        hist.insert(next);
        max_depth = max(max_depth, check_depth(edges, next, n, hist) + 1);
        hist.erase(next);
    }
    //dump(max_depth)
    dp[src] = max_depth;
    return max_depth;
}

int main(){
    std::ios::sync_with_stdio(false);
    map<int,vector<int>> edges;

    int n, tmp;
    cin >> n;
    vector<vector<int>> matches(n);
    for(int i=1;i<=n;++i)
    {
        for(int j=0;j<(n-1);++j)
        {
            cin >> tmp;
            matches[i-1].push_back(get_match_id(i, tmp, n));
        }
    }

    for(int i=0;i<n;++i)
    {
        int sz = matches[i].size();
        for(int j=0;j<sz-1;++j)
        {
            edges[matches[i][j]].push_back(matches[i][j+1]);
        }
    }
    int max_depth = 0;

    for(int i=1;i<=n;++i) {
        for(int j=i+1;j<=n;++j){
            int start_node = get_match_id(i,j,n);
            set<int> hist;
            hist.insert(start_node);
            int depth = check_depth(edges, start_node, n, hist);
            if(depth >= (1 << 30)){
                cout << -1 << endl;
                return 0;                
            }
            max_depth = max(max_depth, depth);
        }
    }

    cout << max_depth + 1 << endl;
}

Measured memory_bytes: 61440
def read_int():
    return int(input())

def read_int_map():
    return map(int,input().split(' '))

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

def read_s_list_loop(n):
    return [input() for _ in range(n)]

A,V = read_int_map()
B,W = read_int_map()
T = read_int()
diff = abs(A-B)
if V*T >= W*T+diff :
    print('YES')
else:
    print('NO')

Measured memory_bytes: 61860
#include <iostream>
#include <vector>
#define REP(i,n) for(int i = 0; i < (n); i++)

using namespace std;

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

int main()
{
  int N, X; cin >> N >> X;
  int ans;
  REP(i, N) {
    int a; cin >> a;
    a = abs(X - a);
    if (i == 0) ans = a;
    else ans = gcd(a, ans);
  }
  cout << ans << endl;

  return 0;
}



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

int main() {
  int N;
  long A,B;
  cin >> N >> A >> B;
  int X[N];
  cin >> X[0];
  long sum=0;
  for(int i=1;i<N;i++){
    cin >> X[i];
    sum+=min(B,A*(X[i]-X[i-1]));
  }
  cout << sum;
}


Measured memory_bytes: 640
n, k = map(int, input().split())
mod = 10**9 + 7

MAX = sum([i for i in range(n-k+1, n+1)[::-1]])
MIN = sum([i for i in range(k)])

ans = MAX - MIN + 1
for i in range(k, n+1):
    MAX+=n-i
    MIN+=i
    ans += MAX - MIN + 1
    ans%=mod

print(ans)

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

int main(void){
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  a *= 100;
  b *= 100;
  vector<int> x, y;
  double ans = 0;
  for(int i = 0; i <= f; i++){
    for(int j = 0; j <= f; j++){
      int tempx = i * a + j * b;
      int tempy = i * c + j * d;
      if(tempx <= f){
        x.push_back(tempx);
      }
      if(tempy <= f){
        y.push_back(tempy);
      }
    }
  }
  double con = -10;
  int answ = 0, anss = 0;
  for(int i = 0; i < x.size(); i++){
    for(int j = 0; j < y.size(); j++){
      if(x[i] == 0 && y[j] == 0) continue;
      if(x[i] + y[j] <= f && y[j] <= x[i] / 100 * e){
        if(con < (double) y[j] / (double)(x[i] + y[j])){
          answ = x[i];
          anss = y[j];
          con = (double) y[j] / (double)(x[i] + y[j]);
        }
      }
    }
  }
  cout << answ + anss << " " << anss << endl;
  return 0;
}


Measured memory_bytes: 1400
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
//	 static int mod = 998244353;
   public static void main(String[] args) {
	   
       Scanner sc = new Scanner(System.in);
       String S = sc.next();
       String T = sc.next();
       char[] c = S.toCharArray();
       char[] d = T.toCharArray();
       
       
       char[][] v=new char[26][2];
       int flg=0;
       int cnt=0;
       for(int i=0;i<S.length();i++) {
    	   flg=0;
    	   for(int j=0;j<cnt;j++) {
     		  if(v[j][0]==c[i]) {
    			  if(v[j][1]!=d[i]) {
    				  flg=-1;
    				  break;
    			  } else {
    				  flg=1;
    			  }
    		  }
    		  if(v[j][1]==d[i]) {
    			  if(v[j][0]!=c[i]) {
    				  flg=-1;
    				  break;
    			  }
    		  }    		  
    	   }
    	   if(flg==0) {
    		   v[cnt][0]=c[i];
    		   v[cnt][1]=d[i];
    		   cnt++;
    	   }
    	   if(flg==-1)break;
       }
       
       if(flg==-1) {
    	   System.out.println("No");
       } else {
    	   System.out.println("Yes");

       }
       
   }
}

Measured memory_bytes: 30424
const rowList = require('fs').readFileSync('/dev/stdin','utf8').trim().split('\n')

var stringList = rowList.slice(1).map(e => e.split('').sort().join(''))

var pairs = 0
var h = {}
for(var i=0;i<stringList.length;i++) {
  if(h[stringList[i]]) {
    h[stringList[i]] += 1
  } else {
    h[stringList[i]] = 1
  }
}

pairs = 0
for(var i in h) {
  var p = 0
  for(var j=1;j<h[i];j++) {
    p += j
  }

  pairs += p
}

console.log(pairs)


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

using Tup = tuple<int64, int64, int64>;

int32 prime[1333456] = {};

void init(){
	FOR(i, 2, 1333456){
		if(prime[i] == 0){
			for(int32 j = 2;i*j < 1333456;j++){
				prime[i*j] = 1;
			}
		}
	}
	REP(i, 1333455){
		if(prime[i+1] != 0){
			prime[i+1] += prime[i];
		}
	}
	for(int32 i = 1333454;i >= 0;i--){
		if(prime[i] != 0){
			chmax(prime[i], prime[i+1]);
		}
	}
}

int main(void){
	int32 n;
	init();
	while(cin >> n && n){
		cout << (prime[n] ? prime[n]+1 : 0) << endl;
	}
}



Measured memory_bytes: 13496
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int a, b, c,cnt = 0;
    scanf("%d %d %d", &a, &b, &c);
    for(int i = a; i <= b; i++){
        if(i % c == 0) cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 3824
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<int(n); i++)
#define all(c) (c).begin(), (c).end()
#define _1 first
#define _2 second
#define pb push_back
#define INF (1LL<<60)
#define MOD 1000000007
#define MAX_N (1<<17) // 10^5

struct SegTree {
  long long seg[MAX_N*2-1];
  SegTree() {
    for (int i=MAX_N*2-2; i>=0; i--) seg[i] = INF;
  }

  void update(int i, long long x) {
    i += MAX_N-1;
    if (seg[i] <= x) return;
    seg[i] = x;
    while (i > 0) {
      i = (i-1) / 2;
      seg[i] = min(seg[i*2+1], seg[i*2+2]);
    }
  }
  long long query(int a, int b, int k=0, int l=0, int r=MAX_N) {
    if (r <= a || b <= l) return INF;
    if (a <= l && r <= b) return seg[k];
    return min(
      query(a, b, k*2+1, l, (l+r)/2),
      query(a, b, k*2+2, (l+r)/2, r)
    );
  }
};

int N, E, T;
int X[100002];
SegTree dp, f;

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> E >> T;
  for (int i=1; i<=N; i++) cin >> X[i];

  dp.update(0, 0);
  f.update(0, -2LL*X[1]);
  int l = 0;
  for (int i=1; i<=N; i++) {
    long long m = INF;
    while (l < N && X[l+1] < X[i] - T/2) l++;
    m = min(m, dp.query(l, i) + T);
    m = min(m, f.query(0, l) + 2*X[i]);
    f.update(i, m - 2LL*X[i+1]);
    dp.update(i, m);
  }
  cout << dp.query(N, N+1) + E << "\n";
  return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  string s;
  while(1){
    cin >> s;
    if(s=="#") return 0;
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    vector<vector<int>> field(10,vector<int>(10,0));
    int x=0,y=0;
    for(int now=0;now<s.length();now++){
      if(s[now]=='/'){
        y++;
        x=0;
      }else if(s[now]=='b'){
        field[y][x]=2;
        x++;
      }else{
        for(int i=0;i<s[now]-'0';i++){
          field[y][x+i]=1;
        }
        x+=s[now]-'0';
      }
    }
    field[a-1][b-1]=1;
    field[c-1][d-1]=2;
    // for(int i=0;i<9;i++){
    //   for(int j=0;j<9;j++){
    //     cout << field[i][j];
    //   }
    //   cout << endl;
    // }
    int count=0;
    for(int i=0;i<10;i++){
      if(field[i][0]==0){
        cout << endl;
        break;
      }
      for(int j=0;j<10;j++){
        if(field[i][j]==0){
          if(count>0) cout << (count);
          count=0;
          if(field[i+1][0]!=0) cout << "/";
          break;
        }else if(field[i][j]==1){
          count++;
        }else{
          if(count>0) cout << (count);
          count=0;
          cout << "b";
        }
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3152
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int MOD = 2019;

int c[MOD];

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

	int cur = 0;
	c[cur]++;
	string s;
	cin >> s;
	int ans = 0;
	reverse(s.begin(), s.end());
	int p = 1;
	for (auto x : s) {
		int ncur = cur + p * (x - '0');
		ncur %= MOD;
		ans += c[ncur];
		cur	= ncur;
		c[cur]++;
		p *= 10;
		p %= MOD;
	}
	cout << ans << endl;
}


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

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

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

signed main(){
	int a,b;
	while(cin >> a >> b){
		cout << gcd(a,b) << " " << lcm(a,b) << endl;
	}
}



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

int main() {
  string S;
  cin >> S;
  vector<int> v;
  for ( int i = 0; i < S.size(); i++) {
    if (S.at(i) == 'W') {
      v.push_back(i);
    }
  }
  int64_t n = v.size();
  int64_t t = 0;
  for (int i = 0; i < n; i++) {
    t += v.at(i) - i;
  }
  cout << t << endl;
}


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

using namespace std;
typedef long long ll;

int n;
int a[20][20];
ll sum[1<<16];
ll dp[1<<16];
ll f(int msk)
{
    ll &ret = dp[msk];
    if (~ret) return ret;
    ret = 0;
    for (int sub = msk ; sub ; sub = (sub-1) & msk)
    {
        ret = max(ret, f(msk ^ sub) + sum[sub]);
    }
    return ret;
}
int main()
{
    memset(dp, -1, sizeof dp);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            scanf("%d", &a[i][j]);
    for (int i = 0 ; i < (1<<n); ++i)
    {
        for (int j = 0 ; j < n; ++j)
            if ((1<<j) & i)
                for (int k = 0; k < n; ++k)
                    if ((1<<k) & i)
                        sum[i] += a[j][k];
        sum[i] /= 2;
    }
    printf("%lld\n", f((1<<n)-1));
    return 0;
}


Measured memory_bytes: 1408
x = input().split()
n = int(x[0])
m = int(x[1])
if n == 0:
  print(int(m * (m -1) /2))
elif m == 0:
  print(int(n * (n - 1) / 2))
else:
  k = m * (m -1) /2 + n * (n - 1) / 2
  print(int(k))

Measured memory_bytes: 3060
def main():
    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
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    h = int(input())
    w = int(input())
    print((n-h+1)*(n-w+1))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
N,M,C = (int(x) for x in input().split())
B_arr = [int(x) for x in input().split()]+[C]

ans = 0
for _ in range(N):
    A_arr = [int(x) for x in input().split()] + [1]
    t = 0
    for a,b in zip(A_arr, B_arr):
        t += a*b
    if t > 0:
        ans += 1
print(ans)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
bool IsKaibun(string s) {
  int n = s.size();
  rep(i, n / 2) {
    if (s.at(i) != s.at(n - i - 1)) return false;
  }
  return true;
}
int main() {
  string s;
  cin >> s;
  int n;
  n = s.size();
  string s_1, s_2;
  rep(i, ((n - 1) / 2)) { s_1 += s.at(i); }
  for (int i = (n + 2) / 2; i < n; i++) {
    s_2 += s.at(i);
  }
  if (IsKaibun(s) && IsKaibun(s_1) && IsKaibun(s_2))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    string s; cin >> s;
    int q; cin >> q;

    deque<char> deq;
    bool rev = false;

    for (int i = 0; i < s.size(); ++i) {
        deq.push_back(s[i]);
    }

    for (int i = 0; i < q; ++i) {
        int t; cin >> t;

        if (t == 1) {
            rev = !rev;
        } else {
            int f; cin >> f;
            char c; cin >> c;

            if (!rev) {
                if (f == 1) {
                    deq.push_front(c);
                } else {
                    deq.push_back(c);
                }
            } else {
                if (f == 1) {
                    deq.push_back(c);
                } else {
                    deq.push_front(c);
                }
            }
        }
    }

    if (rev) {
        reverse(deq.begin(), deq.end());
    }


    for (char t : deq) {
        cout << t;
    }

    cout << endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout<<'\n';
#define MOD 1000000007
#define sz(x) ((int)x.size())
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN

void solve(){
  int n,k; cin>>n>>k;
  int a[n];
  for(int i=0 ; i<n ; i++) cin>>a[i];
  sort(a,a+n);
  int ans=0;
  for(int i=0 ; i<k ; i++) ans+=a[i];
  cout<<ans;LOL
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  solve();
  return 0;
}

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

#define log(x) cout << (x) << endl
using ll = long long;

int main() {

	ll A,B,C,x,y;
	cin>>A>>B>>C>>x>>y;

	if (C*2 > A+B) {
		log(A*x + B*y);
	}
	else {
		ll m = min(x,y) * 2, cst = 0;
		cst += C*m;

		if (x > y) {
			if (C*2 < A) cst += C * ((x-y) * 2);
			else cst += A * (x-y);
		}
		else if (y > x) {
			if (C*2 < B) cst += C * ((y-x) * 2);
			else cst += B * (y-x);
		}

		log(cst);
	}


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

string a[8] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};

int main() {
  string s;
  cin >> s;
  int ans = 7;
  FOR(i, 0, 7) {
    if(s==a[i]) {
      ans -= i;
      break;
    }
  }
  cout << ans << endl;

  return 0;
}

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

    
int main(){
    
    char b;
    cin >> b ;
    if(b=='A'){cout << 'T' << endl;}
    if(b=='T'){cout << 'A' << endl;}
    if(b=='G'){cout << 'C' << endl;}
    if(b=='C'){cout << 'G' << endl;}
}

Measured memory_bytes: 256
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
max_box = [0]*n
for i in range(n):
  max_box[i] = v[i]-c[i]
max_box.sort()
ans = 0
for i in range(n):
  ans += max_box[i] if max_box[i]>0 else 0
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;

int main(){
    int n; cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    int res = 0, tmp = 0, j, k;

    rep(i, n){
        tmp = 0;
        for(j = 0; j <= i; ++j){
            tmp += a[j];
        }
        for(k = j-1; k < n; ++k){
            tmp += b[k];
        }
        if(res <= tmp) res = tmp;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repin(Array,n) for(int i=0;i<n;i++){cin>>Array[i];}
using namespace std;

using ll = long long;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;
using Graph = vector<vector<int>>;

int main() {

	int N;
	cin >> N;

	int ans = 0;
	rep(i, N) {
		int l, r;
		cin >> l >> r;
		ans += r - l + 1;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
def divisors(n)
  b = Array.new
  for i in 1..((n**0.5))
    if n % i == 0
      b.push(i)
    end
  end
  len = b.length
  len.times{|i|
    if n/b[len-1-i] != b[len-1-i]
      b.push(n/b[len-1-i])
    end
  }
  b
end
n,m = gets.chomp.split(" ").map(&:to_i)
max = 1
divisors(m).each do |i|
  if (m - i*n) >= 0 && (m - i*n) % i == 0
    max = i if i > max
  end
end
puts max


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

int main() {
  double a,b,h,m;
  cin>>a>>b>>h>>m;
  double ca=30*h+0.5*m;
  double cb=6*m;
  double c=ca-cb;
  c*=M_PI;
  c/=180;
  double co=cos(c);
  double ans=a*a+b*b-2*a*b*co;
  ans=sqrt(ans);
  cout<<setprecision(12)<<ans<<endl;
}

Measured memory_bytes: 4228
#include<stdio.h>
int A[20000000],B[20000000],C[20000000];
int n;

void CountingSort(int k)
{
  int i,j;
  for(i=0;i<=k;i++)
    {
      C[i]=0;
    }
  for(j=1;j<=n;j++)
    {
      C[A[j]]++;
    }
  for(i=1;i<=k;i++)
    {
      C[i]=C[i]+C[i-1];
    }
  for(j=n;j>=1;j--)
    {
      B[C[A[j]]]=A[j];
      C[A[j]]--;
    }
}

main(){
  int i,k=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    {
      scanf("%d",&A[i]);
      if(k<A[i])
	k=A[i];
    }
  CountingSort(k);
  for(i=1;i<=n;i++)
    {
      printf("%d",B[i]);
      if(i<n)
	printf(" ");
    }
  printf("\n");
  return 0;

}

Measured memory_bytes: 21076
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin >> S ;
    int l = S.length();
    int i;
    int k[l];
    for(i=0;i<l;i++)
    {
        k[i] = 0;
    }
    int count_pre = 0;
    int count_ans = 0;
    for(i=0;i<l;i++)
    {
        
        count_pre++;
        if(S[i]!='A' && S[i] != 'T' && S[i]!='C' && S[i] != 'G')
        {
            count_pre =0;
        }
        
        k[i] = count_pre;
        
        
    }
    sort(k,k+l);
    
    cout << k[l-1] << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		int n = in.readInt();
		int m = in.readInt(); 
		System.out.println((n-1)*(m-1));
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 21204
function main(input) {
  const args = input.split('');
  let count = 0;
  for (let i = 0; i < args.length; i++) {
    args[i] === 'o' ? count++ : ''
  }
  
  console.log(700 + (100 * count));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29476
#include <bits/stdc++.h>
using namespace std;
int b[666];
int main(){
	string s;
	while(getline(cin,s))for(int i=0;i<s.length();i++)b[s[i]]++;
	for(char i='a';i<='z';i++)
		printf("%c : %d\n",i,b[i]+b[i-'a'+'A']);
	return 0;
}


Measured memory_bytes: 3244
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll unsigned long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

void solve() {
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5])  cout << "Yes";
    else cout << "No";
    
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int t = 1;
    // cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}




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


int main(){
	
	int n,w;
	while(cin>>n>>w,n){
		int d[11]={0};
		int mx=0;
		int g;
		double ans=0.01;
		for(int i=0;i<n;i++){
			int v;
			cin>>v;
			d[v/w]++;
		}
		for(int i=0;i<11;i++){
			mx=max(mx,d[i]);
			if(d[i]>0)g=i+1;
		}
		for(int i=0;i<g;i++){
			ans+=(double)(g-1-i)/(g-1)*d[i]/mx;
		}
		
		
		printf("%8f\n",ans);
	}
	
	return 0;
}


Measured memory_bytes: 1188
n, k = map(int, input().split())
h =  list(map(int, input().split()))

def solve():
    global n, k, h
    if n <= k:
        return 0
    s = sum(h)
    h = sorted(h, reverse=True)
    for i in range(k):
        s -= h[i]
    return s

print(solve())

Measured memory_bytes: 26024
#include <iostream>
#include <string>

using namespace std;

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

    string t = "keyence";

    bool res = false;
    for (int i = 0; i <= static_cast<int>(t.size()); i++) {
        res = res || (s.substr(0, i) == t.substr(0, i)
                && s.substr(s.size() - t.size() + i, t.size() - i) == t.substr(i, t.size() - i));
    }

    cout << (res ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
import sys

ERROR_INPUT = 'input is invalid'


def main():
    n = get_length()
    arr = get_array(length=n)

    bubbleLi = bubbleSort(li=arr.copy(), length=n)
    selectionLi = selectionSort(li=arr.copy(), length=n)

    print(*list(map(lambda c: c.card, bubbleLi)))
    print(checkStable(inp=arr, out=bubbleLi))
    print(*list(map(lambda c: c.card, selectionLi)))
    print(checkStable(inp=arr, out=selectionLi))
    return 0


def get_length():
    n = int(input())
    if n < 1 or n > 36:
        print(ERROR_INPUT)
        sys.exit(1)
    else:
        return n


def get_array(length):
    nums = input().split(' ')
    return [Card(n) for n in nums]


def bubbleSort(li, length):
    for n in range(length):
        for n in range(1, length - n):
            if li[n].num < li[n - 1].num:
                li[n], li[n - 1] = li[n - 1], li[n]

    return li


def selectionSort(li, length):
    for i in range(0, length - 1):
        min_index = i
        for j in range(i, length):
            if li[j].num < li[min_index].num:
                min_index = j

        if i != min_index:
            li[i], li[min_index] = li[min_index], li[i]

    return li


def checkStable(inp, out):
    small_num = out[0].num

    for n in range(1, len(out)):
        if out[n].num == small_num:
            if inp.index(out[n]) < inp.index(out[n - 1]):
                return 'Not stable'
        elif small_num < out[n].num:
            small_num = out[n].num
            continue

    return 'Stable'


class Card:
    def __init__(self, disp):
        li = list(disp)
        self.card = disp
        self.chara = li[0]
        self.num = int(li[1])
        return


main()

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

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

int n;
string str;

map<tuple<int, bool>, long long> dp;

long long dfs(int p, bool black) {
	if (p == n) return 0;
	auto status = make_tuple(p, black);
	if (dp.count(status)) return dp[status];
	if (!black) {
		if (str[p] == '#') {
			return dp[status] = min(dfs(p + 1, false) + 1, dfs(p + 1, true));
		}
		return dp[status] = dfs(p + 1, str[p] == '#');
	}
	if (str[p] == '.') {
		return dp[status] = dfs(p + 1, true) + 1;
	}
	return dp[status] = dfs(p + 1, true);
}

void hawawa()
{
	int n;
	cin >> n;
	Vec<int> v(n), c(n);
	for (auto&& i : v) {
		cin >> i;
	}
	for (auto&& i : c) {
		cin >> i;
	}
	int ans = 0;
	for (int i = 0; i < n; i++)	{
		ans += max(v[i] - c[i], 0);
	}
	cout << ans << "\n";
}


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


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = 0;
        for(int i=1; i<=n; i++){
            if(sc.nextInt()!=i){
              d++;
            }
        }
        System.out.println(d<=2 ? "YES" : "NO");
    }
}


Measured memory_bytes: 23252
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String str = in.nextLine();
		int q = Integer.parseInt(in.nextLine());

		for (int i = 0; i < q; i++) {
			String strs[] = in.nextLine().split(" ");
			String what = strs[0];
			int a = Integer.parseInt(strs[1]);
			int b = Integer.parseInt(strs[2]);
			switch (what) {
				case "print":
					System.out.println(str.substring(a, b+1));
					break;
				case "replace":
					String target = strs[3];
					str = str.substring(0, a) + target + str.substring(b+1);
					break;
				case "reverse":
					str = str.substring(0, a) + new StringBuilder(str.substring(a, b+1)).reverse().toString() + str.substring(b+1);
					break;
			}
		}
	}
}

Measured memory_bytes: 28868
#include<iostream>
#include<stack>
using namespace std;
int n;
long a[2<<17];
long L[2<<17],R[2<<17];
long cnt(long s,long t)
{
	long ans=0;
	while(s<t)s*=4,ans++;
	return ans;
}
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	stack<pair<int,int> >S;
	for(int i=1;i<n;i++)
	{
		long now;
		if(a[i-1]<a[i])now=cnt(a[i-1],a[i]);
		else now=1-cnt(a[i],a[i-1]+1);
		L[i+1]=L[i];
		if(now>=0)
		{
			while(now>0)
			{
				if(S.empty())
				{
					L[i+1]+=i*now*2;
					break;
				}
				else
				{
					pair<int,int>p=S.top();S.pop();
					if(p.first>=now)
					{
						p.first-=now;
						L[i+1]+=(i-p.second)*now*2;
						now=0;
						if(p.first>0)S.push(p);
					}
					else
					{
						L[i+1]+=(i-p.second)*p.first*2;
						now-=p.first;
					}
				}
			}
		}
		else
		{
			S.push(make_pair(-now,i));
		}
	}
	stack<pair<int,int> >T;
	for(int i=n-1;i--;)
	{
		long now;
		if(a[i+1]<a[i])now=cnt(a[i+1],a[i]);
		else now=1-cnt(a[i],a[i+1]+1);
		R[i]=R[i+1];
		if(now>=0)
		{
			while(now>0)
			{
				if(S.empty())
				{
					R[i]+=(n-1-i)*now*2;
					break;
				}
				else
				{
					pair<int,int>p=S.top();S.pop();
					if(p.first>=now)
					{
						p.first-=now;
						R[i]+=(p.second-i)*now*2;
						now=0;
						if(p.first>0)S.push(p);
					}
					else
					{
						R[i]+=(p.second-i)*p.first*2;
						now-=p.first;
					}
				}
			}
		}
		else
		{
			S.push(make_pair(-now,i));
		}
	}
	long ans=R[0];
	for(int i=1;i<=n;i++)ans=min(ans,L[i]+R[i]+i);
	cout<<ans<<endl;
}


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

// why am I so weak

int n, m;
char mat[8][9];

int main() {
	scanf("%d %d", &n, &m);
	
	for (int i = 0; i < n; i++) scanf("%s", mat[i]);
	
	int pos = 0;
	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < pos; j++) if (mat[i][j] == '#') return 0 * printf("Impossible");
		
		if (mat[i][pos] != '#') return 0 * printf("Impossible");
		
		for (int j = pos + 1; j < m; j++) {
			if (mat[i][j] == '#') {
				if (pos + 1 != j) {
					return 0 * printf("Impossible");
				}
				
				pos = j;
			}
		}
	}
	
	puts("Possible");
	
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int N; cin>>N;
  vector<int> A(N);
  set<int> cand_set;
  REP(i,N) cin>>A[i];
  sort(A.begin(), A.end());
  REP(k,2) {
    //    cout << A[k] << endl;                                                          
    for(int i = 1; i * i <= A[k]; i++) {
      //      cout << i << "...." << endl;                                               
      if(A[k] % i == 0) {
        //      cout << i << " is ok" << endl;                                           
        cand_set.insert(i);
        cand_set.insert(A[k] / i);
      }
    }
  }
  vector<int> cand(cand_set.begin(), cand_set.end());
  //  REP(i, cand.size()) cout << cand[i] << " "; cout << endl;                          
  for(int i = cand.size()-1; i >= 0; i--) {
    int	cnt = 0;
    REP(k,A.size()) {
      if(A[k] % cand[i]   == 0) cnt++;
    }
    if(cnt >= N-1) {
      cout << cand[i] << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 640
#include<algorithm> 
#include<string>
#include<iostream>
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());
    
    if(t.compare(s) > 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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

int main() {
	int n, y;
	cin >> n >> y;
	y /= 1000;
	for (int i = 0; i <= y / 10; i++) {
		for (int j = 0; j <= y / 5; j++) {
			if (10 * i + 5 * j + (n - i - j) == y && n - i - j >= 0) {
				cout << i << " " << j << " " << n - i - j << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;

void solve(){

    ll n;
    cin >> n;
    if(n%2==1){
        cout << 0 << endl;
        return;
    }
    ll num =1;
    n /= 2;
    ll ans = 0;
    while(num<n){
        num *= 5;
        ans += (n/num);
    }
    cout << ans << endl;

}

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


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

struct UfTree{
    vi parent;
    vi num;

    UfTree(int n){
        rep(i,n){
            parent.push_back(i);
            num.push_back(1);
        }
    }

    int find(int a){
        if(parent[a]==a){
            return a;
        }else{
            parent[a]=find(parent[a]);
            return parent[a];
        }
    }

    int get_num(int a){
        if(parent[a]==a){
            return num[a];
        }else{
            parent[a]=find(parent[a]);
            return num[parent[a]];
        }
    }

    void unite(int a, int b){
        a = find(a);
        b = find(b);
        if(a==b)return;

        parent[b]=a;
        num[a]+=num[b];
    }

    bool same(int a, int b){
        return find(a)==find(b);
    }

};


int main(){

    int n,m;
    cin>>n>>m;
    vi a(m),b(m);
    rep(i,m)cin>>a[i]>>b[i];

    UfTree uft(n);

    rep(i,m){
        uft.unite(a[i]-1,b[i]-1);
    }

    int ans=0;
    rep(i,n){
        cmax(ans,uft.get_num(i));
    }

    cout<<ans<<"\n";

    return 0;

}

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

using namespace std;

int main()
{
    long long q,n,h,s,d,mn=1e9,ck[10];
    cin>>q>>h>>s>>d>>n;
    ck[3]=q*4;
    ck[4]=h*2;
    ck[1]=s;
    ck[2]=d;
    mn = min(ck[4],min(ck[3],ck[1]));
    if(n==1)cout<<mn<<endl;
    else{
        if(n%2)
            cout<<min(n*mn,(mn+((n-1)/2*ck[2])))<<endl;
        else
            cout<<min(n*mn,(n/2)*ck[2])<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(50 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, ans = 0;
    double a[105], sum=0, mi=1000;
    cin >> n;
    REP(i,n){
        cin >> a[i];
        sum += a[i];
    }
    sum /= double(n);
    REP(i,n){
        if(abs(sum-a[i])<mi){
            ans = i;
            mi = abs(sum-a[i]);
        }
    }
    cout << ans << endl;
    return 0;
}

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

const int MAX = 300;
int A[MAX];

int main() {
  int h;
  cin >> h;
  for (int i = 1; i <= h; i++) {
    cin >> A[i];
  }

  for (int i = 1; i <= h; i++) {
    cout << "node " << i << ": key = " << A[i] << ", "; 
    if (i != 1) {
      cout << "parent key = " << A[i / 2] << ", ";
    }
    int left_id = 2 * i;
    if (left_id <= h) {
      cout << "left key = " << A[left_id] << ", ";
    }
    int right_id = 2 * i + 1;
    if (right_id <= h) {
      cout << "right key = " << A[right_id] << ", ";
    }
    cout << endl;
  }
}



Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 999999999999;
using ll = long long;
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;
}






int main(){
  ll N,K;
  cin>>N>>K;
  ll a[N];
  ll dp[N];
  for(ll i = 0;i<N;i++){
    cin>>a[i];
  }
  for(ll i = 0;i<N;i++){
    dp[i] = INF;
  }
  dp[0] = 0;
  for(ll i = 1;i<N;i++){
    if(i < K){
      for(ll p = 1;p<=i;p++){
        dp[i] = min(dp[i],(dp[i-p]+abs(a[i]-a[i-p])));
      }
    }
    else{
      for(ll p = 1;p<=K;p++){
        dp[i] = min(dp[i],dp[i-p]+abs(a[i]-a[i-p]));
      }
    }
  }
  cout << dp[N-1] << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    long long sum=0;
    cin >> n;
    for(long long i=1;i<=n;i++){
        if(i%3!=0 && i%5!=0) sum+=i;
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 3636
class Dice:
    def __init__(self, list):
        self.list = list  #listのinput
    def roll_n(self):
        self.list = [self.list[1], self.list[5], self.list[2], self.list[3], self.list[0], self.list[4]]
    def roll_s(self):
        self.list = [self.list[4], self.list[0], self.list[2], self.list[3], self.list[5], self.list[1]]
    def roll_e(self):
        self.list = [self.list[3], self.list[1], self.list[0], self.list[5], self.list[4], self.list[2]]
    def roll_w(self):
        self.list = [self.list[2], self.list[1], self.list[5], self.list[0], self.list[4], self.list[3]]
    def print0(self):
        print(self.list[0])


list = list(map(int, input().split()))
direct = input()
instance = Dice(list)
for i in direct:
    if i == 'N':
        instance.roll_n()
    if i == 'S':
        instance.roll_s()
    if i == 'E':
        instance.roll_e()
    if i == 'W':
        instance.roll_w()
instance.print0()


Measured memory_bytes: 5608
from collections import defaultdict

n = int(input())
W = [input() for _ in range(n)]

dd = defaultdict(int)
before = ''
for c in W:
    if dd[c] == 0 and (before == '' or before[-1] == c[0]):
        dd[c] += 1
        before = c
    else:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define sc(x)            scanf("%d",&x)
#define scc(x)           scanf("%c",&x)
#define scl(x)           scanf("%lld",&x)
#define sz(v)	     	(v.size())
#define mem(v, d)		memset(v, d, sizeof(v))
#define oo				2000000100
#define OO				2000000000000000100
#define PI 3.14159265
#define S second
#define F first
#define Ceil(x,y) ((x+y-1)/y)
#define EPS 1e-8
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double pi=3.14159265358979323846264338327950288419716939937510582097494459;
typedef unsigned int uint;
typedef long long ll;
int dX[] = {0,0,1,-1,0};
int dY[] = {1,-1,0,0,0};
string alpha = "abcdefghijklmnopqrstuvwxyz";
const int MOD = 1000000007;
const int N = 100100;
int sum[N],n,k,q;
int main()
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
#else
    //freopen("journey.in","r",stdin);
    //freopen("journey.out","w",stdout);
#endif
    sc(n); sc(k); sc(q);
    while(q--){
        int x; sc(x);
        sum[x+1]++;
        sum[1]++,sum[x]--;
    }
    for(int i = 1;i<=n;++i){
        sum[i]+=sum[i-1];
        if(sum[i]>=k) puts("No");
        else puts("Yes");
    }







    return 0;
}


Measured memory_bytes: 1024
A,B,K= (int(i) for i in input().split())

def gcd(a,b):
  if b>a:
    a,b=b,a

  if a%b==0:
    return b
  else:
    return(gcd(b,a%b))

first=gcd(A,B)
if first==1:
  print(1)
else:
  k=1
  if K==1:
    print(first)
  else:
    for i in reversed(range(1,first)):
      if A%i==0:
        if B%i==0:
          k=k+1
          if k==K:
            print(i)
            break

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

using namespace std;

int main()
{
	char s[301];
	scanf("%[^\n]", s);
	int len = strlen(s);
	int in;
	for(int i = 0; i < len; i++) {
		if(s[i] == ' ') {
			in = i;
			break;
		} 	
	}
	cout << "A" << s[in + 1] << "C";
	cout << endl;

	return 0;
}

Measured memory_bytes: 256