akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		String in = new String();
		for(;scanner.hasNext();)
		{
			in += scanner.nextLine();
		}
		
		int[] cnt = new int[26];
		for(int i=0; i<cnt.length; i++)
		{
			cnt[0] = 0;
		}
		
		for(int i=0; i<in.length(); i++)
		{
			char c = in.charAt(i);
			for(int j=0; j<cnt.length; j++)
			{
				if(c=='a'+j || c=='A'+j)
				{
					cnt[j]++;
					break;
				}
			}
		}
		
		for(int i=0; i<cnt.length; i++)
		{
			System.out.println((char)('a'+i) + " : " + cnt[i]);
		}
	}
}

Measured memory_bytes: 25820
m, n, l = map(int, input().split())

arra = [input().split() for l in range(m)]
arrb = [input().split() for l in range(n)]

for i in range(m):
    retstr = ""
    for j in range(l):
        ans = 0
        for k in range(n):
            ans += int(arra[i][k]) * int(arrb[k][j])
        retstr += str(ans) + " "
    retstrs = retstr.strip()
    print(retstrs)


Measured memory_bytes: 6832
#include <bits/stdc++.h>
 
using namespace std;
 
 
int main(){
 
    int L;
    cin >> L;
    double l = (double)L;

    double len2 = l/3;
      cout <<std::setprecision(10)<<len2*len2*len2 << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

int main(){
    int N;cin >> N;
    vector<int> v(N);
    for(int i=0; i< N;i++) cin >> v[i];
    sort(v.begin(),v.end());
    float ans = v[0]/(pow(2,N-1));
    for(int i=1; i<N;i++){
        ans += v[i]/pow(2,N-i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>

int main(void) {
	int n, k;
	int a[100000];
	int ans;

	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);

	if ((n - 1) % (k - 1))ans = (n - 1) / (k - 1) + 1;
	else ans = (n - 1) / (k - 1);

	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 512
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        n: usize
    };
    if n % 1000 == 0 {
        println!("0");
    } else {
        println!("{}", 1000 - n % 1000);
    }
}


Measured memory_bytes: 2176
n = int(input())
rss = []
num = 1
for i in range(n):
  tmp = input().split(" ")
  tmp[1] = 100-int(tmp[1])
  tup = [tmp,num]
  rss.append(tup)
  num = num+1

rss.sort()

for i in range(n):
  print(rss[i][1])



Measured memory_bytes: 3060
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    a,b,c,X,Y = LI()
    ans = float("inf")
    for z in range(300001):
        if z%2 == 0:
            m = c*z
            x = z//2
            y = z//2
            m += a*max(0,X-x)
            m += b*max(0,Y-y)
            if m < ans:
                ans = m
    print(ans)
    return

#G
def G():
    n = I()
    x = LI()
    f = [(i,x[i]) for i in range(n)]
    f.sort(key = lambda x:x[1])
    g = [(f[i][0],i) for i in range(n)]
    g.sort(key = lambda x:x[0])
    for i in range(n):
        if g[i][1] < n//2:
            print(f[n//2][1])
        else:
            print(f[n//2-1][1])
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    F()


Measured memory_bytes: 40944
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	double a, b;

	cin >> a >> b;

	printf("%5f\n" ,(a*b)/3.305785);
}

Measured memory_bytes: 1240
#include<stdio.h>

int main(){
  long n,i,j,a[200000],bit[200010][21]={},left,right,c,cnt=0,flag=1;
  scanf("%ld",&n);
  for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
    for(j=0;j<21;j++){
      bit[i+1][j]=bit[i][j]+a[i]%2;
      a[i]/=2;
    }
  }

  for(i=1;i<=n;i++){
    left=i;
    right=n;
    while(left<=right){//printf("%ld %ld\n",left,right);
      c=(right+left)/2;
      flag=1;
      for(j=0;j<21;j++){
        if(bit[c][j]-bit[i-1][j]>1){
          flag=0;
          break;
        }
      }
      if(flag) left=c+1;
      else right=c-1;
    }

    cnt+=left-i;
  }
  printf("%ld\n",cnt);
}


Measured memory_bytes: 34560
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;


ll N,K;

struct info {
	string name;
	int age;
	int num;
	info(string newname,int newage,int newnum) {
		name = newname;
		age = newage;
		num = newnum;
	}
};
bool cmp(const info &a, const info &b) {
	if (a.name == b.name)return a.age > b.age;
	else return a.name < b.name;
}


int main() {
	vector<info> I;
	cin >> N;
	FOR(i, 0, N) {
		string cur; int A;
		cin >> cur >> A;
		I.push_back(info(cur, A, i + 1));
	}
	sort(I.begin(), I.end(), cmp);

	FOR(i, 0, N) {
		cout << I[i].num << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<map>

using namespace std;

int main(){
	int sum;
	string st;
	map <char,int> code;
	code['I']=1;
	code['V']=5;
	code['X']=10;
	code['L']=50;
	code['C']=100;
	code['D']=500;
	code['M']=1000;
	
	while(cin>>st){
		sum=0;
		for(int i=0;i<st.size()-1;i++){
			if(code[st[i]]<code[st[i+1]])
			sum-=code[st[i]];
			else
			sum+=code[st[i]];
		}
		printf("%d\n",sum+code[st[st.size()-1]]);
	}
}


Measured memory_bytes: 3220
#define f(i,a)for(i=0;i<a;i++)
i,j,k,l;s;f;char a[100][55];
main(n,m){
	for(scanf("%d%d\n",&n,&m);gets(a[i++]););
	f(i,n-m+1)f(j,n-m+1){f=1;f(k,m)f(l,m)f&=a[i+k][j+l]==a[n+k][l];s+=f;}
	puts(s?"Yes":"No");
}

Measured memory_bytes: 128
k = int(input())
li = [i + 1 for i in range(9)]

c = 0
while len(li) < k:
    if li[c] % 10 != 0:
        li.append(li[c] * 10 + li[c] % 10 - 1)
    li.append(li[c] * 10 + li[c] % 10)
    if li[c] % 10 != 9:
        li.append(li[c] * 10 + li[c] % 10 + 1)
    c += 1
print(li[k - 1])

Measured memory_bytes: 7200
#include<bits/stdc++.h>
using namespace std; 
 
#define FAST_I0 ios_base::sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"
#define int long long 
#define vvi vector<int>
#define pb push_back


void think(){
	string s,t;
	cin >> s >> t;
	int ans = INT_MAX;
	int n1 = s.size();
	int n2 = t.size();
	for(int i = 0; i<n1-n2+1; i++){
		int temp = 0;
	//	cout << s[i] << " ";
		for(int j = 0; j<n2; j++){
			if(s[j+i] == t[j]){
				temp++;
				}
			}
			ans = min(ans,n2-temp);
		}
		cout << ans << endl;
}

int32_t main(){
	FAST_I0; 
	int testcase = 1; 
//	cin >> testcase;
	while(testcase--){
		think();
		}
	return 0;	

}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#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(){
  string s;
  int n;
  cin >> n >> s;
  int ans = 0;
  rep(i,n-2){
    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
      ans++;
  }
  cout << ans << endl;
}

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

import static java.lang.System.in;

public class Main {
    static int[] dat;
    static int n=1;
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        //PrintWriter out = new PrintWriter(System.out);
        //BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        //String[] buf = reader.readLine().split(" ");
        int H = sc.nextInt(), W = sc.nextInt();
        int[][] grid = new int[H][W];
        List<int[]> que = new LinkedList<>(), next = new LinkedList<>();
        for(int i=0;i<H;i++){
            char[] s = sc.next().toCharArray();
            for(int j=0;j<W;j++){
                if(s[j]=='#') {
                    grid[i][j]=1;
                    que.add(new int[]{i,j});
                }
            }
        }
        if(que.size()==H*W){
            System.out.println(0);
            return;
        }
        int step = 0;
        int[] dr = new int[]{1,0,-1,0}, dc=new int[]{0,1,0,-1};
        while(que.size()>0){
            for(int[] w:que){
                for(int i=0;i<4;i++){
                    int r=w[0]+dr[i], c=w[1]+dc[i];
                    if(r>=0&&r<H&&c>=0&&c<W&&grid[r][c]==0){
                        next.add(new int[]{r,c});
                        grid[r][c]=1;
                    }
                }
            }
            step++;
            que=next;
            next = new LinkedList<>();
        }
        System.out.println(step-1);
    }
}


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

#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {0, -1, 0, 1, 1, 1, -1, -1};
int dy[] = {-1, 0, 1, 0, 1, -1, 1, -1};

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

  int h, w, k;
  cin >> h >> w >> k;

  int sx, sy;
  vvt<bool> grid(h + 2, vt<bool>(w + 2, false));
  rep(i, 0, h) {
    string s;
    cin >> s;

    rep(j, 0, w) {
      if(s[j] == 'S') {
        sx = j + 1;
        sy = i + 1;
        grid[sy][sx] = true;
      }
      else if(s[j] == '.') grid[i + 1][j + 1] = true;
    }
  }

  vvt<int> dist(h + 2, vt<int>(w + 2, INF));
  dist[sy][sx] = 0;
  queue<pi> que;
  que.push({sx, sy});
  while(!que.empty()) {
    int x = que.front().first, y = que.front().second;
    que.pop();

    rep(i, 0, 4) {
      int nx = x + dx[i], ny = y + dy[i];
      if(!grid[ny][nx] || dist[y][x] + 1 >= dist[ny][nx]) continue;
      dist[ny][nx] = dist[y][x] + 1;
      que.push({nx, ny});
    }
  }

  int ans = INF;
  rep(i, 1, h + 1) {
    rep(j, 1, w + 1) {
      if(dist[i][j] > k) continue;

      int cost = min({h - i, w - j, i - 1, j - 1});
      ans = min(ans, cost / k + !!(cost % k));
    }
  }
  cout << ans + 1 << endl;
}


Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
 
int main()
{
	long long H, N;
	long long A[100000];
	long long sum = 0;

	cin >> H >> N;
	for(int i=0; i<N; i++){
		cin >> A[i];
	}
 
	for(int i=0; i<N; i++){
		sum += A[i];
	}
 
	cout << (sum >= H? "Yes":"No") << endl;
 
	return 0;
}

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

#undef int
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t = 1;
	//cin >> t;
	while (t--) {
		int n;
		cin >> n;
		int ans = 0;
		while (1) {
			if (n % 1000 == 0) break;
			n++;
			ans++;
		}
		cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int cnt = 0;
	for(int i = 0; i < 4; i++){
		char c = cin.get();
		if(c == '+') cnt++;
		else cnt--;
	}
	cout << cnt << "\n";
	return 0;
}

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

using namespace std;
const int MAXN = 2e5+5;
int dist[MAXN];
priority_queue<pair<int,int>> pq;
int main(){
    int k;
    cin>>k;
    pq.push(make_pair(-1,1));
    for(int i=0;i<k;i++){
        dist[i] = 1e9;
    }
    dist[1] = 1;
    while(!pq.empty()){
        auto hold = pq.top();
        pq.pop();
        int dis = -hold.first;
        int node = hold.second;
        
        if(dist[(node+1)%k]>dis+1){
            dist[(node+1)%k]=dis+1;
            pq.push(make_pair(-dis-1,(node+1)%k));
        }
        if(dist[(node*10)%k]>dis){
            dist[(node*10)%k]=dis;
            pq.push(make_pair(-dis,(node*10)%k));
        }
        
    }
    cout<<dist[0]<<endl;
}

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

using namespace std;

int main(){
    int x1,x2,x3,x4,x5;
    cin>>x1>>x2>>x3>>x4>>x5;
    if(x1==0){
        cout<<1<<endl;
    }
    
    if(x2==0){
        cout<<2<<endl;
    }
    
    if(x3==0){
        cout<<3<<endl;
    }

    
    if(x4==0){
        cout<<4<<endl;
    }
    
    if(x5==0){
        cout<<5<<endl;
    }
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] values = new int[w];
        for(int i = 0;i < values.length;i++){
            values[i] = i + 1;
        } 

        for(int i = 0;i < n ; i++ ){
            String str = sc.next();
            String ab[] = str.split(",");
            int a = Integer.parseInt(ab[0]) -1;//stringからint 最初は１
            int b = Integer.parseInt(ab[1]) -1;
            int c;
            c = values[a];
            values[a] = values[b];
            values[b] = c;
        }
        for(int i = 0;i < values.length ;i++){
         System.out.println(values[i]);
        }
        sc.close();
    }
}


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

int main()
{
  int n, a;
  cin >> n >> a;
  vector<int> x(n);
  int i, j;
  for(i = 0; i < n; i++)
  {
    cin >> x.at(i);
  }
  int maxx = 0;
  for(i = 0; i < n; i++)
  {
    maxx = max(maxx, x.at(i));
    x.at(i) -= a;
  }
  maxx = max(maxx, a);
  vector<vector<long long>> dp(n+1, vector<long long>(2*n*maxx+1, 0));
  dp.at(0).at(n*maxx) = 1;
  for(i = 1; i <= n; i++)
  {
    for(j = 0; j <= 2*n*maxx; j++)
    {
      if(j-x.at(i-1)<0 || j-x.at(i-1) > 2*n*maxx) dp.at(i).at(j)=dp.at(i-1).at(j);
      else dp.at(i).at(j)=dp.at(i-1).at(j)+dp.at(i-1).at(j-x.at(i-1));
    }
  }
  cout << dp.at(n).at(n*maxx)-1 << endl;
}

Measured memory_bytes: 2304
#include<iostream>
#include<vector>
#include<math.h>

using namespace std;

double keisan(vector< vector<int> >& v,int t1,int t2)
{
    double ans=0;
    for (int i = 0; i < v[t1].size(); i++)
    {
        ans+=pow(v[t1][i]-v[t2][i],2);
    }
    ans=sqrt(ans);

    return ans;
}

int main()
{
    int n,d;
    cin>>n>>d;
    vector< vector<int> > vec(n,vector<int>(d,0));

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < d; j++)
        {
            cin>>vec[i][j];
        }
    }
    
    int count=0;
    for (int i = 0; i < n-1; i++)
    {
        double ans=0;
        for (int j = i+1; j < n; j++)
        {
            ans=keisan(vec,i,j);
            if(ceil(ans)==floor(ans))
            {
                count++;
            }
        }
    }

    cout<<count<<endl;
    

    return 0;
}


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

