akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    deque<int> dq;
    int N, K; cin >> N >> K;
    vector<int> v(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }
    for (int i = N-1; i >= 0; i--) {
        dq.push_front(v[i]);
    }

    int ans = 0;
    for (int left = 0; left <= N; left++) {
        for (int right = 0; right <= N; right++) {
            deque<int> dQ = dq;
            priority_queue<int, vector<int>, greater<int>> pq;
            for (int i = 0; i < left; i++) {
                if (dQ.empty()) break;
                pq.push(dQ.front());
                dQ.pop_front();
            }
            for (int i = 0; i < right; i++) {
                if (dQ.empty()) break;
                pq.push(dQ.back());
                dQ.pop_back();
            }
            if (left + right > K) continue;
            for (int i = 0; i < K - left - right; i++) {
                if (!pq.empty() && pq.top() < 0) {
                    pq.pop();
                }
            }
            int sum = 0;
            int len = pq.size();
            for (int i = 0; i < len; i++) {
                sum += pq.top();
                pq.pop();
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	ans := 0
	gp := []rune{'g', 'p'}
	for i, t := range s {
		a := gp[i%2]
		if a == 'p' && t == 'g' {
			ans++
		}
		if a == 'g' && t == 'p' {
			ans--
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1280
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

void debug(VS &board){
	int h = board.size();
	rep(i,h){
		cout<<board.at(i)<<endl;
	}
	return;
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int n;
	cin>>n;
	int cnt = 0;
	bool f = false;
	rep(i,n){
		int a,b;
		cin>>a>>b;
		if(a==b){
			cnt++;
			if(cnt>2){
				f=true;
			}
		}else{
			cnt=0;
		}
	}
	if(f)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3616
# -*- coding: utf-8 -*-
import math
n = int(input())

if n==1:
    print(1)
    exit()
primes = []
x = 2
while x*x<=n:
    if n%x==0:
        primes.append(x)
        primes.append(n//x)
    x += 1

# print(primes)

def digit(x):
    return math.ceil(math.log10(x)) + (1 if x%10==0 else 0)

res = digit(n)
for i in range(len(primes)):
    a = primes[i]
    b = n//a
    t = max(digit(a), digit(b))
    # print(a,b,t)
    res = min(res, t)

print(res)


Measured memory_bytes: 3064
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  int ans = min(B, N * A);
  cout << ans << endl;
  return 0;
}


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

int main()
{
  string s;
  cin >> s;
  bool ans = true;
  if (s.size() % 2 == 1)
  {
    cout << "No" << endl;
    return 0;
  }
  for (int i = 0; i < s.size(); i++)
  {
    if(i % 2 == 0) ans = s.at(i) == 'h';
    if(i % 2 == 1) ans = s.at(i) == 'i';
    if(!ans)
    {
      cout << "No" << endl;
      return 0;
    } 
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	t1,t2 = readline() |> split |> parseMap
	a1,a2 = readline() |> split |> parseMap
	b1,b2 = readline() |> split |> parseMap
	if a1*t1+a2*t2==b1*t1+b2*t2
		println("infinity")
	else
		if a1*t1+a2*t2>b1*t1+b2*t2
			if a1>b1
				println(0)
			else
				k = div((b1-a1)*t1,a1*t1+a2*t2-b1*t1-b2*t2)
				k *= 2
				if ((b1-a1)*t1)%(a1*t1+a2*t2-b1*t1-b2*t2)==0
					k -= 1
				end
				println(k+1)
			end
		else
			if b1>a1
				println(0)
			else
				k = div((a1-b1)*t1,-a1*t1-a2*t2+b1*t1+b2*t2)
				k *= 2
				if ((a1-b1)*t1)%(-a1*t1-a2*t2+b1*t1+b2*t2)==0
					k -= 1
				end
				println(k+1)
			end
		end
	end
end

main()

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

int main()
{
  int n;
  vector<int> v;
  vector<int>::iterator it;
  while (cin>>n, n!=(-1)) {
    v.clear();
    v.push_back(n%4);
    while (n/=4) v.push_back(n%4);
    for (it = v.end(); it != v.begin();)
      cout<<*(--it);
    cout<<endl;
  }
}

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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 4e3 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

char s[maxn];
int cnt[maxn][3];
int pos[26];
char st[] = {'R', 'G', 'B'};

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);
//  freopen(Task".out", "w", stdout);

  int n; cin >> n;
  cin >> s + 1;

  For (i, 0, 2){
    pos[st[i] -'A'] = i;
  }

  For(i, 1, n) For(j, 0, 2){
    cnt[i][j] = cnt[i-1][j];
    if (s[i] == st[j]) ++cnt[i][j];
  }
  ll ans = 0;
  For(i, 1, n - 2) For (j, i + 1, n - 1){
    if (s[i] == s[j]) continue;
    int k = 3 - pos[s[i]-'A'] - pos[s[j]-'A'];
    ans += cnt[n][k] - cnt[j][k];
    int dif = j - i;
    if (j + dif <= n && pos[s[j+dif]-'A'] == k) --ans;
  }
  cout << ans;

}



Measured memory_bytes: 3616
from fractions import gcd
lcm=lambda x,y:x//gcd(x,y)*y
N,M=map(int, input().split())
S=input()
T=input()
g=gcd(N,M)
if all(S[N//g*i]==T[M//g*i] for i in range(g)):
    print(lcm(N,M))
else:
    print(-1)

Measured memory_bytes: 5372
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>

using namespace std;
using ll = long long int;
using vec = vector<int>;

#define rep(n) for(int i = 0; i < (n); ++i)
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
const int INF = 2147483647;
const ll  MOD = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;

    cout << (n - 1) * (n) / 2.0 + m * (m - 1) / 2.0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string.h>
#include<cmath>
#include<algorithm>
#include<assert.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const ll INF=4223372036854775807,max_n=300005,mod=0x7f7f7f7f7f;
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
inline ll pow(ll a,ll b,ll mod){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int chengshi[20];
vector<int>x[20];
vector<int>y[20];
int xx;
int a,b;
int n;
bool check()
{
	for(int i=1;i<=n;i++)
	{
		if(chengshi[i]==1)
		{
			for(int j=0;j<x[i].size();j++)
			{
				if(y[i][j]==0&&chengshi[x[i][j]]==1)
				{
					return false;
				}
				if(y[i][j]==1&&chengshi[x[i][j]]==0)
				{
					return false;
				}
			}
		}
	}
	return true;
}
int max1;
int count1;
int main()
{
	cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>xx;
    	for(int j=1;j<=xx;j++)
    	{
			cin>>a>>b;
			x[i].push_back(a);
			y[i].push_back(b);
		}
	}
    for(int i=0;i<(1<<n);i++)
    {
    	count1=0;
        for(int j=0;j<n;j++)
        {
            if(i&(1<<j))
            {
                //cout<<1;
                //µÚj+1ÈËÎª³ÏÊµµÄ
                chengshi[j+1]=1;
                count1++;
            }
            else
            {
            	//µÚj+1ÈËÎªÐéÎ±µÄ
            	chengshi[j+1]=0;
            }
        }
		if(check())
		{
			max1=max(max1,count1);
		}
    }
    cout<<max1;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 100005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define pii pair<int,int>
 
int main(){
	ll n;
	cin >> n;
	map<ll,ll>mp;
	ll ans = 0;
	f(n){
		string s;
		cin >> s;
		ll cnt[26] = {};
		for(auto j:s){
			cnt[j-'a']++;
		}
		ll h = 0;
		fr(j,0,26){
			h*=1474751;
			h+=cnt[j];
			h%=12140003621;
		}
		ans += mp[h];
		mp[h]++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <set>
#include <cstdio>
using namespace std;
using ll = long long;


#define loop(i,n) for(int i=0;i<(n);i++)


int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll x1 = a * c;
    ll x2 = a * d;
    ll x3 = b * c;
    ll x4 = b * d;
    cout << max(max(x1, x2), max(x3, x4)) << endl;;

}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;

int main(){
    int N , M;
    cin >> N >> M;
    vector<int> H(N);
    vector<int> ans(N, 1);
    rep(i, N) cin >> H[i];
    rep(i, M){
        int A, B;
        cin >> A >> B;
        if(H[A-1]>H[B-1]) ans[B-1]=0;
        else if(H[A-1]<H[B-1]) ans[A-1]=0;
        else{
            ans[A-1] = 0;
            ans[B-1] = 0;
        }
    }
    int cnt = 0;
    rep(i, N){
        if(ans[i]==1){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 4052
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pi 3.1415926535
#define endl '\n'
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll inf=1e19;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  string s;
  cin>>s;
  if(s[2]==s[3] && s[4]==s[5])
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
ans = m//n
t = []
for i in range(1,int(m**0.5)+1):
    if m % i == 0:
        t.append(i)
        t.append(m//i)
t = sorted(t,reverse = True)
for i in t:
    if i <= ans:
        print(i)
        break

Measured memory_bytes: 38896
// by The_One_Solver
#include <bits/stdc++.h>
using namespace std;
/*
long long n;
vector<vector<pair<long long ,long long > > > v(1000);
struct node
{
    int num,dist;
    node()
    {
        num=0;dist=1e9;
    }
    node(int c,int x)
    {
        this->num=c;
        this->dist=x;
    }
};
const int N=100000;
int dist[N];
void dijkstra(int m)
{
    memset(dist,1e9,N);
    dist[m]=0;
    priority_queue<node> pq;
    pq.push(node(m,dist[m]));


}
*/
const int N=1e5;
long long  n,k,arr[N];
string str;
int main()
{
    cin>>n>>k;
    cin>>str;
    /*
    for(int i=0;i<n;i++)
    {
        int a,b,c;
        cin>>a>>b>>c;
        v[a].push_back(make_pair(b,c));
        v[b].push_back(make_pair(a,c));
    }
   */
   int coun=0;
   for(int i=1;i<str.size();i++)
   {
     if(str[i]=='C'&&str[i-1]=='A')
      {
          arr[i]=arr[i-1]+1;
      }
     else arr[i]=arr[i-1];
   }

    for(int i=0;i<k;i++)
    {
        int a,b;
        cin>>a>>b;
        cout<<arr[b-1]-arr[a-1]<<endl;
    }


}


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

long long n,k,now=1,cnt,a[223456],pre[223456];

int main(){
  cin>>n>>k;
  for(int i=1;i<=n;i++)cin>>a[i];
  while(k--){
    now=a[now];
    if(pre[now])k%=cnt-pre[now];
    pre[now]=cnt++;
  }
  cout<<now<<endl;
}


Measured memory_bytes: 6756
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ACC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mod 1000000007
#define MAXN 10000001
//string alpha="abcdefghijklmnopqrstuvwxyz";
//int dx[]={1,-1,0,0};
//int dy[]={0,0,1,-1};
//int dx8[]={1,-1,0,0,1,1,-1,-1};
//int dy8[]={0,0,1,-1,1,-1,1,-1};
/*int spf[MAXN];
void sieve()
{
	int i,j;
	for(i=0;i<MAXN;i++)
	spf[i]=i;
	for(i=4;i<MAXN;i+=2)
	spf[i]=2;
	for(i=3;i*i<MAXN;i++)
	{
		if(spf[i]==i)
		{
			for(j=i*i;j<MAXN;j+=i)
			{
				if(spf[j]==j)spf[j]=i;
			}
		}
	}
}*/
/*bool isvowel(char c)
{
    switch(c)
    {
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':return true;
        default : return false;
    }
}*/
/*bool isValid(int x,int y,int n,int m)
{
    if(x<0||x>n-1||y<0||y>m-1)return false;
    return true;
}*/
/*
bool comp(pair<int,int> x,pair<int,int> y)
{
    if(x.first==y.first)
        return x.second<y.second;
    return x.first>y.first;
}*/
vector<int> v[200001];
int vis[200001];
int dis[200001];
int ans;
void bfs(int x)
{
    vis[x]=1;
    dis[x]=1;
    ans=max(ans,dis[x]);
    int i=2;
    queue<int> q;
    q.push(x);
    while(!q.empty())
    {
        int p=q.front();
        q.pop();
        for(int child:v[p])
        {
            if(!vis[child])
            {
                vis[child]=1;
                dis[child]=i++;
                ans=max(ans,dis[child]);
                //cout<<
                q.push(child);
            }
        }
    }
}
int32_t main()
{
    ACC
    int T;
    T=1;
    //cin>>T;
    //sieve();
    while(T--)
    {
        int n,i,m;
        cin>>n>>m;
        set<pair<int,int>> s;
        for(i=0;i<m;i++)
        {
            int x,y;
            cin>>x>>y;
            if(x>y)swap(x,y);
            s.insert({x,y});
        }
        for(auto j:s)
        {
            v[j.first].pb(j.second);
            v[j.second].pb(j.first);
        }
        memset(vis,0,sizeof(vis));
        memset(dis,0,sizeof(dis));
        ans=0;
        for(i=1;i<=n;i++)
        {
            if(!vis[i])
            {
                bfs(i);
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}


Measured memory_bytes: 32524
#include<stdio.h>
 
int main()
{
  int t[4][3][10]={0};
  int b,f,r,v,i,j,k,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%d%d%d%d",&b,&f,&r,&v);
t[b-1][f-1][r-1]=t[b-1][f-1][r-1]+v;

      
    
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	printf(" %d",t[i][j][k]);
      }
      printf("\n");
    }
    if(i!=3)printf("####################\n");
  }
  return 0;
}



Measured memory_bytes: 2088
c = [0, 0]
f = True
for _ in range(int(input())):
    t, x, y = map(int, input().split())
    if sum(c) + t < abs(x) + abs(y):
        f = False
    if t % 2 != abs(c[1] - y + c[0] - x) % 2:
        f = False
print(f and 'Yes' or 'No')


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.q = l
        heapq.heapify(self.q)
        return

    def push(self, n):
        heapq.heappush(self.q, n)
        return

    def pop(self):
        return heapq.heappop(self.q)


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    def ispalindrome(str): return 1 if str == str[::-1] else 0
    S = Scanner.string()
    if not ispalindrome(S):
        print('No')
        return
    if not ispalindrome(S[:len(S)//2]):
        print('No')
        return
    if not ispalindrome(S[len(S) // 2 + 1:]):
        print('No')
        return
    print('Yes')
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 62668
import itertools
N,K = [int(hoge) for hoge in input().split()]
RSP = [int(hoge) for hoge in input().split()]
T = input()
Hand = [[] for i in range(K)]

for n,d in enumerate(T):
    if d == "r":
        t = 2
    elif d == "s":
        t = 0
    else:
        t = 1
    Hand[n%K].append(t)

ans = 0
for k in Hand:
    Hands = itertools.groupby(k)
    for h in Hands:
        l = len(list(h[1]))
        ans +=  RSP[h[0]] * ((l+1)//2)
    
print(ans)

Measured memory_bytes: 53116
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n;
  cin >> n;
  vector<vi> g(n);
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<vi> d(2, vi(n, -1));
  rep(k, 2) {
    queue<int> q;
    q.push(k * (n - 1));
    d[k][k * (n - 1)] = 0;
    while(!q.empty()) {
      int i = q.front();
      q.pop();
      for(int ni : g[i]) {
        if(d[k][ni] != -1) continue;
        d[k][ni] = d[k][i] + 1;
        q.push(ni);
      }
    }
  }
  int cnt = 0;
  rep(i, n) if(d[0][i] <= d[1][i]) cnt++;
  cout << (cnt > n / 2 ? "Fennec" : "Snuke") << endl;
}

Measured memory_bytes: 6912
#if loc||local
#define _GLIBCXX_DEBUG
#endif

#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
struct union_find{
  size_t n;
  vector<int> par;
  size_t group;
  union_find(){}
  union_find(size_t _n):n(_n),group(_n){
    par.resize(n,-1);
  }
  void reset(size_t _n){
    n = _n;
    group = n;
    par.clear();
    par.resize(n,-1);
  }
  int root(int k){
    if(par[k]<0)return k;
    return par[k] = root(par[k]);
  }
  int size(int k){
    k = root(k);
    return -par[k];
  }
  auto operator[](int k){
    return size(k);
  }
  bool unite(int a,int b){
    a = root(a);
    b = root(b);
    if(a==b)return false;
    if(size(a)<size(b))swap(a,b);
    group--;
    par[a] += par[b];
    par[b] = a;
    return true;
  }
  auto operator()(int a,int b){
    return unite(a,b);
  }
  bool same(int a,int b){
    return root(a) == root(b);
  }
};
signed main(){

  int n,m;
  cin>>n>>m;
  union_find uni(n);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    uni.unite(a,b);
  }
  ll ans = 0;
  rep(i,n)chmax<ll>(ans,uni.size(i));
  cout<<(ans)<<endl;

}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;

  vector<int> a(N);
  vector<int> num_cnt(100001,0);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
    num_cnt.at(a.at(i)) ++;
  }

  int ans_max = 1;
  for(int i=1;i<N-1;i++){
    if(ans_max < num_cnt.at(i-1) + num_cnt.at(i) + num_cnt.at(i+1)){
      ans_max = num_cnt.at(i-1) + num_cnt.at(i) + num_cnt.at(i+1);
    }
  }

  cout << ans_max << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,x,y;
  cin >> a >> b >> x;
  y=0;
  int i= min(a,b);
  while(y<x){
    if(a%i==0&&b%i==0){
      y++;
    }
    i--;
  }
    cout << i+1 << endl;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename T>
ostream& operator << (ostream& os, vector<T> v)
{
  os << "(";
  each (i, v) os << i << ", ";
  os << ")";
  return os;
}

void fn(lli n, int x) {
    vector<int> v(60, 0);
    for (int i = 0; i < v.size(); ++i) {
      if (n & (1LL << i)) v[i] = 1;
    }

    for (int i = 0; i < v.size(); ++i) {
      if (1 < v[i]) {
        v[i + 1] += v[i] / 2;
        v[i] %= 2;
      }
      if (i % 2 == x && v[i]) {
        v[i + 1] += v[i];
      }
    }

    while (1 < v.size() && v.back() == 0) v.pop_back();
    reverse(v.begin(), v.end());
    each (i, v) cout << i; cout << endl;

    return ;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n;
  while (cin >> n) {
    if (0 <= n) fn(n, 1);
    else fn(abs(n), 0);
    
  }
  
  return 0;
}


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

using namespace std;

int main()
{
    int n;cin>>n;
    int act[3][100005]={};
    int ans[3][100005]={};
    for(int j=0;j<n;j++){
        for(int i=0;i<3;i++){
            cin>>act[i][j];
        }
    }
    for(int i=0;i<3;i++){
        ans[i][0]=act[i][0];
    }
    for(int j=1;j<n;j++){
        for(int i=0;i<3;i++){int Max=0;
            for(int k=0;k<3;k++){
                if(i==k)continue;
                Max=max(Max,ans[k][j-1]);
            }
            ans[i][j]+=Max+act[i][j];
            //cout<<"["<<Max<<" "<<ans[i][j]<<"] ";
        }
       // cout<<endl;
    }
    int Max=0;
    for(int i=0;i<3;i++)
    Max=max(Max,ans[i][n-1]);
    cout<<Max<<endl;



}



/*3 10 40 70 20 50 80 30 60 90*/








Measured memory_bytes: 2688
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		
        Scanner sc= new Scanner(System.in);
        
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int p;
        
        if(b<a){
        p=a;
        a=b;
        b=p;
        }
        
        if(c<b){
        p=b;
        b=c;
        c=p;
        }
        
        if(b<a){
        p=a;
        a=b;
        b=p;
     	}
        
        System.out.println(a+" "+b+" "+c);
 
}

}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] h = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int ans = 0;
            int t = h[0];
            int c = 0;
            for (int i = 1; i < h.Length; i++) {
                if (t >= h[i]) {
                    c++;
                } else {
                    c = 0;
                }
                ans = Math.Max(ans, c);
                t = h[i];
            }
            Console.WriteLine(ans);
        }
    }
}


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

int main(){
  int a,b,c;
  int e,f;
  cin>>a>>b>>c;
  e=b-a;
  f=c-b;
  
  if(e==f){
    cout<<"YES";
    
    
  }else{cout<<"NO";}
 return 0; 
}

Measured memory_bytes: 256
n=parse(Int,readline())
lst=[]
for i=1:n
    push!(lst,readline())
end

s=unique(lst)
newlst=sort([ele for ele in s])
d=Dict{String, Int64}()

for i in 1:n
  if haskey(d,lst[i])
    d[lst[i]] += 1
  else
    d[lst[i]] = 1
  end
end
m = maximum(values(d))

for ele in newlst
    if d[ele]==m
        println(ele[1:length(ele)-1])
    end
end


Measured memory_bytes: 181236
n, m = map(int, input().split())
ans = [-1 for _ in range(n)]
flag = 0
for k in range(m):
    s, c = map(int, input().split())
    if (ans[s - 1] == -1) or (ans[s - 1] == c):
        ans[s - 1] = c
    else:
        print(-1)
        flag = 1
        break

if flag == 0:
    if (n == 1) and (ans[0] == -1):
        print(0)
    else:
        anss = []
        flag = 1
        for a in ans:
            if a != -1:
                anss.append(a)
                flag = 0
            else:
                if flag == 0:
                    anss.append(0)
                else:
                    anss.append(1)
                    flag = 0
        if anss[0] == 0:
            if len(anss) == 1:
                print(0)
            else:
                print(-1)
        else:
            print("".join(map(str, anss)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
struct city
{
	int num;
	int Yi;
	int Pi;
	string str;
};
bool comp(city A,city B)
{
	return A.Pi<B.Pi || A.Pi==B.Pi && A.Yi<B.Yi;
}
bool recomp(city A,city B)
{
	return A.num<B.num;
}
int main()
{
	int n,m;
	cin>>n>>m;
	vector <city> At(m);
	rep(i,0,m)
	{
		cin>>At[i].Pi>>At[i].Yi;
		At[i].num=i;
	}
	sort(all(At),comp);
	int pos=1;
	rep(i,0,m)
	{
		if(At[i].Pi!=At[i-1].Pi)pos=1;
		else pos++;
		char s[20]={};
		sprintf(s,"%06d%06d",At[i].Pi,pos);
		At[i].str=s;
	}
	sort(all(At),recomp);
	rep(i,0,m)cout<<At[i].str<<endl;
	return 0;
}



Measured memory_bytes: 8576
from collections import defaultdict
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    S = [input() for _ in [0] * N]

    ans = defaultdict(int)
    for s in S:
        ans[s] += 1
    for s in ('AC', 'WA', 'TLE', 'RE'):
        print(s, 'x', ans[s])


main()


Measured memory_bytes: 17400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int A,B,M;
	cin>>A>>B>>M;
	vector<pair<int,int>> p;
	int a[A+1]={0};
	int b[B+1]={0};
	for(int i=1;i<=A;i++)
		cin>>a[i];
	for(int i=1;i<=B;i++)
		cin>>b[i];
	int c[M];
	for(int i=0;i<M;i++)
	{
		int x,y;
		cin>>x>>y;
		p.push_back(make_pair(x,y));
		cin>>c[i];
	}
	int mn=INT_MAX;
	for(int i=0;i<p.size();i++)
	{
		mn=min(a[p[i].first]+b[p[i].second]-c[i],mn);
	}
	sort(a+1,a+A+1);
	sort(b+1,b+B+1);
	int x=a[1]+b[1];
	if(x<mn)
		mn=x;
	cout<<mn<<endl;
}


Measured memory_bytes: 2424
using System;
using System.Collections.Generic;
using System.Linq;
namespace Codes
{
    class Program
    {
        static void Main(string[] args)
        {
            double r = double.Parse(Console.ReadLine());
            double answer = 2*r*3.1415;
            Console.WriteLine(answer);
 
 
        }
    }
}

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

int main(){
    string s;
    cin >> s;
    map<string,string> tenki;
    tenki["Sunny"]="Cloudy";
    tenki["Cloudy"]="Rainy";
    tenki["Rainy"]="Sunny";
    cout << tenki.at(s) << endl;
}

Measured memory_bytes: 256
N,Q = map(int,input().split())
S = input()
X = [list(map(int, input().split())) for _ in range(Q)]
L =[0]*(N+1)
for i in range(N-1):
  if S[i]=="A" and S[i+1]=="C":
    L[i+1] = L[i]+1 
  else:
    L[i+1] = L[i]
L[N] = L[N-1]
for x in X:
  print(L[x[1]-1]-L[x[0]-1])

Measured memory_bytes: 29584
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
using namespace std;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
typedef vector<ll> vc;
typedef vector<string> vcs;
typedef vector<pair<ll, ll>> vcp;
typedef vector<tuple<ll, ll, ll>> vct;
//vector<vector<ll>> vv(n, vector<ll>(n));

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator >(const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	string s;
	cin >> s;
	REP(i, s.size()) if (!(i % 2)) cout << s[i];
	cout << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    lint n; cin >> n;
    vector<lint> a(n+2); repeat_from_to (i, 1, n) cin >> a[i];
    a[0] = a[n+1] = 0;
    
    vector<lint> asc(n + 2, 0), dsc(n + 2, 0);
    repeat_from_to (i, 1, n+1) {
        asc[i] = asc[i-1] + abs(a[i] - a[i-1]);
    }
    repeat_reverse_from_to (i, n, 0) {
        dsc[i] = dsc[i+1] + abs(a[i+1] - a[i]);
    }
    
    repeat_from_to (i, 1, n) {
        lint ans = 0;
        ans += asc[i-1];
        ans += abs(a[i-1] - a[i+1]);
        ans += dsc[i+1];
        cout << ans << endl;
    }
    
}

Measured memory_bytes: 3584
// C - Inserting 'x'
// https://atcoder.jp/contests/code-festival-2017-qualc/tasks/code_festival_2017_qualc_c?lang=en

#include <bits/stdc++.h>
                    
using namespace std;
typedef long long ll;
   
#define MAX 100000 + 4
char s[MAX];

int main() {
  scanf("%s", s);
          
  ll l=0;
  ll r=strlen(s)-1;
  ll ans=0;
  while(l<r) {
    if (s[l] == s[r]) {
      l++;
      r--;
      continue;
    }     
    if (s[l] == 'x') {
      l++;
      ans++;
      continue;
    }
    if (s[r] == 'x') {
      r--;
      ans++;
      continue;
    }
    printf("%d\n", -1);
    exit(0);
  }      
  printf("%lld\n", ans);
}


Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;


namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int[] abc = sc.intarr;

            if(abc[0] + abc[1] >= abc[2])
            {
                wr.wri("Yes");
            }
            else
            {
                wr.wri("No");
            }
        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<vector<int>> arr(n, vector<int>(3));
	for(int i=0; i<n; ++i) {
		cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
	}
	vector<vector<int>> dp(n, vector<int>(3, -1));
	int answer = -1;
	for(int j=0; j<3; ++j) {
		dp[0][j] = arr[0][j];
		answer = max(dp[0][j], answer);
	}
	for(int i=1; i<n; ++i) {
		for(int j=0; j<3; ++j) {
			for(int k=0; k<3; ++k) {
				if(j != k) {
					dp[i][j] = max(dp[i][j], dp[i-1][k] + arr[i][j]);
				}
			}
			answer = max(answer, dp[i][j]);
		}
	}
	printf("%d", answer);
	return 0;
}

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

using namespace std;

using i64 = long;

const i64 MOD = 998244353;
const i64 INF = i64(1e18) + 7;


template <i64 mod = MOD>
struct ModInt{
    i64 p;

    ModInt() : p(0){}
    ModInt(i64 x){p = x >= 0 ? x % mod : x + (-x + mod - 1) / mod * mod;}

    ModInt& operator+=(const ModInt& y){p = p + *y - ((p + *y) >= mod ? mod : 0); return *this;}
    ModInt& operator-=(const ModInt& y){p = p - *y + (p - *y < 0 ? mod : 0); return *this;}
    ModInt& operator*=(const ModInt& y){p = (p * *y) % mod; return *this;}
    ModInt& operator%=(const ModInt& y){if(y)p %= *y; return *this;}

    ModInt operator+(const ModInt& y) const{ModInt x = *this; return x += y;}
    ModInt operator-(const ModInt& y) const{ModInt x = *this; return x -= y;}
    ModInt operator*(const ModInt& y) const{ModInt x = *this; return x *= y;}
    ModInt operator%(const ModInt& y) const{ModInt x = *this; return x %= y;}

    friend ostream& operator<<(ostream& stream, const ModInt<mod>& x){
        stream << *x;
        return stream;
    }

    friend ostream& operator>>(ostream& stream, const ModInt<mod>& x){
        stream >> *x;
        return stream;
    }

    ModInt& operator++(){p = (p + 1) % mod; return *this;}
    ModInt& operator--(){p = (p - 1 + mod) % mod; return *this;}

    bool operator==(const ModInt& y) const{return p == *y;}
    bool operator!=(const ModInt& y) const{return p != *y;}

    const i64& operator*() const{return p;}
    i64& operator*(){return p;}

};

using mint = ModInt<>;

auto mpow = [](auto x, i64 y){
    auto z = x;
    decltype(x) val = y & 1 ? x : decltype(x)(1);
    while(z *= z, y >>= 1)
        if(y & 1)
            val *= z;
    return val;
};


signed main(){
    i64 n;
    cin >> n;
    vector<i64> d(n);
    vector<i64> cnt(n + 5, 0);
    for(auto& x : d){
        cin >> x;
        ++cnt[x];
    }
    if(d[0] != 0 || cnt[0] != 1){
        cout << 0 << endl;
        return 0;
    }
    mint ans = 1;
    bool fl = true;
    i64 val = 1;
    for(i64 i = 0; i < n; ++i){
        if(cnt[i + 1] == 0)
            break;
        if(fl)
            ans *= mpow(mint(cnt[i]), cnt[i + 1]);
        val += cnt[i + 1];
    }
    if(val != n){
        cout << 0 << endl;
        return 0;
    }
    cout << (*ans) << endl;
}


Measured memory_bytes: 1792
#include <math.h>
#include <stdio.h>

#include <iostream>
#include <string>
using namespace std;

int main() {
    double a, b, C, PI = 3.1415926535;
    cin >> a >> b >> C;
    double S;
    printf("%.5f\n" , a * b * sin(C * PI / 180) / 2);
    printf("%.5f\n" , a + b + sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(C * PI / 180)));
    printf("%.5f\n" , b * sin(C * PI / 180));
    return 0;
}


Measured memory_bytes: 3480
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C&lang=jp
sample_input = list(range(3))
sample_input[0] = '''7
insert 5
insert 2
insert 3
insert 1
delete 3
insert 6
delete 5'''
sample_input[1] = '''9
insert 5
insert 2
insert 3
insert 1
delete 3
insert 6
delete 5
deleteFirst
deleteLast'''
sample_input[2] = '''8
insert 1000000000
insert 999999999
deleteLast
insert 1234566890
insert 5
deleteFirst
insert 7
delete 5'''
give_sample_input = None
if give_sample_input is not None:
    sample_input_list = sample_input[give_sample_input].split('\n')
    def input():
        return sample_input_list.pop(0)
        
# main
from collections import deque

num_of_command = int(input())
doubly_list = deque()
for n in range(num_of_command):
    str_command = input()
    if str_command == 'deleteFirst':
        doubly_list.popleft()
        continue
    elif str_command == 'deleteLast':
        doubly_list.pop()
        continue
    command_name = str_command.split()[0]
    command_obj = int(str_command.split()[1])
    if command_name == 'insert':
        doubly_list.appendleft(command_obj)
    elif command_name == 'delete':
        try:
            doubly_list.remove(command_obj)
        except ValueError:
            continue

output = ''
for item in doubly_list:
    output += str(item) + ' '
output = output.rstrip()
print(output)

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

main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++)
    cin >> A.at(i);
  sort(A.begin(),A.end());
  cout << A[N-1]-A[0];
  return 0;
}  
  

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int n, k, i, a[200003];

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

    int l, r, mid, log_num;
    l = 0;
    r = INF;
    while (r - l > 1) {
        mid = (l + r) / 2;
        log_num = 0;
        for (i = 0; i < n; i++) {
            log_num += a[i] / mid;
            if (a[i] % mid == 0) {
                log_num--;
            }
        }
        if (log_num <= k) {
            r = mid;
        }
        else {
            l = mid;
        }
    }

    printf("%d\n", r);

    return 0;
}

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

#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define pb push_back
#define fi first
#define se second

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}
ll LCM(ll x, ll y){
	return x/GCD(x, y)*y;
}

int main() {
	 ll n, m; cin >> n >> m;
	 ll a[100005], b[100005];
	 vector<pll> v;
	 rep(i, 0, n){
		 cin >> a[i] >> b[i];
		 v.pb({a[i], b[i]});
	 }
	 sort(v.begin(), v.end());
	 ll ans = 0;
	 ll cnt = 0;
	 for(auto p: v){
		 ans += p.fi*min(p.se, m-cnt);
		 cnt += min(p.se, m-cnt);
		 if(cnt==m) break;
	 }
	 cout << ans << endl;
	return 0;
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String b = sc.next();
		if(b.equals("A"))
			System.out.println("T");
		if(b.equals("C"))
			System.out.println("G");
		if(b.equals("G"))
			System.out.println("C");
		if(b.equals("T"))
			System.out.println("A");
		
	}

}


Measured memory_bytes: 23252
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//priority_queue<int> pque;
//priority_queue<int, vector<int>, greater<int>> pque;
//cout << fixed << setprecision(10) << ans << endl;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;

double p[3010];
double dp[3010][3010];

int main(void){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> p[i];
    }
    dp[0][0] = 1;
    
    for(int i = 1; i <= N; i++){
        for(int j = 0; j <= i; j++){
            
            dp[i][j] = p[i-1] * dp[i-1][j-1] + (1.0 - p[i-1]) * dp[i-1][j];
            
        }
    }
    double ans = 0;
    for(int i = N / 2 + 1; i <= N; i++){
        ans += dp[N][i];
    }
    
    cout << fixed << setprecision(10) << ans << endl;
    
}


Measured memory_bytes: 69120
import java.util.Scanner;

public class Main
{

	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		int a = Integer.parseInt(sc.next());
		sc.next();sc.next();sc.next();
		int e = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		String ans = (e - a > k) ? ":(" :
								   "Yay!";

		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() { 
    string s;
    cin >> s;
    s[3]++;
    cout << s << endl;
}




Measured memory_bytes: 3636
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	x,y = map(int,input().split())	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# 3
# hoge
# foo
# bar
# n=int(input())
# string_list=[input() for i in range(n)]
n=int(input())
p=[int(input()) for _ in range(n)]

print(sum(p)-int(max(p)/2))

Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int K,N;
int num[100010];

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

std::vector<int> div(int n){
	std::vector<int> v;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			v.push_back(i);
			if(i*i!=n){
				v.push_back(n/i);
			}
		}
	}
	return v;
}

int mod_pow(int b,int e,int m){
    if(e==0){
        return 1;
    }else{
        int sum = mod_pow(b,e/2,m);
        if(e%2==0){
            return (sum*sum)%m;
        }else{
            return (((sum*sum)%m)*b)%m;
        }
    }
}

signed main(){
	cin>>N>>K;
	int ans=0;
	int sum=mod_pow(K,N,MOD);
	int cnt=0;
	for(int i=K;2<=i;i--){
		int s=K/i;
		int R=mod_pow(s,N,MOD);
		R=R-num[i];
		cnt+=R;cnt%=MOD;
		ans=ans+(R*i)%MOD;ans%=MOD;
		vector<int> v=div(i);
		REP(j,v.size()){
			num[v[j]]+=R;
		}
	}
	ans=ans+sum-cnt+MOD;
	ans%=MOD;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4380