akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
import re
import math
import fractions
import random
import time
#import numpy as np
mod=int(10**9+7)
inf=int(10**20)

class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n

    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]

    def same(self,x,y):
        return self.find(x)==self.find(y)

    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1

    def unite(self,x,y):
        self.link(self.find(x),self.find(y))

    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)




def solve():
    return

#入力
N,M=map(int,input().split())
XYZ=[]

U=union_find(N)
for a in range(M):
    X,Y,Z=map(int,input().split())
    X-=1
    Y-=1
    U.unite(X,Y)
print(U.size())

Measured memory_bytes: 107676
#include <bits/stdc++.h>
using namespace std;
int main (){
  int A,B,C,D;
    cin >> A >> B >> C >> D ;
  if(A+B>C+D)
    cout<<"Left"<<endl;
  
  if(A+B==C+D)
    cout<<"Balanced"<<endl;
  
  if(A+B<C+D)
    cout<<"Right"<<endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define ll long long
#define p pair<ll, int>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    ll a[n], sum = 0;
    for (int i = 0; i < n; i++) cin >> a[i], sum += a[i];
    sort(a, a + n);
    vector<p> v;
    for (int i = 0; i < m; i++) {
        int b;
        ll c;
        cin >> b >> c;
        v.push_back(p(c, b));
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    int i = 0;
    for (int j = 0; j < m; j++) {
        int idx = v[j].second;
        ll val = v[j].first;
        while (a[i] < val && i < n && idx > 0) {
            sum -= a[i];
            sum += val;
            i++;
            idx--;
        }
    }
    cout << sum << endl;
    return 0;
}

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

long long solve(int a, int b, int c, int x, int y) {
  const long long c1 { a * x + b * y };
  const long long c2 { 2 * c * std::min(x, y) + a * (x - std::min(x, y)) + b * (y - std::min(x, y)) };
  const long long c3 { 2 * std::max(x, y) * c };

  return std::min(c1, std::min(c2, c3));
}

int main() {
  int a, b, c, x, y;
  std::cin >> a >> b >> c >> x >> y;
  std::cout << solve(a, b, c, x, y) << std::endl;
  return 0;
}


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

using namespace std;

int main()
{
    vector<int> v;

    for (int i = 0; i < 3; i++) {
        int x; cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end(), greater<int>());

    cout << v[0] * 10 + v[1] + v[2] << endl;

    return 0;
}

Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(i64);

    // N = q・K^(m+1) + K^m となる K の集合。(K = 1 を含む。)
    let mut k_set = HashSet::new();

    // m = 0 のケース
    // N = q・K + 1
    // K = (N-1)/q
    {
        let M = N - 1;
        let mut d = 1;
        while d * d <= M {
            if M % d == 0 {
                k_set.insert(d);
                k_set.insert(M / d);
            }

            d += 1;
        }
    }

    // m = 1, q = 0 のケース
    // N = K
    k_set.insert(N);

    // m = 1 かつ q >= 1 のケース
    // N = q・K^2 + K (q >= 1)
    let mut K = 2;
    while K * K <= N {
        if N - K >= K * K && (N - K) % (K * K) == 0 {
            k_set.insert(K);
        }

        K += 1;
    }

    // m >= 2 のケース
    let mut K = 2;
    while K * K <= N {
        // K^m
        let mut km = K * K;
        while km <= N {
            // K^(m+1)
            let km1 = km * K;

            // (N - K^m) = q・K^(m+1)
            if (N - km) % km1 == 0 {
                k_set.insert(K);
                break;
            }

            km *= K;
        }

        K += 1;
    }

    k_set.remove(&1);

    println!("{}", k_set.len())
}


Measured memory_bytes: 4476
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;


int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi x(n), l(n);
    rep(i,n) cin >> x.at(i) >> l.at(i);
    vector<pair<int64_t,int64_t>> pair(n);
    rep(i,n) pair.at(i) = make_pair(x.at(i) - l.at(i), x.at(i) + l.at(i));
    sort(pair.begin(), pair.end());
    int64_t right = -10000000000007, res = n;
    rep(i,n){
        if(pair.at(i).first>=right){
            right = pair.at(i).second;
            continue;
        }
        res--;
        if(pair.at(i).second<=right) right = pair.at(i).second;
    }
    cout << res << endl;
}


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

int main(void)
{
    ll n;
    vector<ll> cost(5);
    cin >> n;
    rep(i, 0, 5) cin >> cost[i];
    cout << 4 + ((n + *min_element(cost.begin(), cost.end()) - 1) / *min_element(cost.begin(), cost.end())) << endl;
}


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

ll n;vector<vector<ll>> vw;vector<vector<ll>> dp;
ll c1,c2;

void dfs(ll i){
    if(i==1){
        dp[i-1][vw[i-1][1]]=vw[i-1][0];
    }else{
        ll j=i/2;
        for(ll k=c2;k+1;k--){
            if(dp[j-1][k]!=0 or k==0){
                ll ne=k+vw[i-1][1];
                if(ne<=c2)dp[i-1][ne]=max(dp[j-1][k]+vw[i-1][0],dp[i-1][ne]);
            }
            dp[i-1][k]=dp[j-1][k];
        }
    }
    if(i*2<=min(c1,n))dfs(i*2);
    if(i*2+1<=min(c1,n))dfs(i*2+1);
}

