akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T> inline T gcd(T&a,T&b){return b==0?a:gcd(b,a%b);}
template<typename T> inline T lcm(T&a,T&b){return a/gcd(a,b)*b;}
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
int n,a[maxn],tt=0;
map<int,int>mp;
int main(){
    read(n);
    for (int i=1;i<=n;i++) read(a[i]);
    sort(a+1,a+1+n);
    int cnt=0,pre=0;
    for (int i=1;i<=n;i++) mp[a[i]]++,tt=max(tt,mp[a[i]]);
    int pos=unique(a+1,a+1+n)-(a+1);
    int sum=-1;
    for (int i=3;i<=n;i++){
        int tmp;
        if (a[i]==a[i-1]+1 && a[i-1]==a[i-2]+1){
            tmp=mp[a[i]]+mp[a[i-1]]+mp[a[i-2]];
            sum=max(sum,tmp);
        }
    }
    for (int i=2;i<=n;i++){
        int tmp;
        if (a[i]==a[i-1]+1){
            tmp=mp[a[i]]+mp[a[i-1]];
            sum=max(sum,tmp);
        }
    }
    if (sum==-1) printf("%d\n",tt);
    else cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3584
n=int(input())
l=list(map(int,input().split()))
res=1
f=1
if(0 in l):
    print(0)
    f=0
if(f==1):
    
    for x in l:
        res=res*x
        if(res>1000000000000000000):
            print(-1)    
            f=0
            break
    
    if(f==1):
        print(res)

    
        
    
    


Measured memory_bytes: 21672
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

typedef pair<int, int> P;

int main(){
	
	int n;
	
	while(true){
		cin >> n;
		
		if(n == 0){
			break;
		}
		
		vector<P> v_a, v_b;
		
		for(int loop = 0; loop < n; loop++){
			int m, a, b;
			cin >> m >> a >> b;
			P p_a, p_b;
			p_a.first = a;
			p_a.second = m;
			p_b.first = b;
			p_b.second = m;
			v_a.push_back(p_a);
			v_b.push_back(p_b);
		}
		
		sort(v_a.begin(), v_a.end());
		sort(v_b.begin(), v_b.end());
		
		int index_b = 0;
		
		int sum = 0;
		
		bool safe = true;
		
		for(int i = 0; i < n; i++){
			int cur = v_a[i].first;
			sum += v_a[i].second;
			while(true){
				if(v_a[i].first < v_b[index_b].first){
					break;
				}
				
				sum -= v_b[index_b].second;
				
				index_b++;
			}
			//cout << sum << " ";
			if(sum > 150){
				safe = false;
				break;
			}
		}
		//cout << endl;
		
		if(safe){
			cout << "OK" << endl;
		}else{
			cout << "NG" << endl;
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 3116
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int A, B, C;
	cin >> A;
	cin >> B;
	cin >> C;
	if (A == B)
	{
		cout << C << endl;
	}
	else if (A == C)
	{
		cout << B << endl;
	}
	else if (B == C)
	{
		cout << A << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int cnt=0;
string t,s;
signed main()
{
	cin>>t>>s;
	rep(i,3){
		if(t[i]==s[i]){
			cnt++;
		}
	}
	cout<<cnt;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iterator>
#include <typeinfo>
using namespace std;


// define list


namespace  math{
    const double PI = 3.14;
    const int INF = 1000000007;
    int GCM(int a,int b); //最大公約数
    int LCM(int a,int b); //最小公倍数
    int Pemu(int n,int r); //順列
    int Comb(int n,int m); //組み合わせ
    int Digit(int N); //桁和
    
    int GCM(int a,int b){
        if(a<b){
            swap(a,b);
        }
        int r = a%b;
        while (r!=0)
        {
            a=b;
            b=r;
            r=a%b;
        }
        return b;
    }

    int LCM(int a,int b){
        return a*(b/GCM(a,b));
    }

    int Pemu(int n,int r){
        int ans = n;
        for(int i=1;i<r;i++){
            ans*=(ans-i);
        }
        return ans;
    }

    int Comb(int n,int m){
        int a=n,b=m;
        for(int i=1;i<m;i++){
            a *= (a-i);
        }
        for(int i=1;i<m;i++){
            b *= (b-i);
        }
        
        return a/b;
    }

    int Digit(int N){
        if(N<10){
            return N;
        }
        int r = 0;
        while (N>=10)
        {
            r += (N%10);
            N /= 10;
        }
        r += N;
        return r;
    }
}

namespace SubLib{
    #define int long long
    #define double long double
    #define incin(n) int (n); cin >> (n);
    #define strcin(s) string (s); cin >> (s);
    #define incin2(a,b) int a,b; cin >> a >> b; 
    #define rap(n,i) for(int (i) = 0;i<(n);(i)++)
    #define input(n,v) (v) = SubLib::Input((n),(v))
    #define all(v) (v).begin(),(v).end()
    using intv = vector<int>;
    using strv = vector<string>;
    using charv = vector<char>;
    template <class T1>
    using pvec = vector<pair<T1,T1>>;
    template <typename T> vector<T> Input(int n,vector<T> v){
        for(int i=0;i<n;i++){
            cin >> v.at(i);
        }
        return v;
    }
}

using namespace math;
using namespace SubLib;

signed main(){
    incin2(h,w);
    string wall;
    for(int i=0;i<w+2;i++){
        wall += ".";
    }
    strv s(h+2);
    s[0]=wall;
    for(int i=1;i<=h;i++){
        cin >> s.at(i);
        s[i].insert(s[i].begin(),'.');
        s[i].push_back('.');
    }
    s[h+1]=wall;
    int map[h+2][w+2];
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            map[i][j]=0;
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(s[i][j]!='#'){
                for(int a=-1;a<=1;a++){
                    for(int b=-1;b<=1;b++){
                        if(a==0 && b==0){
                            continue;
                        }else{
                            if(s[i+a][j+b]=='#'){
                                map[i][j]++;
                            }
                        }
                    }
                }
            }
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(s[i][j]=='#'){
                cout<<'#';
            }else{
                cout<<map[i][j];
            }
        }
        cout<<'\n';
    }
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
cnt_A = Counter(A)
# print(cnt_A)

kouho = []

ans = 0

for key in cnt_A:
    if cnt_A[key] >= 2:
        kouho.append(key)
    if cnt_A[key] >= 4:
        ans = max(ans, key ** 2)

if len(kouho) < 2:
    print(ans)
    exit()

kouho.sort()
ans = max(ans, kouho[-1] * kouho[-2])
print(ans)


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

namespace CSharpSample01
{

    

    class Program
    {
        
        


        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for(int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                int year = int.Parse(input[0]);
                int month = int.Parse(input[1]);
                int day = int.Parse(input[2]);

                long sum_day = 0;

                //year + 1年, 1月, 1日にする
                if(year % 3 == 0)
                {

                    sum_day += 20 - day + 1;

                    if (month < 10)
                    {
                        month++;
                    }
                    else
                    {
                        month = 1;
                    }

                    if(month != 1)
                    {
                        sum_day += (10 - month + 1) * 20;
                    }

                }
                else
                {
                    if (month % 2 == 0)
                    {
                        sum_day += 19 - day + 1;
                    }
                    else
                    {
                        sum_day += 20 - day + 1;
                    }
                    
                    if(month < 10)
                    {
                        month++;
                    }
                    else
                    {
                        month = 1;
                    }

                    if(month != 1)
                    {
                        for (int m = month; m <= 10; m++)
                        {
                            if (m % 2 == 0)
                            {
                                sum_day += 19;
                            }
                            else
                            {
                                sum_day += 20;
                            }
                        }
                    }
                    
                }

                year++;

                for(int y = year; y < 1000; y++)
                {
                    if (y % 3 == 0)
                    {
                        sum_day += 10 * 20;
                    }
                    else
                    {
                        sum_day += 10 * 20 - 5;
                    }
                }
                
                
                Console.WriteLine(sum_day);

            }
            
        }
    }
}


Measured memory_bytes: 15780
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807/2;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
int d[210][210];
int dd[210];
vector<int> v[210];
void warshall_floyd(){
	for(int k=0;k<n;k++)
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
}
bool tree_make(){
	queue<int> q;
	q.push(0);
	dd[0]=-1;
	while(q.size()){
		int t=q.front();q.pop();
		for(int i=0;i<v[t].size();i++){
			if(dd[v[t][i]]==0){
				dd[v[t][i]]=dd[t]*(-1);
				q.push(v[t][i]);
			}else{
				if(dd[t]==dd[v[t][i]])return false;
			}
		}
	}
	return true;
}
	
int main(){
	cin>>n;
	REP(i,n){
		REP(j,n){
			
			char s;
			cin>>s;
			if(i==j)continue;
			if(s=='1'){
				d[i][j]=1;
				d[j][i]=1;
				v[i].push_back(j);
				v[j].push_back(i);
			}else{
				d[i][j]=INF;
				d[j][i]=INF;
			}
		}
	}
	if(!tree_make()){
		cout<<-1<<endl;
		return 0;
	}
	warshall_floyd();
	int ans=0;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++){
			if(d[i][j]!=INF)ans=max(ans,d[i][j]+1);
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 768
// -*- coding:utf-8-unix -*-

use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        l: [usize; n],
    }
    let mut ans: usize = 0;
    for i in 1..=n {
        for j in (i + 1)..=n {
            for k in (j + 1)..=n {
                if l[i - 1] == l[j - 1] || l[j - 1] == l[k - 1] || l[k - 1] == l[i - 1] {
                    continue;
                }
                let sum = l[i - 1] + l[j - 1] + l[k - 1];
                let max = l[i - 1].max(l[j - 1]).max(l[k - 1]);
                if max < sum - max {
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2204
#include<stdio.h>
#include<string.h>
int main(){
    int count=0,i;
    char W[12],end[12]="END_OF_TEXT";
    char T[1003]={'\0'};
    
    scanf("%s",W);
    while(1){
        scanf("%s",T);
        if(strcmp(T,end)==0){
            break;
        }
        for(i=0;i<strlen(T);i++){
            if(T[i]>=65&&T[i]<=90){
                T[i]+=32;
            }
        }
        if(strcmp(T,W)==0){
           count++;
        }
    }

    printf("%d\n",count);
    
    return 0;
}



Measured memory_bytes: 2048
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

void reader(int &a) { scanf("%d", &a); }
void reader(double &a) { scanf("%lf", &a); }
void reader(char a[]) { scanf("%s", a); }
void reader(char &a) { scanf(" %c", &a); }
void reader(ll &a) { scanf("%lld", &a); }
void reader(ull &a) { scanf("%llu", &a); }
// void reader(string& a){cin >> a;};
template<class T, class U> void reader(T& t, U& u) { reader(t); reader(u); }
template<class T, class U, class V> void reader(T& t, U& u, V& v) { reader(t); reader(u); reader(v); }

void writer(const int a, char c) { printf("%d", a); putchar(c); }
void writer(const ll a, char c) { printf("%lld", a); putchar(c); }
void writer(const ull a, char c) { printf("%llu", a); putchar(c); }
void writer(const double a, char c) { printf("%.20lf", a); putchar(c); }
void writer(const char a[]) { printf("%s", a); };
void writer(const char a[], char c) { printf("%s", a); putchar(c); };
void writer(const char a, char c) { putchar(a); putchar(c); };
template<class T> void writerLn(T t) { writer(t, '\n'); }
template<class T, class U> void writerLn(T t, U u) { writer(t, ' '); writer(u, '\n'); }
template<class T, class U, class V> void writerLn(T t, U u, V v) { writer(t, ' '); writer(u, ' '); writer(v, '\n'); }
template<class T> void writerArr(T x[], int n) { int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }
template<class T> void writerVec(vector<T> x) { int n = x.size(); int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }

vector<string> split(const string &str, char sep) { vector<string> v; stringstream ss(str); string buffer; while (getline(ss, buffer, sep)) { v.push_back(buffer); }return v; }
// #define int ll
bool test = 1;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define MAX 300000
//.....................
ull mod = (int)1e9 + 7;

signed main(void)
{
	while (1) {
		int N, A, B, C, X;
		int Y[100];
		reader(N, A, B);
		reader(C, X);
		rep(i, N) {
			cin >> Y[i];
		}
		if (N == 0) break;
		ll now = X;
		int cnt = 0;
		int res = 0;
		rep(i, 10001) {
			if (Y[cnt] == now) {
				cnt++;
			}
			if (cnt == N) {
				res = i;
				break;
			}
			now = (A*now + B) % C;
		}
		if (cnt == N) cout << res << endl;
		else puts("-1");
	}
	return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
using namespace std;
#define fastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define stk             stack<ll>
#define que             queue<ll>
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define rev             reverse
#define Y               "YES"
#define N               "NO"
#define br              "\n"
#define sp              " "
#define debug(x)        cout << #x << " : " << x << endl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;


// ====== int_1024t begins ======
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// ====== int_1024t ends ======

inline ll add(ll a, ll b) {return ((a % mod) + (b % mod)) % mod;}
inline ll sub(ll a, ll b) {return ((a % mod) - (b % mod) + mod) % mod;}
inline ll mul(ll a, ll b) {return ((a % mod) * (b % mod)) % mod;}
ll pwr(ll x, ll n) {
	x = x % mod;
	if (!n) return 1;
	if (n & 1) return mul(x, pwr(mul(x, x), (n - 1) / 2));
	else return pwr(mul(x, x), n / 2);
}
// O(nlogn) for [1,n]
ll modinv(ll n) {
	return pwr(n, mod - 2);
}
// O(logn) for[1,n]
ll inv(ll i) {
	if (i == 1) return 1;
	return (MOD - (MOD / i) * inv(MOD % i) % MOD) % MOD;
}
// =============================

string ok = "";

void solve()
{

	string s1, s2;
	cin >> s1 >> s2;
	int m = s1.length();
	int n = s2.length();
	int ans[m + 1][n + 1];
	for (int i = 0; i <= m; i++)
	{
		for (int j = 0; j <= n; j++)
		{
			if (i == 0 || j == 0)
				ans[i][j] = 0;

			else if (s1[i - 1] == s2[j - 1])
				ans[i][j] = ans[i - 1][j - 1] + 1;

			else
				ans[i][j] = max(ans[i - 1][j], ans[i][j - 1]);

		}
	}
	int i = m, j = n;
	while (i > 0 && j > 0)
	{
		if (s1[i - 1] == s2[j - 1])
		{
			ok += s1[i - 1];
			i--; j--;
		}
		else
		{
			if (ans[i - 1][j] > ans[i][j - 1])
			{
				i--;
			}
			else
				j--;
		}
	}
	reverse(ok.begin(), ok.end());
	cout << ok << endl;

}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t;
	// cin >> t;
	// while (t--)
	// {
	solve();
	// }

	return 0;
}

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

using namespace std;

int main(){
  int K;
  cin >> K;
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << a[K-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
  string data;
  int n;
  cin>>data>>n;
  while (n--){
    string order,p; int a,b;
    cin>>order>>a>>b;
    if (order=="replace"){
      cin>>p;
      data.replace(a,b-a+1,p);
    }
    else if(order=="reverse") reverse(begin(data)+a,begin(data)+b+1);
    else if  (order=="print") cout<<data.substr(a,b-a+1)<<endl;
  }
    return 0;
}

Measured memory_bytes: 1220
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A[] = new int[N];
        int count = 0;
		for(int i = 0;i < N; i++){
          A[i] = sc.nextInt();
          while(A[i] % 2 == 0){
            A[i] = A[i]/2;
            count += 1;
          }
        }
		 System.out.println(count);            
    }
}

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

using namespace std;

#pragma GCC optimize "-O3"

#define watch(x) cout << (#x) << " is " << (x) << endl

#define rep(i,a,b)  for(lli i=a;i<b;i++)
#define repd(i,a,b) for(lli i=a-1;i>=b;i--)
#define nl          cout<<endl;
#define test()      lli t;cin>>t;while(t--)
#define sp(n)       setprecision(n)

#define lli     long long int
#define ulli    unsigned long long int
#define ld      long double
#define uld     unsigned long double
#define S       string
#define C       char
#define elif    else if

#define pb      push_back
#define pp      pop_back
#define mp      make_pair
#define plli    pair<lli,lli>
#define vlli    vector<lli>
#define vulli   vector<ulli>
#define vld     vector<ld>
#define vs      vector<string>

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define vsort(v) sort(v.begin(),v.end())

#define max1 1000001    //10^6 + 1
#define max2 10000001   //10^7 + 1
#define max3 1000000007 //10^9 + 7
#define inf  1000000009 //10^9 + 9


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    lli n;
    cin>>n;
    lli h[n+1];
    rep(i,1,n+1)
    {
        cin>>h[i];

    }
    lli c[n+1]={0};
    c[1]=0;
    c[2]=abs(h[2]-h[1]);

    rep(i,3,n+1)
    {

        c[i]=min(c[i-1]+abs(h[i-1]-h[i]) , c[i-2]+abs(h[i-2]-h[i]));
    }

    cout<<c[n];
    nl;;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <unordered_map>
#include <vector>

using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> primes = {2, 3, 5, 7, 11, 13};
  for (int i = 17; i <= n - 1; i += 2) {
    bool is_prime = true;
    for (int j = 0; primes[j] * primes[j] <= i; ++j) {
      if (i % primes[j] == 0) {
        is_prime = false;
        break;
      }
    }
    if (is_prime)
      primes.emplace_back(i);
  }
  int ans = 0;
  for (int i = 1; i < n; ++i) {
    int k = i;
    int fac = 1;
    for (int j = 0; primes[j] * primes[j] <= k; ++j) {
      if (k % primes[j] == 0) {
        int cnt = 0;
        while (k % primes[j] == 0)
          cnt++, k /= primes[j];
        fac *= (cnt + 1);
      }
    }
    if (k != 1)
      fac *= 2;
    ans += fac;
  }
  cout << ans;
}

Measured memory_bytes: 3896
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
#define pb push_back 
#define mp make_pair 
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
	int n , k;
	cin >> n >> k;
	int arr[n] ;
	for(int i = 0 ; i < n ; i++)
		cin >> arr[i] ;
	int dp[n] = {0} ;
	dp[1] = abs(arr[0] - arr[1]) ;
	for(int i = 2 ; i < n; i++){
		int mn = INT_MAX ;
		for(int j = i - 1; j >= max(0 ,i - k ) ; j--){
			mn = min(mn, dp[j] + abs(arr[i] - arr[j])) ;
		}
		dp[i] = mn ;
		// dp[i] = min(dp[i - 1] + abs(arr[i] - arr[i - 1]), dp[i - 2] + abs(arr[i] - arr[ i - 2])) ;
	}	
	cout << dp[n - 1] ;
}

Measured memory_bytes: 1024
def main():
    
    a,b,c = tuple([int(t)for t in input().split()])
    k = int(input())

    for _ in range(k):
        if not b>a:
            b*=2
        elif not c>b:
            c*=2

    if c>b and b>a:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9180
#include<bits/stdc++.h>
#define N 2000009
#define ll long long
#define ld long double
#define ff first
#define ss second
#define inf 1000000005
#define mod 1000000007
using namespace std;
string s;
ll d, dp[10001][2][100];
int main() {
    cin>>s>>d;
    int n = s.size();
    dp[n][0][0] = 1;
    dp[n][1][0] = 1;
    for(int i = n - 1; i >= 0 ; i--) {
        for(int tight=0;tight<=1;tight++) {
            for(int sum=0;sum<d;sum++) {
                if(tight) {
                    for(int dig = 0; dig <= s[i] - '0' ; dig++) {
                        ll new_sum = sum - dig;
                        while(new_sum < 0)
                            new_sum += d;
                        //cout<<i<<" "<<1<<" "<<sum<<" "<<dig<<" "<<new_sum<<" "<<((dig == s[i] - '0') ? dp[i+1][1][new_sum] : dp[i+1][0][new_sum])<<endl;
                        dp[i][1][sum] += (dig == s[i] - '0') ? dp[i+1][1][new_sum] : dp[i+1][0][new_sum];
                        dp[i][1][sum] %= mod;
                    }
                }
                else {
                    for(int dig = 0; dig < 10 ; dig++) {
                        ll new_sum = sum - dig;
                        while(new_sum < 0)
                            new_sum += d;
                        //cout<<i<<" "<<0<<" "<<sum<<" "<<dig<<" "<<new_sum<<" "<<dp[i+1][0][new_sum]<<endl;
                        dp[i][0][sum] += dp[i+1][0][new_sum];
                        dp[i][0][sum] %= mod;
                    }
                }
            }
        }
    }
    cout<<((dp[0][1][0] > 0) ? (dp[0][1][0] - 1) : (mod - 1));
}


Measured memory_bytes: 19216
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) ((a>b)?a:b);
#define min(a,b) ((b>a)?a:b);
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)                                 //g++ template.cpp -o template.exe
//#define all(x) (x).begin(), (x).end()
typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn=100000;







bool sortbysec(const pair<int,int> &a,                         //sorting of elements wrt second
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 




int main()
{
	
	unsigned long long int a,i;
	long long int k=1;
	cin>>a;
	//unsigned long long int a[n];
	long  double b,sum1;
	cin>>b;
	sum1=a*b;
	cout<<(unsigned long long int)sum1;
	

	return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<ll>
#define vvll vector<vll>
#define mll map<ll,ll>
#define f(i,m,n) for(i=m;i<n;i++)
#define ee endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define take(v,n) for(i=0;i<n;i++) cin>>v[i];
#define NO() cout<<"NO"<<endl
#define YES() cout<<"YES"<<endl
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sot(v) sort(v.begin(),v.end());
bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}

void solve()
{
    ll i,j,k,l,n;
    cin>>n>>k>>j;
    n=abs(n);
    ll cnt=n/j;
    l=k;
    k-=cnt;
    //cout<<cnt<<" "<<k<<ee;
    
    // while(n>0 && k>0)
    // {
    //     n-=j;
    //     k--;
    // }
    if(k<=0)
    {
        cout<<abs(n-l*j)<<ee;
    }
    else
    {
        n-=(cnt*j);
        if(k%2==0)
        cout<<n<<ee;
        else
        cout<<abs(n-j)<<ee;
    }
}


int main() {
    fast;
    ll i,j,l,k,t,n;
    t=1;
    while(t--)
    solve();
}


Measured memory_bytes: 3684
package main

import (
	"fmt"
	"os"
)

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	var n, q int
	var s string
	fmt.Fscan(fp, &n, &q, &s)

	t := make([]string, q)
	d := make([]string, q)
	for i := 0; i < q; i++ {
		fmt.Fscan(fp, &t[i], &d[i])
	}

	l := 0
	r := n - 1
	for l <= r {
		m := (l + r) / 2
		move := 0
		for i := 0; i < q; i++ {
			if s[m+move] == t[i][0] {
				if d[i][0] == 'R' {
					move++
				} else {
					move--
				}
			}
			if m+move < 0 || m+move >= n {
				break
			}
		}
		if m+move < 0 {
			l = m + 1
		} else {
			r = m - 1
		}
	}

	deleted := 0
	if r >= 0 {
		deleted += r + 1
	}
	l = 0
	r = n - 1
	for l <= r {
		m := (l + r) / 2
		move := 0
		for i := 0; i < q; i++ {
			if s[m+move] == t[i][0] {
				if d[i][0] == 'R' {
					move++
				} else {
					move--
				}
			}
			if m+move < 0 || m+move >= n {
				break
			}
		}
		if m+move >= n {
			r = m - 1
		} else {
			l = m + 1
		}
	}
	if l < n {
		deleted += n - l
	}
	fmt.Println(n - deleted)

}

Measured memory_bytes: 12676
#include <stdio.h>
char str[10000];
int main(int argc, char const *argv[])
{
	int i = 0;
	int N;
	scanf("%d", &N);
	scanf("%s", str);
	while(str[i]!=0)
	{
		str[i] = (str[i] + N - 'A')%26 + 'A';
		i++;
	}
	printf("%s\n", str);
	return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> b(n - 1);
    for (int i = 0; i < n - 1; ++i) {
        cin >> b.at(i);
    }
    vector<int> a(n);
    a.at(0) = b.at(0);
    a.at(n - 1) = b.at(n - 2);
    for (int j = 1; j < n - 1; ++j) {
        a.at(j) = min(b.at(j - 1), b.at(j));
    }
    int amount = 0;
    for (int k : a) {
        amount += k;
    }
    cout << amount << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
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; }

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

const int MAX = 100000;

int main(){
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    for(int b = k+1; b <= n; b++){
        int p = n / b;
        int r = n % b;
        ans += p*max(b-k, 0);
        ans += max(r-k+1, 0);
    }
    if (k == 0) ans -= n;
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
using namespace std;

int main(void)
{
    bool judge = false;
    string s;
    cin >> s;
    for(int i = 0;i < s.size();i++)
    {
        if(s[i] == 'C')
        {
            for(int j = i + 1;j < s.size();j++)
            {
                if(s[j] == 'F'){judge = true;}
            }
            break;
        }
    }
    if(judge){cout << "Yes" << endl;}
    else{cout << "No" << endl;}
    return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<pll> vpl;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n;
  cin>>n;
  vpl a(n);
  REP(i,n)cin>>a[i].FI>>a[i].SE;
  sort(ALL(a),greater<pll>());
  
  ll ans=a[0].FI+a[0].SE;
  cout<<ans<<endl;
}

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

using namespace std;

int main(void)
{
  string S;
  cin >> S;

  int cnt = 0;
  for(int i = 0; i < S.size(); i++) {
    if(i == 0) {
      if(S[i] != 'A') {
        cout << "WA" << endl;
        return 0;
      }
    } else if(2 <= i && i <= S.size() - 2) {
      if(S[i] == 'C') cnt++;
      else if('A' <= S[i] && S[i] <= 'Z') {
        cout << "WA" << endl;
        return 0;
      }
    } else {
      if('A' <= S[i] && S[i] <= 'Z') {
        cout << "WA" << endl;
        return 0;
      }
    }
  }
  if(cnt == 1)
    cout << "AC" << endl;
  else 
    cout << "WA" << endl;
  return 0;
}


Measured memory_bytes: 256
import itertools
n = int(input())

x = ['A','G','C','T']

dame = ['AGC','GAC','ACG']

o = 'AGC'

for ap in x:
    dame.append(o[0]+ap+o[1:])
    dame.append(o[:-1]+ap+o[-1])


l = list(itertools.product(x,x,x))

ll = len(l)
D = 10**9+7
for i in range(ll):
    l[i] = ''+l[i][0]+l[i][1]+l[i][2]
cnt = [1]*len(l)

for i in range(3,n):
    new_cnt = [0]*ll
    for j in range(ll):
        for ap in x:
            s = l[j]+ap
            if s in dame or s[1:] in dame or s[:-1] in dame:
                continue
            else:
                new_cnt[l.index(s[1:])]+=cnt[j]
    cnt = new_cnt
    for j in range(ll):
        cnt[j] %= D
res = 0
for i in range(ll):
    if l[i] not in dame:
        res += cnt[i] 
print(res%D)


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var raw = ReadLine().Split().Select(int.Parse).ToArray();
            var N = raw[0];
            var K = raw[1];

            WriteLine(N % K == 0 ? 0 : 1);
        }
    }
}


Measured memory_bytes: 13268
def dist(a, b):
  res = 0
  for i in range(D):
    res += (a[i] - b[i]) ** 2
  res = res ** 0.5
  return res

N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]
ans = 0
for i in range(N - 1):
  for j in range(i +1, N):
    if dist(X[i], X[j]).is_integer():
      ans += 1
