akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Dynamic;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ue = Console.ReadLine().Split(' ').ToArray();
            string[] naka = Console.ReadLine().Split(' ').ToArray();
            string[] sita = Console.ReadLine().Split(' ').ToArray();
            int N = int.Parse(Console.ReadLine());
            bool[] bingo = new bool[9];
            for (int i = 0; i < N; i++)
            {
                string b = Console.ReadLine();
                for(int j = 0; j < 3; j++)
                {
                    if(ue[j] == b)
                    {
                        bingo[j] = true;
                    }
                    if (naka[j] == b)
                    {
                        bingo[j + 3] = true;
                    }
                    if (sita[j] == b)
                    {
                        bingo[j + 6] = true;
                    }
                }
            }
            if (bingo[0] && bingo[1] && bingo[2])
            {
                Console.WriteLine("Yes");
            }
            else if (bingo[3] && bingo[4] && bingo[5])
            {
                Console.WriteLine("Yes");
            }
            else if (bingo[6] && bingo[7] && bingo[8])
            {
                Console.WriteLine("Yes");
            }
            else if (bingo[0] && bingo[3] && bingo[6])
            {
                Console.WriteLine("Yes");
            }
            else if (bingo[1] && bingo[4] && bingo[7])
            {
                Console.WriteLine("Yes");
            }
            else if (bingo[2] && bingo[5] && bingo[8])
            {
                Console.WriteLine("Yes");
            }
            else if (bingo[0] && bingo[4] && bingo[8])
            {
                Console.WriteLine("Yes");
            }
            else if (bingo[2] && bingo[4] && bingo[6])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 27904
N = int(input())

D = [None] * (N + 2)
D[0] = [-1, -2]
D[1] = [-1, -2]
for i in range(2, N+2):
    D[i] = list(map(int, input().split()))

def zorome(a):
    return a[0] == a[1]

message = 'No'
for i in range(2, N+2):
    if (zorome(D[i-2]) and zorome(D[i-1]) and zorome(D[i])):
        message = 'Yes'

print(message)

Measured memory_bytes: 9220
#include <stdio.h>
int main(){
    int N;
    scanf("%d",&N);
    int a = N%10;
    if(a == 0||a == 1 ||a == 6||a == 8){
        printf("pon\n");
    } else if(a == 2 ||a == 4||a == 5||a == 7||a == 9){
        printf("hon\n");
    } else if(a == 3){
        printf("bon\n");
    }
}

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

namespace ABC146B
{
    class Program
    {
        static void Main(string[] args)
        {
            var alphabet = new List<char>();
            alphabet.Add('A');
            alphabet.Add('B');
            alphabet.Add('C');
            alphabet.Add('D');
            alphabet.Add('E');
            alphabet.Add('F');
            alphabet.Add('G');
            alphabet.Add('H');
            alphabet.Add('I');
            alphabet.Add('J');
            alphabet.Add('K');
            alphabet.Add('L');
            alphabet.Add('M');
            alphabet.Add('N');
            alphabet.Add('O');
            alphabet.Add('P');
            alphabet.Add('Q');
            alphabet.Add('R');
            alphabet.Add('S');
            alphabet.Add('T');
            alphabet.Add('U');
            alphabet.Add('V');
            alphabet.Add('W');
            alphabet.Add('X');
            alphabet.Add('Y');
            alphabet.Add('Z');

            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            var newS = new List<char>();
            foreach (var cha in S)
            {
                int pointer = alphabet.FindIndex(a => a== cha);
                if (pointer + N > 25)
                {
                    newS.Add(alphabet[pointer+N-26]);
                }
                else
                {
                    newS.Add(alphabet[pointer+N]);
                }
            }

            foreach (var cha in newS)
            {
                Console.Write(cha);
            }

            Console.WriteLine();
            Console.Read();

        }
    }
}


Measured memory_bytes: 13272
w,h,n=[int(s)for s in input().split(" ")]
route=[[int(s)for s in input().split(" ")]for i in range(n)]
s=0
for i in range(len(route)-1):
    dx=route[i+1][0]-route[i][0]
    dy=route[i+1][1]-route[i][1]
    if dx==0:s+=abs(dy)
    elif dy==0:s+=abs(dx)
    elif dx*dy>0:s+=max((abs(dx),abs(dy)))
    else:s+=abs(dx)+abs(dy)
print(s)

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// dijkstra
struct edge {ll to, cost;};
typedef pair<ll, ll> P; // firstはsからの最短距離, secondは頂点の番号
const ll INF = 1e15;
const int max_n = 1e6;

int n;
vector<edge> g[max_n];
ll d[max_n];

