akhauriyash/Code-Regression huggingface dataset:
from heapq import heappop,heappush
from math import sqrt
def distf(xyr,i,j):
  x,y,r=xyr[i]
  x1,y1,r1=xyr[j]
  d=max(0,sqrt((x-x1)**2+(y-y1)**2)-r-r1)
  return d

def main():
  # 優先度付きキューを使わないダイクストラ
  xs,ys,xt,yt=map(int,input().split())
  n=int(input())
  xyr=[list(map(int,input().split())) for _ in range(n)]
  xyr.append([xs,ys,0])
  xyr.append([xt,yt,0])
  inf=float('inf')
  dist=[[inf]*(n+2) for _ in range(n+2)]
  for i in range(n+2):
    dist[i][i]=0
  for i in range(n+1):
    for j in range(i+1,n+2):
      dist[i][j]=distf(xyr,i,j)
      dist[j][i]=dist[i][j]
  seen=[inf]*(n+2)
  seen[n]=0
  mi=set(range(n+2))
  while mi:
    d,v=inf,-1
    for j in mi:
      if d>seen[j]:
        d=seen[j]
        v=j
    mi.remove(v)
    for nv in mi:
      nd=dist[v][nv]
      if seen[nv]>seen[v]+nd:
        seen[nv]=seen[v]+nd
  print(seen[n+1])
if __name__=='__main__':
  main()


Measured memory_bytes: 33288
S = input("")
l = S.split()
A = int(l[0])
B = int(l[1])
C = int(l[2])
K = int(l[3])
sum = 0
while(K > 0):
  if A > 0:
    K = K - A
    sum+=A
    A = 0
    if K < 0:
    	sum+=K
  elif B > 0:
    K = K - B
    B = 0
  elif C > 0:
    K = K - C
    sum-=C
    C = 0
    if K < 0:
    	sum-=K
print(sum)

Measured memory_bytes: 9200
//
//  main.cpp
//  Competitive
//
//  Created by Ashutosh Tiwari on 16/05/20.
//  Copyright © 2020 Ashutosh Tiwari. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <cassert>
#include <iomanip>
#include <climits>
#include <functional>
#include <unordered_map>
#include <tuple>
#include <iterator>
#include <unordered_set>
#include <chrono>
#include <regex>

using namespace std;
using vi = vector<int>;
int N = 1e5 + 5;
vector<bool> visited(N, false);
vi dist(N, 0);
vi in_degree(N, 0);
vector<vector<int>> adj_list (N);
void dfs(int n) {
    assert(!visited[n]);
    visited[n] = true;
    for (int i: adj_list[n]) {
        in_degree[i] --;
        dist[i] = max(dist[i], dist[n] + 1);
        if (in_degree[i] == 0) {
            dfs(i);
        }

    }

}

int main()
{
    ios_base::sync_with_stdio(false);
//    freopen("../in.txt", "r", stdin);
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i ++) {
        int x, y;
        scanf("%d%d", &x, &y);
        adj_list[x].emplace_back(y);
        in_degree[y] ++;
    }
    for (int i = 1; i <= n; i ++)
        if (!visited[i] && in_degree[i] == 0)
            dfs(i);
//    for (int i = 1; i <= n; i ++)
//        cout << dist[i] << " ";
//        cout << endl;
    printf("%d\n", (*max_element(dist.begin() + 1, dist.begin() + n + 1)));

    return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    ll n;cin>>n;
    if(n%2==0){cout<<(n/2)*(n-1)<<endl;}
    else{cout<<n*((n-1)/2)<<endl;}
    return 0;
}

Measured memory_bytes: 256
//
// Created by Akifumi Ohata on 2017/10/01.
//


#include<iostream>
#include <vector>
#include <numeric>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

using ll =  long long int;

int main() {
    ios::sync_with_stdio(false);

    int N, K;

    //ll MOD=1000000007;


    cin >> N >> K;


    vector<int> ArraryL(N,0);
    for(int i=0;i<N;i++){
        cin>>ArraryL[i];

    }


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

    int sum =0;

    for(int j=N-K;j<N;j++){
        sum+=ArraryL[j];
        //cout<< ArraryL[j] <<endl;
    }


    cout  << sum << endl ;

    return 0;
}


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

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define SUBL freopen("/home/ajinkya/Desktop/input.txt","r",stdin); freopen("/home/ajinkya/Desktop/output.txt","w",stdout); 
#define ll long long
#define ull unsigned long long
#define FI(i,a,n) for(int i=a; i<=n; i++)
#define RFI(i,n,a) for(int i=n; i>=a; i--)
#define FLL(i,a,n) for(ll i=a; i<=n; i++)
#define RFLL(i,n,a) for(ll i=n; i>=a; i--)
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define pi pair<int, int>
#define GCD(a,b) __gcd(a,b)
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define debug(x) cout << x << endl
#define MOD 1000000007
#define INF LLONG_MAX
#define PI 3.14159265359
using namespace std;