print(ans)      

Measured memory_bytes: 3188
import java.util.Scanner;
public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		System.out.printf("%f %f\n", Math.PI * a * a, 2 * Math.PI * a);
		sc.close();
	}
}


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

int main(){
  string s;
  cin >> s;
  ll sum=0;
  //9が終わった時点を求める
  ll tmp=1;
  while(tmp<s.size()){
    if((s[tmp]-'0')!=9){
      break;
    }
    tmp++;
  }
  if(tmp==s.size()){
    sum=(s[0]-'0');
  }else{
    sum=(s[0]-'0'-1);
  }
  for(ll i=1;i<s.size();i++){
    sum+=9;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int n;
	int MIN=100000000;
	int MAX=-100000000;
	long long SUM=0;
	int i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		int t;
		scanf("%d",&t);
		if(t<MIN) MIN=t;
		if(t>MAX) MAX=t;
		SUM+=t;
	}
	printf("%d %d %ld\n",MIN,MAX,SUM);
	return 0;
}

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

#define maxn 100000

int parent(int i){return i/2;}
int left(int i) {return i*2;}
int right(int i){return i*2+1;}

int main(){
 //  freopen("data.in","r",stdin);
    int H, A[maxn+1];

    cin>>H;
    for(int i=1;i<=H;i++) cin>>A[i];

    for(int i=1;i<=H;i++){
        cout<<"node "<<i<<": key = "<<A[i]<<", ";
        if(parent(i)>=1) cout<<"parent key = "<<A[parent(i)]<<", ";
        if(left(i)<=H) cout<<"left key = "<<A[left(i)]<<", ";
        if(right(i)<=H) cout<<"right key = "<<A[right(i)]<<", ";
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3080
h,w,d=map(int,input().split())
A=[[0]*w for i in range(h)]
B=[0]*(w*h)
C=[0]*(w*h)
for i in range(h):
  A[i]=list(map(int,input().split()))
  for j in range(w):
    B[A[i][j]-1]=i
    C[A[i][j]-1]=j
D=[0]*(h*w)
for i in range(d,w*h):
  D[i]=D[i-d]+abs(B[i-d]-B[i])+abs(C[i-d]-C[i])
q=int(input())
for i in range(q):
  a,b=map(int,input().split())
  print(D[b-1]-D[a-1])

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

using namespace std;
int a[100005];
int cnt;
void init()
{
    for(int i=1; i<=100; i++)
        for(int j=2; j<=100 ;j++)
        {
            a[cnt++] = pow(i*1.0,j);
        }
    sort(a,a+cnt);

}
int main()
{   cnt = 0;
    init();

    int n;
    scanf("%d",&n);
    int pos = lower_bound(a,a+cnt,n)-a;
    while(a[pos] > n)
        pos--;
    cout<<a[pos]<<endl;

    return 0;
}


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

#define endl '\n'
#define mod 1e7 

using ll = long long;
using namespace std;

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

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

    int dp[n+1] = {0};
    dp[0] = 0;
    dp[1] = abs(nums[1] - nums[0]);
    int i=2;
    while(i < n) {
        dp[i] += min( abs( nums[i-1] - nums[i]) + dp[i-1] , abs( nums[i-2] - nums[i]) + dp[i-2] );
        ++i; 
    }
    i = 2;

    // while(i < n) {
    //     dp[i] += min(dp[i-1], dp[i-2]);
    //     ++i;
    // }
    cout << dp[n-1] << endl;
    // for(int x : dp) cout << x << " ";
    // cout << endl;

    return 0;
}

Measured memory_bytes: 3964
// diverta2019_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int R,G,B,N;
    cin >> R >> G >> B >> N;

    int ans = 0;

    int R_ = N / R + 1;
    int G_ = N / G + 1;
    REP(r, R_) REP(g, G_) {
        int res = N - r * R - g * G;
        if (res >= 0 && res % B == 0){
            ans ++;
        }
    }

    print(ans);

    return 0;
}


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

