akhauriyash/Code-Regression huggingface dataset:
#頭から分ける場合とけつから分ける場合を考えよう

"""メモ
1142

なんかあってそう
漏れがある
#######################################
blkA_train = arr_train[0:3] 
blkB_train = arr_train[3:4]

abcd
4
4
abc
d

all_list = ['abcd', 'cbad', 'dabc', 'dabc'] setなし　

######################################
blkA_train = arr_train[0:2]
blkB_train = arr_train[2:5]

abcd
4
4
ab
cd

alllist = ['abcd', 'bacd', 'cdab', 'dcab'] setなし

#####################################
blkA_train = arr_train[0:1]
blkB_train = arr_train[1:4]
abcd
4
4
a
bcd

['abcd', 'abcd', 'bcda', 'dcba'] setなし
######################################


"""

arr_train = []
m = input() #kは繰り返す回数
m = int(m)
while(True):
	
	if m == 0:
		break
	x = input()
	arr_train = str(x)
	#arr_train.append(x) #多分appendする必要ない
	
	counter = 0
	"""
	print(len(x)) #len(x) - 1 = n-1 みたいな感じでループ
	print(len(arr_train))
	"""
	
	#blkA_train = [] #最初の分割　これを真ん中のindexの要素を中心に反転しようかな
	#blkB_train = [] #分割されたもの　あとで反転したリストと連結
	
	all_list = []
	
	#文字分割にはリストは必要ない。多分str変数を用意しておいて、ループごとに初期化する。処理終了、連結したstrをリストに保存
	#リストは多分1つだけでよく最後にset+lenで数え上げ
	
	#blkA_train  = None
	#blkB_train  = None
	
	#right = 0 #列車の分割の右分け数
	#left = 0 #列車の分割の左分け数
	
	left = len(arr_train) -1 # まず n-1
	right = 1 #まず1
	
	"""
	blkA_train = arr_train[0:3] #スライスで文字列を指定 このindexを一般化 i j len 左スライスは0で良い 右スライスはleftでいいんじゃない?
	blkB_train = arr_train[3:4] #右スライスは増加していく ループ変数を使え
	"""
	"""
	blkA_train = arr_train[0:2]
	blkB_train = arr_train[2:5]
	"""
	
	"""
	blkA_train = arr_train[0:1]
	blkB_train = arr_train[1:4]
	"""
	
	#反転するものとそうでないもので1ループごとに2つの文字列をリストにappend
	
	"""
	#頭が反転の場合
	all_list.append(blkA_train+blkB_train) #そのまま連結
	all_list.append(blkA_train[::-1]+blkB_train) #反転して連結 ok
	
	#けつが反転の場合
	all_list.append(blkB_train+blkA_train)
	all_list.append(blkB_train[::-1]+blkA_train)
	
	#頭、けつが反転する　頭から連結
	
	all_list.append(blkA_train[::-1]+blkB_train[::-1])
	all_list.append(blkB_train[::-1]+blkA_train[::-1])
	
	all_list.append(blkA_train+blkB_train[::-1])
	all_list.append(blkB_train+blkA_train[::-1])
	"""
	
	while(True):
		blkA_train  = None
		blkB_train  = None
		
		blkA_train = arr_train[0:left]
		blkB_train = arr_train[left:len(arr_train)-1+left]
		
		all_list.append(blkA_train+blkB_train) #そのまま連結
		all_list.append(blkA_train[::-1]+blkB_train) #反転して連結 ok
		
		all_list.append(blkB_train+blkA_train)
		all_list.append(blkB_train[::-1]+blkA_train)
		
		all_list.append(blkA_train[::-1]+blkB_train[::-1])
		all_list.append(blkB_train[::-1]+blkA_train[::-1])
	
		all_list.append(blkA_train+blkB_train[::-1])
		all_list.append(blkB_train+blkA_train[::-1])
		if left == 1: #左分割フラグが1になったら終了
			break
		left -= 1
		#right += 1
	all_list = set(all_list)
	all_list = list(all_list)
	print(len(all_list))
	m -=1

"""
print(blkA_train)
print(blkB_train)
"""

"""
print()
print(all_list)
all_list = set(all_list)
all_list = list(all_list)

print(all_list)
print(len(all_list))
"""
"""
print(blkA_train)
print(blkB_train)

print()
print(all_list)
print()
all_list = set(all_list)
all_list = list(all_list)

print(all_list)
"""




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

int main() { 
    int a, b, ans = 0;;
    cin >> a >> b;
    for(int i = 1; i < 10000; ++i) {
        if((int)(i*0.08) == a && (int)(i*0.1) == b) {
            cout << i << '\n';
            return 0;
        }
    }
    cout << -1 << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++) 
#define fs first
#define sc second
#define _GLIBCXX_DEBUG

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

template <class S>
void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){
		cerr << v[i] << ' ';
	}
	cerr << endl;
}
template <class S>
void print(vector<vector<S>> &v) {
  	for (ll i = 0; i < (ll)v.size(); i++) {
    	for (ll j = 0; j < (ll)v[i].size(); j++) {
      		cerr << v[i][j] << ' ';
    	}
    	cerr << endl;
  	}
}

int main(){
	int k,x; cin >>k>>x;
	for(int i=x-k+1; i<x+k;i++) cout << i << ' ';
}

