akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
int main() {
  std::string S;
  std::cin >> S;
  int N = (int)(S.size());
  int mi = 1000000000;
  for (int i = 0; i < N - 2; ++i) {
    int x = std::stoi(S.substr(i, 3));
    int d = std::abs(x - 753);
    mi = std::min(mi, d);
  }
  std::cout << mi << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
  int number,save=1;
  int digit = 0;
  int cn=0,input;
  scanf("%d",&input);
 
  do{
    digit = 0;
 	number = save;
  
  while(number != 0){
    number = number / 10;
    digit++;
  }
  if( (digit+1) % 2 ==0){
    cn++;
  }
    save++;
  }while(input != save -1);
  
  printf("%d\n",cn);
  
  return 0;
}


Measured memory_bytes: 128
# input
s = input()
bins = [b == '1' for b in s]

pattern_a = ([True, False] * ((len(s) // 2) + 1))[:len(s)]
pattern_b = ([False, True] * ((len(s) // 2) + 1))[:len(s)]

pat_a_min = [p ^ q for p, q in zip(bins, pattern_a)].count(True)
pat_b_min = [p ^ q for p, q in zip(bins, pattern_b)].count(True)

print(min(pat_a_min, pat_b_min))


Measured memory_bytes: 7012
/*input
3
RRRGGGBBB
*/
#include "bits/stdc++.h"
using namespace std;
const long long md=998244353;
map<set<char>,int> mp;
int n; string s; 
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin >> n >> s;
	mp[set<char>()] = n;
	long long ans = 1;

	for(auto c:s){
		set<char> now = {'R', 'G', 'B'}; now.erase(c);
		if(mp[now]) ans *= mp[now], --mp[now];
		else{
			set<char> a,b;
			for(char i:{'R','G','B'}) if(c!=i) {a.insert(i); break;}
			for(char i:{'R','G','B'}) if(c!=i && !a.count(i)) {b.insert(i); break;}
			if(mp[a] < mp[b]) swap(a,b);
			if(!mp[a]){
				ans *= mp[set<char>()];
				--mp[set<char>()];
				++mp[set<char>{c}];
			} else{
				ans *= mp[a];
				--mp[a];
				a.insert(c);
				++mp[a];
			}
		}
		ans %= md;
	}
	cout << ans;
}


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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);


int main(void)
{
    ll x,sum=0,t=0;
    cin>>x;
    while(sum<x){
        t++;
        sum+=t;
    }
    cout<<t<<endl;
    return 0;
}

Measured memory_bytes: 3628
import math
K=int(input())

sum=K

for i in range(1,K):
    sum+=i
    for j in range(i+1,K+1):
        for k in range(j,K+1):
            if j==k:
                base=math.gcd(i,j)
                sum+=math.gcd(base,k)*6
            else:
                base=math.gcd(i,j)
                sum+=math.gcd(base,k)*6
print(sum)

Measured memory_bytes: 9200
class Process():

    def __init__(self, data):
        self.name = data[0]
        self.time = int(data[1])
        self.endtime = 0

    def process(self, time):
        process_time = min(time, self.time)
        self.time -= process_time
        return process_time

    def is_done(self):
        return self.time <= 0


class MyQueue():

    def __init__(self, max):
        self.Q = [None for _ in range(max)]
        self.head = 0
        self.tail = 0
        self.max = max

    def enqueue(self, x):
        if self.is_full():
            raise ValueError
        self.Q[self.tail] = x
        self.tail += 1
        if self.tail == self.max:
            self.tail = 0

    def dequeue(self):
        if self.is_empty():
            raise IndexError
        ret = self.Q[self.head]
        self.head += 1
        if self.head == self.max:
            self.head = 0
        return ret

    def is_empty(self):
        return self.head == self.tail

    def is_full(self):
        return self.head == (self.tail + 1) % self.max

def main():
    n, q = map(int, input().split())
    queue = MyQueue(n + 1)
    current_time = 0
    done = []
    [queue.enqueue(Process(input().split())) for i in range(n)]

    while True:
        try:
            p: Process = queue.dequeue()
        except IndexError:
            break
        process_time = p.process(q)
        current_time += process_time
        if p.is_done():
            p.endtime = current_time
            done.append(p)
        else:
            queue.enqueue(p)

    [print(p.name, p.endtime, sep=" ") for p in done]

if __name__ == "__main__":
    main()



Measured memory_bytes: 19632
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		boolean[][] judg = new boolean[n+1][n+1];
		for(int i=0;i<n+1;i++){
			Arrays.fill(judg[i],false);
		}
		for(int i=0;i<n;i++){
			int u = stdIn.nextInt();
			int k = stdIn.nextInt();
			for(int j=0;j<k;j++){
				int v = stdIn.nextInt();
				judg[u][v] = true;
			}
		}
		int[] d = new int[n+1];
		int[] f = new int[n+1];
		int count = 0;
		
		for(int i=1;i<=n;i++){
			count = func(judg,d,f,i,count);
		}
		
		for(int i=1;i<=n;i++){
			System.out.println(i+" "+d[i]+" "+f[i]);
		}
	}
	
	static int func(boolean[][] judg,int[] d,int[] f,int now,int count){
		if(d[now]!=0){
			return count;
		}
		d[now] = ++count;
		for(int i=1;i<judg.length;i++){
			if(judg[now][i]){
				count = func(judg,d,f,i,count);
			}
		}
		f[now] = ++count;
		return count;
	}
}

Measured memory_bytes: 20956
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		//入力表示

		int X = sc.nextInt();
		int a = X;

		while (!determine(a)) {
			a++;
		}
		System.out.println(a);
	}

	public static boolean determine(int s) {
		if (s >= 2) {
			for (int i = 2; i * i <= s; i++) {
				if (s % i == 0) {
					return false;
				}
			}
		}
		return true;
	}
}

