akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int max_array(const int a[], int n)
{
    int max;

    max = a[0];
    for (int i = 1; i < n; i++){
        if (a[i] > max) max = a[i];
    }

    return max;
}

bool check_prime(int target, const vector<int>& prime_numbers)
{
    bool b = true;
    for (int n : prime_numbers){
        if (n * n > target) break;

        if (target % n == 0){
            b = false;
            break;
        }
    }

    return b;
}

vector<int> derive_prime_numbers(int max)
{
    vector<int> v;

    v.push_back(2);
    for (int i = 3; i <= max; i += 2){
        if (check_prime(i, v)) v.push_back(i);
    }

    return v;
}

int count_prime_numbers(const int a[], int n)
{
    int cnt = 0;

    int max = max_array(a, n);
    vector<int> prime_numbers = derive_prime_numbers((int)sqrt(max));

    for (int i = 0; i < n; i++){
        if (check_prime(a[i], prime_numbers)) cnt++;
    }

    return cnt;
}

int main()
{
    int n;
    int *a;     // 後の配列

    cin >> n;
    a = new int[n];
    for (int i = 0; i < n; i++) cin >> a[i];

    cout << count_prime_numbers(a, n) << endl;

    delete[] a;

    return 0;
}



Measured memory_bytes: 3144
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll a,b;
int32_t main(){
CODE_START;
cin>>a>>b;
if(a<b){
    for(ll i=0;i<b;i++)
        cout<<a;
    }else if(b<a){
    for(ll i=0;i<a;i++)
        cout<<b;
    }else {
    for(ll i=0;i<a;i++)
        cout<<a;
    }
}



Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  string s;
  int k;
  cin >> s;
  cin >> k;
  vector<string> ss;
  for(int i = 0; i < s.size(); ++i)
  {
    for(int j = 0; j < std::min((int)s.size() - i + 1, k+1); ++j)
    {
      ss.push_back(s.substr(i,j));
    }
  }
  sort(ss.begin(), ss.end());
  auto i = unique(ss.begin(),ss.end());
  ss.erase(i, ss.end());
  cout << ss[k] << endl;
}


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

int main(){
  string s;cin>>s;
  int n=s.size();
  bool ans=1;
  int sum=0;
  for(int i=1;i<n;i++){ 
    if(i>1&&i<n-1&&s[i]=='C'){
      sum++;
      if(sum>1)ans=0;
      continue;
    }
    if('a'>s[i]||s[i]>'z')ans=0;
  }
  if(s[0]!='A'||s[1]=='C'||s[n-1]=='C'||sum==0)ans=0;
  cout<<(ans?"AC":"WA");
}


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

