akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  int k;
  cin>>k;
  int n=s.size();
  int as=min(k,5);
  vector<string>a;
  rep(i,n){
    string e="";
    rep2(j,i,n){
      e+=s.at(j);
      if(as>0){
        bool ch=true;
        rep(l,a.size()){
          if(a.at(l)==e){
            ch=false;
          }
        }
        if(ch){ 
          a.push_back(e);
          as--;
        }
      }
      else{
        sort(a.begin(),a.end());
        if(a.at(a.size()-1)>e){
          bool ch=true;
          rep(l,a.size()){
            if(a.at(l)==e){
              ch=false;
            }
          }
          if(ch){ 
            a.at(a.size()-1)=e;
          }
        }
        else{
          break;
        }
      }
    }
  }
  sort(a.begin(),a.end());
  cout<<a.at(k-1)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

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

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt" , "r" , stdin);
// 	freopen("output.txt" , "w" , stdout);
// #endif

	int n, k;
	cin >> n >> k;
	int a[n + 1];
	map<int, int>m;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	int mx = a[n], b[n + 1];
	b[n] = a[n];
	for (int i = n - 1; i >= 1; i--)
	{
		if (mx >= a[i])
			b[i] = mx;
		else
		{
			b[i] = a[i];
			mx = a[i];
		}
	}
	for (int i = 1; i <= n; i++)
	{
		if (b[i] - a[i] > 0)
			m[b[i] - a[i]]++;
	}
	mx = 0;
	for (auto i : m)
		mx = i.second;
	cout << mx << endl;




}