void dfs(vector<int> vec[],int dist[], bool visited[],int src, int n, int m)
{
    visited[src]=true;
    for(int i=0;i<vec[src].size();i++)
    {
        if(visited[vec[src][i]]==false)
        {
            dfs(vec,dist,visited,vec[src][i],n,m);
        }
         dist[src]=max(dist[src],1+dist[vec[src][i]]);
    }
}

int main()
{
    int n,m;
    cin>>n>>m;
    vector<int> vec[n];
    int dist[n];
    memset(dist,0,sizeof dist);
    bool visited[n];
    memset(visited,false,sizeof visited);

    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        vec[x-1].push_back(y-1);
    }
    for(int i=0;i<n;i++)
        dfs(vec,dist,visited,i,n,m);
    int mx=0;
    for(int i=0;i<n;i++)
        mx=max(mx,dist[i]);
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 12828
n = int(input())
a = list(map(int, input().split()))

def func(a):
  count = [0] * (max(a)+1)

  for i in a:
      count[i] += 1

  max_n = 0
  for j in range(1, len(count)-1):
      max_n = max(max_n, count[j] + count[j-1] + count[j+1])
  max_n = max(max_n, count[-1] + count[-2])

  return max_n

print(n if len(set(a)) == 1 else func(a))


Measured memory_bytes: 20756
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main()
{
	int r, g, b;
	cin >> r >> g >> b;

	if ((r * 100 + g * 10 + b) % 4 == 0)
	{
		ANS("YES");
	}
	else
	{
		ANS("NO");
	}
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)