signed main(){
    cin>>n;
    vw.resize(n);
    REP(i,n){ll x,y;cin>>x>>y;vw[i]={x,y};}
    c1=1<<10;c2=100000;
    dp.resize(c1);REP(i,c1)dp[i].resize(c2+1);
    dfs(1);
    REP(i,c1)REP(j,c2)dp[i][j+1]=max(dp[i][j],dp[i][j+1]);
    ll q;cin>>q;
    REP(i,q){
        ll v,l;cin>>v>>l;
        vector<ll> cand;
        while(v>c1){
            cand.push_back(v);
            v=v/2;
        }
        ll r=cand.size();
        ll ans=0;
        REP(j,1<<r){
            ll v_sub=0;ll w_sub=0;
            REP(k,r){
                if((j>>k)&1){
                    v_sub+=vw[cand[k]-1][0];
                    w_sub+=vw[cand[k]-1][1];
                }
            }
            if(w_sub<=l)ans=max(ans,dp[v-1][l-w_sub]+v_sub);
        }
        cout<<ans<<endl;
    }
}


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

int main(void){
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n-1);
    for(auto& i : a) cin >> i;
    for(auto& i : b) cin >> i;
    for(auto& i : c) cin >> i;
    int sut = 0;
    int prex = 0;
    for(auto xa : a){
        sut += b.at(xa-1);
        if(xa >= 2 && xa == prex + 1) sut += c.at(xa-2);
        prex = xa;
    }
    cout << sut << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

int main() {
//  freopen("../Console/1.txt", "rb", stdin);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int N;
  cin >> N;

  vector<int> A(N);
  for (int& a : A) {
    cin >> a;
  }

  int result = 0;
  for (int i = 0; i < N; ) {
    ++result;

    int j1 = i + 1;
    while (j1 < N && A[j1 - 1] <= A[j1]) {
      ++j1;
    }

    int j2 = i + 1;
    while (j2 < N && A[j2 - 1] >= A[j2]) {
      ++j2;
    }

    i = max(j1, j2);
  }

  cout << result << '\n';


  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <limits>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <numeric>
//#include <tuple>

constexpr long long mod = static_cast<long long>(1e9 + 7);

struct Edge {
    int to;
    int w;
};

using Edges = std::vector<std::vector<Edge>>;

std::pair<int, int> maxDistance(int i, const Edges& edges, std::vector<bool>& memo) {
    memo[i] = true;
    int dist = 0;
    int node = i;
    for(auto v: edges[i]) {
        if(!memo[v.to]) {
            auto ans = maxDistance(v.to, edges, memo);
            if(dist < ans.first + v.w) {
                dist = ans.first + v.w;
                node = ans.second;
            }
        }
    }

    return std::make_pair(dist, node);
};

int main() {
    int n;
    std::cin >> n;
    Edges edges(n);

    while(--n) {
        int s, t, w;
        std::cin >> s >> t >> w;
        edges[s].push_back(Edge{t, w});
        edges[t].push_back(Edge{s, w});
    }

    std::vector<bool> memo(edges.size(), false);
    auto ans1 = maxDistance(0, edges, memo);
    std::fill(begin(memo), end(memo), false);
    auto ans2 = maxDistance(ans1.second, edges, memo);
    std::cout << ans2.first << std::endl;

    return 0;
}



Measured memory_bytes: 17560
k = int(input())
a = list(map(int,input().split()))

#始めの人数がn人だった時終わりの人数
def g(n,a,k):
    for i in range(k):
        n = n - (n%a[i])
    return n

#print(g(8,a,k))

s = 0
t = 2 + k*max(a)
while t-s > 1:
    m = (s+t)//2
    if g(m,a,k)> 2:
        t = m
    else:
        s = m
    
p = 0
q = 2+k*max(a)
while q-p > 1:
    m = (p+q)//2
    if g(m,a,k) >= 2:
        q = m
    else:
        p = m

c = 1
if g(s,a,k) == 2:
    res = s
elif g(t,a,k) == 2:
    res = t
else:
    c = -1

if g(q,a,k) == 2:
    res2 = q
elif g(p,a,k) == 2:
    res2 = p
else:
    c = -1

if c == 1:
    print(res2,res)
else:
    print(-1)

Measured memory_bytes: 63856
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    let c=read::<i32>();
    println!("{}",if b-a==c-b{"YES"}else{"NO"})
}

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