typedef vector<int> vi;

long long f(vi a){
	long long x = 0;
	for(int i = 0 ; i < a.size() ; i++) x = x * 10 + a[i];
	return x;
}
int n;
inline vi g(long long t){
	vi v(n);
	for(int i = 0 ; i < n ; i++){
		v[n-i-1] = t % 10;
		t /= 10;
	}
	return v;
}

map<long long,int> F(vi init,vi goal){
	queue<long long> Q;
	map<long long,int> done;
	done[f(init)] = 0;
	Q.push(f(init));
	while( Q.size() ){
		auto q_ = Q.front(); Q.pop();
		auto q = g(q_);
		if( done[q_] >= 4) break;
		for(int i = 0 ; i < n ; i++){
			for(int j = i + 1 ; j < n ; j++){
				vi v = q;
				int l = j - i + 1;
				for(int k = 0 ; k < l/2 ; k++){
					swap(v[i+k],v[j-k]);
				}
				long long h = f(v);
				if( done.count(h) == 0 ){
					Q.push(h);
					done[h] = done[q_] + 1;
				}
			}
		}
	}
	return done;
}
int main(){
	cin >> n;
	vi init(n);
	vi goal(n);
	for(int i = 0 ; i < n ; i++){
		cin >> init[i];
		goal[i] = i;
		init[i]--;
	}
	auto A = F(init,goal);
	auto B = F(goal,init);

	if( A.count(f(goal)) ){
		cout << A[f(goal)] << endl;
	}else{
		int ans = 9;
		for( auto x : A){
			if( B.count(x.first) ){
				ans = min(ans,x.second+B[x.first]);
			}
		}
		cout << ans << endl;
	}


}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

