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

using namespace std;
#define rep(i, N) for(int i=0;i<int(N);++i)
#define rep1(i, N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << "{" << p.first << ", " << p.second << "}";
    return os;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

const int INF = (ll) 1e9;
const ll INFLL = (ll) 1e18 + 1;
const ll MOD = (ll) 1e9 + 7;
const double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string S;
    cin >> S;
    if(S == "ABC"){
        cout << "ARC" << endl;
    }
    else{
        cout << "ABC" << endl;
    }

}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main()
{
    int k,s,z,ans=0;
    cin>>k>>s;
    for(int i=0;i<=k;i++)
    {
        for(int j=0;j<=k;j++)
        {
            z=s-(i+j);
            if(i+j+z==s && z<=k && z>=0)
                ans++;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
class abc_165:
    
    def __init__(self):
        pass
    
    def A(self):
        K=int(input())
        AB=list(map(int,input().split()))
        flag=False
        
        for i in range(AB[0],AB[1]+1):
            if i%K==0:
                flag=True
                break
            else :pass
        
        if flag==True:print("OK")
        else: print("NG")
    
    def B(self):
        X=int(input())
        mane=100
        count=0
        
        while(mane<X):
            mane+=int(mane*0.01)
            count+=1
        
        print(count)    
    
    def C(self):
        pass
        
    def D(self):
        pass
    
    def E(self):
        pass
    
    def F(self):
        pass
    
    
if __name__=='__main__':
    obj=abc_165()
    obj.B()

Measured memory_bytes: 63832
def search(x, y, m):
    if x < 0 or y < 0 \
            or x >= len(m[0]) or y >= len(m):
        return 0
    if m[y][x] == '#':
        return 0
    m[y][x] = '#'
    return 1 + search(x+1,y, m) + search(x-1,y,m) \
            + search(x,y+1,m) + search(x,y-1,m)

while True:
    w, h = map(int, input().split())
    if w == 0: break
    room = []
    for i in range(h):
        tmp = list(input())
        room.append(tmp[:w])
        if '@' in tmp:
            y = i
            x = tmp.index('@') 
    print(search(x, y, room))

Measured memory_bytes: 6780
def prime_fact(n):
    i = 2
    table = []
    while i*i<=n:
        while n%i ==0:
            n /=i
            table.append(i)
        i+=1
    if n>1:
        table.append(n)
    return table
n = input()
anslist = prime_fact(n)
print str(n)+":",
for ans in anslist:
    print str(ans),

Measured memory_bytes: 6428
fn main(){
    let mut sc = Scanner::new();
    while sc.ok(){
        let n = sc.next();
        let mut x = vec![0i64; n];
        for i in 0..n {
            x[i] = sc.next();
        }
        let mut d = vec![0i64; n-1];
        for i in 0..n-1 {
            d[i] = x[i+1] - x[i];
        }
        let m = sc.next();
        let k = sc.next();

        let mut perm:Vec<_> = (0..n-1).collect();
        for _ in 0..m {
            let a = sc.next::<usize>() - 1;
            perm.swap(a-1, a);
        }

        let perm2 = pow(&perm, k);
        let mut res = vec![0i64; n-1];
        for i in 0..n-1 {
            res[i] = d[perm2[i]];
        }

        let mut cur = x[0];
        println!("{}", cur);
        for i in 0..n-1 {
            cur += res[i];
            println!("{}", cur);
        }
    }
}

fn pow(perm: &Vec<usize>, k: usize) -> Vec<usize> {
    if k == 0 {
        (0..perm.len()).collect()
    } else if k%2 == 1 {
        let x = pow(perm, k-1);
        prod(&x, &perm)
    } else {
        let x = pow(perm, k/2);
        prod(&x, &x)
    }
}

fn prod(a: &Vec<usize>, b: &Vec<usize>) -> Vec<usize> {
    let n = a.len();
    let mut res = vec![0; n];
    for i in 0..n {
        res[i] = a[b[i]];
    }
    res
}

#[allow(dead_code)]
struct Scanner {
    buf: std::collections::VecDeque<String>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner { buf: std::collections::VecDeque::new() }
    }

    fn next<T: std::str::FromStr>(&mut self) -> T {
        self.wrapped::<T>().unwrap()
    }

    fn wrapped<T: std::str::FromStr>(&mut self) -> Option<T> {
        self.read();
        self.buf.pop_front().and_then(|s| s.parse::<T>().ok())
    }

    fn ok(&mut self) -> bool {
        self.read() && !self.buf.is_empty()
    }

    fn eof(&mut self) -> bool {
        !self.ok()
    }

    fn read(&mut self) -> bool {
        while self.buf.is_empty() {
            let mut st = String::new();
            while st.trim() == "" {
                match std::io::stdin().read_line(&mut st) {
                    Ok(l) if l > 0 => continue,
                    _ => return false,
                }
            }
            self.buf = st.split_whitespace().map(|x| x.to_string()).collect();
        }
        true
    }
}


Measured memory_bytes: 9368
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void solve1();
void solve()
{
    int t;cin>>t;
    while(t--)
    {
        solve1();
    }
}
int main()
{
    solve1();
    return 0;
}
void solve1()
{
    ll n;
    cin>>n;
    ll ans;
    cin>>ans;
    for(ll i=1;i<n;i++)
    {
        ll x;
        cin>>x;
        if(x==0)
        {
            ans=0;
            break;
        }
        else if(x>1000000000000000000/ans)
        {
           //cout<<"me"<<x<<ans<<endl<<1000000000000000000/ans;
            ans=-1;
        }
        else if (ans==-1)
        {
            ans=-1;
        }
        else
        {
            ans*=x;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3640
function main(input) {
    var inputs = input.split("\n");
    var ABC = inputs.shift().split(" ");
    var A = ABC.shift();
    var B = ABC.shift();
    var C = ABC.shift();
    console.log(Math.min(C, Math.floor(B / A)))
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h> 
using namespace std;
  
// Function to print the divisors 

  
/* Driver program to test above function */
int main() 
{ 
	#define int long long
    int n;
    cin>>n;
   int ans=0;
    vector<int> dive(10000005,0);
for(int i=1;i<=10000000;i++){
	int x=i;
	while(x<=10000000) {
		dive[x]+=1;
		x+=i;
	}
}
 	for(int i=1;i<=n;i++) ans+=i*dive[i];
 	cout<<ans; 
    return 0; 
} 

Measured memory_bytes: 81396
//8 may 2020
//count of solved problems : 1
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=2e5+5;
string s[3];
int main(){
	cin>>s[0]>>s[1]>>s[2];
	int t=0;
	while(true){
		if(s[t].size()==0){
			cout<<char(t+'A');
			return 0;
		}
		char c=s[t][0];
		s[t].erase(s[t].begin());
		t=c-'a';
	}
	
}



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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

const int N = 1e5 + 5;

set<string> s;

int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        string t; cin >> t;
        s.emplace(t);
    }

    cout << s.size() << endl;

    return 0;
%>

Measured memory_bytes: 19248
using System;

namespace AOJ.Volume1
{
    public class BusLine
    {
        public static int Main()
        {
            var course = new int[16] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1, 0 };
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                var input = Console.ReadLine().Split(' ');
                int start = int.Parse(input[0]);
                int goal = int.Parse(input[1]);

                bool desc = false;
                if (start >= 1 && start <= 5)
                {
                    // 2方向のバスを選べる
                    // 目的の停留所が乗車する停留所より小さい場合は逆順
                    if (goal < start) { desc = true; }
                }

                // 逆順の場合はスタート位置を調整
                int pos = start;
                if (desc)
                {
                    for (int j = 10; j <= 15; j++)
                    {
                        if (course[j] == start)
                        {
                            pos = j;
                            break;
                        }
                    }
                }

                string answer = "";
                for (int j = pos; j <= 15; j++)
                {
                    answer += course[j] + " ";
                    if (course[j] == goal) { break; }

                    // ループ最終回でも降車場所に着かない場合
                    if (j == 15) { j = 0; }
                }
                Console.WriteLine(answer.Trim());
            }
            return 0;
        }
    }
}

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

int main(){
	string s; cin>>s;
	string ans;
	rep(i,s.size()){
		if(s[i]=='0') ans+='0';
		else if(s[i]=='1') ans+='1';
		else if(ans.size()!=0&&s[i]=='B') ans.erase(ans.size()-1);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<bits/stdc++.h>
#define ll                    long long int
#define fo(i,a,b)          for( i=(ll)a;i<(ll)b;++i)
#define loopr(i,a,b)          for(int i=(int)a;i>=(int)b;--i)
#define pb                    push_back
#define mset(a,b,c)           loop(i,0,b) a[i]=c
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define MAX                   1e9
#define MIN                   -1e9
#define vi                    vector<ll>
#define vvi                   vector<vi>
#define pll                   pair<ll,ll>
#define all(p)                p.begin(),p.end()
#define max(x,y)              (x>=y)?x:y
//#define min(x,y)              (x<=y)?x:y
#define mid(s,e)              (s+(e-s)/2)
#define start()                  int t; scanf("%d",&t); while(t--)
using namespace std;
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll min(ll x,ll y)
{
		return x<=y?x:y;
}

int main()
{
    ll a,b,n;
    cin>>a>>b>>n;
    ll x=min(b-1,n);
    ll ans= floor(a*x/b)-a*floor(x/b);
    cout<<ans;

}

Measured memory_bytes: 3596
def resolve():
    n = int(input())
    cs = list(map(int, input().split()))
    bs = list(map(int, input().split()))
    count = 0

    for i in range(n):
        if cs[i] >= bs[i]:
            count += bs[i]
        else:
            next_defeat = min(cs[i+1], bs[i] - cs[i])
            cs[i+1] = cs[i+1] - next_defeat
            count += cs[i]
            count += next_defeat

    print(count)
resolve()

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<string> A(N);
  vector<string> B(M);
  for (int i=0; i<N; i++) cin >> A[i];
  for (int i=0; i<M; i++) cin >> B[i];

  string ans = "No";
  // A の中には B が N-M+1 個あるのでそれを検査
  for (int y=0; y<N-M+1; y++) {
    for (int x=0; x<N-M+1; x++) {
      bool flag = true;

      for (int i=0; i<M; i++) {
        for (int j=0; j<M; j++) {
          if (A[y+i][x+j] != B[i][j]) flag = false;
        }
      }

      if (flag) {
        ans = "Yes";
        break;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

//abc142D
int main(void) {
  int c=1;
  long long a, b, tmp, i=2, memo=1;
  scanf("%lld %lld", &a, &b);

  if(a < b) tmp=a, a=b, b=tmp; //ユークリッドの互除法//gcd(a,b)=>b
  while(a % b != 0){
    a=a % b;
    if(a < b) tmp=a, a=b, b=tmp;
  }
  //printf("b=%lld\n", b);
  while(i <= sqrt(b)){
    if(b % i == 0){
      if(memo != i) c++;
      b/=i, memo=i;
    }else i++;
  }
  if(b != 1 && b!=i) c++;
  printf("%d", c);
}

Measured memory_bytes: 128
(a, b, c) = input().rstrip().split(' ')
a = int(a)
b = int(b)
c = int(c)
 
if a < b < c:
    print(a, b, c)
elif a < c < b:
    print(a, c, b)
elif b <= a <= c:
    print(b, a, c)
elif b <= c <= a:
    print(b, c, a)
elif c <= a <= b:
    print(c, a, b)
else:
    print(c, b, a)

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

int n, m, k;
char s[11][11];

int main() {
	scanf("%d%d%d", &n, &m, &k);
	for(int i=0;i<n;i++) scanf("%s", s[i]);
	
	int lim = (1<<(n+m));
	int ans = 0;
	for(int mask = 0; mask < lim; mask ++) {
		int cnt = 0;
		for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			if (s[i][j] == '#' && 
				!(mask & (1<<i)) &&
				!(mask & (1<<(n+j))))
				cnt++;
		if(cnt == k) ans++;
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 3824
import java.util.Scanner;

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

    long A = scanner.nextLong() - 1;
    long B = scanner.nextLong();
    long C = scanner.nextInt();
    long D = scanner.nextInt();

    long lcm = lcm(C, D);
    System.out.println(B - (B / C) - (B / D) + (B / lcm) - A + (A / C) + (A / D) - (A / lcm));
  }

  private static long lcm(long i, long j) {
    return i / gcd(i, j) * j;
  }

  private static long gcd(long i, long j) {
    if (i > j) return gcd(j, i);
    while (i > 0) {
      long r = j % i;
      j = i;
      i = r;
    }
    return j;
  }
}


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

int main() {
  long long a,b,k;
  cin >> a >> b >> k;
  if(a+k > b-k){
    for(long long i = a;i <= b;i++){
      cout << i << endl;
    }
  }
  else{
    for(long long i = a;i < a+k;i++){
      cout << i << endl;
    }
    for(long long i = b-k+1;i <= b;i++){
      cout << i << endl;
    }
  }
}


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

int main(){
   
    int N;
    string S;
    cin>>N>>S;
    int r=0,b=0;
    for(int i=0;i<N;i++){
        if(S[i]=='R') r++;
        else b++;
    }
    if(r>b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::suspicious_arithmetic_impl)]

// using Rust(1.42.0)
// My Library Repo is at "https://github.com/Loptall/prcn_lib"
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"

/*
    AtCoder Language Update 2020204 お疲れ様でした! 有難いです
*/


// Dep crates are...
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::{i32, i64, isize, u32, u64, usize};

use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_integer::{binomial, gcd, lcm, Integer};
use permutohedron::Heap;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

// code...
#[fastout]
fn main() {
    input! {
        n: i64, m: usize,
        a: [i64; m]
    }

    let ans: i64 = n - a.iter().sum::<i64>();

    println!("{}", if ans >= 0 { ans } else { -1 });
}


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	ll a[n], b[n];
	FOR(i,0,n)
		cin >> a[i] >> b[i];
	ll ans = 0;
	FORR(i,n-1,0){
		int amari = (a[i]+ans) % b[i];
		if(amari == 0)continue;
		int button = b[i] - amari;
		ans += button;
	}
	ANS(ans);
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;
 
int main() {
    int k;
    cin >> k;
    queue<ll> q;
    repr(i,1,10) q.push(i);
    int cnt=1;
    while(cnt<k) {
        ll p=q.front();
        q.pop();
        if (p%10>0) q.push(10*p+p%10-1);
        q.push(10*p+p%10);
        if (p%10<9) q.push(10*p+p%10+1);
        ++cnt;
    }
    
    cout << q.front() << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;
const int M = 100000;
const double pi = 3.141592653589;

int main()
{
	cout << fixed;
	double r;
	cin >> r;
	printf("%.8lf %.8lf\n", pi*r*r, 2 * pi*r);
	return 0;
}

Measured memory_bytes: 3296
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
     
    int i, x;
     
    for(i = 1; i <= 10000; i++){
        cin >> x;
            if(x == 0){
                break;
            }
        cout << "Case " << i << ": " << x << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
s = input()
s_len = len(s)
if s_len % 2:
  print("No")
else:
  prev = 0
  count = 0
  for i in range(1, (s_len//2)+1):
    if s[prev*2:i*2] != "hi":
      print("No")
      break
    else:
      count += 1
      prev = i
  if count == s_len // 2:
    print("Yes")

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

vector<ll>par(2e5+10);
void init(ll n) {
  for(ll i=0;i<n;i++) {
    par[i]=i;
  }
}

ll root(ll x) {
  if(par[x]==x) {
    return x;
  }
  else {
    return par[x]=root(par[x]);
  }
}

bool same(ll x, ll y) {
  return root(x)==root(y);
}

void unite(ll x, ll y) {
  if(same(x,y)) return;
  par[root(x)]=root(y);
}

int main() {
  ll n,m;
  cin >> n >> m;
  vector<ll> a(m);
  vector<ll> b(m);
  for(ll i=0;i<m;i++) {
    cin >> a[i] >> b[i];
  }
  ll ans=0;
  for(ll i=0;i<m;i++) {
    init(n);
    for(ll j=0;j<m;j++) {
      if(j==i) continue;
      unite(a[j]-1,b[j]-1);
    }
    bool flag=false;
    for(ll j=0;j<n;j++) {
      for(ll k=j+1;k<n;k++) {
        if(!same(j,k)) {
          flag=true;
          ans++;
          break;
        }
      }
      if(flag) {
        break;
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
	int n;
	while(cin >> n , n){
		vector<string> s(n);
		vector<int> cnt(n);
		for(int i = 0;i < n;i++){
			cin >> s[i];
			while(cnt[i] < (int)s[i].size() && s[i][cnt[i]] == '.') s[i][cnt[i]] = ' ', cnt[i]++;
			if(cnt[i] > 0) s[i][cnt[i] - 1] = '+';
		}
		for(int i = 0;i < n;i++){
			if(i - 1 >= 0 && cnt[i] < cnt[i - 1]){
				int p = i - 1;
				while(p >= 0 && s[p][cnt[i] - 1] == ' '){
					s[p][cnt[i] - 1] = '|';
					p--;
				}
			}
		}
		for(int i = 0;i < n;i++){
			cout << s[i] << endl;
		}
	}
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d;
int main(){
	cin>>a>>b>>c>>d;a--;
	long long r=__gcd(c,d),k=c*d/r,x=b/c-a/c,y=b/d-a/d,z=b/k-a/k;
	cout<<b-a-x-y+z;
}

Measured memory_bytes: 256
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *

X,Y,Z,K=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
B=sorted(list(map(int,input().split())),reverse=True)
C=sorted(list(map(int,input().split())),reverse=True)

lst=[]
for a in A:
    for b in B:
        lst.append(a+b)
lst.sort(reverse=True)
lst=lst[:K]

_lst=[]
for a in lst:
    for c in C:
        _lst.append(a+c)

_lst.sort(reverse=True)
for i in range(K):
    print (_lst[i])


Measured memory_bytes: 148240
import std.stdio;
import std.conv;
import std.algorithm;
import std.string;
import std.file;
import std.math;

int main() {
	string l;
	int[] stack;
	while((l = readln(), l.length)){
		l = l.split("\n")[0];
		
		if(!l.length || !l.split[0].length) break;
		int a = to!int(l.split[0]);
		
		if(a > 0) stack ~= a;
		else printf("%d\n", stack[$-1]), stack = stack[0..$-1];
		}
	return 0;
	}

Measured memory_bytes: 1100
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    int K; cin >> K;
    ll ans = 0;
    rep(i, 1, K + 1)
    {
        rep(j, 1, K + 1)
        {
            rep(k ,1, K + 1)
            {

                ans += gcd(gcd(i, j), k);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] dp = new int[30];
            dp[0] = 1;
            dp[1] = 2;
            dp[2] = 4;
            for (int i = 3; i < 30; ++i) 
            {
                dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
            }
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0)
                    break;

                Console.WriteLine((dp[n - 1] / 3650 + 1).ToString());
            }
        }
    }
}

Measured memory_bytes: 5604
import java.io.IOException
import java.lang.NumberFormatException
import java.lang.StringBuilder
import kotlin.math.max
import kotlin.math.pow

object AMain{
    fun solve(){
        val n = nextInt()
        val x = nextInt()
        val t = nextInt()
        if(n % x == 0){
            println(t * (n / x))
        }else{
            println(t * (n / x + 1))
        }
    }





    // Scanner based on uwi-san's Java code
    val stream = System.`in`
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0

    fun hasNextByte(): Boolean{
        if(ptr < buflen){
            return true
        }else{
            ptr = 0
            try{
                buflen = stream.read(buffer)
            }catch (e: IOException){
                e.printStackTrace()
            }
            if(buflen <= 0){
                return false
            }
        }
        return true
    }

    fun readByte() =
        if(hasNextByte()) buffer[ptr++]
        else -1

    fun isPrintableChar(c: Byte) = c in 33..126

    fun hasNext(): Boolean{
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++
        return hasNextByte()
    }

    fun next(): String{
        if(!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while(isPrintableChar(b)){
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun nextLong(): Long{
        if(!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if(b == '-'.toByte()){
            minus = true
            b = readByte()
        }
        if(b !in '0'.toByte()..'9'.toByte())
            throw NumberFormatException()
        while(true){
            if(b in '0'.toByte()..'9'.toByte()){
                n *= 10
                n += b - '0'.toByte()
            }else if(!isPrintableChar(b)){
                return if(minus) -n else n
            }else{
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextInt(): Int{
        val n1 = nextLong()
        if(n1 !in Int.MIN_VALUE..Int.MAX_VALUE)
            throw NumberFormatException()
        return n1.toInt()
    }

    fun NextDouble() = next().toDouble()
}

fun main(){
    AMain.solve()
}



Measured memory_bytes: 33752
/* 実行時間1s制限の場合10^6 1,000,000 : 余裕をもって間に合う10^7
  10,000,000 : おそらく間に合う10^8 100,000,000 : 非常にシンプルな処理
  でないと厳しい
 */
#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)
#include <bits/stdc++.h>
#define M_PI 3.14159265358979323846
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

const ll INF = LONG_MAX;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(int argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    //std::ifstream in(string(argv[0]) + ".txt");
    std::ifstream in("in.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int x,y,z;
    cin >> x >> y >> z;

    cout << (x-z) / (y+z);

    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));  // 2次元配列初期化
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let a: Vec<u64> = sc.vec(n);
    let mut xor = 0;
    for i in 0..n {
        xor ^= a[i];
    }

    for i in 0..n {
        if i > 0 {
            sc.write(" ");
        }
        sc.write(xor ^ a[i]);
    }
    sc.write("\n");
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4100
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ull unsigned long long

void fast_IO() { ios_base::sync_with_stdio(false);cin.tie(NULL);}
void test_here_once(){ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);}

int main()
{
	ll n,w; cin>>n>>w;
	ll wt[n], val[n];
	for(ll i=0;i<n;i++) cin>>wt[i]>>val[i];

	vector<vector<ll> > dp(n+1, vector<ll>(w+1,0));

	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=w;j++)
		{
			if(wt[i-1]<=j)
			{
				dp[i][j]= max(val[i-1] + dp[i-1][j-wt[i-1]], dp[i-1][j]);
			}
			else dp[i][j]= dp[i-1][j];			
		}
	}
	cout<<dp[n][w];
}

Measured memory_bytes: 83124
#include<stdio.h>
int main()
{   int A, B, C, D;
    scanf("%d%d%d%d", &A,&B,&C,&D);
    if(A<=B && C<=D ){printf("%d", (A+C));}
    else if(B<=A && D<=C){printf("%d", (B+D));}
    else if(A<=B && D<=C){printf("%d", (A+D));}
    else{printf("%d", (B+C));}
        return 0;
}



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

int main() {
  int N,L;
  cin>>N>>L;
  if(L<0&&L+N-1>=0){
    cout <<N*(N+1)/2+N*(L-1)<<endl;
  }
  if(L<0&&L+N-1<0){
    cout <<N*(N+1)/2+N*(L-1)+1-L-N<<endl;
  }
   if(L>=0){
    cout <<N*(N+1)/2+N*(L-1)-L<<endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, x = mi()
    L = lmi()
    a = accumulate(L)
    print(len(list(filter(lambda num: num<=x, a))) + 1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ABC113A
{
    class Program
    {
            static void Main(string[] args)
            {
 
 
                var word = Console.ReadLine().Split();
                int a = int.Parse(word[0]);
                int b = int.Parse(word[1]);
                int max = 0;
            max = a + (b / 2);
                Console.WriteLine(max);
                Console.ReadKey();
 
 
 
            }
        }
    }

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

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; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    ll A, B;
    cin >> A >> B;

    if(A>=13){
        p(B);
    }
    else if(A<=5){
        p(0);
    }
    else{
        p(B/2);
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ara[400],n;
int one=0,two=0,three=0;
 
double dp[302][302][302];
 
double f(int x,int y,int z){
   
    double res,j,k,l,m;
    j=x,k=y,l=z,m=n;
    if(x<0 || y<0 || z<0) return 0;
    else if(x==0 && y==0 && z==0) return 0;
     if(dp[x][y][z]>-10) return dp[x][y][z];
    else{
        res=(m+j*f(x-1,y,z)+k*f(x+1,y-1,z)+l*f(x,y+1,z-1))/m;
        res=res/(1-((m-(x+y+z))/m));
    }
   dp[x][y][z]=res;
    return res;
}
 
 
int main(){
   for(int i=0;i<302;i++)  for(int j=0;j<302;j++)  for(int k=0;k<302;k++) dp[i][j][k]=-50;
    cin >> n;
    for(int i=0;i<n;i++) cin >> ara[i];
    for(int i=0;i<n;i++){
        if(ara[i]==1) one++;
        else if(ara[i]==2) two++;
        else three++;
    }
   
   
  
    
    
    
    printf("%0.12lf\n",f(one,two,three));
    
}


Measured memory_bytes: 219036
n = int(input())
w = list(map(int, input().split()))
ans = float('inf')
s1 = 0
s2 = sum(w)
for t in range(0,n):
    s1 += w[t]
    s2 -= w[t]
    ans = min(ans, abs(s1-s2))
print(ans)

Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)
// #define NMAX 1000000000
int H,W;
vector<string> A;

void solve(){

	vector<string> B;
	rp(h,0,H){
		rp(w,0,W){
			if(A[h][w] == '#'){
				B.push_back(A[h]);
				break;
			}
		}
	}

	// for(auto x:B) cout<<x<<endl;///

	vector<string> C(B.size());

	int wc = 0;
	rp(w,0,W){
		int h;
		for(h=0; h<B.size(); ++h){
			if(B[h][w] == '#'){
				break;
			}
		}

		// cout<<h<<" "<<B.size()<<"\n";///
		if(h < B.size()){
			for(h=0; h<B.size(); ++h){
				C[h] += B[h][w];
			}
		}

	}

	for(auto x:C) cout<<x<<endl;

}

int main(){
	cin>>H>>W;
	A.resize(H);
	rp(i,0,H) cin>>A[i];
	solve();
}


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

int main(){
  string s;
  cin >> s;
  int l = s.size();
  int si = 0, gi = 0;
  for(int i = 0; i < l; i++){
    if(s.at(i) == 'A'){
      si = i;
      break;
    }
  }
  for(int i = l-1; i > 0; i--){
    if(s.at(i) == 'Z'){
      gi = i;
      break;
    }
  }
  cout << gi - si + 1 << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 1e5 + 5;
string a;
int main()
{
    ios::sync_with_stdio(false);
    int n; cin >> n;
    cin >> a;
    int all = 0 , cnt = 0;
    for (auto g : a) if (g == 'R') all++;
    for (int i = 0 ; i < all ; i++){
        if (a[i] == 'R') cnt++;
    }
    cout << all - cnt << endl;
    return 0;
}


Measured memory_bytes: 3756
#include<iostream>
#include<cassert>
#define _A_ true
using namespace std;


int main(){
  long long b,r,g,c,s,t;
  while(_A_){
    cin >> b >> r >> g >> c >> s >> t;
    if(b+r+g+c+s+t == 0)break;
    long long sem = 100;
    sem += 7*g;
    sem += 2*c;
    sem += 15*b*6;
    sem += 15*r*4;
    t -= (b*5+r*3+s);
    sem -= b*2*5;
    assert(sem>=0);
    sem-= r*2*3;
    assert(sem>=0);
    sem -= t*3;
    assert(sem>=0);
    cout << sem << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const Int MAX = 2000010;
const Int MOD = 1000000007;
Int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
Int COM(int n, int k) {
    if (n < k || n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
void add(Int& x, Int y) {
    x = (x + y % MOD) % MOD;
}
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    COMinit();
    int R1, C1, R2, C2; cin >> R1 >> C1 >> R2 >> C2;
    vector<int> A(R2 + 1), B(C2 + 1);
    for (int i = 0; i < A.size(); i++) {
        A[i] = COM(C1 + i, i);
    }
    for (int i = 0; i < B.size(); i++) {
        B[i] = COM(R1 + i, i);
    }
    Int ans = 0;
    for (int r = R1 + 1; r <= R2; r++) {
        Int n = C2 - C1, m = R2 - r + 1;
        add(ans, (COM(m + n, n) + MOD - 1) % MOD * A[r]);
    }
    for (int c = C1 + 1; c <= C2; c++) {
        Int n = C2 - c + 1, m = R2 - R1;
        add(ans, (COM(m + n, n) + MOD - 1) % MOD * B[c]);
    }
    for (int r = R1; r <= R2; r++) add(ans, A[r]);
    for (int c = C1 + 1; c <= C2; c++) add(ans, B[c]);
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main () {
    long long N, K;

    cin >> N >> K;

    vector<int> A(N + 1);

    for(int i = 1; i <= N; i++) {
        cin >> A[i];
    }

    vector<int> step(N + 1, -1);

    int current = 1;
    int loop;
    for(int i = 0; i < N; i++) {
        if(step[current] == -1) {
            step[current] = i;
            current = A[current];
        } else {
            loop = i - step[current];
            break;
        }
    }

    if(K < step[current]) {
        current = 1;
        for(int i = 0; i < K; i++) {
            current = A[current];
        }
        cout << current << endl;
        return 0;
    }

    K -= step[current];
    K = K % loop;

    for(int i = 0; i < K; i++) {
        current = A[current];
    }

    cout << current << endl;

    return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define FOR(i, n) for(ll i = 0; i < n; i++)
#define FORR(i, n) for(ll i = n; i >= 0; i--)
#define FORS(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) accumulate(v.begin(),v.end(),0)
#define SORT(v) sort(v.begin(),v.end())
#define OUT(n) (cout << n << endl)
#define IN1(a) (cin >> a)
#define IN2(a,b) (cin >> a >> b)
#define IN3(a,b,c) (cin >> a >> b >> c)
#define IN4(a,b,c,d) (cin >> a >> b >> c >> d)
using namespace std;
typedef long long ll;

int main(){
  int a;
  string s;
  IN2(a,s);
  if (a >= 3200){
    OUT(s);
  }
  else
  {
    OUT("red");
  }
  
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		TreeSet<String> set = new TreeSet<String>();
		for (int i = 0; i < N; i++) {
			set.add(sc.next());
		}
		sc.close();

		System.out.println(set.size());
	}
}


Measured memory_bytes: 77884
module ch
  implicit none
  type char
     character(100)      :: chara
  end type char
  type(char),allocatable :: namec(:)
end module ch
program main
   
  use ch, only : namec 

  implicit none
  integer :: n, l
  character(10000) :: ans
  integer, allocatable :: s(:)
  integer :: i,j,k
  
  read(*,*) n, l

  allocate( s(n) )
  allocate( namec(n) )

  do i = 1, n
    read(*,*) namec(i)%chara
  end do

  call quicksort1( 1, n ) 
  
  j = 1
  do i = 1, n
    ans(j:j+l) = trim( namec(i)%chara )
    j = j + l 
  end do
  ans = ans(1:j)
  print*,ans

end program main
recursive subroutine quicksort1( first, last )
!recursive subroutine quicksort1( a%chara, first, last )

  use ch, only : namec 

  implicit none
  integer,intent(in)::first,last
  !type char
  !   character(100) :: chara 
  !end type 
  !type(char),intent(inout)::a(*)
  !
  ! Original
  ! https://gist.github.com/t-nissie/479f0f16966925fa29ea
  !
  character(100)::x,t
  integer::i,j

  x = namec((first+last)/2)%chara
  !x = a((first+last)/2)%chara
  i = first
  j = last
  do
     do while ( LGT( x, namec(i)%chara ) )
     !do while ( LGT( x, a(i)%chara ) )
        i=i+1
     end do
     do while ( LGT( namec(j)%chara, x ) )
     !do while ( LGT( a(j)%chara, x ) )
        j=j-1
     end do
     if (i >= j) exit
     t = namec(i)%chara
     namec(i)%chara = namec(j)%chara
     namec(j)%chara = t
     i=i+1
     j=j-1
  end do
  if (first < i-1) call quicksort1( first, i-1  )
  if (j+1 < last)  call quicksort1( j+1  , last )

  return

end subroutine quicksort1

!recursive subroutine quicksort1(a, first, last )
!  implicit none
!  integer,intent(inout)::a(*)
!  integer,intent(in)::first,last
!  !
!  ! Original
!  ! https://gist.github.com/t-nissie/479f0f16966925fa29ea
!  !
!  integer::x,t
!  integer::i,j
!
!  x = a((first+last)/2)
!  i = first
!  j = last
!  do
!     do while (a(i) < x)
!        i=i+1
!     end do
!     do while (x < a(j))
!        j=j-1
!     end do
!     if (i >= j) exit
!     t = a(i)
!     a(i) = a(j)
!     a(j) = t
!     i=i+1
!     j=j-1
!  end do
!  if (first < i-1) call quicksort1(a, first, i-1)
!  if (j+1 < last)  call quicksort1(a, j+1, last)
!
!  return
!end subroutine quicksort1



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <list>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

struct UnionFind {
private:
	const int n;
	int __size;
	vector<int> uf;
public:
	// 初期化 UnionFind uni(n) のように宣言すれば良い
	UnionFind(int _n) : n(_n), __size(_n), uf(_n, -1) {}
	// find (木の根を求める)
	int find(int x) { return (uf[x] < 0) ? x : uf[x] = find(uf[x]); }
	// x と y が同じ集合に属するかどうか
	bool same(int x, int y) { return find(x) == find(y); }
	// x が属する集合の要素数
	int size(int x) { return -uf[find(x)]; }
	// 集合はいくつあるか
	int size() { return __size; }
	// x と y の属する集合を併合
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return false;
		__size--;
		if (uf[y] < uf[x]) swap(x, y);
		uf[x] += uf[y]; uf[y] = x;
		return true;
	}
};

using Graph = vector< vector<int> >;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m;
	cin >> n >> m;
	vector<int> x(m), y(m), z(m);
	rep(i, m) cin >> x[i] >> y[i] >> z[i];

	UnionFind uni(n);

	rep(i, m) {
		uni.unite(x[i] - 1, y[i] - 1);
	}

	cout << uni.size() << endl;

	return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define ff               first
#define ss               second
#define pb               push_back
#define all(x)           (x).begin(), (x).end()
#define mem0(x)          memset(x, 0, sizeof (x))
#define mem1(x)          memset(x, -1, sizeof (x))

typedef long long ll;
#define int ll
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector <ii> vii;
typedef vector<vii> vvii;
typedef vector <ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;

vvii g;
vi p, vls;
vi comp, comp_size;
vll total, vis, max_con_sum;

void dfs(int u, int rep){
    vis[u] = 1;
    comp[u] = rep;
    comp_size[rep]++;
    total[comp[u]] += vls[u];
    for (ii v: g[u]){
        if (!vis[v.ff]) dfs(v.ff, rep);
    }
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    p.resize(n+1);
    comp.resize(n+1);
    total.assign(n+1, 0);
    comp_size.assign(n+1, 0);
    vis.assign(n+1, 0);
    max_con_sum.assign(n+1, 0);
    vls.resize(n+1);
    g.assign(n+1,vii());
    for (int i = 1; i <= n; ++i) {
        cin >> p[i];
    }
    int maxi = -1000000000;
    for (int i = 1; i <= n; ++i) {
        cin >> vls[p[i]];
        maxi = max(vls[p[i]], maxi);
    }
    if (maxi <= 0){
        //cout << maxi << "\n";
       // return 0;
    }
    for (int j = 1; j <= n; ++j) {
        g[p[j]].pb({p[p[j]], vls[p[p[j]]]});
    }
    for (int k = 1; k <= n; ++k) {
        if (!vis[k]) dfs(k, k);
    }
    ll ans = -1e18;
    vis.assign(n+1,  0);
    for (int l = 1; l <= n; ++l) {
        if (vis[comp[l]]) continue;
        vis[comp[l]] = 1;
        for (int len = 1; len <= min(k, comp_size[comp[l]]); ++len) {
            int p1 = l, p2 = l;
            int sum = 0;
            for (int i = 0; i < len; ++i) {
                sum += vls[p2];
                p2 = g[p2][0].ff;
            }
            for (int j = 0; j <= comp_size[comp[l]]; ++j) {
                if (total[comp[l]] > 0) ans = max(ans, sum + (k-len)/comp_size[comp[l]] * total[comp[l]]);
                else ans = max(ans, sum);
                sum += vls[p2];
                p2 = g[p2][0].ff;
                sum -= vls[p1];
                p1 = g[p1][0].ff;
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 4368
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s: Vec<char> = iterator.next().unwrap().chars().collect();

    let mut ans: usize = 0;
    for i in 0..(s.len() / 2) {
        if s[i] != s[s.len() - 1 - i] {
            ans += 1;
        }
    }
    return ans.to_string();
}


Measured memory_bytes: 4352