akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
 string S,T;
  cin >> S >> T;
  int K = S.size();
  bool ans = true;
  for(int i = 0; i < K; i++) {
    if(S.at(i) != T.at(i) ) {
      ans = false;
      break;
    }
  }
  if(ans) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1000 + 5;
int dp[N][N];
char grid[N][N];
int h, w;
const ll mod = 1e9 + 7;

void self_add(int &a, int b) {
    a += b;
    if (a >= mod)
        a -= mod;
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> h >> w;
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            cin >> grid[i][j];
    dp[0][0] = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (!i && !j)
                continue;
            if (grid[i][j] == '#')
                continue;
            if (i)
                self_add(dp[i][j], dp[i - 1][j]);
            if (j)
                self_add(dp[i][j], dp[i][j - 1]);
        }
    }
    cout << dp[h - 1][w - 1];
    return 0;
}


Measured memory_bytes: 5120
using System;

namespace ResistorsInParallel
{
    class Program
    {
        static void Main(string[] args)
        {
            int s = int.Parse(Console.ReadLine());
            String[] a = Console.ReadLine().Split(' ');
            float[] aa = new float[s];
            float sum = 0;
            

            for(int b = 0; b < s; b++){
                aa[b] = float.Parse(a[b]);
            }

            for(int b = 0; b < s; b++){
                sum += (1 / aa[b]);
            }

            
            Console.WriteLine(1 / sum);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
using namespace std;
int main(){
        string s;
        int n,i,a,z=0;
        cin >> s;
        n = s.size();
        for(i=0; i<n; i++) {
                if(s[i] == 'A') {
                        a = i+1;
                        break;
                }
        }
        for(i=n; i>=0; i--) {
                if(s[i] == 'Z') {
                        z = i+1;
                        break;
                }
        }
        cout << z - a + 1 <<endl;
}


Measured memory_bytes: 640
#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()

using namespace std;
typedef long long ll;

template<typename T>
T gcd(T a, T b) {
	if (a % b == 0) {
		return(b);
	}
	else {
		return(gcd(b, a % b));
	}
}

template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}

int main(void) {
	string s;
	int k;
	cin >> k >> s;
	if (s.length() <= k) {
		cout << s;
	}
	else {
		for (int i = 0; i < k; ++i) {
			cout << s[i];
		}
		cout << "...";
	}
}

/*

*/


Measured memory_bytes: 3628
N,A,B,C,D = map(int,input().split())
S = list(input())
S.append('.')
A -=1
B -=1
C -=1
D -=1

if C > D:
  if '##' not in ''.join(S[A+1:C]) and '##' not in ''.join(S[B+1:D]) and '...' in ''.join(S[B-1:D+2]):
    print('Yes')
  else:
    print('No')
else:
  if '##' not in ''.join(S[A+1:C]) and '##' not in ''.join(S[B+1:D]):
    print('Yes')
  else:
    print('No')
  

Measured memory_bytes: 6388
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

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

using namespace std;

int main() {
    int p, q, r;
    cin >> p >> q >> r;
    cout << p + q + r - max(p, max(q, r)) << endl;
    return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    # ??????????????\???
    num = int(input())
    triangles = []
    for i in range(num):
        triangles.append([int(x) for x in input().split(' ')])

    # ??´?§?????§???¢?????????????????????
    results = []
    for t in triangles:
        t.sort()
        if t[0]**2 + t[1]**2 == t[2]**2:
            results.append('YES')
        else:
            results.append('NO')

    # ???????????????
    for r in results:
        print(r)

Measured memory_bytes: 7852
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=1000005;
#define M 1000000007
#define double long double
#define BINF 100000000000000001
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 15000001
#define deb(x) cout << #x << " " << x << endl;
const int LG = 22;



#undef int 
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);
    
