akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define ll              long long
#define Ull             unsigned long long
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

const int N = 2;
const ll MOD = 1e9 + 7;


/*bool comp(const pii &p1, const pii &p2)
{

}*/


void Solve()
{

	ll n, m;
	cin >> n >> m;
	ll dp[n][m];
	for (ll i = 0; i < n; i++)
	{
		for (ll j = 0; j < m; j++)
		{
			char c;
			cin >> c;
			if (c == '#')
				dp[i][j] = INF;
		}
	}
	dp[0][0] = 1;
	for (ll i = 1; i < m; i++)
	{
		if (dp[0][i] == INF || dp[0][i - 1] == 0)
			dp[0][i] = 0;

		else
			dp[0][i] = 1;


		//cout << dp[0][i] << " ";
	}

	for (ll i = 1; i < n; i++)
	{
		if (dp[i][0] == INF || dp[i - 1][0] == 0)
			dp[i][0] = 0;

		else
			dp[i][0] = 1;

		//cout << dp[i][0] << "\n";
	}

	for (ll i = 1; i < n; i++)
	{
		for (ll j = 1; j < m; j++)
		{
			if (dp[i][j] == INF)
			{
				dp[i][j] = 0;
				continue;
			}

			else
				dp[i][j] = (dp[i - 1][j] % MOD + dp[i][j - 1] % MOD) % MOD;
		}
	}

	cout << dp[n - 1][m - 1] << "\n";



}


int main()
{

	FastRead;
	int T = 1;
	//cin>>T;
	while (T--)
	{
		Solve();
	}

	return 0;
}


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

int main() {
    
    long A,B,K;
    
    cin>>A>>B>>K;
    
    if(A+B<K){
        cout<<0<<" "<<0<<endl;
    }
    else if(A<K){
        cout<<0<<" "<<B-(K-A)<<endl;
    }
    else{
        cout<<A-K<<" "<<B<<endl;        
    }

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

main(void)
{
  int i, j, n, q, S[10000], T[500],ans = 0;

  cin >> n;

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

  cin >> q;

  for(i = 0;i < q;i++){
    cin >> T[i];
  }

  for(i = 0;i < q;i++){
    for(j = 0;j < n;j++){
      if(S[j] == T[i]){
	ans++;
	break;
      }
    }
  }

  cout << ans << endl; 
  
  return 0;
}



Measured memory_bytes: 3136
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

ll dp[110][100010],w[110],v[110];

int main(void){
	          ll i,j;

	          cin.tie(0);  ios_base::sync_with_stdio(false);

	          ll N,W;
	          cin >> N >> W;
	          for(i=0;i<N;i++) cin >> w[i] >> v[i];

	          fill(dp[0],dp[0]+100001,1e18);
	          dp[0][0]=0;
	          REP(i,N){
	        	  for(j=0;j<=100000;j++){
	        	  if(j<v[i]){
	        		  dp[i+1][j]=dp[i][j];
	        	  }else{
	        		  dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
	        	  }
	          }
	          }

	          ll res=0;
	          for(j=0;j<=100000;j++) if(dp[N][j]<=W) res=j;

	          cout << res << endl;


	          return 0;
}


Measured memory_bytes: 80128
#include <iostream>
#include <vector>
#include <bitset>
#include <string>
#include <array>
#include <random>
#include <chrono>
#include <algorithm>
#include <unordered_map>
int main(void){
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	for(int i=0;i<n;i++)std::cin >> a[i];
	double denom = 0;
	for(int i=0;i<n;i++){
		denom += 1.0 / a[i];
	}
	printf("%.9lf\n", 1.0 / denom);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
		
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	char a[3];
	cin>>a;
	for(int i=0;i<3;i++){
		if(a[i]=='9'){
			cout<<"1";
		}
		else{	cout<<"9";
		}
}
 return 0;
}

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

int main() {
  int N, A;
  string op;
  cin >> N >> A;
if ( N - N / 1000 * 1000 == A )
  cout << "Yes" << endl;
if ( N - N / 1000 * 1000 > A ) {
  cout<< "No"<< endl;
 }
else if ( N - N / 1000 * 1000 < A ) {
  cout <<"Yes"<< endl;
 }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc088() {
	ll c[3][3];
	string ans = "Yes";

	ll sum3 = 0;
	rep(i, 3)rep(j, 3) {
		cin >> c[i][j];
		sum3 += c[i][j];
	}
	if (sum3 % 3 != 0) ans = "No";

	ll sum2 = 0;
	rep(i, 2)rep(j, 2) {
		sum2 += c[i][j];
	}
	if (sum2 % 2 != 0) ans = "No";

	sum2 = 0;
	rep(i, 2)rep(j, 2) {
		sum2 += c[i + 1][j];
	}
	if (sum2 % 2 != 0) ans = "No";

	sum2 = 0;
	rep(i, 2)rep(j, 2) {
		sum2 += c[i][j + 1];
	}
	if (sum2 % 2 != 0) ans = "No";

	sum2 = 0;
	rep(i, 2)rep(j, 2) {
		sum2 += c[i + 1][j + 1];
	}
	if (sum2 % 2 != 0) ans = "No";

	cout << ans << "\n";
}

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

	solve_abc088();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int A[2019];
int main(){
	int l,r;
	cin >> l >> r;
	
	for (int i=l;i<=r;i++){
		if (A[i%2019]<2)
			A[i%2019]+=1;
		else break;
	}
	
	int ans = 2019;
	for (int i = 0; i<2019; i++)
		for (int j = 0; j<2019; j++)
			if (( i!=j && A[i]!=0 && A[j]!=0) || (i==j && A[i]==2)){
				int mu = (i*j)%2019;
				if (ans>mu) ans = mu;
			}

	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
s = (10**9)+7

def power_func(a,n,p):
    bi = str(format(n,"b"))#2進表現に
    res = 1
    for i in range(len(bi)):
        res = (res*res) %p
        if bi[i] == "1":
            res = (res*a) %p
    return res

res1 = power_func(10,N,s)
res2 = power_func(9,N,s)
res3 = power_func(8,N,s)
print((res1 - (res2*2-res3))%s)

Measured memory_bytes: 9212
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			long n = scanner.nextLong();
			scanner.nextLine();
			long min = IntStream.range(0, 5).mapToLong(i -> {
				long number = scanner.nextLong();
				scanner.nextLine();
				return number;
			}).min().getAsLong();
			System.out.println((n - 1) / min + 5);
		}
	}
}


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