Measured memory_bytes: 256
import numpy as np

#root = {}でいけるか

def find(a):
    if a==root[a]: return a
    else: root[a] = find(root[a]) ; return root[a]
    
def unite(a,b):
    ra,rb = find(a),find(b)
    if ra==rb : return
    else: root[ra] = rb
    
def same(a,b): return find(a)==find(b)

n,m =  map(int,input().split())
ab = np.array([list(map(int,input().split())) for i in range(m)])
a,b = ab.T[0]-1, ab.T[1]-1

ans = 0
for i in range(m):
    root = list(range(n))
    connect = 0
    for j in range(m):
        if i==j: continue
        if not same(a[j],b[j]): unite(a[j],b[j]); connect += 1
    ans += 0 if connect==n-1 else 1
    
print(ans)


Measured memory_bytes: 12456
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<pair <ll,ll> >ab(n);
    REP(i,n){
        ll a,b;
        cin >> a >> b;
        ab[i].first = b;
        ab[i].second = a;
    }
    sort(ab.begin(),ab.end());
    ll total = 0;
    REP(i,n){
        total+=ab[i].second;
        if(total > ab[i].first){
            cout << "No" <<endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3328
//Bismillahir Rahmanir-Rahim
/**@MSR**/
#include<bits/stdc++.h>
using namespace std;

#define mod 1e9+7
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vll vector<long long>
#define ll long long
#define lli long long int
#define el '\n'
#define inf 2000000000
#define mem(a,b) memset(a, b, sizeof(a) )

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define F1(i,n)  for(lli i=1;i<=n;i++)
#define F0(i,n)  for(lli i=0;i<n;i++)
#define FRev(i,n)  for(lli i=n-1;i>=0;i--)
#define ever (;;)

ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    ll x=(a/gcd(a,b))*b;
    return x;
}

const int mx=1e5+123;
int dp[mx];
int n,k;
int h[mx];

int magic(int i)
{
    if(i==n)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    int ret = inf;
    for ( int j = 1; j <= k; j++ )
    {
        if ( i + j <= n )
            ret = min ( ret, abs ( h[i] - h[i+j] ) + magic ( i+j ) );
    }

    return dp[i] = ret;
}

int main()
{
    optimize();
    ll t,x,y,z,m,a,b;
    /**/
    cin>>n>>k;
    for(int i=1; i<=n; i++)
        cin>>h[i];


    mem(dp,-1);

    cout<<magic(1)<<el;

    return 0;
}
/**/



Measured memory_bytes: 12224
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

class dice {
    int dice[6];
public:
    void input() {
        for(int i=0; i<6; ++i) cin >> dice[i];
    }
    void output() {
        cout << dice[0];
        for(int i=1; i<6; ++i) cout << ' ' << dice[i];
        cout << endl;
    }
    void move(string state) {
        for(int i=0; i<state.length(); ++i) {
            switch(state[i]) {
                case 'N':
                    swap(dice[0], dice[1]);
                    swap(dice[1], dice[5]);
                    swap(dice[5], dice[4]);
                    break;
                case 'S':
                    swap(dice[0], dice[4]);
                    swap(dice[4], dice[5]);
                    swap(dice[5], dice[1]);
                    break;
                case 'E':
                    swap(dice[0], dice[3]);
                    swap(dice[3], dice[5]);
                    swap(dice[5], dice[2]);
                    break;
                case 'W':
                    swap(dice[0], dice[2]);
                    swap(dice[2], dice[5]);
                    swap(dice[5], dice[3]);
                    break;
                default:
                    break;
            }
        }
    }
    int getTopside(string state) {
        move(state);
        return dice[0];
    }
    int index_of(int x) {
        for(int i=0; i<6; ++i) {
            if(dice[i] == x) return i;
        }
        return -1;
    }
    int getRightside(int top, int front) {
        int ind;
        ind = index_of(top);
        if(ind < 0) return -1;
        switch(ind) {
            case 0:
                break;
            case 1:
                move("N");
                break;
            case 2:
                move("W");
                break;
            case 3:
                move("E");
                break;
            case 4:
                move("S");
                break;
            case 5:
                move("NN");
                break;
            default:
                break;
        }
        ind = index_of(front);
        switch(ind) {
            case 0:
                break;
            case 1:
                break;
            case 2:
                move("NWS");
                break;
            case 3:
                move("NES");
                break;
            case 4:
                move("NWWS");
                break;
            case 5:
                break;
            default:
                break;
        }
        return dice[2];
    }
    int getPip(int ind) {
        return dice[ind];
    }
};

int main() {
    dice d1, d2;
    d1.input();
    d2.input();

    if(d1.getPip(2) == d2.getRightside(d1.getPip(0), d1.getPip(1)))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main(){
  int a,b,c;
  cin >> a >> b >> c;

  if(a==b){
    if(b==c){
      printf("1\n");
      }else{
        printf("2\n");
      }
  }else{
    if(b==c){
      printf("2\n");
      }else if(a==c){
        printf("2\n");
        }else{
          printf("3\n");
        }
  }
  return 0;
}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n"
#define rep(i,n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;
typedef pair<string, int> Psi;

int H[110];
int h[110];

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

	int n;cin>>n;

	rep(i,n){
		cin>>H[i];
	}

	bool judge =false;
	int ans =0;
	for(int i=0; i<110; i++){
		for(int j=0; j<n; j++){

			if(h[j]+1 <=H[j]){
				judge =true;
				h[j] +=1;
			}else if(judge) {
				ans++;
				judge =false;
			}
			if(judge && j==n-1){
				ans++;
				judge = false;
			}
		}
/*		rep(i,n){
			cout<<h[i]<<" ";
		}
		cout<<endl;

		writeln(ans);*/
	}
	writeln(ans);






}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline

a = int(input())

c = 1
keta = 0
while True:
    if a < c:
        break
    else:
        a -= c
        c *= 26
        keta += 1

def Base_10_to_n(X, n):
    if (X//n):
        return Base_10_to_n(X//n, n)+[X%n]
    return [X]

l = Base_10_to_n(a,26)
#print(l)

l2 = [chr(x + 65) for x in l]

st = "".join(l2).lower()

st = "a" * (keta-len(st)) + st

print(st)

Measured memory_bytes: 9196
# -*- coding:utf-8 -*-
import itertools


def solve():
    N = int(input())

    if N==1:
        print("a")
        return

    anss = []

    def _dfs(d, _max, ans):
        if d==N:
            anss.append(ans)
            return

        for i in range(ord("a"), _max+2):
            _dfs(d+1, max(_max, i), ans+chr(i))

    _dfs(1, ord("a"), "a")

    anss.sort()

    for ans in anss:
        print(ans)


if __name__ == "__main__":
    solve()


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

int main() {
  int N, K;
  cin >> N >> K;
  int sum =0 ;
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    if(x < K-x){
      sum += x*2;
    }
    else{
      sum += (K-x)*2;
    }

  }

  cout << sum << endl;


}


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

const ll mod = 1e9 + 7;

ll qp(ll a, ll b) {
	ll res = 1;
	while (b) {
		if (b & 1) res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
}

const int N = 1e5 + 10;
char s[N];
ll dp[N];
ll bit[N];

int main() {
	scanf("%s", s);
	int len = strlen(s);
	ll ans = qp(3, len);
	bit[0] = 1;
	for (int i = 1; i <= len; i++) bit[i] = bit[i - 1] * 3 % mod;
	if (s[0] == '0') ans = (ans - 2 * qp(3, len - 1)) % mod;
	ll temp = 4;
	for (int i = 1; i < len; i++) {
		if (s[i] == '0') ans = (ans - temp * bit[len - i - 1] % mod + mod) % mod;
		else temp = temp * 2 % mod;
	}
//	dp[0] = 1;
//	reverse(s, s + len);
//	for (int i = 0; i < len; i++) {
//		if (s[i] == '1') dp[i + 1] = (2 * dp[i] + bit[i]) % mod;
//		else dp[i + 1] = dp[i];
//	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef long long int lli;
int main(void)
{
    lli n,t;
    lli a[200000];
    lli sum=0;

    scanf("%lld %lld",&n,&t);
    for(lli i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    for(lli i=1;i<n;i++){
        if(a[i]-a[i-1]<=t){
            sum+=a[i]-a[i-1];
        }
        else sum+=t;
    }
    sum+=t;
    printf("%lld\n",sum);
    return 0;
}

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

int main(){
    int n ;
    cin >> n;
    vector<int> a(n) ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> a.at(i) ;
    }
    int mod = 1000000007;
    int r = 0;
    int g = 0;
    int b = 0;
    bool pr,pg,pb ;
    int64_t ans = 3 ;
    if (a.at(0) != 0)
    {
        ans = 0 ;
    }
    r = 1;
    for (size_t i = 1; i < n; i++)
    {
        int mul = 0 ;
        pr = false;
        pg = false;
        pb = false;
        if (r == a.at(i))
        {
            mul ++ ;
            pr = true;
        }
        if (g == a.at(i))
        {
            mul ++ ;
            pg = true;
        }
        if (b == a.at(i))
        {
            mul ++ ;
            pb = true ;
        }
        ans *= mul ;
        if (ans > mod)
        {
            ans = ans % mod ;
        }
        if (ans == 0)
        {
            break ;
        }
        if (pr == true)
        {
            r ++ ;
        }else if (pg == true)
        {
            g++ ;
        }else if (pb == true)
        {
            b ++ ;
        }
        
        
        
        
        
        
    }
    cout << ans << endl ;
}

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

int main() {
    // 整数の入力
    int N, i;
    vector<long> a;

    cin >> N;
    a = vector<long>(N, 0);
    for(i = 0; i < N; ++i) cin >> a[i];
    long max;
    long min;
    max = *max_element(a.begin(), a.end());
    min = *min_element(a.begin(), a.end());

    cout << max - min;
    
    return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[4]={0},n;
    rep(i,6) {
        cin >> n;
        a[n-1]++;
    }
    bool f=false;
    rep(i,4) {
        if (a[i] == 3) f=true;
    }
    if(f) {
        cout << "NO" <<endl;
    }
    else {
        cout <<"YES" <<endl;
    }
    return 0;
}

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

#define ll long long

bool debug = false;

int main(void){
  map<int,ll> m;
  vector<int> order;
  int n;
  long long no,amount,price;

  while(cin >> n){
	bool exist = false;
	if(!n) break;
	for(int i=0;i<n;i++){
	  cin >> no >> amount >> price;
	  if(find(order.begin(), order.end(), no) == order.end()){
		order.push_back(no);
		if(debug) cout << "pushed " << no << endl;
	  }
	  m[no] += (ll)amount*price;
	}
	for(int i=0;i<order.size();i++){
	  if(m[order[i]] >= 1e+6){
		cout << order[i] << endl;
		exist = true;
	  }
	}
	if(!exist) cout << "NA" << endl;
	m.clear();
	order.clear();
  }
}

Measured memory_bytes: 0
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        for (int length = s.length() - 2; length >= 2; length -= 2) {
            if (s.substring(0, length/2).equals(s.substring(length/2, length))) {
                System.out.println(length);
                return;
            }
        }
    }
}


Measured memory_bytes: 21844
def main():
    n = int(input())
    t, a = map(int, input().split())
    h = list(map(int, input().split()))

    temp = []
    for h_i in h:
        temp.append(abs(a - (t - h_i * 0.006)))

    ans = temp.index(min(temp)) + 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
n = int(input())

stick = list(map(int, input().split()))

total = sum(stick)
mid = total // 2

cum = 0
midi = 0
for i, block in enumerate(stick):
    cum += block
    if cum >= mid:
        midi = i
        break

l1 = sum(stick[:midi])
r1 = sum(stick[midi:])
diff1 = abs(l1 - r1)
 
l2 = l1 + stick[midi]
r2 = r1 - stick[midi]
diff2 = abs(l2 - r2)
 
print(min(diff1, diff2))

Measured memory_bytes: 26764
import java.io.*;
import java.util.Scanner;


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

        do{
            String line1 = scanner.next();
            String line2 = scanner.next();

            int h = Integer.parseInt(line1);
            int w = Integer.parseInt(line2);

            if(h == 0 && w == 0){
                break;
            }         

            for(int i = 1;i <= h; i++){
                for(int j = 1;j<=w;j++){
                    if(i%2 == 1 && j%2 == 1){
                        System.out.print("#");
                    }else if(i%2 == 1 && j%2 == 0){
                        System.out.print(".");
                    }
                    if(i%2 == 0 && j%2 ==1){
                        System.out.print(".");
                    }else if(i%2 == 0 && j%2 == 0){
                        System.out.print("#");
                    }
                }
                System.out.print("\n");
            }   
            System.out.print("\n");
        }while(true);
    }
}




