akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
	
	int angka,ratusan,puluhan,satuan;
	scanf("%d", &angka);
	
		ratusan = angka % 100;
		puluhan = ratusan % 10;
		satuan = puluhan;
		puluhan = ratusan/10;
		ratusan = angka/100;
		
	if (ratusan==7){
		printf("Yes\n");
	}
	else if(puluhan==7){
		printf("Yes\n");
	}
	else if(satuan==7){
		printf("Yes\n");
	}
	else {
			printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1644
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			int n = sc.nextInt();
			
			int p = n % 2 == 0 ? n /2 : n /2 + 1;
			
			System.out.println(p);
			
		}
	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstring>
#include<map>
#include<set>
#include<stack>
#include<utility>
#include<queue>
#include<vector>
#include<cctype>
using namespace std;
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define forb(i,a,b) for(int i=a;i>=b;i--)
#define fir first
#define sec second
#define ABS(a) ((a)>0?(a):-(a))
#define PI acos(-1,0)
typedef long long ll;
typedef long double ld;
const int MAXN=100005;
int t[MAXN];
int main(){
    int n,c,k;
    cin>>n>>c>>k;
    fore(i,1,n) cin>>t[i];
    sort(t+1,t+n+1);
    int pos=1;
    int ans=1;
    fore(i,2,n){
        if(t[pos]+k<t[i]) {ans++,pos=i;/*cout<<i<<"\n";*/}
        else{
            if (i - pos >= c) { ans++, pos = i; /*cout<<i<<"\n";*/ }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  string s, t;
  cin >> n >> s >> t;
  
  string str(n * 2, 'a');
  
  for (int i = 0; i < n; i++) {
    str.at(i * 2) = s.at(i);
    str.at(i * 2 + 1) = t.at(i);
  }
  
  cout << str << endl;
}

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

bool prime(int x)
{
  if (x < 2) return true;
  else if (x == 2) return false;
  else if (x % 2 == 0) return true;

  double sqrtx = sqrt(x);
  for (int i = 3; i <= sqrtx; i += 2) {
    if (x % i == 0) {
      return true;
    }
  }
  return false;
}

int main()
{
  int x;
  cin >> x;
  while (prime(x)) {
    
    x++;
  }
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int stack[1000000][3];
#define max(a,b) ((a)>(b)?(a):(b))

int main(){
		int h,w,i,j;
		int st=0,fn=0,ans=0;
		char s[1000][1001];
		scanf("%d%d",&h,&w);
		for(i=0;i<h;i++)scanf("%s",s[i]);
		for(i=0;i<h;i++){
				for(j=0;j<w;j++){
						if(s[i][j]=='#'){
								stack[fn][0]=i;
								stack[fn][1]=j;
								stack[fn][2]=0;
								fn++;
						}
				}
		}
		while(fn>st){
				int x=stack[st][0],y=stack[st][1];
				if(x>0){
						if(s[x-1][y]=='.'){
								stack[fn][0]=x-1;
								stack[fn][1]=y;
								stack[fn][2]=stack[st][2]+1;
								ans=max(ans,stack[fn][2]);
								fn++;
								s[x-1][y]='#';
						}
				}if(y>0){
						if(s[x][y-1]=='.'){
								stack[fn][0]=x;
								stack[fn][1]=y-1;
								stack[fn][2]=stack[st][2]+1;
								ans=max(ans,stack[fn][2]);
								fn++;
								s[x][y-1]='#';
						}
				}if(x<h-1){
						if(s[x+1][y]=='.'){
								stack[fn][0]=x+1;
								stack[fn][1]=y;
								stack[fn][2]=stack[st][2]+1;
								ans=max(ans,stack[fn][2]);
								fn++;
								s[x+1][y]='#';
						}
				}if(y<w-1){
						if(s[x][y+1]=='.'){
								stack[fn][0]=x;
								stack[fn][1]=y+1;
								stack[fn][2]=stack[st][2]+1;
								ans=max(ans,stack[fn][2]);
								fn++;
								s[x][y+1]='#';
						}
				}
				st++;
		}
		printf("%d\n",ans);
		return 0;
}


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

constexpr int MAX_N = 1e5;
int H[MAX_N];

int main() {
  int N; cin >> N;
  bool ans{true};
  cin >> H[0]; --H[0];
  for (int i{1}; i < N; ++i) {
    cin >> H[i];
    if (H[i-1] < H[i]) --H[i];
    if (H[i-1] > H[i]) {
      ans = false;
      break;
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


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

using namespace std;
const int maxn=105;
int n;
int a[maxn];
int vis[maxn],cnt;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]),vis[a[i]]=1;
	for (int i=1;i<=n;i++){
		if (a[i]==a[i-1]){
			for (int j=1;j<=n;j++){
				if (!vis[j]){
					vis[j]=1;
					cnt++;
					a[i]=j;
					break;
				}
			}
		}
	}
	cout << cnt << '\n';
} 

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		System.out.println((n * (n - 1) / 2) + m * (m - 1) / 2);
	}
}

Measured memory_bytes: 21844
import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Stack<String> s = new Stack<>();
		s.push(sc.next());
		while(sc.hasNext()) {
			String str = sc.next();
			if(str.equals("=")) {
				System.out.println(s.pop());
				break;
			}
			if(!Character.isDigit(str.charAt(0))) {
				s.push(str);
			}
				
			else {
				String ss = s.pop();
				int a = Integer.parseInt(s.pop());
				int b = 0;
				if(ss.equals("+"))
					b = a + Integer.parseInt(str);
				if(ss.equals("-"))
					b = a - Integer.parseInt(str);
				if(ss.equals("*"))
					b = a * Integer.parseInt(str);
				if(ss.equals("/"))
					b = a / Integer.parseInt(str);
				s.push(String.valueOf(b));
			}
			
		}
	}
}