int main() {
  int N, K, d, i;
  set<int> A;
  cin >> N >> K;
  while (K>0) {
    K--;
    cin >> d;
    while (d>0) {
      d--;
      cin >> i;
      A.insert(i);
    }
  }
  cout << N - A.size() << endl;
}

Measured memory_bytes: 3632
import numpy as np
import itertools as it

n = int(input())
city = [np.array(list(map(int,input().split()))) for i in range(n)]

dist = [[[] for i in range(n)] for i in range(n)]
for i in range(n):
    for j in range(n):
        v = city[i] - city[j]
        dist[i][j] = np.linalg.norm(v, ord=2)

ps = it.permutations([i for i in range(n)])
anss = []
for p in ps:
    ans = 0
    for i in range(n-1):
        ans += dist[p[i]][p[i+1]]
    anss.append(ans)

print(np.average(anss))


Measured memory_bytes: 23220
from collections import deque

N, M = map(int, input().split())
m = [[] for _ in range(N + 1)]
for _ in range(M):
    u, v = map(int, input().split())
    m[u].append(v)
S, T = map(int, input().split())

l = [[-1, -1, -1] for _ in range(N + 1)]

q = deque()
q.append((S, 0, 0))
while len(q):
    i, n, mod = q.popleft()
    for j in m[i]:
        if j == T and mod == 2:
            print((n + 1) // 3)
            exit()
        if l[j][(mod + 1) % 3] != -1:
            continue
        l[j][(mod + 1) % 3] = n + 1
        q.append((j, n + 1, (mod + 1) % 3))

print(-1)


Measured memory_bytes: 71712
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long x = sc.nextLong();
    long[] a = new long[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
    }
    long[][] b = new long[n][n];
    for(int i = 0; i < n; i++) {
      b[i][0] = a[i];
      for(int j = 1; j < n; j++) {
        if((i - j) >= 0) {
          b[i][j] = Math.min(b[i][j - 1], a[i - j]);
        } else {
          b[i][j] = Math.min(b[i][j - 1], a[n - (j - i)]);
        }
      }
    }
    long ans = (long)Math.pow(10, 18);
    for(int k = 0; k < n; k++) {
      long t = (x * k);
      for(int i = 0; i < n; i++) {
        t += b[i][k];
      }
      ans = Math.min(ans, t);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 80600
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
#define ll long long
using namespace std;
int n,K;
ll ans=0;
int read()
{
	int x=0,f=1;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
int main()
{
	n=read();K=read();
	if(K==0) ans=(ll)n*n;
	else 
		for(int b=K+1;b<=n;b++)
			ans+=(n/b)*(b-K)+max(n%b-K+1,0);
	printf("%lld",ans);	
    return 0;
}



Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

vector<int> primes;//100以下の素数

int main(){
  for(int i = 2 ; i <= 100; i++){
    bool is_prime = true;
    for(int j = 2; j < i; j++){
      if(i%j==0) is_prime = false;
    }
    if(is_prime) primes.push_back(i);
  }
  ll n;
  cin >> n;
  vector<int> prime_cnt;
  prime_cnt.resize(primes.size());
  for(int i = 1; i <= n; i++){
    int k = i;
    REP(j,primes.size()){
      while(k%primes[j]==0){
        k /= primes[j];
        prime_cnt[j]++;
      }
    }
  }
  ll ans = 0;

  int cnt_over2 = 0, cnt_over4 = 0, cnt_over14 = 0, cnt_over24 = 0, cnt_over74 = 0;
  REP(j,primes.size()){
    if(prime_cnt[j]>=2) cnt_over2++;
    if(prime_cnt[j]>=4) cnt_over4++;
    if(prime_cnt[j]>=14) cnt_over14++;
    if(prime_cnt[j]>=24) cnt_over24++;
    if(prime_cnt[j]>=74) cnt_over74++;
  }
  ans += max(0,cnt_over74);
  ans += max(0,cnt_over24 * (cnt_over2-1));
  ans += max(0,cnt_over14 * (cnt_over4-1));
  ans += max(0,cnt_over4 * (cnt_over4-1) * (cnt_over2-2)/2);

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<bool> ac(N);
	vector<int> num(N);
	for (auto i = 0; i < M; ++i)
	{
		int p;
		string S;
		cin >> p >> S;
		--p;
		if (S == "AC")
		{
			ac[p] = true;
		}
		else if (ac[p] == false)
		{
			++num[p];
		}
	}

	auto numAC = 0;
	auto numWA = 0;
	for (auto i = 0; i < N; ++i)
	{
		if (ac[i] == true)
		{
			++numAC;
			numWA += num[i];
		}
	}

	cout << numAC << " " << numWA << endl;

	return 0;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    string s;
    rep(0, 3) {
        cin >> s;
        cout << char(toupper(s[0]));
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let k: i64 = scan(tokens);
    let mut x: i64 = scan(tokens);
    let mut y: i64 = scan(tokens);
    if k % 2 == 0 && (x.abs() + y.abs()) % 2 == 1 {
        println!("-1");
        return;
    }
    let mut res = Vec::new();
    while x != 0 || y != 0 {
        res.push((x, y));
        let (sx, mut ax) = if x < 0 { (-1, -x) } else { (1, x) };
        let (sy, mut ay) = if y < 0 { (-1, -y) } else { (1, y) };
        let d = ax + ay;
        if d % k == 0 {
            if ax >= k {
                ax -= k;
            } else if ay >= k {
                ay -= k;
            } else {
                ax = 0;
                ay = 0;
            }
        } else if d < 2 * k && d % 2 == 0 {
            let r = k - d / 2;
            if ax >= k - r {
                ax -= k - r;
                ay += r;
            } else if ay >= k - r {
                ax += r;
                ay -= k - r;
            } else {
                unreachable!();
            }
        } else if d % k % 2 == k % 2 {
            let s = (k - d % k) / 2;
            if ax >= k - s {
                ax -= k - s;
                ay += s;
            } else if ay >= k - s {
                ax += s;
                ay -= k - s;
            } else {
                assert_eq!(k, d + 2 * s);
                ax = -2 * s;
                ay = 0;
            }
        } else {
            if ax >= ay {
                ax -= k;
            } else {
                ay -= k;
            }
        }
        x = sx * ax;
        y = sy * ay;
    }
    println!("{}", res.len());
    while let Some((x, y)) = res.pop() {
        println!("{} {}", x, y);
    }
}


Measured memory_bytes: 11512
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n; cin >> n;
	if (n / 10 == 9) {
		cout << "Yes" << endl;
	}
	else if (n % 10 == 9) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	cin >> n;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cctype>

int main(){
    char ch;
    while(1){
        scanf("%c",&ch);
        if(isalpha(ch)){
         if(islower(ch))printf("%c",toupper(ch));
         else printf("%c",tolower(ch));
        }else printf("%c",ch);
        if(ch=='\n') break;
    }
    return 0;
}



Measured memory_bytes: 2560
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

s = input()
t = input()
c1 = collections.Counter(s)
c2 = collections.Counter(t)
value1 = []
value2 = []
for value in c1.values():
    value1.append(value)
for value in c2.values():
    value2.append(value)
value1.sort(),value2.sort()
if value1 == value2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3940
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();
        int[] city = new int[N+1];
        for (int i = 1; i < N+1; i++) {
            city[i] = sc.nextInt();
        }
        int[] step = new int[N+1];
        int now = 1;
        int tmp = 0;
        step[1] = 1;
        int front = 0;
        int roop = 0;
        boolean roopIn = false;
        for (int i = 0; i < K; i++) {
            tmp = now;
            now = city[now];
            if (step[now] == 1 && !roopIn) {
                front = i+1;
                roopIn = true;
            } else if (step[now] == 2) {
                roop = i - front;
                break;
            } else {
                step[now]++;
            }
        }
        if (roop != 0) {
            long Kres = (K-front)%roop;
            for (int i = 0; i < (int) Kres; i++) {
                tmp = city[tmp];
            }
            System.out.println(tmp);
        } else {
            System.out.println(now);
        }
    }
}


Measured memory_bytes: 60232
using System;

namespace abc168_b
{
    class Program
    {
        static void Main(string[] args)
        {
            var maxNum = int.Parse(Console.ReadLine());
            var inputText = Console.ReadLine();

            // 入力された文字列が指定文字数以上の場合切り取る
            Console.WriteLine(AcquireDisplayText(maxNum, inputText));
            Console.Read();
        }

        /// <summary>
        /// 入力された文字が指定文字数以上の場合、先頭から指定文字数分のみ切り取り「...」を加える
        /// </summary>
        /// <param name="maxNum"></param>
        /// <param name="inputText"></param>
        /// <returns></returns>
        private static string AcquireDisplayText(int maxNum, string inputText)
        {
            if (inputText.Length > maxNum)
            {
                var resultText = "";

                for (int i = 0; i < maxNum; i++)
                {
                    resultText += inputText[i];
                }

                resultText += "...";

                return resultText;
            }

            return inputText;
        }
    }
}


Measured memory_bytes: 27364
#include <bits/stdc++.h>
using namespace std;
int count_2(int x){
  int cnt = 0;
  while(x%2==0){
    cnt++;
    x /= 2;
  }
  return cnt;
}
int main() {
  int n;
  cin >> n;
  int maxn=1;
  int max2=0;
  for(int i=1; i<=n; i++){
    if(max2<count_2(i)){
      max2=count_2(i);
      maxn=i;
    }
  }
  cout << maxn << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
//int p = 998244353;
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) {pa[x] = y;}
}
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
const int sz = (1 << 21);
vel bit_in(sz+1, 0);
vel bit_out = bit_in;
void change(vel &bit, int pot, int val) {
	pot++;
	for (int x = pot; x <= sz; x += x & -x) bit[x] += val;
}
int sum(vel &bit, int pot) {
	int ret = 0;
	pot++;
	for (int x = pot; x > 0; x -= x & -x) ret += bit[x];
	return ret;
}
void add(int st, int to,set<int> &all_st) {
	if (to < 0) { to =  0; }
	change(bit_out, st, 1);
	change(bit_in, to, 1);
	auto itr_to = all_st.upper_bound(to);
	auto itr_st = all_st.upper_bound(st);
	if (itr_to != itr_st) {
		itr_st--;
		all_st.erase(itr_st);
	}
}
void del(int st, int to, set<int> &all_st) {
	if (to < 0) { to = 0; }
	change(bit_out, st, -1);
	change(bit_in, to, -1);
	if (sum(bit_in, to) == sum(bit_out, to)) {
		all_st.insert(to + 1);
	}
}
signed main(){
	int n; cin >> n; n--;
	int a, b, c, d; cin >> a >> b >> c >> d;
	int diff = abs(a - b);
	rep(i, n + 1) {
		int max1 = d * i - c * (n - i);
		int min1 = c * i - d * (n - i);
		if (min1 <= diff and diff <= max1) { cout << "YES" << endl; return 0; }
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 34176
N = int(input())
S = [input() for i in range(N)]
ABcnt = 0
Acnt = 0
Bcnt = 0
BAcnt = 0
for s in S:
    for i in range(len(s)-1):
        if s[i] == 'A' and s[i+1] == 'B':
            ABcnt += 1
    if s[0] == 'B' and s[-1] == 'A':
        BAcnt += 1
    elif s[0] == 'B':
        Bcnt += 1
    elif s[-1] == 'A':
        Acnt += 1

if Acnt == 0 and Bcnt == 0:
    ans = ABcnt + max(BAcnt-1,0)
else:
    ans = ABcnt + BAcnt + min(Acnt,Bcnt)

print(ans)


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

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

    double ans = (double)(v[0] + v[1]) / 2.0;
    for (int i = 2; i < N; i++)
    {
        ans = (ans + (double)v[i]) / 2.0;
    }
    
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from sys import stdin
from collections import defaultdict,deque
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n)]
        self.rank = [0]*n
        self.n = n
    def find(self,x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:return
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    def same(self,x,y):
        return bool(self.find(x)==self.find(y))



def main():
    N,M = map(int,stdin.readline().split())
    uf = UnionFind(N)
    p = list(map(int,stdin.readline().split()))
    p = list(map(lambda x: x-1,p))
    ans = 0
    for _ in range(M):
        x,y = map(int,stdin.readline().split())
        x -= 1
        y -= 1
        uf.union(x,y)
    for i in range(N):
        tmp = p[i]
        if not uf.same(tmp,i):continue
        else:ans += 1
    print(ans)
    #print(*list(map(lambda x:x+1,p)))
if __name__ == "__main__":
    main()

Measured memory_bytes: 18896
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int x = 0;
        
        while(true){
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
            
            if(op.equals("?")){
                break;
            }
            else if(op.equals("+")){
                x = a + b;
            }
            else if(op.equals("-")){
                x = a - b;
            }
            else if(op.equals("*")){
                x = a * b;
            }
            else if(op.equals("/")){
                x = a / b;
            }
            System.out.println(x);
        }
        
    }
}