Measured memory_bytes: 27056
//#pragma GCC optimize("trapv")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
#include <x86intrin.h>
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;
const int maxn = 2e6 + 55, mod = 1000000007;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	cout << (500*n>=k?"Yes":"No");
}


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

struct edge {
    int to;
    int from;
    int64_t point;
};

#define INF -(int64_t)(1e18)

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

    vector<edge> E(M);
    vector<int64_t> P(N, INF);

    for (int i = 0; i < M; ++i) {
        cin >> E[i].from >> E[i].to >> E[i].point;
        E[i].from--;
        E[i].to--;
    }

    P[0] = 0;

    int cnt = 0;
    int64_t ds;
    bool flag = false;
    bool update = true;

    while (update && cnt < 2 * N) {
        cnt++;
        bool update = false;

        for (const auto &e : E) {
            if (P[e.from] != INF && P[e.to] < P[e.from] + e.point) {
                P[e.to] = P[e.from] + e.point;
                update = true;
            }
        }

        if (cnt == N - 1) {
            ds = P[N - 1];
        }

        if (cnt == 2 * N && ds < P[N - 1]) {
            goto loop;
        }
    }
end:
    cout << P[N - 1] << endl;
    return 0;
loop:
    cout << "inf" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

// https://atcoder.jp/contests/abc143/tasks/abc143_a
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();


		//あまり部分0以上ならば完全に隠れる。
		int result = 2*B - A;
		if(result>=0) {
			System.out.println(0);
		} else {
			System.out.println((-1)*result);
		}



	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n;
    intl w[n];
    cin(i,w);
    intl min = INF;
    intl a = 0;
    intl b = 0;
    rep(i,n)a += w[i];
    rep(i,n){
        a -= w[i];
        b += w[i];
        min = min(min,abs(a - b));
    }
    cout << min << endl;
    return 0;
}

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

int main(void){
        int n, ans = 0;
        cin >> n;
        for(int i = 1; i <= n; i++){
                if(n%i==0) ans += n/i-1;
                else ans += n/i;
        }
        cout << ans << endl;
        return 0;
}


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

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

int main()
{
    string s, p;
    cin >> s >> p;
    s += s + s;

    rep(i, s.size())
    {
        bool flg = false;
        rep(j, p.size())
        {
            if (i + j == s.size() || s[i + j] != p[j])
            {
                flg = true;
                break;
            }
        }
        if (!flg)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3176
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;
import std.numeric;
import std.bigint;
import core.checkedint;

void main()
{
	int[] arr;
	foreach (i; 0..10) {
		arr ~= readln.chomp.to!int;
	}
	std.algorithm.sort(arr);
	foreach (v; arr.retro[0..3]) {
		v.writeln;
	}
}

void tie(R, Args...)(R arr, ref Args args)
		if (isRandomAccessRange!R || isArray!R)
in
{
	assert (arr.length == args.length);
}
body
{
	foreach (i, ref v; args) {
		alias T = typeof(v);
		v = arr[i].to!T;
	}
}

void verbose(Args...)(in Args args)
{
	stderr.write("[");
	foreach (i, ref v; args) {
		if (i) stderr.write(", ");
		stderr.write(v);
	}
	stderr.writeln("]");
}



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

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))    
#define OUT(P) cout << (P) << endl    
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl    
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;    
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)    
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)    
typedef long long ll;    

int sum_digits(int num);    
template <class T>    
vector<T> copy_vector(vector<T> vec);    
int gcd(int a, int b);    

void print_pair(const vector<pair<int, int>> &pts) {
    for(int i=0; i<pts.size(); i++) {
        cout << "(" << pts[i].first << ", " << pts[i].second << ")" << " ";
    }
    cout << endl;
}


bool find_difs(const vector<pair<int, int>> &diffs, const pair<int, int> &diff) {
    for(int i=0; i<diffs.size(); i++) {
        if((diffs[i].first == diff.first && diffs[i].second == diff.second))  {
            return true;
        }
    }
    return false;
}

int main() {    
    int n;
    cin >> n;
    vector<pair<int, int>> pts(n);
    for(int i=0; i<n; i++) {
        int x, y;
        cin >> x >> y;
        pts[i].first = x;
        pts[i].second = y;
    }

    int ans = 1;
    if(n > 1) {
        map<pair<int, int>,int> diffs;
        for(int i=0; i<n; i++) {
            for(int j=0; j<n; j++) {
                if(i != j) {
                    int difx = pts[i].first - pts[j].first;
                    int dify = pts[i].second - pts[j].second;
                    pair<int, int> diff = make_pair(difx, dify);
                    diffs[diff]++;
                }
            }
        }
        ///for(auto it=diffs.cbegin(); it!=diffs.cend(); it++) {
        ///    cout << it->first.first << "," << it->first.second << ": " << it->second << endl;
        ///}
        pair<pair<int, int>, int> x = *max_element(diffs.begin(), diffs.end(), 
                [](const pair<pair<int, int>, int> &pt1, const pair<pair<int, int>, int> &pt2){return pt1.second < pt2.second; });
        ans = n - x.second;
    }
    cout << ans << endl;
    return 0;    
}    