    int ans = BINF;
    int n;
    cin >> n;
    for(int i = 1; i  * i <= n; i++){
        if(n % i == 0){
            ans = min(ans, i + n / i - 2);
        }
    }
    cout << ans << endl;


    
return 0;  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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


int main() {
  while(1){
    queue<pair<int,int>> que;
    int w,h; cin >> w >> h;
    if(w==0 && h==0) break;
    int length[h][w];
    FOR(i,0,h-1){
      FOR(j,0,w-1){
        length[i][j] = INF;
      }
    }
    bool ver[h][w];
    bool par[h][w];
    FOR(i,1,2*h-1){
      if(i%2==1){
        FOR(j,0,w-2){
          bool c; cin >> c;
          ver[(i-1)/2][j] = c;
        }
      } else {
        FOR(j,0,w-1){
          bool c; cin >> c;
          par[(i-2)/2][j] = c;
        }
      }
    }
    que.push(MP(0,0));
    length[0][0] = 1;
    while(!que.empty()){
      int ny,nx;
      Edge p = que.front();
      que.pop();
      FOR(i,0,3){
        ny = p.first + dy[i];
        nx = p.second + dx[i];
        if(ny<0 || nx<0 || ny>=h || nx>=w || length[ny][nx]!=INF) continue;
        if(dy[i]==1 && par[p.first][p.second]) continue;
        if(dy[i]==-1 && par[p.first-1][p.second]) continue;
        if(dx[i]==1 && ver[p.first][p.second]) continue;
        if(dx[i]==-1 && ver[p.first][p.second-1]) continue;

        que.push(MP(ny,nx));
        length[ny][nx] = length[p.first][p.second] + 1;
      }
    }
    if(length[h-1][w-1]==INF) cout << 0 << endl;
    else cout << length[h-1][w-1] << endl;
  }

}



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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  vector<bool> hurui(1300000,true);
  hurui[0]=hurui[1]=false;
  repp(i,2,1300000){
    if(hurui[i]){
      for(int j=i+i;j<1300000;j+=i) hurui[j]=false;
    }
  }
  map<int,int> mp;
  int pre = 2;
  rep(i,1300000){
    if(hurui[i]){
      mp[pre]=i-pre;
      pre=i;
    }
  }
  int n;
  while(1){
    cin >> n;
    if(n==0) return 0;
    auto itr = mp.upper_bound(n);
    itr--;
    if(itr->first==n){
      cout << 0 << endl;
    }else{
      cout << itr->second << endl;
    }
  }
  return 0;
}



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

int main(){
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    double d= sqrt( (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    printf("%lf\n",d);
    
    return 0;
}


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

int N, M;
vector<vector<int>> v, rv;
vector<int> cmp, vs;
bool used[10001];
const long long int MOD = 1e9+7LL;

void dfs(int now) {
    used[now] = true;

    for (auto next: v[now]) {
        if (!used[next]) dfs(next);
    }

    vs.push_back(now);
}

void rdfs(int now, int k) {
    used[now] = true;
    cmp[now] = k;

    for (auto next: rv[now]) {
        if (!used[next]) rdfs(next, k);
    }
}

int scc() {
    memset(used, 0, sizeof(used));
    vs.clear();
    for (int i = 0; i < N; i++)
        if (!used[i]) dfs(i);

    memset(used, 0, sizeof(used));
    int k = 0;
    for (int i = vs.size() - 1; i >= 0; i--) {
        if (!used[vs[i]]) rdfs(vs[i], k++);
    }

    return k;
}

int main() {
    cin >> N >> M;
    v.resize(N), rv.resize(N), cmp.resize(N);

    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;

        v[x].push_back(y);
        rv[y].push_back(x);
    }

    int k = scc();
    vector<int> next(k, -1);
    for (int i = 0; i < N; i++) {
        if (v[i].size())
            next[cmp[i]] = cmp[v[i][0]];
    }

    vector<long long int> sum(k, 0);
    memset(used, 0, sizeof(used));
    long long int ans = 1LL;
    for (int i = 0; i < k; i++) {
        if (sum[i]) {
            sum[i]++;
        } else {
            sum[i] = 2LL;
        }

        if (next[i] < 0 || next[i] == i) 
            ans = (ans * sum[i]) % MOD;
        else if (sum[next[i]]) 
            sum[next[i]] = (sum[next[i]] * sum[i]) % MOD;
        else 
            sum[next[i]] = (sum[next[i]] + sum[i]) % MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3264
import java.util.Scanner;

public class Main {
	static Node root;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		for(int i = 0; i < n; i++) {
			String com = scan.next();
			if(com.equals("insert")) {
				int k = scan.nextInt();
				insert(k);
			}else {
				inorder(root);
				System.out.println();
				preoder(root);
				System.out.println();
			}
		}
		scan.close();
	}
	static class Node{
		int key;
		Node parent, left, right;
		Node(int key){
			this.key = key;
		}
	}
	static void insert(int k) {
		Node y = null;
		Node x = root;
		Node z = new Node(k);
		while(x != null) {
			y = x;
			if(k < x.key) {
				x = x.left;
			}else {
				x = x.right;
			}
		}
		z.parent = y;
		if(y == null) {
			root = z;
		}else {
			if(z.key < y.key) {
				y.left = z;
			}else {
				y.right = z;
			}
		}
	}
	static void inorder(Node u) {
		if(u == null) return;
		inorder(u.left);
		System.out.print(" " + u.key);
		inorder(u.right);
	}
	static void preoder(Node u) {
		if(u == null) return;
		System.out.print(" " + u.key);
		preoder(u.left);
		preoder(u.right);
	}
}


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


int main() {
    int x, y;
    cin >> x >> y;
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    rep(i, a) cin >> p[i];
    rep(i, b) cin >> q[i];
    rep(i, c) cin >> r[i];
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    sort(r.rbegin(), r.rend());
    vector<int> d;
    rep(i,x) d.push_back(p[i]);
    rep(i,y) d.push_back(q[i]);
    rep(i,c) d.push_back(r[i]);
    sort(d.rbegin(), d.rend());
    ll ans = 0;
    rep(i, x+y) ans += d[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3572
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias pred)(int n) {
    foreach(i; 0..n) pred();
}
auto rep(alias pred, T = typeof(pred()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = pred();
    return res;
}

void main() {
    int N, A, B;
    readf("%d %d %d\n", &N, &A, &B);
    string str = readln.chomp;
    int x, y;
    foreach(i, c; str) {
        if (c=='a') {
            writeln(x+y<A+B ? "Yes":"No");
            x++;
        } else if (c=='b') {
            writeln(x+y<A+B && y<B ? "Yes":"No");
            if (x+y<A+B && y<B) y++;
        } else {
            writeln("No");
        }
    }
}


Measured memory_bytes: 892
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
bool valid_pos(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }



int main()
{
	ios::sync_with_stdio(false);

	int n, m, W, w[16], K = 0;
	cin >> n >> m >> W;
	--m;
	int f[12345], top;
	for (int i = 0; i < n; ++i)
	{
		int k;
		cin >> k;
		int s = 0;
		for (int j = 0; j < k; ++j, ++K)
		{
			cin >> w[K];
			s |= 1 << K;
		}
		f[i] = s;
		if (s)
			top = i;
	}
	if (f[0] == (1 << K) - 1)
	{
		cout << 0 << endl;
		return 0;
	}

	int sum_w[1 << 15];
	for (int i = 0; i < 1 << K; ++i)
	{
		int s = 0;
		for (int j = 0; j < K; ++j)
			if (i >> j & 1)
				s += w[j];
		sum_w[i] = s;
	}

	int dp[1 << 15];
	dp[0] = 0;
	for (int S = 1; S < 1 << K; ++S)
	{
		dp[S] = 1 << 27;
		for (int T = S; T > 0; T = --T & S)
		{
			if (sum_w[T] <= W)
				min_swap(dp[S], dp[S ^ T] + 1);
		}
	}

	int rider = 0;
	int res = abs(m - top);
	for (int i = top; i > 0; --i)
	{
		rider |= f[i];
		res += dp[rider] * 2 - 1;
	}
	cout << res << endl;
}

Measured memory_bytes: 0
import java.util.*;

class Main{
    public static void main(String[] args){

	Scanner s = new Scanner(System.in);
	int[] prime = new int[500000];
	int j=0,num;

	for(int i=1;i<1000000;i++){
	    if( judgeprime(i) ){
		prime[j]=i;
		j++;
		//System.out.println(i);
	    }
	}
	prime[j]=1000001;

	while( s.hasNextInt() ){

	    int much=0;
	    num=s.nextInt();

	    for( int i=0 ; i < j+1 ; i++ ){
		if( prime[i]>num ){
		    much=i;
		    break;
		}
	    }

	    System.out.println(much);
	}

    }

    public static boolean judgeprime(int num){
	boolean primeflag=true;

	if( num%2==0 ){primeflag=false;}
	else if( true ){
	    for( int i=3 ; i < Math.sqrt( num ) +1 ; i+=2 ){
		if( num%i == 0 ){
		    primeflag=false;
		    break;
		}
	    }
	}

	if(num==0||num==1){primeflag=false;}
	else if(num==2){primeflag=true;}

	return primeflag;
    }
}

Measured memory_bytes: 22688
// Your code here!
use std::io::*;
use std::str::FromStr;
 
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
 
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main(){
    let n:i32 = read();
    match n%10 {
        3=>println!("bon"),
        0|1|6|8=>println!("pon"),
        _=>println!("hon"),
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n,x;

int main(){
    cin >> n >> x;
    vector<ll> a(n);
    ll sum = x;
    ll MIN = INF;
    ll ans = n;
    rep(i,n){
        cin >> a[i];
        sum -= a[i];
        MIN = min(MIN,a[i]);
    }
    cout << ans + sum / MIN << endl;
}

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

int main(){
  int n, m, c(0), a, b;
  cin >> n >> m;
  int heights[n + 1] = {};
  vector<int> notgood(n + 1);
  for (int i = 1; i <= n; ++i) cin >> heights[i];
  
  for (int i = 0; i < m; ++i) {
    
    cin >> a >> b;
    
    if (heights[a] > heights[b]) {
      notgood[b] = true;
    } else if (heights[a] < heights[b]) {
      notgood[a] = true;
    } else {
      notgood[a] = notgood[b] = true;
    }
    
  }
  for (int i = 1; i <= n; ++i) {
    if (!notgood[i]) c++;
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 3976
// To the MOTHER OF DRAGONS	

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
#include <bits/stdc++.h>
#define ll long long
#define llu unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define PI 3.14159265358979323846
#define all(x) x.begin(), x.end()
#define deb(x) cerr << ">> " << #x << " : " << x << "\n"
#define RAGE ios::sync_with_stdio(0); cin.tie(0);

using namespace std;

const ll inf = 1e18 + 42;

void solve()
{
	ll k;
	cin >> k;
	ll ans = 0;	
	for(ll i = 1; i <= k; i++)
	{
		for(ll j = 1; j <= k; j++)
		{
			for(ll l = 1; l <= k; l++)
			{
				ans += __gcd(i, __gcd(j, l));
			}
		}
	}
	cout << ans << "\n";
}

int main()
{
	RAGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ll t;
	//cin >> t;
	//while(t--)
		solve();
	return 0;
}

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

char S[11][11];

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

int check(int id,int x,int y){
  // cout << id << " " << " " << x << " "<< y << " "<< S[x][y] << endl;
  if( S[x][y] != '.'  ) return 0;
  int res = 0;
  for(int i=0;i<8;i++){
    int nx = x, ny = y;
    int cnt = 0; bool f = true;
    do{
      cnt++;
      nx = nx + dx[i], ny = ny + dy[i];
      if( nx < 0 || ny < 0 || nx >= 8 || ny >= 8 ) {
	f = false;
	break;
      }
    }while( S[nx][ny] == (id==0?'x':'o') );
    if( f && S[nx][ny] == (id==0?'o':'x') ){
      res += cnt - 1;
    }
  }
  return res;
}
void ume(int id,int x,int y){
  S[x][y] = (id==0?'o':'x');
  for(int i=0;i<8;i++){
    int nx = x, ny = y;
    bool f = true;
    do{
      nx = nx + dx[i], ny = ny + dy[i];
      if( nx < 0 || ny < 0 || nx >= 8 || ny >= 8 ) {
	f = false;
	break;
      }
    }while( S[nx][ny] == (id==0?'x':'o') );

    if( f && S[nx][ny] == (id==0?'o':'x') ){
      nx = x + dx[i],  ny = y + dy[i];
      // cout << "st " << nx << " "<< ny << endl;
      while( S[nx][ny] != (id==0?'o':'x') ){
	S[nx][ny] = (id==0?'o':'x');
	nx = nx + dx[i]; ny = ny + dy[i];
	//cout << nx << " "<< ny << endl;
      }
    }
  }
}

bool solve(int id,int t){
  if( t == 2 ){
    for(int i=0;i<8;i++){
      for(int j=0;j<8;j++)
	cout << S[j][i];
      cout << endl;
    }
    return true;
  }
  if( id == 0 ){
    int ix=0,jx=0,resx=0;
    for(int i=0;i<8;i++){
      for(int j=0;j<8;j++){
	int ret = check(id,j,i);
	if( resx < ret ){
	  resx = ret; jx = j; ix = i;
	}
      }
    }
    if( resx == 0 ) solve(1-id,t+1);
    else {
      ume(id,jx,ix);
      solve(1-id,0);
    }
  } else {
    int ix=7,jx=7,resx=0;
    for(int i=7;i>=0;i--){
      for(int j=7;j>=0;j--){
	int ret = check(id,j,i);
	if( resx < ret ){
	  resx = ret; jx = j; ix = i;
	}
      }
    }
    if( resx == 0 ) solve(1-id,t+1);
    else {
      ume(id,jx,ix);
      solve(1-id,0);
    }
  }
}

int main(){
  for(int i=0;i<8;i++)
    for(int j=0;j<8;j++)
      cin >> S[j][i];

  solve(0,0);
}

Measured memory_bytes: 1136
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = readInts >>= print . uncurry lcm . mp

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


    string a;
    cin>>a;
    int cnt=0;
    int cntt=0;
    for(int i=0;i<3;i++)
    {
        if(a[i]=='A') cnt++;
        if(a[i]=='B') cntt++;
    }
    if(cnt!=3&&cntt!=3) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long
				
int32_t main() {
	fast_cin();  
	int x; cin >> x;
	if (x >= 30) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <cassert>
#include <iomanip>
using namespace std; 
int main(){
	int n,ans=0;
	cin>>n;
	string s;
	cin>>s; 
	for(int i=1;i<n;i++){
		int cnt=0;
 
		for(char c='a';c<='z';c++){
			bool left=false,right=false;
 
			for(int j=0;j<i;j++){
				if (s[j]==c) left=true;
      }
 
			for(int j=i;j<n;j++){
				if (s[j]==c) right=true;
      }
 
			if (left&&right) cnt++;
		}
 
		if (ans<cnt) ans=cnt;
	}
 
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int X;cin>>X;
    int N=X/100;
    for(int i=N;i>=max(0,N-10);i--){
        int rem=X-i*100;
        if(0<=rem&&rem<=5*i){
            cout<<1<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
}


Measured memory_bytes: 256
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}


ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}




int main(){

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

    int n, odd = 0;
    cin>>n;
    while(n--){
        int a;
        cin>>a;
        odd += (a%2==1);
    }

    odd %= 2;
    if(odd == 1)    cout<<"NO";
    else    cout<<"YES";
    return 0;
}





Measured memory_bytes: 384
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())

if v <= w:
    print('NO')
    exit(0)

n = abs(a - b)
m = abs(v - w)

if n / m <= t:
    print('YES')
else:
    print('NO')

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

int main()
{
    int n;
    cin >> n;
    
    char s[n], t[n];
    for(int i=0; i<n; i++){
        cin >> s[i];
    }
    for(int i=0; i<n; i++){
        cin >> t[i];
    }
  
    for(int i=0; i<n; i++){
        cout << s[i] << t[i];
    }
    
    return 0;
}

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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}
public static void Ans() {

			var inputArray = retreiveStringArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var N = inputArray[0].Select(x=>x).ToArray();

			var count = N.Select(x => int.Parse(x.ToString())).Sum();

			//答えの出力
			var ans = count%9==0?"Yes":"No";
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}



Measured memory_bytes: 34216
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int n;
  cin >> n;
  int ans = (n/500)*(1000);
  n%=500;
  ans+= (n/5)*5;
  cout << ans << endl;


return 0;
}
///....


Measured memory_bytes: 256
#include <stdio.h>

#define N 100
#define max 2000
#define inf 2001


int main(){

  int n,i,j;
  int a[N][N];
  int v[N];
  int small;
  int mj,mi,k=1;
  int smlcost=0;
  int hanbetu = 0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&a[i][j]);
    }
  }
  
  for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	if(a[i][j] < small && a[i][j] != -1){
	  small = a[i][j];
	  mi = i;
	  mj = j;
	}
      }
    }

  a[mi][mj] = -1;
  a[mj][mi] = -1;

  v[0] = mi;
  v[1] = mj;

  smlcost = small + smlcost;

  while(1){
    
    small = inf;

    for(i=0;i<=k;i++){
      for(j=0;j<n;j++){
	if(a[v[i]][j] < small && a[v[i]][j] != -1){
	  small = a[v[i]][j];
	  mi = v[i];
	  mj = j;
	}
      }
    }
    
    a[mi][mj] = -1;
    a[mj][mi] = -1;
    
    for(i = 0; i<=k;i++){
      if(v[i] == mj){
	  hanbetu++;
	}
    }
      if(hanbetu == 0){
       smlcost = small + smlcost;
       k++;
       v[k] = mj;
      }

      hanbetu = 0;
  
    if(k == n-1){
      break;
    }
  }
  printf("%d\n",smlcost);
  return 0;
}



Measured memory_bytes: 2040
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
typedef pair<int, int> P;

int H, W;
vector<string> S;
vector<vector<bool>> visited;
vector<P> ds = {{1, 0}, {-1, 0}, {0, -1}, {0, 1}};

LL bfs(int y, int x) {
  LL cnt_w = 0, cnt_b = 0;
  queue<P> que; que.push({y, x});
  visited[y][x] = true;

  while (!que.empty()) {
    auto [y, x] = que.front(); que.pop();
    if (S[y][x] == '.') ++cnt_w;
    else                ++cnt_b;

    for (auto [dy, dx] : ds) {
      int ny = y + dy, nx = x + dx;
      if (nx < 0 || W <= nx || ny < 0 || H <= ny) continue;
      if (visited[ny][nx]) continue;
      if (S[y][x] == S[ny][nx]) continue;

      visited[ny][nx] = true;
      que.push({ny, nx});
    }
  }
  return cnt_w * cnt_b;
}

int main() {
  cin >> H >> W;
  S.resize(H);
  visited.resize(H, vector<bool>(W, false));
  for (int r = 0; r < H; ++r) {
    cin >> S[r];
  }

  LL cnt = 0;
  for (int r = 0; r < H; ++r) {
    for (int c = 0; c < W; ++c) {
      if (visited[r][c]) continue;
      cnt += bfs(r, c);
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3868
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

vector<bool> visited;
vector<int> dist;
vector<int> par;

Graph G;

void bfs(int s, int d) {
  queue<pair<int, int>> que;
  pair<int, int> y = make_pair(s, d);
  que.push(y);
  while (!que.empty()) {
    pair<int, int> p = que.front();
    que.pop();
    // cout << p.first << endl;
    // cout << G[p.first].size() << endl;
    rep(i, G[p.first].size()) {
      if (visited[G[p.first][i]]) continue;
      dist[G[p.first][i]] = p.second + 1;
      visited[G[p.first][i]] = true;
      par[G[p.first][i]] = p.first;
      pair<int, int> x = make_pair(G[p.first][i], p.second + 1);
      que.push(x);
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ///////////////////////////////////////
  int n, m;
  cin >> n >> m;
  G.resize(n);
  visited.resize(n);
  dist.resize(n);
  par.resize(n);
  rep(i, n) {
    visited[i] = false;
    dist[i] = 0;
    par[i] = -1;
  }
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  par[0] = 0;
  visited[0] = true;
  bfs(0, 0);
  rep(i, n) {
    if (!visited[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  repi(i, 1, n) cout << ++par[i] << endl;
  return 0;
}


Measured memory_bytes: 10948
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;

typedef long long LL;

int main() {
    LL A, B, C;
    cin >> A >> B >> C;
    LL ans1 = 0;
    if (A%2 != 0) {
        ans1 = B*C;
    }
    LL ans2 = 0;
    if (C%2 != 0) {
        ans2 = B*A;
    }
    LL ans3 = 0;
    if (B%2 != 0) {
        ans3 = A*C;
    }
    LL ans = min(ans1,ans2);
    ans = min(ans, ans3);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

string S, T;

int main(void) {

	cin >> S >> T;

	int N = S.size();
	int M = T.size();

	int ans = N;

	for (int i = 0; i + M - 1 < N; i++) {
		int cnt = 0;
		for (int j = 0; j < M; j++) {
			if (S[i + j] != T[j]) { cnt++; }
		}
		ans = min(ans, cnt);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3624
/*
                                        //     //     //\\\\\\\\\
                                        \\    //      \\        \\
                                        //   //       //         \\
                                        \\  //        \\          \\
                                        // //         //           \\
                                        \\//          \\            \\       
                                        //\\          //            //
                                        \\ \\         \\           //
                                        //  \\        //          //
                                        \\   \\       \\         //
                                        //    \\      //        //
                                        \\     \\     \\/////////
*/

#include <bits/stdc++.h>
//#include <boost/math/common_factor.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vint vector <int>
#define vll vector <long long int>
#define endl cout<<'\n'
#define fre(i,l,n) for(long long int i=l;i<n;++i)
#define fr(i,l,n) for(long long int i=l;i<=n;i++)
#define rfre(i,n,l) for(long long int i=n-1;i>=l;i--)
#define rfr(i,n,l) for(long long int i=n;i>=l;--i)
#define tab '\t'
#define debug cout<<'*';
#define s(a) cin>>a
#define p(a) cout<<a
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> pll;
typedef pair<int,pair<int,int> > tii;
typedef vector<int> vec;
typedef vector<long long> vecll;
typedef vector<pair<int,int> > vec_pii;
typedef vector<pair<long long int,long long int> > vec_pll;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvll;
typedef vector<vector<pair<int,int> > > vvpii;
typedef vector<vector<pair<ll,ll> > > vvpll;
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define Pi 3.14159265358979
#define gcd(a,b) __gcd(a,b)
#define sf(n) scanf("%lld",&(n))
#define pf(n) printf("%lld\n",(n))
#define min3(a,b,c) (min((c),min((a),(b))))
#define max3(a,b,c) (max((a),max((b),(c))))
#define w(t) while(t--)
#define flt(a) cout<<fixed<<setprecision(a)
#define cntSetBits(n) __builtin_popcountll(n)
/*****************************
*****************************/




void solve()
{
    ll n;
    s(n);
    map<ll,ll> kd;
    ll sum = 0;
    fre(i,0,n)
    {
        ll val;
        s(val);
        sum += val;
        kd[val] += 1;
    }
    ll q;
    s(q);
    w(q)
    {
        ll a,b;
        s(a);s(b);
        if(kd.find(a) != kd.end())
        {
            ll val = kd[a];
            kd[a] = 0;
            sum -= (val*a);
            sum += (val*b);
            kd[b] += val;
        }
        p(sum);endl;
    }
}



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll t=1;
    // s(t);
    w(t)
    {
        solve();
    }
    return 0;
}









Measured memory_bytes: 8752
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

type Node [][]int
func (N Node) Len() int { return len(N) }
func (N Node) Less(i, j int) bool { return N[i][0] < N[j][0] }
func (N Node) Swap(i, j int) { N[i], N[j] = N[j], N[i] }

func DFC(V *[]string, H *[][]int, v int) {
  for _, adj := range (*H)[v] {
    if (*V)[adj] != "" { continue }
    if (*V)[v] == "B" {
      (*V)[adj] = "W"
    } else {
      (*V)[adj] = "B"
    }
    DFC(V, H, adj)
  }
}

func Solve() {
  NM := NextIntVec()
  N, M := NM[0], NM[1]
  D := NextIntVec()
  G := make([][][]int, N)
  for i := range G {
    G[i] = make([][]int, 0)
  }
  E := make([]int, M)
  for i := range E {
    UV := NextIntVec()
    u, v := UV[0] - 1, UV[1] - 1
    G[u] = append(G[u], []int{v, i})
    G[v] = append(G[v], []int{u, i})
  }
  V := make([]string, N)
  H := make([][]int, N)
  for i := range H {
    H[i] = make([]int, 0)
  }
  for u, g := range G {
    sort.Sort(Node(g))
    adj := u
    for _, v := range g {
      if D[u] < D[v[0]] { continue }
      adj = v[0]
      E[v[1]] = D[u]
      H[u] = append(H[u], v[0])
      H[v[0]] = append(H[v[0]], u)
      break
    }
    if adj == u {
      Write(-1)
      return
    }
  }
  for v := range V {
    if V[v] == "" { V[v] = "B" }
    DFC(&V, &H, v)
  }
  Write(strings.Join(V, ""))
  for i, e := range E {
    if e < 1 { E[i] = 1000000000 }
    Write(E[i])
  }
  return
}

func main() {
  Solve()
  Output()
}

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

std::pair<unsigned int, unsigned int> solve(unsigned int a, unsigned int b){
	std::pair<unsigned int, unsigned int> ans;
	std::vector<unsigned int> divs;
	unsigned int n = 2;

	while(true){
		if( a < n || b < n ) break;
		if(	a % n == 0 &&
			b % n == 0){
			divs.push_back(n);
			a /= n;
			b /= n;
			n = 2;
		}else{
			n++;
		}
	}

	ans.first = 1;
	for(unsigned int n : divs){
		ans.first *= n;
	}

	ans.second = ans.first*a*b;

	return(ans);
}

int main(){
	std::vector<std::pair<unsigned int, unsigned int>> ans;

	unsigned int a,b;
	while(true){
		std::cin >> a >> b;
		if(std::cin.eof()) break;
		ans.push_back(solve(a,b));
	}

	for(auto&& a : ans){
		std::cout << a.first << " " << a.second << std::endl;
	}
	
}

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

int main(){
  int n,y,m,d;
  cin >> n;
  while(n--){
    cin >> y >> m >> d;
    
    int days = 0;
    while(y<1000){
      d++; days++;
      if(y%3==0){
	if(d>20){
	  d = 1; m++;
	}
      }else{
	if(m%2==0){
	  if(d>19){
	    d = 1; m++;
	  }
	}else{
	  if(d>20){
	    d = 1; m++;
	  }
	}
      }
      if(m>10){
	m = 1; y++;
      }
    }
    cout << days << endl;
  }
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  string s; cin >> s;
  int n = s.length() - 6;
  for(int i = 0; i < s.length(); i++) {
    for(int j = 0; j < n; j++) {
      string tmp = s;
      if(tmp.erase(i, j) == "keyence") {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;

  return 0;
}

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

int main(){

  int n;
  cin>>n;
  string s[100];
  int t[100];
  for(int i=0; i<n; i++) cin>>s[i]>>t[i];
  string x;
  cin >>x;
  
  int j=0;
  for(int i=0; i<n; i++){
    
    if(x==s[i]) j=i;
  
  }
int sum=0;
  for(int i=j+1; i<n; i++){

    sum+=t[i];
  
  }

cout<<sum<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  string a;
  cin >> a;
  if (a == "Sunny")
    cout << "Cloudy"<< endl;
  else if (a == "Cloudy")
    cout << "Rainy" << endl;
  else
    cout << "Sunny" << endl;
  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
//21:30
int main(){
  long n = 0;
  long a[100000] = {};
  long i = 0;
  long division = 0;
  int mode = 0;
  scanf("%lu",&n);
  for(i=0;i<n;i++){
    scanf("%lu",&a[i]);
  }
  
  for(i=0;i<n-1;i++){
    if(mode == 0 && a[i] < a[i+1]){
      mode = 1;
    }else if(mode == 0 && a[i] > a[i+1]){
      mode = -1;
    }else if(mode == 1 && a[i] > a[i+1]){
      division++;
      mode = 0;
    }else if(mode == -1 && a[i] < a[i+1]){
      division++;
      mode = 0;
    }
  }
  printf("%lu",division+1);
  return 0;
}

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

using namespace std;

int main() {
    int n , k; cin>>n;
    vector<int>dp(3);
    for(int d = 0 ; d < n ; ++d){
        vector<int>n_dp(3 , 0);
        vector<int>cst(3);
        for(int x = 0 ; x < 3; ++x)cin>>cst[x];
        for(int i = 0 ; i < 3 ; ++i){
            for(int j = 0 ; j < 3 ; ++j){
                if(i != j)n_dp[j] = max(n_dp[j] , dp[i] + cst[j]);
            }
        }
        dp = n_dp;
    }
    cout<<*max_element(dp.begin(),dp.end());


}

Measured memory_bytes: 384
N,M = map(int,input().split())
H = list(map(int,input().split()))
ten = [True]*N
for i in range(M):
    A,B = map(int,input().split())
    if H[A-1] <= H[B-1]:
        ten[A-1] = False
    if H[A-1] >= H[B-1]:
        ten[B-1] = False
res = 0
for i in ten:
    if i:
        res += 1
print(res)
    


Measured memory_bytes: 20072
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define unique(a)  sort(all(a)) , (a).erase(unique((a).begin(), (a).end()),(a).end())
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(x) (int)(x).size()
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
const int N = 2e5 + 5;
#define PI acos(-1.0)
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> VI;
#define pqll_max priority_queue<ll> // max heap. push(),pop(),top(),size(),empty()
#define pqll_min priority_queue<ll,vector<ll>,greater<ll> >
#define lb(v,val)   lower_bound(v.begin(),v.end(),val) //first equal to or lower than [------------
#define ub(v,val)   upper_bound(v.begin(),v.end(),val) //first greater than ------------)
#define bs(v,x) binary_search(v.begin(),v.end(),x)
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x; }
inline ll sub(ll a, ll b) { if (a < b)swap(a, b); return (((a%mod) - (b%mod) + mod) % mod); }
inline ll mul(ll x, ll y) { return (x%mod * 1ll * y%mod) % mod; }
inline ll pwr(ll a, ll b) { ll x = 1 % mod; while (b) { if (b & 1) x = mul(x, a); a = mul(a, a); b >>= 1; }return x % mod; }
inline ll inv(ll a) { return pwr(a, mod - 2) % mod; }
ll gcd(ll a, ll b) { if (!a)return b % mod; return gcd(b%a, a) % mod; }
#define debug(x) cout << #x << " = " << x << endl;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#define in(container) for (auto &it : container) cin>>it;
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
signed main()
{
	fastio;
	int n, m;
	cin >> n >> m;
	cout << (n*(n - 1)) / 2 + (m*(m - 1)) / 2 << endl;

}

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

int main()
{
	int K, A, B;
	cin >> K >> A >> B;
	
	if (B - A <= 2) {
		cout << K + 1 << endl;
		return 0;
	}
	
	ll ans = K + 1;
	
	if (K >= A - 1) {
		ll tmpans = A;
		K -= A - 1;
		
		if (K % 2 == 1) {
			K--;
			tmpans++;
		}
		
		tmpans += (K / 2) * 1LL * (B - A);
		
		ans = max(ans, tmpans);
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n;
    cin>>n;
    cout<<n/3<<NL;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if (a == b)
    {
        printf("%d\n", c);
    }
    else if (a == c)
    {
        printf("%d\n", b);
    }
    else if (b == c)
    {
        printf("%d\n", a);
    }
}


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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define m_p make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,ans=0;
    cin >> n;
    vector<ll> a(n+1),b(n);
    rep(i,n+1) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n){
        if(b[i]>=a[i]+a[i+1]){
            ans += a[i] + a[i+1];
            a[i] = a[i+1] = 0;
        }else if(b[i]>=a[i] && b[i]-a[i]<a[i+1]){
            ans += b[i];
            a[i+1] -= (b[i]-a[i]);
            a[i] = 0;
        }else if(b[i]<a[i]){
            ans += b[i];
            a[i] -= b[i];
        }
    }
    cout << ans << endl;
    return 0;
}

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

int A, B;

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

    int tmp = A + B;
    if (tmp >= 24) {
        tmp -= 24;
    }

    cout << tmp << endl;
}

Measured memory_bytes: 256