Measured memory_bytes: 38060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int c(const void *a, const void *b){return strcmp((char*)b,(char*)a);}
int i,j,n,a[2000]={},b,r=1;
char s[200000][11];
int main(){
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%s",s[i]);
    qsort(s,n,11,c);
    for(i=0;i<n-1;i++)if(strcmp(s[i],s[i+1])!=0)r++;
    printf("%d",r);
    return 0;
}

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

constexpr int MaxN = 8;
constexpr int MaxM = (MaxN * (MaxN - 1)) / 2;

int answer = 0;
array<vector<int>, MaxN> edges;

int Count(int s, int check)
{
	if (check == answer)
	{
		return 1;
	}

	int sum = 0;
	for (auto candidate : edges[s])
	{
		int check_cand = 1 << candidate;
		if ((check & check_cand) != 0)
		{
			continue;
		}

		sum += Count(candidate, check | check_cand);
	}

	return sum;
}

int main()
{
	int N, M;

	cin >> N >> M;
	for (int i = 0; i < N; ++i)
	{
		answer |= (1 << i);
	}

	for (int i = 0; i < M; ++i)
	{
		int a, b;
		cin >> a >> b;
		a -= 1;
		b -= 1;

		edges[a].push_back(b);
		edges[b].push_back(a);
	}

	int sum = Count(0, 1);

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<vector>
#include<deque>


#define REP(i,a,b) for(int i = (a); i < b; ++i)
#define inf 1e9+10
#define MOD 1000000007

using ll = long long;
using namespace std;

int main() {
	string s, t;

	cin >> s;
	cin >> t;

	int sum = 0;

	REP(i, 0, s.size()) {
		if (s[i] != t[i]) {
			++sum;
		}
	}

	cout << sum;

	return 0;
}

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

#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl  "\n"

typedef long long int ll ;

void solve()
{
	int x ;
    cin >> x ;
    if (x == 1) cout << 0 << endl ;
    else cout << 1 << endl ;
}  
int main()
{
	ios ;
    solve() ;
}

Measured memory_bytes: 3648
n, k = map(int, input().split())
d = list(map(int, input().split())) #k

def check(n, d):
	# nがdに含まれているか
	# 含まれていないならばTrue
	s = str(n)
	for i in range(len(s)):
		if int(s[i]) in d:
			return False
	return True

res = n

while True:
	if check(res, d):
		print(res)
		break
	res += 1


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

string T;

void input(){
  cin >> T;
}

int main(){
  input();
  for(int i=0;i<T.length();i++){
    if(T[i]=='?'){
      T[i]='D';
    }
  }
  cout << T <<endl;
  return 0;
}


Measured memory_bytes: 3804
S = input()
ans = 0
temp = 0
for i in range(len(S)):
    if S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T':
        temp += 1
    else:
        if ans < temp:
            ans = temp
            temp = 0
        else:
            temp = 0

if ans < temp:
    ans = temp

print(ans)



Measured memory_bytes: 3060
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int a = scanner.nextInt(), b = scanner.nextInt(), c = scanner.nextInt();
        int i = Math.max(Math.max(a, b), c) * 3 - a - b - c;
        System.out.println(((i & 1) == 0 ? i : i + 3) / 2);
    }
}