int main()
{
    fastio 
    // SUBL
  	int n, d;
  	cin >> n >> d;
  	int k = ceil((double)n/(2*d+1));
  	cout << max(1, k);
    return 0;
}         	

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 100000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;

int sum[N];
int main() {
    for(int i=1; i<=N-1; i++)
        sum[i]=sum[i-1]+i;

    int x;
    scanf("%d",&x);
    int left=1,right=N-1;
    while(left<=right){
        int mid=(left+right)/2;
        if(sum[mid]<x){
            left=mid+1;
        }
        else if(sum[mid]>=x){
            right=mid-1;
        }
    }
    int pos=right+1;
    printf("%d\n",pos);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N, W;
  cin >> N >> W;
  
  vector<vector<long long>> dp(N + 1, vector<long long>(100000 + 1, 1000000000 + 1));
  
  dp.at(0).at(0) = 0;
  
  int w, v;
  for (int i = 1; i <= N; i++) {
    cin >> w >> v;
    for (int j = 0; j <= 100000; j++) {
        dp.at(i).at(j) = min(dp.at(i - 1).at(j), dp.at(i - 1).at(max(int(j - v), 0)) + w);
    }
  }
  
  long long ans = 100000;
  
  while (dp.at(N).at(ans) > W) {
    ans--;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 83204
#include <bits/stdc++.h> 
using namespace std ; 
#define ll long long int 
#define pb push_back
#define ff first 
#define dobara(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define ss second 
#define S(x) scanf("%d",&x) 
#define SL(x) scanf("%lld",&x)
#define M 1000000007
#define sz(x) (int)x.size()
#define all(a) (a).begin(),(a).end()

int arr[100005] ; 

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

	for(int i=0;i<n;i++)
	{
		cin>>arr[i] ; 
	}
    
    sort(arr,arr+n) ; 
    int ans = INT_MAX ; 
	for(int i=0;i<=n-k;i++)
	{
		//cout<<arr[i+k]
		ans = min(arr[i+k-1]-arr[i],ans) ; 
	} 
	cout<<ans<<"\n" ; 
}

Measured memory_bytes: 640
import java.util.*;

public class Main{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    String s=sc.nextLine();
    long sum=0;
    for(int i=0;i<s.length();i++)
    {
      sum+=Long.parseLong(String.valueOf(s.charAt(i)));
    }
    if(sum%9==0)
    System.out.println("Yes");
    else
    System.out.println("No");
  }
}

Measured memory_bytes: 50456
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  int dx = tx - sx;
  int dy = ty - sy;

  rep(i, dx) cout << 'R';
  rep(i, dy) cout << 'U';

  rep(i, dx) cout << 'L';
  rep(i, dy) cout << 'D';

  cout << 'D';
  rep(i, dx + 1) cout << 'R';
  rep(i, dy + 1) cout << 'U';
  cout << 'L';

  cout << 'U';
  rep(i, dx + 1) cout << 'L';
  rep(i, dy + 1) cout << 'D';
  cout << 'R';

  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1 << 20;

typedef long long ll;




int main(){
  int n,k;
  cin >> n >> k;
  ll sum = 0;
  for(int i = k+1;i <= n;i++){
    int K = i-k;
    int T = n/i;
    //cout << K << "     " << T << endl;
    if(n%i == 0){
      sum += K*T;
    }
    else{
      int e = i*(T+1) - n;
      if(k != 0)
	e--;
      
      ll p = K - e;
      if(e > K){
	p = 0;
      }
      sum += K*T + (p);
    }
    //cout << sum << endl;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <bitset>
#include <queue>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define sqr(x) (x)*(x)
typedef long long ll;

int main() {
    int a, b;
    cin >> a >> b;
    if(a < 10 && b < 10) {
        cout << a*b;
    } else {
        cout << -1;
    }
    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var k = long.Parse(Console.ReadLine());

        var runrun = GetRunRun(k).ToArray();

        Console.WriteLine(runrun.Last());
    }

    public static IEnumerable<long> GetRunRun(long k)
    {
        var q = new Queue<long>();
        for (int i = 1; i <= 9; i++) q.Enqueue(i);

        for(int i = 0; i < k; i++)
        {
            var current = q.Dequeue();
            yield return current;

            var last = current % 10;
            if (last != 0) q.Enqueue(current * 10 + last - 1);
            q.Enqueue(current * 10 + last);
            if (last != 9) q.Enqueue(current * 10 + last + 1);
        }
    }
}

Measured memory_bytes: 17888
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0


#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);


int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}
#pragma endregion


#include <stdio.h>

#include<stdio.h>