void dijkstra(ll s){
	fill(d, d + n, INF);
	d[s] = 0;

	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,s));

	while(!que.empty()){
		P p = que.top();
		que.pop();

		ll v = p.second;
		if(d[v] < p.first) continue; //後から最短パスが見つかった場合、先にqueに入っているものはここではじかれる

		for(ll i = 0; i < g[v].size(); i++){
			edge e= g[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

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

	cin >> n;

	rep(i,n-1){
		ll a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;

		g[a].push_back((edge){b, c});
		g[b].push_back((edge){a, c});
	}

	int q;
	ll k;

	cin >> q >> k;
	k--;

	dijkstra(k);

	rep(i,q){
		ll x, y;
		cin >> x >> y;
		x--;
		y--;

		cout << (d[x] + d[y]) << endl;
	}	
}

Measured memory_bytes: 33904
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef long double ld;

int MOD=1000000007;


int main(){
    ll N,M,an=0;
    cin >> N >> M;
    ll H[N+10],A[M+10],B[M+10];
    bool ans[N+10];
    for(ll i=1; i<=N; i++) ans[i]=true;
    for(ll i=1; i<=N; i++) cin >> H[i];
    for(ll i=1; i<=M; i++) cin >> A[i] >> B[i];
    for(ll i=1; i<=M; i++){
        if(H[A[i]]==H[B[i]]){ ans[A[i]]=false; ans[B[i]]=false;}
        else if(H[A[i]]<H[B[i]]) ans[A[i]]=false;
        else ans[B[i]]=false;
    }
    for(ll i=1; i<=N; i++){
        if(ans[i]){an++;}
    }
    cout << an << endl;

}



Measured memory_bytes: 6084
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;
int MOD = 1000000007;


signed main(){
    
    string s;
    cin >> s;
    string x = "keyence";
    int n = s.size();
    for(int i = 0;i <= 7;i++){
        int c = 1;
        rep(j,i){
            if(x[j] != s[j])c = 0;
        }
        for(int j = i;j < 7;j++){
            if(x[j] != s[n-7+j])c = 0;
        }
        if(c){
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;


    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 
// rm -r -f test;oj dl http://arc074.contest.atcoder.jp/tasks/arc074_b

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,t1,t2;
char op[7];
inline int type() {
    if (op[0]=='M')
        return 1;
    return 2;
}
inline bool even(int x) {
    return x%2==0;
}
void dfs(int l,int r,int t1) {
    int m=(l+r)>>1;
    if (m==l)
        ++m;
    printf("%d\n",m);
    fflush(stdout);
    scanf("%s",op);
    if (op[0]=='V')
        exit(0);
    int t2=type();
    if ((even(m-l+1)&&t1==t2)||(!even(m-l+1)&&t1!=t2))
        dfs(l,m-1,t1);
    else
        dfs(m,r,t2);
}
int main()
{
    cin>>n;
    int l=0,r=n-1,m=(l+r)>>1;
    printf("%d\n",0);
    fflush(stdout);
    if (op[0]=='V')
        return 0;
    scanf("%s",op);
    t1=type();
    printf("%d\n",m);
    fflush(stdout);
    scanf("%s",op);
    t2=type();
    if (op[0]=='V')
        return 0;
    if ((even(m-l+1)&&t1==t2)||(!even(m-l+1)&&t1!=t2))
        dfs(l,m-1,t1);
    else
        dfs(m,r,t2);
    return 0;
}


Measured memory_bytes: 852
#include <string>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string.h>
#include <utility>
#include <queue>
#include <stack>
#include <iomanip>
#include <ctype.h>
#include <map>
#include <set>
#include <stdio.h>
#include <assert.h>
#include <ctype.h>
#include <sstream>
#include <math.h>
#include <time.h>
#include <iostream>
#include <iomanip>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <tuple>
#include <cmath>
#include <stdio.h>      /* printf, fgets */
#include <stdlib.h>
#include <fstream>
#pragma comment(linker, "/STACK:67108864")

using namespace std;

typedef long long LL;

#define FOR(i,n) for(int i = 0;i < n;i++)
#define MP make_pair
#define PB push_back
#define ALL(a) (a).begin(),(a).end()
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define CLEAR(a) memset(a, 0, sizeof(a))
#define ERASE(a) memset(a, -1, sizeof(a))
#define INF 2000000000
#define y1 uu1
#define y2 uu2
const double EPS = 1E-12;
const double PI = acos(-1.0);
const LL mod = 1000000007;

using namespace std;

int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0);
  int h,a;
  cin >>h>>a;
  int rv= h/a;
  if (h%a)rv++;
  cout <<rv<<endl;
  
  return 0;
}


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

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

int n;

const int MOD = (int)1e9 + 7;
vector<vector<int> > edge;

long long dp[100009][2];


long long funct(int node, int parent, int color) {

    if(dp[node][color] != -1) return dp[node][color];


    long long cur = 1;
    for(auto ch: edge[node]) {
        if(ch == parent) continue;

        if(color == 0) {
            cur *= (funct(ch, node, 1) + funct(ch, node, 0));
        }
        else {
            cur *= funct(ch, node, 0);
        }

        cur %= MOD;
    }
    dp[node][color] = cur;
    return cur;
}


int main() {
    int n; cin >> n;
    edge.resize(n+1, vector<int>(0));

    for(int i = 0; i < n-1; ++i) {
        int u, v; cin >> u >> v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }

    for(int i = 0; i <= n; ++i) {
        dp[i][0] = dp[i][1] = -1;
    }

    funct(1, -1, 0);
    funct(1, -1, 1);
    cout << (dp[1][0]+ dp[1][1])%MOD;

}

Measured memory_bytes: 15616
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue> 
#include<string>
using namespace std;
typedef long long LL;
LL a[51],b[51];
int main(){
	string s;
	LL n,m;
	cin>>n>>m;
	a[0] = 1;
	b[0] = 1;
	for(int i=1;i<=n;i++){
		a[i] = a[i-1]*2+1+2;
		b[i] = b[i-1]*2+1;
	}
	int zd;
	int i = n;
	LL sum = 0;
	int f = 0;
	while(m>0){
		if(m>=a[i]){
			m-=a[i];
			sum+=b[i];
			if(m>=1){
				sum++;
				m--;
			}
		}
		else{
			i--;
			m--;
		}
	}
	cout<<sum<<endl;
	return 0;
} 

Measured memory_bytes: 256
use std::cmp::min;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let s: String = read(&mut stdin_lock, &mut buf, b'\n');
    let cv: Vec<char> = s.chars().collect();

    let mut wv = vec![0i32; n];
    wv[0] = if cv[0] == 'W' { 1 } else { 0 };
    for i in 1..n {
        wv[i] = wv[i - 1] + if cv[i] == 'W' { 1 } else { 0 };
    }

    let mut ans = n as i32;
    for i in 0..n {
        // W -> E | E -> W
        let ec = if i == 0 { 0 } else { wv[i - 1] };
        let wc = (n - i) as i32 - 1 - (wv[n - 1] - wv[i]);
        let x = ec + wc;
        ans = min(ans, x);
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
#define ll long long int
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define pb(v, a) v.push_back(a)
#define Sort(v) sort(v.begin(), v.end())
#define For(m) for (auto it = m.begin(); it != m.end(); it++)
#define mod 1000000007
using namespace std;

 ll dp[3005][3005][2];
 bool dp1[3005][3005][2];
 ll arr[3005];

 ll fun(ll l,ll r,ll k)
 {
     if(dp1[l][r][k])
     return dp[l][r][k];
     if(l==r)
     {
         if(k==0)
         {
             dp[l][r][0]=arr[l];
         }
         else
         {
             dp[l][r][1]=-arr[l];
         }
     }
     else
     {
           if(k==0)
         {
             dp[l][r][0]=max(fun(l+1,r,1)+arr[l],fun(l,r-1,1)+arr[r]);
         }
         else
         {
             dp[l][r][1]=min(fun(l+1,r,0)-arr[l],fun(l,r-1,0)-arr[r]);
         }
     }
     dp1[l][r][k]=true;
     return dp[l][r][k];
 }



int main()
{
  ll n;
  cin >> n;
  
  fr(i,0,n)cin >> arr[i];
  fr(i,0,3005)
  {
      fr(j,0,3005)
      {
          fr(k,0,2)
          dp1[i][j][k]=false;
      }
  }

  cout << fun(0,n-1,0);
  

  return 0;
}


Measured memory_bytes: 158208
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
#define REP(i,n) for(int i=0;i<n;i++)

int N;


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

    cin >> N ;
    int target =  N%28;
    int ans = 1;
    bool flag = false;
    for (int i =0 ; i <7; ++i){
        ans = (target - i * 4);
        if(ans < 0){
            break;
        }
        ans %= 7;
        if(ans == 0 ){
            flag = true;
            break;

        }
    }
    if(flag){
        cout << "Yes"<<endl;
    }else{
        cout << "No"<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int deg[10];

int main()
{
	int x,y;
	while (scanf("%d%d",&x,&y)==2) {
		deg[x]++;
		deg[y]++;
	}
	int add=0;
	for (int i=1;i<=4;i++)
		if (deg[i]%2) add++;
	if (add==2) puts("YES"); else puts("NO");	
	return 0;
}

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

int main() {
  int n,k,ans = 1e9+5;
  cin >> n >> k;
  vector<int>h(n);
  rep(i,n) cin >> h[i];
  sort(h.begin(),h.end());
  rep(i,n-k+1){
    ans = min(ans,h[i+k-1]-h[i]);
  }
  cout << ans << endl;
}

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


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

    int N;
    cin >> N;

    ll stoolHeight = 0;
    int maxHeight = 0;
    for(int i = 0; i < N; i++)
    {
    	int currentHeight;
    	cin >> currentHeight;

    	if(maxHeight > currentHeight)
    		stoolHeight += maxHeight - currentHeight;

    	maxHeight = max(maxHeight, currentHeight);
    }

    std::cout << stoolHeight << "\n";


	return 0;
}

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

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

    int a[200001];
    int ai, a_num[200001] = {0};
    for(int i=0; i<n; i++) {
        cin >> ai;
        a_num[ai]++;
        a[i] = ai;
    }

    long long convs = 0;
    for(int i=0; i<=n; i++) {
        convs += (long long)(a_num[i]) * (a_num[i] - 1) / 2;
    }

    for(int i=0; i<n; i++) {
        cout << convs - (a_num[a[i]] - 1) << endl;
    }
}

Measured memory_bytes: 4096
s = input()
cnt = 0
if len(s) % 2 == 1:
    half = (len(s)-1)//2
else:
    half = len(s)//2
l1 = list(s[:half])
l2 = list(reversed(s[-half:]))
for i in range(len(l1)):
    if l1[i] != l2[i]:
        cnt += 1
print(cnt)
 

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
    int a, b, d, r;
    double f;
    cin >> a >> b;
    d = a / b;
    r = a % b;
    f = double(a) / double(b);
    cout << d << " " << r << " " << fixed << setprecision(5) << f << endl;
    return 0;
}



Measured memory_bytes: 3272
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

// 文字列s内に文字列tがいくつ含まれるか
int count(string s, string t) {
  int size_s = s.size();
  int size_t = t.size();
  if (size_s < size_t) return 0;
  int ret = 0;
  for (int i = 0; i < size_s - size_t + 1; i++) {
    if (s.substr(i, size_t) == t) ret++;
  }
  return ret;
}

void solve() {
  int n; cin >> n;
  string s; cin >> s;
  int cntr = count(s, "R");
  if (cntr > n - cntr) Yes();
  else No();
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cassert>

using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    
    int h, w;
    cin >> h >> w;
    
    cout << (H - h) * (W - w) << endl;
}


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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans = min(a, b) + min(c, d);
	cout << ans << endl;
	return 0;
}


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

int main() {

  long long int n;
  cin >> n;

  vector< long long int > v;
  long long int s = 0;
  long long int m = 0;

  for ( long long int i = 0; i < n; i++ ) {

    long long int in;
    cin >> in;
    v.push_back( in );
    s += in;
    m += ( i + 1 );

  }

  if ( ( s % m ) != 0 ) {
    cout << "NO" << endl;
    return 0;
  }
  long long int c = s / m;
  long long int k = c;

  for ( long long int i = 0; i < n; i++ ) {

    long long int p = c - ( v[(i+1)%n] - v[i] );
    if ( ( p % n ) != 0 ) {
      cout << "NO" << endl;
      return 0;
    }
    long long int x = p / n;
    if ( x < 0 ) {
      cout << "NO" << endl;
      return 0;
    }
    if ( x > k ) {
      cout << "NO" << endl;
      return 0;
    }
    k -= x;

  }

  if ( k == 0 ) {
      cout << "YES" << endl;
      return 0;
  }else {
      cout << "NO" << endl;
      return 0;
  }

  return 0;

}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n,m,x,value=1000000000;cin >> n >> m >> x;
  long long c[n+10][m+10];
  for (int i=0;i<n;i++) {
    cin >> c[i][0];
	for (int j=0;j<m;j++) cin >> c[i][j+1];
  }
  //cout << c[0][2] << endl;
  for (int i=0;i<(1<<n);i++) {
    long long value2=0;
    vector<long long> vec(m,0);
    for (int j=0;j<n;j++) {
	  if (i & (1<<j)) {
        //cout << "WWO" << j << endl;
        //cout << c[0][0] <<" " << c[0][1] <<" "<< c[0][2] << c[0][3];
	    value2+=c[j][0];
	    for (int j2=0;j2<m;j2++) {vec[j2]+=c[j][j2+1];}
	  }
	}
	long long r=1;
    //cout << i << " " <<vec[0] << vec[1] << vec[2] << endl;
	for (int j3=0;j3<m;j3++) if (vec[j3]<x) r=0;
    if (r) value=min(value,value2);
  }
  if (1000000000-value) cout << value << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
#define EN cout<<endl;
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
const ll mod=1000000007;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yes(T b){if(b)out("yes");else out("no");}
template<class T> void Yes(T b){if(b)out("Yes");else out("No");}
template<class T> void YES(T b){if(b)out("YES");else out("NO");}
template<class T> void no(T b){if(b)out("no");else out("yes");}
template<class T> void No(T b){if(b)out("No");else out("Yes");}
template<class T> void NO(T b){if(b)out("NO");else out("YES");}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}
 