/******************************/    
/***** DECRARED FUNCTIONS *****/    
/******************************/    

int sum_digits(int num) {    
    int rtn = 0;    
    while(num != 0) {    
        int tmp = num % 10;    
        rtn += tmp;    
        num /= 10;    
    }    
    return rtn;    
}    

// vectorのコピー    
template <class T>    
vector<T> copy_vector(vector<T> vec) {    
    vector<T> rtn;    
    rtn.reserve(vec.size());    
    copy(vec.begin(), vec.end(), back_inserter(rtn));    
    return rtn;    
}    

// ユークリウッドの互除法    
int gcd(int a, int b) {    
    if(b==0) return a;    
    else return gcd(b, a % b);    
}


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

int main()
{
  int A,B;
  cin >> A >> B;
  if(A==B)
  {
    cout << 2*A;
  }else if(A>B)
  {
    cout << 2*A-1;
  }else
  {
    cout << 2*B-1;
  }
  
  return 0;
}

Measured memory_bytes: 256
function parseInput(input) {
  const values = []
  input.split('\n').forEach(row => {
    const list = row.split(' ')
    list.forEach(v => values.push(v))
  })

  return values
}

function getInput() {
  return parseInput(require('fs').readFileSync('/dev/stdin', 'utf8'))
}
(function main() {
  const input = getInput()
  const N = +input[0]
  const R = +input[1]
  
  if (N < 10) {
    console.log(R + 100 * (10 - N))
  } else {
    console.log(R)
  }
})()



Measured memory_bytes: 21064
//#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main() {
	int n, k;
		cin>>n>>k;
		vector<int> v(n);
		rep(f,n){
			cin>>v.at(f);

		}

		priority_queue<int> q;
		int ans=0;
		//cout<<min(n,k)<<endl;
		rep(i,min(n,k)+1){
			int jj = 0;
			if (i == 0){
				jj=1;
			}
			for(int j=jj;j<min(n,k)-i+1;j++){
				//cout<<100+i+10*j<<endl;
				rep(a,i){
					//cout<<"a"<<endl;
					q.push(-v.at(a));
				}
				rep(b,j){
					q.push(-v.at(n-b-1));
					//cout<<"b"<<endl;
				}
				//cout<<100+i+10*j<<endl;
				rep(s,k-i-j){
					if ((q.top()<=0)||q.empty()){
						//cout<<"bre"<<endl;
						break;
					}else{
						q.pop();
						//cout<<"q"<<endl;
					}
				}
				int sum=0;
				while(!q.empty()){
					sum -= q.top();
					q.pop();

				}

				ans = max(sum,ans);
				//cout<<ans<<endl;
			}
		}

		cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define MAX 2000
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2


int A[N][N], n;