static int n[100];
int main(void)
{
	int  i, len, flg = 0;
	char w[101];

	s_cin(w);
	len = strlen(w); 
	
	for (i = 0; i < len; i++) {
		n[w[i] - 'a']++;
	}
	for (i = 0; i < 100; i++) {
		if (!n[i])continue;
		if (n[i] % 2) {
			flg = 1; break;
		}
	}
	(flg) ? s_cout("No") : s_cout("Yes");
	return 0;
}



Measured memory_bytes: 128
import sys
import bisect
from functools import lru_cache
from collections import defaultdict
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
n=read()
a=list(reads())
a.sort(reverse=True)
res=a[0]
next=[a[1],a[1]]
k=2
while(True):
  length=len(next)
  hoge=[]
  for i in range(length):
    if k>=n:
      print(res)
      exit()
    res+=next[i]
    hoge.append(a[k])
    hoge.append(a[k])
    k+=1
  next=hoge

Measured memory_bytes: 108548
#include <iostream>
#include <algorithm>
#include <typeinfo>
#include <numeric>
#include "math.h"
#include <string>
#include <vector>
#include <iomanip>

#define pai 3.14159265358979323846264338327950288
using namespace std;


// gacha
//*
int main() {

	int n;
	vector<string> keihinlist;

	cin >> n;

	for (int i = 0; i < n; i++) {
		string keihin="";
		cin >> keihin;
		keihinlist.push_back(keihin);
	}
	sort(keihinlist.begin(),keihinlist.end());
	keihinlist.erase(unique(keihinlist.begin(),keihinlist.end()),keihinlist.end());

	cout << keihinlist.size();

	return 0;
}
//*/


Measured memory_bytes: 11668
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <atcoder/all>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

using namespace atcoder;

struct S{
    ll zero,one,inversion;
};

using F=bool;
S op(S l,S r){
    return S{
        l.zero+r.zero,
        l.one+r.one,
        l.inversion+r.inversion+l.one*r.zero,
    };
}

S e(){
    return S{0,0,0};
}

S mapping(F l,S r){
    if(!l) return r;
    return S{r.one,r.zero,r.one*r.zero-r.inversion};
}
F composition(F l,F r){
    return (l && !r) || (!l && r);
}
F id(){
    return false;
}

int main(){
    int n,q;
    cin >> n >> q;
    vector<S> a(n);
    rep(i,n){
        int x;
        cin >> x;
        if(x==0){
            a[i]=S{1,0,0};
        }
        else{
            a[i]=S{0,1,0};
        }
    }
    lazy_segtree<S,op,e,F,mapping,composition,id> seg(a);
    
    rep(i,q){
        int t;
        cin >> t;
        int l,r;
        cin >> l >> r;
        l--;
        if(t==1){
            seg.apply(l,r,true);
        }
        if(t==2){
            cout << seg.prod(l,r).inversion << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 20360
#include <stdio.h>
#define MAX_SIZE 100
int main()
{
    int arr[MAX_SIZE], reverse[MAX_SIZE];
    int size, i, arrIndex, revIndex;
    scanf("%d", &size);
    for(i=0; i<size; i++)
    {
        scanf("%d",&arr[i]);
    }

    revIndex = 0;
    arrIndex = size - 1;
    while(arrIndex >= 0)
    {
        reverse[revIndex] = arr[arrIndex];

        revIndex++;
        arrIndex--;
    }
    for(i=0; i<size; i++)
    {
        if(i==size-1)
        printf("%d",reverse[i]);
        else
            printf("%d ",reverse[i]);
    }
    printf("\n");

    return 0;
}




Measured memory_bytes: 2072
n = int(input())
a_input = [0]+list(map(int,input().split()))+[0]

cost_li = [0]*(n+1)
cost_li[0]=a_input[1]
cost_li[-1]=abs(a_input[-2])

for i in range(1,n+1):
    cost_li[i-1]=abs(a_input[i]-a_input[i-1])

sum_cost = sum(cost_li)

for i in range(1,n+1):
    ans = sum_cost-cost_li[i-1]-cost_li[i]+abs(a_input[i+1]-a_input[i-1])
    print(ans)





Measured memory_bytes: 14044
n,k = map(int,input().split())

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

print(len(Base_10_to_n(n,k)))

Measured memory_bytes: 2940
use proconio::{fastout, input};
use std::f64;

#[fastout]
fn main() {
    let pi = f64::consts::PI;
    input! {
        hour_length: f64,
        minute_length: f64,
        hour: f64,
        minute: f64,
    }
    let hour_angle = pi * 2.0 * (hour / 12.0 + minute / 720.0);
    let minute_angle = pi * 2.0 * (minute / 60.0);
    let inner_angle = match (hour_angle - minute_angle).abs() {
        a if a < pi => a,
        a => pi * 2.0 - a,
    };

    let tip_distance_sq = hour_length.powf(2.0) + minute_length.powf(2.0)
        - 2.0 * hour_length * minute_length * inner_angle.cos();
    println!("{}", tip_distance_sq.sqrt());
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  int N,M,X;cin>>N>>M>>X;
  VECINT MS(M);
  REP(i,M) cin>>MS[i];
  int sep_idx = lower_bound(ALL(MS), X)-MS.begin();
  OUT(min(sep_idx,M-sep_idx));

  return 0;
}

Measured memory_bytes: 256
n=int(input())
table=[[]*2 for i in range(n)]
for i in range(n):
  table[i]=list(map(int,input().split()))
table=sorted(table,key=lambda x:x[1])
T=0
t=0
for i in range(n):
  T=table[i][1]
  t=t+table[i][0]
  if t>T:
    print("No")
    break
if i==n-1 and t<=T:
  print("Yes")

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

// @@ !! LIM()

bool solve() {
  vector<vector<ll>> c(3, vector<ll>(3));
  for (ll i = 0; i < 3; i++) {
    for (ll j = 0; j < 3; j++) {
      cin >> c.at(i).at(j);
    }
  }
  for (ll i = 0; i < 2; i++) {
    ll p = c.at(i+1).at(0) - c.at(i).at(0);
    for (ll j = 1; j < 3; j++) {
      if (c.at(i+1).at(j) - c.at(i).at(j) != p) return false;
    }
  }
  for (ll i = 0; i < 2; i++) {
    ll p = c.at(0).at(i+1) - c.at(0).at(i);
    for (ll j = 1; j < 3; j++) {
      if (c.at(j).at(i+1) - c.at(j).at(i) != p) return false;
    }
  }
  return true;

}

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);
  cout << (solve() ? "Yes\n" : "No\n");
  return 0;
}



Measured memory_bytes: 256
n=list(input())

if int(n[0])>int(n[1]):
    ans = [n[0]]*3
elif int(n[0])==int(n[1]) and int(n[1])>=int(n[2]):
    ans = [n[0]]*3
else:
    ans = [int(n[0])+1]*3
print(*ans,sep="")

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}


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

	ll A = 0;
	ll B = 0;

	A = X / 500;
	B = (X % 500) / 5;
	cout << A * 1000 + B * 5 << endl;

	return 0;
}

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

