akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main() {
    lli n,k,a,roop,sta=N,now=0;
    vector<lli> vec,tel,check;
    lli i,j;
    cin>>n>>k;
    rep(i,0,n){
        cin>>a;
        vec.push_back(a);
        check.push_back(0);
    }
    tel.push_back(1);
    rep(i,0,n){
        if(check[vec[now]-1]==0){
//            cout<<i+1<<"回の移動で"<<vec[now]<<"に移動する"<<endl;
            check[vec[now]-1]=i+1;
            tel.push_back(vec[now]);
            now=vec[now]-1;
        }
        else{
            roop=i+1-check[vec[now]-1];
            sta=check[vec[now]-1];
//            cout<<roop<<" "<<sta<<endl;
            break;
        }
    }
    if(k<sta){
        cout<<tel[k]<<endl;
    }
    else{
        cout<<tel[sta+((k-sta)%roop)]<<endl;
    }
    
}


Measured memory_bytes: 9404
#include <iostream>

int main(void){
    int a, b, c;
    std::cin >> a >> b >> c;
    bool flag = false;
    if (a + b == c) flag = true;
    else if (b + c == a) flag = true;
    else if (c + a == b) flag = true;

    if (flag) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation
#include <cmath>

using namespace std;

int main() {
	int n;
	string s;
	cin >> s;
	n = s.size();
	string ss;
	ss = s;
	reverse(s.begin(), s.end());
	bool F = true;
	if (ss != s) F = false;

	string sss, ssss;
	sss = ss.substr(0, (n - 1) / 2);
	ssss = sss;
	reverse(sss.begin(), sss.end());
	if (ssss != sss) F = false;
	
	string sss2, ssss2;
	sss2 = ss.substr((n + 3) / 2 - 1);
	ssss2 = sss2;
	reverse(sss2.begin(), sss2.end());
	if (ssss2 != sss2) F = false;
	if (F) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner date = new Scanner(System.in);

		int [] num = new int [10];
		
		for (int i = 0; i < 10; i++) {
			num[i] = date.nextInt();
		}
		
		java.util.Arrays.sort(num);
		
		for (int i = num.length - 1; i > num.length - 4; i--) {
			System.out.println(num[i]);
		}
		
	
	}

}

