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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n,x,y;
        cin>>x>>n;
        int mark[102] = {};
        for(int i=0;i<n;i++)cin>>y,mark[y]++;
        int d = 1e9,ans;
        for(int i=0;i<102;i++)
        {
            if(!mark[i])
            {
                int now = abs(x-i);
                if(now < d)d=now,ans=i;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3652
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)

    if op == '?':
        break

    if op == '+':
        print(a + b)

    if op == '-':
        print(a - b)

    if op == '*':
        print(a * b)

    if op == '/':
        print(a // b)

Measured memory_bytes: 7660
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
bool a[2005][2005];
int l[2005][2005];
int r[2005][2005];
int u[2005][2005];
int d[2005][2005];
string s[2005];
int main(){
    int h, w;
    cin >> h >> w;
    rep(i,h){
        cin >> s[i+1];
        s[i+1] = "#" + s[i+1];
        rep(j,w)a[i+1][j+1] = (s[i+1][j+1]=='.');
    }
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            l[i][j] = s[i][j]=='.';
            if(l[i][j])l[i][j] += l[i][j-1];
            u[i][j] = s[i][j]=='.';
            if(u[i][j])u[i][j] += u[i-1][j];
        }
    }
    for(int i = h; i >= 1; i--){
        for(int j = w; j >= 1; j--){
            r[i][j] = s[i][j]=='.';
            if(r[i][j])r[i][j] += r[i][j+1];
            d[i][j] = s[i][j]=='.';
            if(d[i][j])d[i][j] += d[i+1][j];
        }
    }
    int ans = 0;
    rep(i,h)rep(j,w)ans = max(ans, l[i+1][j+1]+r[i+1][j+1]+u[i+1][j+1]+d[i+1][j+1]-3);
    cout << ans << endl;
}

Measured memory_bytes: 71168
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

typedef long long ll;
#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