Measured memory_bytes: 21972
#include <stdio.h>

int main(void)
{
	double a, b, c, d, e, f;
	double x, y;
	
	while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF){
		
		x = (e * c + (-b) * f) / (a * e - d * b);
		y = ((-d) * c + a * f) / (a * e - d * b);
		if (x == 0) x = 0.000;
		else if (y == 0) y = 0.000;
		
		printf("%.3f %.3f\n", x , y);
	}
	
	return (0);
}

Measured memory_bytes: 1080
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

const int MAX_N=200000;
int n,q;
std::vector<int> node[MAX_N+1];
int count[MAX_N+1]={};
int result[MAX_N+1]={};

void DFS(int current,int prev_cum){
  prev_cum+=count[current];
  result[current]=prev_cum;
  for(auto next:node[current]){
    DFS(next,prev_cum);
  }
}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  cin>>n>>q;

  for(int i=0;i<n-1;i++){
    int a,b;
    cin>>a>>b;
    node[a].push_back(b);
  }

  for(int i=0;i<q;i++){
    int p,x;
    cin>>p>>x;
    count[p]+=x;
  }

  DFS(1,0);

  for(int i=1;i<=n-1;i++){
    cout<<result[i]<<" ";
  }
  cout<<result[n]<<endl;






  return 0;
}


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