using namespace std;

template<typename T>
long long modpow(const T n,const T p,const T mod);
template<typename T>
long long modinv(const T n,const T mod);
template<typename T>
bool chmax(T &a,const T &b);
template<typename T>
bool chmin(T &a,const T &b);

long long inf=1000000007;

int main(){
	long long n;
	cin>>n;
	string s;
	cin>>s;
	long long cnt=0;
	long long ans=0;

	for(long long i=0;i<n;i++){
		if(s.at(i)=='W') cnt++;
	}

	for(long long i=0;i<n-cnt;i++){
		if(s.at(i)=='W') ans++;
	}

	cout<<ans<<endl;

	return 0;
}

template<typename T>
long long modpow(const T n,const T p,const T mod){
	if(p==0) return 1;
	if(p%2==0){
		long long a=modpow(n,p/2,mod);
		return a*a%mod;
	}
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}

template<typename T>
long long modinv(const T n,const T mod){
	return modpow(n,mod-2,mod);
}

template<typename T>
bool chmax(T &a,const T &b){
	if(a<b){
		a=b;
		return 1;
	}
	return 0;
}

template<typename T>
bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return 1;
	}
	return 0;
}


Measured memory_bytes: 3756
import scala.io.StdIn._

object Main extends App {


  val n = readInt()

  def solve() = {
    val ansArr = Array.fill(10050)(0)
    val lim = 105
    for {
      x <- 1 to lim
      y <- 1 to lim
      z <- 1 to lim
    } yield {
      val v = x*x + y*y + z*z + x*y + y*z + z*x
      if(v < 10050) ansArr(v) += 1
    }
    (1 to n).map { i =>
      ansArr(i)
    }.mkString("\n")
  }

  println(solve())

}



Measured memory_bytes: 61948
#include <iostream>