int out()
{
  int i, u, v, minv, sum = 0;
  int d[N], p[N], color[N];

  for( i = 0 ; i < n ; i++)
  {
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }
  d[0] = 0;

  while(1)
  {
    minv = INFTY;
    u = -1;
    for( i = 0; i < n ; i++)
    {
      if(minv > d[i] && color[i] != BLACK)
      {
        u = i;
        minv = d[i];
      }
    }
    if( u == -1 ) break;
    color[u] = BLACK;
    for( v = 0 ; v < n ; v++)
    {
      if( color[v] != BLACK && A[u][v] != INFTY )
      {
        if( d[v] > A[u][v] )
        {
          d[v] = A[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }
  for( i = 0 ; i < n ; i++ )
  {
    if( p[i] != -1 ) sum += A[i][p[i]];
  }

  return sum;
}

int main()
{
  int i, j, s;
  scanf("%d", &n);
  for( i = 0 ; i < n ; i++ )
  {
    for( j = 0 ; j < n ; j ++)
    {
      scanf("%d", &s);
      A[i][j] = (s == -1) ? INFTY : s;
    }
  }

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

  return 0;
}



Measured memory_bytes: 2036
N=int(input())
suits=["S","H","C","D"]
cards=[]
for _ in range(N):
    s,n=input().split()
    if s=="S":
        cards.append(int(n))
    elif s=="H":
        cards.append(13+int(n))
    elif s=="C":
        cards.append(26+int(n))
    else:
        cards.append(39+int(n))
        
for i in range(1,53):
    if i not in cards:
        print(suits[(i-1)//13],(i-1)%13+1)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
    using namespace std;
     
    int main()
    {
      int a = 0 , sum = 0;
     long long int n ;
     long long int n2;
     cin >> n;
     n2 = n;
     while(n>0){
       a = n % 10;
       sum += a;
       n = n / 10;
     }
     
     
     if(n2 % sum == 0) cout << "Yes" << endl;
     else cout << "No" << endl;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int N, L;
  cin >> N >> L;

  int left = L;
  int right = L + N - 1;

  int eat;
  if (right <= 0) eat = right;
  else if (left >= 0) eat = left;
  else eat = 0;

  int ans = (left + right) * N / 2 - eat;
  cout << ans << endl;
}


Measured memory_bytes: 3612
#include<stdio.h>
#pragma warning (disable:4996)
int main()
{
	int n;
	scanf("%d", &n);
	int sum = 0;
	int m = n;
	while (n)
	{
		sum += n % 10;
		n /= 10;
	}
	if (m%sum == 0)printf("Yes");
	else printf("No");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> vx(n);
	vector<int> vy(m);
	bool flag = false;
	for( int &i : vx ) cin >> i;
	for( int &i : vy ) cin >> i;
	sort(vx.begin(), vx.end());
	sort(vy.begin(), vy.end());
	if( vx.back() >= vy.front() || x >= y ){
		flag = true;
	}
	if(
		x+1 < vx.back()+1 && y < vx.back()+1
		||
		vy.front() < x+1 && vy.front() < y
	){
		flag = true;
	}
	cout << (( flag ) ? "War" : "No War" ) << endl; 
	return 0;
}

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

vector<vector<int> >g;
int n,m,q,s,t;

vector<bool>visited;
vector<int>color;
void dfs(int s){
    for(int i=0;i<g[s].size();i++){
        if(color[g[s][i]]==-1){
            color[g[s][i]]=color[s];
            dfs(g[s][i]);
        }
    }
}
bool dfs2(int s,int t){
    if(s==t)return true;
    visited[s]=true;
    for(int i=0;i<g[s].size();i++){
        if(!visited[g[s][i]]){
            if(dfs2(g[s][i],t)){
                return true;
            }
        }
    }
    return false;
}
int main() {
    scanf("%d %d",&n,&m);
    g.resize(n);
    color.resize(n,-1);
    for(int i=0;i<m;i++){
        scanf("%d %d",&s,&t);
        g[s].push_back(t);
        g[t].push_back(s);
    }
    for(int i=0;i<n;i++){
        if(color[i]==-1){
            color[i]=i;
            dfs(i);
        }
    }
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%d %d",&s,&t);
        visited.resize(n,false);
        string s1=(dfs2(s,t)?"yes":"no");
        string s2=(color[s]==color[t]?"yes":"no");
        if(s1!=s2&&s1=="yes")return 1;
        printf((color[s]==color[t]?"yes\n":"no\n"));
    }
    return 0;
}

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

using namespace std;

#define MAX 		26
#define BASE		97

//zyxwvutsrqponmlkjihgfedcba

//abcdefghijklmnopqrstuvwxyz

int main(){
	int count[MAX];
	int point = -1;
	string st;

	cin >> st;

	for(int i=0;i<MAX;++i)
		count[i] = 0;	

	for(auto t:st){
		count[(int)t-BASE]++;
	}
	for(int i=0;i<MAX;++i){
		if(count[i]==0){
			point = i;
			break;
		}
	}
	if(point != -1){
		st += (char)(BASE+point);
		cout << st << endl;;
	}
	else{
		int minl = -1;
		for(int i=26;i>0;--i)
			if(st[i-1] < st[i]){
				minl = i;
				break;
			}
		if(minl == -1){
			cout << minl << endl;
			return 0;
		}

		for(int i=26;i>=0;--i)
			if(st[minl-1] < st[i]){
				st[minl-1] = st[i];
				break;
			}
		st.erase(st.begin()+minl,st.end());
		cout << st << endl;
	}
}

Measured memory_bytes: 256
S = input()
ans = "AC"
l = len(S)
if S[0] != "A":
    ans = "WA"

if len(S[2:-1].replace("C", "")) != l-4:
    ans = "WA"

s = S.replace("C", "").replace("A", "")
if len(s) != l-2 :
    ans = "WA"
if not s.islower():
    ans ="WA"

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+5;
int a[N],b[N];
map<long long,int>mp;
int main(){
	int h,w,m,x,y,ma1=0,ma2=0,si1=0,si2=0;scanf("%d%d%d",&h,&w,&m);
	for(int i=0;i<m;i++)scanf("%d%d",&x,&y),a[x]++,b[y]++,mp[1ll*x*N+y]=1;
	for(int i=1;i<=h;i++)ma1=max(ma1,a[i]);
	for(int i=1;i<=h;i++)if(a[i]==ma1)a[si1++]=i;
	for(int i=1;i<=w;i++)ma2=max(ma2,b[i]);
	for(int i=1;i<=w;i++)if(b[i]==ma2)b[si2++]=i;
	for(int i=0;i<si1;i++)
		for(int j=0;j<si2;j++)
			if(!mp[1ll*a[i]*N+b[j]])return printf("%d",ma1+ma2),0;
	printf("%d",ma1+ma2-1);
	return 0;
}

Measured memory_bytes: 24932
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
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 get_index(v: usize, silver: usize) -> usize {
    v * 2501 + silver
}

fn main() {
    let v = read_vec::<i64>();
    let (n, m, s) = (v[0] as usize, v[1] as usize, v[2]);
    let mut edges = vec![vec![]; n * 2501];
    for _ in 0..m {
        let v = read_vec::<i64>();
        let (u, v, a, b) = (v[0] as usize - 1, v[1] as usize - 1, v[2] as usize, v[3]);
        for pi in a..2501 {
            edges[get_index(u, pi)].push(Edge {
                to: get_index(v, pi - a),
                cost: b,
            });
            edges[get_index(v, pi)].push(Edge {
                to: get_index(u, pi - a),
                cost: b,
            });
        }
    }
    for i in 0..n {
        let v = read_vec::<i64>();
        let (c, d) = (min(v[0], 2500) as usize, v[1]);
        for pi in c..2501 {
            edges[get_index(i, pi - c)].push(Edge {
                to: get_index(i, pi),
                cost: d,
            });
        }
    }
    let s = min(s, 2500) as usize;
    let cost = solve(&edges, get_index(0, s));
    for i in 1..n {
        let ans = (0..2501).map(|x| cost[get_index(i, x)]).min().unwrap();
        println!("{}", ans);
    }
}

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()
}

use std::cmp::Ordering;
use std::collections::BinaryHeap;
const INF: i64 = 100000_00000_00000;

#[derive(PartialEq, Debug)]
struct MinInt {
    value: i64,
}

impl Eq for MinInt {}

impl PartialOrd for MinInt {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        other.value.partial_cmp(&self.value)
    }
}

impl Ord for MinInt {
    fn cmp(&self, other: &MinInt) -> Ordering {
        other.value.cmp(&self.value)
    }
}

fn make_pair(x: i64, y: usize) -> (MinInt, usize) {
    (MinInt { value: x }, y)
}

#[derive(Debug, Clone)]
struct Edge {
    to: usize,
    cost: i64,
}

fn solve(edges: &Vec<Vec<Edge>>, start_idx: usize) -> Vec<i64> {
    let num_apexes = edges.len();
    let mut d = vec![INF; num_apexes];
    d[start_idx] = 0;
    let mut que = BinaryHeap::new();
    que.push(make_pair(0, start_idx));

    while let Some((u, v)) = que.pop() {
        if d[v] < u.value {
            continue;
        }
        for e in &edges[v] {
            if d[v] != INF && d[e.to] > d[v] + e.cost {
                d[e.to] = d[v] + e.cost;
                que.push(make_pair(d[e.to], e.to));
            }
        }
    }
    d
}


Measured memory_bytes: 21856
import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,W=mp()
dp=[[10**10]*(n*1000+1) for i in range(n+1)]
for i in range(n+1):
    dp[i][0]=0
for i in range(1,n+1):
    w,v=mp()
    for k in range(n*1000+1):
        dp[i][k]=dp[i-1][k]
        if k-v>=0:
            dp[i][k]=min(dp[i-1][k],dp[i-1][k-v]+w)
ans=0
for i in range(n*1000+1):
    if dp[-1][i]<=W:
        ans=i
print(ans)

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

import collections
cnt = collections.Counter(a)
ans = 0
for ai, ni in cnt.items():
    ans += ai * ni
for _ in range(q):
    bi, ci = map(int, input().split())
    tmp = cnt[bi]
    del cnt[bi]
    cnt[ci] = tmp + cnt[ci]
    ans = ans - bi * tmp + ci * tmp
    print(ans)
    





Measured memory_bytes: 24032
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(a,b,c) for(int i=a;i<b;i+=c)  
typedef pair<ll , pair<ll, ll> > pi;
int pow(int x,int y){
    int res=1;
    while(y){
        if(y&1) res*=x;
        y>>=1;
        x*=x;
    }
    return res;
}   
struct Compare {
    constexpr bool operator()(pi const & a,
                              pi const & b) const noexcept
    { return a.first < b.first || (a.first == b.first && a.second.first > b.second.first); }
 
};
void prefix_function( string s,ll arr[] )
{
     long long border=0; arr[0]=0;
    for(long long i=1;i<s.size();i++)
    {
      while(border>0 && s[i]!=s[border])
        border=arr[border-1];
     
     if(s[i]==s[border])
         border++;
      else
       border=0;
      
      arr[i]=border;
    }
}
ll mod=998244353;
ll add( ll a , ll b)
{
    return (((a%mod)+(b%mod))%mod);
}
ll mul(ll a,ll b)
{
  return (((a%mod)*(b%mod))%mod);
}
//send mod-2 for a^-1 if mod is a prime number
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) res = mul(res, a);
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}
ll dsu_arr[100000];
ll dsu_sz[100000];
void dsu(ll n)
{
    for(ll i=0;i<=n;i++)
    {
        dsu_arr[i]=i;
        dsu_sz[i]=1;
    }
}
ll find(ll x)
{
     ll root=x;
    while (root!=dsu_arr[root])
    {
        root=dsu_arr[root];
    }
    while(x!=dsu_arr[x])
    {
        dsu_arr[x]=root;
        x=dsu_arr[x];
    }
    return root;
}
ll merge(ll x,ll y)
{
    ll root1=find(x);
    ll root2=find(y);
    
    if(root1==root2)
    return 0ll;
 
    if(dsu_sz[x]>dsu_sz[y]){
    dsu_arr[root2]=root1;
    dsu_sz[x]+=dsu_sz[y];
    }
    else
    {
         dsu_sz[y]+=dsu_sz[x];
        dsu_arr[root1]=root2;
    }
    return 1ll;
}


int main()
{
    Fast
 ll n;
 cin>>n;
 unordered_map<ll,ll>count;
 vector<ll>sura;
 for(ll i=0;i<n;i++)
 {
     ll k;
     cin>>k;
     count[k]++;
     sura.push_back(k);

 }
 if(n==1)
 {
     cout<<1<<endl;
     return 0;
 }
 ll ans=0;
 for(ll i=0;i<n;i++)
 {
     ll x=sura[i];
     ll y=n-1;
     for(ll j=1; j*j<=x;j++)
     {
        if(x%j==0)
        {
            if(j!=x/j)
            {
                

                      if(x==j)
                    y-=count[j]-1;
                    else
                    {
                          y-=count[j];
                    }
                     if(x==x/j)
                    y-=count[x/j]-1;
                    else
                    {
                          y-=count[x/j];
                    }
                      
                
            }
            else
            {
                  if(x==j)
                    y-=count[j]-1;
                    else
                    {
                          y-=count[j];
                    }
            }
            
        }
     }
    
     if(y==n-1 )
     ans++;
 }
 cout<<ans<<endl;

}



   
      
    
        



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

int main() {
  int N, M, L, R, X, Y;
  cin >> N >> M >> L >> R;
  X = L, Y = R;

  for (int i = 1; i < M; i++) {
    cin >> L >> R;
    X = max(X, L);
    Y = min(Y, R);
    if (Y < X || Y < L || R < X) {
      cout << 0 << endl;
      return 0;
    }
  }

  cout << Y - X + 1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int N, max = 0, x = 0;
	scanf("%d", &N);
	char s[N];
	scanf("%s", s);

	for(int i = 0; s[i] != '\0'; i++){
		if(s[i] == 'I'){
			x ++;
		}else if(s[i] == 'D'){
			x --;
		}if(max < x){
			max = x;
		}
	}
	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 1720
N = int(input())
T = [int(x) for x in input().split()]
V = [int(x) for x in input().split()]

import itertools
tv = [0] + list(itertools.chain(*[[v] * t * 2 for t, v in zip(T, V)])) + [0]
for i in itertools.accumulate(T):
    tv[i * 2] = min(tv[i * 2], tv[i * 2 + 1])
for i in range(len(tv)-1, 0, -1):
    if tv[i] < tv[i-1] - 0.5:
        tv[i-1] = tv[i] + 0.5
    elif tv[i] > tv[i-1] + 0.5:
        for j in range(i, len(tv) - 1):
            if tv[j-1] + 0.5 < tv[j]:
                tv[j] = tv[j-1] + 0.5
            else:
                break
print(sum([(v1 + v2) * 0.5 * 0.5 for v1, v2 in zip(tv[1:], tv[:-1])]))

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;

int mpow(int n,int m){
    int ret=1;
    while(m){
        if(m&1)ret=ret*n%mod;
        n=n*n%mod;
        m>>=1;
    }
    return ret;
}

int N,C;
int A[444],B[444];

int dp[444][444];

int table[444][444];

signed main(){
    cin>>N>>C;
    rep(i,N)cin>>A[i];
    rep(i,N)cin>>B[i];

    for(int i=0;i<=C;i++){
        for(int j=1;j<=400;j++){
            table[i][j]=(table[i][j-1]+mpow(j,i))%mod;
        }
    }

    dp[0][0]=1;
    rep(i,N){
        for(int j=0;j<=C;j++){
            for(int k=0;j+k<=C;k++){
                int tmp=(table[k][B[i]]-table[k][A[i]-1]+mod)%mod;
                dp[i+1][j+k]=(dp[i+1][j+k]+dp[i][j]*tmp)%mod;
            }
        }
    }

    cout<<dp[N][C]<<endl;
    return 0;
}


Measured memory_bytes: 3072
from collections import deque
import sys
input = sys.stdin.readline

mod = 10**9 + 7
INF = float("inf")

N, K = map(int, input().split())

edges = [[] * N for _ in range(N)]
for _ in range(N - 1):
    # 頂点の番号を0-indexに直す
    a, b = map(lambda x: int(x) - 1, input().split())
    edges[a].append(b)
    edges[b].append(a)

# 0をrootとする
dq = deque([0])

# color[i] = i番目の頂点を塗ることが可能な色の数
# visitedの管理も兼ねている（別にvisited配列を作っても特に問題はない）
# 後述するように負の値が入ることを許しているので、-1や0などで初期化するのはNG
color = [INF] * N
color[0] = K

"""
root = 0 から末端に向かって調べる

子1, 子2, 子3, ...と複数の「未着色」の子がある場合、塗ることが出来る色の数は
K-1, K-2, K-3,... (p==0 の場合)
K-2, K-3, K-4,... (p!=0 の場合)　のようになる

子が十分多い場合、どこかで「0」になるので、ans = 0　となる
故に、色の数が負になっても答えには影響しない
"""
ans = K

while dq:
    # 親となる頂点
    p = dq.popleft()
    # 親をpとした時の、「未着色」な子の数
    cnt = 0
    for c in edges[p]:
        if color[c] == INF:
            if p == 0:
                color[c] = (K - 1 - cnt) % mod
            else:
                color[c] = (K - 2 - cnt) % mod
            ans = (ans * color[c]) % mod
            cnt += 1
            dq.append(c)

print(ans)


Measured memory_bytes: 90736
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n, m; std::cin >> n >> m;
    std::string s; std::cin >> s;
    std::set<int> st;
    for (int i = 0; i <= n; i++)
        if (s[i] == '0') st.insert(i);
    int pos = n;
    std::vector<int> ans;
    int cnt = 0;
    while (pos > 0) {
        auto iter = st.lower_bound(pos - m);
        ans.push_back(pos - *iter);
        pos = *iter;
        cnt++;
        if (cnt > n) {
            std::cout << -1 << std::endl;
            return 0;
        }
    }
    std::reverse(ans.begin(), ans.end());
    for (int i : ans) std::cout << i << " ";
    std::cout << std::endl;
    return 0;
}



Measured memory_bytes: 5756
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int capacity = sc.nextInt();
		long[][] productInfo = new long[n][2];
		for(int i = 0;i < n;i++) {
			// 重さ
			productInfo[i][0] = sc.nextInt();
			// 価値
			productInfo[i][1] = sc.nextInt();
		}
		// その重さでの最大の価値を記録する。
		long[] maxValueInfo = new long[capacity +1];
		maxValueInfo[0] =1;

		for(int i =0;i < productInfo.length;i++) {
			int weight = (int)productInfo[i][0];
			int value = (int)productInfo[i][1];
			for(int j = capacity; j >=0;j--) {
				if(maxValueInfo[j] != 0) {
					if(j + weight <= capacity) {
						if(j != 0) {
							if(maxValueInfo[j + weight] < maxValueInfo[j] + value) {
								maxValueInfo[j + weight] = maxValueInfo[j] + value;
							}
						}else {
							if(maxValueInfo[weight] < value) {
								maxValueInfo[weight] = value;
							}
						}
					}
				}
			}
		}
		long answer = 0;
		for(int i =1; i <= capacity; i++) {
			if(maxValueInfo[i] > answer) {
				answer = maxValueInfo[i];
			}
		}
		System.out.println(answer);

	}
}

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

