akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

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

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

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

ll powmod(ll n, ll x)
{
    vector<ll> vll(32);
    vll[0] = n;
    FOR(i, 1, 32)
    {
        vll[i] = (vll[i - 1] * vll[i - 1]) % MOD;
    }
    ll ret = 1;
    int cnt = 0;
    while (x > 0) {
        if (x & 1) {
            ret = (ret * vll[cnt]) % MOD;
        }
        x >>= 1;
        cnt++;
    }
    return ret;
}

int main()
{
    string s;
    cin >> s;
    vector<int> memo(s.length());
    map<int,int> mpii;
    mpii[0]++;
    REPD(i,s.length()){
        if(i==s.length()-1){
            memo[i]=s[i]-'0';
            mpii[memo[i]]++;
        }else{
            memo[i]=(memo[i+1]+(s[i]-'0')*powmod(10,s.length()-i-1))%MOD;
            mpii[memo[i]]++;
        }
    }
    ll ans=0;
    for(auto it=mpii.begin();it!=mpii.end();it++){
        ans+=(it->second)*((it->second)-1)/2;
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);

    int n;
    cin >> n;

    vector<int> a(n);
    for (int i = 0 ;i < n ;i++)
        cin >> a[i];

    int prev = a[0] - 1;
    for (int i = 1 ;i < n ;i++) {
        if (a[i] < prev) {
            cout << "No";
            return 0;
        }

        if (a[i] - 1 >= prev)
            prev = a[i] - 1;
        else
            prev = a[i];
    }

    cout << "Yes";
}


Measured memory_bytes: 3668
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);

            if(A > 8 || B>8)
            {
                Console.WriteLine(":(");
            }
            else
                Console.WriteLine("Yay!");
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>

using namespace std;

using ll = long long;

