akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cin >>a >>b >>c;
    int i=a;
    int d=0;
    while(i<=b){
        
       if(c%i==0) {
          d++;
        
       }
       i++; 
    }
   cout <<d<<endl;
    
    return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,k;
  ll n,m; cin>>n>>m;
  //ll a,b,c,d,e,f; cin>>a>>b;
  //ll a,b,c,d,e,f; cin>>a>>b>>c;
  //ll a,b,c,d,e,f; cin>>a>>b>>c>>d;
  //string s; cin >> s;
  ll result = 0;
  ll buf = 0;
  ll buf2 = 0;
  ll buf3 = 0;
  bool judge = true;
  //cout<<<<endl;
  bitset<11> a=0;
  vector<vector<ll>> b(m);
  ll c, d;

  for(i=0;i<m;i++){
    cin>>buf;
    for(j=0;j<buf;j++){
      cin>>c;
      b[i].push_back(c);
    }
  }
  vector<ll> p(m);
  for(i=0;i<m;i++) cin>>p[i];

  buf2=1;
  for(i=0;i<n;i++)buf2*=2;
  
  for(i=0;i<buf2;i++){
    a=i;
    judge=true;
    for(j=0;j<m&&judge;j++){
      buf=0;
      for(k=0;k<b[j].size();k++){
        if(a[b[j][k]-1]==true)buf++;
      }
      if(buf%2!=p[j])judge=false;

    }
    if(judge)result++;

  }
  
  cout<<result<<endl;
  

  return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
def euclid(a,b):
    a,b=max(a,b),min(a,b)
    if a%b==0:
        return b
    else:
        a,b=b,a%b
        return euclid(a,b)

N=int(input())
A=list(map(int,input().split()))

org_A=A[:]
#左から最大公約数作る右もね
A=A[::-1]
l=[A.pop(-1)]
while A:
    l.append(euclid(l[-1],A.pop(-1)))

A=org_A
r=[A.pop(-1)]
while A:
    r.append(euclid(r[-1],A.pop(-1)))
r=r[::-1]

ans=0
#print(l,r)
for i in range(N):
    temp=euclid(l[i-1] if i!=0 else r[i+1],r[i+1] if i!=N-1 else l[i-1])
    #print(l[i-1] if i!=0 else r[i+1],r[i+1] if i!=N-1 else l[i-1])
    ans=max(ans,temp)

print(ans)


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

#define DEBUG

#ifdef DEBUG
#define dump(x) cout << "[*] " #x ": " << x << endl
#define debug(x) x
#else
#define dump(x)
#define debug(x)
#endif

//#define int long long
typedef long long ll;
//constexpr int INF = 1e9;
//constexpr int MOD = 1000000007;

decltype(1) main() {
    //cin.tie(nullptr);
    //ios_base::sync_with_stdio(false);

    int h, a;
    cin >> h >> a;
    cout << (h / a) + !!(h % a) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define MAX_PRIMARY_NUM 1000000

using namespace std;

int main(void){
	int a, d, n;
	bool p[MAX_PRIMARY_NUM + 1];
	fill(p, p + MAX_PRIMARY_NUM + 1, true);
	p[0] = p[1] = false;
	for (int i = 2; i * i <= MAX_PRIMARY_NUM; i++){
		if (p[i]){
			for (int j = 2 * i; j <= MAX_PRIMARY_NUM; j += i){
				p[j] = false;
			}
		}
	}
	while (true){
		cin >> a >> d >> n;
		if (a == 0 && d == 0 && n == 0){
			break;
		}
		int i, j = 0;
		// iは等差数列
		// jは等差数列に含まれる素数の合計
		for (i = a; j < n; i += d){
			if (p[i]){
				j++;
			}
		}
		cout << i - d << endl;
	}
	return 0;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x,p/2);
	if(p%2==1)res=res*x;
	return res;
}