int main() {
    ll N;
    cin >> N;

    ll ans = 1;
    rep(i,N){
        ans *= (i+1);
        ans = ans % (1000000007);
    }

    
    cout << ans << endl;
}


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

int main(int argc, char const *argv[])
{
    int n; cin >> n;
    long long int ans = 0;
    rep(i,n) {
        long long int j = n/(i+1);
        ans +=  j*(j+1)/2*(i+1);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  
  int A, B;
  cin >> A >> B;
  int ans=-1;
  
  if(A >= 1 && A <=9 && B>=1 && B<=9) ans = A*B;
  
  cout << ans << endl;
  

}

Measured memory_bytes: 256
while True:
    te = []
    tmp = 0
    for i in range(5):
        tmp = input()
        if tmp == 0:
            break
        te.append(tmp)
    if tmp == 0:
        break
    out = []
    if te[0]==te[1] and te[1]==te[2] and te[2]==te[3] and te[3]==te[4]:
        out += [3, 3, 3, 3, 3]
    elif 1 in te and 2 in te and 3 in te:
        out += [3, 3, 3, 3, 3]
    else:
        if not 1 in te:
            for i in range(5):
                    if te[i] == 2:
                        out.append(1)
                    elif te[i] == 3:
                        out.append(2)

        elif not 2 in te:
            for i in range(5):
                    if te[i] == 1:
                        out.append(2)
                    elif te[i] == 3:
                        out.append(1)

        elif not 3 in te:
            for i in range(5):
                    if te[i] == 1:
                        out.append(1)
                    elif te[i] == 2:
                        out.append(2)
    for o in out:
        print"%d" % o

Measured memory_bytes: 6416
S = input()
ans = [0 for i in range(len(S))]
t = []
p = 'R'
c = 1
for i in range(1, len(S)):
    if p == S[i]:
        c += 1
    else:
        t.append(c)
        c = 1
        p = S[i]
if c:
    t.append(c)
s = 0
for i in range(0, len(t), 2):
    ans[s + t[i] - 1] += (t[i] + 1) // 2 + t[i + 1] // 2
    ans[s + t[i]] += t[i] // 2 + (t[i + 1] + 1) // 2
    s += t[i] + t[i + 1]
print(*ans)


Measured memory_bytes: 7152
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	ll N;
	cin >> N;
	N -= 1;
	string S = "";
	while(true){
		S = (char)((N % 26)+97) + S;
		if( N < 26 ) break;
		N /= 26;
		N --;
	}
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 3628
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void) {
  int n, k, i, cou=0, tmp, j, m, p, q;
  scanf("%d", &n);
  int max=sqrt(n), memo[n];

  for(i=1; i<=n; i++){
    cou=0;
    for(j=1; j<=i; j++){
      for(k=1; k<=i; k++){
        tmp=j*j+k*k+j*k;
        if(tmp>i) break;
        for(m=1; m<=i; m++){
          tmp=(j+k)*(j+k)+(k+m)*(k+m)+(m+j)*(m+j);
          //printf("%d %d %d %d %d\n",i, j,k,m,tmp);
          if(tmp>2*i) break;
          else if(tmp==2*i) cou++;
        }
      }
    }
    //printf("cou=%d\n", cou);
    memo[i-1]=cou;
  }
  //printf("\n");
  for(i=0; i<n; i++)
    printf("%d\n", memo[i]);

}