int main(){
  char line[30];
  char c;
  int cnt, i;

  scanf("%s", line);
  cnt = strlen(line)-1;

  for(i = 0;i < (cnt+1)/2; i++){
    c = line[i];
    line[i] = line[cnt-i];
    line[cnt-i] = c;
  }
  printf("%s\n", line);
  return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
#define HAPPY_BIRTHDAY 0
int A,B,C,D,E,F;
int main(){
  cin>>A>>B>>C>>D>>E>>F;
  cout<<A+B+C+D-min(min(A,B),min(C,D))+max(E,F)<<endl;
  return HAPPY_BIRTHDAY;
}

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

#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)
#define sc second
#define fs first
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int bd[10][10];

int W,H;
void dec(string s){
	int p=0,w=0,h=0;
	rep(i,s.length()){
		char c = s[i];
		if (c == 'b' ) bd[h][w++]=1;
		else if (c == '/') {w=0;h++;}
		else w+=c-'0';
	}
	W=w;
	H=h+1;
}

void enc(){
	rep(i,H){
		int cnt = 0;
		rep(j,W){
			if(bd[i][j]){
				if(cnt) cout << cnt;
				cout << 'b';
				cnt = 0;
			}
			else cnt++;
		}
		if(cnt) cout << cnt;
		if(i!=H-1)cout << "/";
	}
	cout << endl;
}
void pr(){
	rep(i,H){
		rep(j,W){
			cout << (bd[i][j] ? 'b' : '.');
		}
		cout << endl;
	}
}
int main(){
	int a,b,c,d;
	string s;
	for(;;){
		cin >> s;
		if(s[0] == '#') break;
		rep(i,10)rep(j,10) bd[i][j] = 0;
		cin >> a >> b >> c >> d;
		a--;b--;c--;d--;
		dec(s);
		swap(bd[a][b], bd[c][d]);
		enc();
	}
	return 0;
}

Measured memory_bytes: 3116
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
  int h,w;
  string* a = new string[100];
  cin >> h >> w;
  bool* hb = new bool[100];
  bool* wb = new bool[100];
  for(int i=0;i<h;i++) cin >> a[i];
  for(int i=0;i<h;i++) hb[i] = false;
  for(int i=0;i<w;i++) wb[i] = false;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(a[i][j]=='#'){
        hb[i] = true;
        wb[j] = true;
      }
    }
  }
  for(int i=0;i<h;i++){
    if(!hb[i]) continue;
    for(int j=0;j<w;j++){
      if(hb[i] && wb[j]){
        cout << a[i][j];
      }
    }
    cout << endl;
  }
  return 0;
}


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