Measured memory_bytes: 17364
#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>;
const int mod = 1000000007;
const int INF = 1001001001;
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 main(){
  int n,L;
  cin >> n >> L;
  vector<int> a(n);
  rep(i,n) a[i] = L+i;
  int s = 0;
  rep(i,n) s += a[i];
  int ans = mod;
  rep(i,n){
    int p = s;
    p -= a[i];
    if(abs(ans-s)>abs(s-p)) ans = p;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3588
from sys import stdin
import itertools

data=[]
for i in range(5):
    data.append(int(input()))
k=int(stdin.readline().rstrip())

flag=0
for j in list(itertools.product(data,repeat=2)):
    if abs(j[0]-j[1]) > k:
        flag=1
if flag==1:
    print(":(")
else:
    print("Yay!")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <chrono>
using namespace std::chrono;
using namespace std;
#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<int,int>
#define ll long long int
const int mod=1e9+7;
/*    auto start = high_resolution_clock::now();
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cout << "\nduration="<<duration.count()/1e6 << endl;
*/
int c[12],a[12][12];
int n,m,x;
bool pos(int mask){
    vector<int> v(m,0);
    fr(i,0,n){
        if((mask>>i)&1){

            fr(j,0,m){
                v[j]+=a[i][j];
            }
        }
    }
    fr(i,0,m){
        if(v[i]<x)
        return 0;
    }
    return 1;
}
void solve(){

    cin>>n>>m>>x;
    fr(i,0,n){
        cin>>c[i];
        fr(j,0,m)
        cin>>a[i][j];
    }
    int mn=INT_MAX;
    fr(mask,1,(1<<n)){
        if(pos(mask)){
            int sum=0;
            fr(j,0,n){
                if((mask>>j)&1)
                sum+=c[j];
            }
            mn=min(mn,sum);
        }
    }
    if(mn==INT_MAX)
    cout<<-1;
    else
    cout<<mn;

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
//    cin>>t;
    while(t--)
    solve();

}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#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++)
using namespace std;

int n, m, q;
vector<int> a, b, c, d;
int ans = 0;
void dfs(vector<int> A){
    if(A.size() ==  n + 1) {
        int score = 0;
        rep(i,q){
            if (A[b[i]] - A[a[i]] == c[i]) score += d[i];
        }
        ans = max(ans, score);
        return;
    }
    A.push_back(A.back());
    while(A.back() <= m){
        dfs(A);
        A.back()++;
    }
}
signed main(){
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    rep(i,q){
        cin  >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1,1));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
signed main()
{
    fast;
    map<string,int> mp;
    mp["SUN"] = 7;
    mp["MON"] = 6;
    mp["TUE"] = 5;
    mp["WED"] = 4;
    mp["THU"] = 3;
    mp["FRI"] = 2;
    mp["SAT"] = 1;
    //mp["WED"] = 4;
    string s;
    cin>>s;
    cout<<mp[s];
}

Measured memory_bytes: 256
A=[list(map(int,input().split())) for i in range(3)]
N=int(input())
b=[int(input()) for i in range(N)]
f=[0]*9
flag=False
for i in range(N):
  for j in range(3):
    for k in range(3):
      if(b[i]==A[j][k]):
        f[3*j+k]=1
if((f[0]==1 and f[1]==1 and f[2]==1)or(f[3]==1 and f[4]==1 and f[5]==1)or(f[6]==1 and f[7]==1 and f[8]==1)):
  flag=True
elif((f[0]==1 and f[3]==1 and f[6]==1)or(f[1]==1 and f[4]==1 and f[7]==1)or(f[2]==1 and f[5]==1 and f[8]==1)):
  flag=True
elif((f[0]==1 and f[4]==1 and f[8]==1)or(f[2]==1 and f[4]==1 and f[6]==1)):
  flag=True
if(flag==True):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
N = int(input())
a = list(map(int,input().split()))
x = a[0]
y = sum(a[1:])
ans = abs(x-y)
for i in range(1,N-1):
    x += a[i]
    y -= a[i]
    ans = min(abs(x-y),ans)
 
print(ans)

Measured memory_bytes: 24832
#include<stdio.h>

int main(){
    int a[5][14], i, j, k;
    int m, n;
    char design;
    
    scanf("%d", &n);
    for(i = 1; i <= 4; i++){
        for(j = 1; j <= 13; j++){
            a[i][j] = 0;
        }
    }
    
    for(k = 0; k < n; k++){
        scanf(" %c %d", &design, &m);
        if(design == 'S')a[1][m] = 1;
        else if(design == 'H')a[2][m] = 1;
        else if(design == 'C')a[3][m] = 1;
        else if(design == 'D')a[4][m] = 1;
    }
    
    for(i = 1; i <= 4; i++){
        for(j = 1; j <= 13; j++){
            if(a[i][j] == 0){
                if(i == 1)printf("S %d\n", j);
                else if(i == 2)printf("H %d\n", j);
                else if(i == 3)printf("C %d\n", j);
                else if(i == 4)printf("D %d\n", j);
            }
        }
    }
}


Measured memory_bytes: 2696
#include<stdio.h>

int main(void){
    int N, M, i, j;
    int ans=0;
    int K[50];
    int A[50][50];
    int flag[50];

    for(i=0;i<50;i++) flag[i] = 0;
    
    scanf("%d %d", &N, &M);
    for(i=0;i<N;i++){

	scanf("%d", &K[i]);
	for(j=0;j<K[i];j++){
	    scanf("%d", &A[i][j]);	    
	}
    }

    for(i=0;i<N;i++){
    	for(j=0;j<K[i];j++){
    	    flag[A[i][j]]++;
    	}
    }
        
    for(i=1;i<=M;i++){
    	if(flag[i] == N){
	    ans++;
	} 
    }

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


Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N,M,max = 0;
	N = sc.nextInt();
	M = sc.nextInt();
	int n[] = new int [N];
	int m[] = new int [M];
	int vote[] = new int [N];
	for(int i = 0;i < N;i++){
		n[i] = sc.nextInt();
		vote[i] = 0;
	}
	for(int i = 0;i < M;i++){
		m[i] = sc.nextInt();
	}
	for(int i = 0;i < M;i++){
		for(int k = 0;k < N;k++){
			if(m[i] >= n[k]){
				vote[k]++;
				break;
			}
		}
	}
	for(int i = 0;i < N;i++){
		if(vote[max] < vote[i])max = i;
		//System.out.println(vote[i]);
	}
	System.out.println(max + 1);
	}
}

Measured memory_bytes: 32000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,i;
  cin>>a;
  bool B=true;
  
  for(i=0;i<50000;i++){
    b=i*108/100;
    if(a==b){
      cout<<i<<endl;
      B=false;
      break;
    }
  }
  if(B){
    cout<<":("<<endl;
  }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}
};

int main() {
	ll a, b;
	cin >> a >> b;
	cout << (!(abs(a - b) <= 1) ? "Alice" : "Brown") << endl;
}


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

namespace ABC052A___Two_Rectangles
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] num = input.Split(' ');

            int a = int.Parse(num[0]) * int.Parse(num[1]);
            int b = int.Parse(num[2]) * int.Parse(num[3]);

            int x =  a > b ? a : b;

            Console.WriteLine(x);

        }
    }
}


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