int main() {
  int n;
  cin >> n;
  double ans=0;
  vector<int> whex(n),whey(n);
  rep(i,n) cin >> whex[i] >> whey[i];
  vector<int> v(n);
  rep(i,n) v[i]=i;
  do{
    int nowx=whex[v[0]],nowy=whey[v[0]];
    for(int i=1;i<n;i++){
        int x=whex[v[i]],y=whey[v[i]];
        double dist=sqrt((x-nowx)*(x-nowx)+(y-nowy)*(y-nowy));
        ans += dist;
    }
  }while(next_permutation(v.begin(),v.end()));
  double cut=1;
  rep(i,n){
      cut*=(i+1);
  }
  double fans=ans/cut;
  cout << fixed << setprecision(10);
  cout << fans << endl;
}



Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int h, w; cin >> h >> w;
    auto c = vec<ll>(10, 10); cin >> c;
    FOR(k, 0, 10)FOR(i, 0, 10)FOR(j, 0, 10) {
        chmin(c[i][j], c[i][k] + c[k][j]);
    }
    ll ans = 0;
    FOR(i, 0, h* w) {
        int a; cin >> a;
        if (a == -1)continue;
        ans += c[a][1];
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int n;
map<int,int> mp;

int main() {
    cin >> n;
    vector<ll> a(n);
    vector<ll> s(n+2);
    s[0] = 0;
    REP(i,n){
        cin >> a[i];
        s[i+1] = s[i] + a[i];
    }
    s[n+1] = LLONG_MAX;
    sort(s.begin(),s.end());
    ll cnt = 1;
    ll res = 0;
    REP(i,n+2){
        if(s[i]==s[i+1]){
            cnt++;
        }else{
            if(cnt>1){
                res += (cnt-1)*cnt/2;
            }
            cnt = 1;
        }
    }
    put(res);
    return 0;
}


Measured memory_bytes: 3328
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
	ll ans = 1;
	ll n,x;
	cin>>n>>x;
	ll d = 0; 
	rep(i,0,n){
		ll a;
		cin>>a;
		if(d+a<=x)ans++;
		d += a;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int>p(n);
    for(int i = 0; i < n; i++) {
        cin >> p[i];
    }
    int ans = 0;
    for(int i = 1; i < n-1; i++) {
        if(p[i] > p[i-1] && p[i] < p[i+1]) {
            ans++;
        }
        else if(p[i] < p[i-1] && p[i] > p[i+1]) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
	int n = 0, no;
	char mark;
	int card[4][15];
	cin >> n;
	for (int i = 0; n > i; i++){
		cin >> mark;
		cin >> no;
		switch (mark){
			case 'S':
				card[0][no] = 99;
				break;
    		case 'H':
				card[1][no] = 99;
				break;
			case 'C':
				card[2][no] = 99;
				break;
			case 'D':
				card[3][no] = 99;
				break;
		}
	}
	for (int i = 0; i < 4;i++){
		for (int n = 1; n <= 13;n++){
			if (card[i][n]!=99){
				switch (i){
				case 0:
					cout << "S " << n << endl;
					break;
				case 1:
					cout << "H " << n << endl;
					break;
				case 2:
					cout << "C " << n << endl;
					break;
				case 3:
					cout << "D " << n << endl;
					break;
				}


			}
		}
	}
	return 0;
}

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
# 整数の入力
#a = int(input())
# スペース区切りの整数の入力
#b, c = map(int, input().split())
# 文字列の入力
#s = input()
# 出力
#print("{} {}".format(a+b+c, s))

from collections import Counter

n = int(input())
s=[input() for i in range(n)]
l=Counter(s)
m=0
for i in l.values():
  m=max(m,i)
ans=[]
for k,v in l.items():
  if v==m:
    ans.append(k)
ans.sort()
print(*ans,sep='\n')


Measured memory_bytes: 35940
#include <bits/stdc++.h>
using namespace std;
long long n,k;
long long ans=0,dp[107][10007],sub=0,sum=0;
const long long mod=1e9+7;
long long pw(long long a,long long b){
	if(b==0) return 1LL;
	if(b==1) return a;
	long long ret=pw(a,b/2);
	if(b%2==0) return ret*ret%mod;
	else return ret*ret%mod*a%mod;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin>>n>>k;
	ans=(n*(((k+1)*k)/2LL))%mod;
	ans=(ans*pw(k+1,n-1))%mod;
	dp[n+1][0]=1;
	for(int i=n;i>=1;i--){
		int sv=sum;
		for(int j=0;j<=sum;j++){
			for(int t=0;t<=k;t++){
				if(t<=i){
					dp[i][j+(j+t)/i]=(dp[i][j+(j+t)/i]+dp[i+1][j])%mod;
					sv=max(sv,j+j/i+1);
				}
				else{
					dp[i][j]=(dp[i][j]+dp[i+1][j])%mod;
				}
			}
		}
		while(dp[i][sv]==0) sv--;
		sum=sv;
	}
	for(int i=1;i<=sum;i++){
		sub=(sub+1LL*i*dp[1][i])%mod;
	}
	ans=ans-sub+mod;
	ans%=mod;
	cout<<ans;
}


Measured memory_bytes: 6656
#168
#c
import math
a,b,h,m = list(map(int, input().split()))
oa = (60*h + m)/2
ob = m*6
cos_ab = math.cos(math.radians(oa-ob))
c = abs((a**2 + b**2 -2*a*b*cos_ab)**0.5)
print(c)


Measured memory_bytes: 9496
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <queue>

using namespace std;

map<string, int> dp;
int dx[4]={-1, 1, 4, -4};

void bfs(){
    string now="01234567";
    dp[now]=0;
    queue<string> q;
    q.push(now);
    while(q.size()){
        now=q.front(); q.pop();
        int z;
        for(int i=0; i<8; i++)
            if(now[i]=='0') z=i;
        for(int i=0; i<4; i++){
            int n=z+dx[i];
            if(n>=0&& n<8 &&(!(z==3&&i==1))&&(!(z==4&&i==0))){
                string next=now;
                swap(next[n], next[z]);
                if(dp.find(next)==dp.end()){
                    dp[next]=dp[now]+1;
                    q.push(next);
                }
            }
        }
    }
}
int main(){
    bfs();
    string line;
    while(getline(cin, line)){
        line.erase(remove(line.begin(), line.end(), ' '), line.end());
        cout<<dp[line]<<endl;
    }
}


Measured memory_bytes: 5324
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n;
	scanf("%lld",&n);
	if(n==2){
		printf("1");return 0;
	}
	long long ans=0;
	for(ll i=1;i*i<=n-1;i++){
        if((n-1)%i==0){
            if(i!=1)ans++;
            if((n-1)/i!=i)ans++;
        }
    }
	ans++;
	for(long long i=2;i*i<=n;i++){
		if(n%i==0){
			long long s=n;
			while(s%i==0) s/=i;
			if(s%i==1) ans++;
		}
	}
	printf("%lld",ans);
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define FOR(i, n, m) for(ll i = (ll)n; i < (ll)(m); i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define PRINT(x) std::cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dx[8] = {0,1,0,-1, 1, -1, 1, -1}, dy[8] = {1,0,-1,0,1,1,-1,-1};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{
  ll H, W, K;
  cin >> H >> W >> K;
  vector<vector<ll>> mat(H, vector<ll>(W, 0));
  REP(i, H) {
    string s;
    cin >> s;
    REP(j, W) {
      if (s[j] == '#') mat[i][j] = 1;
    }
  }
  ll ans = 0;
  REP(i, pow(2, H)) {
    vector<vector<ll>> tmp1(mat);
    REP(j, H) {
      if ( (i >> j) & 1) {
        REP(k, W) tmp1[j][k] = 2;
      }
    }
    REP(j, pow(2, W)) {
      vector<vector<ll>> tmp2(tmp1);
      REP(k, W) {
        if ((j >> k) & 1) {
          REP(l, H) tmp2[l][k] = 2;
        }
      }

      // count black
      ll cnt = 0;
      REP(x, H) {
        REP(y, W) {
          if (tmp2[x][y] == 1) {
            cnt++;
          }
        }
      }
      if (cnt == K) ans++;
    }
  }
  PRINT(ans);
  return 0;
} 


Measured memory_bytes: 4092
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<int> sum(N+1,0);
  for(int i=0; i<N; i++){
    sum[i+1] = sum[i] + (S[i]=='W' ? 1 : 0);
  }
  int ans=mod;
  for(int i=0; i<N; i++){
    chmin(ans,((N-(i+1))-(sum[N]-sum[i+1]))+sum[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1796
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,w,i,j;
    cin>>h>>w;
    string s;
    vector<string>vs;
    for(i = 0 ;i<h ;i++)
    {
        cin>>s;
        vs.push_back(s);
    }
    for(i = 0 ;i<w+2 ;i++)
        cout<<"#";
    cout<<endl;
    for(i = 0 ;i<h ;i++)
    {
        cout<<"#"<<vs[i]<<"#"<<endl;
    }
    for(i = 0 ;i<w+2 ;i++)
        cout<<"#";
    cout<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
            string N = Console.ReadLine();
            Console.WriteLine(N[0] == N[2] ? "Yes":"No");
        }
    }
}


Measured memory_bytes: 13140
import java.util.*;
import java.io.*;
import java.text.*;
//Solution Credits: Taranpreet Singh
public class Main{
    //SOLUTION BEGIN
    void pre() throws Exception{}
    void solve(int TC) throws Exception{
        int n = ni(), W = ni();
        long[] dp = new long[1+W];
        Arrays.fill(dp, -IINF);
        dp[0] = 0;
        for(int i = 0; i< n; i++){
            int w = ni();long v = nl();
            for(int j = W-w; j>= 0; j--)if(dp[j]!=-IINF)dp[j+w] = Math.max(dp[j+w], dp[j]+v);
        }
        for(int i = 1; i<= W; i++)dp[i] = Math.max(dp[i], dp[i-1]);
        pn(dp[W]);
    }
    //SOLUTION END
    void hold()throws Exception{throw new Exception("Hold right there, Sparky!");}
    long mod = (long)1e9+7, IINF = (long)4e18;
    final int INF = (int)2e9, MX = (int)1e6+1;
    DecimalFormat df = new DecimalFormat("0.000000000000000");
    double PI = 3.1415926535897932384626433832792884197169399375105820974944, eps = 1e-8;
    static boolean multipleTC = false, memory = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        int T = (multipleTC)?ni():1;
        //Solution Credits: Taranpreet Singh
        pre();for(int i = 1; i<= T; i++)solve(i);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{   
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }  
            return str;
        }
    }
}    

Measured memory_bytes: 24660
from collections import Counter
N = int(input())
Alist = list(map(int,input().split()))
numcntlist = [0] * N 
numCounter = Counter(Alist)

for i in range(1,N+1):
    numcntlist[i-1] = numCounter[i]

sumcomb = 0
for i in numcntlist:
    sumcomb += int(i*(i-1)/2)

for i in Alist:
    ans = sumcomb -(numCounter[i] - 1)
    print(ans)

Measured memory_bytes: 34124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    vector<ll>a(n),b(n);
    rep(0,i,n){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b.begin(),b.end());
    ll c=0;
    rep(0,i,n){
        if(a[i]!=b[i])++c;
    }
    if(c<=2)cout<<"YES";
    else cout<<"NO";
}


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