Measured memory_bytes: 26080
import Text.Printf

d x y p = (**(1/p)) . sum . map ((**p).abs) $ zipWith (-) x y

d_chebyshev x y = maximum . map abs $ zipWith (-) x y

main :: IO ()
main = do
    _ <- getLine
    x <- getLine >>= return.(map (\n -> read n :: Double)).words
    y <- getLine >>= return.(map (\n -> read n :: Double)).words

    printf "%.6f\n" $ d x y 1
    printf "%.6f\n" $ d x y 2
    printf "%.6f\n" $ d x y 3
    printf "%.6f\n" $ d_chebyshev x y



Measured memory_bytes: 4460
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Element> list = new ArrayList<>();
        Map<Integer, Element> map = new HashMap<>(); // 回答出力用のMap, 2回目のソート(市の昇順でソート)を不要とするため
        for (int i = 0; i < m; i++) {
            int p = sc.nextInt();
            int y = sc.nextInt();
            Element element = new Element(p, y, i);
            list.add(element);
            map.put(i, element);
        }
        sc.close();

        // 誕生年の昇順でソート
        Collections.sort(list, (e1, e2) -> e1.y - e2.y);
//        System.out.println(list);

        // 県ごとのカウンター
        int[] counter = new int[n];
        // 県ごとのカウンターをインクリメントしながら、認識番号を割り振り
        for (Element e : list) {
            e.id = String.format("%06d%06d", e.p, counter[e.p - 1] + 1);
            counter[e.p - 1]++;
        }

        // 識別番号を出力
        for (int i = 0; i < m; i++) {
            System.out.println(map.get(i).id);
        }
    }

    static class Element {
        int p;
        int y;
        int no;
        String id;

        Element(int p, int y, int no) {
            this.p = p;
            this.y = y;
            this.no = no;
        }

        @Override
        public String toString() {
            return "(p=" + p + ", y=" + y + ", no=" + no + ", id=" + id + ")";
        }
    }

}


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

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

    string s,s1;
    cin>>s>>s1;
    bool reshenie=true;
    if(s1.size()-s.size()!=1)
        reshenie=false;
    for(int i=0;i<(int)s.size();i++){
        if(s.at(i)!=s1.at(i))
            reshenie=false;
    }
    if(reshenie==false){
        cout<<"No";
    }
    else
        cout<<"Yes";
}