typedef long long ll;
typedef pair<double,ll> P;


int main(){
	string str;cin >> str;REP(i,str.size())cout << (str[i] == '1' ?9 : 1);cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;


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

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

int main() {
    
    long long N,M;
    cin >> N >> M;
    string S,T;
    cin >> S >> T;

    long long l = lcm(N,M);

    map<long long, char> m;

    long long ans = l;

    for ( long long i = 0; i < N; i++ ) {
        m[(l/N)*i] = S[i];
    }
    for ( long long i = 0; i < M; i++ ) {
        if ( m[(l/M)*i] && m[(l/M)*i] != T[i] ) { ans = -1; }
    }



    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 10880
#include <iostream>
#define LL long long
using namespace std;

LL N,a[100010];

int main(){
    cin >> N;

    int i;
    for (i=1; i<=N; i++) cin >> a[i];

    LL res=0;
    for (i=1; i<=N; i++){
        res+=(a[i]/2);
        a[i]%=2;
        if (a[i]==1 && a[i+1]>0) res++,a[i+1]--;
    }

    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 1024
n, a, b, c, d = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s = input()
flag = False
for i in range(a,c):
    if s[i] == s[i+1] == '#':
        print("No")
        exit()
for i in range(b,d):
    if s[i] == s[i+1] == '#':
        print("No")
        exit()
if c < d:
    print("Yes")
else:
    for i in range(b, d+1):
        if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
            print("Yes")
            exit()
    print("No")



Measured memory_bytes: 40060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n) 
{ v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i]; }
template<class T, class U> void read_n(vector<pair<T, U>>& v, size_t n)
{ v = vector<pair<T, U>>(n); 
  for (lli i=0; i<n; ++i) cin >> v[i].first >> v[i].second; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

bool serve[100001];
lli sum[100001];
lli q;
// vector<pair<lli, lli>> p;
int main() {
  fill(begin(serve), end(serve), true);
  for (lli i=2; i<=100000; ++i) {
    if (serve[i]) for (lli j=2*i; j<=100000; j+=i) serve[j] = false;
  }
  fill(begin(sum), end(sum), 0);
  for (lli i=3; i<=100000; i+=2) {
    if (serve[i] && serve[(i+1)/2]) sum[i] = sum[i-2] + 1;
    else sum[i] = sum[i-2];
  }
  cin >> q;
  for (lli i=0; i<q; ++i) {
    lli l, r;
    cin >> l >> r;
    cout << (sum[r] - sum[l-2]) << '\n';
  } 
  /*
  read_n(p, q);
  for (auto&& a : p) {
    cout << (sum[a.second] - sum[a.first-2]) << endl;
  }
  */
  return 0;
}


Measured memory_bytes: 1536
N = int(input())
list = []
for i in range(N): #因数注意！
    n = input()    
    m = n.split()
    p = [i for i in m] #1列の数列をリスト化
    list.append(p)
x = input()
a = 0
A = 0
for i in list:
    if a == 0:
        if x == i[0]:
            a = 1
        else:
            pass
    else:
        A = A + int(i[1])
print(A)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main (){
  vector<int> a(3);
  for(int i=0;i<3;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
    if(a.at(0)=5&&a.at(1)==5&&a.at(2)==7){
      cout<<"YES"<<endl;
    }
  else{
    cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int r,g;
  cin>>r>>g;
  g*=2;
  g-=r;
  cout<<g<<"\n";
  
  return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N,T,A;
    cin>>N>>T>>A;
    vector<int>H(N);
    for(int i=0;i<N;i++){
        cin>>H.at(i);
    }
    double sa=100000;
    int num;
    for(int i=0;i<N;i++){
     if(abs(T-H.at(i)*0.006-A)<=sa){sa=abs(T-H.at(i)*0.006-A);num=i;}
    }
    cout<<num+1<<endl;
        
    return 0;
}

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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}

int loadvec(vector<int>& v, int N=-1) {
    if (N == 0) {
        v.clear();
        return 0;
    }
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    return i;
}
void read_cr() {
    fgets(_buf, 256, stdin);
}


ll solve(int N, vi& v, vi& c) {
    ll ans = 0;
    rep(i,N){
        int diff = v[i] - c[i];
        if (diff >= 0) ans += diff;
    }
    return ans;
}

int main() {
    int N; scanf("%d%*c", &N);
    vi v(N), c(N);
    loadvec(v,N);
    loadvec(c,N);
    cout << solve(N,v,c) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.regex.Pattern;
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        Pattern pattern=Pattern.compile("the|this|that");
        String str;
        try{
            while((str=br.readLine())!=null){
                char[] ch=str.toCharArray();
                for(int j=0;!pattern.matcher(str).find()&j<26;j++){
                    for(int i=0;i<ch.length;i++){
                        if('a'<=ch[i]&&ch[i]<'z'){
                            ch[i]++;
                        }else if(ch[i]=='z'){
                            ch[i]='a';
                        }
                    }
                    if(pattern.matcher(String.valueOf(ch)).find()){
                        break;
                    }
                }
                System.out.println(ch);
            }
        }catch(Exception e){
        }
    }
}

Measured memory_bytes: 17964
S = input()
T = input()

LEN_S = len(S)
LEN_T = len(T)

if LEN_S < LEN_T:
  print('UNRESTORABLE')
  exit()

def isEquals(s):
  for i in range(LEN_T):
    if T[i] == s[i] or s[i] == '?':
      pass
    else:
      return False
  return True

answers = []
for i in range(LEN_S - LEN_T+1):
  if isEquals(S[i:i+LEN_T]):
    text = S[:i].replace('?', 'a') + T + S[i+LEN_T:].replace('?', 'a')
    answers.append(text)
  else:
    pass

if 0 < len(answers):
  answers = sorted(answers)
  print(answers[0])
  
else:
  print('UNRESTORABLE')
  

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
 
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;
 
#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
 
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const LL INF = 1e18;
 
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
 
  int N, M;
  cin >> N >> M;
  vector<vector<PLL>> G(N);
  REP(i,M){
	int a, b, c;
	cin >> a >> b >> c;
	--a;
	--b;
	G[a].EB(b, c);
  }
 
  VL dist(N, -INF);
  dist[0] = 0;
  REP(i,N+1){
	REP(j,N){
	  for(PLL& e: G[j]){
		maxi(dist[e.FF], dist[j] + e.SS);
	  }
	}
  }
 
  VL dist2 = dist;
  REP(i,N+1){
	REP(j,N){
	  for(PLL& e: G[j]){
		maxi(dist2[e.FF], dist2[j] + e.SS);
	  }
	}
  }
  if(dist[N-1] != dist2[N-1])
	cout << "inf" << endl;
  else
	cout << dist[N-1] << endl;
  
  return 0;
}

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

using namespace std;

int main() {
	string str;
	char offset[27] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	getline(cin, str);
	cout << offset[str.at(0) - 'a'];
	for (int i = 0; i < str.size(); i++)
		if(str.at(i)==' ')cout << offset[str.at(i+1)-'a'];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
M=10**9+7
n,k=map(int,input().split())
for i in range(k):
  if n-k<i: print(0)
  else:
    s=t=1
    for j in range(1,i+1): s=s*(n-k+2-j)*(k-j)%M; t=t*j*j%M
    print(s*(n-k+1-i)*pow(t*(i+1),M-2,M)%M)

Measured memory_bytes: 3316
// 解き直し.
// AtcoderRegularContest解説
// https://img.atcoder.jp/arc098/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
LL A[200002], CUM[200002], XOR[200002];

int main(){

    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    for(int i = 1; i <= N; i++){
        scanf("%lld", &A[i]);
        CUM[i] = CUM[i - 1] + A[i];
        XOR[i] = XOR[i - 1] ^ A[i];
    }
    
    // 2. 解説通り.
    // 条件を満たす 整数の組(l, r) の 個数 を計算(※尺取り法っぽいロジックを使えるとのこと).
    LL ans = 0;
    int l = 1, r = 1;
    int counter = 0;
    while(l <= N){
        while(r <= N){
            // 2-1. 整数の組(l, r) に 対応する和, 排他的論理和を取得.
            LL Add = CUM[r] - CUM[l - 1];
            LL Xor = XOR[r] ^ XOR[l - 1]; // 変数名: xor だと, Compile error となった.
            
            // 2-2. 条件を満たすか確認.
            if(Add == Xor) ans += (r - l + 1);
            else           break;
            
            // 2-3. r を increment.
            r++;
            
            // 2-4. debug用.
            counter++;
            if(counter > 200002) break;
            
        }
        
        // 2-5. l を increment.
        l++;
        
    }
    
    // 3. 出力 ～ 後処理.
    printf("%lld\n", ans);
    return 0;

}

Measured memory_bytes: 4992
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <queue>
#include <set>
#include <stack>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define debug(x) cout<<x<<endl
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
using namespace std;
const int MAXN=1e5+50;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
//::iterator it;
char s[2*MAXN];
int x[3500];
int main()
{
    std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>s;
    int n=strlen(s);
    x[0]=1;
    int p=1;
    int kk=0;
    int ans=0;
    for(int i=n-1;i>=0;i--){
    	kk=(kk+(s[i]-'0')*p)%2019;
    	ans+=x[kk];
    	x[kk]++;
    	p=p*10%2019;
    }
    cout<<ans<<endl;
    return 0;
}
/*

*/

 
 

Measured memory_bytes: 3816
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <string>
#include <map>
using namespace std;

#define maxA 100000
#define maxB 10000
int main()
{
    long long int ans = 0;
    int N, M;
    vector<vector<int>> job(maxA);
    cin >> N >> M;
    {
        int tp, tm;
        for (int i = 0; i < N; i++)
        {
            cin >> tp >> tm;
            job[tp].push_back(tm);
        }
    }
    {
        priority_queue<int> q;
        for (int i = 1; i <= M; i++)
        {
            for (auto &&j : job[i])
            {
                q.push(j);
            }
            if (q.size() != 0)
            {
                ans += q.top();
                q.pop();
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5632
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    assert N == len(A)
    votes = sum(A)/(4*M)
    count = 0
    for i in A:
        if i >= votes:
            count += 1
    print("Yes") if count >= M else print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep1(i,b) for(ll i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define vi vector<ll>
#define all(v) v.begin(), v.end()

int main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s;
	ll ans = 0;
	cin >> s;
	rep(i, s.length())
	{
		if(s[i] == '+')	ans++;
		else if(s[i] == '-') ans--;
	}
	cout << ans << endl;
	
	#ifdef LOCAL_DEFINE
		cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	#endif
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int x, y;
  cin >> x >> y;
  bool flag = true;
  int X = 4 * x - y, Y = y - 2 * x;
  if (X % 2 != 0 || Y % 2 != 0) flag = false;
  if (X < 0 || Y < 0) flag = false;
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

int main() {
	int k[5];
	for (int i = 0; i < 3; ++i) { cin >> k[i]; }
	sort(k, k + 3);
	for (int i = 0; i < 3; ++i) {
		cout << k[i];
		if (i != 2) { cout << " "; }
	}
	cout << endl;
}


Measured memory_bytes: 3144
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    string s; cin >> s;
    ll k; cin >> k;
    set<char> st;

    REP(i, s.size()) {
        st.insert(s[i]);
    }

    ll tmp_c = 0;
    bool prev_change = false;
    REP(i, s.size()) {
        if (i == 0) {
            continue;
        } else {
            if (s[i] == s[i-1]) {
                if (prev_change) {
                    prev_change = false;
                } else {
                    tmp_c++;
                    prev_change = true;
                }
            } else {
                if (prev_change) {
                    prev_change = false;
                } else {
                }
            }
        }
    }
    if (st.size() == 1) {
        cout << s.size() * k / 2 << endl;
    } else if (s[0] != s[s.size()-1]) {
        cout << tmp_c * k << endl;
    } else {
        ll a = 0;
        ll b = 0;
        REP(i, s.size()) {
            if (s[i] == s[0]) {
                a++;
            } else {
                break;
            }
        }
        REP(i, s.size()) {
            if (s[s.size()-i-1] == s[0]) {
                b++;
            } else {
                break;
            }
        }
        cout << tmp_c * k - (a/2 + b/2 - (a+b)/2) * (k-1) << endl;
    }
    return 0;
}

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

int main(){
  int n, m, l;
  long long A[100][100], B[100][100], C[100][100];

  cin >> n >> m >> l;
  for(int i =0; i < n; i++)
    for(int j=0; j<m; j++) cin >> A[i][j];
  for(int i=0; i<m;i++)
    for(int j=0; j<l; j++) cin >> B[i][j];

  for(int i=0; i<n; i++){
    for(int j=0; j<l; j++){
      C[i][j]=0;
      for(int k=0; k<m; k++){
        C[i][j] += A[i][k] * B[k][j];
      }
    }
  }
  for(int i=0; i<n; i++){
    for(int j=0; j<l; j++){
      if(j) cout << " ";
      cout << C[i][j];
    }
    cout <<endl;
  }
  return 0;
}


Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N, M;
  cin >> N >> M;
  vector<pair<int,int>> v;
  rep(i,M){
    int a, b;
    cin >> a >> b;
    v.push_back(make_pair(a,b));
  }

  vector<bool> w(N+1);
  rep(i,M){
    if(v[i].second == N){
      w[v[i].first] = true;
    }
  }

  bool ret = false;
  rep(i,M){
    if(v[i].first == 1 && w[v[i].second]) ret = true;
  }

  if(ret) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  
  return 0;
}



Measured memory_bytes: 2420
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char=小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define str string
#define please return
#define AC 0
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int keta(int n) {
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {

	int a, b;
	cin >> a >> b;

	YES(b <= (a + 1) / 2);

	please AC;
}

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

int main() {
  std::string s, t;
  std::cin >> s >> t;
  if (std::count(s.begin(), s.end(), '1') > 0 &&
      std::count(t.begin(), t.end(), '1') == 0) {
    std::cout << "-1\n";
    return 0;
  }
  int n = s.size();
  std::vector<int> lsh(n, n + 1), rsh(n, n + 1);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (t[j] == '1') {
        if (i >= j) {
          lsh[i] = std::min(lsh[i], i - j);
        } else {
          lsh[i] = std::min(lsh[i], n - (j - i));
        }
        if (j >= i) {
          rsh[i] = std::min(rsh[i], j - i);
        } else {
          rsh[i] = std::min(rsh[i], n - (i - j));
        }
      }
    }
  }
  constexpr int kInf = 1'000'000'000;
  int ans = kInf;
  // for (int i = 0; i < n; ++i) std::cout << lsh[i] << ' ' << rsh[i] << "\n";
  for (int rot = 0; rot < n; ++rot) {
    {
      std::vector<char> r(n);
      for (int i = 0; i < n; ++i) r[(i + n - rot) % n] = s[i];
      int res = rot;
      std::vector<std::pair<int, int>> more;
      for (int i = 0; i < n; ++i) {
        if (r[i] != t[i]) {
          ++res;
          if (lsh[(i + rot) % n] <= rot) continue;
          more.emplace_back(rsh[(i + rot) % n], lsh[i]);
        }
      }
      std::sort(more.begin(), more.end());
      std::vector<int> suff(more.size() + 1, 0);
      for (int i = more.size() - 1; i >= 0; --i) {
        suff[i] = std::max(suff[i + 1], more[i].second);
      }
      int extra = suff[0];
      for (int i = 0, j = 0; i < more.size(); i = j) {
        for (j = i; j < more.size() && more[j].first <= more[i].first; ++j)
          ;
        extra = std::min(extra, more[i].first + suff[j]);
      }
      // std::cout << "rotate left rot = " << rot << " res = " << res
      //           << " extra = " << extra << "\n";
      ans = std::min(ans, 2 * extra + res);
    }
    {
      std::vector<char> r(n);
      for (int i = 0; i < n; ++i) r[(i + rot) % n] = s[i];
      int res = rot;
      std::vector<std::pair<int, int>> more;
      for (int i = 0; i < n; ++i) {
        if (r[i] != t[i]) {
          ++res;
          if (rsh[(i + n - rot) % n] <= rot) continue;
          more.emplace_back(lsh[(i + n - rot) % n], rsh[i]);
        }
      }
      std::sort(more.begin(), more.end());
      std::vector<int> suff(more.size() + 1, 0);
      for (int i = more.size() - 1; i >= 0; --i) {
        suff[i] = std::max(suff[i + 1], more[i].second);
      }
      int extra = suff[0];
      for (int i = 0, j = 0; i < more.size(); i = j) {
        for (j = i; j < more.size() && more[j].first <= more[i].first; ++j)
          ;
        extra = std::min(extra, more[i].first + suff[j]);
      }
      // std::cout << "more = {";
      // for (auto &p : more) std::cout << "(" << p.first << ", " << p.second << ") ";
      // std::cout << "}\n";
      // std::cout << "rotate right rot = " << rot << " res = " << res
      //           << " extra = " << extra << "\n";
      ans = std::min(ans, 2 * extra + res);
    }
  }
  std::cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF (ll)(1e17+5)
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
       ll n,k,i,ans=INF,cl,acl;
       cin>>k>>n;
       vector <ll> v(n);
       for(i=0;i<n;i++)
        cin>>v[i];
       ans=min(v[n-1]-v[0],k-v[1]+v[0]); 
       for(i=1;i<n-1;i++)
       {
           ans=min(ans,k-v[i]+v[i-1]);
           ans=min(ans,k-v[i+1]+v[i]);
       } 
       ans=min(ans,k-v[n-1]+v[n-2]);
       ans=min(ans,v[n-1]-v[0]);
       cout<<ans<<"\n";

   }
}

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

string c(ll n);
int main() {
  ll n;
  cin >> n;
  cout << c(n);
}


string c(ll n) {
  // n >= 1
  string ans = "";
  while(n) {
    n--;
    ans += (char)('a' + (n % 26));
    n/=26;
  }
  reverse(ans.begin(), ans.end());
  return ans;
}



Measured memory_bytes: 3576
/*

                              Jai Shree Krishna !!
                                 Radhe Radhe !!
                                 
             उद्यमेन हि सिद्ध्यन्ति कार्याणि न मनोरथैः। नहि सुप्तस्य सिंहस्य मुखे प्रविशन्ति मृगाः।।
             
*/
   
   
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int,int>
#define vvi vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(int j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define endl "\n"
#define mp make_pair
#define ins insert
#define rep(i,s,e) int i; for(int i=s;i<=e;i++)
#define repd(i,s,e) int i; for(int i=e;i>=s;i--)
#define vb vector<bool>
#define read2(n,m) int n,m; cin >> n >> m;
#define range(v) v.begin(),v.end()
#define sortd(v) sort(v.begin(),v.end(),greater<int>())
#define sorti(v) sort(v.begin(),v.end())

const ll inf = 1e18;
const ll mod = 1e9 + 7;
 
signed main()
{
 
    fast;
    read(k);
    int s=0;
    rep(i,1,k){
    	rep(j,1,k){
    		rep(l,1,k){
    			s+=__gcd(i,__gcd(j,l));
    		}
    	}
    }
   cout<<s<<endl;
    
    return 0;
}

/* Pooja Yadav */

Measured memory_bytes: 3632