using namespace std;

int main() {
	int n, a, b, c, d;
	scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
	string s;
	cin >> s;

	a --, b --, c --, d --;
	if (a > b) {
		swap(a, b);
		swap(c, d);
	}

	if (d < c) {
		while (1) {
			if (a + 1 < b and s[a + 1] == '.') a ++;
			else if (a + 2 < b and s[a + 2] == '.') a += 2;
			else break;
		}

		while (a < b) {
			if (a + 1 < n and a + 1 != b and s[a + 1] == '.') {
				a ++;
				continue;
			}
			if (a + 2 < n and a + 2 != b and s[a + 2] == '.') {
				a += 2;
				continue;
			}
			if (b + 1 < n and s[b + 1] == '.') {
				b ++;
				continue;
			}
			if (b + 2 < n and s[b + 2] == '.') {
				b += 2;
				continue;
			}
			break;
		}
		if (a < b) return !printf("No\n");
		while (a < c) {
			if (a + 1 < n and s[a + 1] == '.') a ++;
			else if (a + 1 < n and s[a + 2] == '.') a += 2;
			else break;
		}

		while (b < d) {
			if (b + 1 < n and s[b + 1] == '.') b ++;
			else if (b + 2 < n and s[b + 2] == '.') b += 2;
			else break;
		}
	} else {
		while (b < d) {
			if (b + 1 < n and s[b + 1] == '.') b ++;
			else if (b + 2 < n and s[b + 2] == '.') b += 2;
			else break;
		}
		while (a < c) {
			if (a + 1 < n and s[a + 1] == '.') a ++;
			else if (a + 1 < n and s[a + 2] == '.') a += 2;
			else break;
		}
	}

	if (a == c and b == d) puts("Yes");
	else puts("No");
}

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

