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

typedef struct node {
  int key;
  struct node *next, *prev;
} Node;

Node *nil;

void make_node(void);
void insert(int);
void deleteFirst(void);
void deleteLast(void);
Node * Search(int);
void deleteNode(Node *);
void deleteKey(int);
void Print(void);

int main()
{
  int i, n, key;
  char command[15];
  
  scanf("%d", &n);

  make_node();

  for( i = 0 ; i < n ; i++ ){
    scanf("%s", command);
    if( command[0] == 'i' ){
      scanf("%d", &key);
      insert(key);    
    } 
    else if( command[0] == 'd' ){
      if( strlen(command) > 6 ){
	if( command[6] == 'F' ) deleteFirst();
	else if( command[6] == 'L' ) deleteLast();
      }
      else {
	scanf("%d", &key);
	deleteKey(key);
      }
    }
  }

  Print();		      

  return 0;
}

void make_node()
{
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}
  
void insert(int key)
{
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

void deleteFirst()
{
  deleteNode(nil->next);
}

void deleteLast()
{
  deleteNode(nil->prev);
}

void deleteKey(int key)
{
  deleteNode(Search(key));
}

void deleteNode(Node *z)
{
  if( z == nil ) return;
  z->prev->next = z->next;
  z->next->prev = z->prev;
  free(z);
}

Node *Search(int key)
{
  Node *v = nil->next;
  while( v != nil && v->key != key ) v = v->next;
  return v;
}

void Print(){
  Node *v = nil->next;
  int cnt=0;
  
  while( 1 ){
    if( v == nil ) break;
    if( cnt++ > 0 ) printf(" ");
    printf("%d", v->key);
    v = v->next;
  }
  printf("\n");
}

Measured memory_bytes: 31788
N, x = map(int, input().split())
A = [int(i) for i in input().split()]
A.insert(0, 0)
ans = 0

for i in range(N):
    if A[i] + A[i+1] > x:
        ans += abs(A[i+1]-(x-A[i]))
        A[i+1] = x - A[i]
print(ans)

Measured memory_bytes: 14052
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+7;

int n, k;
int profit[3];
int com[MAXN];
int dp[MAXN][3];

int myProfit(int x, int y) {
    if ((x+1)%3 == y) return profit[x];
    return 0;
}

int main() {
    cin >> n >> k;
    cin >> profit[0] >> profit[1] >> profit[2];

    string t;
    cin >> t;
    for (int i = 0; i < n; i++) {
        if (t[i] == 'r') com[i+1] = 0;
        if (t[i] == 's') com[i+1] = 1;
        if (t[i] == 'p') com[i+1] = 2;
    }

    for (int i = n; i > 0; i--) {
        for (int h = 0; h < 3; h++) {
            dp[i][h] = myProfit(h, com[i]);
            if (i + k <= n) {
                int nxt = 0;
                for (int g = 0; g < 3; g++) {
                    if (h == g) continue;
                    nxt = max(nxt, dp[i+k][g]);
                }
                dp[i][h] += nxt;
            }
        }
    }

    int ans = 0;
    for (int i = 1; i <= k; i++) {
        int mx = 0;
        for (int h = 0; h < 3; h++) {
            mx = max(mx, dp[i][h]);
        }
        ans += mx;
    }

    cout << ans << "\n";


    return 0;
}


Measured memory_bytes: 2048
#include<stdio.h>
#include<string.h>
#define MAX 1000

void search(char* find, char* txt){
    int M = strlen(find);
    int N = strlen(txt);
    int i,j;
    for(i=0; i<=N-M; i++){
        for(j=0; j<M; j++)
            if(txt[i+j] != find[j]) break;
            if(j==M)
                printf("%d\n",i);
        
    }
}

int main(){
    char txt[MAX], find[MAX];
    scanf("%s %s",txt,find);
    search(find, txt);
    return 0;
}


Measured memory_bytes: 2112
n, m = map(int, input().split())
py = {}
for i in range(m):
    p, y = map(int, input().split())
    py.setdefault(p, [])
    py[p].append([i + 1, y])
for i in py:
    py[i].sort(key = lambda x: x[1])
    for j in range(len(py[i])):
        py[i][j][1] = j + 1
city = []
for i in py:
    for j in py[i]:
        city.append([j[0], i, j[1]])
city.sort()
for i in city:
    print(str(i[1]).rjust(6, "0") + str(i[2]).rjust(6, "0"))

Measured memory_bytes: 51120
odd = ["R","U","D"]
even = ["L","U","D"]

def tap(S):
    for i,s in enumerate(S):
        if ((i + 1)%2 != 0):
            if s in odd:
                continue
            else:
                print("No")
                return
        else:
            if s in even:
                continue
            else:
                print("No")
                return
    print("Yes")


S = list(input())
tap(S)


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

using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	
	int s, t, e;
	vector<pair<pair<int, int>, int>> vec;
	while(cin >> s >> t >> e, s != 0){
		vec.push_back({{s-1, t-1}, e});
	}
	
	int l;
	cin >> l;
	
	for(int p = 0;p < l;p++){
		int b[10010];
		int c[10010] = {};
		for(int i = 0;i < m;i++) cin >> b[i];
		
		for(int i = 0;i < vec.size();i++){
			int s = vec[i].first.first;
			int t = vec[i].first.second;
			int e = vec[i].second;
			c[s] += b[t] * e;
		}
		
		for(int i = 0;i < n-1;i++){
			cout << c[i] << " ";
		}
		
		cout << c[n-1] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3756
#include<iostream>
#include<cstdio>
#include<cctype>
#include<queue> 
using namespace std;
#define mp make_pair
#define pii pair<int,int>
const int maxn=1e5+10;
int k;
int vis[maxn];
deque<pii> q;
inline int read()
{
	int x=0;bool f=0;char c=getchar();
	while(!isdigit(c)) {f|=c=='-';c=getchar();}
	while(isdigit(c)) {x=(x<<3)+(x<<1)+(c^48);c=getchar();}
	return f?-x:x;
}
int main()
{
	k=read();
	q.push_front(mp(1,1));
	while(!q.empty())
	{
		pii tmp=q.front();
		q.pop_front();
		int mod=tmp.first,ans=tmp.second;
		if(vis[mod]) continue;
		vis[mod]=1;
		if(!mod) {cout<<ans;return 0;}
		q.push_front(make_pair(((mod<<3)+(mod<<1))%k,ans));//乘10代价为0 
        q.push_back(make_pair((mod+1)%k,ans+1));//加1代价为1 
    }
}

Measured memory_bytes: 1408
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [H, W] = [int(input_raw[0]), int(input_raw[1])]
    dic = {}
    for i in range(H):
        input_raw = read_func().strip()
        for j in range(W):
            if input_raw[j] not in dic:
                dic[input_raw[j]] = 1
            else:
                dic[input_raw[j]] += 1

    max_count = 0
    odd_count = 0
    even_count = 0

    if H % 2 == 0 and W % 2 == 0:
        for s in dic:
            if dic[s] % 4 != 0:
                print "No"
                return
        print "Yes"
    else:
        four_count = (H / 2) * (W / 2)
        count = 0
        odd_count = 0
        for s in dic:
            count += dic[s]/4
            dic[s] %= 4
            if dic[s] %2 == 1:
                odd_count += 1
        if count < four_count:
            print "No"
            return
        if H % 2 == 1 and W % 2 == 1:
            if odd_count == 1:
                print "Yes"
            else:
                print "No"
            return
        else:
            if odd_count == 0:
                print "Yes"
            else:
                print "No"



if __name__ == '__main__':
    main()


Measured memory_bytes: 30956
#include <iostream>
#include <algorithm>
#include <numeric>
#include <map>
#include <cstdint>
using namespace std;
using i64 = int64_t;
int main() {
	int n, k;
	cin >> n >> k;
	map<i64, i64> h;
	for (int i = 0; i < n; ++i) {
		i64 hi;
		cin >> hi;
		auto it = h.end();
		tie(it, ignore) = h.insert({hi, 0});
		it->second += 1;
	}
	int c = n - k;
	i64 i = 0, r = 0;
	for (const auto& e : h) {
		if (!(i < c)) { break; }
		if (c - i < e.second) {
			r += e.first * (c - i);
			i += (c - i);
		} else {
			r += (e.first * e.second);
			i += e.second;
		}
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
int a[105],b[105];
int main(){
	int n,m,x,y;
	scanf("%d%d%d%d",&n,&m,&x,&y);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<m;i++){
		scanf("%d",&b[i]);
	}
	sort(a,a+n);
	sort(b,b+m);
	if(a[n-1]>=b[0]||a[n-1]>=y||b[0]<=x){
		printf("War\n");
	}else{
		printf("No War\n");
	}
}

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

struct node{
	string name;
	int time;
};

int main(int argc, char *argv[]) {
	int n,q;
	int runtime = 0;
	cin>>n>>q;
	queue<node> in_queue;
	queue<node> out_queue;

	for(int i = 0; i<n; i++)
	{
		node input;
		cin>>input.name>>input.time;
		in_queue.push(input);
	}
	
	while(!in_queue.empty())
	{
			if(in_queue.front().time<=q)
			{
				runtime += in_queue.front().time;
				in_queue.front().time = runtime;
				out_queue.push(in_queue.front());
				in_queue.pop();	
				
			}
			else
			{
				runtime += q;
				in_queue.front().time -= q;
				in_queue.push(in_queue.front());
				in_queue.pop();
			}			
	}
	
	while(!out_queue.empty())
	{
		cout<<out_queue.front().name<<" "<<out_queue.front().time <<endl;
		out_queue.pop();
	}

	
	return 0;
}

Measured memory_bytes: 4436
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	fastio;
	LL N;
	cin>>N;
	LL tmp=N;
	int ans1,ans2;
	ans1=ans2=0;
	while(tmp){
		ans1+=tmp%10;
		tmp/=10;
	}
	while(N){
		if(N>=10)
		ans2+=9;
		else
		ans2+=N-1;
		N/=10;
	}
//	ans2--;
	cout<<max(ans1,ans2)<<endl; 
	return 0;
}


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, ans =0;
	cin >>n;
	rep(i, n){
		int a; cin >>a;
		ans = __gcd(ans, a);
	}
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

int main()
{
    long long int N, C, K;
    if (scanf("%lld%lld%lld", &N, &C, &K) < 3) return 0;

    long long int lateT = 0;
    long long int busCnt = 0;
    long long int busPsn = 0;

    vector<long long int> vi;

    for (int i = 0; i < N; i++)
    {
        long long int T;

        if (scanf("%lld", &T) < 1) return 0;

        vi.push_back(T);
    }

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

    for (int i = 0; i < N; i++)
    {
        if (0 < busPsn && K < vi[i] - lateT)
        {
            busCnt++;
            busPsn = 0;
            lateT = vi[i];
        }
        else if (busPsn == 0)
        {
            lateT = vi[i];
        }

        busPsn++;

        if (C == busPsn)
        {
            busCnt++;
            busPsn = 0;
        }
        else if (i == N - 1)
        {
            busCnt++;
        }
    }

    printf("%lld\n", busCnt);
    return 0;
}


Measured memory_bytes: 1400
#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> istream & operator>>(istream & is, vector<T> &);
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _it(istream &, tuple<T...> &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _it(istream & is, tuple<T...> & t){ is >> get<n>(t); _it<n+1>(is, t); }
template<class...T> istream & operator>>(istream & is, tuple<T...> & t){ _it<0>(is, t); return is; }
template<class T, class U> istream & operator<<(istream & is, pair<T,U> & p){ return is >> p.first >> p.second; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> istream & operator>>(istream & is, vector<T> & v){ rep(i,v.size()) is >> v[i]; return is; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif

int a[100010];

int main(){
    int n,t;
    while(cin >> n >> t){
        rep(i,n) cin >> a[i];
        sort(a,a+n);
        ll ans = 1;
        rep(i,n){
            int k = lower_bound(a,a+i,a[i]+1) - lower_bound(a,a+i,a[i]-t) + 1;
            ans = ans*k % 1000000007;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1560
import java.util.Scanner;

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

		for (int i = 2; i * i < 1000001; i++) {
			for (int j = i * 2; j < 1000001; j += i) {
				prime[j] = 1;
			}
		}

		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}
			count = 0;
			for (int i = 2; i <= n / 2; i++) {
				if (prime[i] == 0 && prime[n - i] == 0) {
					count++;
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 16000
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define PI 3.14159265359
ll gcd(ll a, ll b) {//最大公約数
    if(a<b){
        ll tmp = a;
        a = b;
        b = tmp; 
    }
    if (b==0) return a;
    else return gcd(b, a%b);
}
ll lcm(ll a, ll b) {//最小公倍数
    return a * b / gcd(a, b);
}

int main() {
    int r; cin >> r;
    double ans = r*PI*2;
    cout  << ans << endl;

}




Measured memory_bytes: 3780
#include <cstdio>
#include <vector>

using namespace std;
bool chk[201];
vector<int> p;
void getprime(int n)
{
    int i, j;
    for (i=2;i<=n;i++) {
        if (!chk[i]) {
            p.push_back(i);
            for (j=i*i;j<=n;j+=i) {
                chk[j]=1;
            }
        }
    }
}
int main()
{
    int n, i, j, sum=1, cnt=0, ans=0, tmp;
    scanf("%d",&n);
    getprime(n);
    for (i=3;i<=n;i+=2) {
        tmp=i;
        for (j=1;j<100;j++) {
            if (tmp==1) break;
            if (i%p[j]==0) {
                while (tmp%p[j]==0) {
                    //printf("%d %d\n",p[j],tmp);
                    tmp/=p[j];
                    cnt++;
                }
            }
            sum*=(cnt+1);
            cnt=0;
        }
        if (sum==8) ans++;
        sum=1;
    }
    printf("%d",ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    long long int n;
    cin>>n;
    vector<pair<long long int, long long int>> hoge(n);
    for(long long int i=0; i<n; i++){
        cin>>hoge.at(i).first>>hoge.at(i).second;
    }
    
    long long int ans=0;
    long long int sum=0;
    for(long long int i=n-1; i>=0; i--){
        long long int &a=hoge.at(i).first;
        long long int &b=hoge.at(i).second;
        a+=sum;
        if(a<=b&&a!=0){
            long long int huga=b-a;
            ans+=huga;
            sum+=huga;
        }else if(a%b!=0){
            long long int amari=a%b;
            ans+=b-amari;
            sum+=b-amari;
        }
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#define LL long long

using namespace std;

LL read()
{
	LL ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}

LL a,b,k;

int main()
{
	a=read(),b=read(),k=read();
	a<=k?(k-=a,a=0):(a-=k,k=0);
	b<=k?b=0:b-=k;
	printf("%lld %lld\n",a,b);
	return 0;
}

Measured memory_bytes: 256
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,m = map(int,ipt().split())
    x = list(map(int,ipt().split()))
    y = list(map(int,ipt().split()))
    mod = 10**9+7

    #nCrをmodで割った余りを求める。Nに最大値を入れて使用。
    N = 10**5
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル
    def cmb(n,r,mod):
        if r<0 or r>n :
            return 0
        r = min(r,n-r)
        return g1[n]*g2[r]*g2[n-r]%mod
    for i in range(2,N+1):
        g1.append((g1[-1]*i)%mod)
        inverse.append((-inverse[mod % i]*(mod//i))%mod)
        g2.append((g2[-1]*inverse[-1])%mod)

    sx = 0
    px = x[0]
    for i,xi in enumerate(x[1:n:]):
        sx = (sx+((xi-px)%mod*(i+1)%mod*(n-i-1))%mod)%mod
        px = xi
    sy = 0
    py = y[0]
    for i,yi in enumerate(y[1:m:]):
        sy = (sy+((yi-py)%mod*(i+1)%mod*(m-i-1))%mod)%mod
        py = yi
    print(sx*sy%mod)


    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 110248
import math

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

S = 1 / 2 * a * b * math.sin(math.radians(C))

c = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(math.radians(C)))
L = a + b + c

h = b * math.sin(math.radians(C))

print(format(S, '.8f'))
print(format(L, '.8f'))
print(format(h, '.8f'))


Measured memory_bytes: 5708
#include<stdio.h>
#include<string.h>
int main(){
    int n;
    char s[10001];
    scanf("%d",&n);
    scanf("%s",s);
    int len = strlen(s);
    int i;
    for(i=0;i<len;i++){
        if(s[i]+n >'Z'){
            //s[i] = 'o';
            int t = 'Z'-s[i];
            s[i] = 'A'+(n-t)-1;
        }
        else{
        s[i] = s[i] + n;
        }
    }
    printf("%s",s);
    return 0;
}

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

using namespace std;

int main(){
    double r,are,circ;
    double pi = 3.141592653589;
    scanf("%lf", &r);
    are = r*r*pi;
    circ = 2*r*pi;
    printf("%f %f\n", are, circ);
    return 0;
}



Measured memory_bytes: 3216
INF = float('inf')
#vは頂点数、eは辺数
#s番目の頂点から各頂点への最短距離を求める
def Bellmanford(n, e, s):
  d = [INF]*n
  d[s] = 0
  for i in range(n):
    for e_from, e_to, e_cost in e:
      if d[e_from] != INF and d[e_to] > d[e_from] + e_cost:
        d[e_to] = d[e_from] + e_cost
        if i == n-1 and e_to == n-1:
          return 'inf'
  return -d[n-1]

n,m = (int(x) for x in input().split())
edges = [None] * m

for i in range(m):
    ai, bi, ci = map(int, input().split())
    edges[i] = (ai-1, bi-1, -ci)
    
ans = Bellmanford(n, edges, 0)
print(ans)

    
  


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

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.14159265358979323846264338327950288419

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

using namespace std;

int n, d, x;

double f(int N){
	double ret = 0.0;
	FI(i, 1, N) ret += 1.0 * (N + 1 - i) / i;
	return ret;
}

int main(){
	scanf("%d %d %d", &n, &d, &x);
	printf("%.15lf\n", f(n) * (d + (n - 0.5) * x));
	return 0;
}


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

int main(){
  int N,M;
  cin >> N >> M;
  
  vector<int> city(N);
  vector<vector<int>> road(M, vector<int>(2));
  
  int i,j,k;
  
  for(i = 0; i < M ; i++){
    for(j = 0 ; j < 2 ; j++){
      cin >> road.at(i).at(j);
     for(k = 0 ; k < N ; k++)	if(road.at(i).at(j) - 1 == k)	city.at(k)++;
    }
  }
  
  for(k = 0 ; k < N ; k++)	cout << city.at(k) << endl;
  
  
}

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

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007

using namespace std;

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

	while( a >= b && k > 0 ){
		b *= 2;
		k--;
	}

	while( b >= c && k > 0 ){
		c *= 2;
		k--;
	}

	if( a < b && b < c )	cout << "Yes" << endl;
	else	cout << "No" << endl;

	return 0;
}


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

string s;
int cnt1,cnt2;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>s;
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s[i]=='0'){
                cnt1++;
            }else{
                cnt2++;
            }
        }else{
            if(s[i]=='0'){
                cnt2++;
            }else{
                cnt1++;
            }
        }
    }
    cout<<min(cnt1,cnt2)<<endl;

    return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  rep(i,s.size()-1){
    if(s[i] == s[i+1]){
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;


typedef long long       ll;
typedef struct edge_ { ll to; ll cost; } edge;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef vector<edge>    ve;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<ve>      vve;
typedef vector<vc>		vvc;

#define repr(itr, bgn, end) for (ll itr = (ll)bgn; itr < (ll)end; ++itr)
#define rep(itr, end) repr(itr, 0, end)
#define reprrev(itr, bgn, end) for (ll itr = (ll)end - 1; itr >= (ll)bgn; --i)
#define reprev(itr, end) reprrev(itr, 0, end)
#define all(container) container.begin(), container.end()
#define sortall(container) sort(all(container))
#define yn(cond) cond ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(cond) cond ? (cout << "YES" << endl) : (cout << "NO" << endl)

// 定数
#define LLONG_MAX numeric_limits<ll>::max()
#define INT_MAX numeric_limits<int>::max()
constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 15;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;

// よく使うもの
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (T& x : vec) os << x << " ";
	return os;
}



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

	int ans = 0;
	
	while (true) {
		bool m = false;
		int start = -1;
		for (int i = 0; i < N; i++) {
			if (!m && h[i] > 0) {
				m = true;
				start = i;
			}

			if (m && (h[i] == 0 || i == N - 1)) {
				for (int j = start; j < i; j++) {
					h[j]--;
				}
				if (i == N - 1 && h[i] > 0) h[i]--;
				m = false;
				ans++;
			}
		}

		if (start < 0) {
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

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

bool kouji[20][20]; // x, y
int dp[20][20];

int main() {
    int a, b, n, x, y;
    while (cin >> a >> b, (a || b)) {
        memset(kouji, 0, sizeof kouji);
        memset(dp, 0, sizeof dp);
        cin >> n;
        for (int i=0; i<n; ++i) {
            cin >> x >> y;
            kouji[x][y] = true;
        }
        dp[1][1] = 1;
        for (int i=1; i<=a; ++i) {
            for (int j=1; j<=b; ++j) {
                if (i == 1 && j == 1) continue;
                if (kouji[i][j]) continue;
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
            }
        }
        cout << dp[a][b] << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 100000000000000000
int main(void) {
  int n,m;
  cin>>n>>m;
  const int nmax = 1000;
  const int mmax = 2000;
  int a[mmax], b[mmax];
  ll c[mmax];
  for(int i=0;i<m; i++){
    cin>>a[i]>>b[i]>>c[i];
    c[i]*=-1;
  }
  ll dist[nmax];
  for(int i=0;i<n;i++){
    dist[i]=INF;
  }
  dist[0] = 0;
  for(int loop=0;loop<n-1;loop++){
    for(int i=0;i<m;i++){
      if(dist[a[i]-1]==INF)continue;
      if(dist[b[i]-1]>dist[a[i]-1]+c[i]){
        dist[b[i]-1]=dist[a[i]-1]+c[i];
      }
    }
  }
  ll ans=dist[n- 1];
  bool negative[nmax];
  for(int i=0;i<n;i++){
    negative[i]=false;
  }
  for(int loop=0;loop<n;loop++){
    for(int i=0;i<m;i++){
      if(dist[a[i]-1]==INF)continue;
      if(dist[b[i]-1]>dist[a[i]-1]+c[i]){
        dist[b[i]-1]=dist[a[i]-1]+c[i];
        negative[b[i]-1]=true;
      }
      if(negative[a[i]-1]==true){
        negative[b[i]-1]=true;
      }
    }
  }
  if(negative[n-1])
    cout<<"inf"<<endl;
  else
    cout<<-ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n,k;
int a[300000];
int main() {
    scanf("%d%d",&k,&n);
    if (k%2==0) {
        printf("%d",k/2);
        for (int i=1;i<n;++i) printf(" %d",k);
        printf("\n");
    } else {
        fill(a,a+n,(k+1)/2);
        int t=n-1;
        for (int i=0;i<n/2;++i) {
            if (a[t]!=0) a[t]--;
            else {
                a[t-1]--;
                a[t]=k;
                if (a[t-1]!=0) t=n-1;
                else t--;//下一步还会再处理的
            }
        }
        for (int i=0;i<n;++i) {
            printf("%d",a[i]);
            if (a[i+1]!=0) printf(" ");
            else break;
        }
        printf("\n");
    }
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  int y = 0;
  
  for (int i = 0; i < n; i++){
   	string s;
    cin >> s;
    if (s == "Y"){
      y = 1;
      break;
    }
  }
  
  if (y == 0){
    cout << "Three" << endl;
  }
  if (y == 1){
    cout << "Four" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,m;
long long sum,ans;
map<long long,long long>p;
int main(){
	cin>>n>>m;
	p[0]=1;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		sum+=x;
		sum%=m;
		ans+=p[sum]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4224
import java.util.*;
 
class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    String ans = "";
    for(int i=0; i<3; i++){
      ans += s.charAt(i);
    }
    System.out.println(ans);

    sc.close();
  }
}

Measured memory_bytes: 39176
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890
#define debug(x) if(MODE==x)
#define MODE 0
using namespace std;

int A[107],B[107],C[107];

int main()
{
    int i,j;
    int n;

    scanf("%d",&n);

    for( i=1; i<=n; i++)
    {
        scanf("%d",&A[i]);
    }
    for( i=1; i<=n; i++)
    {
        scanf("%d",&B[i]);
    }
    for( i=1; i<=n-1; i++)
    {
        scanf("%d",&C[i]);
    }

    int total = 0;
    for( i=1; i<=n; i++)
    {
        total += B[ A[i] ];
        if(i>1 && A[i]==A[i-1]+1)
            total += C[ A[i-1] ];
    }
    printf("%d\n",total);

    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 REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
int main(){
  string s;
  cin >> s;
  cout << s.substr(0,3) << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
#define MAX 100
#define INFTY 200000

int n,M[MAX][MAX];

int prim(){
    int u,minv;
    int d[MAX],p[MAX],color[MAX];
    int i,j;
    int sum;
    
    for(i=0;i<n;i++){
        d[i] = INFTY;
        p[i] = -1;
        color[i] = 0;
    }
    
    d[0] = 0;
    
    while(1){
        minv = INFTY;
        u = -1;
        for(i=0;i<n;i++){
            if(minv > d[i] && color[i] != 2){
                u = i;
                minv = d[i];
            }
        }
        if(u == -1) break;
        color[u] = 2;
        for(j=0;j<n;j++){
            if(color[j] != 2 && M[u][j] != INFTY){
                if(d[j] > M[u][j]){
                    d[j] = M[u][j];
                    p[j] = u;
                    color[j] = 1; 
                }
            }
        }
    }
    sum = 0;
    for(i=0;i<n;i++){
        if(p[i] != -1) sum += M[i][p[i]];
    }
    return sum;
}

int main(void){
    int i,j;
    int e;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            scanf("%d",&e);
            M[i][j] = (e==-1) ? INFTY : e;
        }
    }
    printf("%d\n",prim());
    return 0;
}



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

namespace ConsoleApplication2
{
    class Program
    {
        public static int GetResult(int[] data)
        {
            int result = 0;
            int n = data[0];
            int x = data[1];

            for (int i = 1; i <= n; i++)
            {
                for (int j = i+1; j <= n; j++)
                {
                    for (int k = j+1; k <= n; k++)
                    {
                        if ((i + j + k) == x)
                            result++;
                    }
                }
            }

            return result;
        }

        static void Main(string[] args)
        {
            string line = null;
            while ((line = Console.ReadLine()) != null)
            {
                int[] data = line
                    .Split(' ')
                    .Select(x => int.Parse(x))
                    .ToArray();
                bool isFinished = (data[0] == 0) && (data[1] == 0);
                if (isFinished)
                    break;
                Console.WriteLine(GetResult(data));
            }
        }
    }
}

Measured memory_bytes: 9588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    map<int, int> mp;
    cin >> n;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for(auto a : mp) {
        if(a.second>=a.first) ans += a.second - a.first;
        else ans += a.second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4736
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
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 1000000007
#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())
int main(){
 ll N,D;cin>>N>>D;
 ll X[15][15];
 ll i,j,k,l;
 rep(i,N){
   rep(j,D){
     cin>>X[i][j];
   }
 }
 ll ans=0;
 rep(i,N){
   for(j=i+1;j<N;j++){
     ll tmp=0;
     rep(k,D){
       tmp+=abs(X[i][k]-X[j][k])*abs(X[i][k]-X[j][k]);
       // if(i==0 and j==1) cout<<abs(X[i][k]-X[j][k])<<" "<<tmp<<endl;
     }
     double x=sqrt(tmp);
     if( ceil(x) == floor(x) ){
       ans++;
     }
   }
  }
  cout<<ans<<endl;
}


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


void solve(){
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    rep(i,N){
        cin >> H[i];
    }
    sort(ALL(H), greater<>());
    int ans = 0;
    for(int i=K; i<N; i++){
        ans += H[i];
    }
    cout << ans << endl;
}

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


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

int t;
long long int gcd(long long int a, long long int b){
	if (a > b)swap(a, b);
	while (a){
		swap(a, b);
		a %= b;
	}
	return b;
}
int main(){
	cin >> t;
	while (t--){
		long long int A, B, C, D;
		scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
		if (A < B){
			puts("No");
			continue;
		}
		if (D < B){
			puts("No");
			continue;
		}
		if (B <= C){
			puts("Yes");
			continue;
		}
		// D>=B
		// B>=C
		long long int star = A%B;
		long long int offset = D - B;
		//star,star+offset,star+2*offset
		//(star+x*offset)%B > C
		//A+x*(D-B)>C
		//A+D*x>C
		long long int z = gcd(offset, B);
		if (star > C){
			puts("No");
			continue;
		}
		//B > star+x*z > C
		long long int goal = B - 1;
		goal -= star;
		goal /= z;
		goal *= z;
		goal += star;
		if (goal > C){
			puts("No");
		}
		else{
			puts("Yes");
		}
	}
	return 0;
}

Measured memory_bytes: 256
(n, a, b, c, d) = parse.([Int], split(readline()))

f(m) = a + m * c - (n - 1 - m) * d <= b && b <= a + m * d - (n - 1 - m) * c
println(any(map(f, [m for m in 0:n-1]))? "YES" : "NO")

Measured memory_bytes: 155596
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	try {
    		final String S = sc.next();
    		String previousString = "";
    		StringBuilder currentString = new StringBuilder();
    		int count = 0;

    		for (int i=0; i<S.length(); i++) {
    			currentString.append(S.charAt(i));
    			if (!previousString.equals(currentString.toString())) {
    				count++;
    				previousString = currentString.toString();
    				currentString = new StringBuilder();
    			}
    		}
    		System.out.println(count);

    	} finally {
    		sc.close();
    	}
    }
}



Measured memory_bytes: 45288
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,N) for(int i=0; i<N; i++) ;
int main() {
int N;
cin>>N;
ll answer=0;
for(int i=01; i<N+1; i++){
    if(i%3==0||i%5==0){
    }
    else{
    answer+=i;
    }
}
cout<<answer<<endl;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int n;cin >>n;
    vector<ll>a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    ll ans=0;
    int r=0;
    int sum=0;
    for (int l = 0; l < n; ++l) {
        while(r<n&&(sum+a[r]==(sum^a[r]))){
            sum+=a[r];
            r++;
        }
        ans+=r-l;
        if(r==l)r++;
        else sum-=a[l];
    }
    cout<<ans <<endl;
    return 0;
}


Measured memory_bytes: 4784
#include<iostream>
#include<cstdio>
#include<ctype.h>
using namespace std;
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(!isdigit(ch))f|=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return f?-x:x;
}
int main(){
	long long n=read(),A=1,B=1;
	for(int i=1;i<=n;i++){
		int t=read(),a=read();
		long long m=max(A/t+bool(A%t),B/a+bool(B%a));
		A=m*t,B=m*a;
	}
	printf("%lld\n",A+B);
	return 0;
}

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

int main() {
  
  string s;
  cin >> s;
  
  if ( s == "SUN" ){
    cout << 7 << endl;
  }else if ( s == "MON" ){
    cout << 6 << endl;
  }else if ( s == "TUE" ){
    cout << 5 << endl;
  }else if ( s == "WED" ){
    cout << 4 << endl;
  }else if ( s == "THU" ){
    cout << 3 << endl;
  }else if ( s == "FRI" ){
    cout << 2 << endl;
  }else{
    cout << 1 << endl;
  }
  
}



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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int A, B, K;

int main(void) {
    cin >> A >> B >> K;

    int c = 0;
    int i = 100 + 1;

    

    while (c != K) {
        i--;
        if (A % i == 0 && B % i == 0) {
            c++;
        }
    }

    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;++i){
    cin >> a.at(i);
  }
  int mn = 1000000;
  int mx = -mn;
  long long sum = 0;
  for(int i=0;i<n;++i){
    mn = min(mn,a.at(i));
    mx = max(mx,a.at(i));
    sum += a.at(i);
  }
  cout << mn << " " << mx << " " << sum << endl;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
long long int mod = (long long int)1000000007;
using namespace std;

void solve()
{
    ll i,j,k,n;
    std::cout.precision(10);
    int yes=0;
  double r;
  cin>>r;
  r=2*r*22;
  r/=7;
  cout<<r;
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int i,j,k;
    int t;
    std::cout.precision(10);
   t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 3732
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;




int main(){
	int n;
	ll ans = 0;
	string s;
	cin >> n >> s;
	vector<int> r;
	vector<int> g;
	vector<int> b;
	for (int i = 0; i < n; i++){
		if (s[i] == 'R') r.push_back(i+1);
		if (s[i] == 'G') g.push_back(i+1);
		if (s[i] == 'B') b.push_back(i+1);
	}
	for (int i = 0; i < r.size(); i++){
		for (int j = 0; j < g.size(); j++){
			ans += b.size();
			int big = max(r[i], g[j]);
			int small = min(r[i], g[j]);
			int sa = big - small;
			if (binary_search(b.begin(), b.end(), big + sa)){
				ans -= 1;
			}
			if (binary_search(b.begin(), b.end(), small - sa)){
				ans -= 1;
			}
			if (sa % 2 == 0){
				if (binary_search(b.begin(), b.end(), small + sa/2)){
					ans -= 1;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3680
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	int m = sc.nextInt();
      	int[] C = new int[n];
      	for(int i = 1; i <= m ; i++){
      		int a = sc.nextInt();
      		int b = sc.nextInt();
          	C[a-1]++;
          	C[b-1]++;
        }
      	for(int x : C){
          	System.out.println(x);
        }
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=705,INF=1<<30;

vector<int> G[MAX],color(MAX);
bool ok=true;

void DFS(int u,int p){
    
    for(int i=0;i<G[u].size();i++){
        int a=G[u][i];
        if(a==p) continue;
        if(color[a]){
            if(color[u]==color[a]){
                ok=false;
                return;
            }
        }else{
            if(color[u]%10==1) color[a]=color[u]+1;
            else color[a]=color[u]-1;
            DFS(a,u);
        }
    }
}

int main(){
    
    int N,M;cin>>N>>M;
    vector<vector<int>> A(N,vector<int>(N,1));
    for(int i=0;i<N;i++){
        A[i][i]=0;
    }
    for(int i=0;i<M;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        A[a][b]=0;
        A[b][a]=0;
    }
    
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(A[i][j]) G[i].push_back(j);
        }
    }
    
    for(int i=0;i<N;i++){
        if(color[i]==0&&G[i].size()){
            color[i]=i*10+1;
            DFS(i,-1);
        }
    }
    
    if(!ok){
        cout<<-1<<endl;
        return 0;
    }
    
    vector<int> cnt(8000,0);
    int dp[8000][701];
    
    for(int i=0;i<8000;i++){
        for(int j=0;j<701;j++){
            dp[i][j]=0;
        }
    }
    
    for(int i=0;i<N;i++){
        cnt[color[i]]++;
    }
    int sum=0;
    for(int i=0;i<=700;i++){
        if(cnt[i*10+1]>cnt[i*10+2]) swap(cnt[i*10+1],cnt[i*10+2]);
        sum+=cnt[i*10+1];
        cnt[i*10+2]-=cnt[i*10+1];
        cnt[i*10+1]=0;
    }
    
    for(int i=0;i<=cnt[0];i++){
        dp[0][sum+i]=1;
    }
    
    for(int i=0;i<7999;i++){
        for(int j=700;j>=0;j--){
            if(dp[i][j]){
                dp[i+1][j]=1;
                dp[i+1][j+cnt[i+1]]=1;
            }
        }
    }
    
    int ans=INF;
    
    for(int j=0;j<=700;j++){
        if(dp[7999][j]){
            ans=min(ans,j*(j-1)/2+(N-j)*(N-j-1)/2);
        }
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 24448
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int gcd(int a, int b) {
	if(a > b) swap(a, b);
	return (a == 0) ? b : gcd(b%a, a);
}

int main() {
	int N, M, Q, MOD;
	cin >> N >> M >> Q >> MOD;
	vector< vector<int> > Gr(N), W(N);
	vector<int> W_occ(MOD, 0);
	int W_1; // arbitrary weight
	for(int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		W_1 = c;
		Gr[--a].push_back(--b);
		Gr[b].push_back(a);
		W[a].push_back(c);
		W[b].push_back(c);
		W_occ[c]++;
	}
	vector<char> is_prime(MOD+1, 1), is_unique_mod(MOD+1, 0);
	vector<int> one_prime(MOD+1, 1);
	is_unique_mod[1] = 1;
	for(int i = 2; i <= MOD; i++) if(is_prime[i])
		for(int j = i; j <= MOD; j += i) one_prime[j] = i, is_prime[j] = 0;
	for(int i = 2; i <= MOD; i++) if(is_unique_mod[i/one_prime[i]]) {
		int um = W_1 % i, occ = 0;
		for(int k = um; k < MOD; k += i) occ += W_occ[k];
		if(occ == M) is_unique_mod[i] = 1;
	}
	int G = MOD;
	while(is_unique_mod[G] == 0) G--;

	MOD = gcd(3*G, MOD);
	G = gcd(G, MOD);
	for(int i = 0; i < N; i++) for(auto & w : W[i]) w = (w % MOD - w % G) / G;
	vector<char> has_dif[2] = {vector<char>(N, 0), vector<char>(N, 0)};
	has_dif[0][0] = 1;
	queue<int> qu;
	qu.push(0);
	while(!qu.empty()) {
		int k = qu.front() % 2, v = qu.front()/6;
		for(int i = 0; i < (int)Gr[v].size(); i++) {
			int x = (qu.front()/2 + (4-2*k) * W[v][i]) % 3;
			if(((has_dif[1-k][Gr[v][i]] >> x) & 1) == 0) {
				has_dif[1-k][Gr[v][i]] |= 1<<x;
				qu.push(Gr[v][i] * 6 + x * 2 + 1-k);
			}
		}
		qu.pop();
	}
	vector<char> R[2] = {vector<char>(MOD, 0), vector<char>(MOD, 0)};
	for(int i = 0, pw = 1; i < MOD; i++, pw = 2*pw%MOD) {
		if(i%2 == 0) R[0][1LL*W_1%G*(pw+MOD-1)%MOD] = 1;
		else R[1][1LL*W_1%G*(pw+MOD-1)%MOD] = 1;
	}

	for(int q = 0; q < Q; q++) {
		int s, t, r;
		cin >> s >> t >> r;
		s--, t--;
		bool found = false;
		for(int k = 0; k < 6; k++) if((has_dif[k%2][s]>>(k/2))&1)
			for(int l = 0; l < 6; l++) if((has_dif[l%2][t]>>(l/2))&1)
				if(R[(k+l)%2][(r + 9 * G - (k/2 - l/2) * (2*(k%2)-1) * G)%MOD]) found = true;
		cout << (found ? "YES\n" : "NO\n");
	}
}


Measured memory_bytes: 17664