//---- Swapping Two Numbers
int main()
{
    int a,b;
    while(1){
        cin >> a >> b;
        if(a==0 && b==0)
            break;
        if(a>b)
            swap(a,b);
        cout << a << " " << b << endl;
    }
    return 0;
}

Measured memory_bytes: 3000
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node *Node;

#define NIL NULL

Node root;
int num=0;

void insert(Node);
void inorder(Node);
void preorder(Node);

int main(){
  char command[20];
  int i,n,v,j;
  Node z;
  
  //root->key = -1;
  
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%s",command);
    if(strcmp(command,"insert") == 0){
      scanf("%d",&v);
      z = malloc(sizeof(struct node));
      z->key = v;
      z->left = NIL;
      z->right = NIL;
      insert(z);
    }
    else if(strcmp(command,"print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    
  
  }

  
  return 0;
}

void insert(Node z){
  Node y = NIL;
  Node x = root;
  num++;
  while(x!=NIL){
    y = x;
    if(z->key<x->key){
      x = x->left;      
    }else{
      x = x->right;
    }
  }
  z->parent = y;
  
  if(y == NIL){
    root = z;
  }else if(z->key < y->key){
    y->left = z;
  }else{
    y->right = z;
  }
}

void inorder(Node root){
  if(root != NIL){
    inorder(root->left);
    printf(" %d",root->key);
    inorder(root->right);
  }

}

void preorder(Node root){
  if(root == NIL){
    return;
  }
  printf(" %d",root->key);
  preorder(root->left);
  preorder(root->right);
}



Measured memory_bytes: 25204
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <math.h>

using namespace std;

#define INF 210000000
#define int long long

static long long gcd(long long a, long long b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

static long long lcm(long long a, long long b) { return a * b / gcd(a, b); }

signed main() {
    int n;
    int ans = 0;
    cin >> n;
    for(int i=0;i<n;i++){
        int tmp;
        cin >> tmp;
        while(tmp % 2 == 0){
            ans++;
            tmp /= 2;
        }
    }
    cout <<ans;
}



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

int main(){

int n,k;
cin>>n>>k;
vector<int> arr(n);
for(int i=0;i<n;i++){
   cin>>arr[i];
}
vector<int> dp(n,INT_MAX);

dp[0]=0;

for(int pos=0;pos<n;pos++){
    for(int jump=pos+1;jump<=(pos+k);jump++){
       if(jump<n){
          dp[jump]=min(dp[jump],dp[pos]+abs(arr[pos]-arr[jump]));
       }
       
   }
}
cout<<dp[n-1]<<"\n";
 return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;
vector <int> n;

int main(){
	map <int,int> hn,wn;
	int hm=0,wm=0;
	vector <int> hl,wl;
	int h,w,m,a,b;
	map <long long,int> plac;
	bool dec=true;
	cin>>h>>w>>m;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		hn[a]++;
		if(hn[a]==hm){
			hl.push_back(a);
		}else if(hn[a]>hm){
			hl.clear();
			hl.push_back(a);
			hm=hn[a];
		}
		wn[b]++;
		if(wn[b]==wm){
			wl.push_back(b);
		}else if(wn[b]>wm){
			wl.clear();
			wl.push_back(b);
			wm=wn[b];
		}
		plac[a*1000000+b]=1;
	}
	for(int i=0;i<hl.size();i++){
		for(int j=0;j<wl.size();j++){
			if(plac[hl[i]*1000000+wl[j]]!=1){
				dec=false;
				break;
			}
		}
		if(!dec){
			break;
		}
	}
	if(dec){
		cout<<hm+wm-1<<endl;
	}else{
		cout<<hm+wm<<endl;
	}
	return 0;
}

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

signed main() {

  int X, N;
  cin >> X >> N;

  map<int, int> p;
  int tmp;

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

  int diff = 1000;
  int ans = 0;

  for(int i = 0; i <= 101; i++){
    if(p.find(i) == p.end()){
      if(abs(X - i) < diff){
        ans = i;
        diff = abs(X - i);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      String S = sc.next();
      int r = 0;
      int l = 0;
      for(int i=1;i<S.length();i++){
        if(S.charAt(i)=='E'){
          r++;
        }
      }
      int min = r+l;
      int count = 0;
      for(int i=1;i<N;i++){
        if(S.charAt(i-1)=='W'){
          l++;
        }
        if(S.charAt(i)=='E'){
          r--;
        }
        count = l+r;
        min = Math.min(min,count);
      }
      System.out.println(min);
    }
}

Measured memory_bytes: 42316
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H==0&&W==0) {break;}
			for (int i=0; i<H; i++) {
				for (int j=0; j<W; j++) {
					if (i==0||i==H-1||j==0||j==W-1) {System.out.print("#");}
					else {System.out.print(".");}
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}



Measured memory_bytes: 37620
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor

import heapq
import itertools
import operator


def get_int():
    return int(input())


def get_str():
    return input().strip()


def get_int_list():
    return [int(i) for i in input().split()]


def get_char_list():
    return list(input().strip())


def main():
    t, x = get_int_list()
    print(float(t) / float(x))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38424
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000000 + 7;

vector<vector<ll>> c(2010, vector<ll>(2010, 0));

ll comb(ll n, ll r) {
    if (c.at(n).at(r) != 0) return c.at(n).at(r);
    if (n <= 0) {
        return 1;
    }
    if (n == r or r == 0) {
        c.at(n).at(r) = 1;
        return 1;
    } else {
        c.at(n).at(r) = comb(n - 1, r - 1) % MOD + comb(n - 1, r) % MOD;
        return c.at(n).at(r);
    }
}

int main() {
    int s;
    cin >> s;
    int n = s / 3;
    ll cnt = 0;
    for (ll i = 1; i <= n; i++) {
        cnt += comb(i - 1 + s - 3 * i, i - 1) % MOD;
        cnt %= MOD;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 34704
from collections import defaultdict as dd
x, n = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
d = dd(int)
for i in a:
    d[i] = 1

left, right = x-1, x+1

if x not in d:
    print(x)
else:
    while(1):
        if left not in d:
            print(left)
            break
        if right not in d:
            print(right)
            break
        left -=1
        right +=1

    


Measured memory_bytes: 9472
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T>
T pow_ (T x, T n, T M){
    uint64_t u = 1, xx = x;
    while (n > 0){
        if (n&1) u = u * xx % M;
        xx = xx * xx % M;
        n >>= 1;
    }
    return static_cast<T>(u);
};

int main() {
    int n, m, a, b, c, t;
    while(cin >> n >> m >> a >> b >> c >> t, n){
        vector<int> v(n);
        for (auto &&l : v) scanf("%d", &l);
        vector<vector<int>> mat(n, vector<int>(n, 0));
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                if(i == j+1) mat[i][j] = a;
                if(i == j) mat[i][j] = b;
                if(i == j-1) mat[i][j] = c;
            }
        }
        vector<vector<int>> ret(n, vector<int>(n, 0));
        for (int i = 0; i < n; ++i) {
            ret[i][i] = 1;
        }
        while(t > 0){
            if(t&1) {
                vector<vector<int>> J(n, vector<int>(n, 0));
                for (int i = 0; i < n; ++i) {
                    for (int j = 0; j < n; ++j) {
                        for (int k = 0; k < n; ++k) {
                            (J[i][j] += mat[i][k]*ret[k][j]) %= m;
                        }
                    }
                }
                ret = J;
            }
            vector<vector<int>> J(n, vector<int>(n, 0));
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < n; ++j) {
                    for (int k = 0; k < n; ++k) {
                        (J[i][j] += mat[i][k]*mat[k][j]) %= m;
                    }
                }
            }
            mat = J;
            t >>= 1;
        }
        vector<int> ans(n);
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                (ans[i] += ret[i][j]*v[j]) %= m;
            }
        }
        for (int i = 0; i < n; ++i) {
            if(i) printf(" ");
            printf("%d", ans[i]);
        }
        puts("");
    }
    return 0;
}