int main() {
	string a;
	cin >> a;
	for (int i = 0; i < sizeof(a); i++) {
		if (a[i] == 'A'&&a[i + 1] == 'C') {
			cout << "Yes"; return 0;
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
import sys
from heapq import heappush, heappop

n, q = map(int, sys.stdin.readline().split())
stx = [tuple(map(int, sys.stdin.readline().split())) for _ in range(n)]
*d, = map(int, sys.stdin.read().split())

def main():
    queue = []
    for s, t, x in stx:
        queue.append((s-x, 1, x))
        queue.append((t-x, 0, x))
    
    for i in range(q):
        queue.append((d[i], 2, i))
    
    queue.sort()

    res = [None] * q
    hq = []
    running = set()
    
    for t, f, x in queue:
        if f == 1:
            heappush(hq, x)
            running.add(x)
        elif f == 0:
            running -= set([x])
        elif f == 2:
            i = x
            while hq:
                if not hq[0] in running:
                    heappop(hq)
                    continue
                res[i] = hq[0]
                break
            else:
                res[i] = -1
    return res

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Measured memory_bytes: 128636
import sys
N = int(input())
BA = [None] * N
for i in range(N):
    a, b = map(int, sys.stdin.readline().split())
    BA[i] = (b, a)
BA.sort()

t = 0
for b, a in BA:
    t += a
    if b < t:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 34996
//#include <iostream>
//#include <vector>
//#include <algorithm>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main(){
  int N;
  cin >> N;
  int odd = 0;
  for(int i=1; i<=N; i++){
    if(i%2 == 1) odd++;
  }
  double ans = (double)odd/N;
  //cout << odd << endl;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
 
using namespace std;
 
int main(){
  while(true){
    int N,M,mex;
    mex = -1;
    cin >> N >> M ;
    if(N+M == 0)break;
    vector<int> val,dp;
    for(int i=0;i<N;i++){
      int a; cin >> a; 
      val.push_back(a);     
      dp.push_back(a);
    }
    dp.push_back(0);
    map<int,bool> exist;
    for(int i=0;i<val.size();i++){
      for(int j=0;j<val.size();j++){
    //if(M > val[i]+val[j])continue;
    dp.push_back(val[i]+val[j]);
      }
    }
    sort(dp.begin(),dp.end());
    int mmex = -1; 
    for(int i=0;i<dp.size();i++){
      if(M >= dp[i])mmex = max(mmex,dp[i]+upper_bound(dp.begin(),dp.end(),M-dp[i])[-1]);
       
    }
 
    cout << mmex << endl;
    mex = -1;
  }
  return 0;
}

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

#define ROUND_UP(a, b) ((a) + (b)-1)/(b)

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

	int price = 700;

	if (s[0] == 'o')
		price += 100;
	if (s[1] == 'o')
		price += 100;
	if (s[2] == 'o')
		price += 100;


	cout << price << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#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(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

queue<pair<char, int>> run_length_encoding(const string &s) {
  queue<pair<char, int>> ans;

  int num = 1;
  for (int i = 0; i < (int)s.size() - 1; ++i) {
    if (s[i] == s[i + 1]) {
      num++;
    } else {
      ans.push(make_pair(s[i], num));
      num = 1;
    }
  }
  ans.push(make_pair(s.back(), num));
  return ans;
}

int main() {
  string s;
  cin >> s;
  queue<pair<char, int>> result = run_length_encoding(s);
  vector<int> data(s.size(), 0);
  int idx = 0;
  while (!result.empty()) {
    pair<char, int> r = result.front();
    result.pop();
    pair<char, int> l = result.front();
    result.pop();
    // Lの位置
    data[idx + r.second] += r.second / 2 + +l.second / 2 + l.second % 2;
    // Rの位置
    data[idx + r.second - 1] += r.second / 2 + r.second % 2 + l.second / 2;
    idx += r.second + l.second;
  }
  REP(i, s.size()) {
    if (i != s.size() - 1) {
      cout << data[i] << " ";
    } else {
      cout << data[i] << endl;
    }
  }
}

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

int main(void)
{
	int i;
	int min;
	int N;
	int L;
	int k = 0;
	int* apple;
	int total = 0;


	scanf("%d", &N);
	scanf("%d", &L);

	apple = (int*)malloc(sizeof(int) * N);

	for(i=0; i< N; i++){
		apple[i] = L+i;
		//printf("%d", apple[i]);
	}

	min = abs(apple[0]);
	for(i=1; i< N; i++){
		if(abs(apple[i]) < min){
			min = abs(apple[i]);
			k = i;
			//printf("%d", k);
		}
	}

	for(i=0; i< N; i++){
		if(i == k){
			total += 0;
		} else {
			total += apple[i];
		}
	}

	printf("%d", total);


	return 0;
}

Measured memory_bytes: 128
import queue

H, W = list(map(int, input().split()))
ans = H * W
L = []
for i in range(H):
	s = list(input())
	ans -= s.count("#")
	L.append(s)

length = [[float("inf") for i in range(W)] for j in range(H)]
length[0][0] = 0

def breadth(H, W, q, L, length, goal):
	while not q.empty():
		m = q.get()
		x = m[0]
		y = m[1]
		if [x, y] == goal:
			break

		if y - 1 >= 0:
			if length[y - 1][x] > length[y][x] + 1:
				if L[y - 1][x] == ".":
					length[y - 1][x] = length[y][x] + 1
					q.put([x, y - 1])
		if y + 1 <= H - 1:
			if length[y + 1][x] > length[y][x] + 1:
				if L[y + 1][x] == ".":
					length[y + 1][x] = length[y][x] + 1
					q.put([x, y + 1])
		if x - 1 >= 0:
			if length[y][x - 1] > length[y][x] + 1:
				if L[y][x - 1] == ".":
					length[y][x - 1] = length[y][x] + 1
					q.put([x - 1, y])
		if x + 1 <= W - 1:
			if length[y][x + 1] > length[y][x] + 1:
				if L[y][x + 1] == ".":
					length[y][x + 1] = length[y][x] + 1
					q.put([x + 1, y])
	return length[-1][-1]

q = queue.Queue()
q.put([0, 0])
goal = [W - 1, H - 1]
goal_len = breadth(H, W, q, L, length, goal)

if length[H - 1][W - 1] == float("inf"):
	print(-1)
else:
	print(ans - goal_len - 1)


Measured memory_bytes: 3948
N, K = map(int, input().split())
S = input() + '0'

ans = L = R = 0

while R < N:
    if S[R] == '0':
        while R < N and S[R] == '0':
            R += 1
        while S[R] == '1':
            R += 1
        K -= 1
        if K <= 0:
            ans = max(ans, R-L)

            while L < N and S[L] == '1':
                L += 1
            while L < N and S[L] == '0':
                L += 1
    else:
        R += 1
    ans = max(ans, R-L)
print(ans)

Measured memory_bytes: 3316
import java.io.*;
import java.util.ArrayList;
public class Main{
	public static void main(String args[]){
    int a=0,b=0,i=0,n=0;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    while(true){
    try{
      String line = reader.readLine();
      String[] splitted = line.split(" ");
      a = Integer.parseInt(splitted[0]);
      b = Integer.parseInt(splitted[1]);
      a++;
      if (b == 0) break;
		}catch(Exception e){
      break;
    }
    for(i = 1; i < a;i++){
      for(n = 0; n < b;n++){
        System.out.print("#");
      }
      System.out.print("\r\n");
    }
    System.out.print("\r\n");
  }
	}
}


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

const int mod = 1e9 + 7;
ll exp(int n, int m)
{
	int i;
	ll tmp;

	i = 0;
	tmp = 1;
	while (i < n)
	{
		tmp *= m;
		tmp %= mod;
		i++;
	}
	return (tmp);
}

signed main(void)
{
	ll n, ans;

	cin >> n;
	ans = 0;
	ans += exp(n, 10) % mod;
	if (ans < 0) ans += mod;
	ans %= mod;
	ans -= exp(n, 9);
	if (ans < 0) ans += mod;
	ans %= mod;
	ans -= exp(n, 9) % mod;
	if (ans < 0) ans += mod;
	ans %= mod;
	ans += exp(n, 8) % mod;
	if (ans < 0) ans += mod;
	ans %= mod;
	cout << ans << endl;
	return 0;
}


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

int main(){
  int n,k;
  cin >> n >> k;
  ll ans=0;
  for(int i=1;i<=n;++i){
    ans+=max(i-k,0)*(n/i);
    ans+=max(0,n%i-k+1);
    if(k==0){
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

void gcd(int x,int y){
    if(x % y != 0){
        gcd(y, x % y);
    }else{
        cout << y << endl;
    }
}

int main(){
    int x,y;
    cin >> x >> y;
    if(x >= y){
        gcd(x, y);
    }else{
        gcd(y, x);
    }
}



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

vector<int> pass[2005]; //         // dis[i] : startからiまでの距離

int main(){
    int a, b, c, d ;
    cin >>  a >> b >> c >> d ;
    for(;;){
        c -= b ;
        if(c <= 0 ){
            cout << "Yes" << endl;
            return 0 ;
        }
        a -= d ;
        if( a <= 0 ){
            cout << "No" << endl;
            return 0 ;
        }
    }
}

Measured memory_bytes: 3716
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007

ll now,n,k;

int main(){
  ll ans=0LL;
  cin >> n ;
  vector<ll> a(n+1),b(n);
  REP(i,n+1) cin>>a[i];
  REP(i,n) cin>>b[i];
  ans=accumulate(a.begin(),a.end(),0LL);

  ll t=0LL;
  REP(i,n){
    t=min(a[i],b[i]);
    a[i]-=t;
    b[i]-=t;
    a[i+1]=max(a[i+1]-b[i],0LL);
  }


  ans-=accumulate(a.begin(),a.end(),0LL);


  cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1061109567
#define pb push_back
#define in(s) freopen(s,"r",stdin);
#define out(s) freopen(s,"w",stdout);
#define fi first
#define se second
#define bw(i,r,l) for (int i=r-1;i>=l;i--)
#define fw(i,l,r) for (int i=l;i<r;i++)
#define fa(i,x) for (auto i:x)
using namespace std;
const int N=3005;
int n,a[N];
bool vis[N],ans[N];
vector<int> G[N];
void dfs(int u) {
	ans[u]=false;
	vis[u]=true;
	fa (v,G[u]) {
		if (a[v]>=a[u]) continue;
		if (!vis[v]) dfs(v);
		ans[u]|=ans[v];
	}
	ans[u]=1-ans[u];
}
signed main() {
	//in("aome.inp");
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n;
	fw (i,0,n) cin>>a[i];
	fw (i,1,n) {
		int u,v;
		cin>>u>>v;
		u--; v--;
		G[u].pb(v); G[v].pb(u);
	}
	fw (i,0,n) if (!vis[i]) dfs(i);
	fw (i,0,n) if (!ans[i]) cout<<i+1<<" ";
	return 0;
}

Measured memory_bytes: 512
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip, std.regex;
 
void main() {
    immutable int INF = 1 << 29;
 
    auto N = readln.chomp.to!int;
    auto A = new int[](2*N);
    auto C = new bool[](2*N);
    foreach (i; 0..2*N) {
        auto s = readln.split;
        A[i] = s[1].to!int;
        C[i] = s[0] == "B";
    }
 
    auto BR = new int[](N+1);
    auto WR = new int[](N+1);
    foreach (i; 0..2*N) {
        if (C[i]) BR[A[i]] = i;
        else      WR[A[i]] = i;
    }
 
    auto dpB = new int[][](N+1, 2*N+1); //座標iまでで、jより大きいBの数
    auto dpW = new int[][](N+1, 2*N+1); //座標iまでで、jより大きいWの数
 
    foreach (i; 0..N+1) foreach (j; 0..2*N) dpB[i][j+1] = dpB[i][j] + (C[j] && A[j] > i);
    foreach (i; 0..N+1) foreach (j; 0..2*N) dpW[i][j+1] = dpW[i][j] + (!C[j] && A[j] > i);
 
    auto dp = new int[][](N+1, N+1);
    foreach (i; 0..N+1) dp[i].fill(INF);
    dp[0][0] = 0;
 
    foreach (n; 1..2*N+1) {
        foreach (b; 0..n+1) {
            int w = n - b;
            if (b > N || w > N)
                continue;
            if (b > 0) {
                dp[b][w] = min(dp[b][w], dp[b-1][w] + dpB[b][BR[b]+1] + dpW[w][BR[b]+1]);
            }
            if (w > 0) {
                dp[b][w] = min(dp[b][w], dp[b][w-1] + dpW[w][WR[w]+1] + dpB[b][WR[w]+1]);
            }
        }
    }
 
    dp[N][N].writeln;
}

Measured memory_bytes: 82812
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		
		int n = sc.nextInt();
		if (n % 2 == 0) {
			System.out.println(n);
		} else {
			System.out.println(n * 2);
		}
	}
}


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

int main(){
  int K, i, len;
  scanf("%d",&K);
  char S[101]={};
  scanf("%s",S);
  len = strlen(S);
  if(K<len){
    for(i=0; i<K;i++){
   		printf("%c",S[i]);
  	}
    printf("...");
  }
  if(K>=len){
        for(i=0; i<len;i++){
   		printf("%c",S[i]);
  	}
  }
}

Measured memory_bytes: 1736
#include <stdio.h>

int main() {
	int L, R, o, ctr = 0;
	scanf("%d %d %d", &L, &R, &o);
	while(L <= R){
		if (L % o == 0){
		ctr = ctr + 1;
		}
		L++;
	}
	printf("%d", ctr);
	return 0;
}


Measured memory_bytes: 1712
n,x=map(int,input().split())
a=[1]
p=[1]
for i in range(n):
    a.append(a[-1]*2+3)
    p.append(p[-1]*2+1)

def num(n,x):
    if n==0 or x<=0:
        return 0 +(x>0)
    elif x<=a[n-1]+1:
        return num(n-1,x-1)
    else:
        return p[n-1]+1+num(n-1,x-a[n-1]-2)

print(num(n,x))

Measured memory_bytes: 38384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class AffineCipher
    {
        internal int a, b;
        internal string txt, result;

        public void Solve(string source)
        {
            txt = source;
            result = "";

            for (a = 3; ; a += 2)
            {
                if (a % 13 != 0)
                {
                    for (b = 0; b < 26; b++)
                    {
                        result = MakeText();

                        if (CheckText(result)) return;
                    }
                }
            }
        }

        private bool CheckText(string s)
        {
            if (s.Contains("that")) return true;
            if (s.Contains("this")) return true;
            return false;
        }

        private string MakeText()
        {
            StringBuilder ret = new StringBuilder();

            for (int i = 0; i < txt.Length; i++)
            {
                if (txt[i] >= 'a' && txt[i] <= 'z')
                {
                    int index = (a * (txt[i] - 'a') + b) % 26;
                    ret.Append((char)('a' + index));
                }
                else ret.Append(txt[i]);
            }
            return ret.ToString();
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();
            AffineCipher AC = new AffineCipher();

            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string input = Console.ReadLine();

                AC.Solve(input);
                sb.AppendLine(AC.result);
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9892
#include<cmath>
#include<bits/stdc++.h>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(lint i=(lint)(n);i>0;--i)
#define reps(i,a,b) for(lint i=a;i<=(lint)(b);i++)
typedef long long lint;
typedef long double ld;
using namespace std;
const ld PI = acos(-1.0);

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

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

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

void get_N1234 (int64 *n1, int64 *n2, int64 *n3, int64 *n4)
{
  int cnt;

  if (n2 == NULL) {
    cnt = scanf("%lld", n1);
    return;
  }
  if (n3 == NULL) {
    cnt = scanf("%lld %lld", n1, n2);
    return;
  }
  if (n4 == NULL) {
    cnt = scanf("%lld %lld %lld", n1, n2, n3);
    return;
  }
  cnt = scanf("%lld %lld %lld %lld", n1, n2, n3, n4);
  return;
}

void omit_LF (void)
{
  char c;
  int  cnt;
  
  cnt = scanf("%c", &c);
  return;
}

char *get_S (int64 n)
{
  char *buf;
  int  i;
  int  cnt;

  buf = malloc((size_t)(n * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  return buf;
}

char *get_SN (int64 max, int64 *size)
{
  char *buf;
  int  i;
  int  n;
  int  cnt;

  buf = malloc((size_t)(max * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  n = strlen(buf);

  *size = n;
  
  return buf;
}

int64 *get_NSeq (int64 n)
{
  int64 *buf;
  int64 i;

  buf = malloc((size_t)(n * sizeof(int64)));
  for (i=0; i<n; i++) {
    get_N(&buf[i]);
  }

  return buf;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;

typedef int64 simple_t;

int compare_simple(const void *a, const void *b)
{
  simple_t *x;
  simple_t *y;

  x = (simple_t *)a;
  y = (simple_t *)b;

  if (x > y) return 1;
  if (y < x) return -1;

  return 0;
}
void qsort_simple (simple_t *array, int size)
{
  qsort(array, size, sizeof(simple_t), compare_simple);
}

int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

int main()
{
  int64 N,M;
  int64 *A;
  int64 i;
  int64 total = 0;
  int64 play=0;
  
  get_NK(&N, &M);
  A = get_NSeq(M);

  for (i=0; i < M; i++) {
    total += A[i];
  }

  if (N >= total) {
    play = N - total;
  } else {
    printf("-1");
    return 0;
  }

  printf("%lld",play);
  return 0;
}



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

static const int margin = 3;
static const int board_size = 8;
char board[margin * 2 + board_size][margin * 2 + board_size];
pair<int, int> start;
int n;

void input_dataset() {
	for(int i = margin; i < margin + board_size; i++) {
		cin >> board[i] + margin;
	}
	cin >> start.second >> start.first;
	start.first += margin - 1;
	start.second += margin - 1;
}

void init() {
	for(int i = 0; i < margin * 2 + board_size; i++) {
		for(int j = 0; j < margin * 2 + board_size; j++) {
			board[i][j] = '0';
		}
	}
}

void solve(pair<int, int> p) {
	for(int i = 0; i < 3; i++) {
		if(board[p.first - (i + 1)][p.second] == '1') {
			board[p.first - (i + 1)][p.second] = '0';
			solve(pair<int, int>(p.first - (i + 1), p.second));
		}

		if(board[p.first + (i + 1)][p.second] == '1') {
			board[p.first + (i + 1)][p.second] = '0';
			solve(pair<int, int>(p.first + (i + 1), p.second));
		}

		if(board[p.first][p.second - (i + 1)] == '1') {
			board[p.first][p.second - (i + 1)] = '0';
			solve(pair<int, int>(p.first, p.second  - (i + 1)));
		}
		
		if(board[p.first][p.second+ (i + 1)] == '1') {
			board[p.first][p.second + (i + 1)] = '0';
			solve(pair<int, int>(p.first, p.second + (i + 1)));
		}
	}
}

void print_board() {
	for(int i = margin; i < board_size + margin; i++) {
		for(int j = margin; j < board_size + margin; j++) {
			cout << board[i][j];
		}
		cout << endl;
	}
}

int main() {
	cin >> n;
	for(int i = 0; i < n; i++) {
		init();
		input_dataset();
		board[start.first][start.second] = '0';
		solve(start);
		cout << "Data " << i + 1 << ":" << endl;
		print_board();
	}
}

Measured memory_bytes: 1164
#include <iostream>
#include <unordered_map>
#include <vector>
#include <string>
using namespace std;

int main(){
    int n;
    string com, str;
    vector<bool> check;
    unordered_map<string, bool> mp;

    cin >> n;
    for(int i=0; i<n; i++){
        cin >> com >> str;

        if(com[0] == 'i') mp[str] = true;
        else{
            if(mp[str]) check.push_back(true);
            else check.push_back(false);
        } 
    }

    for(vector<bool>::iterator it=check.begin(); it!=check.end(); it++){
        if(*it) cout << "yes" << endl;
        else cout << "no" << endl;
    }

    return 0;
}


Measured memory_bytes: 50140
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <math.h>
#define ll long long 
#define PI 3.14159265358979323846
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(x,n) for(ll x=1;x<(ll)n+1;x++)
using namespace std;

int main() {
	string S;
	cin >> S;
	ll con = 0;
	rep(i, 3) {
		if (S[i] == 'R') {
			if (con==0) con++;
			else if (S[i - 1] == 'R') con++;
		}
	}
	cout << con << endl;
	return 0;
}

Measured memory_bytes: 3620
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;
  
  vll ans(1000010, 0);
  repr(i, 1, 101)repr(j, 1, 101)repr(k, 1, 101){
    ans[i*i+j*j+k*k+i*j+j*k+k*i]++;
  }
  repr(i, 1, n+1) print(ans[i]);
}



Measured memory_bytes: 10996
#include<iostream>
#include<math.h>
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include <time.h>
#include<string.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e5+5;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e=2.718281828459045235360287471352662;
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
ll a[maxn];
int main()
{
    ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int n;
    ll sum=0;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sum+=abs(a[0]);
    sum+=abs(a[n-1]);
    for(int i=1;i<n;i++)
        sum+=abs(a[i]-a[i-1]);
    for(int i=0;i<n;i++)
    {
        if(i==0)
            cout<<sum-abs(a[0])-abs(a[1]-a[0])+abs(a[1])<<endl;
        else if(i==n-1)
            cout<<sum-abs(a[n-1])-abs(a[n-1]-a[n-2])+abs(a[n-2])<<endl;
        else
            cout<<sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1])<<endl;
    }
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Measured memory_bytes: 2048
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int a, b, c;
	cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << " " << b << " " << c << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include<cstdio>

const int INF = 1e8;
int n, m;
struct edge {
    int from, to;
    int cost;
    bool jdg = true;
};

edge e[1000];
int d[100][100][100], pr[100][100][100];

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        e[i].from = a - 1;
        e[i].to = b - 1;
        e[i].cost = c;
    }
    
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = 0; k < n; k++) d[i][j][k] = INF;
        }
    }

    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            d[i][j][i] = 0;
            bool update = true;
            while (update) {
                update = false;
                for (int k = 0; k < m; k++) {
                    if (d[i][j][e[k].to] > d[i][j][e[k].from] + e[k].cost) {
                        d[i][j][e[k].to] = d[i][j][e[k].from] + e[k].cost;
                        pr[i][j][e[k].to] = k;
                        update = true;
                    }
                    if (d[i][j][e[k].from] > d[i][j][e[k].to] + e[k].cost) {
                        d[i][j][e[k].from] = d[i][j][e[k].to] + e[k].cost;
                        pr[i][j][e[k].from] = k;
                        update = true;
                    }
                }
            }
            int ind = j;
            while (true) {
                if (ind == i) break;
                int a = pr[i][j][ind];
                e[a].jdg = false;
                ind = (e[a].to == ind) ? e[a].from : e[a].to;
            }
        }
    }
    
    int ans = 0;
    for (int i = 0; i < m; i++) {
        if (e[i].jdg) ans++;
    }

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


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

ll keta(ll i){
    ll res = 0;
    while(i>0){
        i /= 2;
        res++;
    }
    return res;
}

int main(){
    ll n,k;
    cin >> n >> k;
    ve<ll> a(n);
    rep(i,n) cin >> a[i];
    ve<ve<ll>> dp(41,ve<ll>(2,-1));
    dp[0][0] = 0;
    rep(i,40){
        ll id = pow(2,(39-i));
        ll cnt = 0;
        rep(j,n){
            if(a[j] & id) cnt++;
        }
        if(k&id){
            dp[i+1][0] = dp[i][0] + id*(n-cnt);
            if(dp[i][1] == -1) dp[i+1][1] = dp[i][0] + id*cnt;
            else{
                dp[i+1][1] = dp[i][1] + id*max(cnt,n-cnt);
                dp[i+1][1] = max(dp[i+1][1], dp[i][0] + id*cnt);
            }
        }else{
            dp[i+1][0] = dp[i][0] + id*cnt;
            if(dp[i][1] == -1) dp[i+1][1] = -1;
            else dp[i+1][1] = dp[i][1] + id*max(cnt,n-cnt);
        }
    }
    cout << max(dp[40][0],dp[40][1]) << endl;
    return 0;
}

Measured memory_bytes: 4120
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, c[501], s[501], f[501];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    rep(i, 0, n-1) cin >> c[i] >> s[i] >> f[i];
    rep(i, 0, n-1) {
      int ans = 0;
      rep(j, i, n-1) {
        if (ans < s[j]) ans = s[j];
        if ((ans - s[j]) % f[j] != 0) {
          ans += f[j] - (ans - s[j]) % f[j];
        }
        ans += c[j];
      }
      cout << ans << endl;
    }
    cout << 0 << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

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

    ArrayList<Integer> list = new ArrayList<Integer>();
    Arrays.stream(scan.nextLine().split(" ", -1)).forEach(a -> list.add(Integer.parseInt(a)));

    int ans = 0;
    if(list.get(0) >= list.get(1)) {
      ans = 10;
    }
    System.out.println(String.valueOf(ans));
  }
}
  


Measured memory_bytes: 32348
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B,C,D;
  cin >> A >> B >> C >> D;
 
  if (A+B>C+D){
    cout << "Left" <<endl;
  }
  else if (A+B==C+D){
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

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

  string n;
  cin >> n;
  int sum = 0;
  each(c, n) sum += c - '0';
  cout << (sum % 9 ? "No" : "Yes") << endl;
	return 0;
}



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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

int v[101010][3];
int dp[101010][3];

int main() {
    int N;
    cin >> N;
    rep(i, N) {
        rep(j, 3) cin >> v[i][j];
    }

    for (int i = 1; i <= N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                dp[i][j] = max(dp[i][j], dp[i-1][k] + v[i-1][j]);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < 3; ++i) ans = max(ans, dp[N][i]);
    cout << ans << endl;
}


Measured memory_bytes: 5900
<?php
$n = intval(fgets(STDIN));
$A = array_map("intval", explode(" ", trim(fgets(STDIN))));
$max = max($A);
$min = min($A);
if($max - $min > 1){
    echo "No";exit;
}
if($max==$min){
//全員aloneか全員aloneではない
    if($max == $n - 1){//全員aloneな場合
        echo "Yes";exit;
    }else{
        //全員aloneではないので、$maxが大きすぎてはいけない
        if($max <= intdiv($n, 2)){
            echo "Yes";exit;
        }else{
            echo "No";exit;
        }
    }
}else{
    $maxCount = 0;
    foreach($A as $a){
        if($a == $max)$maxCount++;
    }
    $minCount = $n - $maxCount;
    //一部aloneな場合
    if($max > intdiv($maxCount, 2) + $minCount){//aloneではない猫をK匹とすると、その部分の色の数はfloor($K/2)以下である
        echo "No";exit;
    }elseif($maxCount<2){//aloneでない猫は必ず2匹以上いる
        echo "No";exit;
    }elseif($max < 1+$minCount){//色数は1＋aloneな猫の数以上である
        echo "No";exit;
    }else{
        echo "Yes";exit;
    }
}

Measured memory_bytes: 16884
#include <iostream>
#include <cstdio>

using namespace std;
using ll=long long;

int main()
{
    int N;
    
    cin >> N;
    
    if (N / 100 == N % 10)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    
    return 0;
}


Measured memory_bytes: 256