int main(){

    int N,M,X,Y;
    cin >> N >> M >> X >> Y;

    int x[N],y[M];

    int x_max = X;
    for(int i=0;i<N;i++){
        cin >> x[i];
        x_max = max(x[i],x_max);
    }
    int y_min = Y;
    for(int i=0;i<M;i++){
        cin >> y[i];
        y_min = min(y[i],y_min);
    }
    
    if(x_max>=y_min){ cout << "War" << endl;}
    else{cout << "No War" << endl;}
    
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{min,max};
use std::collections::BinaryHeap;

fn main() {
    let xs = read_vec_i64();
    let (v,e,r) = (xs[0] as usize, xs[1] as usize, xs[2] as usize);
    let mut adj = vec![];
    adj.resize(v,vec![]);
    for _ in 0..e {
        let ys = read_vec_i64();
        let (s,t,d) = (ys[0] as usize, ys[1] as usize, ys[2]);
        adj[s].push((t,d));
    }
    let mut dists = vec![];
    dists.resize(v, None);
    dists[r] = Some(0);
    let mut heap = BinaryHeap::new();
    heap.push((0,r));
    while let Some((md,s)) = heap.pop() {
        let d = -md;
        for t_dd in adj[s].iter() {
            let (t,dd) = *t_dd;
            let nd = d + dd;
            if dists[t].is_none() || nd < dists[t].unwrap() {
                dists[t] = Some(nd);
                heap.push((-nd,t));
            }
        }
    }
    for d in dists {
        match d {
            Some(x) => println!("{}", x),
            None => println!("INF"),
        }
    }
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}



Measured memory_bytes: 23348
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def SS(): return map(str,sys.stdin.readline().rstrip().split())
def II(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

A,B,C = II()


if A==B==C and A % 2 != 1:
  print(-1)
  exit()
cnt = 0
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
  A_half = A/2
  B_half = B/2
  C_half = C/2
  A = B_half + C_half
  B = A_half + C_half
  C = A_half + B_half
  cnt += 1
print(cnt)


Measured memory_bytes: 12440
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd 
/****************************/
using namespace std;     
int main()
{
	ios::sync_with_stdio(0);
	string s;
	cin>>s;
	rep(i,3)
	{
		cout<<s[i];
	 } 
	return 0;                                                                                                                                     
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        string s;
        cin >> s;
        int k;
        cin >> k;
        int n = s.length();
        vector<string>st;
        for (int i = 0; i < n; i++) {
            for (int r = i + 1; r <= n && r - i <= 5; r++)
            {
                st.push_back(s.substr(i, r - i));
            }
        }
        sort(st.begin(), st.end());
        st.erase(unique(st.begin(), st.end()), st.end());
        cout << st[k - 1] << endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll N,K;cin>>N>>K;
	vector<ll> P(N);
	for(int i=0;i<N;i++)cin>>P[i],P[i]--;
	vector<ll> C(N);
	for(int i=0;i<N;i++)cin>>C[i];
	vector<int> visited(N);
	vector<vector<ll> >VV;
	for(int i=0;i<N;i++)if(!visited[i]){
		vector<ll> v={i};
		int pt=P[i];
		while(pt!=i){
			v.push_back(pt);
			pt=P[pt];
		}
		for(int a:v)visited[a]=1;
		VV.push_back(v);
	}
	ll ans = -1e18;
	for(vector<vector<ll> >::iterator it=VV.begin();it!=VV.end();it++){
		vector<ll> v=*it;
		int sz=v.size();
		for(int r=0;r<sz;r++){
			vector<ll> S(sz+1);
			for(int i=0;i<sz;i++) S[i+1]=S[i]+C[v[i]];
			for(int t=0;t<sz;t++){
				ll lmn=(t?0:1);
				ll lmx=(K+sz-t)/sz-1;
				if(lmn>lmx)continue;
				ll l=(S[sz]>0?lmx:lmn);
				ll res=l*S[sz]+S[t];
				ans=max(ans,res);
			}
			rotate(v.begin(),v.begin()+1,v.end());
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3820
#include<stdio.h>
#include<string.h>
void LCS(char *X,char *Y,int xl,int yl){
  int m,n,i,j,c[1005][1005];
  m=xl;
  n=yl;
  for(i=1;i<=m;i++)
    c[i][0]=0;
  for(j=0;j<=n;j++)
    c[0][j]=0;
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(X[i-1]==Y[j-1])
	c[i][j]=c[i-1][j-1]+1;
      else if(c[i-1][j]>=c[i][j-1])
	c[i][j]=c[i-1][j];
      else
	c[i][j]=c[i][j-1];
    }
  }
  printf("%d\n",c[xl][yl]);
}
int main(void){
  char X[200][10000],Y[200][10000];
  int n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",X[i]);
    scanf("%s",Y[i]);
  }
  for(i=0;i<n;i++)
    LCS(X[i],Y[i],strlen(X[i]),strlen(Y[i]));
  return 0;
}

Measured memory_bytes: 6692
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <type_traits>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using intl32 = std::int_least32_t;
using intl64 = std::int_least64_t;
using uintl32 = std::uint_least32_t;
using uintl64 = std::uint_least64_t;

template<typename T>
T gcd(T m, T n)
{
	T temp = m;
	temp %= n;
	while (temp) {
		m = n;
		n = temp;
		temp = m%n;
	}
	return n;
}

int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n, k;
	std::cin >> n >> k;
	std::vector<uint32> a(n);
	uint32 max = 0;
	for (uint32 i = 0;i < n;++i) {
		std::cin >> a[i];
		max = std::max(max, a[i]);
	}
	if (n == 1) {
		std::cout << (a[0] == k ? "POSSIBLE" : "IMPOSSIBLE");
		return 0;
	}
	uint32 g = gcd(a[0], a[1]);
	for (uint32 i = 2;i < n;++i) {
		g = gcd(g, a[i]);
	}
	std::cout << (k%g == 0 && k <= max ? "POSSIBLE" : "IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 1024
from collections import deque
 
n = int(input())
a = list(map(int,input().split()))
d = deque(a)
 
tmp = []
cnt = 0
while d:
  v = d.popleft()
  if len(tmp)<=1:
    pass
  else:
    if not (v >= tmp[-1] >= tmp[-2] >= tmp[0] or v <= tmp[-1] <= tmp[-2] <= tmp[0]):
      tmp = []
      cnt += 1
  tmp.append(v)
#  print(d,tmp,cnt)
if tmp:
  cnt+=1
print(cnt)

Measured memory_bytes: 20640
import java.util.*;

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

        long ret = Long.MAX_VALUE;

        for (int a = 1; a <= N / 2; a++) {
            int b = N - a;

            int atmp = a;
            int btmp = b;
            long sum = 0;

            while (atmp > 0) {
                sum += atmp % 10;
                atmp /= 10;
            }

            while (btmp > 0) {
                sum += btmp % 10;
                btmp /= 10;
            }

            ret = Math.min(ret, sum);
        }

        System.out.println(ret);
    }
}

Measured memory_bytes: 23268
import sys


sys.setrecursionlimit(10 ** 6)


def solve():
    def dfs(v):
        print(counter)
        for nv in g[v]:
            if nv in visited:
                continue
            visited.add(nv)
            counter[nv] += counter[v]
            dfs(nv)

    def input():
        return sys.stdin.readline().strip()

    N, Q = map(int, input().split())
    g = [set() for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        g[a].add(b)
        g[b].add(a)
    counter = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        p -= 1
        counter[p] += x

    stack = [0]
    visited = {0}
    while stack:
        v = stack.pop()
        for nv in g[v]:
            if nv in visited:
                continue
            stack.append(nv)
            visited.add(nv)
            counter[nv] += counter[v]
    return counter


print(" ".join(map(str, solve())))


Measured memory_bytes: 99288
# Dice for AOJ
class Dice
  def initialize(input)
    @t, @s, @e, @w, @n, @b = input
  end

  def roll_e
    tmp = @e
    @e = @t
    @t = @w
    @w = @b
    @b = tmp
  end

  def roll_n
    tmp = @n
    @n = @t
    @t = @s
    @s = @b
    @b = tmp
  end

  def roll_w
    tmp = @w
    @w = @t
    @t = @e
    @e = @b
    @b = tmp
  end

  def roll_s
    tmp = @s
    @s = @t
    @t = @n
    @n = @b
    @b = tmp
  end

  def spin_r
    tmp = @s
    @s = @e
    @e = @n
    @n = @w
    @w = tmp
  end

  attr_reader :t
  attr_reader :s
  attr_reader :e
  attr_reader :w
  attr_reader :n
  attr_reader :b
end

d = gets.split.map(&:to_i)
dice1 = Dice.new(d)
d = gets.split.map(&:to_i)
dice2 = Dice.new(d)

case dice2.t
when dice1.s
  dice1.roll_n
when dice1.e
  dice1.roll_w
when dice1.w
  dice1.roll_e
when dice1.n
  dice1.roll_s
when dice1.b
  dice1.roll_n
  dice1.roll_n
end

4.times do
  dice1.spin_r
  break if dice2.s == dice1.s
end

if dice1.e == dice2.e && dice1.w == dice2.w \
    && dice1.n == dice2.n && dice1.b == dice2.b
  puts 'Yes'
else
  puts 'No'
end



Measured memory_bytes: 8888
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=2e5+10,inf=0x3f3f3f3f;
int a[maxn],vis[maxn],n;
struct szsz{
	vector<pair<int,int> > stk[maxn];
	int top,c[maxn];
	inline int lowbit(int x){
		return x&(-x);
	}
	int sum(int x){
		int res=-inf;
		while(x){
			chkmax(res,c[x]);
			x-=lowbit(x);
		}
		return res;
	}
	void add(int x,int y){
		++top;
		while(x<=n+1){
			stk[top].push_back(make_pair(x,c[x]));
			chkmax(c[x],y);
			x+=lowbit(x);
		}
	}
	void undo(){
		assert(top>0);
		for(auto v:stk[top]) c[v.first]=v.second;
		stk[top].clear();
		--top;
	}
	void clear(){
		REP(i,1,n+1) c[i]=-inf;
	}
}bit1,bit0;
inline bool pd(int v,int h){
	if(v<0) return 0;
	int u;
	if(v&1) u=bit1.sum(n-h+1);
	else u=bit0.sum(n-h+1);
//	cerr<<v<<' '<<u<<' '<<h<<endl;
	return u>=v;
}
inline bool check(int x,int cx,int cy,int hx,int hy){
	if(pd(cy-cx+vis[x],hx)) return 1;
	if(pd(cx-cy+vis[x],hy)) return 1;
	return 0;
}
int main(){
	n=read();
	int Max=0;
	REP(i,1,n){
		a[i]=read();
		if(a[i]>Max) vis[i]=1,Max=a[i];
	}
	bit0.clear(),bit1.clear();
	bit0.add(1,0);
	DREP(i,n,1){
		int u=bit0.sum(n-a[i]+1),v=bit1.sum(n-a[i]+1);
		if(vis[i]) bit0.add(n-a[i]+2,u+2),bit1.add(n-a[i]+2,v+2);
		else bit0.add(n-a[i]+2,v+1),bit1.add(n-a[i]+2,u+1);
	}
	int cx=0,cy=0,hx=0,hy=0;
	DREP(i,n,1) vis[i]+=vis[i+1];
	if(!check(1,0,0,0,0)) return printf("-1\n"),0;
	REP(i,1,n){
		bit0.undo(),bit1.undo();
		if(check(i+1,cx+(a[i]>hx),cy,max(hx,a[i]),hy)){
			putchar('0');
			if(chkmax(hx,a[i])) cx++;
		}
		else{
			putchar('1');
			if(chkmax(hy,a[i])) cy++;
		}
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 60288
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
 
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
#define setpr(x) cout << setprecision((x))
#define PI atan(1)*4
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mk(a , b) { min((a) , (b)) , max((a) , (b)) }
#define flush cout.flush()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endc "\n"
#define MOD 1000000007
#define meme(x) memset((x), 0, sizeof((x)))
#define memo(x) memset((x),-1, sizeof((x)))
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

// #define int ll

ll egcd(ll a, ll b, ll &x, ll &y){
    if (a == 0LL){  
        x = 0LL;  
        y = 1LL;  
        return b;  
    }
    ll xx, yy;
    ll val = egcd(b % a, a, xx, yy);  
    x = yy - (b / a) * xx;  
    y = xx;  
    return val;
}

ll gcd(ll a, ll b){
    while(true){
        if(a>b)
            swap(a,b);
        if (a == 0) 
            return b; 
        ll p = b % a  , q = a;
        a = p;
        b = q;
    }
}
 
ll powerMod(ll x,ll y){
    ll res = 1;
    x %= MOD;
    while(y > 0){
        if(y & 1)res = (res*x)%MOD;
        y = y >> 1;
        x = (x * x)%MOD;
    }
    return res%MOD;
}

//  ==========     //\\       //||     ||====//||
//      ||        //  \\        ||     ||   // ||
//      ||       //====\\       ||     ||  //  ||
//      ||      //      \\      ||     || //   ||
//  ========== //        \\  ========  ||//====|| 
//  code

void solve(){
    ll n,i,j,k,l,p;
    cin >> n;
    ll ans = powerMod(10LL, n);
    ans -= powerMod(9LL, n);
    ans = (ans + MOD) % MOD;
    ans -= powerMod(9LL, n);
    ans = (ans + MOD) % MOD;
    ans += powerMod(8LL, n);
    ans = (ans + MOD) % MOD;
    cout << ans << endc;
}

int32_t main(){
    init;
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll MOD = 1e9 + 7;

// ll C[2005][2005];
// ll dp[100005][13];

ll tousa(ll a, ll l, ll n) {
    return n*(a+l)/2;
}

int main(){
    ll ans=0;
    ll mis_ans=0;
    ll r=0,g=0,b=0;
    ll N;
    cin >> N;
    string S;
    cin >> S;
    for(int i = 0; i < S.size();i++){
        if(S[i] == 'R')r++;
        if(S[i] == 'G')g++;
        if(S[i] == 'B')b++;
    }
    ans = r*g*b;

    for(int i=1; i<=N-2; i++){
        for(int j=i+1; j<=N-1; j++){
            int k= 2*j-i;
            if( k<= N){
                if(S[i-1] != S[j-1] && S[k-1] != S[j-1] && S[i-1] != S[k-1]){
                    mis_ans++;
                }
            }
        }
    }
    cout << ans - mis_ans << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

int main(){
    int n;
    cin >> n;
    vector<int> a, b(n);
    rep(i, n){
        int x;
        cin >> x;
        a.push_back(x);
    }
    int start = n/2;
    b[start] = a[0];
    if(n%2){
        rep2(i, 1, start+1){
            b[start+i] = a[i*2-1];
            b[start-i] = a[i*2];
        }
    }else{
        rep2(i, 1, start){
            b[start-i] = a[i*2-1];
            b[start+i] = a[i*2];
        }
        b[0] = a[n-1];
    }

    rep(i, n){
        cout << b[i] << " ";
    }
    cout << endl;
    return 0;
}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

const int MAXN = 2e5 + 5;
const int MOD = 998244353; //1e9 + 7;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define FAIL0 {cout << "0\n"; return 0;}
#define FAIL1 {cout << "-1\n"; return 0;}
#define FAILNO {cout << "NO\n"; return 0;}

int N, M;
vector<pair<int,pair<int,int>>> A[MAXN];
vector<pair<int,pair<int,int>>> B[MAXN];

LL val[MAXN*4], lz[MAXN*4], mx[MAXN*4];

void build(int node, int left, int right) {
    if (left == right) {
        mx[node] = 0;//
        lz[node] = 0;//
        return;
    }

    int m = (left + right) / 2;
    build(node*2, left, m);
    build(node*2 + 1, m+1, right);

    mx[node] = max(mx[node*2], mx[node*2+1]);
}

void push(int node, int left, int right) {
    mx[node] += lz[node];
    if (left != right) {
        lz[node*2]   += lz[node];
        lz[node*2+1] += lz[node];
    }

    lz[node] = 0;
}

void update(int node, int left, int right, int l, int r, LL newval) {
    push(node, left, right);
    if (r < l) return;
    if (r < left || right < l) return;

    if (l <= left && right <= r) {
        lz[node] += newval;
        push(node, left, right);
        return;
    }

    int m = (left + right) / 2;
    update(node*2, left, m, l, min(m, r), newval);
    update(node*2+1, m+1, right, max(m+1,l), r, newval);

    mx[node] = max(mx[node*2],mx[node*2+1]);
}

LL query(int node, int left, int right, int l, int r) {
    push(node, left, right);
    if (r < l) return -1e9;
    if (r < left || right < l) -1e9;

    if (l <= left && right <= r) return mx[node];

    int m = (left + right) / 2;
    return max(query(node*2, left, m, l, min(m,r)), 
               query(node*2+1, m+1, right, max(m+1,l), r));
}

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int l,r,a;
        cin >> l >> r >> a;
        A[l].pb({a,{l,r}});
        B[r+1].pb({a,{l,r}});
    }

    build(1,0,N);
    LL ans = 0;
    LL cur = 0;

    for (int i = 1; i <= N+1; i++) {
        for (auto a: A[i]) cur += a.fi;
        for (auto b: B[i]) {
            cur -= b.fi;
            int l = b.se.fi;
            int r = b.se.se;
            update(1,0,N,l,r,b.fi);
        }

        LL m = query(1,0,N,0,i-1);
        ans = max(ans, m + cur);
        
        update(1,0,N,i,i,m);
    }

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


Measured memory_bytes: 34688
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        long L = NextInt();
        long R = NextInt();
        //2019で全探索
        long ans = INF;
        if (R - L >= 2019) { ans = 0; }
        R %= 2019;
        L %= 2019;
        if (R < L) { ans = 0; }
        for (long i = L; i <= R; i++)
            for (long j = i + 1; j <= R; j++)
            {
                ans = Math.Min(ans, (i * j) % 2019);
            }

        Console.WriteLine(ans);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 11220
#include <stdio.h>
#include <iostream>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int max(int X, int Y) {
    return X > Y ? X : Y;
}

int main() {
    int A, B, C; cin >> A >> B >> C;

    cout << max(max(A * 10 + B + C, A + B * 10 + C), A + B + C * 10) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n;
int sum = 0;
int a[200];
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		a[i] *= n;
		sum += a[i];
	}
	sum /= n;
	int mem=10000000, ans = 0;
	rep(i, n) {
		if (abs(a[i] - sum) < mem) {
			ans = i;
			mem = abs(a[i] - sum);
		}
	}
	cout << ans << endl;
	getchar();getchar();
	return 0;
}

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

int main(){
  string S;
  long long K;
  cin>>S>>K;
  for(int i=0;i<K;i++){
    if(S[i]!='1'){
      cout<<S[i]<<endl;
      return 0;
    }
  }
  cout<<1<<endl;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc066/tasks/arc077_a
# C - pushpush

n = int(input().split()[0])
a_list = list(map(int, input().split()))

pre_list = a_list[1::2][::-1]
suf_list = a_list[::2]

b = pre_list + suf_list

if n % 2 == 1:
    b = b[::-1]

ans = ' '.join([str(x) for x in b])

print(ans)


Measured memory_bytes: 33140
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ull unsigned long long


using namespace std;
int adj[200005];
int seen[200005] = {0};

int main()
{
	
	
	
    ios_base::sync_with_stdio(false);	
    cin.tie(NULL); cout.tie(NULL);
    
    ll n, k; cin >> n >> k;
    
    for(int i = 1; i <= n; i++)
    {
		int x; cin >> x;
		adj[i] = x;
	}
	
	seen[1] = 0;
	
	int nxt = adj[1];
	
	ll ln = 1;
	
	int start;
	
	while(true)
	{
		
		if(!seen[nxt])
		{
			seen[nxt] = ln;
		}
		else
		{
			ln = ln - seen[nxt];
			start = seen[nxt];
			break;
		}
		
		nxt = adj[nxt];
		ln++;
	}
	int dest;
	if(k >= seen[nxt])
	{
		k -= seen[nxt];
		k =  k%ln;
		dest = nxt;
		
		for(int i = 0; i < k; i++)
		{
			dest = adj[dest];
		}
	}else
	{
		dest = 1;
		for(int i = 0; i < k; i++)
		{
			dest = adj[dest];
		}
	}
		
	
	cout << dest << '\n';
    
    return 0;
}


Measured memory_bytes: 5200
def main():
    """
    1 <= A,B,C<=5*10^3
    1 <= X,Y<=10^5
    """
    A, B, C, X, Y = map(int, input().split())

    search(A, B, C, X, Y)

def search(A, B, C, X, Y):
    ans = float("inf")
    for a in range(X+1):
        ab = 2 * (X - a)
        b = max(Y - ab // 2, 0)
        price = A * a + B * b + C * ab
        ans = min(ans, price)

    for b in range(Y+1):
        ab = 2 * (Y - b)
        a = max(X - ab // 2, 0)
        price = A * a + B * b + C * ab
        ans = min(ans, price)

    for ab in range(0, max(X, Y) * 2 + 1, 2):
        a = max(X - ab // 2, 0)
        b = max(Y - ab // 2, 0)
        price = A * a + B * b + C * ab
        ans = min(ans, price)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
	/*static double res=0;
	 static void help(int p,int r,int n){
		double tmp=p;
		for(int i=1;i<=n;i++){
			double x=1+(double)r/1200 ;
			tmp*=x;
		}
		res+=tmp;
		int k=100000,m=360;
		for(int i=m;i>0;i--){
			help(k,5,i);
		}
		System.out.println("paid amount "+k*m+" ");
		System.out.println((long)res);
	}
*/
public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n=s.nextInt();
		int[] arr=new int[n+1];
		//Set<Integer>set=new HashSet<>();
		Map<Integer,Integer>map=new HashMap<>();
		for(int i=0;i<n;i++){
			int x=s.nextInt();
			
			map.put(x,i+1);
		}
		
		StringBuilder sb=new StringBuilder();
for(int i=1;i<=n;i++){
	sb.append(map.get(i)+" ");
	
}		
System.out.println(sb);
		}
    }
	
		
	













Measured memory_bytes: 71464
import sys
import math
input = sys.stdin.readline
N, A, B = map(int, input().split())
h_list = []
for _ in range(N):
    h_list.append(int(input()))

def compare(k):
    cnt = 0
    for h in h_list:
        tmp_h = h - k*B
        x = max(math.ceil(tmp_h/(A-B)),0)
        cnt += x
        if cnt > k:
            return False
    return True
def solve():
    ng = 0
    ok = math.ceil(max(h_list) / B)
    while abs(ok-ng) > 1:
        mid = (ng + ok) // 2
        res = compare(mid)
        if (res):
            ok = mid
        else:
            ng = mid
    return ok
print(solve())

Measured memory_bytes: 45020
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define INF 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());
#define usort(a) sort(a.rbegin(),a.rend());

using namespace::std;

int jo(ll int a, ll int b){//累乗
    ll int num=1;
    rep(i,0,b) num=num*a;
    return num;
}
char tobig(char s){//char大文字化
  return (s-0x20);
}
char tolow(char s){//char小文字化
  return (s+0x20);
}
int ctoi(char a){//char->int
  if('0'<=a&&a<='9') return (a-'0');
  return -1;
}

int gcd(ll int a,ll int b) {//最大公約数
  if(a<b) return gcd(b,a);
  int c;
  while ((c=a%b)) {
    a=b;
    b=c;
  }
  return b;
}
int lcm(ll int a,ll int b){//最小公倍数
 return (a*b)/gcd(a,b);
}


int main(){
  int A,B,C;
  string S,T,U;
  cin>>A>>S>>T;
  rep(i,0,A) cout<<S[i]<<T[i];
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート
//  sort(変数名.rbegin(),変数名.rend());//降順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示

//  vector<pair<int,int>> data(N);  //2つのデータを格納、.first/.secondで参照
// pairのソートはfirst優先の昇順

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define M                 1000000007
#define MM                998244353
#define ff                first
#define ss                second
#define pii               pair<int,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define endl              "\n"
#define GCD(x,y)          (__gcd((x), (y)))
#define LCM(x,y)          (((x)/__gcd((x), (y)))*(y))
#define mem0(x)           memset(x, 0, sizeof (x))
#define mem1(x)           memset(x, -1, sizeof (x))
#define IOS ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
//coded by Avijit Mandal 18CS30010
int main(){
   ll i,j,n,k,t1,t2,count=0,mx=INT_MIN,mn=INT_MAX;
   cin>>n;
   ll a[n+1];
   ll dp[n+1];
   for(i=0;i<n;i++)cin>>a[i+1];
   dp[1]=0;
   for(i=2;i<n+1;i++){
      dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
      if(i>2)
         dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
   }
   cout<<dp[n]<<"\n";

}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  if(a==5){
    if((b==7 && c==5) || (b==5 && c==7))
      printf("YES\n");
    else
      printf("NO\n");
  }else if(a==7){
    if(b==5 && c==5)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}


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

S = [list(map(int, input().split()))[1:] for _ in range(m)]
P = list(map(int, input().split()))

C = [format(i, "0" + str(n) + "b") for i in range(2**n)]

ans = 0
for c in C:
    l = 0
    for i in range(m):
        o = sum(int(c[s - 1]) for s in S[i])
        if o % 2 == P[i]:
            l += 1
    if l == m:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int h[n];
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	int x,y;
	int ans[n]={0};
	
	for(int i=0;i<m;i++){
		cin>>x>>y;
		if(h[x-1]>h[y-1]){
			ans[y-1]=-1;
		}
		if(h[y-1]>h[x-1]){
			ans[x-1]=-1;
		}
		if(h[x-1]==h[y-1]){
			ans[y-1]=-1;
			ans[x-1]=-1;
		}
	}
	
	int count =0;
	for(int i=0;i<n;i++){
		if(ans[i]==0){
			count++;
		}
	}
	cout<<count<<endl;
	return 0;
	
}


Measured memory_bytes: 4400
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 998244353, N = 1e5 + 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;

string t;

main () {
	cin >> t;
	for (auto c : t)
		cout << (c == '?' ? 'D' : c);
}





Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
int main(void) {
	int n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	long long sum = accumulate(a.begin(), a.end(), 0LL);
	long long snuke = 0;
	long long ans = 1e18;
	for (int i = 0; i < n - 1; ++i) {
		snuke += a[i];
		long long kuma = sum - snuke;
		ans = min(ans, abs(snuke - kuma));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <cmath>
#include <iostream>

int main(int argc, char *argv[]) {
  long x;
  std::cin >> x;

  long sqrtx = pow(x, 1. / 5.) * 2;
  for (long a = -sqrtx - 1; a <= sqrtx; ++a)
    for (long b = -sqrtx - 1; b <= sqrtx; ++b)
      if (pow(a, 5) - pow(b, 5) == x) {
        std::cout << a << " " << b << std::endl;
        return 0;
      }
}


Measured memory_bytes: 3588
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str = sc.next();
        String[] s = str.split("");
        int[] dp = new int[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
        int left = 0;
        int right = 0;
        for (int i = 1; i < n; i++) {
            if (s[i].equals("E"))
                right++;
        }
        dp[0] = right;
        for (int i = 1; i < n; i++) {
            if (s[i - 1].equals("W"))
                left++;
            if (s[i].equals("E"))
                right--;
            dp[i] = left + right;
        }
        Arrays.sort(dp);
        System.out.println(dp[0]);
    }
}


Measured memory_bytes: 53280
#include<iostream>
#define p(i) (i>>1)
#define l(i) (i<<1)
#define r(i)  ((i<<1)+1)
const int Max=500005;
using namespace std;
int arr[500005];
int n;
void maxheapify(int i)
{
    int l=l(i),r=r(i),Maxi=-1;
    if(l<=n&&arr[l]>arr[i])
        Maxi=l;
    else Maxi=i;
    if(r<=n&&arr[r]>arr[Maxi])
        Maxi=r;
    if(Maxi!=i)
    {
        swap(arr[Maxi],arr[i]);
        maxheapify(Maxi);
    }
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>arr[i];
    for(int i=n/2;i>0;i--)
    maxheapify(i);
    for(int i=1;i<=n;i++)cout<<' '<<arr[i];
    cout<<endl;
    return 0;
}



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

int main(){
   int N,count;
   string S;
   cin>>N>>S;
   count=1;
  
   for(int i=0;i<N-1;i++){
      if(S.at(i)!=S.at(i+1)){
         count++;
      }
   }
    cout<<count<<endl;
   
}

Measured memory_bytes: 512
n = int(input())
p = []
for i in range(n-1):
    p.append(list(map(int, input().split())))
q,k = map(int,input().split())
kue = []
for i in range(q):
    a,b=input().split()
    kue.append((int(a), int(b)))
import heapq

def shortest_path(edge,num_v,start):
    inf = float("inf")
    cost = [[] for i in range(n+1)]
    for path in edge:
      cost[path[0]].append((path[1],path[2]))
      cost[path[1]].append((path[0],path[2]))
    d = [inf for j in range(num_v)]
    q = []
    heapq.heappush(q, (0, start))
    d[start] = 0
    while len(q) != 0:
      prov_cost, src = heapq.heappop(q)
      if d[src] < prov_cost:
                continue
      for dest,weight in cost[src]:
        if weight != float('inf') and d[dest] > d[src] + weight:
          d[dest] = d[src] + weight
          heapq.heappush(q, (d[dest], dest))
    return d
kno = shortest_path(p,n+1,k)
for i in kue:
  print(kno[i[0]] + kno[i[1]])

Measured memory_bytes: 72812
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n=gets.to_i
a=get_i
puts a.max-a.min

Measured memory_bytes: 1788
#include<stdio.h>
int main(void){
    char c;
    int i,count[26]={0};

    while(scanf("%c",&c) != EOF){
        if('a'<=c&&c<='z'){
            count[c-'a']++;
        }else if('A'<=c&&c<='Z'){
            count[c-'A']++;
        }
    }

    for(i=0;i<26;i++){
        printf("%c : %d\n",'a'+i,count[i]);
    }


    return 0;
}


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

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

  if(count(S.begin(), S.end(), 'A') == 0 || count(S.begin(), S.end(), 'B') == 0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256