Measured memory_bytes: 5760
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n,x,t = i2()
if n/x == n//x:
	print( (n//x*t ) )
else:
	print( (n//x+1)*t )

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<tuple<string,int,int>> vec(N);
  for(int i=0;i<N;i++){
    cin>>get<0>(vec.at(i))>>get<1>(vec.at(i));
    get<1>(vec.at(i))=100-get<1>(vec.at(i));
    get<2>(vec.at(i))=i+1;
  }
  sort(vec.begin(),vec.end());
  for(int i=0;i<N;i++){
    cout <<get<2>(vec.at(i))<<endl;
  }
}

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

int main(void){

  int W, H, x, y, r;

  scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);

  if((r <= x && x <= (W - r)) && (r <= y && y <= (H - r))){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
    
  return 0;
}


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

const int N=100010,mo=int(1e9+7);
struct edge{int s,t,n;}e[N];
int n,a[N],h[N],d[N],vis[N],inc[N],len[N],cnt[N],fac[N],ifac[N],ans;
vector <int> V;

int qpow(int a,int b)
{
	int x=a;  a=1;
	while (b)
		{
			if (b&1)  a=1LL*a*x%mo;
			x=1LL*x*x%mo,b>>=1;
		}
	return a;
}

int C(int n,int m){return 1LL*fac[n]*ifac[m]%mo*ifac[n-m]%mo;}

int go(int x)
{
	if (vis[x])  return x;
	vis[x]=1;
	int _=go(a[x]);
	if (_)  inc[x]=1,V.push_back(x);
	return _==x?0:_;
}

int dfs(int x,int f)
{
	int _=0;
	vis[x]=1;
	for (int i=h[x],y; y=e[i].t,i; i=e[i].n)
		if ((y!=f)&&(!inc[y]))
			{
				if (_)  return -1<<30;
				else  _=dfs(y,x)+1;
			}
	return _;
}

void work()
{
	scanf("%d",&n),ans=1;
	for (int i=1; i<=n; i++)
		scanf("%d",&a[i]),e[i]=(edge){a[i],i,h[a[i]]},h[a[i]]=i,d[a[i]]++;
	for (int i=1,s; i<=n; i++)
		if (!vis[i])
			{
				V.clear(),go(i);
				for (int i=0; i<V.size(); i++)
					if ((len[i+1]=dfs(V[i],0))<0)
						puts("0"),exit(0);
				s=0;
				for (int i=1; i<=V.size(); i++)
					if (!len[i])  s++;  else  break;
				if (s==V.size())  {cnt[s]++;  continue;}
				for (int i=V.size(); i; i--)
					{
						s++;
						if (len[i])
							{
								if (s<len[i])  puts("0"),exit(0);
								if (s>len[i])  ans=2*ans%mo;
								s=0;
							}
					}
			}
	fac[0]=1;
	for (int i=1; i<=n; i++)  fac[i]=1LL*fac[i-1]*i%mo;
	ifac[n]=qpow(fac[n],mo-2);
	for (int i=n; i; i--)  ifac[i-1]=1LL*ifac[i]*i%mo;
	for (int i=1,s; i<=n; i++)
		if (cnt[i])
			{
				s=0;
				for (int j=0,_; j<=cnt[i]/2; j++)
					{
						_=1LL*C(cnt[i],2*j)*fac[2*j]%mo*ifac[j]%mo*qpow(2,mo-1-j)%mo*qpow(i,j)%mo;
						if ((i&1)&&(i>1))  _=1LL*_*qpow(2,cnt[i]-2*j)%mo;
						s=(s+_)%mo;
					}
				ans=1LL*ans*s%mo;
			}
	printf("%d",ans);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 8184
#include<iostream>
#include<vector>
using namespace std;
int ans[1005][1005];
int main(){
	int H,W,A,B;
	scanf("%d%d%d%d",&H,&W,&A,&B);
	for(int i=0;i<B;i++){
		for(int j=0;j<A;j++)
			printf("1");
		for(int j=A;j<W;j++)
			printf("0");
		printf("\n");
	}
	for(int i=B;i<H;i++){
		for(int j=0;j<A;j++)
			printf("0");
		for(int j=A;j<W;j++)
			printf("1");
		printf("\n");
	}
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    ll N;
    cin >> N;
    vector<ll> a(N);
    for (int i=0; i<N; ++i) cin >> a[i];

    ll sum = 0;
    for (int i=0; i<N; ++i) sum += a[i];
    vector<ll> dif(N);
    for (int i=0; i<N; ++i) dif[i] = a[(i+1)%N] - a[i];
    if (sum % (N * (N + 1) / 2) != 0) {
        cout << "NO" << '\n';
        return;
    }
    ll ope = sum / (N * (N + 1) / 2);
    for (int i=0; i<N; ++i) {
        if (dif[i] - ope > 0 || (dif[i] - ope) % N != 0) {
            cout << "NO" << '\n';
            return;
        }
    }
    cout << "YES" << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 4792
n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n-i+1):
        z = n - i - j
        if 10000 * i + 5000 * j + 1000 * z == y:
            print(i, j, z)
            exit()

print('-1 -1 -1')


Measured memory_bytes: 2940
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;
use std::cmp::Ordering;
use std::collections::HashMap;

#[fastout]
fn main() {
  input! {
    n: usize,
    mut vals: [isize;n]
  }
  vals.sort();
  let max = vals.pop().unwrap();
  let mut half = max / 2;
  if max % 2 == 1 {
    half += 1;
  }
  let mut vals = vals
          .into_iter()
          .map(|v| {
             (
               v, 
               (half - v).abs()
             )
           })
          .collect::<Vec<(isize, isize)>>();
  vals.sort_by(|a,b| a.1.cmp(&b.1));
  println!("{} {}", max, vals.first().unwrap().0);
}

Measured memory_bytes: 5308
//#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int num[15];
int p[15];
int main()
{
	//N个开关，M个灯泡
	//1号灯泡 以下开关相连   
	//2号灯泡 以下开关相连
	//。。。。。。。。。。
	//M号灯泡 以下开关相连
	//1号开的数量 2号开的数量 3号开的数量 。。。。。。 M号开的数量 
	//数据范围 n 10 m 10 
	//状态压缩试一次 
	int T,n,m,i,j,len,a;
	//cin>>T;
	//while(T--)
	{
		int sum=0;
		cin>>n>>m;
		for(i=1;i<=m;i++)
		{
			cin>>len;
			while(len--)
			{
				cin>>a;
				num[i]+=(1<<(a-1)); 
			}
		}
		for(i=1;i<=m;i++)
		{
			cin>>p[i];
		}
		int qwe=1<<n;
		for(i=0;i<qwe;i++)
		{
			int flag=1;
			for(j=1;j<=m;j++)
			{
				int asd=i&num[j];//取
				int num1=0;
				while(asd)
				{
					num1+=(asd&1);
					asd>>=1;
				} 
				if(num1%2!=p[j])
				{
					flag=0;
					break;	
				}
			} 
			if(flag)
			sum++;
		}
		cout<<sum<<"\n";
	}
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>
#include <iomanip>

using namespace std;

int main() {
	int r, d, x;
	cin >> r >> d >> x;
	for (size_t i = 0; i < 10; i++)
	{
		x = r * x - d;
		cout << x << endl;
	}
	
}


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

int main(){
  long long N;
  cin>>N;
  int flag;
  /*if(N==702){
    cout<<"zz"<<endl;
    return 0;
  }*/

  vector<char>ans;
  while(N>0){
    flag=1;
    for(int i=0;i<26;i++){
      if(N%26==0){
        ans.push_back('z');
        N=N/26;
        N--;
        flag=0;
        break;
      }
      if(N%26==i) ans.push_back('a'-1+i);
    }
    if(flag){
    N=N/26;
    }
  }
  for(int i=ans.size()-1;i>=0;i--){
    cout<<ans[i];
  }
  cout<<endl;
    
  return 0;
}


Measured memory_bytes: 3628
import java.util.*;

class Main{

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

		String S =sc.next();
		String ans = "AC";
		int cnt = 0;

		if(S.charAt(0) != 'A') ans = "WA";

		for(int i = 1; i < S.length(); i++){
			if(S.charAt(i) < 'a'){
				if(i == 1 || i == S.length() -1){
					ans = "WA";
				} else if(S.charAt(i) == 'C'){
				}
				cnt++;
			}
		}
		if(cnt != 1) ans = "WA";
		
		
			System.out.println(ans);

	}

}

Measured memory_bytes: 21844
#include<stdio.h>
int main(void)
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b&&b<c)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<iostream>
#define pb push_back
#define fi first
#define se second
#define sz(x)  x.size()
#define cl(x)  x.clear()
#define all(x)  x.begin() , x.end()
#define r(x)  scanf("%d", &x)
#define rr(x , y)  scanf("%d%d" , &x , &y)
#define rst(s)  scanf("%s" , s)
#define rl(x)  scanf("%lld" , &x)
#define rrl(x , y)  scanf("%lld%lld" , &x , &y)
#define w(x)  printf("%d" , x)
#define ww(x , y)  printf("%d %d" , x , y)
#define wl(x)  printf("%lld" , x)
#define wwl(x , y)  printf("%lld %lld" , x , y)
#define sp()  printf(" ")
#define en()  puts("")
#define rep(i , x , n)  for(int i = x ; i <= n ; i ++)
#define per(i , n , x)  for(int i = n ; i >= x ; i --)
#define mem0(x)  memset(x , 0 , sizeof(x))
#define mem_1(x)  memset(x , -1 , sizeof(x))
#define mem_inf(x)  memset(x , inf , sizeof(x))
#define mem__inf(x)  memset(x , -inf , sizeof(x))
#define p_queue priority_queue
#define debug(x)  cout << '*' << x << '\n'
#define ddebug(x , y)  cout << '*' << x << ' ' << y << '\n'
#define ios std::ios::sync_with_stdio(false) , cin.tie(0)
using namespace std ;
//mt19937  rnd(chrono::high_resolution_clock::now().time_since_epoch().count()) ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair<int , int> pii ;
typedef pair<ll , ll> pll ;
typedef pair<int , ll> pil ;
typedef pair<ll , int> pli ;
typedef pair<double , double> pdd ;
const int inf = 0x3f3f3f3f ;
const ll mod = 1e9 + 7 ;
const int maxn = 4e4 + 5 ;
const int maxm = 30 ;
const double eps = 1e-6 ;
const double pi = acos(-1.0) ;
int n , k ;
bool vis[105] ;
int main()
{
	mem0(vis) ;
	rr(n , k) ;
	while(k --)
	{
		int d ;
		r(d) ;
		rep(i , 1 , d)
		{
			int x ;
			r(x) ;
			vis[x] = 1 ;
		}
	}
	int ans = 0 ;
	rep(i , 1 , n)  if(!vis[i])  ans ++ ;
	w(ans) , en() ;
	return 0 ;
}

Measured memory_bytes: 3828
using System;
using System.Collections.Generic;
using System.Linq;

//解説コードを理解してC#で解いたもの
class Progaram
{
    static readonly int NMAX = 8;
    static int N;
    static int M;
    static bool[,] graph = new bool[NMAX, NMAX];

    static int Dfs(int v, bool[] visited)
    {
        var allv = true;
        for (var i = 0; N > i; i++) if (visited[i] == false) allv = false;
        if (allv) return 1;

        var ret = 0;

        for (var i = 0; N > i; i++)
        {
            if (graph[v, i] == false) continue;
            if (visited[i]) continue;
            visited[i] = true;
            ret += Dfs(i, visited);
            visited[i] = false;
        }
        return ret;
    }

    static void Main(string[] args)
    {
        var line = Console.ReadLine().Split(' ')
            .Select(x => int.Parse(x)).ToArray();
        N = line[0]; M = line[1];
        
        for (var i = 0; M > i; i++)
        {
            var l = Console.ReadLine().Split(' ')
                .Select(x => int.Parse(x)).ToArray();
            graph[l[0] - 1, l[1] - 1] = true;
            graph[l[1] - 1, l[0] - 1] = true;
        }
        var visited = new bool[NMAX];
        for (var i = 0; N > i; i++) visited[i] = false;
        visited[0] = true;

        Console.WriteLine(Dfs(0, visited));
    }
}


Measured memory_bytes: 13396
use std::io;
use std::io::{BufRead, Write};

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let (a, b): (usize, usize) = {
        let mut split = buf.split_whitespace();
        (
            split.next().unwrap().parse().unwrap(),
            split.next().unwrap().parse().unwrap(),
        )
    };
    writeln!(output, "{}", if b < a { a - 1 } else { a }).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "5 5
", "5\n",
        );
    }

    #[test]
    fn case2() {
        test(
            "2 1
", "1\n",
        );
    }

    #[test]
    fn case3() {
        test(
            "11 30
", "11\n",
        );
    }
}