int main()
{
  string s;
  cin >> s;
  
  string ans = "";
  for(int i = 0; i < s.size(); i++)
  {
    if(s.at(i) != 'B')
    {
      ans += s.at(i);
    }
    else
    {
      if(ans.size() > 0)
        ans.pop_back();
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n, m;
    cin >> n >> m;
    vi cnt(m);
    rep(i, n) {
        int sz;
        cin >> sz;
        rep(j, sz) {
            int d;
            cin >> d;
            cnt[d-1]++;
        }
    }
    int ans = 0;
    rep(i, m) if(cnt[i] == n) ++ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = list(map(int, input().split()))
a = [input() for i in range(m)]
b = []
c = []
total_act = 0
total_act2 = 1
total = 1
if m == 0:
    for i in range(n + 1):
        if str(i) in a:
            total *= total_act
            total_act = 0
            total_act2 = 1
        else:
            total_act3 = total_act2 + total_act
            total_act2 = total_act
            total_act = total_act3
    total *= total_act
    print(total % 1000000007)
else:
    b.append(int(a[0]))
    for i in range(len(a) - 1):
        b.append(int(a[i + 1]) - int(a[i]) - 1)
        if int(a[i + 1]) - int(a[i]) - 1 == 0:
            print(0)
            exit()
    b.append(n - int(a[-1]))

    for i in range(max(b)):
        total_act3 = total_act2 + total_act
        total_act2 = total_act
        total_act = total_act3
        c.append(total_act)

    for i in b:
        total *= c[i - 1]
    print(total % 1000000007)


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

int main() {
    char x, y;
    cin >> x >> y;
    if (x < y) {
        cout << "<" << endl;
    } else if (x > y) {
        cout << ">" << endl;
    } else if (x == y) {
        cout << "=" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int R;
  cin >> R;
  double answer = 2.0 * M_PI * (double)R;
  
  cout << setprecision(10) << answer << endl;
  return 0;
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

//struct Point {
//	int x,y;
//};
//long long ccw(const Point& A, const Point& B, const Point& C) { // 시계방향이면 음수 
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}


int main() { // 골드 1, 플레 1, 네트워크 유량(디닉 알고리즘), 

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll ans = 0;
	ll n; cin >> n; 
	cout << n * (n - (ll)1) / (ll)2 << '\n';




}


Measured memory_bytes: 256
#include <stdio.h>
using namespace std;

int main()
{
  while (1)
  {
    int h, w;
    scanf("%d %d", &h, &w);
    if(h == 0 && w == 0) break;
    for (int i = 0; i < h; i++)
    {
      for (int j = 0; j < w; j++)
      {
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

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

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a), t(b);
    for(int i = 0; i < a; i++) cin >> s[i];
    for(int i = 0; i < b; i++) cin >> t[i];
    auto solve1 = [&](ll x) {
        vector<ll> a(2, -1);
        ll ret = 1e18;
        auto it = lower_bound(s.begin(), s.end(), x);
        if(it!=s.end())a[0] = *it;
        if(it!=s.begin()) it--;
        a[1] = *it;
        for(int i = 0; i < 2; i++) if(a[i] != -1){
            auto it2 = lower_bound(t.begin(), t.end(), a[i]);
            if(it2!=t.end()) {
                chmin(ret, abs(x-a[i])+abs(a[i]-*it2));
            }
            if(it2!=t.begin()) {
                it2--;
                chmin(ret, abs(x-a[i])+abs(a[i]-*it2));
            }
        }
        return ret;
    };

    auto solve2 = [&](ll x) {
        vector<ll> a(2, -1);
        ll ret = 1e18;
        auto it = lower_bound(t.begin(), t.end(), x);
        if(it!=t.end())a[0] = *it;
        if(it!=t.begin()) it--;
        a[1] = *it;
        for(int i = 0; i < 2; i++) if(a[i] != -1){
            auto it2 = lower_bound(s.begin(), s.end(), a[i]);
            if(it2!=s.end()) {
                chmin(ret, abs(x-a[i])+abs(a[i]-*it2));
            }
            if(it2!=s.begin()) {
                it2--;
                chmin(ret, abs(x-a[i])+abs(a[i]-*it2));
            }
        }
        return ret;
    };

    while(q--) {
        ll x;
        cin >> x;
        ll ans = min(solve1(x), solve2(x));
        cout << ans << endl;
    }
}

Measured memory_bytes: 2944
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

#define MAX 30000
#define LEN_MAX 2000

#define TREE_MAX 8192

int tree[TREE_MAX * 2];

int tree_sum_internal(int qleft, int qright, int idx, int sleft, int sright) {
	/* クエリの範囲が、セグメントの範囲から完全に外れている */
	if (qright <= sleft || sright <= qleft) return 0;
	/* セグメントの範囲が、クエリの範囲に完全に含まれる */
	if (qleft <= sleft && sright <= qright) return tree[idx];
	/* 分割する */
	{
		int center = (sright - sleft) / 2 + sleft;
		int left = tree_sum_internal(qleft, qright, idx * 2 + 1, sleft, center);
		int right = tree_sum_internal(qleft, qright, idx * 2 + 2, center, sright);
		return left + right;
	}
}

void tree_add(int pos, int value) {
	int idx = pos + (TREE_MAX - 1);
	tree[idx] += value;
	while (idx > 0) {
		idx = (idx - 1) / 2;
		tree[idx] += value;
	}
}

/* [left, right) */
int tree_sum(int left, int right) {
	return tree_sum_internal(left, right, 0, 0, TREE_MAX);
}

int cmp(const void* x, const void* y) {
	int a = *(const int*)x;
	int b = *(const int*)y;
	if (a < b) return -1;
	return a > b;
}

int N;
int L[MAX];

int main(void) {
	int i, j;
	uint64_t count = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &L[i]) != 1) return 1;
	}
	qsort(L, N, sizeof(*L), cmp);

	for (i = 1; i < N; i++) {
		tree_add(L[i], 1);
	}

	for (j = 1; j < N; j++) {
		tree_add(L[j], -1);
		for (i = 0; i < j; i++) {
			count += tree_sum(0, L[i] + L[j]);
		}
	}

	printf("%" PRIu64 "\n", count);

	return 0;
}

/*
1 2 3
1 2   4
1 2     5
1   3 4
1   3   5
1     4 5
  2 3 4
  2 3   5
  2   4 5
    3 4 5

1 2     5
1   3   5
1     4 5
  2 3   5
  2   4 5
    3 4 5
1 2   4
1   3 4
  2 3 4
1 2 3

*/


Measured memory_bytes: 252
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
using namespace std;

int main()
{
	int n;
	vector<int> ns(3);
	cin >> ns[0] >> ns[1] >> ns[2] >> n;
	sort(ns.begin(), ns.end());

	int cnt = 0, tmp1, tmp2;
	for (int i = 0; i <= n / ns[2]; ++i) {
		tmp1 = ns[2] * i;
		for (int j = 0; j <= (n - tmp1) / ns[1]; ++j) {
			tmp2 = tmp1 + ns[1] * j;
			if ((n - tmp2) % ns[0] == 0)++cnt;
		}
	}


	cout << cnt << endl;
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>x;
	cout<<x*(x+1)/2<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
char a[100][100];
int n,m,i,j;
int main()
{
	scanf("%d%d",&n,&m);
	for (i=0;i<=n+1;i++)
		for (j=0;j<=m+1;j++)
			a[i][j]='.';
	for (i=1;i<=n;i++)
	{ 
		scanf("%s",a[i]+1);
		a[i][m+1]='.';
	} 
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++)
			if ((a[i][j]=='#') && (a[i-1][j]=='.') && (a[i+1][j]=='.') && (a[i][j-1]=='.') && (a[i][j+1]=='.'))
			{
				printf("No");
				return 0;
			}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n,m;
    cin >> n >> m;
    vector<int> v[m];
    rep(i,m){
        int k;
        cin >> k;
        rep(j,k){
            int x;
            cin >> x;
            x--;
            v[i].push_back(x);
        }
    }
    vector<int> p(m);
    rep(i,m) cin>>p[i];
    int cnt = 0;
    rep(i,1<<n){
        bool ok = 1;
        vector<bool> on(n,0);
        rep(j,n){
            if((i>>j)&1) on[j]=1;
        }
        rep(j,m){
            int cnt2 = 0;
            for(auto u : v[j]){
                if(on[u]) cnt2++;
            }
            if(cnt2%2 != p[j]) ok = 0;
        }
        if(ok) cnt++;
    }
    cout<< cnt <<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
num = {}
ans = 0
for i in a:
    num.setdefault(i, 0)
    num[i] += 1
    ans += i
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    num.setdefault(b, 0)
    ans += (c - b) * num[b]
    if c in num.keys():
        num[c] += num[b]
        del num[b]
    else:
        num[c] = num[b]
        del num[b]
    print(ans)

Measured memory_bytes: 93584
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
ll count_div(ll n, ll m) {
    if (n%m != 0) return 0;
    else return 1 + count_div(n/m, m);
}
#endif


int main_C() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, K; cin >> N >> K;
    vi a(N); REP(i, N) cin >> a[i];

    // 1 + ceil((N-K)/(K-1))
    int ans = 1 + (N - 2) / (K - 1);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<string>
using namespace std;
map<string,bool>mp;
int n;
string s[2];
bool f;
int main()
{
	scanf("%d\n",&n);
	n--;
	cin>>s[1];
	mp[s[1]]=1;
	while(n--)
	{
		cin>>s[0];
		if(s[1][s[1].length()-1]!=s[0][0]||mp[s[0]]==1)
			f=1;
		mp[s[0]]=1;
		s[1]=s[0];
	}
	printf("%s",f?"No":"Yes");
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;

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

	vector<int32_t> a(N);
	int64_t total = 0;
	for (int32_t i = 0; i < N; i++) {
		cin >> a[i];
		total += a[i];
	}

	int64_t res = numeric_limits<int64_t>::max();
	int64_t x = 0, y;
	for (int32_t i = 0; i < N - 1; i++) {
		x += a[i];
		y = total - x;
		res = min(res, abs(x - y));
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    string s;
    cin >> s;
    string ans = "AC";
    if (s[0] != 'A') ans = "WA";
    bool c_found = false;
    for (int i = 1, n = s.size(); i < n; i++) {
        if (isupper(s[i])) {
            if (!c_found && s[i] == 'C' && 2 <= i && i <= n - 2) c_found = true;
            else ans = "WA";
        }
    }
    if (!c_found) ans = "WA";
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n,m;
struct st{
	ll x,y,z;
	st(ll _x,ll _y,ll _z):x(_x),y(_y),z(_z){}
};
vector<st> vs;


int main(){
	cin >> n >> m;
	rep(i,n){
		ll x,y,z;
		cin >> x >> y >> z;
		vs.push_back(st(x,y,z));
	}
	ll ans = -INF;
	rep(i,8){
		ll cnt = 0;
		vector<ll> vl;
		rep(j,vs.size()){
			cnt = 0;
			if(i&(1<<0))cnt += vs[j].x;
			else cnt -= vs[j].x;
			if(i&(1<<1))cnt += vs[j].y;
			else cnt -= vs[j].y;
			if(i&(1<<2))cnt += vs[j].z;
			else cnt -= vs[j].z;
			vl.push_back(cnt);
		}
		sort(ALL(vl));
		reverse(ALL(vl));
		cnt = 0;
		rep(j,m){
			cnt += vl[j];
		}
		ans = max(ans,cnt);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int N,K,T,U,V,L;
  while(cin>>N>>K>>T>>U>>V>>L){
    vector<double> D(N);
    REP(i, N) cin>>D[i];
    int cur_idx = 0;
    double now_d = 0;
    double ans = 0;
    int have = 0;
    while(true){
      //printf("distance:%f time:%f\n", now_d, ans);
      if(now_d >= L) break;
      if(have > 0){
        have--;
        double to = now_d + (double)V * T;
        if(to < L){
          double arrive = to;
          while(cur_idx < N && D[cur_idx] <= to){
            have++;
            if(have == K + 1){
              arrive = D[cur_idx];
              cur_idx++;
              break;
            }
            cur_idx++;
          }
          ans += (arrive-now_d)/V;
          now_d = arrive;
        }else{
          double d = L - now_d;
          ans += d/V;
          now_d = L;
        }
      }else{
        if(cur_idx < N){
          //printf("go to D[%d](%f)\n", cur_idx, D[cur_idx]);
          double d = D[cur_idx] - now_d;
          ans += d/U;
          have = 1;
          now_d = D[cur_idx];
          cur_idx++;
        }else{
          double d = L - now_d;
          ans += d/U;
          now_d = L;
        }
      }
    }
    printf("%.9f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1244
#include<iostream>
#include<vector>
using namespace std;
int main(void){
    int r0,w0,c,r;
    while(1){
cin>>r0>>w0>>c>>r;
if(r0==0)break;
int ru=w0*c;
int i=0;
while(r0<ru){
r0+=r;
i++;
}
cout<<i<<endl;
    }
    return 0;
}

Measured memory_bytes: 3096
#include <iostream>
using namespace std;
int main()
{
    long int r, g, b, n, sum=0, i, j;
    cin>>r>>g>>b>>n;
    for(i=0;i*r<=n;i++){
        for(j=0;j*g<=n;j++){
            if(n-i*r-g*j>=0&&(n-i*r-g*j)%b==0)
                sum++;
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static int[][] field = new int[10][10];
    static int[] dx = {1, 0, -1, 0};
    static int[] dy = {0, 1, 0, -1};
    static int[] p = {-2, 0, 2, 0};
    static int[] q = {0, 2, 0, -2};
    static int x, y, size;
    public static void main(String[] args) {
        while(read()){
            write();
        }
        solve();
    }
    static boolean read(){
        if(!sc.hasNext())
            return false;
        String[] input = sc.next().split(",");
        x = Integer.parseInt(input[0]);
        y = Integer.parseInt(input[1]);
        size = Integer.parseInt(input[2]);
        return true;
    }
    static void write(){
        if(size == 1){
            drop_small(x, y);
        }else if(size == 2){
            drop_medium(x, y);
        }else if(size == 3){
            drop_large(x, y);
        }
    }

    static void drop_small(int x, int y){
        field[y][x]++;
        for(int i = 0; i < dx.length; i++){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if( nx >= 0 && nx <= 9 &&  ny >= 0 && ny <= 9 )field[ny][nx]++;
        }
    }

    static void drop_medium(int x, int y){
        for(int i = -1; i <=1; i++){
            for(int j = -1; j <= 1; j++){
                int nx = x + i;
                int ny = y + j;
                if( nx >= 0 && nx <= 9 &&  ny >= 0 && ny <= 9 )field[ny][nx]++;
            }
        }
    }

    static void drop_large(int x, int y){
        drop_medium(x, y);
        for(int i = 0; i < p.length; i++){
            int nx = x + p[i];
            int ny = y + q[i];
            if( nx >= 0 && nx <= 9 &&  ny >= 0 && ny <= 9 )field[ny][nx]++;
        }
    }
    static void solve(){
        int res = 0;
        int max = 0;
        for(int i = 0; i < field.length; i++){
            for(int j = 0; j < field[0].length; j++){
                if(field[i][j] == 0)res++;
                if(field[i][j] > max)max = field[i][j];
            }
        }
        System.out.println(res);
        System.out.println(max);
        /*for(int i = 0; i < field.length; i++){
            for(int j = 0; j < field[0].length; j++){
                System.out.print(field[i][j]);
            }
            System.out.println();
        }*/
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> Pr;
typedef tuple<int, int, int> Tp;
const int INF = 1 << 28;

int n; 
vector<Pr> g[200];
map<string, int> mp;
int dist[200];

bool check(int v, int p)
{
	if (dist[v] != INF) return dist[v] == p;
	dist[v] = p;
	
	for (auto &e : g[v]){
		int to = e.first;
		int cost = e.second;
		if (!check(to, p + cost)) return false;
	}
	
	return true;
}

int main()
{
	while (scanf("%d", &n), n){
		fill_n(g, 200, vector<Pr>());
		mp.clear();
		for (int i = 0; i < n; i++){
			vector<string> v;
			for (int j = 0; j < 5; j++){
				string str;
				cin >> str;
				v.push_back(str);
			}
			string a = v[1];
			string b = v[4];
			int p = atoi(v[3].c_str() + 3);
			int f, t;
			if (mp.count(a)) f = mp[a];
			else f = mp[a] = mp.size() - 1;
			if (mp.count(b)) t = mp[b];
			else t = mp[b] = mp.size() - 1;
			g[f].push_back(Pr(t, p));
			g[t].push_back(Pr(f, -p));
		}
		
		fill_n(dist, mp.size(), INF);
		bool res = true;
		for (int i = 0; i < mp.size(); i++){
			if (dist[i] == INF){
				res &= check(i, 0);
			}
		}
		puts(res ? "Yes" : "No");
	}
	
	return 0;
}

Measured memory_bytes: 1256
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main() {
    multiset<int> s;
    int q; cin >> q;
    while (q--) {
        int com, x; cin >> com >> x;
        if (com == 0) {
            s.emplace(x);
            cout << s.size() << endl;
        } else if (com == 1) {
            cout << s.count(x) << endl;
        } else if (com == 2) {
            s.erase(x);
        } else if (com == 3) {
            int y; cin >> y;
            auto it = s.lower_bound(x);
            while (it != s.end() && *it <= y) cout << *it++ << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 12356
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 200005;

int N,X[3],S,B;
ll dp[41][(1<<16)+1];

int encode(int u){
  if((u&B)==B) return (1<<(S-1));
  else return u&((1<<(S-1))-1);
}

int main(){
  cin >> N >> X[0] >> X[1] >> X[2];
  B = (1<<(X[0]+X[1]+X[2]-1))|(1<<(X[1]+X[2]-1))|(1<<(X[2]-1));
  S = X[0] + X[1] + X[2];
  dp[0][0] = 1LL;
  rep(i,N){
    rep(j,(1<<(S-1))){
      REP(k,1,11){
        (dp[i+1][encode((j<<k)|(1<<(k-1)))] += dp[i][j]) %= lmod;
      }
    }
    (dp[i+1][1<<(S-1)] += dp[i][1<<(S-1)] * 10LL) %= lmod;
  }
  cout << dp[N][(1<<(S-1))] << endl;
  return 0;
}


Measured memory_bytes: 20736
#include <iostream>
#include<bits/stdc++.h>
#define inf 1e9
using namespace std;
int cp(vector<int>v,int n,int k){
    vector<int>dp(n+1);
    dp[1]=0;
    for(int i=2;i<=n;i++){
        dp[i]=inf;
        for(int j=i-1;j>=1 &&(i-j)<=k;j--){
            dp[i]=min(dp[i],abs(v[i]-v[j])+dp[j]);
        }
    }
    return dp[n];
}
int main() {
    int n,k;
    cin>>n>>k;
    vector<int>v(n+1);
    for(int i=1;i<=n;i++)
    cin>>v[i];
    cout<<cp(v,n,k);
}


Measured memory_bytes: 4324
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define MOD 1000000007
typedef long long LL;
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

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

	string string_for_check = S + S;

	if (string_for_check.find(T) == string::npos) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 384