int main(){
    ll n;
    cin>>n;
    string s="";
    
    int a[101010]={};
    ll ans=0;;
    rep(i,n){
        ll x;
        cin>>x;
        a[x]++;
        ans+=x;
    }
    ll z;
    cin>>z;
    rep(i,z){
        ll b,c;
        cin>>b>>c;
        ans+=(c-b)*a[b];
        a[c]+=a[b];
        a[b]=0;
        cout<<ans<<endl;
    }

    
}


Measured memory_bytes: 4000
#include <iostream>
#include <algorithm>

int main() {
    int K, N;
    int l[50];

    std::cin >> N >> K;
    for (int i = 0; i < N; i++) {
        std::cin >> l[i];
    }

    std::sort(l, l + N);

    int sum = 0;
    for (int i = 0; i < K; i++) {
        sum += l[N - i - 1];
    }

    std::cout << sum << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define sz size()
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)

#define ll long long

int main() {

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

    // freopen("input.in","r",stdin);

    string s;
    cin>>s;

    int i;
    int n = s.size();
    long long br = 0ll;
    for (i=0;i<n;i++) {
        br+=(int)s[i]-48;
    }
    if (br%9 == 0)
        cout<<"Yes\n";
    else
        cout<<"No\n";

    return 0;
}

Measured memory_bytes: 3740
#include<iostream>
#include<math.h> 
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#define max(a,b) (a>b ? a : b)
#define min(a,b) (a<b ? a : b)
using namespace std;
typedef long long int lli;
lli mod=1000000007;
vector < lli> primes;