Measured memory_bytes: 26268
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		int ans = a + b;
		System.out.println(ans%24);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22996
N, M = map(int, input().split())

l_max = 1
r_min = N
for m in range(M):
    left, right = map(int, input().split())
    l_max = max(l_max, left)
    r_min = min(r_min, right)

if r_min < l_max:
    print(0)
else:
    print(r_min-l_max + 1)



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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B, C, X;
  int count = 0;
  cin >> A >> B >> C >> X;
  rep(i, A + 1) {
    rep(j, B + 1) {
      rep(k, C + 1) {
        if(X == (i * 500 + j * 100 + k * 50)) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define FORR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (e), i ## __begin = (b); i -- > i ## __begin;)
#define rep(i,n) for (decay_t <decltype (n)> i = 0, i ## __len = (n); i < i ## __len; ++ i)
#define ALL(x) begin (x), end (x)
using namespace std;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t n; cin >> n;
  vector <int> h (n);
  for (auto && elem : h) cin >> elem;

  auto preh = -1;
  auto ans = 0;
  for (auto && elem : h)
  {
    if (preh <= elem) ++ ans;
    preh = max (preh, elem);
  }
  cout << ans << endl;
}


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

int main(){
  char c;
  int cnt=0,h,w; cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>c;
      if(c=='#')cnt++;
    }
  }
  cout<<(cnt==h+w-1 ? "Possible" : "Impossible")<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <stdio.h>
#include <cassert>
#include <vector>
using namespace std;
int main() {
	int A, B, C;
	// string s;
	cin >> A >> B >> C;
 
	vector<int> vec{ A, B, C };
	// cin >> s;
	vector<int> five;
	vector<int> seven;
 
	for (int i : vec) {
		if (i == 5) {
			five.push_back(1);
		}
		else if (i == 7) {
			seven.push_back(1);
		}
	}
	if (five.size() == 2 && seven.size() == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
 
}

Measured memory_bytes: 3596
open System.Collections.Generic

let K = stdin.ReadLine() |> int

let queue = new Queue<int64>()

[ 1L..9L ] |> List.iter queue.Enqueue

let mutable n = 0L

let rec resolver k =
    n <- queue.Dequeue()
    match n % 10L with
    | 0L ->
        [ n * 10L + n % 10L
          n * 10L + n % 10L + 1L ]
    | 9L ->
        [ n * 10L + n % 10L - 1L
          n * 10L + n % 10L ]
    | _ ->
        [ n * 10L + n % 10L - 1L
          n * 10L + n % 10L
          n * 10L + n % 10L + 1L ]
    |> List.iter queue.Enqueue
    if k = K - 1 then ()
    else resolver (k + 1)

resolver 0
n |> printfn "%d"


Measured memory_bytes: 19924
import sys
input = sys.stdin.readline
def main():
    N = int( input())
    A = [ int( input()) for _ in range(N)]
    B = [0]*N
    C = [0]*N
    B[0] = A[0]
    C[N-1] = A[N-1]
    for i in range(N-1):
        B[i+1] = max(B[i], A[i+1])
        C[N-2-i] = max( C[N-1-i], A[N-2-i])
    print(C[1])
    for i in range(1, N-1):
        print( max(B[i-1], C[i+1]))
    print(B[N-2])
if __name__ == '__main__':
    main()


Measured memory_bytes: 15648
// スタックサイズ: 100MB

#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1e18;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }




int main() {
	fastio;

	ll n;
	cin >> n;
	vll a(n);
	rep(i, n) cin >> a[i];

	ll sum1 = a[0], ans1 = 0;
	if (sum1 <= 0) {
		ans1 += 1 - sum1;
		sum1 = 1;
	}
	fori(i, 1, n) {
		if (0 <= sum1 * (sum1 + a[i])) {
			ans1 += abs(pow(-1, i) - sum1 - a[i]);
			sum1 = pow(-1, i);
		}
		else sum1 += a[i];
	}

	ll sum2 = a[0], ans2 = 0;
	if (0 <= sum2) {
		ans2 += 1 + sum2;
		sum2 = -1;
	}
	fori(i, 1, n) {
		if (0 <= sum2 * (sum2 + a[i])) {
			ans2 += abs(pow(-1, i + 1) - sum2 - a[i]);
			sum2 = pow(-1, i + 1);
		}
		else sum2 += a[i];
	}

	cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 1024
s = str(input())
s += s
p = str(input())

ans = "No"
for i in range(len(s)):
    if s[i] == p[0]:
        for j in range(len(p)):
            if i + j >= len(s): break
            if s[i + j] != p[j]: break
        else:
            ans = "Yes"
print(ans)


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

// 最小公倍数
ll lcm(ll a, ll b){
	
	ll x = a * b;
	  if(a<b){
    ll tmp = a;
    a = b;
    b = tmp;
  }
	  /* ユークリッドの互除法 */
  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
	return x/b;

}

int main(){
	ll a,b;
	cin >> a >> b;
	
	cout << lcm(a,b) << endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

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

		int N = sc.nextInt();
		int K = sc.nextInt();
		int ans = 0;

		if (N % K == 0 ) {
			ans = 0;
		} else {
			ans = 1;
		}

		System.out.println( ans );
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

ll binpow(ll a, ll b) {
    if (b == 0)
    {
        return 1;
    }
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
    {
        return res * a;
    }
    return res;
}

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

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int s,w;
    cin>>s>>w;
    if (w>=s) cout<<"unsafe";
    else cout<<"safe";
    return 0;
}

Measured memory_bytes: 3656
use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::{max,min,Ordering};
use std::io::Read;

fn main() {

    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let N = buf_it.next().unwrap().parse::<usize>().unwrap();

    let mut S = HashSet::new();

    for _ in 0..N{
        let com = buf_it.next().unwrap();
        let C = buf_it.next().unwrap().chars().collect::<Vec<_>>();

        if com=="insert"{
            S.insert(C);
        } else {
            println!("{}",if S.contains(&C) {"yes"} else {"no"});
        }
    }

}


Measured memory_bytes: 58164
#include<bits/stdc++.h>
#define N 200010
#define pp pair<int,int>
#define fi first
#define se second
using namespace std;
pp ans[N*2];
int cnt;
int main(){
	int n;
	scanf("%d",&n);
	int g=(int)(log(n)/log(2)+0.5);
	if((1<<g)==n)return 0*printf("No\n");
	// if(n==3){
	// ans[++cnt]=pp(1,2);
	// ans[++cnt]=pp(2,3);
	// ans[++cnt]=pp(3,1+n);
	// ans[++cnt]=pp(1+n,2+n);
	// ans[++cnt]=pp(2+n,3+n);
	// 	for(int i=1;i<=cnt;i++)printf("%d %d\n",ans[i].fi,ans[i].se);
	// 	return 0;
	// }
	printf("Yes\n");
	for(int i=2;i+1<=n;i+=2){
		ans[++cnt]=pp(i,i+1);
		ans[++cnt]=pp(i+1,1);
		ans[++cnt]=pp(1,i+n);
		ans[++cnt]=pp(i+n,i+1+n);
	}
	ans[++cnt]=pp(3+n,1+n);
	if(n%2==0){
		int g1=1;while(g1*2<=n)g1<<=1;
		int g2=n-g1;
		ans[++cnt]=pp(n,g1+n);
		ans[++cnt]=pp(g2+1,n+n);
	}
	for(int i=1;i<=cnt;i++)printf("%d %d\n",ans[i].fi,ans[i].se);
	return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

vint dx = {1,1,0,-1,-1,-1,0,1};
vint dy = {0,1,1,1,0,-1,-1,-1};

int main() {
    int h, w; cin >> h >> w;
    vector<string> field(h);
    rep(i,h) cin >> field[i];
    rep(i,h)rep(j,w) {
        if (field[i][j] == '#') continue;
        else {
            int ct = 0;
            rep(k,8) {
                int n_x = j + dx[k];
                int n_y = i + dy[k];
                if (n_x >= 0 && n_x <= w-1 && n_y >= 0 && n_y <= h-1) {
                    if (field[n_y][n_x] == '#') ct++;
                }
            }
            field[i][j] = to_string(ct)[0];
        }
    }
    rep(i,h) {
        rep(j,w) cout << field[i][j];
        cout << endl;
    }
}

Measured memory_bytes: 256
# S = list(input().split())
# a = int(S[0])
# b = S[1].replace('.', '')
# B = int(b)
#
# ans = (a * B) // 100
# print(ans)

a, b = input().split()
A = int(a)
b = b.replace('.', '')
B = int(b)
ans = (A * B) // 100
print(ans)

Measured memory_bytes: 9036
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  std::string s;

  std::cin >> s;

  std::string t;

  for (const auto& c : s) {
    if (c == '0') {
      t.push_back(c);
    }
    else if (c == '1') {
      t.push_back(c);
    }
    else if (! t.empty()) {
      t.pop_back();
    }
  }

  std::cout << t << std::endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		int a, b;
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		if (a <= b) System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 35532
#include <stdio.h>

int main(void)
{
    int n,i,x;
    
    scanf("%d",&n);
    
    for(i=1;i<=n;i++){
        x=i;
        if(x%3==0){
            printf(" %d",i);
        }else{
            while(x){  //whileでも問題ない
                if(x%10==3){
                    printf(" %d",i);
                    x=0;
                }else{
                x/=10;
                }
            }
/*            do{
                if(x%10==3){
                    printf(" %d",i);
                    x=0;
                }else{
                x/=10;
                }
            }while(x); 19行目の処理でx=0になったとき偽となり処理から抜ける*/
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2112
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner(os.Stdin)
	ans := 0
	mx := 0
	for i := 0; i < 5; i++ {
		a := sc.NextInt()
		if a%10 != 0 {
			ans += a - a%10 + 10
			mx = max(mx, 10-a%10)
		} else {
			ans += a
		}
	}
	fmt.Println(ans - mx)
}

func vmin(v []int) int {
	mn := math.MaxInt32
	for i := 0; i < len(v); i++ {
		mn = min(mn, v[i])
	}
	return mn
}

func lcm(x, y int) int {
	x, y = max(x, y), min(x, y)
	if y == 0 {
		return x
	}
	return lcm(y, x%y)
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// scanner
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner(r io.Reader) *Scanner {
	rdr := bufio.NewReaderSize(r, 1024)
	return &Scanner{r: rdr}
}

func (s *Scanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		line, isp, err := s.r.ReadLine()
		if err != nil {
			os.Exit(1)
		}
		s.buf = append(s.buf, line...)
		if !isp {
			break
		}
	}
}

func (s *Scanner) NextInt() int {
	i, err := strconv.Atoi(s.Next())
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextFloat64() float64 {
	i, err := strconv.ParseFloat(s.Next(), 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	next := string(s.buf[start:s.p])
	s.p++
	return next
}

func (s *Scanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}


Measured memory_bytes: 640
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

K = list(map(int,input())); n = len(K)
D = int(input())
dp = [[[0]*D for i in range(2)] for j in range(n+1)]
dp[0][0][0] = 1
for i in range(n):
  for p in range(D):
    dp[i+1][0][p] = dp[i][0][(p-K[i])%D] % mod
    tmp = 0
    for l in range(K[i]):
      tmp += dp[i][0][(p-l)%D]
    for l in range(10):
      tmp += dp[i][1][(p-l)%D]
    dp[i+1][1][p] = tmp % mod
print((dp[n][0][0] + dp[n][1][0] -1) % mod)
# for di in dp:
#   print(*di)

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

int main(void) {
  int ss, h, m, s;
  cin >> ss;
  h = ss / 3600;
  m = (ss % 3600) / 60;
  s = (ss % 3600) % 60;
  cout << h << ":" << m << ":" << s << endl;
}



Measured memory_bytes: 3100
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

n=int(input())
a=list(map(int,input().split()))
lm=a[0]
for i in range(1,n):
    lm=lcm(lm,a[i])
lm-=1
res=0
for i in a:
    res+=lm%i
print(res)


Measured memory_bytes: 3316
n = int(input())
list = list(range(9, 1, -1))
ans = 0

if n > 1:
    while n > 1:
        flag = 1
        for i in list:
            if n % i == 0:
                n = n / i
                ans += 1
                flag = 0
                break

        if flag == 1:
            ans = 0
            break
elif n == 1:
    ans = 2

if 0 < ans <= 2:
    print("Yes")
else:
    print("No")


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

int main(){
  int n,m;
  cin >> n >> m;
  if (n == m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int dp[100010];

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

    vector<int> h;
    inputVector(h, N);

    REP(i, 1, N - 1) {
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        if (i > 1) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << dp[N - 1] << endl;

    return 0;
}



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

int main()
{
    int n;
    cin >> n;
    int b[102];
    for(int i = 0; i < n - 1; i++) cin >> b[i];
    int ans = b[0] + b[n - 2];
    for(int i = 1; i < n - 1; i++) ans += min(b[i - 1], b[i]);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
int prev[200001] = { 0 }, next[200001] = { 0 };
int main() {
	int  r=0, masatoy, ruio, hideo, m=0, p=0;
	scanf("%d %d %d", &masatoy, &ruio, &hideo);
	for (int i = 0; i < masatoy; i++) {
		prev[i] = (i - 1 + masatoy) % masatoy;
		next[i] = (i + 1) % masatoy;
	}
	for (int i = 0; i < ruio; i++) {
		scanf("%d", &m);
		for (int j = 0; j < m; j++) {
			p = m % 2 == 0 ? next[p] : prev[p];

		}
		r = p;
		prev[next[p]] = prev[p];
		next[prev[p]] = next[p];
		p = next[p];
		prev[r] = -1;
		next[r] = -1;
	}

	for (int i = 0; i < hideo; i++) {
		scanf("%d", &m);
		if (prev[m] == -1) {
			printf("0\n");

		}
		else {
			printf("1\n");
		}
	}
	return 0;
}

Measured memory_bytes: 4696
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define INF 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;
typedef pair<int, int> P;

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

	rep(i,s.size()-1){
		if(s[i] == s[i+1]){
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX
typedef pair<long long, long long> P;
int main(){
    string s,t;
    cin>>s>>t;
    
    long long ans=0;
    vector<char>d(30);
    rep(i,30){
        d[i]='0';
    }
    rep(i,s.size()){
        int sz= (int) s[i]-'a';
        if(d[sz]=='0' ||d[sz]==t[i]){
            d[sz]=t[i];
        }
        else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    rep(i,30){
        d[i]='0';
    }
    rep(i,s.size()){
        int sz= (int) t[i]-'a';
        if(d[sz]=='0' ||d[sz]==s[i]){
            d[sz]=s[i];
        }
        else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

using namespace std;
using ll=long long;
const ll mod = 1e9 + 7;

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

int main() {
    ll N;
    cin>>N;
    vector<ll> a(N),b(N);
    for (int i = 0; i < N; ++i) {
        cin>>a[i];
    }
    for (int i = 0; i < N; ++i) {
        cin>>b[i];
    }
    ll cnt=0;
    for (int i = 0; i < N; ++i) {
        if(a[i]>=b[i]){
            cnt-=a[i]-b[i];
        }else{
            cnt+=(b[i]-a[i])/2;
        }

    }
    if(cnt>=0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



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

int main() {
    string s;
    cin >> s;
    int len = s.length();
    if (s[len-1]=='s') {
        cout << s + "es" <<endl;
    } else {
        cout << s + "s" <<endl;
    }
}

Measured memory_bytes: 3132