int main () {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  int count = 0;
  for (int i = 0; i < n; i++) {
    int mini = i;
    for (int j = i; j < n; j++) {
      if (a.at(j) < a.at(mini)) mini = j;
    }
    if (mini != i) {
      int b = a.at(i), c = a.at(mini);
      a.at(i) = c;
      a.at(mini) = b;
      count++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (i == n-1) cout << a.at(i) << endl;
    else cout << a.at(i) << ' ';
  }
  cout << count << endl;
}


Measured memory_bytes: 3128
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    N, M = map(int, readline().split())
    path = [[] for _ in range(N+1)]
    for _ in range(M):
        a,b = map(int, readline().split())
        path[a].append(b)
        path[b].append(a)
    if set(path[1])&set(path[N]):
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

if __name__ == '__main__':
    main()

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

int main() {
  int N;
  cin >> N;
  int P[N],Q[N];
  for(int i = 0;i < N;i++)
    cin >> P[i];
  for(int i = 0;i < N;i++)
    cin >> Q[i];

  int sa_q[N],sa_p[N];
  for(int i = 0;i < N;i++){
    sa_p[i] = P[i] - 1;
    for(int j = 0;j < i;j++){
      if(P[j] < P[i])
	sa_p[i]--;
    }
    sa_q[i] = Q[i] - 1;
    for(int j = 0;j < i;j++){
      if(Q[j] < Q[i])
	sa_q[i]--;
    }
  }

//  for(int i = 0;i < N;i++){
//    cout << sa_p[i];
//  }
//  cout << endl;
//    for(int i = 0;i < N;i++){
//    cout << sa_q[i];
//  }
//  cout << endl;


  long long ans1 = 0,ans2 = 0;
  long long tmp1 = 0,tmp2 = 0;
  int tt;
  for(int i = 0;i < N;i++){
    tmp1 = 1;
    tt = N - 1 - i;
    for(int j = tt;j > 1;j--){
      tmp1 *= j;
    }
    //    cout << tmp1 << endl;
    ans1 += tmp1 * sa_p[i];
    ans2 += tmp1 * sa_q[i];
  }

  if(ans1 - ans2 > 0){
    cout << (ans1 - ans2) << endl;
  }else{
    cout << (ans2 - ans1) << endl;
  }   

}


Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

vector<int> arr[500000];
int main(void){
    int n;cin >> n;
    vector<ll> p(n);for(int i = 0;i < n;i++)scanf("%lld",&p[i]);
    vector<ll> q(n);for(int i = 0;i < n;i++)scanf("%lld",&q[i]);

    vector<int> v(n);
//    int id = 0;
    iota(v.begin(),v.end(),n);
    int a=0,b=0;
    int id = 1;
    do{
//        arr[id++] = v;
//        for(auto i : v)cout << i+1-n << " ";
        bool A = true,B = true;
        for(int i = 0;i < n;i++){
//            cout << v[i] << " ";
            if(v[i]-n+1 != p[i])A = false;
            if(v[i]-n+1 != q[i])B = false;
        }
//        cout << endl;
        if(A)a = id;
        if(B)b = id;

        id++;
    }while(next_permutation(v.begin(),v.end()));
    //sort(arr,arr + 1000);
//    int a,b;
//    for (int i = 0; i < 500000; ++i)
//    {
//
//        if(arr[i].size() == 0)break;
//        cout << arr[i].size() << endl;
//        bool A=true,B=true;
//        for (int j = 0; j < arr[i].size(); ++j)
//        {
//            if(arr[i][j] != p[i])A = false;
//            if(arr[i][j] != q[i])B = false;
//            if(A)a = i+1;
//            if(B)b = i+1;
//        }
//    }
//    cout << a << " " << b << endl;
//    cout << abs(a-b) << endl;
    cout << abs(a-b) << endl;
}

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

int main() {
  string s;
  cin >> s;
  if(s.size()%2!=0) cout << "No" << endl;
  else {
    bool hitachi = true;
    for(int i=0; i<s.size(); i+=2) {
      if(s.substr(i,2)!="hi") hitachi = false;
    }
    if(hitachi) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    cout<<a[0]+a[1]<<endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b,c,d,e,k; cin>>a>>b>>c>>d>>e>>k;
	cout<<(e-a>k?":(":"Yay!")<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
using namespace std;


ll gcd(ll a, ll b)
{
    if (a == 0)
    return b;
    return gcd(b % a, a);
}


ll power(ll a,ll b,ll p)
{

    ll res = 1; // Initialize result
    // Update a if it is more than
    // or equal to mod

    a %= p;

    while(b)
    {
    // If b is odd, multiply a with result
    if (b & 1)
    res = (res * a)%p;

    // Here we assume that doing a*a
    // doesn't cause overflow
    a = (a * a) % p;
    b >>= 1; // b = b / 2

    }

    return res;
}

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

    int n;
    cin>>n;

    string str= "ACL";

    n--;

    while(n--)
    {
       str+="ACL";
    }

    cout<<str<<endl;



    return 0;
}

Measured memory_bytes: 3644
n = gets.to_i
d, x = gets.split(" ").map{ |i| i.to_i }
a = []
for i in 0...n do
  a[i] = gets.to_i
end

cnt = x
for i in 0...n do
  if a[i] < d
    cnt += (d - 1) / a[i] + 1
  else
    cnt += 1
  end
end

puts cnt


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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

int main() {
	string a, b;
	cin >> a >> b;
	int la = a.size();
	int lb = b.size();
	if (la < lb) {
		cout << "LESS" << endl;
	}
	if (la > lb) {
		cout << "GREATER" << endl;
	}
	if (la == lb) {
		if (a < b) {
			cout << "LESS" << endl;
		} else if (a > b) {
			cout << "GREATER" << endl;
		} else {
			cout << "EQUAL" << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    s[5] = ' ';
    s[13] = ' ';

    cout  << s << endl;

}
 
    

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

using namespace std;

long long int gcd(long long int x, long long int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main(){
    long long int N,M,len;
    bool flag =true;
    string S,T;

    cin >> N >> M;
    len = N*M/gcd(N,M);
    cin >> S;
    cin >> T;

    for(int i=0;i<gcd(N,M)+1;i++){
        if(S[i*(len/M)] != T[i*(len/N)]){
            flag = false;
        }
    }

    if(flag){
        cout << len << endl;
    }else{
        cout << "-1" << endl;
    }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n , a[200],sum;
main ()
{
    cin >> n;
    for(int i = 1 ;i <= n; ++i)
    {
        cin >> a[i];
        sum+=a[i];
    }
    sort(a+1,a+n+1 );
    if(sum%10!=0)
    {
        cout << sum;
        return 0 ;
    }
    for(int i = 1 ; i <= n; ++i)
    {
        if( ( sum - a[i]  ) % 10 !=0)
        {
            cout << sum-a[i];
            return 0;
        }
    }
    cout << 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)((n>>m)&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

int cmp(const void*a,const void*b){
	ll aa=*(ll*)a,bb=*(ll*)b;
	ll sa=0,sb=0;
	while(sa+=aa%10,aa/=10);
	while(sb+=bb%10,bb/=10);
	//aa/sa<bb/sb <==> aa*sb<bb*sa
	aa=*(ll*)a;
	bb=*(ll*)b;
	if(aa*sb<bb*sa)return -1;
	if(aa*sb>bb*sa)return 1;
	if(aa<bb)return -1;
	return 1;
}

ll ans[20000000];
ll cnt;
int main(){
	rep(i,1,100000)if(i%10!=9||i==9){
		ll t=i;
		while(t<1000000000000000){
			ans[cnt++]=t;
			t=t*10+9;
		}
	}
	qsort(ans,cnt,sizeof(ll),cmp);
	ll n;
	scanf("%lld",&n);
	ll ptr=0,M=0;
	rep(i,0,n){
		while(ans[ptr]<=M)ptr++;
		printf("%lld\n",M=ans[ptr]);
	}
	return 0;
}

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

int K, X;
int ans;

int main(){

    cin >> K >> X;
    ans = 500*K;

    if (ans >= X){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100005
#define ll long long
#define For(i,x,y) for(int i=(x);i<=(y);++i)
#define Rof(i,x,y) for(int i=(x);i>=(y);--i)
#define Edge(x) for(int i=head[x];i;i=e[i].nxt)
#define Cur(x) for(int &i=cur[x];i;i=e[i].nxt)
#define mset(x,y) memset(x,y,sizeof(x))
using namespace std;
const int S=0,T=200015;
int dep[N*2],cur[N*2],head[N*2],cnt=1,tot=0,p[N],q[N],_p[N],_q[N];
queue<int> Q;
struct ed{ int v,nxt,f; }e[N<<3];
void add(int u,int v,int f){
	e[++cnt]=(ed){v,head[u],f},head[u]=cnt;
	e[++cnt]=(ed){u,head[v],0},head[v]=cnt;
}
void dfs1(int x,int y){ if(_p[x])return;_p[x]=tot;dfs1(p[x],y); }
void dfs2(int x,int y){ if(_q[x])return;_q[x]=tot;dfs2(q[x],y); }
bool bfs(){
	For(i,0,T) dep[i]=0;
	dep[S]=1;Q.push(S);
	while(!Q.empty()){
		int x=Q.front();Q.pop();
		Edge(x){
			int to=e[i].v;
			if(!dep[to] && e[i].f){
				dep[to]=dep[x]+1;
				Q.push(to);
			}
		}
	}
	return dep[T];
}
int dfs(int x,int f){
	if(x==T) return f;
	int use=0,o,w;
	Cur(x){
		int to=e[i].v;
		if(e[i].f && dep[to]==dep[x]+1){
			o=min(f-use,e[i].f);
			w=dfs(to,o);
			use+=w;
			e[i].f-=w,e[i^1].f+=w;
			if(use==f) return f;
		}
	}
	return use;
}
int main(){
	int n,ans;
	scanf("%d",&n);tot=0,ans=n;
	For(i,1,n) scanf("%d",&p[i]),p[i]++;
	For(i,1,n) scanf("%d",&q[i]),q[i]++;
	For(i,1,n) if(!_p[i]) ++tot,dfs1(i,i);
	For(i,1,n) if(!_q[i]) ++tot,dfs2(i,i);
	For(i,1,n){
		if(p[i]==i && q[i]==i) ans--;
		else{
			if(p[i]==i && q[i]!=i) add(S,_q[i],1);
			else if(p[i]!=i && q[i]==i) add(_p[i],T,1);
			else{
				add(_p[i],_q[i],1);
				if(p[i]==q[i]) add(_q[i],_p[i],1);
			}
		}
	}
	while(bfs()){
		For(i,0,T) cur[i]=head[i];
		ans-=dfs(S,2001010);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 11520
# -*- coding:utf-8 -*-
import sys
n = int(input())
s = input()

word = ''

if n % 2 != 0:
  print('No')
  sys.exit()

for i in range(int(n/2)):
  word += s[i]

if word*2 == s:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <stdio.h>

int main() {
    long long int X;
    scanf("%lld", &X);

    long long int maney = 100;
    int i;

    for(i = 0; maney < X; i++) {
        maney *= 1.01;
    }

    printf("%d", i);

    return 0;
}

Measured memory_bytes: 1724
#include <stdio.h>
#include <string.h>
int main(){
    int a;
    scanf("%d", &a);
    getchar();
    char string[105];
    scanf("%[^\n]", string);
    int len = strlen(string);
    if(len > a){
        strcpy(string + a, "...");
    }
    printf("%s\n", string);
    return 0;
}

Measured memory_bytes: 1620
*g=1
gets.to_i.times{h=[0]*256
g.size.times{|k|4.times{|a|h[a+=k*4%256]+=a.to_s(4)=~/1.?2.?3|213|132/?0:g[k]}}
g=h}
p g.reduce(:+).%10**9+7

Measured memory_bytes: 1788
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int c = sc.nextInt();
        int[][] a = new int[r+1][c+1];
        for (int ir = 0; ir < r; ir++) {
            for (int ic = 0; ic < c; ic++) {
                a[ir][ic] = sc.nextInt();
                a[ir][c] += a[ir][ic];
                a[r][ic] += a[ir][ic];
                a[r][c] += a[ir][ic];
            }
        }
        for (int ir = 0; ir <= r; ir++) {
            for (int ic = 0; ic <= c; ic++) {
                System.out.print(a[ir][ic]);
                if (ic == c)
                    System.out.println("");
                else
                    System.out.print(" ");
            }
        }
    }
}
                
        


Measured memory_bytes: 40696
n = int(input())
s = [sorted(list(input())) for _ in range(n)]

res = 0
d = dict()
for list_ in s:
    str_ = str(list_)
    if str_ in d:
        d[str_] += 1
        res += d[str_] - 1
    else:
        d[str_] = 1

print(res)

Measured memory_bytes: 130776
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int h,w;cin>>h>>w;
  int n;cin>>n;
  int r,c;cin>>r>>c;
  string s,t;
  cin>>s>>t;
  int Rlim,Llim,Ulim,Dlim;
  Rlim = w-c + 1;
  Llim = c;
  Ulim = r;
  Dlim = h-r+1;

    //cout<<Llim<<"   "<<Rlim<<"   "<<Ulim<<"   "<<Dlim<<"   "<<endl;

  bool ans = false;
  REP(i,n){
    switch(s[i]){
      case 'L':
        Llim--;
        if(Llim<=0)ans = true;
      break;
      case 'R':
      Rlim--;
              if(Rlim<=0)ans = true;
      break;
      case 'U':
      Ulim--;
              if(Ulim<=0)ans = true;
      break;
      case 'D':
      Dlim--;
              if(Dlim<=0)ans = true;
      break;
    }
        //cout<<"a "<<Llim<<"   "<<Rlim<<"   "<<Ulim<<"   "<<Dlim<<"   "<<endl;
    if(ans){
      cout<<"NO"<<endl;
      return 0;
    }
    switch(t[i]){
      case 'L':
      Rlim++;
      Rlim = min(Rlim,w);
      break;
      case 'R':
      Llim++;
      Llim = min(Llim,w);
      break;
      case 'U':
      Dlim++;
      Dlim = min(Dlim,h);
      break;
      case 'D':
      Ulim++;
      Ulim = min(Ulim,h);
      break;
    }
    //cout<<"b "<<Llim<<"   "<<Rlim<<"   "<<Ulim<<"   "<<Dlim<<"   "<<endl;
  }


  cout<<"YES"<<endl;
 

  return 0;
}

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

using namespace std;

const int mmax = 100 + 10;

int n, m;
int a[mmax], b[mmax];

int main()
{
    //freopen("input","r",stdin);
   // freopen("output","w",stdout);

    scanf("%d %d", &n, &m);

    int odd = 0;
    for (int i = 1; i <= m; ++i) {
        scanf("%d", &a[i]);
        odd += (a[i] & 1);
    }

    if (odd > 2) {
        printf("Impossible\n");
        return 0;
    }

    for (int i = 2; i < m; ++i) {
        if (a[i] % 2 == 0) continue;

        if (a[1] % 2 == 0) swap(a[1], a[i]);
        else swap(a[m], a[i]);
    }

    for (int i = 1; i <= m; ++i)
        printf("%d ", a[i]);
    printf("\n");

    if (m == 1) {
        if (n == 1) printf("1\n1\n");
        else printf("%d\n%d %d\n", 2, n - 1, 1);

        return 0;
    }

    b[1] = a[1] - 1;
    for (int i = 2; i < m; ++i)
        b[i] = a[i];
    b[m] = a[m]+1;

    printf("%d\n", m - (b[1] == 0));
    for (int i = 1 + (b[1] == 0); i <= m; ++i)
        printf("%d ", b[i]);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
using namespace std;
int main(){
    int a, b, n;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int acount = 0;
    int bcount = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'c') cout << "No" << endl;
        else if(s[i] == 'a'){
            acount++;
            if((acount + bcount) <= (a + b)) cout << "Yes" << endl; 
            else cout << "No" << endl;
        }
        else if(s[i] == 'b'){
            bcount++;
            if((acount + bcount) <= (a + b) && bcount <= b) cout << "Yes" << endl;
            else{
                cout << "No" << endl;
                bcount--;
            }
        }
    }
}


Measured memory_bytes: 896
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007LL
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
#define DEBUG 0
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;
struct edge{int from, to; ll cost;};

signed main(){
    ios::sync_with_stdio(0); cin.tie(0);
    string un = "UNRESTORABLE", s, t;
    cin >> s >> t;
    int tn = (int)t.length(), start = -1;
    rep((int)s.length()){
        int flag = 1;
        repp(j, tn){
            if(s[i+j] != '?' && s[i+j] != t[j]){
                flag = 0;
            }
        }
        if(flag) start = i;
        
    }
    if(start == -1){
        cout << un;
        return 0;
    }
    reppp(i, start, start+tn-1) s[i] = t[i-start];
    rep((int)s.length()){
        if(s[i] == '?') cout << 'a';
        else cout << s[i];
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws java.io.IOException {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		while (scan.hasNext()) {
			String tmp[] = scan.nextLine().split(",");
			int[] l = new int[10];
			int sum = 0;
			for (int i = 0; i < 10; i++) {
				l[i] = Integer.parseInt(tmp[i]);
				sum += l[i];
			}
		
			//System.out.println(Arrays.toString(l));
			int v1 = Integer.parseInt(tmp[10]);
			int v2 = Integer.parseInt(tmp[11]);

			/* x = v1 * t , x = -v2*t + sum */
			double dist = v1 * sum / (double) (v1 + v2);
			int passed = 0;
			int ans = 0;
			for (int i = 0; i < 10; i++) {
				passed += l[i];
				if (passed >= dist) {
					ans = i + 1;
					break;
				}
			}

			System.out.println(ans);
		}
	}

}

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

int main() {

ll n,m;
cin>>n>>m;
ll sum=0;
rep(i,m)
{ll a;
cin>>a;
sum+=a;}

ll ans;
if(n>=sum)
{ans=n-sum;}
else
{ans=-1;}

cout <<ans<<endl;


return 0;
}
/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/

Measured memory_bytes: 3636
unittest
{
	assert( [ "1 2 3 4" ].parse.expand.solve == 4 );
	assert( [ "13 1 4 3000" ].parse.expand.solve == 87058 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto rgbn = input.front.split.to!( long[] );
	return tuple( rgbn[ 0 .. 3 ], rgbn[ 3 ] );
}

auto solve( long[] rgb, long n )
{
	rgb.sort!( ( a, b ) => b < a );
	
	auto ans = 0L;
	for( auto a = 0L; a <= n; a += rgb[ 0 ] )
	{
		for( auto b = 0L; a + b <= n; b += rgb[ 1 ] )
		{
			ans += ( ( n - a - b ) % rgb[ 2 ] == 0 );
		}
	}
	return ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll l,r;
int main()
{
	cin>>l>>r;
	if(r-l>=2019)
	cout<<0<<endl;
	else
	{
		while(l>2019)
		{
			l-=2019;
			r-=2019;
		}
		ll mi=2019*2020;
		for(int i=l;i<=r;i++)
		for(int j=i+1;j<=r;j++)
		mi=min(mi,(ll)i*(j)%2019);
		cout<<mi<<endl;
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007


int main(){
    int n,k;
    cin >> n >> k;
    int x=1;
    int count=0;

    while(n>=x)
    {
        x*=k;
        count++;

    }
    cout << count << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int gcd(int ,int);
int main(){
  int x,y,a;
  cin>>x>>y;
  a=gcd(x,y);
  cout<<a<<endl;
  return 0;
}
 
int gcd(int x,int y){
  while(x!=y)
    if(x>y){
      x=x%y;
      if(x==0) return y;
    }
    else{
      y=y%x;
      if(y==0) return x;
  }
  return x;
}

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

int main(void) {
  int N;
  cin >> N;
  string s = to_string(N);
  bool ok = true;
  for(int i=0;i<s.size();i++){
    if(s[i] != s[s.size()-i-1])ok = false;
  }
  if(ok)cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

int main()
{
	boost;
	int n, i;
	cin >> n;
	ld arr[n];
	fo(i, 0, n)
	cin >> arr[i];
	
	ld dp[n][n + 1];
	memset(dp, 0, sizeof dp);
	dp[0][1] = arr[0];
	dp[0][0] = 1.0 - arr[0];
	fo(i, 1, n) {
		for(int j = 0; j <= i + 1; j++) {
			dp[i][j] = dp[i - 1][j] * (1.0 - arr[i]);
			if(j) dp[i][j] += dp[i - 1][j - 1] * arr[i];
		}
	}
	ld ans = accumulate(dp[n - 1] + n / 2 + 1, dp[n - 1] + n + 1, 0.0);
	cout << fixed << setprecision(10) << ans;
}


Measured memory_bytes: 144332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n; cin >> n;
    vector<ll> t(5); ll mint = LONG_LONG_MAX;
    for(int i=0; i<5; ++i){
        cin >> t[i]; mint = min(mint, t[i]);
    }
    ll res = (n+mint-1) / mint;
    res += 4;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3620
n, x = map(int, input().rstrip("\n").split())
kids_needs = sorted(list(map(int, input().rstrip("\n").split())))

c = 0
for need in kids_needs:
    x -= need
    if x < 0:
        break
    c += 1
else:
    c -= bool(x)

print(c)

Measured memory_bytes: 2940
import java.util.Scanner;

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

        int k = Integer.parseInt(sc.next());
        String s = sc.next();

        if (s.length() <= k) {
            System.out.println(s);
        } else {
            System.out.println(s.substring(0, k) + "...");

        }
    }
}

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


using namespace std;


#ifdef zxc

#include "debug.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = int64_t;
using ld = long double;
const ld EPS = 1e-10;
const ll MOD = 1e9 + 7;
const ld PI = 3.141592653589793;
const int maxn = 200001;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

int a[maxn];
ll dp[maxn][3];

signed main() {
#ifdef zxc
    mt19937 mt(228);
    freopen("../kolya_input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    //    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
    //            freopen("", "r", stdin);
    //        freopen("hack.out", "w", stdout);
#endif
    fast_io();
    cout.precision(1);
    cout << fixed;
    auto start = chrono::steady_clock::now();
    int n;
    cin >> n;
    vector<pair<int, int>> values;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        values.emplace_back(a[i], i & 1);
    }
    sort(values.begin(), values.end());
    int cnt = 0;
    for (int i = 0; i < values.size(); ++i) {
        int cur = i + 1;
        if ((values[i].second & 1) != (cur & 1)) {
            ++cnt;
        }
    }
    cout << cnt / 2;

    auto end = chrono::steady_clock::now();
    debug("time", chrono::duration_cast<chrono::milliseconds>(end - start).count() / 1000.0);

}



Measured memory_bytes: 1656
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
char tmp[20000];
int n ,len;
int main()
{
    scanf("%d" ,&n);
    cin>>tmp;
    len = strlen(tmp);
    for(int i = 0 ; i < len ; ++ i)
    {
        tmp[i] = ((tmp[i] - 'A') + n) % 26 + 'A';
    }
    cout<<tmp;
    return 0;
}

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



int main() {
	int n;
	string s;
	cin >> n >> s;
	int *num = new int[n+1];
	num[0] = 0;
	for (int i = 1; i <= n; i++) {
		if (s[i - 1] == 'E') {
			num[i] = num[i - 1] + 1;
		}
		else {
			num[i] = num[i - 1];
		}
	}
	int min = 1000000;
	for (int i = 1; i <= n; i++) {
		int temp = (i - 1 - num[i - 1]) + (num[n] - num[i]);
		if (min > temp) {
			min = temp;
		}
	}
	cout << min;
}


Measured memory_bytes: 1924
#include<bits/stdc++.h>
#define pb push_back
#define mem(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair <int,int> PAIR;
const int N = 1e5 + 7;
const double pi = acos(-1);
const ll mod = 1e9 + 7;
const double eps = 1e-6;
const ll inf = 0x3f3f3f3f;

int main(){	
	int n;
	cin >> n;
	string s;
	cin >> s;
	int nr = 0,nw = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == 'R')
			nr++;
	}
	for(int i = 0; i < nr; i++){
		if(s[i] == 'W')
			nw++;
	}
	cout << nw << endl;
    return 0;
}

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

int main(){
    string s,t;
    cin >> s >> t;
    int ans=0;
    if(s[0]==t[2]){
        if(s[1]==t[1]){
            if(s[2]==t[0]){
                ans=1;
            }
        }
    }
    cout << (ans ? "YES":"NO") << endl;
}


Measured memory_bytes: 256