Measured memory_bytes: 3576
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Collection;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.Queue;
import java.io.BufferedReader;
import java.util.LinkedList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EHopscotchAddict solver = new EHopscotchAddict();
        solver.solve(1, in, out);
        out.close();
    }

    static class EHopscotchAddict {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            ArrayList<Integer> a[] = new ArrayList[n];
            ArrayList<Integer> b[] = new ArrayList[3 * n];
            for (int i = 0; i < 3 * n; i++) {
                b[i] = new ArrayList<>();
            }
            for (int i = 0; i < m; i++) {
                int u = in.nextInt() - 1;
                int v = in.nextInt() - 1;
                b[u].add(v + n);
                b[u + n].add(v + 2 * n);
                b[u + 2 * n].add(v);
            }
            int s = in.nextInt() - 1;
            int v = in.nextInt() - 1;
            Queue<Integer> q = new LinkedList<>();
            boolean visited[] = new boolean[3 * n];
            int pos[] = new int[3 * n];
            q.add(s);
            visited[s] = true;
            while (q.size() > 0) {
                int r = q.poll();
                for (int x : b[r]) {
                    if (!visited[x]) {
                        q.add(x);
                        visited[x] = true;
                        pos[x] = pos[r] + 1;
                    }
                }
            }
            if (pos[v] == 0) {
                out.println(-1);
            } else {
                out.println(pos[v] / 3);
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 106020
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

from collections import Counter

dc = Counter(d)
dt = Counter(t)

for k, v in dt.items():
	if dc[k] < v:
		print('NO')
		exit()

print('YES')

Measured memory_bytes: 127572
S=input()
T=True
for i in range(int((len(S)-1)/2)-1):
  if S[i]!=S[int(len(S))-1-i]:
    T=False
for i in range(int((len(S)-3)/4)+1):
  if S[i]!=S[int((len(S)-3)/2)-i]:
    T=False
if T==False:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 9136
n = int(input())
d = [int(i) for i in input().split()]
#存在しないとき
if d[0] != 0:
    print(0)
    exit()
d0 = sorted(d)
for i in range(n-1):
    if d0[i+1] -d0[i] > 1:
        print(0)
        exit()
if d0[1] == 0:
    print(0)
    exit()
#############
dmax = d0[n-1]
if dmax == 1:
    print(1)
    exit()
l1 = 0
k = 1
for i in range(1,n):  
    if d0[i] == 1:
        l1 += 1
        k += 1
    else:
        break
l = [1,l1]
#print(l1)
ans = 1
for i in range(2,dmax+1):
    tmp = 0
    for j in range(k,n):
        if d0[j] == i:
            tmp += 1
            k += 1
        else:
            break
    #print(tmp)
    l.append(tmp)
    ans = ans * (l[i-1] ** l[i]) % 998244353
print(ans)


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

int main(){
  int N;
  cin>>N;
  vector<double> v;
  rep(i,N){
    double b;
    cin>>b;
    v.push_back(b);
  }

  sort(all(v), greater<double>());

  /*
  for(double x: v){
    cout<<x<<",";
  }cout<<endl;
  */

  while(v.size()>1){
    double f = v.back();
    v.pop_back();
    double s = v.back();
    v.pop_back();

    v.push_back((f+s)/2);
  }

  cout<<v.front()<<endl;
}

Measured memory_bytes: 256
s = ""

def format_input(filename = None):
	global s
	if filename == None:
		s = str(input())

	elif filename == '__random__':
		from random import randint as rng
		from random import choices
		s = ''.join(choices('abcdefghijklmnopqrstuvwxyz', k = 6))
		print(s)

def get_answer():
	answer = 'No'
	if s[2] == s[3] and s[4] == s[5]:
		answer = 'Yes'
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
using Graph = vector<vector<ll>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 1 << 29;
/****** define constant end ********/
/*
ll saiki(ll kaisuu, ll n, ll moji, string str)
{
    if (moji == 0)
    {
        str += "a";
        cout << "a";
    }
    else if (moji == 1)
    {
        str += "b";
        cout << "b";
    }
    else if (moji == 2)
    {
        str += "c";
        cout << "c";
    }
    else if (moji == 3)
    {
        str += "d";
        cout << "d";
    }
    else if (moji == 4)
    {
        str += "e";
        cout << "e";
    }
    else if (moji == 5)
    {
        str += "f";
        cout << "f";
    }
    else if (moji == 6)
    {
        str += "g";
        cout << "g";
    }
    else if (moji == 7)
    {
        str += "h";
        cout << "h";
    }
    else if (moji == 8)
    {
        str += "i";
        cout << "i";
    }
    else if (moji == 9)
    {
        str += "j";
        cout << "j";
    }
    else
    {
        str += "k";
        cout << "k";
    }
    kaisuu++;
    if (kaisuu == n)
    {
        cout << endl;
        return 0;
    }
    saiki(kaisuu, n, moji, str);
    cout << str;
    saiki(kaisuu, n, moji + 1, str);
    return 0;
}
*/
/****** define variable start ******/
unsigned long long h, w;
/******* define variable end *******/
ll solve()
{
    /*
    cin >> n;
    ll first = 0;
    string kara = "";
    ll res = saiki(0, n, first, kara);
*/

    cin >> h >> w;
    if (w == 1 || h == 1)
    {
        cout << 1 << endl;
    }
    else if (h % 2 == 0)
    {
        unsigned long long h2 = h / 2;
        cout << h2 * w << endl;
    }
    else if (w % 2 == 0)
    {
        unsigned long long w2 = w / 2;
        cout << h * w2 << endl;
    }
    else
    {
        unsigned long long h2 = (h - 1) / 2;
        unsigned long long anstmp = h2 * w + w / 2.0 + 1;
        cout << anstmp << endl;
    }

    return 0;
}
int main()
{
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */

    return (int)end_solve;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
//--
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<cstdio>
#include<cstring>
#include<sstream>
#include<complex>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()

#define re real()
#define im imag()

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef complex<double> pt;
typedef pair<pt,pt> line; //X+tY

double dot(pt a,pt b){return (conj(a)*b).real();}
double cros(pt a,pt b){return (conj(a)*b).imag();}
pt proj(pt a,pt to){
  return dot(a,to)/norm(to)*to;
}

pt refle(pt a,pt mirror){
  return pt(2)*proj(a,mirror)-a;
}

int pt3(pt a,pt b,pt c){
  pt p=b-a,q=c-a;
  double tmp;
  tmp=cros(p,q);
  if(tmp>0){
    return 0;
  }else if(tmp<0){
    return 1;
  }else if(norm(p+q)<max(norm(p),norm(q))){
    return 2;
  }else if(norm(q)>norm(p)){
    return 3;
  }else if(norm(q)<norm(p)){
    return 4;
  }
  return 5;
}

int line2(line a,line b){
  if(dot(a.Y,b.Y)==0)
    return 1;
  if(cros(a.Y,b.Y)==0)
    return 2;
  return 0;
}

int main(){
  int i,j,k,n,re;
  line s1,s2;
  double a[8];
  cin>>n;
  rep(i,n){
    rep(j,8)
      cin>>a[j];
    s1.X=pt(a[0],a[1]);
    s1.Y=pt(a[2],a[3])-s1.X;
    s2.X=pt(a[0+4],a[1+4]);
    s2.Y=pt(a[2+4],a[4+3])-s2.X;
    cout<<line2(s1,s2)<<endl;
  }
  return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> v(n);

	for (int i = 0; i < n; i++)
	{
		cin >> v[i];
	}

	long long int cnt = 0;

	for (int i = 0; i < n; i++)
	{
		int t = v[i];
		while (t % 2 == 0)
		{
			t /= 2;
			cnt++;
		}
	}

	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<cmath>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  2000007
#define md 998244353ll
///////////////////////////
///////////////////////////
///


int main(){
   ll a, b, c;
   L3(a, b, c);
   PL((b / c - (a-1)/c));
    return 0;
}


Measured memory_bytes: 3824
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<ctype.h>
typedef long long LL;
#define rep(i,n) for(LL i=0; i<(LL)(n); i++)

//qsort
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

//比較
int max(int a, int b){
	if (a>b) return a;
	else return b;
}

int min(int a,int b) {
	if(a>b) return b;
	else return a;
}

LL ans( LL n,LL xx){
	if(n == -1){
		return 0;
	}
	return (n/xx)+1;
}

//main関数
int main(){
	char S[50];
	char T[50];
	scanf("%s",S);
	scanf("%s",T);
	
	int Slen = strlen(S);
	int Tlen = strlen(T);
	
	int start = 0;
	
	int ans = 0;
	rep( i , Slen-Tlen+1 ){
		int flag = 0;
		rep( j , Tlen){
			if( S[i+j] != '?' && S[i+j] != T[j] ){
				flag = 1;
				break;
			}
		}
		if (flag == 0){
			start = i;
			ans = 1;
		}
	}
	
	if(ans == 0){
		printf("UNRESTORABLE");
		return 0;
	}
	
	//printf("ちんこ%d\n",start);
	for( int i = start ; i < start + Tlen; i++ ){
		S[i] = T[i-start];
	}
	rep ( i , Slen ) {
		if(S[i] == '?'){
			S[i] = 'a';
		}
	}
	printf("%s",S);	
}







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



int main()
{
  ll n;
  cin >> n;
  ll dig = floor(log10(n))+1;
  ll tmp = 0;
  ll cur = 1;
  ll base = 1;
  while(cur<dig)
  {
    tmp += base*9;
    base *= 100;
    cur+=2;
  }
  if(dig==1){
    cout << tmp + n << endl;
  } else if(dig%2==1) {
    cout << tmp + n - pow(10,dig-1) + 1 << endl;
  } else {
    cout << tmp << endl;
  }
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/
int main(){
  int N;cin>>N;
  vector<ll> res;
  ll ans = 0;
  map<ll,ll> A;
  rep(i,N){
    ll a;cin>>a;
    A[a]++;
    ans += a;
  }

  int Q;cin>>Q;
  while(Q--){

    ll b,c;cin>>b>>c;
    ll Ab = A[b];
    ll Ac = A[c];

    A[c] += Ab;
    A[b] = 0;

    ans -= Ab * b;
    ans += Ab * c;
    res.push_back(ans);
  }
  for(auto x:res){
    cout << x << endl;
  }
}

Measured memory_bytes: 10028
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,t,f=0,k,i,x,j,sum;

    cin>>a>>b>>c>>t;

    for(i=0; i<=a; i++)
    {
        for(j=0; j<=b; j++)
        {
           for(k=0; k<=c; k++)
           {
               sum=(i*500)+(j*100)+(k*50);

               if(sum==t)
               {
                   f++;
                   break;
               }
           }
        }
    }
    cout<<f<<endl;

    return 0;
}


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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<int> d(n);
	rep(i, n) cin >> d[i];
	int sum = 0;
	rep(i, n) rep(j, n) {
		if (i >= j)
			continue;
		sum += d[i] * d[j];
	}
	cout << sum << endl;
	return 0;
}


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

double fact(int  n){
    double ans=1 ;
    for (int i=1; i<=n; i++){
        ans*=i;
    }
    return ans ;
}

int main(void){
    int n ;
    cin >> n ;
    vector<double> x,y ;
    for (int i=0; i<n; i++){
        double a,b ;
        cin >> a >> b ;
        x.push_back(a) ;
        y.push_back(b) ;
    }
    double ans=0 ;
    for (int i=0; i<n; i++){
        for (int j=0; j<n; j++){
            double sum=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
            ans+=sqrt(sum)*fact(n-1) ;
            sum=0 ;
        }
    }
    ans=ans/(fact(n)) ;
    cout << setprecision(15) << ans << endl ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

void solve(int a, int b) {
  int A = a-1;
  int B = b-1;
  int ah = max(1, (A+98)/99) * 4;
  int bh = max(1, (B+98)/99) * 4;
  cout << (ah + bh) << " 100" << endl;
  vector<string> t(ah + bh, string(100, '.'));
  REP(i,ah) REP(j,100) t[i][j] = '#';
  REP(i,A) {
    int y = (i / 99) * 4;
    int x = i % 99;
    if (i%2) t[y+1][x] = '.';
    else t[y+2][x] = '.';
  }
  REP(i,B) {
    int y = (i / 99) * 4 + ah;
    int x = i % 99;
    if (i%2) t[y+1][x] = '#';
    else t[y+2][x] = '#';
  }
  for (auto &l : t) {
    cout << l << endl;
  }
}

int main()
{
  int a,b;
  cin>>a>>b;
  solve(a, b);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ll n, m, x, i, j , k, s = 0;
	cin>>n>>m>>x;
	ll arr[n][m];
	vector<ll> cost(n);
	for(int i=0; i<n;i++)
	{
		cin>>cost[i];
		for(int j=0; j<m;j++)
		{
			cin>>arr[i][j];
		}
	}
	ll ans = 1e8;
	for(ll mask = 0; mask<(1<<n);mask++)
	{
		ll currCost = 0;
		vector<ll> alg(m,0);
		for(ll i=0; i<n;i++)
		{
			if(mask&(1<<i))
			{
				currCost+=cost[i];
				for(int j = 0; j<m;j++)
				{
					alg[j] += arr[i][j];
				}
			}
		}
		ll minElement = *min_element(alg.begin(),alg.end());
		if(minElement>=x)
			ans = min(currCost,ans);
	}
	if(ans==1e8)
		cout<<"-1";
	else
		cout<<ans;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(), v.end()

/* デカい配列はここで宣言 */

int main(int argc, char const *argv[])
{
    ll c;
    cin>>c;
    cout << c * c << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

class Main{
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final PrintWriter out = new PrintWriter(System.out);
    private static final char[] suites = {'S', 'H', 'C', 'D'};
    static boolean[][] cards = new boolean[4][13];
    public static void main(String[] Args) throws IOException{
        final int n = Integer.parseInt(br.readLine());
        for(int i = 0; i<n; i++){
            final String in = br.readLine();
            final char suit = in.charAt(0);
            final int num = Integer.parseInt(in.substring(2));
            if(suit=='S') cards[0][num-1] = true;
            else if(suit=='H') cards[1][num-1] = true;
            else if(suit=='C') cards[2][num-1] = true;
            else if(suit=='D') cards[3][num-1] = true;
        }
        for(int i = 0; i<4; i++){
            for(int j = 0; j<13; j++){
                if(!cards[i][j]) out.println(suites[i]+" "+ (j+1));
            }
        }
        out.flush();
    }
}

Measured memory_bytes: 24244
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+5, G = 1e7;
long long kol, suf[N], x;
int n, f=1;
vector <long long> k;
int main()
{
    ios_base::sync_with_stdio(0);
    //freopen( "input.txt", "r", stdin );
    cin >> n >> kol;
    for( int i = 0; i < n; i++ ){
        cin >> x;
        k.push_back( x );
    }
    sort( k.begin(), k.end() );
    suf[n-1] = k[n-1];
    for( int i = n-2; i >= 0; i-- )
        suf[i] = k[i] + suf[i+1];
    int l = 1, r = k[n-1], m;
    while( l <= r ){
        m = floor((l+r)/2);
        long long sum = 0, j = upper_bound( k.begin(), k.end(), m ) - k.begin();
        for( ; j < n; j++ ){
            sum += k[j] / m;
            if( !(k[j]%m) )
                sum--;
        }
        if( sum <= kol )
            r = m-1;
        else
            l = m+1;
    }
    cout << l;
    return 0;
}


Measured memory_bytes: 6264
n, a, b = map(int, input().split())
mod =  10**9 + 7

def calculate_combination(n, k):
    x, y = 1, 1
    for i in range(k):
        x = x * (n-i) % mod
        y = y * (k-i) %mod
    return x * pow(y, mod-2, mod) % mod

ans = pow(2, n, mod)-1 - calculate_combination(n, a) - calculate_combination(n, b)
while ans < 0:
    ans += mod
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    
    long long h, w;
    cin >> h >> w;
    
    long long ans = h*w;
    
    vector<long long> area(3);
    
    // 回転前と回転後の２通りを試す
    for (int i = 0; i < 2; i++){
        
        // １つの長方形の辺の長さを全探索する
        for (long long t = 1; t < h; t++){
            
            // 縦割りを試す
            area[0] = t * w;
            area[1] = (h-t)*(w/2);
            area[2] = h*w - area[0] - area[1]; // 最後の面積は, 全体の面積から, それまでに計算した面積２つを引けば良い
            
            sort(area.begin(),area.end());
            ans = min (ans, area[2]-area[0]); // mmax - minと現在までの答えを比較せよ
            
            
            // 横割りを試す
            area[0] = t*w;
            area[1] = ((h-t)/2) * w;
            area[2] = h*w - area[0] - area[1];
            
            sort(area.begin(),area.end());
            ans = min(ans, area[2]-area[0]); // mmax - minと現在までの答えを比較せよ
        }
        
        // チョコレートの回転を忘れない!!!
        swap(h,w);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
X, N = list(map(int, input().strip().split()))
l = list(map(int, input().strip().split()))
l = sorted(l, reverse = False)
 
rslt = 200
 
#自明なパターン
if N == 0: rslt = X
if N != 0:
  if l[0] > X: rslt = X
  elif l[-1] < X: rslt = X
  elif (l[0]<=X) and (l[-1]>=X):
    e_min = int(l[0]-1)
    e_max = int(l[-1]+1)
    e_l = [i for i in range(e_min, e_max+1) if i not in l]
    for n in e_l[::-1]:
      if abs(X-n) <= abs(X - rslt): rslt = n
  
print(rslt)

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

int main()
{
  long long k, c[3], a[3];
 
  for (int i=0; i<3; i++) {
    cin >> c[i];
    a[i] = 1 - i;
  }
   cin >> k;
  long long sum = 0;
  for (int i=0; i<3; i++) {
    long long taken = min(k,c[i]);
    sum += taken * a[i];
    k -= taken;
  }
  cout << sum;
}


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

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

	for(int i = 1; i < n;++i){
		if(s[i-1] =='x' and s[i] =='x'){
			cout << i << endl;
			return 0;
		}
	}

	cout << n << endl;
	return 0;
}

Measured memory_bytes: 3340
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;

int main() {
    int N, M;
    cin  >> N >> M;
    priority_queue<int> heap;

    int cost;
    for (int i = 0; i < N; i++) {
        cin >> cost;
        heap.push(cost);
    }
    int m = M;
    while (m--) {
        int cur = heap.top(); heap.pop();
        heap.push(cur / 2);
    }
    ll sum = 0;
    while (!heap.empty()) {
        sum += heap.top();heap.pop();
    }
    cout << sum <<endl;
    
    return 0;
}

Measured memory_bytes: 892
using System;
using System.Linq;
class p
{
  static void Main()
  {
    string S = Console.ReadLine();
    Console.WriteLine((S.Count(x => x == 'a') == 1) && (S.Count(x => x == 'b') == 1) && (S.Count(x => x == 'c') == 1) ? "Yes" : "No");
  }
}

Measured memory_bytes: 11220
from collections import deque

n = int(input())
a = list(input().split())

b = deque()
for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])
if n % 2 == 1:
    b.reverse()

print(' '.join(b))


Measured memory_bytes: 26564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
const int maxn=1e6+5;

vi primes;
bool visited[maxn];

int f(int x){
	int i=1;
	int ans=0;
	while(x>=i){
		x -= i;
		ans++;
		i++;
	}
	return ans;
}

int32_t main(){
    fast_io;
    int n;
    cin>>n;
    fo(i,2,maxn-1){
    	if(!visited[i]) {
    		primes.emplace_back(i);
    		for(int j = 2*i ; j<maxn; j+=i){
    			visited[j] = 1;
    		}
    	}
    }
    int ans=0;
    for(auto it:primes){
    	int curr = 0;
    	while(n % it == 0){
    		n /= it;
    		curr++;
    	}
    	if(curr > 0) ans += f(curr);
    }
    if(n>1) ans++;
    show(ans);
    return 0;
}

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

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

    vector<vector<int>> adj(n+1);

    for(int i=1;i<n;i++){
        int p,c;
        cin>>p>>c;
        adj[p].push_back(c);
        adj[c].push_back(p);
    }

    vector<long long> cost(n+1,0);

    for(int i=0;i<Q;i++){
        int v,c;
        cin>>v>>c;
        cost[v] += c;
    }

    queue <int> q;

    // int a = 0;
    // for(int i=0;i<adj.size();i++)
    //     if(adj[i].size()>0){
    //         a=i;
    //         break;
    //     }
    q.push(1);
    vector<bool> vis(n+1,0);
    vis[1] = 1;
    while(!q.empty()){
        int nc = q.size();
        
        while(nc>0){
            int pa = q.front();
            q.pop();
            
            nc--;
            long long pc = cost[pa];
            for(int i=0;i<adj[pa].size();i++){
                    if(!vis[adj[pa][i]]){   
                        vis[adj[pa][i]]=1;             
                    q.push(adj[pa][i]);
                    cost[adj[pa][i]] += pc;
                }
            }
        }
    }

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

Measured memory_bytes: 16372
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

class Node {
public:
	int location;
	int p, l, r;
	//Node() {}
};

class Point {
public:
	int id, x, y;
	Point() {}
	Point(int id, int x, int y) :id(id), x(x), y(y) {}
	bool operator<(const Point&p) const {
		return id < p.id;
	}

	void print() {
		printf("%d\n", id);
	}
};

static const int MAX = 500000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int np;
Point ans[MAX];
int NANS;

bool lessX(const Point &p1, const Point &p2) {
	return p1.x < p2.x;
}

bool lessY(const Point &p1, const Point &p2) {
	return p1.y < p2.y;
}

int makeKDTree(int p, int l, int r, int depth) {
	if (l == r) {
		return NIL;
	}
	int mid = (l + r) / 2;
	int t = np++;
	if (depth % 2 == 0) {
		sort(P + l, P + r, lessX);
	}
	else {
		sort(P + l, P + r, lessY);
	}
	T[t].location = mid;
	T[t].p = p;
	T[t].l = makeKDTree(t, l, mid, depth + 1);
	T[t].r = makeKDTree(t, mid + 1, r, depth + 1);

	return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth) {
	int x = P[T[v].location].x;
	int y = P[T[v].location].y;

	if (sx <= x && x <= tx && sy <= y && y <= ty) {
		ans[NANS++] = P[T[v].location];
	}

	if (depth % 2 == 0) {
		if (T[v].l != NIL) {
			if (sx <= x) find(T[v].l, sx, tx, sy, ty, depth + 1);
		}
		if (T[v].r != NIL) {
			if (x <= tx) find(T[v].r, sx, tx, sy, ty, depth + 1);
		}
	}
	else {
		if (T[v].l != NIL) {
			if (sy <= y) find(T[v].l, sx, tx, sy, ty, depth + 1);
			//if (sy <= y && sx <= x) find(T[v].l, sx, tx, sy, ty, depth + 1);
		}
		if (T[v].r != NIL) {
			if (y <= ty) find(T[v].r, sx, tx, sy, ty, depth + 1);
			//if (y <= ty && x <= tx) find(T[v].r, sx, tx, sy, ty, depth + 1);
		}
	}
}

int main() {
	int x, y;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d %d", &x, &y);
		P[i] = Point(i, x, y);
		T[i].p = T[i].l = T[i].r = NIL;
	}

	np = 0;

	int root = makeKDTree(NIL, 0, N, 0);

	int q;
	scanf("%d", &q);
	int sx, tx, sy, ty;
	for (int i = 0; i < q; i++) {
		scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
		NANS = 0;
		find(root, sx, tx, sy, ty, 0);
		sort(ans, ans + NANS);
		for (int j = 0; j < NANS; j++) {
			ans[j].print();
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 16308
x, k, d = (int(x) for x in input().split())
if x<0:
    x = -x
if k*d < x:
    print(x-k*d)
else:
    div = x//d
    k-=div
    x-=div*d
    if k%2==0:
        print(x)
    else:
        print(d-x)


Measured memory_bytes: 61684
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	
      	int n = sc.nextInt();
     	long as[] = new long[n];
      	long money = 1000;
      	long stock = 0;
      	    
      	for(int i = 0;i < n;i++) as[i] = sc.nextLong();
      
      	long ystock = as[0];
       	
      	for(int i = 1;i < n;i++){
          	if(ystock <= as[i]){
            	stock = money/ystock;
              	money -= stock*ystock;
				money += stock*as[i];              
            }
          	ystock = as[i];
        }
      
      	System.out.println(money);
	}
}


Measured memory_bytes: 35848
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

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

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; }
typedef pair <ll,ll> P;
ll MOD = 1000000007;

int main()
{
    ll N;
    cin  >> N;
    map<ll, ll> mp;
    rep(i, N) {
        ll A;
        cin >> A;
        mp[A]++;
    }
    bool flag = false;
    if (N % 2 == 0) {
        ll count = 1;
        for(ll i = 1; i < N; i += 2) {
            if (mp[i] != 2) {
                flag = true;
                break;
            } else {
                count *= 2;
                count %= MOD;
            }
        }
        if (flag) {
            cout << 0 << endl;
            return 0;
        } else {
            cout << count << endl;
            return 0;
        }
    } else {
        ll count = 1;
        if (mp[0] != 1) {
            cout << 0 << endl;
            return 0;
        } 
        for(ll i = 2; i < N; i += 2) {
            if (mp[i] != 2) {
                flag = true;
                break;
            } else {
                count *= 2;
                count %= MOD;
            }
        }
        if (flag) {
            cout << 0 << endl;
            return 0;
        } else {
            cout << count << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n); ++i)
typedef long long ll;
int main(){
  int A,B;
  cin >> A >> B;
for(int i=1; i<=3; i++){
    if(i!=A && i!=B){
      cout << i;
    }
}
}

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

long long n;

int main() {
  	cin >> n;
  	for (int i = sqrt(n); i >= 1; i--) 
    	if (n % i == 0) 
     		return cout << (i - 1) + ((n / i) - 1) << '\n', 0;     
	return 0;
}	

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
int s[MAXN],n;
vector<int> a,b,c;
int query(int x) { int ans=0; for (;x;x-=x&(-x)) ans+=s[x]; return ans; }
void add(int x,int y) { for (;x<=n;x+=x&(-x)) s[x]+=y; }
ll gets(vector<int> a)
{
	ll ans=0;
	for (auto v:a) add(v,1),ans+=query(n)-query(v);
	for (auto v:a) add(v,-1);
	return ans;
}
int main()
{
	n=read();
	int flag=1;
	for (int i=1;i<=n;i++)
	{
		int x=read();
		a.PB(x);
		if (i&1) b.PB(x),flag&=(x%2==1);
		else c.PB(x),flag&=(x%2==0);
	}
	if (gets(a)==gets(b)*3+gets(c)*3&&flag) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 9444
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, K;
  while (cin >> N >> K) {
    int res = N - K + 1;
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
 
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n+1);
	vector<bool> sw(n+1);
	reps(i,n){
		cin >> a[i];
	}
	int now = 1;
	rep(i,n){
		if(now == 2){
			cout << i << '\n';
			return 0;
		}
		if(sw[now] == true){
			break;
		}
		sw[now] = true;
		now = a[now];
	}
	cout << -1 << '\n';
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	vector<pii> ans;
	int M = 0;
	int Mi = -1;
	for(int i = 0; i < N; i++) {
		cin >> a[i];
		if(abs(M) < abs(a[i])) {
			M = a[i];
			Mi = i;
		}
	}
	if(M == 0) {
		cout << 0 << endl;
		return 0;
	}
	for(int i = 0; i < N; i++) {
		if(Mi == i) continue;
		a[i] += M;
		ans.emplace_back(Mi + 1, i + 1);
	}
	if(M > 0) {
		for(int i = 1; i < N; i++) {
			ans.emplace_back(i, i + 1);
			a[i] += a[i - 1];
		}
	} else {
		for(int i = N - 1; i > 0; i--) {
			ans.emplace_back(i + 1, i);
			a[i - 1] += a[i];
		}
	}
	cout << ans.size() << endl;
	for(auto it = ans.begin(); it != ans.end(); it++)
		cout << (*it).first << " " << (*it).second << endl;
	return 0;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		if(W == 1){
			Console.WriteLine(1);
			return;
		}
		
		
		List<int> validH = new List<int>();
		for(int i=0;i<1<<(W-1);i++){
			bool chk = true;
			for(int k=0;k<W;k++){
				if(((i >> k) & 0x3) == 0x3) chk = false;
			}
			if(chk) validH.Add(i);
		}
		
		int[] dp = new int[W];
		dp[0] = 1;
		for(int i=0;i<H;i++){
			int[] ndp = new int[W];
			foreach(var vh in validH){
				for(int j=0;j<W;j++){
					if(j > 0 && ((vh >> (j - 1)) & 0x1) == 1){
						ndp[j - 1] += dp[j]; if(ndp[j - 1] >= mod) ndp[j - 1] -= mod;
					} else if(j < W - 1 && ((vh >> j) & 0x1) == 1){
						ndp[j + 1] += dp[j]; if(ndp[j + 1] >= mod) ndp[j + 1] -= mod;
					} else {
						ndp[j] += dp[j]; if(ndp[j] >= mod) ndp[j] -= mod;
					}
				}
			}
			dp = ndp;
		}
		
		Console.WriteLine(dp[K-1]);
		
	}
	
	const int mod = (int) 1e9 + 7;
	int H,W,K;
	public Sol(){
		var d = ria();
		H = d[0]; W = d[1]; K = d[2];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13268
#include <cmath>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

constexpr int MOD = 1e9 + 7;

int n;
vi a;

void input() {
  cin >> n;

  a.resize(n);
  for (auto&& i : a)
    cin >> i;
}

void solve() {
  vector<ll> s(n);

  s[0] = a[0];

  for (int i = 1; i < n; ++i)
    s[i] = s[i - 1] + a[i];

  int ans = 0;
  
  for (int i = 0; i < n - 1; ++i) {
    ll sum = s.back() - s[i];

    sum %= MOD;

    int tmp = (a[i] * sum) % MOD;

    ans = (ans + tmp) % MOD;
  }

  cout << ans << '\n';
}

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

  cout.precision(16);
  cout << fixed;

  int _times = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  _times = 2;
#endif

  // cin >> _times;

  while (_times--) {
    input();
    solve();
  }
}


Measured memory_bytes: 5516