void Sieve(lli n) 
{ 
    bool prime[n+1];
	for(lli i=0;i<n+1;++i)
		prime[i]=true;
    for (lli p=2;p*p<=n;++p) 
    {
        if (prime[p] == true) 
        {  
            for (lli i=2*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    }  
    for(lli p=2; p<=n; p++) 
       if (prime[p]) 
		primes.push_back(p);  
}
lli gcd(lli a,lli b)  
 {
    if(b>a)
        swap(a,b);
    if (a%b==0)  
        return b;  
    else 
        return gcd(a%b,b);  
 }
lli lcm(lli a,lli b)
{
    return (a*b)/gcd(a,b);    
}
lli power(lli x,lli y,lli m)   
{ 
    lli res = 1; 
    x=x%m;   
    while (y > 0) 
    {  
        if (y%2==1) 
            res =(res*x)%m;  
        y=y/2; 
        x=(x*x)%m; 
    } 
    return res; 
}
bool sortcol( const vector<lli>& v1, const vector<lli>& v2 ) 
{ 
	return v1[0] < v2[0]; 
}
int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	lli n;
	cin>>n;
	lli arr[n];
	lli last;
	for(lli i=0;i<n;++i)
	{
		cin>>arr[i];
		if(i==0)
		{
			arr[i]--;
		}
		else if(arr[i]>last)
		{
			arr[i]--;
		}
		last=arr[i];
	}
	
	for(lli i=0;i<n-1;++i)
	{
		if(arr[i]>arr[i+1])
		{
			cout<<"No"<<endl;
			exit(0);
		}
	}
	cout<<"Yes"<<endl;
	
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

int main() {
	makei(N);
	makei(D);
	makei(ans);
	rep(N) {
		int a;
		cin >> a;
		int x = 1;
		while (x <= D) {
			++ans;
			x += a;
		}
	}
	say(ans);
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

mod = 10**9+7


W,a,b = map(int,input().split())

ans = min(abs(b-a-W),abs(b+W-a))
if a <= b and b-a <= W or b<=a and a-b <=W:
    ans = 0

print(ans)


Measured memory_bytes: 6416
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
using namespace std;

int main (void){
    int s, w;
    cin >> s >> w;
    if (s <= w) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
#define openfiles ifstream in("input.txt");ofstream out("output.txt");
#define int ll
typedef long long ll;
typedef long double ld;
const int inf=1e9;
typedef vector<int> vi;
openfiles;
///-------------------------------------------------------------------------------------------------
int n,k;
vector<int> vec;
void init()
{
    cin>>n>>k;
    vec.resize(n);
    for(int i=0;i<n;i++)
        cin>>vec[i];
}

void solve()
{
    vector<int> ans(50);
    vector<int> k2(50);
    int t=k;
    int j=0;
    while(t)
    {
        k2[j++]=t%2ll;
        t/=2ll;
    }
    int summ=0;
    for(int i=0;i<n;i++)
        summ+=vec[i];
    for(int i=0;i<50;i++)
    {
        int cnt1s=0;
        for(int j=0;j<n;j++)
        {
            if((vec[j]>>i)&1ll)
                cnt1s++;
        }
        int cnt0s=n-cnt1s;
        if(cnt0s>cnt1s)
            ans[i]=(cnt0s-cnt1s)*(1ll<<i);
    }
    int maxans=0;
    int pref=0;
    for(int i=49;i>=0;i--)
    {
        int bit=k2[i];
        if(bit)
        {

            int currans=0;
            for(int j=0;j<i;j++)
            {
                currans+=ans[j];
            }
            currans+=pref;
            maxans=max(maxans,currans);
            pref+=ans[i];
        }
    }
    cout<<max(pref,maxans)+summ;
}

signed main()
{
    init();
    solve();
    return 0;
}


















Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
typedef long long ll;
typedef pair<ll,ll> P;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

int main(){
    int n;
    int a[100];
    int count=0;
    cin>>n;
    rep(i,n)cin>>a[i];
        
    rep(i,n){
        if((i+1)%2!=0){
            if(a[i]%2!=0)count++;
        }
    }
    cout<<count;
}


Measured memory_bytes: 3576
def sum_dig(num):
    sum = 0
    while(num):
        dig = num % 10
        sum = sum + dig
        num = num // 10
#        print (dig,sum,num)
    return sum


lim, min, max = map(int, input().split(" "))
chk_sum = 0
for i in range(1,lim+1) :
    chk = sum_dig(i)
#    print(chk,type(chk))
    if (chk >= min and chk <= max) :
        chk_sum += i

print (chk_sum)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll x,n;
  cin >> x >> n;
  set<ll> a;
  for(ll i=0;i<n;i++) {
    ll tmp;
    cin >> tmp;
    a.insert(tmp);
  }
  ll ans=0;
  for(ll i=1;i<=101;i++) {
    if(a.count(i)) continue;
    if(abs(ans-x)>abs(i-x)) ans=i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=5000005;
int n,p[N],q[N],i,j,k,l,head[N],adj[N],nxt[N],flow[N],cap[N],cur[N],d[N],bg,ed,ans,tot,bl1[N],bl2[N];
bool v[N];
void addedge(int u,int v,int w)
{
	adj[++l]=v;
	nxt[l]=head[u];
	head[u]=l;
	cap[l]=w;
	adj[++l]=u;
	nxt[l]=head[v];
	head[v]=l;
	cap[l]=0;
}
void dfs1(int x)
{
	bl1[x]=tot;
	v[x]=true;
	if(!v[p[x]])
		dfs1(p[x]);
}
void dfs2(int x)
{
	bl2[x]=tot;
	v[x]=true;
	if(!v[q[x]])
		dfs2(q[x]);
}
bool bfs()
{
	int i;
	for(i=1;i<=tot;++i)
		d[i]=100000000;
	q[bg=ed=1]=tot-1;
	d[q[bg]]=0;
	while(bg<=ed)
	{
		for(i=head[q[bg]];i;i=nxt[i])
			if(flow[i]<cap[i]&&d[adj[i]]==(100000000))
			{
				d[adj[i]]=d[q[bg]]+1;
				q[++ed]=adj[i];
			}
		++bg;
	}
	return d[tot]!=(100000000);
}
int dfs(int x,int a)
{
	if(x==tot||a<=0)
		return a;
	int g,h=0;
	for(;cur[x];cur[x]=nxt[cur[x]])
		if(d[adj[cur[x]]]==d[x]+1&&(g=dfs(adj[cur[x]],min(a,cap[cur[x]]-flow[cur[x]])))>0)
		{
			flow[cur[x]]+=g;
			flow[cur[x]&1?cur[x]+1:cur[x]-1]-=g;
			a-=g;
			h+=g;
			if(a<=0)
				break;
		}
	return h;
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i)
	{
		scanf("%d",p+i);
		++p[i];
	}
	for(i=1;i<=n;++i)
	{
		scanf("%d",q+i);
		++q[i];
	}
	for(i=1;i<=n;++i)
		if(!v[i])
		{
			++tot;
			dfs1(i);
		}
	for(i=1;i<=n;++i)
		v[i]=false;
	for(i=1;i<=n;++i)
		if(!v[i])
		{
			++tot;
			dfs2(i);
		}
	tot+=2;
	ans=0;
	for(i=1;i<=n;++i)
		if(p[i]==i&&q[i]==i)
			++ans;
		else if(p[i]==i&&q[i]!=i)
			addedge(tot-1,bl2[i],1);
		else if(p[i]!=i&&q[i]==i)
			addedge(bl1[i],tot,1);
		else if(p[i]==q[i])
			addedge(bl1[i],bl2[i],1),addedge(bl2[i],bl1[i],1);
		else
			addedge(bl1[i],bl2[i],1);
	while(bfs())
	{
		for(i=1;i<=tot;++i)
			cur[i]=head[i];
		ans+=dfs(tot-1,100000000);
	}
	printf("%d",n-ans);
	return 0;
}


Measured memory_bytes: 33024
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int mod =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    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;
    }
}
ll 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;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
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;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    int D=in();
    if(D==22){
        cout<<"Christmas Eve Eve Eve"<<endl;
    }else if(D==23){
        cout<<"Christmas Eve Eve"<<endl;
    }else if(D==24){
        cout<<"Christmas Eve"<<endl;
    }else{
        cout<<"Christmas"<<endl;

    }
    return 0;

}


Measured memory_bytes: 256
_, M = map(int, raw_input().split())
lst = []

for i in range(M):
    a, b = map(int, raw_input().split())
    lst.append((b, a))

lst.sort()
pos = 0
ans = 0

for p in lst:
    if p[1] >= pos:
        ans += 1
        pos = p[0]

print ans


Measured memory_bytes: 18436
#include<iostream>
#include<map>
#define maxn 300010
using namespace std;
struct ty{
	int i,j;
}a[maxn];
int H,W,m;
int h[maxn],w[maxn];
int A[maxn],B[maxn];
#define PII pair<int,int>
map<PII,int> s;
pair<int,int> tmp;
bool zw(int i,int j)
{  pair<int,int> x;
   x.first=i;x.second=j;
   if(s[x]==1) return 1;
   return 0;
}
int main ()
{    scanf("%d %d %d",&H,&W,&m);
    int hmax=0,wmax=0;
   for(int i=1;i<=m;i++)
   {   scanf("%d %d",&a[i].i,&a[i].j);
       tmp.first=a[i].i;tmp.second=a[i].j;
       s[tmp]=1;
       h[a[i].i]++; w[a[i].j]++;
       hmax=max(hmax,h[a[i].i]);
       wmax=max(wmax,w[a[i].j]);
   }
   //printf("hmax: %d wmax :%d\n",hmax,wmax);
      int j=1;
      int len1,len2;
   for(int i=1;i<=H;i++)
   {   if(hmax==h[i]) A[j++]=i;
   }
    len1=j-1;
      j=1;
   for(int i=1;i<=W;i++)
   {   if(wmax==w[i]) B[j++]=i;
   }
     len2=j-1;
     for(int i=1;i<=len1;i++)
      for(int j=1;j<=len2;j++)
       {   if(zw(A[i],B[j])==0) 
           {  printf("%d\n",hmax+wmax);
              return 0;
		   }
	   }
	   printf("%d\n",hmax+wmax-1);
}

Measured memory_bytes: 29524
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(C):
    return chr(ord(C) + 1)


def main():
    C = read_str()
    print(slv(C))


if __name__ == '__main__':
    main()


Measured memory_bytes: 62572
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <algorithm>

using namespace std;


int main()
{
  int H, W, N;
  int r, c;
  cin >> H >> W >> N;
  cin >> r >> c;
  string S, T;
  cin >> S;
  cin >> T;

  int x = c;
  int y = r;
  for (int i=0;i<N;i++) {
    if (S[i] == 'R') {
      x++;
    } else if (S[i] == 'D') {
      y++;
    }
    if (x > W || y > H) {
      cout << "NO" << endl;
      return 0;
    }
    if (T[i] == 'L' && x > 1) x--;
    else if(T[i] == 'U' && y > 1) y--;
  }
  x = c;
  y = r;
  for (int i=0;i<N;i++) {
    if (S[i] == 'L') {
      x--;
    } else if (S[i] == 'U') {
      y--;
    }
    if (x == 0 || y == 0) {
      cout << "NO" << endl;
      return 0;
    }
    if (T[i] == 'R' && x < W) x++;
    else if(T[i] == 'D' && y < H) y++;
  }
  cout << "YES" << endl;
  return 0;
}


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

int main() {
	double a,b,C;
	cin >> a >> b >> C;
	cout << fixed << setprecision(5);
	cout << 0.5*a*b*sin(C*M_PI/180) << endl;
	cout << a+b+pow(a*a+b*b-2*a*b*cos(C*M_PI/180),0.5) << endl;
	cout << b*sin(C*M_PI/180) << endl;
	return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define INF 10000000000

ll a, b, c, n, m, x, y, z, w, h, ans = 0, cnt = 0, mx = 0, mn = INF;
string s;

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

    cin >> a >> b >> c >> x;
    if(x % 2){
        cout << b - a << endl;
    }else{
        cout << a - b << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+15+7;
ll n,m,l;
string s,t;
ll d[100],dp[100][100];
vll vec;
ll a,b;

int main(){
  cin >> n;
  print(24+(24-n));
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc080.contest.atcoder.jp/tasks/arc080_b>
問題文============================================================
 縦 H 行、横 W 列のマス目があります。
 すぬけ君は、このマス目を色 1, 2, …, N で塗り分けようとしています。 このとき、次の条件が成り立つようにします。
 
 各 i (1≤i≤N) について、色 i のマスはちょうど ai 個存在する。 ただし、a1+a2+…+aN=HW である。
 
 各 i (1≤i≤N) について、色 i のマスは上下左右に連結である。
 すなわち、どの色 i のマスからどの色 i のマスへも、上下左右に隣り合う色 i のマスのみを辿って行き来できる。
 
 条件を満たす塗り分け方をひとつ求めてください。 解は必ず存在することが示せます。

=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll H,W; cin >> H >> W;
    ll N; cin >> N;
    vector<ll> a(N);
    for(auto& in:a) cin >> in;
    
    
    vector<vector<int>> masu(H+2,vector<int>(W+2,-1));
    for(int i = 1; i <=H;i++) for(int j = 1; j<= W;j++) masu[i][j] = 0;
    
    int aidx = 0;
    for(int i = 1; i<= H;i++){
        if(i%2 == 1){
            for(int j = 1; j <= W;j++){
                masu[i][j] = aidx+1;
                a[aidx]--;
                if(a[aidx] == 0) aidx++;
            }
        }else{
            for(int j = W; j >= 1;j--){
                masu[i][j] = aidx+1;
                a[aidx]--;
                if(a[aidx] == 0) aidx++;
            }
        }
    }
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W;j++){
            cout << masu[i][j] << " ";
        }
        cout << endl;
    }
    
	return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

ll bitpow(ll x,ll n){
    ll ans = 1;
    while(n > 0){
        if(n%2 == 1) ans = ans * x;
        x = x * x;
        n = n >> 1;
    }
    return ans;
}

signed main(){

    int  n,p;
    cin >> n >> p ;
    int tmp_p = p;
    int ans = 1;

    if(n >= 40){
        cout << 1 << endl;
        return 0;
    }

    if(n == 1){
        cout  << p << endl;
        return 0;
    }

    for(int i = 2;i <= 1000000;i++){
        int x = bitpow(i,n);
        if(x > p){
            cout << ans << endl;
            return 0;
        }
        while(p%x == 0){
            ans *= i;
            p /= x;
        }
    }

    //cout << ;
    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 384
fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let a: Vec<usize> = sc.read_vec(n);

    let max = a.iter().map(|&a| a).max().unwrap();
    let mut count = vec![0; max + 1];
    for &a in &a {
        count[a] += 1;
    }

    println!(
        "{}",
        if is_possible(&count) {
            "Possible"
        } else {
            "Impossible"
        }
    );
}

fn is_possible(count: &Vec<usize>) -> bool {
    let diameter = count.len() - 1;
    for dist in 0..(diameter + 1) {
        if dist * 2 == diameter && count[dist] != 1 {
            return false;
        }
        if dist * 2 < diameter && count[dist] > 0 {
            return false;
        }
        if dist * 2 > diameter && count[dist] < 2 {
            return false;
        }
        if dist * 2 == diameter + 1 && count[dist] != 2 {
            return false;
        }
    }
    return true;
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


Measured memory_bytes: 4352
// https://atcoder.jp/contests/abc136/tasks/abc136_c
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
// ll gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// ll lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, now, pre;
    cin >> n;
    REP(i, n) {
        cin >> now;
        if (now >= pre + 1)
            now--;
        else if (now < pre) {
            cout << "No\n";
            return 0;
        }
        pre = now;
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
K = int(input())
ans = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
       1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(ans[K-1])


Measured memory_bytes: 9084