int main() {
    int r, g, b;
    std::cin >> r >> g >> b;
    
    int N = r*100 + g*10 + b;
    
    if (N % 4 == 0) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n, m;
  cin >> n >> m;
  int q;
  cin >> q;
  vector<int> a(q);
  for(int i = 0; i < q; i++){
    cin >> a[i];
    a[i]--;
  }

  vector<int> b(m, -1);
  vector<int> pos(m, -1);
  vector<int> freq(m + 1,0);
  freq[0] = n;
  freq[m] = 0;
  int known = 0;
  for(int it = q - 1; it >= 0; it--){
    int i = a[it];
    if(pos[i] == -1){
      b[known] = i;
      pos[i] = known;
      freq[known]--;
      known++;
      freq[known]++;
      continue;
    }
    if(freq[pos[i]] > 0){
      freq[pos[i]]--;
      freq[pos[i] + 1]++;
    }
  }
  
  int first = -1;
  for(int i = 0; i <= m; i++){
    if(freq[i]  > 0){
        first = i;
        break;
    }
  }
  
  vector<int> all;
  for(int i = first; i < known; i++){
     all.push_back(b[i]);
  }
  for(int i = 0; i < m; i++){
    if(pos[i] == -1){
      all.push_back(i);
    }
  }
  
 sort(all.begin(), all.end());
  for(int i = first; i < known; i++){
    if(all[i - first] != b[i]){
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}

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

int main () {

    ll H, W;
    cin >> H >> W;

    ll min_diff = H * W;

    for (ll h = 1; h < H; h++) {

        ll h_B = (H - h)/2;
        ll h_C = H - h - h_B;

        ll s_A = h * W;
        ll s_B = h_B * W;
        ll s_C = h_C * W;

        min_diff = min(min_diff, max(s_A, max(s_B, s_C)) - min(s_A, min(s_B, s_C)));
    }

    for (ll h = 1; h < H; h++) {

        ll h_BC = H - h;
        ll w_B = W/2;
        ll w_C = W - w_B;

        ll s_A = h * W;
        ll s_B = h_BC * w_B;
        ll s_C = h_BC * w_C;

        min_diff = min(min_diff, max(s_A, max(s_B, s_C)) - min(s_A, min(s_B, s_C)));
    }

    for (ll w = 1; w < W; w++) {

        ll w_B = (W - w)/2;
        ll w_C = W - w - w_B;

        ll s_A = H * w;
        ll s_B = H * w_B;
        ll s_C = H * w_C;

        min_diff = min(min_diff, max(s_A, max(s_B, s_C)) - min(s_A, min(s_B, s_C)));
    }

    for (ll w = 1; w < W; w++) {

        ll w_BC = W - w;
        ll h_B = H/2;
        ll h_C = H - h_B;

        ll s_A = H * w;
        ll s_B = h_B * w_BC;
        ll s_C = h_C * w_BC;

        min_diff = min(min_diff, max(s_A, max(s_B, s_C)) - min(s_A, min(s_B, s_C)));
    }

    cout << min_diff << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long   ll;
ll inf=100000000000000000,mod=1000000007;
int main(){
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        ll curr=0,sum=0;
        while(1){
            if(a<=0){curr=1;break;}
            if(c<=0){curr=0;break;}
            if(sum%2==0){
                c-=b;
            }
            else
            a-=d;
            sum++;
        }
        if(curr==0)cout<<"Yes"<<endl;
        else
         cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3648
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let mut k = read::<i64>();
    let mut a = vec![k / 50 + 49; 50];
    k %= 50;
    for i in 0..k {
        let idx = i as usize % 50;
        a[idx] += 50;
        for j in 0..50 {
            if j == idx {
                continue;
            }
            a[j] -= 1;
        }
    }

    println!("50");
    for num in a {
        print!("{} ", num);
    }
    println!("");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

int main() {
  int N;
  cin >>N ;
  vector<int> a(100010);
  for(int i=0;i<N;i++)cin >>a.at(i);
  int light=1;
  int cnt=0;

  for(int i=0;i<N+1;i++){
    light = a.at(light-1);
    cnt++;
    if(light==2){
      cout<<cnt<<endl;
     break;
    }
    if(cnt>=N){
          cout<<-1<<endl;
		break;
    }
    
  }

 // if(kaisuu<=N)cout<<kaisuu<<endl;
 // else cout<<-1<<endl;
}


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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  int c=a[0];
  for(int i=1;i<n;i++){
    c = c^a[i];
  }
  if(c==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 640
N = input()
seq = list(map(int, input().split()))

is_switched = False
for i in range(len(seq)-1):
    if seq[i] <= min(seq[i+1:]):
        continue
    elif seq[i] > min(seq[i+1:]):
        if is_switched:
            print("NO")
            break
        j = seq.index(min(seq[i+1:]))
        seq[i], seq[j] = seq[j], seq[i]
        is_switched = True
else:
    print("YES")


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
    char S[200007];cin >> S;
    ll c=0,T=0,ans=0;
    rep(i,strlen(S)){
        if(S[i]=='A' && T==0){
            T=1;
            c=0;
        }
        c++;
        if(S[i]=='Z' && T==1){
            ans=c;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
/*
*****
Deeeboooo **** (Uchia_Madara)
*****   
*/  
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int x=0,y=0;
    for(int i=0;i<s.size();i++){
        x+=s[i]-'0';
        y=y*10+(s[i]-'0');
    }
    if(y%x==0)
        cout<<"Yes";
    else
        cout<<"No";

}

Measured memory_bytes: 256
void main() {
	auto ip = readAs!(int[]), N = ip[0], Q = ip[1];
	auto S = rs;
	auto arr = new int[](N);
	foreach(i; 0..S.length-1) {
		if(S[i] == 'A' && S[i+1] == 'C') {
			arr[i+1] = arr[i] + 1;
		} else arr[i+1] = arr[i];
	}
	
	foreach(i; 0..Q) {
		auto ip2 = readAs!(int[]), l = ip2[0]-1, r = ip2[1]-1;
		writeln(arr[r] - arr[l]);
	}
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 4476
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;

int main(){
    int a,b; cin>>a>>b;
    for(int i=1;i<=100000;i++){
        int c=i*0.08;
        int d=i*0.1;
        if(c==a&&d==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <vector>
using namespace std;
#define vi vector<int>
#define pb push_back
#define p push
#define sll stack<long long>
#define qll queue<long long>
#define vll vector<long long>
#define vvll vector<vector<ll>>
#define mll map<ll,ll>
#define fori(n) for(int i=0;i<n;i++)
#define forj(n) for(int j=0;j<n;j++)
#define fork(n) for(int k=0;k<n;k++)
#define fori1(n) for(int i=1;i<=n;i++)
#define f(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
#define pi 3.14159265358979323
#include <math.h>
#define yn(n) if(n)cout<<"yes\n";else cout<<"no\n";
#define Yn(n) if(n)cout<<"Yes\n";else cout<<"No\n";
#define YN(n) if(n)cout<<"YES\n";else cout<<"NO\n";
#define mp   macke_pair 
#define MOD 1000000007
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}
int md(int n){
	if(n>0)return n;
	else return -n;
}
void solve(){
	ll n,k,m,x;
	cin>>n>>k>>x;
	cout<<(n/k+!!(n%k))*x<<"\n";
}


int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
 
    	
	int t;
	t=1;
	//cin >> t;
	while(t--){
		solve();
		
	}
	
	//cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

}

Measured memory_bytes: 3592
import java.util.*;
import java.io.*;

public class Main {
    BufferedReader br;
    PrintWriter out;
    StringTokenizer stok;

    String nextToken() throws IOException {
        while (stok == null || !stok.hasMoreTokens()) {
            String s = br.readLine();
            if (s == null) {
                return null;
            }
            stok = new StringTokenizer(s);
        }
        return stok.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    char nextChar() throws IOException {
        return (char) (br.read());
    }

    String nextLine() throws IOException {
        return br.readLine();
    }

    void solve() throws IOException {
        int a = nextInt();
        int b = nextInt();
        int c = nextInt();
        if (a==b) out.println(c);
        if (a==c) out.println(b);
        if (c==b) out.println(a);

    }

    void run() throws IOException {
        // br = new BufferedReader(new FileReader("dragons.in"));
        //out = new PrintWriter("dragons.out");
        // br = new BufferedReader(new FileReader("input.txt"));
        // out = new PrintWriter("output.txt");
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        br.close();
        out.close();
    }

    public static void main(String[] args) throws IOException {
        // Locale.setDefault(Locale.US);
        new Main().run();
    }
}

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

using namespace std;

using int64 = long long;

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

  int n, m;
  cin >> n >> m;
  vector<vector<int>> d_to_v(m + 1);
  for (int i = 0; i < n; i++) {
    int d, v;
    cin >> d >> v;
    if (d > m) continue;
    d_to_v[d].push_back(v);
  }

  priority_queue<int> pq;
  int ans = 0;
  for (int d = 1; d <= m; d++) {
    for (int v : d_to_v[d]) {
      pq.push(v);
    }
    if (!pq.empty()) {
      ans += pq.top();
      pq.pop();
    }
  }
  cout << ans << endl;
}


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

int main(){

  long long L,R;
  cin >> L >> R;

  long long i = L;
  long long j = L+1;
  int min = 2018;
  int now;
  while(i < j && i <= L +2019){
    j = i+1;
  
    while(j <= R && j <= L +2019){
      now = ((i%2019) * (j % 2019)) % 2019;
      if(now < min) min = now;
      j++;
    }
    i++;
  }

  cout << min << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  ll A, B;
  cin >> N >> A >> B;
  vector<ll> H(N);
  rep(i, N) cin >> H[i];
  auto bsearch = [&]() {
    auto test = [&](ll k) {
      ll cnt = 0;
      rep(i, N) cnt += (max(0LL, H[i]-k*B)+(A-B)-1) / (A-B);
      return cnt <= k;
    };
    ll ok = 1e9, ng = 0;
    while(ok-ng>1) {
      ll mid = (ok+ng)/2;
      (test(mid) ? ok : ng) = mid;
    }
    return ok;
  };
  cout << bsearch() << "\n";
  return 0;
}


Measured memory_bytes: 3960
import java.util.Scanner;

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

		String S = sc.next();

		String SList[] = new String[S.length()];
		for(int i=0; i<S.length(); i++){
			SList[i] = S.substring(i,i+1);
		}

		int maxlength = 0;
		int length = 0;

		for(int s=0; s<SList.length; s++){
			if(SList[s].matches("(A|C|G|T)*")){
				length++;
				if(maxlength < length){
					maxlength = length;
				}
			}else{
				length = 0;
				continue;
			}
		}
		System.out.println(maxlength);
    }
}

Measured memory_bytes: 23636
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, k, i, j, ans, a, b, pp, p, s;
	cin >> n >> k;
	vector<long long> x(n), y(n);
	for (i = 0; i < n; i++) cin >> x[i] >> y[i];

	ans = 1LL << 62;
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			if (x[i] <= x[j]) {
				vector<long long> p;
				for (a = 0; a < n; a++) {
					if ((x[a] >= x[i]) && (x[a] <= x[j])) p.push_back(y[a]);
				}
				sort(p.begin(), p.end());
				for (a = 0; a + k <= p.size(); a++) {
					s = (x[j] - x[i]) * (p[a + k - 1] - p[a]); 
					ans = min(ans, s);
				}

			}
		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 888
n = int(input())
A=[]
for x in input().split():
    A.append(int(x))

sort_A = sorted (A)
flag = 0
for i in range(n):
    if ( A[i] != sort_A[i] ) :
        flag = flag + 1

if (flag>2):
    print ('NO')
else:
    print ('YES')

Measured memory_bytes: 3060
const int N = 400005;
const int LG = 21;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <bitset>
#include <deque>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(N);
    __ufact.resize(N);
    __rev.resize(N);
    __rev[1] = 1;
    for (int i = 2; i < N; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < N; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n; cin >> n;
    string s[2]; cin >> s[0] >> s[1];
    ll ans = 1, t = -1;
    for (int i = 0; i < n; i++) if (s[0][i] == s[1][i]) t = i;
    for (int i = t - 1; i >= 0; i--)
    {
        if (s[0][i] == s[1][i] && s[0][i + 1] == s[1][i + 1]) ans = 2 * ans % MOD;
        else if (s[0][i] != s[0][i + 1] && s[0][i] != s[1][i] && s[0][i + 1] != s[1][i + 1]) ans = 3 * ans % MOD;
        else if (s[0][i] != s[1][i] && s[0][i + 1] == s[1][i + 1]) ans = 2 * ans % MOD;
    }
    for (int i = t + 1; i < n; i++)
    {
        if (s[0][i] == s[1][i] && s[0][i - 1] == s[1][i - 1]) ans = 2 * ans % MOD;
        else if (s[0][i] != s[0][i - 1] && s[0][i] != s[1][i] && s[0][i - 1] != s[1][i - 1]) ans = 3 * ans % MOD;
        else if (s[0][i] != s[1][i] && s[0][i - 1] == s[1][i - 1]) ans = 2 * ans % MOD;
    }
    ans = ans * 3;
    cout << ans % MOD;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>
#define pl pair<ll,ll>
#define TC int t;cin>>t;while(t--)
#define in(n) ll n;cin>>n;
#define inarr(n) ll n;cin>>n;vector<ll>arr;
int main(void){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    inarr(n);
    ll dp[n+1];
    memset(dp,0,sizeof(dp));
    dp[0]=0;
    for(int i=0;i<n;i++){
        in(temp);arr.push_back(temp);
    }
    for(int i=1;i<n;i++){
        if(i==1){
            dp[i]+=fabs(arr[i]-arr[i-1]);
        }
        else{
            dp[i]+=min(dp[i-1]+(ll)fabs(arr[i]-arr[i-1]),dp[i-2]+(ll)fabs(arr[i]-arr[i-2]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 5052
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
/*---------------------便利な関数--------------------------------------*/
constexpr long double pi = 3.141592653589793238462643383279;        //円周率
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/*-------------ここまで---------------------------------------------*/
//C++(GCC9.2.1)

signed main() {
    int N, T;
    cin >> N >> T;
    int j = 0, k = 0;
    for (int i = 0; i < N; i++) {
        int t;
        cin >> t;
        j += T - max(k - t, 0LL);
        k = t + T;
    }
    cout << j << endl;
    return 0;
}

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0);

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  vector<int> t(n), a(n);
  REP(i, n) {
    cin >> t[i] >> a[i];
  }
  pair<int, int> p;
  p.first = t[0]; p.second = a[0];

  int tmpt, tmpa, tmp;
  FOR(i, 1, n) {
    tmp = max(p.first/t[i], p.second/a[i]);
    tmpt = t[i] * tmp;
    tmpa = a[i] * tmp;
    while(!(tmpt >= p.first && tmpa >= p.second)) {
      tmpt += t[i];
      tmpa += a[i];
    }
    p.first = tmpt;
    p.second = tmpa;
  }
  cout << p.first + p.second << endl;
}


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

int main() {
    int64_t N, K;
    cin >> N >> K;
    vector<int64_t> A(N), F(N);
    for (int64_t i = 0; i <  N; i++) {
        cin >> A[i];
    }
    for (int64_t i = 0; i <  N; i++) {
        cin >> F[i];
    }
    std::sort(A.begin(), A.end());
    std::sort(F.begin(), F.end());
    std::reverse(F.begin(), F.end());
    int64_t low = -1, high = 1000000000000000ULL;
    while(low + 1 < high) {
        int64_t mid = (low + high) / 2;
        int64_t count = 0;
        for (int64_t i = 0 ; i < N; i++) {
            count += max<int64_t>(0, A[i] - mid / F[i]);
        }
        if (count <= K) {
            high = mid;
        } else {
            low = mid;
        }
    }
    std::cout << high << std::endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

int main() {
	string s; CI s;
	bool flag = false;
	int ans = 0;
	int tmp = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T') {
			if (!flag) flag = true;
			tmp++;
			ans = max(ans, tmp);
		}
		else if (flag) { flag = false; tmp = 0; }
	}
	CO ans EN;
}

Measured memory_bytes: 256
//
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

string str;

int slove(){
  size_t len = str.length();
  char now = str[0];
  vector<char> res;
  res.push_back(now);
  for(size_t i = 1;i < len;i++){
    if(str[i] != now){
      now = str[i];
      res.push_back(now);
    }
  }
  return res.size() - 1;
}

int main(void){
  cin >> str;
  cout << slove() << endl;
  return 0;
}


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

int main() {
   int K;
   cin >> K;
   if(K % 2 == 0) {
    cout << K * K / 4 << endl;
}
   else{
    cout <<  ( K / 2) * (K / 2 + 1) << endl;
}
}


Measured memory_bytes: 256
/*
 * @author Dhruvit
 */
#include<cstring>
#include<math.h>
#include<stdlib.h>
#include <fstream>
#include<algorithm>
#include<vector>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#include<bits/stdc++.h>
#define vi          vector<int>
#define vii         vector<vector<int>>
#define pii         pair<int,int>
#define pb          push_back
#define pf          push_front
#define all(v)      v.begin(),v.end()

int comp(const void* a, const void* b)
{ return *(int*)a > *(int*)b ; }
int findNumberOfTriangles(int arr[], int n)
{
    qsort(arr, n, sizeof( arr[0] ), comp);

    // Initialize count of triangles
    int count = 0;
    for (int i = 0; i < n - 2; ++i)
    {
        int k = i + 2;

        for (int j = i + 1; j < n; ++j)
        {
            while (k < n && arr[i] + arr[j] > arr[k])
                ++k;
            if(k > j)
                count += k - j - 1;
        }
    }

    return count;
}

class DTriangles {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in>>n;
        int arr[n];
        for(int i=0;i<n;i++){
            in>>arr[i];
        }
        out<<findNumberOfTriangles(arr,n);
	}
};


signed main() {
    fast;
	DTriangles solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(){
    int n, current=0, before=0, counter=1;
    cin >> n;
    vector<int> a(n);

    for(int i=0;i<n;i++) cin >> a.at(i);
    int i=0;
    while(a.at(current) != 2){
        if(a.at(current) == 0){
            counter = -1;
            break;
        }
        before = current;
        current = a.at(current) - 1;
        a.at(before) = 0;
        counter++;
    }
    cout << counter << endl;
    return 0;
}


Measured memory_bytes: 640
N = int(input())
mod = 10**9+7
dp = [[0]*4 for _ in range(N)]

dp[0] = [1,1,1,1]
dp[1] = [4,4,4,4]
#AGC, ACG, GAC, A?GC,AG?C -> AGGC, ATGC,AGTC

for i in range(2,N):
  if i == 2:
    dp[i][0] = dp[i-1][0]*4
    dp[i][1] = dp[i-1][1]*4-2
    dp[i][2] = dp[i-1][2]*4-1
    dp[i][3] = dp[i-1][3]*4
  else:
    dp[i][0] = sum(dp[i-1])
    dp[i][1] = sum(dp[i-1])-dp[i-2][0]-dp[i-2][2]-dp[i-3][0]*3
    dp[i][2] = sum(dp[i-1])-dp[i-2][0]+dp[i-3][2]
    dp[i][3] = sum(dp[i-1])
    
print(sum(dp[N-1])%mod)


Measured memory_bytes: 3064