Measured memory_bytes: 2132
N = int(input())
h = list(map(int, input().split()))

dp_table = [float("inf")]*N # 0~N-1まで
dp_table[0] = 0

for i in range(N-1): # 0~N-1までだが+1して扱う(1~N)
    dp_table[i+1] = min(dp_table[i]+abs(h[i]-h[i+1]), dp_table[i+1])
    if i-1>=0:
        dp_table[i+1] = min(dp_table[i-1]+abs(h[i-1]-h[i+1]), dp_table[i+1])
        
print(dp_table[N-1])

Measured memory_bytes: 13928
#include <stdio.h>
#include <math.h>
struct data{
  double x;
  double y;
};
typedef struct data point;

void func(point,point,double);

int cnt;
int main (){
  point p1,p2;
  scanf("%d",&cnt);
  p1.x=0;
  p1.y=0;
  p2.x=100;
  p2.y=0;
  printf("%f %f\n",p1.x,p1.y);
  if(cnt>0) func(p1,p2,0);
  else{
    printf("%f %f\n",p2.x,p2.y);
  }
  return 0;
}

void func(point p1,point p2,double tilt){
  int bcnt=0;
  double len_x,len_y,splen;
  point p3,p4,newp;

  //make vertex
  len_x=p2.x-p1.x;
  len_y=p2.y-p1.y;
  splen=sqrt((len_y*len_y)+(len_x*len_x))/3;
  len_x/=3;
  len_y/=3;
  p3.x=p1.x+len_x;
  p3.y=p1.y+len_y;
  p4.x=p3.x+len_x;
  p4.y=p3.y+len_y;
  newp.x=p3.x+splen*(cos(M_PI/3+tilt));
  newp.y=p3.y+splen*(sin(M_PI/3+tilt));

  //recursion
  if(cnt>1){
    cnt--;
    func(p1,p3,tilt);
    func(p3,newp,M_PI/3+tilt);
    func(newp,p4,-M_PI/3+tilt);
    func(p4,p2,tilt);
    cnt++;
  }
  else{
    printf("%f %f\n",p3.x,p3.y);
    printf("%f %f\n%f %f\n",newp.x,newp.y,p4.x,p4.y);
    printf("%f %f\n",p2.x,p2.y);
  }
}


Measured memory_bytes: 2064
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    d = [0,0,0]
    ans = 1
    for i in a:
        s = 0
        for k in d:
            if k == i:
                s += 1
        if not s:
            print(0)
            return
        ans *= s
        ans %= mod
        for k in range(3):
            if d[k] == i:
                d[k] += 1
                break
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 53532