Measured memory_bytes: 4352
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
#define TSUKASA_DIARY_S_TEMPLATE
// define
#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) int((a).size())
#define cauto const auto
// typedef
typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;
template< typename T > using Vec = vector< T >;
template< typename T > using Matrix = Vec< Vec< T > >;
template< typename T > using USet = unordered_set< T >;
template< typename T, class C > using MyUSet = unordered_set< T, C >;
template< typename T, typename F > using UMap = unordered_map< T, F >;
template< typename T, typename F, class C > using MyUMap = unordered_map< T, F, C >;
// hash
class PiiHash { public: size_t operator () (const pii& p) const { return (p.first << 16) | p.second; } };
// popcount
inline int POPCNT(int x) { return __builtin_popcount(x); }
inline int POPCNT(lint x) { return __builtin_popcount(x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
const Double EPS = 1e-9;
const Double PI = acos(-1);
// inrange
template< typename T >
inline bool in_range(T v, T mi, T mx) { return mi <= v && v < mx; }
template< typename T >
inline bool in_range(T x, T y, T W, T H) { return in_range(x,0,W) && in_range(y,0,H); }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
template< typename T > inline void modAdd(T& a, T b, T mod) { a = (a + b) % mod; }
template< typename T > inline void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > inline void maxUpdate(T& a, T b) { a = max(a, b); }
// converter
template< typename F, typename T >
inline void convert(F& from, T& to) {
	stringstream ss;
	ss << from; ss >> to;
}


int N, a[200020], pos[200020];

void solve() {
	for_(i,0,N) pos[a[i]] = i;
	
	lint ans = 0;
	
	set< int > pset;
	pset.insert(-1); pset.insert(N);
	
	for_(x,1,N+1) {
		int p = pos[x];
		auto ub = pset.upper_bound(p);
		auto lb = ub; --lb;
		//cerr << *lb << " " << p << " " << *ub << endl;
		
		lint lft = p - *lb;
		lint rgt = *ub - p;
		
		ans += (lint)x * lft * rgt;
		
		pset.insert(p);
	}
	
	cout << ans << endl;
}

int main() {
	cin >> N;
	for_(i,0,N) cin >> a[i];
	solve();
}

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

int main() {
	int64_t n, h;
	cin >> n >> h;
	int64_t a[n], b[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	sort(b, b + n);
	reverse(b, b + n);
	int64_t a_max_v = *max_element(a, a + n);
	int64_t ans = h;
	for (int64_t i = 0; i <= n; i++) {
		if (0 < i) {
			h -= b[i - 1];
		}
		int64_t num = 0;
		if (0 < h) {
			num = (h + a_max_v - 1) / a_max_v;
		}
		ans = min(ans, i + num);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

void fail() {
    printf("-1\n");
    exit(0);
}

int n, m;
int edge[701][701];
int stat[701];
int dp[701][1600];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	int a, b;
	for (int i = 0; i < m; ++i) {
        cin >> a >> b;
        edge[a][b] = edge[b][a] = 1;
	}
	int cnt[2];
	vector<int> vt;
	for (int i = 1; i <= n; ++i) {
        if (stat[i]) continue;
        cnt[0] = 1;
        cnt[1] = 0;
        stat[i] = 1;
        vector<int> st;
        st.push_back(i);
        while (!st.empty()) {
            int x = st.back();
            st.pop_back();
            for (int j = 1; j <= n; ++j) {
                if (x == j) continue;
                if (edge[x][j]) continue;
                if (stat[j] == stat[x]) fail();
                if (stat[j]) continue;
                ++cnt[2 - stat[x]];
                stat[j] = 3 - stat[x];
                st.push_back(j);
            }
        }
        vt.push_back(cnt[0] - cnt[1]);
	}
	const int z = 800;
	dp[0][z] = 1;
	for (int i = 1; i <= vt.size(); ++i) {
        int x = vt[i - 1];
        for (int j = 0; j < 1600; ++j) {
            if (0 < j + x && j + x < 1600 && dp[i - 1][j + x]) dp[i][j] = 1;
            if (0 < j - x && j - x < 1600 && dp[i - 1][j - x]) dp[i][j] = 1;
        }
	}
	for (int i = z; i < 1600; ++i) {
        if (dp[vt.size()][i]) {
            int x = (n - (i - z)) / 2;
            int ans = x * (x - 1) + (n - x) * (n - x - 1);
            printf("%d\n", ans / 2);
            break;
        }
	}
	
	return 0;
}


Measured memory_bytes: 6528
#include <iostream>

using namespace std;

int n, k;

int main()
{
  cin >> n >> k;
  
  int x = (n-1)*(n-2)/2 - k;
  
  if (x < 0) {
    cout << -1 << endl;
    return 0;
  }
  
  cout << (n-1) + x << endl;
  
  for (int i = 2; i <= n; i++) {
    cout << 1 << " " << i << endl;
  }
  
  for (int i = 2; i <= n-1; i++) {
    for (int j = i+1; j <= n; j++) {
      if (x == 0) {
        return 0;
      }
      cout << i << " " << j << endl;
      x--;
    }
  }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	a := sc.NextInt()
	b := sc.NextInt()
	if a%2 == 0 || b%2 == 0 {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
	return

}

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

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    S,T = LS()
    print(T+S)

main()



Measured memory_bytes: 27120
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int N; cin >> N;
    int sum=0;
    int tmp=N;
    while(tmp>0){
        sum += tmp%10;
        tmp /= 10;
    }
    /*
    for(int i=0;i<9;i++){
        cerr << tmp << " ";
        if(tmp==0) break;
        sum += tmp%10;
        //tmp = tmp - tmp%10;
        tmp = tmp/10;

    }*/
    cerr << "\n" << sum << endl;
    if(N%sum==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define W 300
int main(){
    int i,c=0,d=0,j;
    int a[W],b[W];
    for(i=0;i<W;i++){
        scanf("%d",&a[i]);
        scanf("%d",&b[i]);
        if(a[i]==0||b[i]==0)break;
    }
    i=0;
    j=0;
    while(a[c]!=0||b[d]!=0){
    for ( i = 0; i < a[c]; i++ ){
        for ( j = 0; j < b[d]; j++ ){
            if((i%2!=0&&j%2==0)||(i%2==0&&j%2!=0)){
                printf(".");
            }else{
            printf("#");
            }
        }
        printf("\n");
    }
        printf("\n");
        c++;
        d++;
    }
    
	return 0;
}



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

int main()
{
  int n;
  cin >> n;
  long ans = 1;
  long a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  for (int i = 0; i < n; i++) {
    ans *= a[i];
    if (ans > 1000000000000000000 || ans <= 0){
      ans = -1;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4376
N = int(input())
A = []
for _ in range(N):
	A.append(int(input()))
B = sorted(A, reverse = True)
m1, m2 = B[0], B[1]
for i in range(N):
	if m1 > A[i]:
		print(m1)
	else:
		print(m2)


Measured memory_bytes: 18920
#include <cstdio>
#include <queue> 
using namespace std;
const int MAXV = 1e4 + 7;
struct edge {
	int u, v, w;
	edge(int u, int v, int w) :u(u), v(v), w(w) {}
	bool operator < (const edge& rhs) const {
		return w > rhs.w;
	}
};
int p[MAXV];
priority_queue<edge> q;
int find(int x) {
	return p[x] == x ? x : (p[x] = find(p[x]));
}
int main() {
    int v, e, ans = 0;
    scanf("%d%d", &v, &e);
    for (int i = 0; i < v; i++) {
    	p[i] = i;
	}
	for (int i = 0; i < e; i++) {
		int s, t, w;
		scanf("%d%d%d", &s, &t, &w);
		q.push(edge(s, t, w));
	}
	while (!q.empty()) {
		edge cur = q.top();
		q.pop();
		int p1 = find(cur.u), p2 = find(cur.v);
		if (p1 != p2) {
			p[p2] = p1;
			ans += cur.w;
		}
	}
    printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 4084
n = input()
d = [int(i) for i in input().split()]
if len(d) % 2 == 1:
  ans = 0
else:
  d.sort()
  if d[len(d)//2-1] == d[len(d)//2]:
    ans = 0
  else:
    ans = d[len(d)//2] - d[len(d)//2-1]
    
print(ans)

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

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n;
    cin >> n;
    n=n%10;
    if(n==2 or n==4 or n==5 or n==7 or n==9)
    	cout << "hon";
    else if(n==8 or n==6 or n==1 or n==0)
    	cout << "pon";
    else
    	cout << "bon";
}

Measured memory_bytes: 3652
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll

inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int n=in();int m=in();
	int l=-1,r=INT_MAX;
	int x,y;
	for(int i=0;i<m;i++)
	{
		x=in();y=in();
		l=max(l,x);
		r=min(r,y);
	}
	
	cout<<max(0LL,r-l+1);
	
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main(){
  int i,j,cnt;
  int n;
  cin>>n;
  ll a[n+1],b[n];
  for(i=0;i<n+1;i++)cin>>a[i];
  for(i=0;i<n;i++)cin>>b[i];
  ll sum=0;
  for(i=0;i<n;i++){
    if(a[i]>=b[i])sum+=b[i];
    else if(b[i]-a[i]<=a[i+1]){
      a[i+1]-=(b[i]-a[i]);
      sum+=b[i];
    }else{
      sum+=a[i]+a[i+1];
      a[i+1]=0;
    }
  }
  cout<<sum;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define long long long
#define read cin >>
#define echo cout <<
#define fin << endl
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)

// for debug macro
bool global_debug_flag = true;
#define DEBUG(val) \
  if (global_debug_flag) cout << #val << " = " << val << endl

int yakusuu(int x) {
  int tmp = 0;
  FOR(i, 1, x + 1) {
    if (x % i == 0) {
      tmp++;
    }
  }
  return tmp;
}

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i = i + 2) {
    if (yakusuu(i) == 8) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
d = [int(input()) for i in range(N)]

def hantei(x):
  for j in range(x):
    if d[x] == d[j]:
      return(0)
  return(1)

count = 1
for i in range(1, N):
  count = count + hantei(i)
  
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>
#include <queue>

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

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

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, 0, n)cin >> a[i];
	rep(i, 1, n) {
		a[i] = gcd(a[i - 1], a[i]);
	}
	cout << a[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	vector<pair<int,int>> A(3);
	for (int i = 0; i < 3; i++) {
		cin >> A[i].first;
		A[i].second = A[i].first % 2;
	}

	sort(A.begin(), A.end());

	int ans = 0;
	if (A[0].second != A[1].second || A[1].second != A[2].second) {
		ans++;
		for (int i = 0; i < 3; i++) {
			if (A[i].second == A[(i + 1) % 3].second) {
				A[i].first++, A[(i + 1) % 3].first++;
				break;
			}
		}

	}
	ans += (A[2].first * 2 - A[1].first - A[0].first) / 2;
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
	int i,j,l,t;
	char s[128];
	while(scanf("%s",s) != EOF){
		l = strlen(s);
		i = 0;
		while(i < l){
			if(s[i] != '@'){printf("%c",s[i]);i++;continue;}
			t = s[i+1] - 48;
			for(j = 1;j <= t;j++){
				printf("%c",s[i+2]);
			}
			i+=3;
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}

const int INF = 1e9, MOD = 998244353; /// think
const ll LINF = 1e15;

const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k, q, ans = 0;
    cin >> n >> k >> q;
    vector <int> a(q);
    vector <int> have(n, k);
    for (int i = 0; i < q; i++) {
        cin >> a[i];
        --a[i];
        ++have[a[i]];
        ans++;
    }
    for (int i = 0; i < n; i++) {
        cout << (have[i] - ans > 0 ? "Yes" : "No") << '\n';
    }
}


Measured memory_bytes: 4028
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
	FastIO
	lld a, b;
	cin >> a >> b;
	if ((a+b)%2 == 0){
		cout << ((a+b)/2);
	}
	else
		cout << "IMPOSSIBLE";
	return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
if N%2 == 1:
    for i in range (M):
        print(i + 1,N - i)
elif N%4 == 0:
    if M >= N//4 + 1:
        for i in range(N//4):
            print(i + 1,N - i)
        for j in range(M - N//4):
            print(N//4 + j + 1,N - N//4 - j - 1)
    else:
        for i in range(M):
            print(i + 1,N - i)
else:
    k = (N - 2)//4
    if M >= k + 1:
        for i in range(k):
            print(i + 1,N - i)
        for j in range(M - k):
            print(k + j + 1,N - k - j -1)
    else:
        for i in range(M):
            print(i + 1,N - i)

Measured memory_bytes: 9280
s = int(input())

def f(x):
  if x % 2==0:
    return x//2
  else:
    return 3*x + 1
A = [s]    
flag = True
counter = 0
while flag:
  s = f(s)
  A.append(s)
  B = set(A)
  counter += 1
  if len(B) < len(A):
    flag = False
    print(counter+1)
 

Measured memory_bytes: 3060
// inputに入力データ全体が入る
function Main(str) {

  const splitStr = str.split(' ');

  const A = +splitStr[0];
  const B = +splitStr[1];

  if (A > 8 || B > 8) {
    console.log(':(');
    return;
  }
  
  console.log('Yay!');
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f[200005];
int main()
{
    int n,k;
    cin>>n>>k;
    f[0] = 1;
    for(int i=1; i<=n; i++)
    {
        cin>>f[i];
    }
    for(int i=k+1; i<=n; i++)
    {
        if(f[i]>f[i-k])
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
}

Measured memory_bytes: 5188
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long
#define ld long double
#define zeros(x) x^(x-1)&x
#define pii pair<ll,ll>
#define cd complex<double>
#define dbg(x) cerr<<x<<endl;
#define Nmax 500005
using namespace std;

ll n, ans, x, c, k, nr, v[Nmax];
queue<ll> Q;

int main()
{
    cin >> n >> c >> k;
    for (int i=1;i<=n;i++) cin >> v[i];
    sort(v+1,v+n+1);
    for (int i=1;i<=n;i++){
        x = v[i];
        while (!Q.empty() && x > Q.front() + k){
            ans++;
            nr = c;
            while (nr && !Q.empty()) Q.pop(), nr--;
        }
        Q.push(x);
    }
    ans += (Q.size() + (c-1)) / c;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;


typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, P> P2;


int main(){
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;


    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  string s;cin>>s;
  rep(i,0,s.size()){
    cout<<'x';
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
aa=[[] for i in range(n)]
for x in range(m):
  a,b=input().split()
  d=int(a)-1
  aa[d].append(b)
  
ans_ac=0
ans_wa=0
for y in range(n):
  ans1=0
  ans2=0
  for z in range(len(aa[y])):
    if aa[y][z]=='WA' and ans2==0:
      ans1+=1
    elif aa[y][z]=='AC' and ans2==0:
      ans2+=1
      
  if ans2==1:
    ans_wa+=ans1
    ans_ac+=1
    
print(str(ans_ac)+' '+str(ans_wa))
  
  

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;

void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string n;
    cin >> n;
    int m = sz(n);
    bool all9 = true;
    REP1(i, m - 1) {
        if (n[i] != '9') {
            all9 = false;
            break;
        }
    }
    cout << (int)(n[0] - '0') + 9 * (m - 1) - (all9 ? 0 : 1) << endl;
}

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

signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n, a, b;cin >> n >> a >> b;
	cout << (((b-a-1)&1) ? "Alice" : "Borys") << "\n";
 	return 0;
}
















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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  int n; cin>>n;
  vi a(n+1);
  rep(i,n) cin>>a[i];
  a[n]=0;
  
  vi s(n);
  int t=abs(a[0]);
  for(int i=0; i<n; i++){
    t+=abs(a[i+1]-a[i]);
  }
  
  vi d(n+1);
  for(int i=0; i<n; i++){
    int pre;
    if(i>0)pre=a[i-1];
    else pre=0;
    int now=a[i];
    int nex=a[i+1];
    if(pre<=now&&now<=nex || nex<=now&&now<=pre) d[i]=0;
    else{
      if(pre<=nex){
        if(nex<=now)d[i]=abs(now-nex)*2;
        else if(now<=pre)d[i]=abs(pre-now)*2;
      }else if(nex<pre){
        if(now<=nex)d[i]=abs(nex-now)*2;
        else if(pre<=now)d[i]=abs(now-pre)*2;
      }
    }
  }
  
  rep(i,n){
    cout<<(t-d[i])<<endl;
  }
}


Measured memory_bytes: 2432
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    
    int sum = 0;
    
    for(int i=1;i<K+1;i++) {
      for(int j=1;j<K+1;j++){
        for(int k=1;k<K+1;k++) sum += gcd(i, j, k);
      }
    }
    
    System.out.println(sum);
  }
  public static int gcd(int a, int b) {
    if (a < b) {
        int tmp = a;
        a = b;
        b = tmp;
    }
    int r = -1;
    while (r != 0) {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
  }
  public static int gcd(int a, int b, int c) {
    return gcd(gcd(a, b), c);
  }
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define PER(i,n) for (int i=(N-1);i>=0;--i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    int ans = inf;
    int n = s.size();
    REP(i, n) {
        if (s[i] != s[i + 1]){
            chmin(ans, max(i + 1, n - (i + 1)));
        }
    }

    pl(ans)

    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }    
bool f=1;
for(int i=0;i<n;i++){
if(a[i]%2 == 0 && a[i]%3 != 0 && a[i]%5 != 0)f=0;
}

if(f){
    cout << "APPROVED" <<endl;
    return 0;
}
cout << "DENIED" << endl;
return 0;
}

Measured memory_bytes: 256
import static java.lang.Math.min;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner scanner = new Scanner(System.in);
    	int num = Integer.parseInt(scanner.nextLine());
    	String[] numbersStr = scanner.nextLine().split(" ");
    	int[] numbers = new int[num];

    	int proc = Integer.MAX_VALUE;
		for (int i=0; i<num; i++) {
			numbers[i] = Integer.parseInt(numbersStr[i]);
			if (numbers[i] % 2 != 0) {
				System.out.println(0);
				System.exit(0);
			}
			int m = numbers[i];
			int internal = 0;
			while (m % 2 == 0) {
				internal++;
				m = m >> 1;
			}
			proc = min(proc, internal);
		}
		System.out.println(proc);
    }
}

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

const int N=200100;
typedef long long ll;
ll ans;
int dis1[N],dis2[N],q[N],a[N],n,sz[N],mx[N];
vector<int>g[N];
char s[N];

int bfs(int x,int*dis){
	for(int i=1;i<=n;++i)dis[i]=-1;
	dis[x]=0;q[0]=x;
	int t=-1,w=0;
	while(t<w){
		int u=q[++t];
		for(int i:g[u])if(dis[i]==-1){
			dis[i]=dis[u]+1;q[++w]=i;
		}
	}
	return q[w];
}


void dfs(int x,int fa,int d){
	sz[x]=s[x]-'0';mx[x]=0;
	for(int i:g[x])if(i!=fa){
		dfs(i,x,d+1);sz[x]+=sz[i];mx[x]=max(mx[x],mx[i]+1);
		if(sz[i])ans++;
	}
	int mn=mx[x]+1;if(s[x]=='1')mn=0;
	for(int i:g[x])if(i!=fa&&sz[i])mn=min(mn,mx[i]+1);
	ans+=mx[x]-mn+1;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<n;++i){
		int x,y;cin>>x>>y;
		g[x].push_back(y);g[y].push_back(x);
	}
	cin>>(s+1);
	int p=bfs(1,dis1),q=bfs(p,dis2);bfs(q,dis1);
	int L=dis1[p];
	for(int i=1;i<=n;++i)
		if(dis1[i]+dis2[i]==L)a[dis1[i]]=i;
	if(L&1){
		dfs(a[L/2],a[L/2+1],L/2+1);dfs(a[L/2+1],a[L/2],L/2+1);
		if(sz[a[L/2]]||sz[a[L/2+1]])ans++;
	}else dfs(a[L/2],-1,L/2);
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 25472
/* --- author: dxm --- */
#include<bits/stdc++.h>
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
#define DEBUG

const int maxn=70;
const int mod=1e9+7;
inline void add(int &a,int b){a=a+b>=mod?a+b-mod:a+b;}
ll n;
int dp[maxn][3];

int main(){
#ifndef DEBUG
	freopen("my.in","r",stdin);
	freopen("my.out","w",stdout);
#endif
	cin>>n;
	dp[63][0]=1;
	for(ll i=63;i>=1;i--){
//		cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl; 
		//a[i] = 0, b[i] = 0
		add(dp[i-1][(n>>i-1)&1],dp[i][0]);
		add(dp[i-1][2],(dp[i][1]+dp[i][2])%mod);
		//a[i] = 0, b[i] = 1 or a[i] = 1, b[i] = 0
		if((n>>i-1)&1)add(dp[i-1][0],dp[i][0]);
		add(dp[i-1][2-(((n>>i-1)&1)?0:1)],dp[i][1]);
		add(dp[i-1][2],dp[i][2]);
		//a[i] = 1, b[i] = 1
		add(dp[i-1][(n>>i-1)&1],dp[i][1]);
		add(dp[i-1][2],dp[i][2]); 
	}
	int ans=0;
	rep(i,3)add(ans,dp[0][i]);
	cout<<ans;
	return 0;
}

/*
Input:
-----------------
Output:
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
ll ta[55][55][2555];
ll a[55];
 
signed main(){
	//freopen(".INP","r",stdin);
	//freopen(".OUT","w",stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n, m;
	cin >> n >> m;
	for (ll i = 0; i < n; i++){
		cin >> a[i];
	}
	ta[0][0][0] = 1;
	for (ll i = 0; i < n; i++){
		for (ll j = 0; j < n; j++){
			for (ll k = 0; k < 2501; k++){
				if (ta[i][j][k]){
					ta[i + 1][j + 1][k + a[i]] += ta[i][j][k];
					ta[i + 1][j][k] += ta[i][j][k];
				}
			}
		}
	}
	ll ans = 0;
	for (ll i = 1; i <= n; i++){
		ans += ta[n][i][i * m];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 55552
n,k = map(int,input().split())
a = [-1] + list(map(int,input().split()))
if k < 2*10**5:
    now = 1
    for _ in range(k):
        now = a[now]
    print(now)
    exit()

ispass = [False]*n
now = 1
loop = set()
loop_first = -1
for _ in range(2*n):
    if ispass[now-1] == False:
        ispass[now-1] = True
    else:
        if loop_first == -1:
            loop_first = now
        loop.add(now)
    now = a[now]

k = k - (ispass.count(1) - len(loop))
k = k % len(loop)

now = loop_first
for _ in range(k):
    now = a[now]
print(now)

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

namespace cs_AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var a = input[0];
            var b = input[1];

            if (1 <= a && a <= 9 && 1 <= b && b <= 9) Console.WriteLine(a * b);
            else Console.WriteLine(-1);
        }
    }
}


Measured memory_bytes: 13396
from decimal import Decimal

N,K = map(int,input().split())
A = list(map(int,input().split()))
mod = 10 ** 9 + 7
ans = 0
cnt = 0

def tosa(a,n,d):
    s = Decimal(n / 2) * (2*a+(n-1)*d)
    return int(s)

if N == 1:
    print(ans)
    exit()

for i in range(N-1):
    for j in range(i+1,N):
        if A[i] == A[j]:
            cnt += 1
        if A[i] > A[j]:
            ans += 1

d = N*(N-1)//2
print(tosa(ans,K,d-cnt)%mod)

Measured memory_bytes: 5204
#include <cstdio>
const int N=1000000;
bool p[N];int pN[N];
main(){p[0]=0;p[1]=0;int i,k,n,c;
for(i=2;i<N;i++)p[i]=1;for(i=2;i*i<N;){for(k=2;i*k<N;k++)p[i*k]=0;do{i++;}while(!p[i]);}for(i=0,c=0;i<N;i++){p[i]&&c++;pN[i]=c;}for(;scanf("%d",&n)+1;printf("%d\n",pN[n]));}

Measured memory_bytes: 0