int main(){
	int N, K;
	cin >> N >> K;

	int ans = 1;
	while(N-- > 0){
		int pre = ans * 2 - ans;
		if(pre < K){
			ans *= 2;
		} else{
			ans += K;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  auto n = readln.chomp.to!int;
  bool[string] cnt;
  foreach (_; 0..n) {
    auto s = readln.chomp;
    cnt[s] = true;
  }
  cnt.keys.length.writeln;
}


Measured memory_bytes: 26548
#include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

int main(){
	int n;
	cin>>n;
	string t;
	getline(cin,t);
	rep(i,n){
		string s;
		getline(cin,s);
		// cout<<s.size()<<endl;
		if(s.size()<7){
			cout<<s<<endl;
			continue;
		}
		rep(j,s.size()-6){
			if(s.substr(j,7)=="Hoshino"){
				//cout<<"hoge"<<endl;
				//cout<<s[j+6]<<endl;
				s[j+6]='a';
			}
		}
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
#define len length
#define ret0 return 0
#define ret return 

#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)

#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>

// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;

#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)1e5+5

void solve(){
    ll n;
    cin>>n;
    ll a[n];
    loop(i,0,n){
        cin>>a[i];
    }
    set<pll> s;
    ll cnt=0;
    s.insert(mp(a[0], cnt+1));
    cnt++;
    for(ll i=1; i<n; i++){
        auto it = s.lb(mp(a[i], -inf));
        if(it==s.begin()){
            s.insert(mp(a[i], cnt+1));
            cnt++;
        }
        else {
            it--;
            pll p = *it;
            ll x = p.se;
            s.erase(it);
            s.insert(mp(a[i], x));
        }
    }
    print(cnt);
}

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

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



Measured memory_bytes: 7296
/*
 * Author:heroming
 * File:heroming.cpp
 * Time:2012-7-17 12:58:36
 */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

#define SZ(v) ((int)(v).size())

int n, l, t;
vector<int> V;
map<int, int> mp;

int main()
{
        while (scanf("%d%d", &n, &l) != EOF && n + l != 0)
        {
                t = 0;
                mp.clear();
                do
                {
                        mp[n] = ++ t;
                        V.clear();
                        for (int i = 0; i < l; ++ i)
                        {
                                V.push_back(n % 10);
                                n /= 10;
                        }
                        sort(V.begin(), V.end());
                        int a = 0, b = 0;
                        for (int i = l - 1; i >= 0; -- i)
                                a = a * 10 + V[i];
                        for (int i = 0; i < l; ++ i)
                                b = b * 10 + V[i];
                        n = a - b;
                } while (mp[n] == 0);
                printf("%d %d %d\n", mp[n] - 1, n, t - mp[n] + 1);
        }
        return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define INF 1e9
#define endl '\n'
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define FORE(i, a, b) for (int i = (a), e = (b); i < e; ++i)
#define RFORE(i, a, b) for (int i = (b)-1, e = (a); i >= e; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    FOR(c, 0, N / 4 + 1) {
        FOR(d, 0, N / 7 + 1)
        if ((4 * c + 7 * d) == N) {
            cout << "Yes" << endl;
            exit(0);
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[222222];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,k,a[1111],ans;
vector<int>v;
signed main(){
	cin>>n>>k;
	rep(i,n)cin>>a[i];
	rep(i,n){
		int sum=0;
		for(int j=i;j<n;j++){
			sum+=a[j];
			v.push_back(sum);
		}
	}
	for(int i=61;i>=0;i--){
		vector<int>memo;
		for(int p:v){
			if((p>>i)&1)memo.push_back(p);
		}
		if(memo.size()>=k){
			ans+=(int)1<<i;
			v=memo;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6512
n=int(input())
d=[]
for i in range(n):
    s,p=input().split()
    p=int(p)
    d.append((s,-p,i+1)) # タプルをリストへappend
d=sorted(d) #sortedにより、アルファベット順、数値順（-をつけて大きい値が先に来るようにしている）に整形
for i in range(n):
    print(d[i][2]) # d[i]でタプルの順番を指定し、その中の3番目の要素（インデックス）を出力

Measured memory_bytes: 3060
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(1)
    {
        if(c<=0)
        {
            cout << "Yes" << endl;
            return 0;
        }
        if(a<=0)
        {
            cout << "No" << endl;
            return 0;
        }
        c -= b;
        if(c<=0)
        {
            cout << "Yes" << endl;
            return 0;
        }
        if(a<=0)
        {
            cout << "No" << endl;
            return 0;
        }
        a -= d;
    }
}


Measured memory_bytes: 3652
N,K = map(int,input().split())
A_list = list(map(int,input().split()))
# roopがあるときはその範囲

roop = N
first = 0
now = 1
already = [1]
for i in range(N):
  go_town = A_list[now-1]
  already.append(go_town)
  now = go_town

set_A = set(already)
for i in range(len(set_A)+1):
  try:
    set_A.remove(already[i])
  except KeyError:
    first = already.index(already[i])
    roop = already[first:i]
    break

if K < first:
  print(already[K])
else:
  real_K = (K - first) % len(roop)
  print(roop[real_K])

Measured memory_bytes: 33560
import math
def kochCurve(d, p1, p2):
    if d <= 0:
        return
    s = [(2.0*p1[0]+1.0*p2[0])/3.0, (2.0*p1[1]+1.0*p2[1])/3.0]
    t = [(1.0*p1[0]+2.0*p2[0])/3.0, (1.0*p1[1]+2.0*p2[1])/3.0]
    u = [(t[0]-s[0])*math.cos(math.radians(60))-(t[1]-s[1])*math.sin(math.radians(60))+s[0], (t[0]-s[0])*math.sin(math.radians(60))+(t[1]-s[1])*math.cos(math.radians(60))+s[1]]
    kochCurve(d-1, p1, s)
    print(s[0], s[1])
    kochCurve(d-1, s, u)
    print(u[0], u[1])
    kochCurve(d-1, u, t)
    print(t[0], t[1])
    kochCurve(d-1, t, p2)
n = int(input())
s = [0.00000000, 0.00000000]
e = [100.00000000, 0.00000000]
print(s[0],s[1])
if n != 0:
    kochCurve(n,s,e)
print(e[0],e[1])


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

int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    vector<int> A(N);
    vector<int> B(N);
    int index = 0;
    int indexA,indexB;

    for(int i = 0;i<N;i++){
      cin >> A[i];
    }
    for(int i = 0;i<N;i++){
      cin >> B[i];
    }

    for(int i = 1;i<=N;i++){
      v[i-1] = i;
    }

    do {
        bool tmpA=true, tmpB=true;
        for(int i = 0;i < N;i++){
          tmpA = tmpA && v[i] == A[i];
         // cerr << "v[i] " << v[i] << " A[i] " << A[i] << " B[i] " << B[i] << endl; 
          tmpB = tmpB && v[i] == B[i];
        }
        if(tmpA) indexA = index;
        if(tmpB) indexB = index;

        index += 1;
    } while( next_permutation(v.begin(), v.end()) );     // 次の順列を生成

    cout << abs(indexA - indexB) << endl;
}


Measured memory_bytes: 256
while True:
    h,w = map(int, input().split())
    if h == 0 and w == 0:
        break
    else:
        a = ""
        b = ""
        for i in range(w):
            if i%2 == 0:
                a += "#"
                b += "."
            else:
                a += "."
                b += "#"
        for j in range(h):
            if j%2 == 0:
                print(a)
            else:
                print(b)
    print()


Measured memory_bytes: 5612
n, x = gets.split.map(&:to_i)
arr = gets.split.map(&:to_i)

count = 0
pnum = 0
arr.each do |n|
  cnum = pnum + n
  minus = 0
  minus = cnum - x if cnum > x

  count += minus
  pnum = n - minus
end

puts count

Measured memory_bytes: 20808
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll pair<ll,ll>
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 200005;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
     ll s,w;
     cin >> s >> w;
     if(w>=s)
     {
          cout<<"unsafe";
     }
     else
     {
           cout<<"safe";
     }
}

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

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=100005;
//i_am_noob
int n,m,x,c[12],a[12][12],ans=4e18,cnt[12],cost;
bool ok;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n >> m >> x;
	rep(n){
		cin >> c[i];
		rep1(j,m) cin >> a[i][j];
	}
	rep(pow2(n)){
		rep1(j,m) cnt[j]=0;
		cost=0;
		rep1(j,n) if(i&pow2(j)){
			cost+=c[j];
			rep1(k,m) cnt[k]+=a[j][k];
		}
		ok=true;
		rep1(j,m) if(cnt[j]<x) ok=false;
		if(ok) ans=min(ans,cost);
	}
	if(ans>3e18) print1(-1);
	else print1(ans);
	return 0;
}

Measured memory_bytes: 3640
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

def swap(s,pos):
    s[pos]-=1
    s[pos+1]+=1
    print(s)
    if pos == n-2: return s
    if s[pos+2] == 0: swap(s,pos+1)
    return s


n = ip()                              #入力整数1つ
#left,n= (int(i) for i in input().split())      #入力整数横2つ
#n,x,y = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)



#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
a = math.sqrt(n)
print(pow(int(a),2))

Measured memory_bytes: 13668
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

#define p pair<int,int>
#define mp(a,b) make_pair(a,b)
using namespace std;

vector<vector<p>> cost;
int n;

long long prim()
{
	vector<bool> visited(n);
	priority_queue<p, vector<p>, greater<>> que;
	que.push(mp(0,0));
	long long ret = 0;

	while (!que.empty())
	{
		p pa = que.top();
		que.pop();
		int next = pa.second;
		if (visited[next])continue;
		visited[next] = true;
		ret += pa.first;

		for (int i = 0; i < cost[next].size(); i++)
		{
			p edge = cost[next][i];
			que.push(p(edge.second, edge.first));
		}
	}
	return ret;
}

int main()
{
	cin >> n;
	vector<vector<int>> x(n, vector<int>(2));
	vector<vector<int>> y(n, vector<int>(2));
	for (int i = 0; i < n; i++)
	{
		cin >> x[i][0] >> y[i][0];
		x[i][1] = i;
		y[i][1] = i;
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	cost = vector<vector<p>>(n);
	for (int i = 0; i < n - 1; i++)
	{
		cost[x[i][1]].push_back(mp(x[i + 1][1],abs(x[i][0]-x[i+1][0])));
		cost[x[i + 1][1]].push_back(mp(x[i][1],abs(x[i][0]-x[i+1][0])));
		cost[y[i][1]].push_back(mp(y[i + 1][1],abs(y[i][0]-y[i+1][0])));
		cost[y[i + 1][1]].push_back(mp(y[i][1],abs(y[i][0]-y[i+1][0])));
	}
	cout << prim() << endl;
	return 0;
}


Measured memory_bytes: 20980
{-# LANGUAGE BangPatterns #-}

module Main where

import Control.Applicative
import Control.Monad
import Data.List
import Data.Maybe
import Text.Printf

check :: Int -> (Int, Int, Int) -> Maybe (Int, Int, Int)
check n (p, q, r) = iter (p, q, r)
  where
    iter :: (Int, Int, Int) -> Maybe (Int, Int, Int)
    iter (!a, !b, !c)
        | k >  n    = Nothing
        | a <  0    = Nothing
        | k == n    = Just (a, b, c)
        | v == 0    =
            if u <= b
                then Just (a, b - u, c + 5 * u)
                else iter (a - 1, b + 2, c)
        | otherwise = iter (a - 1, b + 2, c)
      where
        k = a + b + c
        (u, v) = (n - k) `divMod` 4

main :: IO ()
main = do
    [n, y] <- fmap read . words <$> getLine :: IO [Int]
    let (q1, r1) = y  `divMod` 10000
    let (q2, r2) = r1 `divMod` 5000
    let (q3, r3) = r2 `divMod` 1000
    let ans = check n (q1, q2, q3)
    case ans of
        Nothing        -> putStrLn "-1 -1 -1"
        Just (a, b, c) -> printf "%d %d %d\n" a b c

Measured memory_bytes: 508
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;
int main(void) {
    
    char a[3];
    char b[3];

    for(int i=0;i<3;i++){
        cin>>a[i];
    }
    for(int i=0;i<3;i++){
        cin>>b[i];
    }

    for(int i=0;i<3;i++){
        if(a[i]!=b[2-i]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;

    return 0;
}

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

int main(){
    int n,s,avg;
    while (cin>>n && n!=0){
        int sum=0,ma=0,mi=1000;
        for (int i=0;i<n;i++){
            cin>>s;
            sum+=s;
            ma=max(ma,s); //最大値の更新
            mi=min(mi,s); //最小値の更新
        }
        avg=(sum-ma-mi)/(n-2); //平均の計算
        cout<<avg<<endl;
    }
}


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

int main() {
    string s;
    cin >> s;
    if (s == "SUN") puts("7");
    if (s == "MON") puts("6");
    if (s == "TUE") puts("5");
    if (s == "WED") puts("4");
    if (s == "THU") puts("3");
    if (s == "FRI") puts("2");
    if (s == "SAT") puts("1");
    return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int N,p[200001];
    scanf("%d",&N);
    int i,j,count,min[200001];
    for(i=0;i<N;i++){
        if(scanf("%d",&p[i])==1){
        }
    }
    min[0] = p[0];
    for(i=1;i<N;i++){
        if(p[i] < min[i-1]){
            min[i] = p[i];
        }else{
            min[i] = min[i-1];
        }
    }
    
    count = 1;
    for(i=1;i<N;i++){
        if(p[i] <= min[i]){
            count++;
        }
    }
    
    printf("%d\n",count);
    return 0;
}



Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c;cin >> a >> b >> c;
	int x,y,z;
	rep(i,1000000){
		if(a%2 || b%2 || c%2){
			cout << i << endl;
			return 0;
		}
		x=b/2+c/2;
		y=a/2+c/2;
		z=a/2+b/2;
		a=x;
		b=y;
		c=z;
	}
	cout << -1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

bool used[100005];

int main(){
	int a,b,c;
	int n,m;
	int i,j,k;
	int s=0;
	bool w;
	while(1){
		cin>>n>>m;
		if(n==0 && m==0)break;
		memset(used,false,sizeof(used));
		w=false,s=0;
		for(i=0;i<m;i++){
			cin>>a;
			if(a==0){
				w=true;
				continue;
			}
			used[a-1]=true;
		}
		a=0,b=-1,c=-1;
		for(i=0;i<n;i++){
			if(used[i]){
				if(b==-1)b=1;
				else b++;
				if(c!=-1)c++;
			}else{
				if(w)s=max(s,c);
				else s=max(s,b);
				if(b!=-1)c=b+1;
				else c=-1;
				b=-1;
			}
		}
		if(w){
			s=max(s,c);
			s=max(s,b+1);
			if(s==0)s=1;
		}else s=max(s,b);
		cout<<s<<endl;
	}
}



Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  if((N-1)%(K-1)==0){
    cout<<(N-1)/(K-1)<<endl;
  }
  else{
    cout<<(N-1)/(K-1)+1<<endl;
  }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, n);
  cout << 180 * (n - 2) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int gcd(int m, int n)
{
	if(n == 0) return m;
	else return gcd(n, m % n);
}

int main()
{
	int n;
	cin >> n;
	int a[100001];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int gcd_l[100001];
	int gcd_r[100001];
	gcd_l[0] = a[0];
	for(int i = 1; i < n; i++){
		gcd_l[i] = gcd(max(gcd_l[i - 1], a[i]), min(gcd_l[i - 1], a[i]));
	}
	gcd_r[n - 1] = a[n - 1];
	for(int i = n - 2; i >= 0; i--){
		gcd_r[i] = gcd(max(gcd_r[i + 1], a[i]), min(gcd_r[i + 1], a[i]));
	}
	int ans = max(gcd_r[1], gcd_l[n - 2]);
	for(int i = 1; i < n - 1; i++){
		int tmp = gcd(gcd_l[i - 1], gcd_r[i + 1]);
		ans = max(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1408
//code by lynmisakura.wish to be accepted
/****************************/
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<vector>
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
/***************************/
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;

const long long Mod = 998244353;
const long long mod = 1000000007;
const long long INF = 10000000000000;

#define pb push_back
#define mp make_pair
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
	
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
/***************************/


int main(void){
	int a,b,c;cin >> a >> b >> c;
	if(a %2 != 0 || b %2 != 0 ||c %2 != 0 ){
		cout << 0 << endl;
		return 0;
	}
	if(a == b && b ==c && c == a){
		cout << -1 << endl;
		return 0;
	}
	int count = 0;
	while(true){
		if(a %2 != 0 || b %2 != 0 ||c %2 != 0 ){
			break;
		}else{
			count++;
			int p,q,r;
			p = (a+b)/2;
			q = (b+c)/2;
			r = (a+c)/2;
			a = q,b = r,c = p;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

a_sort = sorted(set(a))

max_val_1 = a_sort[-1]
max_total_1 = a.count(max_val_1)

if len(a_sort) >= 2:
    max_val_2 = a_sort[-2]

#print("max val:{}".format(max_val_1))
#print("max total:{}".format(max_total_1))

for i in range(n):
    if max_total_1 >=2:
        print(max_val_1)
    
    elif a[i] < max_val_1:
        print(max_val_1)

    elif a[i] == max_val_1 and max_total_1 == 1:
        print(max_val_2)
    else:
        print("err")

Measured memory_bytes: 17168
#include<stdio.h>
int main(void)
{
  int i;
  char x[12];
  for(i=0;i<12;i++)
    {
      scanf("%c",&x[i]);
    }
  for(i=0;i<4;i++)
    {
      printf("%c",x[i]);
    }
  putchar(' ');
  for(i=4;i<12;i++)
    {
      printf("%c",x[i]);
    }
  putchar('\n');
  return 0;
}

Measured memory_bytes: 128
N = int(input())

if N == 0:
    print(0)
    exit()

ans = []
x = N

while x != 1:
    if x % 2 == 0:
        ans.append('0')
    else:
        ans.append('1')
        x -= 1
    x /= -2
ans.append('1')

r = "".join(ans[::-1])
print(r)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int x = stdIn.nextInt();
		boolean y[][] = new boolean[4][13];
		for(int i=0; i < x; i++){
			String kind = stdIn.next();
			int number = stdIn.nextInt();
			if(kind.equals("S")) {
				y[0][number-1]= true;
			} else if(kind.equals("H")){
				y[1][number-1]= true;
			} else if(kind.equals("C")){
				y[2][number-1]= true;
			} else if(kind.equals("D")){
				y[3][number-1]= true;
			}
		}
		stdIn.close();
		for(int i=0; i < 4; i++){
			for(int j=0; j < 13; j++){
				if (!y[i][j]) {
					if( i== 0) {
						System.out.println("S " + (j+1));
					} else if(i == 1){
						System.out.println("H " + (j+1));
					} else if(i == 2){
						System.out.println("C " + (j+1));
					} else if(i == 3){
						System.out.println("D " + (j+1));
					}
				}
			}
		}

	}
}



Measured memory_bytes: 26232
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int n = sz(s);
    string ans;
    rep(i, n) {
        if (s[i] == '0') {
            ans += '0';
        } else if (s[i] == '1') {
            ans += '1';
        } else {
            if (sz(ans) >= 1) ans.pop_back();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	t := make([]int, n)
	sum := 0
	for i := range t {
		t[i] = scanInt()
		sum += t[i]
	}
	m := scanInt()
	var wr = bufio.NewWriter(os.Stdout)
	for i := 0; i < m; i++ {
		p, x := scanInt(), scanInt()
		wr.WriteString(strconv.Itoa(sum-t[p-1]+x) + "\n")
	}
	wr.Flush()
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }

typedef long long ll;
using namespace std;

int main() {
    
    ll n, W;
    cin >> n >> W;
    vector<ll> w(n, 0), v(n, 0);
    REP(i, n) cin >> w[i] >> v[i];

    vector<vector<ll>> dp(n + 1, vector<ll>(W + 1, 0));
    REP(i, n) {
        REP(u, W + 1) {
            if (u - w[i] >= 0) { // choose the i-th thing if improved
                chmax(dp[i+1][u], max(dp[i][u - w[i]] + v[i], dp[i][u]));
            } else // cannot choose it
                dp[i+1][u] = dp[i][u];
        }
    }

    cout << *max_element(ALL_OF(dp[n])) << endl;
    
}

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

int main() {
  int N;
  cin >> N;
  vector<double> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  double denominator = 0.0;
  for (int i = 0; i < N; i++){
    denominator += 1.0 / A[i];
  }
  cout << 1.0 / denominator << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

map<int, vi> mp;
priority_queue<int> que;

int main(){
	int n, m; scanf("%d%d", &n, &m);
	REP(i, n){
		int a, b; scanf("%d%d", &a, &b);
		mp[a].EB(b);
	}
	int ans = 0;
	REP(i, m+1) {
		for(int &j : mp[i]) que.emplace(j);
		if(que.size()){
			int j = que.top(); que.pop();
			ans += j;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 10880
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[allow(unused_macros)]
macro_rules! chmin {
    ( $x : expr , $y : expr ) => {
        if $x > $y {
            $x = $y;
            true
        } else {
            false
        }
    };
}

fn main() {
    input! {
        n: usize, k: usize,
        x: [i64; n]
    }

    let mut ret = i64::max_value() / 4;
    for i in (0..).take_while(|&i|  i + k - 1 < n) {
        let left = x[i];
        let right = x[i+k-1];
        chmin!(ret, std::cmp::min(left.abs(), right.abs()) + right - left);
    }
    println!("{}", ret);
}


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

int main(){
    string n;
    cin >> n;
    bool ok = false;
    rep(i,3){
        if(n[i] == '7'){
            ok = true;
        }
    }
    if(ok == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n;
    cin >> n;

    vector<int64_t> a(n);
    for (auto&& aa : a) {
        cin >> aa;
    }

    if (a[0] != 0) {
        cout << -1 << endl;
        return 0;
    }

    int64_t ans = 0;
    for (auto i : irange(1L, n)) {
        if (a[i] > a[i - 1] + 1) {
            cout << -1 << endl;
            return 0;
        }

        if (a[i] != a[i - 1] + 1) {
            ans += a[i - 1];
        }
    }

    ans += a[n - 1];

    cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] argv) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int max = 0;
        int gcd = 0;
        for (int i= 0; i < n; i++) {
            int m = sc.nextInt();
            max = Math.max(max, m);
            gcd = findGcd(gcd, m);
        }
        if (k <= max && k % gcd == 0) {
            System.out.println("POSSIBLE");
        } else  {
            System.out.println("IMPOSSIBLE");
        }

    }
    private static int findGcd(int a, int b) {
        while (b > 0) {
            int t = a % b;
            a = b;
            b = t;
        }

        return a;
    }
}

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

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

    for(int i = s.size()/2; i>=0; i--){
        if(s.size()%2 == 0 && s.size() / 2 == i){
            continue;
        }
        if(s.substr(0, i) == s.substr(i, i)){
            cout << i*2 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <vector>

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

using namespace std;

void solve(string line)
{
  set<string> ans;
  for (int i = 1; i < line.length(); ++i) {
    string a = line.substr(0, i);
    string b = line.substr(i, line.length() - i);
    ans.insert(a + b);
    ans.insert(b + a);
    reverse(a.begin(), a.end());
    ans.insert(a + b);
    ans.insert(b + a);
    reverse(b.begin(), b.end());
    ans.insert(a + b);
    ans.insert(b + a);
    reverse(a.begin(), a.end());
    ans.insert(a + b);
    ans.insert(b + a);
  }
  cout << ans.size() << endl;
}

int main()
{
  int m;
  cin >> m;
  rep(i, m) {
    string line;
    cin >> line;
    solve(line);
  }

  return 0;
}

Measured memory_bytes: 1292
X, Y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p_sum = [0]*(a+1)
q_sum = [0]*(b+1)
for i in range(a):
    p_sum[i+1] = p_sum[i] + p[i]
for i in range(b):
    q_sum[i+1] = q_sum[i] + q[i]
#print(p_sum)
#print(q_sum)
ans = [0]*(c+1)
ans[0] = p_sum[X] + q_sum[Y]
x, y = X, Y
flag = True
for i in range(c):
    if x > 0 and y > 0:
        ans[i+1] = max(ans[i]-p[x-1]+r[i], ans[i]-q[y-1]+r[i], ans[i])
        if ans[i+1] == ans[i]-p[x-1]+r[i]:
            x -= 1
        elif ans[i+1] == ans[i]-q[y-1]+r[i]:
            y -= 1
        elif ans[i+1] == ans[i]:
            break
    elif x == 0:
        ans[i+1] = max(ans[i]-q[y-1]+r[i], ans[i])
        if ans[i+1] == ans[i]:
            break
        else:
            y -= 1
    elif y == 0:
        ans[i+1] = max(ans[i]-p[x-1]+r[i], ans[i])
        if ans[i+1] == ans[i]:
            break
        else:
            x -= 1
    elif x == 0 and y == 0:
        flag = False
if flag:
    print(max(ans))
else:
    print(sum(r[:x+y-1]))


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

int main(){
    string s;cin>>s;int n=s.size(),c=0;
    for(int i=0;i<n;i++){
        char t=s.at(i);
        if((i+1)%2==0){
            if(t=='L'||t=='U'||t=='D') c++; 
        }
        else{
            if(t=='R'||t=='U'||t=='D') c++;
        }
    }
    if(c==n) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

const ll mod = 3;
const int N = 3e3 + 10, M = 1e6 + 10;
const ll INF = 2e18;
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;

#define pi acos(-1)

int a[N][N];
int n, m, k;
ll dp[N][N][4];
int f[N];

int main()
{
    cin >> n >> m >> k;
    for (int i = 1; i <= k; i++)
    {
        int x, y, w;
        scanf("%d%d%d", &x, &y, &w);
        a[x][y] = w;
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            for (int u = 1; u <= 3; u++)
            {
                dp[i][j][u] = max({dp[i - 1][j][3] + a[i][j], dp[i][j - 1][u], dp[i][j - 1][u - 1] + a[i][j]});
                ans = max(ans, dp[i][j][u]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}
/*

*/

Measured memory_bytes: 320908
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string, copy
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7
ans = count = 0; pro = 1


x=int(input())
a=x//100
b=x%100
if b<=a*5:
    print(1)
else:
    print(0)

Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n; i++)
#define all(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

struct edge
{
  int src, to, cost;
};

using Edges = vector< edge >;
using WeightedGraph = vector< Edges >;
int n, m;
WeightedGraph G;
vector<int> ans, parent;

void bfs(int s)
{
    vector<int> used(n, 0);
    used[s] = 1;
    queue<int> q;
    q.push(s);
    while(!q.empty()){
        int u = q.front(); q.pop();
        for(auto &ve: G[u]){
            int v = ve.to;
            used[v]++;
            ans[v] = u+1;
            if(used[v] == parent[v]) q.push(v);
        }
    }
}


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

    cin >> n >> m;
    G = WeightedGraph(n);
    ans = vector<int>(n, 0);
    parent = vector<int>(n, 0);
    rep(i, n-1+m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        parent[b]++;
        G[a].emplace_back((edge){ a, b, -1} );
    }
    int st = find(all(parent), 0) - parent.begin();
    bfs(st);
    rep(i, n){
        cout << ans[i] << endl;
    }

    return 0;
}


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


int main() {
	int H,W,h,w;cin>>H>>W>>h>>w;
	int minus=(H/h)*(W/w);
	int plus=(H%h)*W+(W%w)*H-(H%h)*(W%w);
//	cout<<minus<<' '<<plus<<endl;
	if((H%h)+(W%w)==0){
		cout<<"No"<<endl;
		return 0;
	}else{
		cout<<"Yes"<<endl;
	}
	int def=1;
	for(int i=0;i<9;i++){
		def*=10;
	}
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			int num=(def/(h*w));
			if((i%h)+(j%w)==0){
				num=-h*w*(def/(h*w))+(def/(h*w))-1;
			}
			cout<<num<<' ';
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int i,a[2*n];
	for(i=0;i<k;++i){
		cin>>a[i];
		a[i]%=n;
	}
	sort(a,a+k);
	for(i=k;i<2*k;++i){
		a[i]=a[i-k]+n;
	}
	int mi=n;
	for(i=0;i<k;++i){
		mi=min(mi,a[i+k-1]-a[i]);
	}
	cout<<mi;
}

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

int main(){

int N, K;
string S;
cin >> N >> S >> K;



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

    if(S.at(i) != S.at(K - 1)){
        S.at(i) = '*';
    }

}

cout << S << endl; 

}

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

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

  string S;
  cin >> S;
  int count = 0;
  for(int i=0;i<S.size();i++){
    if(S[i] == 'o') count++;
  }
  if((8-count) <= (15-S.size())) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

int main() {
  int n;
  char str[10], com[13];
  map<string, bool>  T;  // 標準ライブラリからmapを使用

  cin >> n;
  for ( int i = 0; i < n; i++ ) {
    scanf("%s%s", com, str);
    if ( com[0] == 'i' ) T[string(str)] = true;
    else {
      if ( T[string(str)] ) printf("yes\n");
      else printf("no\n");
    }
  }

  return 0;
}


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

using namespace std;

typedef unsigned long long int ULL;
typedef long long LL;
typedef long double LD;

const LL inf = 1000000000000000;
const LL mod = 1000000007;

int main()
{
	LL n;
	cin >> n;

	string s;
	cin >> s;

	LL cnt = 1;
	for (int i = 0; i < n-1; ++i) {
		if (s[i] != s[i+1]) {
			cnt++;
		}
	}
	cout << cnt << endl;
	 
}

Measured memory_bytes: 512
use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        k: usize,
    }

    let mut find_runrun = 0;
    let mut num = 0;

    let mut ans = 0;

    let mut queue: VecDeque<usize> = VecDeque::new();
    for i in 1..10 {
        queue.push_front(i);
    }

    for i in 0..k - 1 {
        let pop = queue.pop_back().unwrap();

        //println!("{}", pop);

        if pop % 10 != 0 {
            queue.push_front(pop * 10 + pop % 10 - 1);
        }
        queue.push_front(pop * 10 + pop % 10);
        if pop % 10 != 9 {
            queue.push_front(pop * 10 + pop % 10 + 1);
        }
    }

    println!("{}", queue.pop_back().unwrap());
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 10620
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
    string s;
    cin >> s;
    cout << s[0] << s[1] << s[2] << endl;
    return 0;
}

Measured memory_bytes: 3628