akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL =LONG_LONG_MAX;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    int A,B;cin>>A>>B;
    int Q;cin>>Q;
    vector<ll> s(A);cin>>s;
    vector<ll> t(B);cin>>t;
    vector<ll> sinv(s);reverse(all(sinv));
    vector<ll> tinv(t);reverse(all(tinv));
    rep(i,Q){
        ll x; cin>>x;
        

        auto sr = lower_bound(all(s),x);
        auto tr = lower_bound(all(t),x);
        auto sl = lower_bound(all(sinv),x,[](ll a, ll b){return a>b;});
        auto tl = lower_bound(all(tinv),x,[](ll a, ll b){return a>b;});
        
        ll srv,trv,slv,tlv;
        srv = *sr;trv=*tr;slv=*sl;tlv=*tl;
        if(sr==s.end()) srv = 1LL<<40;
        if(tr==t.end()) trv = 1LL<<40;
        if(sl==sinv.end()) slv = 1LL<<40;
        if(tl==tinv.end()) tlv = 1LL<<40;
        
        srv = abs(srv-x);slv = abs(slv-x);trv = abs(trv-x);tlv = abs(tlv-x);
        
        ll mindist = 1LL<<40;
        
        mindist = min(mindist,max(srv,trv));
        mindist = min(mindist,max(slv,tlv));
        mindist = min(mindist,slv*2+trv);
        mindist = min(mindist,slv+2*trv);
        mindist = min(mindist,srv*2+tlv);
        mindist = min(mindist,srv+2*tlv);
        
        cout<<mindist<<endl;
        
    }
    
    
    return 0;
}








Measured memory_bytes: 4480
#include<iostream>
using namespace std;
int main(){
	int m,k;
	cin>>m>>k;
	int n[m];
	for(int i=0;i<m;i++)
	cin>>n[i];
	for(int i=0;i<m-1;i++){
		for(int j=0;j<m-i-1;j++){
			if(n[j]<n[j+1]){
			int tmp=n[j];
			n[j]=n[j+1];
			n[j+1]=tmp;
			}
		}
	}
	int a=0;
	for(int i=0;i<k;i++){
		a+=n[i];
	}
	cout<<a;
	return 0;
}

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