int main()
{
	ll h;
	cin>>h;
	ll cnt=0,tmp=1;
	while(tmp*2<=h){
		tmp*=2;
		cnt++;
	}
	// cout<<tmp<<endl;
	// cout<<cnt<<endl;

	ll ans=0;
	while(cnt>=0){
		ans += power(2LL,cnt);
		cnt--;
		// cout<<power(2LL,cnt)<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll l,r;
  cin>>l>>r;
  
  ll a=l%2019,b=r%2019;
  ll c=l/2019,d=r/2019;
  l=a>b?b:a;
  r=a>b?a:b;
  
  ll ans=2019;
  for(ll i=l;i<r;i++){
    for(ll j=i+1;j<=r;j++){
      const ll p = (i*j)%2019;
      if(ans>p)ans=p;
    }
  }
  if(d-c>0)ans=0;
  //cout<<c<<" "<<d<<endl;
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

        int N = Integer.parseInt(scanner.nextLine());
        long[] sums = new long[N];
        String[] array = scanner.nextLine().split(" ");
        long sum = 0;
        for (int i = 0; i < N; ++i) {
            sum += Long.parseLong(array[i]);
            sums[i] = sum;
        }
        Arrays.sort(sums);
        long count = 0;
        long prep = sums[0];
        long subCount = 0;
        for (int i = 1; i < N; ++i) {
            if (sums[i] == prep) {
                ++subCount;
            } else {
                if (prep == 0) {
                    subCount += 1;
                }
                if (subCount > 0) {
                    count += (subCount * (subCount + 1)) / 2;
                    subCount = 0;
                }
                prep = sums[i];
            }
        }
        if (prep == 0) {
            subCount += 1;
        }
        if (subCount > 0) {
            count += (subCount * (subCount + 1)) / 2;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 56384
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>

struct cell;

struct cell{
    int x;
    struct cell *prev;
    struct cell *next;
};

struct cell *top = NULL;
struct cell *last = NULL;

void insert(int x){
    struct cell * c = (struct cell*)malloc(sizeof(struct cell));
    c->x = x;
    c->prev = NULL;
    c->next = NULL;
    if(top == NULL){ // last == NULL
	top = c;
	last = c;
    }else{
	top->prev = c;
	c->next = top;
	top = c;
    }
}

void delete_cell(struct cell * c){
    if(c == top && c == last){
	top = NULL;
	last = NULL;
    }else if(c == top){
	top = c->next;
	c->prev = NULL;
    }else if(c == last){
	c->prev->next = NULL;
	last = c->prev;
    }else{
	c->prev->next = c->next;
	c->next->prev = c->prev;
    }
    free(c);
}

void my_delete(int x){
    struct cell * c = top;
    while(c != NULL){
	if(x == c->x){
	    delete_cell(c);
	    break;
	}else{
	    c = c->next;
	}
    }
}

void deleteFirst(){
    delete_cell(top);
}

void deleteLast(){
    delete_cell(last);
}

void print(){
    struct cell * c = top;
    std::stringstream ss;
    std::string sep = "";
    while(c != NULL){
	ss << sep << c->x;
	c = c->next;
	sep = " ";
    }
    std::cout << ss.str() << std::endl;
}

int main(int argc, char **argv){

    int N;
    std::cin >> N;
    
    std::string command;
    int x ;
    for(int i = 0; i < N; i++){
	std::cin >> command;
	if(command == "insert"){
	    std::cin >> x;
	    insert(x);
	}else if(command == "delete"){
	    std::cin >> x;
	    my_delete(x);
	}else if(command == "deleteFirst"){
	    deleteFirst();
	}else if(command == "deleteLast"){
	    deleteLast();
	}
    }

    print();
}



Measured memory_bytes: 34268
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

pub fn bsearch<F>(ok: i64, ng: i64, pred: F) -> Option<i64>
where
    F: Fn(i64) -> bool,
{
    let orig_ok = ok;
    let mut ok = ok;
    let mut ng = ng;
    while (ok - ng).abs() > 1 {
        let mid = (ok + ng) / 2;
        if pred(mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    if ok == orig_ok {
        None
    } else {
        Some(ok)
    }
}

// fn dfs(k: usize, av: &av, dp: &mut HashMap::new()) -> isize {
//     if dp[usize]
// }

fn solve() {
    input! {
        n: usize, k: usize,
        av: [f64; n]
    };

    let res = bsearch(10_i64.pow(9) + 1, 0 as i64, |x| {
        let max = x as f64;
        let mut count = 0_usize;
        for &a in &av {
            let n = (a / max) as usize;
            count += if a % max == 0.0 { n - 1 } else { n };
        }
        count <= k
    });
    let res = res.unwrap();
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 4740
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n+1];
    memset(a,0,sizeof(a));
    for(int i=0;i<n-1;i++)
    {
        int x;
        cin>>x;
        if(i==0)a[i]=max(a[i],x);
        a[i+1]=max(a[i+1],x);
    }
    int ans=0;
    for(int i=0;i<n-1;i++)
    {
        if(a[i]>a[i+1])
        {
            a[i]=a[i+1];
        }
        //cout<<a[i]<<endl;
    }
   // cout<<a[n-1]<<endl;
    for(int i=0;i<n;i++)ans+=a[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define All(x) (x).begin(),(x).end()
#define RAll(x) (x).rbegin(),(x).rend()


int main(){
	ll N, X, Y;
	cin >> N >> X >> Y;
	X--, Y--;
	vector<vector<ll>> edge(N, vector<ll>(N, 1000000000));
	for(int i=0;i<N;i++) edge[i][i] = 0;
	for(ll i=0;i<N-1;i++) {
		edge[i][i+1] = 1;
		edge[i+1][i] = 1;
	}
	edge[X][Y] = 1;
	edge[Y][X] = 1;
	for(int i=0;i<=N;i++) {
		for(int j=i+2;j<N;j++) {
			edge[i][j] = edge[i][j-1] + 1;
		}
	}
	for(int i=0;i<=N;i++) {
		for(int j=i+1;j<N;j++) {
			edge[j][i] = edge[i][j];
		}
	}

	for(int i=0;i<=X;i++) {
		for(int j=Y;j<N;j++) {
			edge[i][j] = min(edge[i][j], edge[i][X] + edge[Y][j] + 1);
			edge[j][i] = edge[i][j];
		}
	}
	for(int i=0;i<=X;i++) {
		for(int j=X+1;j<=Y;j++) {
			edge[i][j] = min(edge[i][j], edge[i][X] + 1 + edge[Y][j]);
		}
	}
	for(int i=Y;i<N;i++) {
		for(int j=X;j<Y;j++) {
			edge[i][j] = min(edge[i][j], edge[i][Y] + 1 + edge[X][j]);
			edge[j][i] = edge[i][j];
		}
	}
	for(int i=X;i<=Y;i++) {
		for(int j=i+1;j<=Y;j++) {
			edge[i][j] = min(edge[i][j], edge[i][X] + 1 + edge[Y][j]);
			edge[j][i] = edge[i][j];
		}
	}
	vector<ll> ans(N+1, 0);
	for(ll i=0;i<N;i++) {
		for(ll j=i+1;j<N;j++) {
			ll now = edge[i][j];
			ans[now]++;
		}
	}
	for(ll i=1;i<N;i++) cout << ans[i] << endl;
}

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

using namespace std;

typedef long long ll;
const int MAXN = 300 + 5;

bool a[MAXN][MAXN];

int main()
{
    int n;
    string s;
    int a[4] = {0};
    cin>>n;
    while(n --)
    {
        cin>>s;
        if("AC" == s)
            a[0] ++;
        else if("WA" == s)
            a[1] ++;
        else if("TLE" == s)
            a[2] ++;
        else
            a[3] ++;
    }
    cout<<"AC x "<<a[0]<<endl;
    cout<<"WA x "<<a[1]<<endl;
    cout<<"TLE x "<<a[2]<<endl;
    cout<<"RE x "<<a[3]<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define bisea binary_search
#define unsort(vec) sort(vec); rever(vec);
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
string a,b,c;
signed main() {
  cin>>a>>b>>c;
  int turn=0;
  while(1) {
    if(turn==0) {
      if(a.size()==0) {
        cout<<"A"<<endl;
        break;
      }
      char A=a.at(0);
      if(A=='a') turn=0;
      else if(A=='b') turn=1;
      else turn=2;
      a.erase(a.begin());
    }
    else if(turn==1) {
      if(b.size()==0) {
        cout<<"B"<<endl;
        break;
      }
      char B=b.at(0);
      if(B=='a') turn=0;
      else if(B=='b') turn=1;
      else turn=2;
      b.erase(b.begin());
    }
    else {
      if(c.size()==0) {
        cout<<"C"<<endl;
        break;
      }
      char C=c.at(0);
      if(C=='a') turn=0;
      else if(C=='b') turn=1;
      else turn=2;
      c.erase(c.begin());
    }
  }
}

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

public class Problem_C
{
  public static void Main(string[] args)
  {
    var n = int.Parse(Console.ReadLine());
    var tmp = Console.ReadLine().Split().Select(int.Parse).ToList();
    var spots = new List<int> { 0 };
    spots.AddRange(tmp);
    spots.Add(0);

    var d = 0;
	for (var i = 1; i < spots.Count; i++)
    {
      d += Math.Abs(spots[i] - spots[i - 1]);
    }

    for (var i = 1; i < spots.Count - 1; i++)
    {
      var total = d - Math.Abs(spots[i - 1] - spots[i])
        - Math.Abs(spots[i] - spots[i + 1])
        + Math.Abs(spots[i - 1] - spots[i + 1]);
      Console.WriteLine($"{total}");
    }
  }
}

Measured memory_bytes: 28368
def LI():
    return list(map(int, input().split()))


N = LI()
N.sort()
A, B, C = N
a = (C-A)//2
A += a*2
b = (C-B)//2
B += b*2
if A == B == C:
    ans = a+b
elif A == B:
    ans = a+b+1
else:
    ans = a+b+2
print(ans)


Measured memory_bytes: 9104
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
	int s, e, v; cin >> s >> e >> v;
	int ans = 0;
	for (int i = s; i <= e; ++i) {
		if (v % i == 0) ++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

int main(void){
	lli a=1,b=1;
	int n;
	scanf("%d",&n);
	rep(i,n){
		int x;
		scanf("%d",&x);
		if(x%2==0)b*=2;
		a*=3;
	}
	printf("%lld\n",a-b);
	return 0;
}






Measured memory_bytes: 256
N, K = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

# dp=[0 for i in range(N)]
dp = [float("inf")]*(N)
dp[0] = 0
dp[1] = abs(h[1] - h[0])


for i in range(N-1):
  for j in range(1, min(K+1, N - i)):
    dp[i+j]=min(dp[i+j], dp[i]+ abs(h[i+j]-h[i]))
print(dp[N-1])


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

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int dp[1050][8];
int n;
const int MOD =10007;
int main(){
	cin>>n;
	dp[0][1]=1;
	char c;
	for(int i =1;i <= n;i++){
		cin>>c;
		int x;
		if(c=='J'){
			x =0;
		}else if(c=='O'){
			x = 1;
		}else{
			x =2;
		}
		for(int j =1;j <(1<<3);j++){//今日の状態
			if((j&(1<<x))==0)continue;//含んでないなら
			for(int k =1;k < (1<<3);k++){//前日の状態
				if((j&k)==0)continue;//含んでない
				dp[i][j]=(dp[i][j]+dp[i-1][k])%MOD;
			}
		}
	}
	int ans =0;
	for(int i =0;i < (1<<3);i++){
		ans =(ans+dp[n][i])%MOD;
	}
	cout <<ans<<endl;
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>

using namespace std;
int Par(int n, vector<int> &d) {
	if (d[n] == n)
		return n;
	int ans = Par(d[n], d);
	d[n] = ans;
	return ans;
}

int main(void) {
	int num, m, k, i, j, a, b;
	cin >> num >> m;
	vector<int> d(m + 1), l(m + 1, 0), t(num);
	for (i = 1; i <= m; i++)
		d[i] = i;
	for (i = 0; i < num; i++) {
		scanf("%d%d", &k, &t[i]);
		t[i] = Par(t[i], d);
		while (k > 1) {
			scanf("%d", &a);
			a = Par(a, d);
			if (l[t[i]] < l[a]) {
				d[t[i]] = a;
				t[i] = a;
			}
			else {
				d[a] = t[i];
				if (l[t[i]] == l[a])
					l[t[i]]++;
			}
			k--;
		}
	}
	a = Par(t[0], d);
	for (i = 1; i < num; i++) {
		if (a != Par(t[i], d)) {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string st;
    int n, s, e, w, lng;
    n = s = e = w = 0;
    cin >> st;
    lng = st.size();
    for (int i = 0; i < lng; i++) {
        if (st[i] == 'N') n++;
        if (st[i] == 'S') s++;
        if (st[i] == 'E') e++;
        if (st[i] == 'W') w++;
    }
    if (n > 0 && s > 0) {
        if (w > 0 && e > 0) cout << "Yes";
        else if (w == 0 && e == 0) cout << "Yes";
        else cout << "No";
    }
    else if (n == 0 && s == 0) {
        if (w > 0 && e > 0) cout << "Yes";
        else cout << "No";
    }
    else cout << "No";
    return 0;
}


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

namespace ITP1_5_A
{
    class Program
    {
        static void Main(string[] args)
        {
            //縦Hcm、横Wcmの長方形を描く
            //1cm×1cmの正方形を'#'で表す
            //H,Wがともに0の時入力の終了

            
            while (true)                        //以下の処理をbreak条件が与えられるまで繰り返す
            {
                string[] str = Console.ReadLine().Split(' ');
                int H = int.Parse(str[0]);          //H 長方形の縦
                int W = int.Parse(str[1]);          //W 長方形の横

                int i1;                             //以下のfor文にてHに対応して用いる変数
                int i2;                             //以下のfor文にてWに対応して用いる変数

                if (H == 0 && W == 0)
                {
                    break;                      //H,Wが0の時、処理の終了
                }

                else
                {
                    for (i1 = 0; i1 < H; i1++)      //縦に以下の処理を何回繰り返すか？
                    {
                        for (i2 = 0; i2 < W; i2++)  //#を書く処理を何回繰り返すか？
                        {
                            Console.Write("#");     //横にW個の#を表示させる
                        }
                        Console.WriteLine();        //改行する
                    }
                    Console.WriteLine("");
                }
            }
        }
    }
}



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

int main(int argc, const char * argv[]) {
    // insert code here...
    int X, Y;
    cin >> X >> Y;
    for (int i = 0; i <= X; i++) {
        int num_turtle = X - i;
        if (i * 2 + num_turtle * 4 == Y) {
            cout << "Yes"  << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];

// template starts
typedef long long int ll;

// template ends here

void solve(){
	// code starts from here
	int N;
	cin >> N;
	vector<ll> vec(N);
	input(vec,N);
	
	ll ans = 0;
	for(int i = 1; i < N; i++){
		ans += max((ll)0,vec[i-1]-vec[i]);
		vec[i] = max(vec[i],vec[i-1]);
	}
	
	cout << ans << endl;
}

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

	int T;
	T = 1;
	while(T--){
		solve();
	}

	return 0;
}


Measured memory_bytes: 4716
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)

n,m=map(int,input().split())
G=[[]*n for i in range(n)]
color=[-1]*n
for i in range(m):
    v1,v2=map(int,input().split())
    G[v1].append(v2)
    G[v2].append(v1)


def dfs(v,c):
    color[v]=c
    for vi in G[v]:
        if color[vi]==-1:
            dfs(vi,i)


for i in range(n):
    if color[i]==-1:
        dfs(i,i)

q=int(input())
for i in range(q):
    s,t=map(int,input().split())
    print('yes' if color[s]==color[t] else 'no')



Measured memory_bytes: 126948
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef int status;
typedef long long ll;
typedef unsigned long long ull;
const ull base = 343;
const int INF = int(1e9);
const ll INF1 = ll(1e18);
const int MAX = 200002;

ll N,C;
ll x[MAX],v[MAX];
ll sum1[MAX],sum2[MAX];
ll var1[MAX],var2[MAX];
ll max1 = 0;

int main()
{
    cin>>N>>C;
    for(int i = 1;i <=N;i++)cin>>x[i]>>v[i];
    for(int i = 1;i <= N;i++){
        sum1[i] = sum1[i-1]+v[i];
        var1[i] = max(var1[i-1],sum1[i]-x[i]);
        max1 = max(var1[i],max1);
    }
    for(int i = N;i >= 1;i--){
        sum2[i] = sum2[i+1]+v[i];
        var2[i] = max(var2[i+1],sum2[i]-(C-x[i]));
        max1 = max(var2[i],max1);
    }
    for(int i = N;i >= 1;i--){
        max1 = max(max1,var2[i]+var1[i-1]-(C-x[i]));
    }
    for(int i = 1;i <= N;i++){
       max1 = max(max1,var1[i]+var2[i+1]-x[i]);
    }
    cout<<max1<<endl;
    return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
//#include <atcoder/fenwicktree>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
//#define _GLIBCXX_DEBUG

using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
int main()
{
    string S;
    cin >> S;
    int N = S.size();
    rep(i, N) {
        S[i] = 'x';
    }
    cout << S << "\n";
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int a, b;
    cin >> a >> b;

    if (abs(a - b) % 2 == 1)
    {
        cout << "IMPOSSIBLE" << endl;
    }
    else
    {
        cout << (a + b) / 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let n: usize = read();
    let a: Vec<usize> = read_vec();

    let mut check = Vec::new();

    for (i, &x) in a.iter().enumerate() {
      check.push((i, x));
    }

    check.sort_by(|a, b| a.1.cmp(&b.1));

    for (i, x) in check {
      print!("{} ", i + 1);
    }
    println!("");
}


Measured memory_bytes: 8956
N, M = map(int, input().split())
S = input()
ans = []
tmp = S[::-1]
index = 0
acnt = M
while True:
    if acnt == 0:
        print(-1)
        exit()
    if index + acnt <= N and tmp[index + acnt] == '0':
        ans.append(acnt)
        index += acnt
        acnt = M
    else:
        acnt -= 1
    if index == N:
        break
print(*reversed(ans))

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

int main() {
    int64_t n; cin >> n;
    int64_t a = 1;
    for(int i = sqrt(n); i >= 1; i--){
        if(n%i == 0){
            a = i;
            break;
        }
    }
    int64_t b = n/a;
    int ans = to_string(b).size();
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.ListIterator;
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			ArrayList<Integer> A = new ArrayList<>();
			for(int i=0;i<n;i++){
				A.add(sc.nextInt());
			}
			ListIterator<Integer> AI = A.listIterator();
			int prev = AI.next();
			while(AI.hasNext()) {
				if(prev == AI.next()) {
					AI.remove();
				}else {
					prev = AI.previous();
					AI.next();
				}
			}
			AI = A.listIterator();
			System.out.print(AI.next());
			while(AI.hasNext()) {
				System.out.print(" " + AI.next());
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 72692
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Общий файл.
#include <ext/pb_ds/tree_policy.hpp> // Содержит класс tree_order_statistics_node_update


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)

const int mod = 1e9 + 7;
const int N = 500500;
const int M = 10000;
const int inf = 2e9;
int n;
string s;
const int p = 37;
ll get_hash(string s) {
    int n = s.length();
    ll h = 0;
    for(int i = 0; i < n; ++i) {
        h = h * p + (s[i] - 'a' + 1);
    }
    return h;
}
map<ll, int> cnt[20];
ll ans;
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> s;
    for(int mask = 0; mask < (1 << n); ++mask) {
        string a, b;
        for(int i = 0; i < n; ++i) {
            if((1 << i) & mask) {
                a += s[i];
            } else b += s[i];
        }
        reverse(b.begin(), b.end());
        a += b;
        ll h = get_hash(a);
        cnt[__builtin_popcount(mask)][h]++;
    }
    for(int mask = 0; mask < (1 << n); ++mask) {
        string a, b;
        for(int i = n - 1; i >= 0; --i) {
            if((1 << i) & mask) {
                a += s[i + n];
            } else b += s[i + n];
        }
        reverse(b.begin(), b.end());
        a += b;
        ll h = get_hash(a);
        ans += cnt[__builtin_popcount(mask)][h];
    }
    cout << ans;
    return 0;
}

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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

struct edge{
	int from, to;
	edge(int from, int to):from(from), to(to){;}
};
using node = vector<edge>;
using graph = vector<node>;

void addedge(graph &g, int from, int to, bool bidirectional = false){
	g[from].emplace_back(edge(from, to));
	if(bidirectional)g[to].emplace_back(edge(to, from));
}

int bfs(graph g, int u, vector<int> &prev, vector<int> &d,int start){
	queue<int> q;
	q.push(u);
	prev[u] = start;
	d[u] = 1;
	while(!q.empty()){
		auto tmp = q.front();
		q.pop();
		for(auto e: g[tmp]){
			if(prev[e.to] != -1)continue;
			d[e.to] = d[tmp] + 1;
			prev[e.to] = tmp;
			if(e.to == start)return d[e.to];
			q.push(e.to);
		}
	}
	return 0x7f7f7f7f;
}

class Solution {
public:
	void solve() {
		int n, m;
		cin >> n >> m;
		graph g(n);
		for(int i=0; i < m; i++){
			int a, b;
			cin >> a >> b;
			a--, b--;
			addedge(g, a, b);
		}
		vector<int> ans;
		int ans_d = 0x7f7f7f7f;
		for(int i=0; i < n; i++){
			for(int j=0; j < g[i].size(); j++){
				vector<int> prev(n, -1), d(n, 1e9);
				prev[g[i][j].to] = i;
				d[g[i][j].to] = 1;
				if(bfs(g, g[i][j].to, prev, d, i) < ans_d){
					ans.clear();
					ans = vector<int>({i});
					int x = prev[i];
					while(x != i){
						ans.push_back(x);
						x = prev[x];
					}
					ans_d = d[i];
				}
			}
		}
		if(ans.size() == 0){
			cout << -1 << "\n";
			return;
		}
		cout << ans.size() << "\n";		
		for(int i=0; i<ans.size(); i++)cout << ans[i]+1 << " ";
		cout << "\n";
		
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 512
#import<atcoder/all>
#define g(x)printf("%d ",size(x));for(auto i:x)
int u,v;main(){std::cin>>u>>v;atcoder::scc_graph G(u);for(;std::cin>>u>>v;)G.add_edge(u,v);g(G.scc()){g(i)printf("%d ",i);}}

Measured memory_bytes: 40104
#include <iostream>
using namespace std;
  
int main()
{
	int H, W, i, j;
	while(1){
    cin >> H >> W;
		if ( W == 0 & H == 0)
			break;
		for (i=0; i<H; i++) {
			for(j=0; j<W; j++) {
				if(0 < j && j< W-1 && 0 < i && i < H-1){
				cout <<'.';
			}else {
				cout << '#';
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Ch -= 1
Cw -= 1
Dh, Dw = map(int, input().split())
Dh -= 1
Dw -= 1
S = [list(input()) for i in range(H)]
S[Ch][Cw] = "#"

ans = 0
warp_after = [[Ch, Cw]]
warp_before = []
queue1 = [[1,0],[-1,0],[0,1],[0,-1]]
queue2 = [
        [-2,-2],[-2,-1],[-2,0],[-2,1],[-2,2],
        [-1,-2],[-1,-1],       [-1,1],[-1,2],
        [0,-2],                       [0,2],
        [1,-2], [1,-1],        [1,1], [1,2],
        [2,-2], [2,-1], [2,0], [2,1], [2,2]
    ]

def nowRange(now):
    r = []
    for i in queue1:
        j = now[0] + i[0]
        k = now[1] + i[1]
        if H > j > -1 and W > k > -1:
            if S[j][k] == "#":
                pass
            elif j == Dh and k == Dw:
                print(ans)
                exit()
            elif S[j][k] == ".":
                S[j][k] = "#"
                r = r + [[j,k]]
    return r


def stepRange(trout):
    r = []
    for i in trout:
        r = r + nowRange(i)
    if len(r) != 0:
        return r + stepRange(r)
    else:
        return []


def nowWarp(now):
    r = []
    for i in queue2:
        j = now[0] + i[0]
        k = now[1] + i[1]
        if H > j > -1 and W > k > -1:
            if S[j][k] == "#":
                pass
            elif j == Dh and k == Dw:
                print(ans)
                exit()
            elif S[j][k] == ".":
                S[j][k] = "#"
                r = r + [[j,k]]
            
    return r


def warpRange(trout):
    r = []
    for i in trout:
        r = r + nowWarp(i)
    if len(r) != 0:
        return r
    else:
        print(-1)
        exit()


while True:
    warp_before = stepRange(warp_after) + warp_after
    ans += 1
    warp_after = warpRange(warp_before)

Measured memory_bytes: 173096
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.NoSuchElementException;
import java.util.Set;

public class Main {
	//	static long start;
	//	static long end;

	public static void main(String[] args) {
		FastScanner scan = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		int t = 1000000007;

		int n = scan.nextInt();
		int m = scan.nextInt();
		Set<Integer> a = new HashSet<Integer>();

		for (int i = 0; i < m; i++) {
			a.add(scan.nextInt());
		}

		long[] ret = new long[n + 1];
		for (int i = 1; i < n + 1; i++) {
			if (a.contains(i)) {
				ret[i] = 0;
			} else if (i == 1) {
				ret[i] = 1;
			} else if (i == 2) {
				ret[i] = ret[i - 1] + 1;
			} else {
				ret[i] = ret[i - 1] + ret[i - 2];
				ret[i] %= 1000000007L;
			}
		}

		out.println(ret[n]);
		out.flush();
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 28248
# include <bits/stdc++.h>
using namespace std;
long long n,ans;
int main()
{
	cin>>n;
	for (long long i=1; i<=n; i++)
	{
		if (i%3!=0 && i%5!=0)
		{
			ans+=i;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define int long long int
using namespace std;
int ok = 1000*1000*1000+7;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define MAX 1e15+1
#define pi  pair<int,int>

int hp[200000];

signed main(){
	
	int n,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	hp[1]=0;
	hp[2]=abs(a[1]-a[2]);
		for(int i=3;i<=n;i++){
			int p=i-1;
			int x=1;
			int mini=ok;

			while(1){
				if(p<1 || x>k)break;
				mini=min( abs(a[i]-a[p])+ hp[p] , mini );//abs(a[i]-a[i-(p-1)])+hp[i-(p-1)]);
				//cout<<i<<" "<<p<<" "<<mini;
				p--;
				x++;
				
				//cout<<endl;
			}
			//cout<<endl;
			hp[i]=mini;
	
	}
	cout<<hp[n];



	

}

 


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.Collectors;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();

        final List<List<Integer>> list = new ArrayList<>();
        list.add(new ArrayList<>());
        int mod = 1;
        for (int i = 1; i <= n; ) {
            list.get(0).add(i);
            final List<Integer> tmp = new ArrayList<>();
            tmp.add(i);
            list.add(tmp);
            final int last = list.size() - 1;
            for (int j = 1; j < mod; j++) {
                if (i + j > n) {
                    break;
                }
                list.get(j).add(i + j);
                list.get(last).add(i + j);
            }
            i += mod;
            mod++;
        }

        final long count = list.stream()
                .map(List::size)
                .distinct()
                .count();

        if (count == 1) {
            System.out.println("Yes");
            System.out.println(list.size());
            System.out.println(list.stream()
                    .map(l -> l.size() + " " + l.stream()
                            .map(i -> Integer.toString(i))
                            .collect(Collectors.joining(" ")))
                    .collect(Collectors.joining("\n"))
            );
        } else {
            System.out.println("No");
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

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


Measured memory_bytes: 49104
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,b;
  	ci(a>>b);
  co((a+b)%24)
}

Measured memory_bytes: 256
#include <stdio.h>

typedef long long ll;

void solve_142D();
ll GetGDC_ll(ll a, ll b); // ll な 最大公約数取得関数
int GetNumFactors(ll n); // 素因数の数を数える

ll A, B; // 入力の2数字, 制約:A, B <= 10^12 なので ll

void solve_142D()
{
  ll gdc = GetGDC_ll(A, B);
  int numFactors = GetNumFactors(gdc);
  printf("%d\n", numFactors + 1);
}

ll GetGDC_ll(ll a, ll b)
// ll な 最大公約数取得関数
{
  ll swap_tmp;
  if (a < b){ // 下の計算のために a > b にしておく
    swap_tmp = a; a = b; b = swap_tmp;
  }

  // ユークリッドの互除法により GDC を求める
  ll remainder = a % b;
  while (remainder != 0L){
    a = b; b = remainder; remainder = a % b;
  }
  return b;
}

int GetNumFactors(ll n)
// 素因数の数を数える
// 戻り値:素因数の数
// 内容や何乗かといった情報は返さない
{
  if (n == 1) return 0; // GDC が 1 の場合は 0 を返して終了

  int numFactors = 0;
  if (n % 2 == 0){ // 偶数の場合は numFactors を 1 にして 2 で割れるだけ割る
    numFactors = 1;
    while (1){
      n /= 2;
      if (n % 2 != 0) break;
    }
  }

  for (ll divisor = 3; divisor * divisor <= n; divisor += 2){
    if (n % divisor == 0){ // divisor で割れる場合は numFactors を +1 して divisor で割れるだけ割る
      ++numFactors;
      while (1){
        n /= divisor;
        if (n % divisor != 0) break;
      }
    }
  }
  if (n > 2)
    numFactors++;
  return numFactors;
}

int main()
{
  scanf("%lld %lld", &A, &B);

  solve_142D();

  return 0;
}


Measured memory_bytes: 128
S = input()
str1 = "keyence"
count = 0

for i in range(8):
  if(i != 7):
   str2 = S[:i] + S[-(7-i):]
  else:
   str2 = S[:i]
  #print(str2)
  if(str2 == str1):
   print("YES")
   count = 1
   break 
if(count != 1):
    print("NO")


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

int key=100;
int t;

int kiriage(int n){
	if(n%10==0){
		return n;
	}else{
		if(n%10<key){
			key=n%10;
			t = n;
		}
		return n - (n % 10) + 10;
	}
}

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

	int x;
	int ans=0;

	for (int i = 0; i < 5; i++) {
		cin>>x;
		ans += kiriage(x);
	}

	ans-=kiriage(t);
	ans += t;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

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

    int cnt_0 = 0, cnt_1 = 0;
    for(int i=0; i<s.length(); i++){
        if(s[i] == '0') cnt_0++;
        if(s[i] == '1') cnt_1++;
    }

    cout << min(cnt_0, cnt_1)*2 << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int n,m,i,j,s[100],d[100]={};
  int a,dr=0,er=0,e[100]={};
  char c,w;
  scanf("%d %d",&n,&m);
  while(m--){
    scanf(" %c %d",&c,&a);
    if(c=='D'){
      for(j=dr++;j&&d[j-1]<a;j--)d[j]=d[j-1];
      d[j]=a;
    }
  }
  scanf("%d",&m);
  while(m--){
    scanf(" %c%c %d",&c,&w,&a);
    if(c==w&&c=='D'){
      for(j=er++;j&&e[j-1]<a;j--)e[j]=e[j-1];
      e[j]=a;
    }
  }
  for(i=j=a=0;n>1;){//printf("%d %d %d %d %d\n",d[i],d[i+1],e[j],n,a);
    if(d[i]+d[i+1]>e[j]){
      a+=d[i++];
      n--;
    }
    else{
      a+=e[j++];
      n-=2;
    }
  }
  if(n)a+=d[i];
  printf("%d\n",a);
  return 0;
}
      

Measured memory_bytes: 600
import itertools
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
n = map(int, input().split())
a = list(map(int, input().split()))
result = a[0]
for x in a[1:]:
    result = gcd(result, x)
print(result)

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

#define M 1046527
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  else return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]){
    long long key, i, h;
    key = getKey(str);
    for ( i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if ( strcmp(H[h],str) == 0) return 1;
        else if (strlen(H[h]) == 0) return 0;
    }
}

int insert(char str[]){
    long long key, i, h;
    key = getKey(str);
    for ( i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if ( strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';

    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	    scanf("%s %s", com, str);
	
	    if ( com[0] == 'i' ){
	        insert(str);
	    } else {
            if (find(str)) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }
    return 0;
}


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

int main() {
  int N; cin>>N;
  vector<int> v(N);
  rep(i,N) cin>>v[i];
  sort(v.begin(),v.end());
  int sum=0;
  rep(i,N){
    if(i!=N-1) sum+=v[i];
    else sum+=v[i]/2;
  }
  cout<<sum<<endl;
}

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

int main(){
    int h,w;    cin >> h >> w;
    char table[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> table[i][j];
        }
    }

    int l[h][w],r[h][w],u[h][w],d[h][w];

    for(int i=0;i<h;i++){//l
        for(int j=0;j<w;j++){
            if(table[i][j] == '#'){
                l[i][j]=0;
            }else if(j == 0){
                l[i][j] = 1;
            }else{
                l[i][j] = l[i][j-1] + 1;
            }
        }
    }

    for(int i=0;i<h;i++){//r
        for(int j=w-1;j>=0;j--){
            if(table[i][j] == '#'){
                r[i][j]=0;
            }else if(j == w-1){
                r[i][j] = 1;
            }else{
                r[i][j] = r[i][j+1] + 1;
            }
        }
    }

    for(int i=0;i<h;i++){//u
        for(int j=0;j<w;j++){
            if(table[i][j] == '#'){
                u[i][j]=0;
            }else if(i == 0){
                u[i][j] = 1;
            }else{
                u[i][j] = u[i-1][j] + 1;
            }
        }
    }

    for(int i=h-1;i>=0;i--){
        for(int j=0;j<w;j++){
            if(table[i][j] == '#'){
                d[i][j]=0;
            }else if(i == h-1){
                d[i][j] = 1;
            }else{
                d[i][j] = d[i+1][j] + 1;
            }
        }
    }
    int ans=0;

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(ans < l[i][j]+r[i][j]+u[i][j]+d[i][j]-3){
                ans = l[i][j]+r[i][j]+u[i][j]+d[i][j]-3;
            }
        }
    }
    cout << ans << endl;

}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
int N;
cin >> N;
string S, T;
cin >> S >> T;

REP(i, N){
  string f = S.substr(i, N - i);
  string e = T.substr(0, N - i);
  if(f == e) {
    cout << N + i << endl;
    return 0;
  }

}

cout << 2 * N << endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int T,k,n,a,b,c,d;
int main(){
	scanf("%d",&T);
	while(T--){
		scanf("%d%d%d%d",&a,&b,&c,&d);n=a+b;
		int l=0,r=n+1,mid,A,B;k=(max(a,b)-1)/(min(a,b)+1)+1;;
		while(l<r){
			mid=(l+r)>>1;
			A=a-mid/(k+1)*k-mid%(k+1);B=b-mid/(k+1);
			if(B<=1ll*A*k)l=mid+1;else r=mid;
		}
		A=a-l/(k+1)*k-l%(k+1);B=b-l/(k+1);r=l+B-A*k+1;
		for(int i=c;i<=min(d,l);i++)putchar(i%(k+1)?'A':'B');
		for(int i=max(c,l+1);i<=d;i++)putchar((i-r)%(k+1)?'B':'A');
		puts("");
	}
	return 0;
}//ONION_CYC QwQ

Measured memory_bytes: 256