int main()
{
    ll N, x;
    cin >> N >> x;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }    
    
    ll res = 0;
    for (int i = 1; i < N; i++) {
        if (a[i] + a[i - 1] > x) {
            res += (a[i] + a[i - 1]) - x;
            a[i] = max(0LL, x - a[i - 1]);
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
from collections import deque

queue = deque([])

n = int(input())

for i in range(n):
    commands = input().split(" ")
    command = commands[0]
    if command == "insert":
        queue.appendleft(commands[1])
    elif command == "delete":
        try:
            queue.remove(commands[1])
        except ValueError:
            pass
    elif command == "deleteFirst":
        queue.popleft()
    elif command == "deleteLast":
        queue.pop()

last = queue.pop()
for i in queue:
    print(i, end=" ")

print(last)

Measured memory_bytes: 71880
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

#define len (1<<18)
vl seg(len*2,2147483647);

void update(ll ind,ll x){
	ind+=len;
	seg[ind]=x;
	while(true){
		ind/=2;
		if(ind==0)break;
		seg[ind]=min(seg[ind*2],seg[ind*2+1]);
	}
}

int RMQ(ll l,ll r){
	ll ans=2147483647;
	l+=len; r+=len;
	while(l<r){
		if(l%2==1){
			chmin(ans,seg[l]);
			l++;
		}
		l/=2;
		if(r%2==1){
			chmin(ans,seg[r-1]);
			--r;
		}
		r/=2;
	}
	return ans;
}

signed main(){
	ll n,q; cin>>n>>q;
	vl ans(0);
	rep(i,0,q){
		ll com; cin>>com;
		if(com==0){
			ll ind,x; cin>>ind>>x;
			update(ind,x);
		}
		if(com==1){
			ll l,r; cin>>l>>r;
			ans.push_back(RMQ(l,r+1));
		}
	}
	rep(i,0,ans.size())cout<<ans[i]<<endl;
	
	return 0;
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
#define MAXX 200010
 
#define PI   3.14159265358979323846264338327950
 
#define PB push_back 
#define F first
#define S second
 
#define ll 	long long int
 
#define mod  1000000007
 
 
 
int main()
{
	FAST;
	ll n, m;
	cin >> n >> m; 
	ll ans = 0;
	for(ll i = n; i <= m; i++){
		ll a = i/10000;
		ll b = i/1000    %10;
		ll c = i/10      %10;
		ll d = i%10;
		if(a == d && c == b){
			ans ++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3620
def woo(n, w):
	res = [0 for i in range(0, w+1)]

	for i in range(0, n):
		ww, vv = map(int, input().split())
		for j in range(w, ww-1, -1):
			wtotal = j + ww
			vtotal = res[j-ww] + vv
			if vtotal > res[j]:
				res[j] = vtotal

	return res

if __name__ == '__main__':
	n, w = map(int, input().split())
	r = woo(n, w)
	print(max(r))

Measured memory_bytes: 7832
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
  int n;
  cin>>n;
  int sum=0;
  VI x(n);
  rep(i,n){
    cin>>x[i];
  }

  int p=0;
  ll ans=INF,mem=0;
  rep(i,100){
    mem=0;
    p=i+1;
    rep(j,n){
      mem+=(x[j]-p)*(x[j]-p);
    }
    //cout<<mem<<endl;
    ans=min(mem,ans);
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

int main(int argc, char* argv[])
{
    long h, w, n;
    scanf("%ld%ld%ld", &h, &w, &n);

    map<pair<long,long>, long> z;
    long i;
    for(i=0; i<n; i++) {
        long a, b;
        scanf("%ld%ld", &a, &b);
        a--; b--;
        long j, k;
        for(j=a-2; j<=a; j++) {
            if(j<0 || j>=h-2) continue;
            for(k=b-2; k<=b; k++) {
                if(k<0 || k>=w-2) continue;
                z[make_pair(j, k)]++;
            }
        }
    }
 
    ll cnt[10]={0};
    auto it=z.begin();
    for(; it!=z.end(); ++it) {
        cnt[it->second]++;
    }

    ll tmp=0;
    for(i=1; i<10; i++) {
        tmp += cnt[i];
    }
    cnt[0] = (h-2)*(w-2)-tmp;
    for(i=0; i<10; i++) {
        printf("%lld\n", cnt[i]);
    }

    return 0;
}


Measured memory_bytes: 56448
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
        cin.tie(0);
        cout.tie(0);
    ios::sync_with_stdio(false);

    cin>>n>>k;
    rep(i,n)cin>>a[i];
    rep(i,n+1){
        rep(j,n+1){
            ll kai=i+j;
            if(kai>k)continue;
            vector<ll> mai;
            bool mem[n+10]={};
            rep(kk,i){
                mem[kk]=true;
                cnt+=a[kk];
                if(a[kk]<0)mai.push_back(a[kk]);
            }
            rrrep(kk,n-1,n-j){
                if(mem[kk])break;
                cnt+=a[kk];
                if(a[kk]<0)mai.push_back(a[kk]);
            }
            ll yoyuu=k-kai;
            sort(all(mai));
            rep(kk,min(yoyuu,(ll)Size(mai))){
                cnt+=mai[kk]*-1;
            }
            ans=max(ans,cnt);
            cnt=0;
        }
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
namespace FastIO{const char* ln="\n";struct Reader{char buf[1<<20],*s,*t;bool EOF_FLG;Reader():s(buf),t(buf),EOF_FLG(false) {};char gt() {return s==t&&((t=(s=buf)+fread(buf,1,1<<20,stdin))==s)?EOF:(*s++);}Reader& operator>>(char* str) {if(EOF_FLG)return *str=0,*this;while((*str=gt())!=' '&&*str!='\n'&&*str!=EOF)++str;if(*str==EOF)EOF_FLG=true;*str=0;return *this;}template<typename T>Reader&operator>>(T&x) {if(EOF_FLG)return *this;char c=0,d;while(c!=EOF&&(c<'0'||c>'9'))d=c,c=gt();if(c==EOF){EOF_FLG=true;return *this;}else x=0;while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+c-'0',c=gt();if(d=='-')x=-x;return *this;}}in;struct Writer{char buf[1<<20],*s,*t;Writer():s(buf),t(buf+(1<<20)){}~Writer(){fwrite(buf,1,s-buf,stdout);}void pt(char c){(s==t)?(fwrite(s=buf,1,1<<20,stdout),*s++=c):(*s++=c);}template<typename T>Writer&operator<<(T x){if(!x)return pt('0'),*this;if(x<0)pt('-'),x=-x;char a[40],t=0;while(x)a[t++]=x%10,x/=10;while(t--)pt(a[t]+'0');return *this;}Writer&operator<<(const char*s) {while(*s)pt(*s++);return *this;}}out;}using namespace FastIO;
namespace ZDY{
    #define ll long long
    #define db double
    #define sht short
    #define MB template <class T>
    #define Fur(i,x,y) for(int i=x;i<=y;i++)
    #define fur(i,x,y) for(i=x;i<=y;i++)
    #define Fdr(i,x,y) for(int i=x;i>=y;i--)
    #define fdr(i,x,y) for(i=x;i>=y;i--)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define cpy(x,y) memcpy(x,y,sizeof(x))
    #define inf 0x3f3f3f3f
    #define fin(s) freopen(s".in","r",stdin)
    #define fout(s) freopen(s".out","w",stdout)
    #define l2(n) (int(log2(n)))
    #define fl(i,x) for(int i=head[x],to;to=e[i].to,i;i=e[i].nxt)
    #define fcin ios::sync_with_stdio(false)
    MB T ABS(T x){return x>0?x:-x;}
    MB T MAX(T x,T y){return x>=y?x:y;}
    MB T MIN(T x,T y){return x<=y?x:y;}
    void SWAP(int &x,int &y){x^=y;y^=x;x^=y;}
}using namespace ZDY;using namespace std;
int gcd(int a,int b){
    if(!b)return a;
    return gcd(b,a%b);
}
#define N 1000011
int n,x,t;
int main(){
    in>>n>>t;n--;
    while(n--){
        in>>x;
        t=gcd(t,x);
    }
    out<<t<<ln;
}

Measured memory_bytes: 1280
import java.util.Scanner;

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

		int x = Math.max(a + b, a - b);
		x = Math.max(a * b, x);
		System.out.println(x);
	}
}


Measured memory_bytes: 23124
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
//#include <vector>
//#include <iostream>

typedef long long ll;
typedef unsigned long long ull;

int dp[100001];

bool dfs(int x)
{
    if (dp[x] == 1)
        return true;
    else if (dp[x] == 0)
        return false;
    else
    {
        bool flag = false;
        if (dfs(x - 100))
        {
            flag = true;
        }
        else if (dfs(x - 101))
        {
            flag = true;
        }
        else if (dfs(x - 102))
        {
            flag = true;
        }
        else if (dfs(x - 103))
        {
            flag = true;
        }
        else if (dfs(x - 104))
        {
            flag = true;
        }
        else if (dfs(x - 105))
        {
            flag = true;
        }
        if (flag)
        {
            dp[x] = 1;
            return true;
        }
        dp[x] = 0;
        return false;
    }
}
void Main()
{
    ll X;
    std::cin >> X;
    for (int i = 0; i < 100001; i++)
        dp[i] = -1;

    for (int i = 1; i < 100; i++)
        dp[i] = 0;

    dp[0] = 1;
    dp[100] = 1;
    dp[101] = 1;
    dp[102] = 1;
    dp[104] = 1;
    dp[105] = 1;
    if (dfs(X))
        std::cout << 1 << std::endl;
    else
        std::cout << 0 << std::endl;
}

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
ll powmod(ll a,ll b) {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 nxt() {int x;scanf("%d", &x);return x;}


int main(){
    int k=nxt();
    string s="";
    cin>>s;
    if(s.size()>k){
        s=s.substr(0,k);
        s.append("...");
    }
    cout<<s;
    return 0;
}



Measured memory_bytes: 3660
#include <string>
#include <iostream>
#include <map>
using namespace std;

int main()
{
  string line;
  map<string, int> cnt;
  cnt["A"] = cnt["B"] = cnt["AB"] = cnt["O"] = 0;
  while (getline(cin, line)) {
    if (line.find_first_of("\n") != string::npos)
      line.erase(line.end()-1);
    if (line.find_first_of("\r") != string::npos)
      line.erase(line.end()-1);
    string bt = line.substr(line.find_first_of(",")+1);
    ++cnt[bt];
  }

  cout << cnt.find("A")->second << endl;
  cout << cnt.find("B")->second << endl;
  cout << cnt.find("AB")->second << endl;
  cout << cnt.find("O")->second << endl;
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, t, a;
    cin >> n >> t >> a;
    vec h(n);
    rep(i, n) cin >> h[i];

    int res = -1;
    double cur = INF;

    rep(i, n) {
        double tm = 0.006;
        tm *= h[i];
        double err = t - tm;
        if (abs(a - err) < cur) {
            res = i+1;
            cur = abs(a - err);
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

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

    if (a <= 0 && b >= 0)
        cout << "Zero" << endl;
    else if (a > 0)
        cout << "Positive" << endl;
    else
        if ((abs(b) - abs(a)) % 2 == 0)
            cout << "Negative" << endl;
        else
            cout << "Positive" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> T input() {T t; cin>>t; return t;}
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define CHMAX(a,b) a = max(a,b)
#define CHMIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define PRINT_ARRAY_H(a) REPALL(__i,a) {cout<<a[__i]<<(__i != a.size()-1 ? " " : "");} newline;
#define e1 first
#define e2 second
#define newline putchar('\n')
#define cspace ' '
#define sspace " "
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;
const VI dx = {1, 0, -1, 0};
const VI dy = {0, 1, 0, -1};

VLL ans(11111);

int main()
{
    ll n, m, l, r, k, a, b, c, d;
    string s, t;
    cin>>n;
    FOR(x,1, sqrt(n)+2) {
        FOR(y,x, sqrt(n)+2) {
            FOR(z,y, sqrt(n)+2) {
                if (x*x+y*y+z*z+x*y+y*z+z*x > n)
                    break;
                if (x == y && x == z) {
                    ans[x*x+y*y+z*z+x*y+y*z+z*x] += 1;
                } else if (x == y || y == z || z == x) {
                    ans[x*x+y*y+z*z+x*y+y*z+z*x] += 3;
                } else {
                    ans[x*x+y*y+z*z+x*y+y*z+z*x] += 6;
                }
            }
        }
    }

    FOR(i,1,n+1) {
        cout<<ans[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 3684
#include <cstdio>
#include <algorithm>
using namespace std;
const long long m = 1000000007;
long long p(long long b, long long e) {
	if (e == 0) return 1;
	long long a = p(b, e / 2);
	a = a * a % m;
	if (e % 2) a = a * b % m;
	return a;
}
int main() {
	int n, a, b;
	scanf("%d %d %d", &n, &a, &b);
	long long ans = p(2, n) - 1;
	long long x = 1;
	for (int i = 0; i < a; ++i) x *= (n - i) * p(i + 1, m - 2) % m, x %= m;
	ans -= x;
	x = 1;
	for (int i = 0; i < b; ++i) x *= (n - i) * p(i + 1, m - 2) % m, x %= m;
	ans -= x;
	printf("%lld", (ans % m + m) % m);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;
 
 
void solve(){
    int n;
    cin >> n;
    vi a(n), b(n), c(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    for(int i = 0; i < n - 1; i++) cin >> c[i];
    
    int ans = 0;
    for(int i = 0; i < n; i++){
        int idx = a[i] - 1;
        ans += b[idx];
        if(i < n - 1){
            if(a[i + 1] == idx + 2) ans += c[idx];
        }
    }
    cout << ans;
}
 
int main() {
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

int main(void){
	int d,n;
	scanf("%d %d",&d,&n);

	if(n==100) n++;
	while(d--){
		n*=100;
	}

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

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
 
using namespace std;
 
long long a[100007];
 
int main(){
    int N; cin >> N;
    for(int i=1; i<=N; i++) cin >> a[i];
 
    bool result = false;
    long long multi=a[1];
    int cnt=0;

    for(int i=1; i<=N; i++){
        if(a[i] % 4 == 0){
            cnt = cnt + 2;
        }else if(a[i] % 2 == 0){
            cnt++;
        }
    }
 
    if(cnt >= N/2*2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
 
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

class Main {

	public static void main(String args[]){

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int x[] = new int[n];
		int low = 100,high = -100;
		for(int i =0 ; i < n; i++){
			x[i] =  scan.nextInt();
			if(x[i] >= high)high = x[i];
			if(x[i] <= low)low = x[i];
		}
		
		int cost, min = 10000000;
		for(int i = low; i <= high; i++){
			cost = 0;
			for(int j = 0; j < n; j++){
				cost += (x[j] - i)*(x[j] - i);
			}
			if(cost <= min )min = cost;
		}
		System.out.print(min);
	}

}


Measured memory_bytes: 21588
#include<iostream>
#include<string>
using namespace std;
bool isAlpha(char ch){
  return ('a'<=ch&&ch<='z');
}
string change(string str){
  for(int i=0;i<(int)str.size();i++){
    if(isAlpha(str[i])){
      if(str[i]=='z')str[i]='a';
      else str[i]++;
    }
  }
  return str;
}
string st(string str,int x,int y){
  string res="";
  for(int i=x;i<x+y;i++)res.push_back(str[i]);
  return res;
}
int main(){
  string str;
  string a ="abcdefghi";
  int flg;
  while(getline(cin,str)){
    flg=0;
    for(int i=0;i<26;i++){
      str=change(str);
      for(int j=0;j+3<=(int)str.size();j++)
	if(st(str,j,3)=="the")flg=1;
      if(flg)break;
      for(int j=0;j+4<=(int)str.size();j++)
	if(st(str,j,4)=="this")flg=1;
      if(flg)break;
      for(int j=0;j+4<=(int)str.size();j++)
	if(st(str,j,4)=="that")flg=1;
      if(flg)break;
    }
    cout<<str<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int n, m;
string buf;
map<string, int> cost, memo;
map<string, vector<string>> mat;

int dfs(string s) {
  if (memo.find(s) != memo.end()) return memo[s];
  if (mat.find(s) == mat.end()) return memo[s] = cost[s];
  int res = 0;
  for (string t : mat[s]) {
    res += dfs(t);
  }
  return memo[s] = min(cost[s], res);
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> n, n) {
    memo.clear();
    cost.clear();
    mat.clear();
    for (int i = 0; i < n; i++) {
      string s;
      int p;
      cin >> s >> p;
      cost[s] = p;
    }
    cin >> m;
    for (int i = 0; i < m; i++) {
      string o;
      int k;
      cin >> o >> k;
      for (int i = 0; i < k; i++) {
        string q;
        cin >> q;
        mat[o].emplace_back(q);
      }
    }
    string t;
    cin >> t;
    cout << dfs(t) << endl;
  }

  return 0;
}


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>

using namespace std;

const int MAX = 100010;
bool isprime[MAX];
void eratos(int N){
    fill(isprime, isprime+MAX, true);
    isprime[0] = isprime[1] = false;
    for(int i=2;i<sqrt(N);i++){
        if(isprime[i]){
            int j = 2*i;
            while(j <= N){
                isprime[j] = false;
                j += i;
            }
        }
    }
}

bool isSimilar(int n){
    if(n%2 == 0) return false;
    return isprime[n] && isprime[(n+1)/2];
}

int main(){
    long long num[MAX];
    fill(num,num+MAX,0);
    eratos(MAX);
    for(int i=0;i<MAX;i++){
        if(isSimilar(i)){
            num[i]++;
        }
    }
    for(int i=1;i<MAX;i++){
        num[i] = num[i] + num[i-1];
    }

    int Q; cin >> Q;
    for(int i=0;i<Q;i++){
        int l,r;
        cin >> l >> r;
        cout << num[r] - num[l-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1536
n,m=map(int,input().split())
a=list(map(int,input().split()))
k=[[i,1] for i in a]

for i in range(m):
    b,c=map(int,input().split())
    k+=[[c,b]]
    


kli=sorted(k,reverse=True)
count=0
for i in kli:
    if n-i[1]>=0:
        count+=i[0]*i[1]
        n+=-i[1]
    else:
        count+=i[0]*n
        n=0
    if n==0:
        break


print(count)

Measured memory_bytes: 36228
import sys
from collections import Counter

n, *S = sys.stdin.read().split()
n = int(n)

def main():
    t = [''.join(sorted(t)) for t in S]
    c = Counter(t)
    cnt = 0
    for v in c.values():
        cnt += v*(v-1)
    print(cnt//2)

main()


Measured memory_bytes: 28296
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    ll j, sum = 0, k = 0;
    string s; char x;
    cin >> s;
    vector <ll> v(s.size() + 1);
    v.push_back(0);

    for(ll i = 0; i < s.size(); i++) {
        x = s[i];
        j = i + 1;

        if(x == '<') {
            v[j] = v[j - 1] + 1;
        }
        else {
            k = 0;
            for(ll q = i; q < s.size(); q++)
                if(s[q] == '>')
                    k++;
                else
                    break;

            for(ll z = 0; z < k; z++)
                v[j + z] = k - 1 - z;

            if(v[j] >= v[j - 1]) {
                v[j - 1] += v[j] - v[j-1] + 1;
            }

            i += k - 1;
        }
    }

    /*cout << v[0] << " ";
    for(ll i = 0; i < s.size(); i++) {
        cout << s[i] << " " << v[i+1] << " ";
    }*/

    for(auto x : v) {
        sum += x;
    }

    cout << sum;
    return 0;
}

Measured memory_bytes: 10756
#include<iostream>

using namespace std;

int main(){
  int N;
  bool flag=false;
  cin >> N;

  while(N) {
    int a;
    a = N%10;
    if (a==7) flag = true;
    N /= 10;
  }

  cout << (flag?"Yes":"No") << endl;
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};

signed main(){
    int A, B;
    cin >> A >> B;
    PRINT((B % A == 0) ? A + B : B - A);
    return 0;
}

Measured memory_bytes: 256
num = int(input())
num_digit = len(str(num))

if num_digit == 1:
    print(num)
elif num_digit == 2:
    print(9)
elif num_digit == 3:
    print(9 + (num - 100 + 1))
elif num_digit == 4:
    print(909)
elif num_digit == 5:
    print(909 + (num - 10000 + 1))
elif num_digit == 6:
    print(90909)

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var l string
	s := bufio.NewScanner(os.Stdin)
	s.Scan()
	l = s.Text()

	for i := 0; i < len(l); i++ {
		fmt.Print(string(conv(l[i])))
	}
	fmt.Println()
}

func conv(n byte) byte {
	if n >= 65 && n <= 90 { // A to Z
		return n + 32 // A(65) から Z(90) の場合は a(97) から z(122) に変換
	}
	if n >= 97 && n <= 122 { // a to z
		return n - 32
	}
	return n
}



Measured memory_bytes: 1092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;
#define rep(i,n) for(int i=0;i<(n);i++)
const int MOD = 1000000007;

int main() {
  int a, b;
  cin >> a >> b;
  if(a + b < 25) {
    int ans = a + b == 24 ? 0 : a + b;
    cout << ans << endl;
  } else {
    cout << a + b - 24 << endl;
  }
}

Measured memory_bytes: 256
n,m = map(int,input().split())
ag = []
for i in range(n):
    ag.append(list(input()))
bg = []
for i in range(m):
    bg.append(list(input()))
for i in range(n-m+1):
    for j in range(n-m+1):
        u = []
        for k in range(m):
            u.append(ag[j+k][i:i+m])
        if u == bg:
            print("Yes")
            exit()
print("No")





Measured memory_bytes: 9192
#include<iostream>
#include<vector>

using namespace std;

#define rep(i,a) for(int i = 0 ; i < a ; i ++)

int main(void){
  int n,k;
  while(cin>>n>>k,n+k){
    vector<int> a(n);

    rep(i,n)cin>>a[i];
    int ret = -100000;
    int sum = 0;
    rep(i,k)sum += a[i];
    for(int i = k ; i < n ; i ++){
      sum = sum + a[i] - a[i-k];
      ret = max(ret,sum);
    }
    cout<<ret<<endl;
  }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

// 約数を求める
vl divisor(ll n){
	vl res;
	for(ll i=1; i*i<=n; ++i){
		if(n%i==0){
			res.push_back(i);
			if(i!=n/i){
				res.push_back(n/i);
			}
		}
	}
	return res;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	ll n;
	cin>>n;
	vl res=divisor(n);
	ll ans=0;
	for(auto x : res){
		if(x==1){
			continue;
		}
		if(x*(n/(x-1))==n){
			ans+=x-1;
		}
	}
	cout<<ans<<'\n';
	return 0;
}


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

int main(){
	int N;
	int a[200001];
	int b[200001];
	cin >> N;
	
	int flag = 0;
	
	for(int i = 1; i <= N; i++){
		cin >> a[i];
	}
	
	for(int i = N / 2 + 1; i <= N; i++){
		b[i] = a[i];
	}
	
	for(int i = N / 2; i > 0; i--){
		int sum = 0;
		//sum of b[2*i], b[3*i], ...
		for(int j = 2; i*j <= N; j++){
			sum += b[i*j];
		}
		int remainder = sum % 2;
		if (a[i] == 0){
			b[i] = remainder;
		}else { //a[i]==1
			b[i] = (remainder + 1) % 2;
		}
	}
	
	int cnt = 0;
	
	for(int i = 1; i <= N; i++){
		if( b[i] == 1 ) cnt++;
	}
	cout << cnt << endl;
	for(int i = 1; i <= N; i++){
		if( b[i] == 1 ){ 
			if(cnt != 1) cout << i << " ";
			else cout << i << endl;
			cnt--;
		}
	}
}

Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>

namespace ABC168
{

  class B
  {
  public:
    B() = default;
    ~B() = default;


    void Run()
    {

      std::string S;
      int K= 0;
      std::cin >> K;
      std::cin >> S;

      std::string answer = S;
      if (S.length() > K)
      {
        answer = S.substr(0, K);
        answer.append("...");
      }
        

      std::cout << answer << std::endl;
    }
  };

}
int main()
{

  ABC168::B prob;
  prob.Run();

  return 0;
}




Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define fastio      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int N = 1e6 + 6;

int main()  {
    fastio;
    string s;
    cin>>s;
    s += 'S';
    int cnt = 0;
    int ans = 0;
    for(int i= 0 ; i < s.size() ; i++ ) {
        if(s[i] =='S') {
            ans = max(ans , cnt);
            cnt = 0;
        }
        else cnt++;
    }
    cout<<ans<<'\n';
    return 0;
}

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

#define int long long

int V;

#define INF LONG_MAX
#define MAX_V 100000

using P = pair<int, int>;


struct edge {
        int to;
            int cost;
};

vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

signed main() {
    cin >> V;
    for(int i=0; i<V-1; ++i) {
        signed a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        edge e = {b, c};
        G[a].push_back(e);
        e = {a, c};
        G[b].push_back(e);
    }

    int q, k;
    cin >> q >> k;
    k--;
    dijkstra(k);
    int x, y;
    for(int j=0; j<q; ++j) {
        cin >> x >> y;
        x--;
        y--;
        cout << d[x] +d[y] << endl;
    }
    return 0;
}



Measured memory_bytes: 11120
n = int(input())
b = list(map(int, input().split()))

a = []
flg = True
while b:
    for i in range(len(b), 0, -1):
        if b[i-1] == i:
            a.append(b.pop(i-1))
            break
        elif i == 1:
            flg = False
            break
    if not flg:
        break
a.reverse()
a = [str(i) for i in a]
print('\n'.join(a)) if flg else print(-1)

Measured memory_bytes: 9112
while True:
    m,f,r = map(int,input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f ==-1:
        print('F')
    if m != -1 and f!=-1:
        if m+f >= 80:
            print('A')
        elif 65<=m+f<80:
            print('B')
        elif 50 <= m+f < 65 or r>=50:
            print('C')
        elif 30 <= m+f <50:
            print('D')
        elif m+f<30:
            print('F')


Measured memory_bytes: 5592
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
from functools import reduce

# 0がある場合はもう片方を出力
def gcd(a, b):  
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    r = a % b
    return gcd(b, r)

def gcd_list(numbers):
    return reduce(gcd, numbers)
    

N = ii()
A = li()

print(gcd_list(A))

Measured memory_bytes: 20252
#include<bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<vi > vvi;
typedef std::vector<vll > vvll;
typedef std::pair<int,int> ii;
typedef std::pair< ll, ll > lp;
typedef std::vector<ii> vii;
typedef std::vector<vii > vvii;


#define pb push_back 
#define PB pop_back
#define pf push_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)
#define lb(a,b) lower_bound(all(a),b)
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) f(i,0,n-1)cin>>a[i]
#define in1(a,n) f(i,1,n)cin>>a[i]
#define out(a,n) f(i,0,n-1)cout<<fixed<<setprecision(20)<<a[i]<<" ";cout<<"\n"
#define ff first
#define ss second
#define f(i,a,b) for (int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,n) f(i,0,n-1)
#define clr(a) (a).clear()
#define rz resize
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin() ,(a).rend()
#define endl '\n'

int main(int argc, char const *argv[])
{
	crap;
	int n,m;
	string s,t;
	cin>>s>>t;
	n=s.length();
	m=t.length();
	int dp[1+n][1+m];
	dp[0][0]=0;
	f(i,1,n)
		dp[i][0]=0;
	f(i,1,m)
		dp[0][i]=0;

	f(i,1,n)
	{
		f(j,1,m)
		{
			if (s[i-1]==t[j-1])
				dp[i][j]=1+dp[i-1][j-1];
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}

	//constructing the string 
	int i=n,j=m;
	string p;
	while (i>0 && j>0)
	{
		if (s[i-1]==t[j-1])
		{
			p+=s[i-1];
			i--,j--;
		}

		else
		{
			if (dp[i-1][j]>dp[i][j-1])
				i--;
			else
				j--;
		}
	}

	for (int k=p.length()-1;k>=0;k--)
		cout<<p[k];

	// cout<<endl;

	return 0;
}

Measured memory_bytes: 35456
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double r = scanner.nextDouble();

        double area = Math.PI * r * r;
        double perimeter = 2 * Math.PI * r;

        System.out.printf("%f %f", area, perimeter);
        scanner.close();
    }
}



Measured memory_bytes: 28000
h,w = (int(x) for x in input().split())
field = [[int(i) for i in input().split()] for i in range(h)] 
ans = []

for i in range(h):
  if(i%2 == 0):
    for j in range(w):
      if(field[i][j] %2 == 1):
        if(j != w-1):
          field[i][j+1] += 1
          ans.append([i+1, j+1, i+1, j+2])
        else:
          if(i != h-1):
            field[i+1][j] += 1
            ans.append([i+1, j+1, i+2, j+1])
  else:
    for j in range(w-1, -1, -1):
      if(field[i][j] %2 == 1):
        if(j != 0):
          field[i][j-1] += 1
          ans.append([i+1, j+1, i+1, j])
        else:
          if(i != h-1):
            field[i+1][j] += 1
            ans.append([i+1, j+1, i+2, j+1])

print(len(ans))
for i in range(len(ans)):
  print(" ".join(map(str,ans[i])))


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

//ライブラリ始まり

//定数

//円周率
const double PI = 3.1415926535897932384;

//天井
const int INF = 1000000000; // = 10^9
const int64_t LINF = 1000000000000000; // = 10^15

//関数

//ctoi
int ctoi(char c){
  if (c == '0') {
    return 0;
  }
  if (c == '1') {
    return 1;
  } 
  if (c == '2') {
    return 2;
  } 
  if (c == '3') {
    return 3;
  }
  if (c == '4') {
    return 4;
  } 
  if (c == '5') {
    return 5;
  } 
  if (c == '6') {
    return 6;
  }
  if (c == '7') {
    return 7;
  } 
  if (c == '8') {
    return 8;
  } 
  if (c == '9') {
    return 9;
  }
  return -1;  
}

//素数判定
bool PN(int x) {
  if (x <= 1) {
    return false;
  }
  if (x == 2) {
    return true;
  }
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

//ライブラリ終わり
 
int main() {
  int N;
  cin >> N;
  if (N >=1200) {
    cout << "ARC" << endl;
  }
  else {
    cout << "ABC" << endl;
  }
}


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

int main(){
    int N;
    char ch;
    int p = 0;
    int w = 0;
    int g = 0;
    int y = 0;

    cin >> N;

    rep(i, N)
    {
        cin >> ch;
        switch(ch){
            case 'P':
                p = 1;
                break;
            case 'W':
                w = 1;
                break;
            case 'G':
                g = 1;
                break;
            case 'Y':
                y = 1;
                break;
        }
    }

    if ((p + w + g + y) == 3){
        cout << "Three" << endl;
    }else{
        cout << "Four" << endl;
    }

    return 0;
}

Measured memory_bytes: 3584
#include <iostream>

using namespace std;

typedef long long ll;

// return x^n % mod
ll mod_pow(ll x, ll n, ll mod) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) {
      ret *= x;
      ret %= mod;
    }
    x = x*x % mod;
    n >>= 1;
  }
  return ret;
}

int main() {
  int m, n;
  const int mod = 1000000007;

  cin >> m >> n;
  cout << mod_pow(m, n, mod) << endl;

  return 0;
}


Measured memory_bytes: 3100
/**
 *   author: Shubham Srivastava
 *   created: 01 March 2020  20:05:02
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define MOD 1000000007
#define INF 0x7fffffff
#define sorti(v) sort(v.begin(),v.end())
#define sortd(v) sort(v.rbegin(),v.rend())
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
ll parent[2000005];
vector <ll> size(200005,0);
vector <ll> vis(200005,0);
set <ll> node[200005];
void dfs(ll n,ll count){
	vis[n] = count;
	size[count]++;
	for(auto i : node[n]){
		if(vis[i]==0){
			dfs(i,count);
		}
	}
}

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n,m,k;cin>>n>>m>>k;
    vector <ll> block(n+1);
    for(int i=0;i<m;i++){
    	ll a,b;cin>>a>>b;
    	node[a].insert(b);
    	node[b].insert(a);
    }
    ll count = 0;
    for(int i=1;i<=n;i++){
    	if(vis[i]==0){
    		count++;
    		dfs(i,count);
        }
    }
    vector <ll> node2[n+1];
    for(int i=0;i<k;i++){
    	ll a,b;cin>>a>>b;
    	node2[a].push_back(b);
    	node2[b].push_back(a);
    	if(vis[a] == vis[b] && node[a].find(b) != node[a].end()){
    		block[a]++;
    		block[b]++;
    	}
    	else if(vis[a] != vis[b]){
    		block[a]++;block[b]++;
    	}
    }
    for(int i=1;i<=n;i++)
    	cout<<size[vis[i]]-node[i].size()-node2[i].size()+block[i]-1<<" ";
return 0;
}

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

// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */


int main(){
    Bint x;
    Bint k;
    Bint d;
    cin >> x;
    cin >> k;
    cin >> d;
    
    Bint e;
    
    x = abs(x);
    
    if(x >= k*d){
      //printf("1\n");
        cout << (x - k*d) << endl;
    }else{
        e = x / d;
        k = k - e;
        if(k%2==0){
          //printf("2\n");
            cout << x - e*d << endl;
        }else{
          //printf("3\n");
            cout << abs(x - (e+1)*d) <<endl;
        }
    }
    
    
}

Measured memory_bytes: 3672
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def prepare(n, MOD):
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


def main():
    n, k = ns()
    print(0 if n > k else 1)


if __name__ == '__main__':
    main()



Measured memory_bytes: 7304
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::*;
use std::collections::*;
use std::ops::*;
use procon::*;
use self::Cell::*;

#[derive(Clone, Copy)]
enum Cell {
    White,
    Black,
}

pub fn main() {
    let (W, B) = {
        let x = read_words::<i32>();
        (x[0], x[1])
    };

    let mut board = vec![vec![White; 100]; 100];
    for y in 0..100 {
        for x in 50..100 {
            board[y][x] = Black;
        }
    }

    let mut w = W - 1;
    let mut b = B - 1;
    for yi in 0..50 {
        for xi in 0..25 {
            {
                let y = yi * 2;
                let x = xi * 2;
                if b > 0 {
                    board[y][x] = Black;
                    b -= 1;
                }
            }

            {
                let y = yi * 2;
                let x = 51 + xi * 2;
                if w > 0 {
                    board[y][x] = White;
                    w -= 1;
                }
            }
        }
    }

    println!("100 100");
    for row in board {
        let line = row.into_iter()
            .map(|c| match c {
                White => '.',
                Black => '#',
            })
            .collect::<String>();
        println!("{}", line);
    }

    return;
}

pub mod procon {
    use std;
    use std::collections::*;
    use std::io;
    use std::mem;
    use std::str::FromStr;

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

    pub fn read_words<T>() -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.split_whitespace()
            .map(|word| T::from_str(word).unwrap())
            .collect()
    }

    pub fn read_vec(len: usize) -> Vec<String> {
        let mut vec = Vec::new();
        while vec.len() < len {
            let line = read_line();
            for word in line.split_whitespace() {
                vec.push(word.to_owned());
            }
        }
        assert!(vec.len() == len);
        vec
    }
}


Measured memory_bytes: 4352
x, k, d = map(int, input().split())

if x == 0:
    print(0 if k % 2 == 0 else d)
elif x > 0:
    p = x // d
    if p >= k:
        print(x - k * d)
    else:
        q = 0 if (k-p) % 2 == 0 else 1
        print(abs(x - ((p+q) * d)))
else:
    p = abs(x) // d
    if p >= k:
        print(abs(x + k * d))
    else:
        q = 0 if (k-p) % 2 == 0 else 1
        print(abs(x + ((p+q) * d)))


Measured memory_bytes: 9196
# ABC112C - Pyramid
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    l = sorted(
        [tuple(map(int, input().rstrip().split())) for _ in range(n)],
        key=lambda x: x[2],
        reverse=True,
    )
    for x in range(0, 101):
        for y in range(0, 101):
            i, j, k = l[0]
            h = k + abs(i - x) + abs(j - y)
            for i, j, k in l[1:]:
                if k != max(h - abs(i - x) - abs(j - y), 0):
                    break
            else:
                print(x, y, h)
                break
        else:
            continue
        break


if __name__ == "__main__":
    main()

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<long long> p(N);
  for(int i=0;i<N;++i) cin >> p[i];
  long long ans=K,max=0;
  for(int i=0;i<K;++i) ans+=p[i];
  max=ans;
  for(int i=K;i<N;++i){
    ans+=p[i]-p[i-K];
    if(ans>max) max=ans;
  }
  cout <<fixed << setprecision(6)<< max/2.0 << endl;
}
  

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n,i;
    cin >> n >> i;
    cout << n - i + 1 << endl;
    return 0;
}


Measured memory_bytes: 256