int main(void)
{
	int N;
	int a, b, c;

	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> a >> b >> c;
		if(a * a + b * b == c * c || a * a + c * c == b * b || b * b + c * c == a * a){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.charAt(0) == '7' || s.charAt(1) == '7' || s.charAt(2) == '7') {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

int query(string s) {
	cout << "? " << s << '\n';
	cout.flush();
	int dis;
	cin >> dis;
	return dis;
}

int L;
string charset;
vector<string> strs;

string merge(int l, int r) {
	if (l == r) {
		return strs[l];
	}
	int mid = (l + r) >> 1;
	string sl = merge(l, mid);
	string sr = merge(mid + 1, r);
	string cur = "";
	int should = L - sl.length();
	int pr = 0, _pr = (signed) sr.size();
	for (int i = 0; i < (signed) sl.size(); i++) {
		while (pr < _pr && query(cur + sr[pr] + sl.substr(i)) == should - 1) {
			cur += sr[pr++];
			should--;
		}
		cur += sl[i];
	}
	while (pr < _pr) {
		cur += sr[pr++];
	}
	return cur;
}

int main() {
	for (int i = 0; i < 26; i++) {
		charset += (char) ('a' + i);
	}
	for (int i = 0; i < 26; i++) {
		charset += (char) ('A' + i);
	}
	for (int i = 0; i < 10; i++) {
		charset += (char) ('0' + i);
	}
	L = 0;
	for (int i = 0; i < 62; i++) {
		char c = charset[i];
		string s;
		int cnt;
		s.assign(128, c);
		L += (cnt = 128 - query(s));
		strs.push_back(s.substr(0, cnt));
	}
	string ans = merge(0, (signed) strs.size() - 1);
	cout << "! " << ans << '\n';
	cout.flush();
	return 0;
}


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

int main(){
  int n;cin>>n;
  int l[n];
  int sum=0;
  for(int i=0;i<n;i++){
    cin>>l[i];
    sum+=l[i];
  }
  int tmp=0;
  for(int i=0;i<n;i++){
    tmp=max(tmp,l[i]);
  }
  if((sum-tmp)>tmp){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

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

int main(){
	int a, b, c;
	int d;
	int n;

	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a >> b >> c;

		if (a > c){
			d = c;
			c = a;
			a = d;
		}
		if (b > c){
			d = c;
			c = b;
			b = d;
		}

		if (a*a + b*b == c*c){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3056
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] a = new int[N+1];
    long[] sum = new long[N+1];
    for (int i = 1; i <= N; i++) {
      a[i] = sc.nextInt();
      sum[i] = a[i]+sum[i-1];
    }
    List<Long> subSum = new ArrayList<>();
    for (int l = 1; l <= N; l++) {
      for (int r = l; r <= N; r++) {
        subSum.add(sum[r]-sum[l-1]);
      }
    }
    
    long ans = 0;
    boolean[] use = new boolean[subSum.size()];
    Arrays.fill(use, true);
    for (int b = 60; b >= 0; b--) {
      long mask = 1L << b;
      int count = 0;
      for (int i = 0; i < subSum.size(); i++) {
        if (use[i] && ((subSum.get(i)&mask) != 0)) {
         count++;
        }
      }
      
      if (count < K) continue;

      for (int i = 0; i < subSum.size(); i++) {
        if (use[i] && ((subSum.get(i)&mask) == 0)) {
          use[i] = false;
        }
      }
      
      ans += mask;
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 50784
#n = int(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))

#n = int(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))

x,y,z = map(int,input().split())

a = z
b = x
c = y

print("{} {} {}".format(a,b,c))

Measured memory_bytes: 2940
#include <cstdio>
#include <vector>
using namespace std;

typedef struct P {
	int p, d;
	bool operator<(const P &r) {
		return d < r.d;
	}
} P;
int n;;

int main(){
	int p, d1, d2;
	while (true) {
		scanf("%d", &n);
		if (n == 0) break;
		P m = { 0,-1 };
		P t;
		for (int i = 0; i < n; i++) {
			scanf("%d %d %d", &p, &d1, &d2);
			t = { p,d1 + d2 };
			if (m < t) {
				m = t;
			}
		}
		printf("%d %d\n", m.p, m.d);
	}

	return 0;
}

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

int main() {
int N; cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; ++i) cin >> a[i];
  int ans = 0;
  bool odd = false;
  while(true){
    for(int i = 0; i < N;++i){
      if(a[i] % 2 != 0) odd = true;
    }
    if(odd) break;
    for(int i = 0; i < N; ++i){
      a[i] /= 2;
    }
      ans++;
    
    
    
  }
  cout << ans << endl; 
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pi  3.14159265358979323846
#define mod 1000000007
#define pf push_front
#define pb push_back
#define flush fflush(stdout);
#define null NULL
#define test cout<<"#";
 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(null);
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes\n";
    else
    {
        cout<<"No\n";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string S,T;
  cin >> S >> T;
  int count=0;
  for(int i=0; i<3; i++){
    if(S.at(i)==T.at(i))
      count++;
  }
  cout << count << endl;
}


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

int main(void)
{
	int n;
	int i = 0;
	int ans = 0;
	int table[100000][3];
	int value[100000][3];
	
	scanf("%d",&n);
	while(i<n){
		scanf("%d%d%d",&table[i][0],&table[i][1],&table[i][2]);
		i++;
	}
	value[0][0] = table[0][0];
	value[0][1] = table[0][1];
	value[0][2] = table[0][2];
	i = 1;
	while(i<n){
		if(value[i-1][1] < value[i-1][2]){
			value[i][0] = value[i-1][2] + table[i][0];
		}else{
			value[i][0] = value[i-1][1] + table[i][0];
		}
		if(value[i-1][0] < value[i-1][2]){
			value[i][1] = value[i-1][2] + table[i][1];
		}else{
			value[i][1] = value[i-1][0] + table[i][1];
		}
		if(value[i-1][0] < value[i-1][1]){
			value[i][2] = value[i-1][1] + table[i][2];
		}else{
			value[i][2] = value[i-1][0] + table[i][2];
		}
		i++;
	}
	i = 0;
	while(i<3){
		if(ans < value[n-1][i])
			ans = value[n-1][i];
		i++;
	}

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

Measured memory_bytes: 4064
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let A: i64 = sc.get();
    let V: i64 = sc.get();
    let B: i64 = sc.get();
    let W: i64 = sc.get();
    let T: i64 = sc.get();
    if A == B {
        println!("YES");
        return;
    }
    if A < B {
        let a = A + V * T;
        let b = B + W * T;
        if b <= a {
            println!("YES");
        } else {
            println!("NO");
        }
    } else {
        let a = A - V * T;
        let b = B - W * T;
        if b >= a {
            println!("YES");
        } else {
            println!("NO");
        }
    }
}


Measured memory_bytes: 2108
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stack>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <deque>

#include <set>
#include <bitset>
#include<unordered_map>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
#define endl '\n'
#define exit(s) return cout<<s,0;
#define sz(s) (int)(s.size())
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(), s.rend()
#define watch(x) cout << (#x) << " = " << x << endl
#define DNT ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

ll getbit(int num, int idx)
{
	return (num >> idx) & 1;
}
ll setbit(int num, int idx)
{

	return num || (1 << idx);
}
ll leastBit(ll num) {
	return (num & -num);
}
int main() {
	ll n, a, b, c,x;
	cin >> n;
	if (n < 10)
	{
		cout << n << endl;
		return 0;
	}
	for (int i = n;; i++)
	{
		x = i;
		a = x % 10;
		x = x / 10;
		b = x % 10;
		x = x / 10;
		c = x % 10;

		if (a == b && b == c)
		{
			cout << i << endl;
			break;
		}
		
	}
	return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
int main()
{
    int n,x;
    cin >> n >> x;
    vector<int> d(n);
    rep(i,n){
        int a;
        cin >> a;
        d[i] = abs(x - a);
    }
    x = d[0];
    rep(i,n-1){
        x = __gcd(x, d[i+1]);
    }
    cout << x << endl;
}

Measured memory_bytes: 640
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
# ----------

INF = float("inf")
MOD = 10 ** 9 + 7
# ----------

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

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

if A[0] == A[1] == 1:
    print(0)
    exit()
if A[0] == 1:
    print(1)
    exit()


S = set()

for a in A:
    i = 2
    while a * i <= 10 ** 6:
        S.add(a * i)
        i += 1

ans = []
for a in A:
    if not a in S:
       ans.append(a)


D = defaultdict(int)
for a in ans:
    D[a] += 1

L = []
for k, v in D.items():
    if v > 1:
        continue
    L.append(k)


print(len(L))




Measured memory_bytes: 82716
#include <iostream>
#include <ctime>
#include <ctime>
#include <cstring>
using namespace std;
const int maxn = 1e3;
char s[maxn];
int main()
{
    cin >> s;
    char b[] = "YAKI";
    char c[5];
    c[0] = s[0];
    c[1] = s[1];
    c[2] = s[2];
    c[3] = s[3];
    c[4] = 0;
    if (strcmp(c, b) == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

int main(){
	int a;
	cin>>a;
	int c=0;
	int d=0;
	for(int i=0;i<a;i++){
		int b[10];
		cin>>b[i];
		c=max(c,b[i]);
		d=d+b[i]; 
	}
	int e=d-c;
	if(e>c){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}


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

void fnInput(int& rnTrgSu, int& rnTrgKin)
{
  cin >> rnTrgSu >> rnTrgKin;
}

int fnRcsSch(int nPos, int nTrgSu, int nTrgKin, vector<int>& rvnMoneyCnt)
{
  const vector<int> cnvnMoney{10000, 5000, 1000};

  if (nTrgSu == 0 && nTrgKin == 0)  return  1;
  if (nTrgKin <  0)                 return -1;
  if (nPos == rvnMoneyCnt.size())   return  0;

  if (nPos == rvnMoneyCnt.size() - 1)
  {
    rvnMoneyCnt[nPos] = nTrgSu;
    return fnRcsSch(nPos + 1, 0, nTrgKin - cnvnMoney[nPos] * nTrgSu, rvnMoneyCnt);
  }
  else
    for (int i = 0; i <= nTrgSu; i++)
    {
      rvnMoneyCnt[nPos] = i;
      for (int i = nPos + 1; i < rvnMoneyCnt.size(); i++)
        rvnMoneyCnt[i] = 0;

      int nRslt = fnRcsSch(nPos + 1, nTrgSu - i, nTrgKin - cnvnMoney[nPos] * i, rvnMoneyCnt);
      if      (nRslt ==  1)  return 1;
      else if (nRslt == -1)  break;
    }

  return 0;
}

int fnExhSch(int nTrgSu, int nTrgKin)
{
  vector<int> vnMoneyCnt(3);

  if (fnRcsSch(0, nTrgSu, nTrgKin, vnMoneyCnt))
  {
    for (int i = 0; i < vnMoneyCnt.size(); i++)
    {
      if ( i )  cout << " ";
      cout << vnMoneyCnt[i];
    }
    cout << endl;
  }
  else
    cout << -1 << " " << -1 << " " << -1 << endl;
}

int main()
{
  int nTrgSu, nTrgKin;
  
  fnInput(nTrgSu, nTrgKin);
  fnExhSch(nTrgSu, nTrgKin);

  return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<algorithm>
#include <stdint.h>
#include <math.h>

using namespace std;
const int INF = (1<<31) - 1;
class segment_tree {
private:
	int n;
	vector<int> node;
public:
	//元配列をセグメント木で表現する
	segment_tree(vector<int>v) {
		
		int sz = v.size();
		//最下段のノード数は元配列のサイズ以上になる最小の2冪->これをnとおく
		n = 1;
		while (n < sz) {
			n *= 2;
		}
		node.resize(2 * n - 1, INF);
		//最下段を初期化
		for (int i = 0; i < sz; i++) {
			node[i + n - 1] = v[i];
		}
		//親の値を決めていく
		for (int i = n - 2; i >= 0; i--) {
			node[i] = min(node[2 * i + 1], node[2 * i + 2]);
		}
	}

	void update(int x, int val) {
		x += (n - 1);
		node[x] = val;
		while (x > 0) {
			x = (x - 1) / 2;
			node[x] = min(node[2 * x + 1], node[2 * x + 2]);
		}
	}
	//[a,b)の最小値を求める
	//k番目のノード　範囲は[l,r)
	int query(int a, int b, int k=0, int l=0, int r=-1) {
		if (r < 0) {
			r = n;
		}
		if (r <= a || b <= l)
		{
			return INF;
		}
		if (a <= l && r <= b)
		{
			return node[k];
		}
		else
		{
			int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return min(vl, vr);
		}
	}

};

int main() {
	int N;
	int Q;
	cin >> N >> Q;
	segment_tree seg(vector<int>(N, INF));
	for (int i = 0; i < Q; i++) {
		int c, x, y;
		cin >> c >> x >> y;
		if (c == 0) {
			seg.update(x, y);
		}
		else {
			cout << seg.query(x, y + 1) << endl;
		}
	}
}








Measured memory_bytes: 4144
import java.util.*;
public class Main {
	static boolean[][] map;
	static HashMap<Integer,Pair> hm = new HashMap<Integer,Pair>();
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int n = stdIn.nextInt();
			map = new boolean[1024][1024];
			if(n == 0) break;
			map[500][500] = true;
			hm.put(0, new Pair(500,500));
			int ymax = 500;
			int ymin = 500;
			int xmax = 500;
			int xmin = 500;
			for(int i = 1; i < n; i++) {
				int c = stdIn.nextInt();
				int d = stdIn.nextInt();
				Pair tmp = hm.get(c);
				if(d == 0) {
					map[tmp.y][tmp.x-1] = true;
					hm.put(i, new Pair(tmp.x-1,tmp.y));
					if(xmin > tmp.x-1) xmin = tmp.x-1;
				}
				if(d == 1) {
					map[tmp.y+1][tmp.x] = true;
					hm.put(i, new Pair(tmp.x,tmp.y+1));
					if(ymax < tmp.y+1) ymax = tmp.y+1;
				}
				if(d == 2) {
					map[tmp.y][tmp.x+1] = true;
					hm.put(i, new Pair(tmp.x+1,tmp.y));
					if(xmax < tmp.x+1) xmax = tmp.x+1;
				}
				if(d == 3) {
					map[tmp.y-1][tmp.x] = true;
					hm.put(i, new Pair(tmp.x,tmp.y-1));
					if(ymin > tmp.y-1) ymin = tmp.y-1;
				}
			}
			int xlen = xmax+1 - xmin;
			int ylen = ymax+1 - ymin;
			System.out.println(xlen + " " + ylen);
		}
	}
}

class Pair{
	public int x;
	public int y;
	public Pair(int a, int b) {
		x = a;
		y = b;
	}
}

Measured memory_bytes: 60340
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  string s; cin >> s;
  int n=s.size();
  vector<string> v(0);
  for(int i=0;i<n;i++){
    string t;
    t+=s[i];
    if(i+1<n&&v.size()>0&&t==v[v.size()-1]){
      t+=s[i+1];
      i++;
    }
    v.push_back(t);
  }
  int ans=v.size();
  if(v[v.size()-1]==v[v.size()-2]) ans--;
  cout << ans << endl;
}

Measured memory_bytes: 10996
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int a, b;
  cin >> a >> b;
  if(a+b >= 10) cout << "error" << endl;
  else cout << a+b << endl;
  return 0;
}


Measured memory_bytes: 3620
def solve():
    N = int(input())
    A = []
    B = []
    for i in range(N):
        a, b = map(int,input().split())
        A.append(a)
        B.append(b)
    
    A.sort()
    B.sort(reverse=True)

    if N % 2 == 0:
        tmp = (B[N//2]+B[N//2-1])/2 - (A[N//2]+A[N//2-1])/2
        print(int(tmp / 0.5)+1)
    else:
        print(B[N//2] - A[N//2] + 1)
    
if __name__ == '__main__':
    solve()

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

using namespace std;

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

  deque<string> ws;
  deque<string>::iterator it;
  bool nodup = true;

  for (int i = 0; i < n; i++)
  {
    string w;
    cin >> w;
    if (find(ws.begin(), ws.end(), w) == ws.end())
    {
      ws.push_back(w);
    }
    else
    {
      nodup = false;
    }
  }

  bool shiritoriSafe = true;
  for (int i = 1; i < ws.size(); i++)
  {
    string word = ws[i];
    string prevWord = ws[i - 1];

    char head = word[0];
    char tail = prevWord[prevWord.size() - 1];

    if (head != tail)
    {
      shiritoriSafe = false;
    }
  }

  cout << (shiritoriSafe && nodup ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
s,t=0,0
if len(a)%2==1:
    a.append(0)
for i in range((len(a)+1)//2):
    s+=a[2*i]
    t+=a[2*i+1]
print(s-t)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}
int main(){
  fastIO();
  ll l,r;
  cin>>l>>r;
  ll best = 2019;
  if(r-l+1<2019){
  	for(ll i=l;i<=r;i++){
  		for(ll j=l;j<=r;j++){
  			if(i!=j){
  				best=min(best,(i*j)%2019);
  			}
  		}
  	}
  }else{
  	best=0;
  }
  cout<<best<<endl;
}  



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll N = 2019;
  ll L,R;cin >> L >> R;
  ++R;
  ll minimum = 2018;
  repp(i,L,min(L+N,R)){
    repp(j,i+1,min(i+1+N,R)){
      minimum = min((i%N * j%N)%N, minimum);
    }
  }
  cout << minimum << endl;
  return 0;
}


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

using namespace std;

int main() {
  long long a, b, n;
  cin >> a >> b >> n;

  long long num = min(b - 1, n);
  long long ans = (long long)(a * num / b) - a * (long long)(num / b);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3152
#include<stdio.h>
int main(){
	int i,a,b,c,sum=0;
	
	scanf("%d %d %d",&a,&b,&c);
	if(1<=a && 1<=b && 1<=c && a<=10000 && b<=10000 && c<=10000){
	if(a<=b){
		for(i=1;i<=c;i++){
			if(c%i==0){
				if(a<=i && i<=b) 
					sum++;
			}
		}
	}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 1820
#include <algorithm>
#include <cstdio>
#include <cstring>

const int N = 100;

int n, m, rs[N + 1][N + 1], cs[N + 1][N + 1], dp[51 * 51 * 51 * 51];
char g[N][N + 1];

void update(int& x, int a)
{
    x = std::max(x, a);
}

int get_row(int x, int l, int r)
{
    return l <= r ? rs[x][l] - rs[x][r + 1] : 0;
}

int get_col(int y, int u, int d)
{
    return u <= d ? cs[u][y] - cs[d + 1][y] : 0;
}

int main()
{
#ifdef LOCAL_JUDGE
    freopen("E.in", "r", stdin);
#endif
    scanf("%d%d", &n, &m);
    int ex, ey;
    for (int i = 0; i < n; ++ i) {
        scanf("%s", g[i]);
        for (int j = 0; j < m; ++ j) {
            if (g[i][j] == 'E') {
                ex = i, ey = j;
            }
        }
    }
    for (int i = n - 1; i >= 0; -- i) {
        for (int j = m - 1; j >= 0; -- j) {
            int v = g[i][j] == 'o';
            rs[i][j] = rs[i][j + 1] + v;
            cs[i][j] = cs[i + 1][j] + v;
        }
    }
    int result = 0;
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;
    int state = 0;
    int stride[] { (ey + 1) * (m - ey) * (ex + 1), (ey + 1) * (m - ey), ey + 1, 1};
    for (int u = 0; u < n - ex; ++ u) {
        for (int d = 0; d <= ex; ++ d) {
            for (int l = 0; l < m - ey; ++ l) {
                for (int r = 0; r <= ey; ++ r) {
                    if (~dp[state]) {
                        update(result, dp[state]);
                        if (r + 1 <= ey && l <= ey - (r + 1)) {
                            update(dp[state + stride[3]], get_col(ey - (r + 1), std::max(ex - d, u), std::min(ex + u, n - 1 - d)) + dp[state]);
                        }
                        if (l + 1 < m - ey && ey + (l + 1) <= m - 1 - r) {
                            update(dp[state + stride[2]], get_col(ey + (l + 1), std::max(ex - d, u), std::min(ex + u, n - 1 - d)) + dp[state]);
                        }
                        if (d + 1 <= ex && u <= ex - (d + 1)) {
                            update(dp[state + stride[1]], get_row(ex - (d + 1), std::max(ey - r, l), std::min(ey + l, m - 1 - r)) + dp[state]);
                        }
                        if (u + 1 < n - ex && ex + (u + 1) <= n - 1 - d) {
                            update(dp[state + stride[0]], get_row(ex + (u + 1), std::max(ey - r, l), std::min(ey + l, m - 1 - r)) + dp[state]);
                        }
                    }
                    state ++;
                }
            }
        }
    }
    printf("%d\n", result);
}


Measured memory_bytes: 26752
/* Coached by rainboy */
#include <stdio.h>

#define N 52

int main() {
	static char s1[N + 1], s2[N + 1];
	int n, i;
	long long ans;

	scanf("%d%s%s", &n, s1, s2);
	ans = 1;
	for (i = 0; i < n; ) {
		if (s1[i] == s2[i]) {
			if (i == 0)
				ans *= 3;
			else if (i > 0 && s1[i - 1] == s2[i - 1])
				ans *= 2;
			i++;
		} else {
			if (i == 0)
				ans *= 6;
			else if (i > 0 && s1[i - 1] == s2[i - 1])
				ans *= 2;
			else
				ans *= 3;
			i += 2;
		}
		ans %= 1000000007;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>
#include <ctime>

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;

const int INF = 1001001001;
const ll INFLL = 1001001001001001001LL;


template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }




int main() {
	srand(time(NULL));
//Prepare
	int N;
	int A,B,C,D;
//
	int K;
	string Buf;
	string Buf2;

	cin >> Buf;
	scanf("%d", &K);

	char cMin = 'z';
	for (int i = 0; i < Buf.size(); ++i) {
		chmin(cMin, Buf[i]);
	}

	vector<string> sv;
	int num = 0;
	while (sv.size() < min(K,5)) {

		for (int i = 0; i < Buf.size(); ++i) {
			if (Buf[i] == cMin) {
				for (int j = 1; j <= 5; j++) {
					Buf2 = Buf.substr(i, j);
					sv.push_back(Buf2);
				}
			}
		}
		sort(sv.begin()+num, sv.end());
		sv.erase(unique(sv.begin()+num, sv.end()),sv.end());
		
		num = sv.size();
		cMin++;
	}

	sort(sv.begin(), sv.end());
	unique(sv.begin(), sv.end());



	cout << sv[K-1];


	return 0;
}



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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
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; }

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

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int r, g, b, n; cin >> r >> g >> b >> n;
  int ans = 0;
  for(int i=0; i<=n/r; i++) {
    for(int j=0; j<=n/g; j++) {
      int res = n - i*r - j*g;
      if (res >= 0 && res%b == 0) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

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

#define int long long

int N, K;
vector<int> G[100001];
int ans = 1;
const int MOD = 1e9+7;

void dfs(int v, int d, int k, int p) {
  // cout << v << " " << k << endl;
  ans *= k;
  ans %= MOD;
  int now = K;
  if ( d == 0 ) now--;
  if ( d >= 1 ) now -= 2;  
  for ( int u : G[v] ) {
    if ( u == p ) continue;
    dfs(u, d+1, now--, v);    
  }
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> K;
  for ( int i = 0; i < N-1; i++ ) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  int ma = 0;
  for ( int i = 0; i < N; i++ ) {
    int sum = 0;
    for ( int j : G[i] ) sum += G[j].size();
    if ( sum >= N ) {
      // cout << 0 << endl;
      // return 0;      
    }
  }

  dfs(0, 0, K, -1);  

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


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
void *wmem;
template<class T1, class T2> void sortA_L(int N, T1 a[], T2 b[], void *mem = wmem){
  int i;
  pair<T1, T2> *arr=(pair<T1, T2> *) mem;
  for(i=0;i<N;i++){
    arr[i].first = a[i],
    arr[i].second = b[i];
  }
  sort(arr, arr+N);
  for(i=0;i<N;i++){
    a[i] = arr[i].first,
    b[i] = arr[i].second;
  }
}
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1,
    x=-x;
  }
  while(x){
    f[s++]=x%10,
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class T> void Unique_L(int &N, T A[], int sorted=0){
  int i, k;
  if(!sorted){
    sort(A, A+N);
  }
  k = 0;
  for(i=0;i<N;i++){
    if(k==0 || A[k-1]!=A[i]){
      A[k++] = A[i];
    }
  }
  N = k;
}
template<class T, class S> void Unique_L(int &N, T A[], S B[], int sorted=0){
  int i, k=0;
  if(!sorted){
    sortA_L(N, A, B);
  }
  for(i=0;i<N;i++){
    if(!k || A[k-1]!=A[i]){
      A[k] = A[i];
      B[k] = B[i];
      k++;
    }
    else{
      B[k-1] += B[i];
    }
  }
  N=k;
}
char memarr[64000000];
int A[100000], N, c[100000];
int main(){
  int i, res=0;
  wmem = memarr;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY;
    for(KL2GvlyY=0;KL2GvlyY<(N-1) + 1;KL2GvlyY++){
      c[KL2GvlyY] = 1;
    }
  }
  Unique_L(N, A, c);
  for(i=0;i<N;i++){
    if(c[i]%2){
      res++;
    }
  }
  wt_L(res);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20170910-1

// --- original code ---
// int N, A[100000], c[100000];
// {
//   int i, res = 0;
//   rd(N,A(N));
//   c[0..N-1] = 1;
//   Unique(N, A, c);
//   rep(i,N) if(c[i]%2) res++;
//   wt(res);
// }


Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<unordered_map>

using namespace std;

#define pa pair<int,int>
#define sc(n) scanf("%d",&n)
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define mem(a,b) memset(a,b,sizeof a)

const  int N = 1e6 + 5;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;

typedef long long ll;
typedef long double ld;

int t, n, m;
int a[N];

int main()
{
	cin >> t >> n >> m;
	cout << min(n*t, m) << endl;
	return 0;
}

Measured memory_bytes: 256
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

bingo = 'No'

for t in zip(*a):
    a.append(list(t))

a.append([a[i][i] for i in range(3)])
a.append([a[i][2-i]for i in range(3)])

for line in a:
    if all(item in b for item in line):
        bingo = 'Yes'
        break

print(bingo)



Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(c+a,min(a+b,b+c))<<endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main()
{
    int n, m, l;
    cin >> n >> m >> l;
    int a[n][m];
    int b[m][l];

    long long re[n][l];
    rep(i, n)
    {
        rep(j, l)
        {
            re[i][j] = 0;
        }
    }

    rep(i, n)
    {
        rep(j, m)
        {
            cin >> a[i][j];
        }
    }

    rep(i, m)
    {
        rep(j, l)
        {
            cin >> b[i][j];
        }
    }

    rep(i, n)
    {
        rep(j, l)
        {
            rep(k, m)
            {
                re[i][j] += a[i][k] * b[k][j];
            }
        }
    }

    rep(i, n)
    {
        rep(j, l)
        {
            if (j != 0)
            {
                cout << " ";
            }
            cout << re[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3240
#include<stdio.h>
#define INF (1<<30)-1
int main(){
  int n;
  scanf("%d",&n);
  int s[n];
  int i,j,c=INF;
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
    if(s[i]<c) c = s[i];
  }
  for(i=1;i<=c;i++){
    int ok = 0;
    for(j=0;j<n;j++) if(s[j]%i!=0) ok = 1;
    if(ok == 0) printf("%d\n",i);
  }
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  int n;
  cin >> n;
  vector<int> h(n);
  REP(i,n) cin >> h[i];
  
  bool f = false;
  int ans = 0;
  while(!f){
    f = true;
    if(h[n - 1] != 0) {
      ans++;
    }
    REP(i, n - 1){
      if(h[i] != 0){
        h[i]--;
        if(h[i + 1] == 0){
          ans++;
        }
      }
    }
    if(h [n - 1] != 0) h[n - 1]--;
    REP(i, n) f &= h[i] == 0;
  }

  cout << ans << endl;

  return 0;
}

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

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int a[100005];
int main(void)
{
    int n,cnt=0,sum=0;
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<=n+1;i++)
    {
        if(a[i]!=a[i-1])
        {
            if(cnt%2)
                sum++;
            cnt=1;
        }
        else cnt++;
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 640
import java.util.*;
import java.math.*;
public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    //static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] ary = new int[n];
        for(int i = 0;i < n;i++){
            ary[i] = sc.nextInt();
        }
        int ans = 0;
        for(int i = 0;i < n-2;i++){
            if(ary[i] < ary[i+1]&&ary[i+1] < ary[i+2])ans++;
            if(ary[i] > ary[i+1]&&ary[i+1] > ary[i+2])ans++;
        }
        System.out.println(ans);
    }       
}






Measured memory_bytes: 23764
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <tuple>

using namespace std;

typedef std::tuple<int, int, int> mytuple;

// ?????????????????????????´?????????????????????????????????????????´?????????????????¬????????´???§??????
bool mycompare( const mytuple &lhs, const mytuple &rhs )
{
    if (std::get<0>(lhs) != std::get<0>(rhs)) return std::get<0>(lhs) > std::get<0>(rhs);
    if (std::get<1>(lhs) != std::get<1>(rhs)) return std::get<1>(lhs) > std::get<1>(rhs);
    return std::get<2>(lhs) > std::get<2>(rhs);
}

int main()
{
    //??????, ?¨????, ????????????????????????
    int n, m, a;
    
    while (cin >> n >> m >> a, n)
    {
        vector<mytuple> amida(m);
        int h, p, q;
        
        for (int i = 0; i < m; i++)
        {
            cin >> h >> p >> q;
            amida[i] = make_tuple(h, p, q);
        }
        sort(amida.begin(), amida.end(), mycompare);
        for (int i = 0; i < m; i++)
        {
            if(get<1>(amida[i]) == a ){
                a = get<2>(amida[i]);
            }
            else if(get<2>(amida[i]) == a){
                a = get<1>(amida[i]);
            }
        }
        cout << a << endl;
    }
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
ll maax(ll a,ll b){
    if(a>b)return a;
    else return b;
}
int main(void){
    ll n,maxw;cin>>n>>maxw;
    vector<ll>pr(n),we(n);
    rep(i,n)cin>>we[i]>>pr[i];
    vector<vector<ll>>dp(n+1,(vector<ll>(maxw+1,-1)));
    dp.at(0).at(0)=0;
    rep(i,n){
        rep(j,maxw+1){
            if(dp.at(i).at(j)!=-1){
                dp.at(i+1).at(j)=maax(dp.at(i+1).at(j),dp.at(i).at(j));
                if(j+we.at(i)<=maxw)dp.at(i+1).at(j+we.at(i))=maax(dp.at(i).at(j)+pr.at(i),dp.at(i).at(j+we.at(i)));
            }
        }
    }
    ll ans=0;
    rep(i,maxw+1){
        ans=maax(ans,dp.at(n).at(i));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 80256
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);
    
    public static void main(String[] args) {
        int[] n = new int[4];
        for(int i = 0; i < 4; ++i) n[i] = sc.nextInt();
        Arrays.sort(n);
        int[] m = {1, 4, 7, 9};
        String ans = (Arrays.equals(n, m)) ? "YES" : "NO";
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
N, T = map(int, input().split())
T -= 1
Meals = sorted([list(map(int, input().split())) for i in range(N)])
dp = [[0] * (T + 1) for i in range(N + 1)]
prev = [[-1] * (T + 1) for i in range(N + 1)]


for i, (cost, value) in enumerate(Meals):
    for j in range(T + 1):
        if j >= cost:
            if dp[i + 1][j] <= dp[i][j - cost] + value:
                dp[i + 1][j] = dp[i][j - cost] + value
                prev[i + 1][j] = j - cost

        if dp[i + 1][j] <= dp[i][j]:
            dp[i + 1][j] = dp[i][j]
            prev[i + 1][j] = j

# 復元
selected = set()
cur_w = T
for i in range(N - 1, -1, -1):
    if prev[i + 1][cur_w] == cur_w - Meals[i][0]:
        selected.add(i)
    cur_w = prev[i + 1][cur_w]

non_selected = set(list(range(N))) - selected
ans = dp[N][T]
add = 0
for ni in non_selected:
    add = max(add, Meals[ni][1])

print(dp[N][T] + add)


Measured memory_bytes: 178820
while True :
    i = int(input())
    a = 0
    if i == 0 :
        break
    else :
        b = 1000 - i
        
        if b >= 500 :
            a += 1
            b -= 500
        
        while b >= 100 :
            a += 1
            b -= 100
        
        while b >= 50 :
            a += 1
            b -= 50
            
        while b >= 10 :
            a += 1
            b -= 10
            
        while b >= 5 :
            a += 1
            b -= 5
            
        a += b   
    
    print(a)


Measured memory_bytes: 5584
process.stdin.resume();
process.stdin.setEncoding("utf8");

const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

const lines = [];

reader.on("line", (line) => {
  lines.push(line);
});

const compare = (lhs, rhs) => {
  const [l, r] = [lhs[1], rhs[1]];
  return l < r ? -1 : l > r ? 1 : 0;
};

const bubbleSort = (a) => {
  a = a.slice();
  const len = a.length;
  for (let i = 0; i < len; i++) {
    for (let j = len - 1; j > i; j--) {
      if (compare(a[j], a[j - 1]) < 0) {
        const t = a[j];
        a[j] = a[j - 1];
        a[j - 1] = t;
      }
    }
  }
  return a;
};

const selectionSort = (a) => {
  a = a.slice();
  const len = a.length;
  for (let i = 0; i < len; i++) {
    let minj = i;
    for (let j = i; j < len; j++) {
      if (compare(a[j], a[minj]) < 0) {
        minj = j;
      }
    }
    const t = a[i];
    a[i] = a[minj];
    a[minj] = t;
  }
  return a;
};

const isStable = (a1, a2) => {
  let isEq = true;
  Array(9)
    .fill()
    .map((e, i) => "" + (i + 1))
    .map((e) => {
      if (!isEq) return;

      const aa1 = a1.reduce((p, card) => {
        if (card[1] === e) {
          p.push(card[0]);
        }
        return p;
      }, []);
      const aa2 = a2.reduce((p, card) => {
        if (card[1] === e) {
          p.push(card[0]);
        }
        return p;
      }, []);
      for (let i = 0; i < aa1.length; i++) {
        if (aa1[i] !== aa2[i]) {
          isEq = false;
          break;
        }
      }
    });

  return isEq;
};

reader.on("close", () => {
  let ns = lines[1].split(" ");
  const a1 = bubbleSort(ns);
  const a2 = selectionSort(ns);
  console.log(a1.join(" "));
  console.log(isStable(a1, ns) ? "Stable" : "Not stable");
  console.log(a2.join(" "));
  console.log(isStable(a2, ns) ? "Stable" : "Not stable");
});



Measured memory_bytes: 16824
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
    char c[4];
    scanf("%s",c);
    int a=(c[0]-'0')*10+c[1]-'0';
    int b=(c[2]-'0')*10+c[3]-'0';
    if(a<=12&&b<=12&&a>0&&b>0){
        cout << "AMBIGUOUS" << endl;
    }
    else if(a<=12&&a>0)
    {
        cout <<"MMYY"<<endl;
    }
    else if(b<=12&&b>0)
    {
        cout <<"YYMM"<<endl;
    }
    else{cout << "NA" <<endl;}
    return 0;
}


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

void solve(std::string C)
{
    cout << static_cast<char>(C[0] + 1) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string C;
    std::cin >> C;
    solve(C);
    return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


void main() {
    writeln(readln.chomp.split.map!(to!int).array.sort().take(2).reduce!"a * b" / 2);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
 
using namespace std;
const int INF = 1e9 + 5;
int main(){
    int n; cin >> n;
    map<int, int> m;
    vector<int> v(n);
    long long cnt = 0;
    for(int i = 0; i < n; i++) {
        cin >> v[i];
        cnt += m[i - v[i]];
        m[v[i] + i]++;
    }
    cout << cnt;
    return 0;
}

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

using namespace std;

bool ar[26][2000000];

void up(int c, int r, int l1, int l2, int q, bool ve){
	if(l1==l2){
		ar[c][r]=ve;
		return;
	}
	int m = (l1+l2)/2;
	if(q<=m)up(c,r<<1,l1,m,q,ve);
	else up(c,(r<<1)|1, m+1, l2, q,ve);
	ar[c][r] = ar[c][r<<1]||ar[c][(r<<1)|1];
}

bool qu(int c, int r, int l1,int l2, int q1, int q2){
	if(q2<l1||q1>l2)return false;
	if(q1<=l1&&q2>=l2)return ar[c][r];
	int m = (l1+l2)/2;
	return qu(c,r<<1,l1,m,q1,q2)||qu(c,(r<<1)|1, m+1, l2, q1, q2);
}

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	int n,q;
	string s;
	cin>>n>>s>>q;
	for(int i=0;i<n;i++){
		up((int)(s[i]-'a'), 1, 0, n-1, i, true);
	}
	int v, l,r,i;
	char c;
	while(q--){
		cin>>v;
		if(v==1){
			cin>>i>>c;
			i--;
			up((int)(s[i]-'a'),1,0,n-1,i,false);
			up((int)(c-'a'),1,0,n-1,i,true);
			s[i]=c;
		}
		else{
			cin>>l>>r;
			l--;r--;
			int res =0;
			for(int i=0;i<26;i++){
				if(qu(i,1,0,n-1,l,r))res++;
			}
			cout<<res<<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 49912
import sys
from io import StringIO
import unittest
import os
import math

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


# 実装を行う関数
def resolve(test_def_name=""):
    a, b, c, d = map(int, input().split())

    ans = b - a + 1

    all_cnt = -(b // c + b // d) + b // (lcm(c, d))
    out_cnt = -((a - 1) // c + (a - 1) // d) + (a - 1) // (lcm(c, d))

    print(ans + all_cnt - out_cnt)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """4 9 2 3"""
        output = """2"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """10 40 6 8"""
        output = """23"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """314159265358979323 846264338327950288 419716939 937510582"""
        output = """532105071133627368"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 75448