Measured memory_bytes: 3280
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

ll N;
char s[30303];

ll L[30303][10];
ll R[30303][10];

ll flg[1000];

int main(){

    cin >> N;
    rep1(i, N)cin >> s[i];
    for(ll i = 2; i <= N; i++){
        rep(j, 10)L[i][j] = L[i - 1][j];
        L[i][s[i - 1] - '0'] = 1;
    }
    for(ll i = N - 1; i >= 1; i--){
        rep(j, 10)R[i][j] = R[i + 1][j];
        R[i][s[i + 1] - '0'] = 1;
    }
    rep1(i, N){
        rep(j, 10)rep(k, 10)if(L[i][j] && R[i][k]){
            flg[j * 100 + (s[i] - '0') * 10 + k] = 1;
        }
    }
    ll ans = 0;
    for(ll i = 0; i <= 999; i++){
        if(flg[i]){
            ans++;
            // cout << i << endl;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace PrimeNumber
{
    class Program
    {
        static void Main(string[] args)
        {
 
            var input = Console.ReadLine();
            long readNumber = int.Parse(input);
            bool isPrimeNumber = false;
            
            while(isPrimeNumber == false)
            {
                CountPrimeNumber(ref readNumber, ref isPrimeNumber);
            }
 
            Console.WriteLine(readNumber);                                 
        }
 
        static void CountPrimeNumber(ref long broughtNumber, ref bool isPrimeNumber)
        {
            isPrimeNumber = true;
            for (int i = 2; i < Math.Sqrt(broughtNumber); i++)
            {
                long primeNumber = broughtNumber % i;
                if (primeNumber == 0)
                {                    
                    isPrimeNumber = false;
                    broughtNumber++;
                    break;
                }                                
            }            
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll a, b, c;
  cin >> a >> b >> c;

  if (a + b >= c){
    cout << "No" << endl;
  }
  else {
    if (4*a*b < (c - a - b) * (c - a - b))
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  

  return 0;
}


Measured memory_bytes: 256
# 数値で入力ではなく, 文字列で入力しlist関数を使う
k = int(input())
s = input()
n = len(s)
list_s = list(s)

# リストのスライス機能を使用
if n > k:
    tmp = list_s[0:k]
    print(''.join(tmp) + '...')
else: print(''.join(list_s))

Measured memory_bytes: 9176