akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n; cin >> n;
	vector<int> a(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum ^= a[i];
	}

	for (int i = 0; i < n; i++) {
		int ret = sum ^ a[i];
		cout <<ret<< endl;
	}
	return 0;
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(b, a * n);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <vector>
#include<map>
#include<algorithm>
#include<iomanip>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
const ll MOD = 1e9 + 7;

int main() {
	string s;
	cin >> s;
	string t;
	cin >> t;
	int c = 0;
	rep(i, 3) if (s[i] == t[i]) c++;
	cout << c << endl;
}


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

const int mod = 1000000007;
struct mint
{
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

mint nCr(int n, int r)
{
    int nr = n - r;
    mint ans = 1;
    for (int i = 1; i <= n; ++i)
        ans *= i;
    for (int i = 1; i <= r; ++i)
        ans /= i;
    for (int i = 1; i <= nr; ++i)
        ans /= i;

    return ans;
}

int main()
{
    int x, y;
    cin >> x >> y;

    if ((x + y) % 3 != 0)
    {
        cout << 0 << endl;
        return 0;
    }

    int n = (x + y) / 3;
    x -= n;
    y -= n;
    if (x < 0 || y < 0)
    {
        cout << 0 << endl;
        return 0;
    }

    cout << nCr(x + y, x) << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;
int i,j,k,n,m;
string s;

int main() {
  cin >>n;
  vector<long> v(n), a;
  for(i=0;i<n;++i) cin >> v[i];
  a = v;
  sort(a.begin(),a.end());
  long med1 = a[n/2-1];
  long med2 = a[n/2];
  for(i=0;i<n;++i) {
    if(v[i]<=med1){
      cout << med2 << endl;
    } else {
      cout << med1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 5376
n = int(raw_input())
item_9 = [59049, 6561, 729, 81, 9]
item_6 = [46656, 7776, 1296, 216, 36, 6]

def min_n(yen):
  if yen <= 5:
    return yen
  else:
    small_6 = small_9 = yen
    for x in item_9:
      if x > yen:
        continue
      else:
        small_9 = min_n(yen-x) + 1
        break
    for x in item_6:
      if x > yen:
        continue
      else:
        small_6 = min_n(yen-x) + 1
        break
  return min(small_9, small_6)

print(min_n(n))

Measured memory_bytes: 2820
s = input()

list = []
count = 0

for i in range(len(s)):
	list.append(s[i])
	
for j in range(len(s)):
	if s.count(list[j]) >= 2:
		print('no')
		break
	if s.count(list[j]) == 1:
		count += 1
	if count == len(s):
		print('yes')
		break

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 10007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //------------------------------
    int m,f,r;cin>>m>>f>>r;
    while(!(m==-1&&f==-1&&r==-1)){
        if(m==-1||f==-1){
            cout<<'F'<<endl;
        }
        else if(m+f>=80){
            cout<<"A"<<endl;
        }
        else if(m+f>=65){
            cout<<"B"<<endl;
        }
        else if(m+f>=50){
            cout<<"C"<<endl;
        }
        else if(m+f>=30){
            if(r>=50)cout<<"C"<<endl;
            else cout<<"D"<<endl;
        }
        else cout<<"F"<<Endl;

        cin>>m>>f>>r;
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------


































Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    
    int ans;

    if (A + B > 2 * C){
        if (A > 2 * C && B > 2 * C){
            ans = 2 * C * max(X, Y);
        }
        else{
            if (X < Y){
                if (B > 2 * C){
                    ans = 2 * C * max(X, Y);
                }
                else{
                    ans = 2 * C * X + B * (Y - X);
                }
            }
            else{
                if (A > 2 * C){
                    ans = 2 * C * max(X, Y);
                }
                else{
                     ans = 2 * C * Y + A * (X - Y);
                }
            }
        }
    }
    else{
        ans = A * X + B * Y;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
open System

let mutable c = 0
let n = stdin.ReadLine() |> int
let x = stdin.ReadLine().Split() |> Array.map int
let odd = [|1..n|] |> Array.filter (fun elem -> elem % 2 = 1 )

Array.iter (fun i -> 
   let k = i-1
   if (Array.get x k) % 2 = 1 then c<-c+1) odd
printf "%d" c

Measured memory_bytes: 30512
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
#include <numeric>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define repi(m, itr) for (auto itr = m.begin();itr != m.end();++itr)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// C - Strange Bank
// 貰うDP
int N;
int ans = 200000;
int dp[101000];
const int upb = 200000;

int main(){
    cin >> N;
    dp[0] = 0;
    rep(i, 1, N+1){
        dp[i] = upb;
        rep(j, 0, 7){
            int tmp = i-(int)pow(6,j);
            if(tmp>=0){
                dp[i] = min(dp[i], dp[tmp]+1);
            }
        }
        rep(j, 0, 7){
            int tmp = i-(int)pow(9,j);
            if(tmp>=0){
                dp[i] = min(dp[i], dp[tmp]+1);
            }
        }
    }
    ans = dp[N];
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 640
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::*;
use std::ops::*;
use std::*;

// -----------------------------------------------
// Framework
// -----------------------------------------------

#[allow(unused)]
fn rl() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused)]
fn rw<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|word| T::from_str(word).unwrap())
        .collect()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

#[allow(unused)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        {
            let entries = &[
                $((
                    &stringify!($arg).to_string() as &fmt::Debug,
                    &($arg) as &fmt::Debug,
                )),*
            ];
            eprintln!("{:?}", DebugMap(entries));
        }
    };
}

#[allow(unused)]
struct DebugMap<'a>(&'a [(&'a fmt::Debug, &'a fmt::Debug)]);

impl<'a> std::fmt::Debug for DebugMap<'a> {
    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
        let mut m = fmt.debug_map();
        for &(key, value) in self.0.iter() {
            m.entry(key, value);
        }
        m.finish()
    }
}

// -----------------------------------------------
// Polyfill
// -----------------------------------------------

#[derive(PartialEq, Eq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

#[allow(unused)]
macro_rules! eprintln {
    ($($arg:expr),*) => { _eprintln(format_args!($($arg),*)) }
}

fn _eprintln(args: fmt::Arguments) {
    let err = std::io::stderr();
    let mut err = err.lock();
    err.write_fmt(args).unwrap();
    err.write(b"\n").unwrap();
}

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

pub fn main() {
    let S = rl();
    let N = S.len();
    let p = S.chars().filter(|&c| c == 'p').count();
    let score = N / 2 - p;
    println!("{}", score);
    return;
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_ok() {
        assert_eq!(7, 1 + 2 * 3);
    }
}


Measured memory_bytes: 4352
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <cstdio>

using namespace std;

/**
 * main
 */
int main () {
  int a, b;
  scanf("%d", &a);
  scanf("%d", &b);
  printf("%d\n", (b - a - 1) * (b - a) / 2 - a);
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
using namespace std;


int main(void) {
	int n; cin >> n;
	vint a(n);
	vint b(n);
	vint c(n);
	rep(i, n) {
		cin >> a[i];
		c[i]=i+1;
	}
	rep(i, n) {
		cin >> b[i];
	}

	int i = 0,cnt=0;
	int cnta = 0,cntb=0;
	int numa, numb;
	do {
		i++;
		for (auto x: c) {
			if (a[cnt] == x) {
				cnta++;
			}
			if (b[cnt] == x) {
				cntb++;
			}
			cnt++;
		}
		if (cnta == n) {
			numa = i;
		}
		if (cntb == n) {
			numb = i;
		}
		cnta = 0, cntb = 0,cnt=0;
	} while (next_permutation(c.begin(), c.end()));
	cout << abs(numa - numb) << endl;
	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long k = sc.nextLong();
		long tmp = Math.min(a, k);
		a = Math.abs(a - tmp);
		k = Math.abs(k - tmp);
		tmp = Math.min(b, k);
		b = Math.abs(b - tmp);
		k = Math.abs(k - tmp);
		System.out.println(a + " " + b);
	}
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e5+9;

int main(){
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int x;
    cin>>x;
    cout<<(x==0?1:0);
    


}
    


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

namespace ABC095 {
	class ABC095_A {
		static void Main(string[] args) {
			var input = Console.ReadLine();
			Console.WriteLine(input.Count(s => s == 'o')*100 + 700);
		}
	}
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int a,b;
    cin >> a >> b;
    if(abs(a-b)%2==0){
        cout << min(a,b)+(abs(a-b)/2) << endl;
    }
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n,k;
  cin >> n >> k;
  vector<int> s(n);
  rep(i,k){
    int d;
    cin >> d;
    rep(i,d){
      int a;
      cin >> a;
      a--;
      s.at(a)++;
    }
  }
  int ans = 0;
  rep(i,n){
    if(s.at(i)==0) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int n; 
int a[5][100005],f[5][100005];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[1][i]>>a[2][i]>>a[3][i];
	}
	f[1][1]=a[1][1];
	f[2][1]=a[2][1];
	f[3][1]=a[3][1];
	for(int i=2;i<=n;i++){
		for(int j=1;j<=3;j++){
			int max1=0,t;
			for(int k=1;k<=3;k++){
				if(k!=j&&f[k][i-1]>max1){
					max1=f[k][i-1];
				}
			}
			f[j][i]=max1+a[j][i];
		}
	}
	int ans=0;
	for(int i=1;i<=3;i++){
		ans=max(ans,f[i][n]);
	}
	cout<<ans;
	return 0;
}



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

using namespace std;

typedef long long ll;
typedef long double ld;


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, sol = 0;
  cin >> n >> n >> n;
  map<int, int> a, b;
  map<int, vector<int>> lol;
  while (n--) {
    int x, y;
    cin >> x >> y;
    a[x]++;
    b[y]++;
    lol[x].push_back(y);
    sol = max(sol, a[x]);
    sol = max(sol, b[y]);
  }
  multiset<int> lons;
  lons.insert(0);
  lons.insert(0);
  lons.insert(0);
  lons.insert(0);
  lons.insert(0);
  lons.insert(0);
  for (auto &it : b) lons.insert(it.second);
  for (auto &it : a) {
    int x = it.first;
    for (auto &y : lol[x]) {
      lons.erase(lons.find(b[y]));
      lons.insert(b[y] - 1);
    }
    auto bg = lons.end();
    bg--;
    sol = max(sol, it.second + *bg);
    for (auto &y : lol[x]) {
      lons.erase(lons.find(b[y] - 1));
      lons.insert(b[y]);
    }
  }
  cout << sol << "\n";
  return 0;
}


Measured memory_bytes: 78592
// review
#include <iostream>

using namespace std;
typedef long long ll;

ll n;

void solve() {
  if (n == 0) {
    cout << 0 << endl;
    return;
  }
  string ans = "";
  while (n != 0) {
    if (abs(n) % 2 == 1) {
      ans = '1' + ans;
      n = n - 1;
    } else {
      ans = '0' + ans;
    }
    n /= -2;
  }
  cout << ans << endl;
}
int main() {
  cin >> n;
  solve();
}


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

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:isize,
    b:isize,
    }
    println!("{}",if a%3==0||b%3==0||(a+b)%3==0 {"Possible"}else{"Impossible"})
}

Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
void max_self(long long& a, long long b) {
    a = max(a, b);
}
int main() {
    int n, W;
    cin >> n >> W;
   // vector< int > weight(n), value(n);
    //for (int i = 0; i < n; i++) cin >> weight[i] >> value[i];
    vector< long long > dp(W + 1);
    for (int i = 0; i < n; i++) {
        int value, weight;
        cin >> weight >> value;
        for (int weight_already = W - weight; weight_already >= 0; weight_already--) {
            dp[weight_already + weight] = max(dp[weight_already + weight], dp[weight_already] + value);
            //cout << dp[weight_already + weight] << " ";
        }
        //cout << "\n";
    }
    long long ans = 0;
    for (int i = 0; i <= W; i++) {
        ans = max(ans, dp[i]);
    }
    cout << ans << "\n";
}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    char b;
    std::cin >> b;

    map<char, char> map;
    map.emplace('A', 'T');
    map.emplace('T', 'A');
    map.emplace('C', 'G');
    map.emplace('G', 'C');

    std::cout << map[b] << std::endl;

    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var k, x int
	fmt.Scanln(&k, &x)

	length := (k - 1)
	min := (-1) * length
	max := length
	i := min

	for i <= max {
		fmt.Printf("%d ", x+i)
		i++
	}
	fmt.Printf("\n")
}

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<set>
#include<stack>
#include<queue>
using namespace std;


int pare[200005]; //親
int rak[200005]; //深さ

//n要素で初期化
void init(int n)
{
//初期化の段階では親は自分自身、深さは0
	for(int i=0;i<n;i++)
	{
		pare[i]=i;
		rak[i]=0;
	}
}

//木の根を求める
//親に繋ぎつつ再帰処理
int find(int x)
{
	if(pare[x]==x){return x;}
	else{return pare[x]=find(pare[x]);}
}

//xとyの属する集合を併合
void unite(int x,int y)
{
	x=find(x);
	y=find(y);
	if(x==y){return ;}
	if(rak[x]<rak[y]){pare[x]=y;}//小さい木を子にする
	else{pare[y]=x;if(rak[x]==rak[y]){rak[x]++;} }
}

//xとyが同じ集合か否か
bool same(int x,int y)
{
	return find(x)==find(y);
}

int main()
{
int fin[200005]={};
int ans=0;
int n,m,a,b;
init(200005);
scanf("%d %d",&n,&m);
for(int i=0;i<m;i++)
{
	scanf("%d %d",&a,&b);
	unite(a,b);
}

for(int i=1;i<=n;i++)
{
	//printf("%d %d\n",i,find(i));
	fin[find(i)]++;
}
for(int i=1;i<=n;i++)
{
	if(ans<fin[i]){ans=fin[i];}
}
printf("%d",ans);

}


Measured memory_bytes: 6180
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;
ll fac[2000005];
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
void pre(){fac[0]=1;fac[1]=1;for(int i=2;i<2000005;i++)fac[i]=(i*fac[i-1])%mod;}
vector<pair<ll,ll>>v;
ll n,T;
ll dp[3005][3005];
ll solve(ll idx,ll curr)
{
    if(curr<=0) return 0;
    if(idx==n) return 0;
    ll ans =0;
    if(dp[idx][curr]!=-1)
    return dp[idx][curr];
    ans = max(solve(idx+1,curr),v[idx].se+solve(idx+1,curr-v[idx].fr));
    return dp[idx][curr]=ans;
}
signed main()
{   

      senky_bansal
      IIIT_ALLAHABAD
      
      ll t;
     // cin>>t;
      t=1;
      while(t--)
      {
          cin>>n>>T;
          for(int i=0;i<n;i++)
          {
              ll a1,b1;
              cin>>a1>>b1;
              v.pb({a1,b1});
          }
          memset(dp,-1,sizeof(dp));
          sort(v.begin(),v.end());
          ll ans = solve(0,T);
          cout<<ans<<endl;
      }
}


















Measured memory_bytes: 72192
#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
const int INF = 100000;
typedef pair<int, int> P;
int n;
int main()
{
    int a[5];
    int sum = 0;
    for (int i = 0; i < 5; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    int x = 0;
    for (int i = 0; i < 5; i++)
    {
        if (a[i] % 10 == 0)
        {
            continue;
        }
        sum += ((a[i] / 10) + 1) * 10 - a[i];
        x = max(x, ((a[i] / 10) + 1) * 10 - a[i]);
    }
    cout << sum - x << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


B = 10**7+7
MOD = 10**9+7


def z_algorithm(S):
    """Zアルゴリズム
    https://snuke.hatenablog.com/entry/2014/12/03/214243 の二番目のコード
    """
    N = len(S)
    Z = [0]*N

    c = 0
    for i in range(1, N):
        if i+Z[i-c] < c+Z[c]:
            Z[i] = Z[i-c]
        else:
            j = max(0, c+Z[c]-i)
            while i+j < N and S[j] == S[i+j]:
                j += 1
            Z[i] = j
            c = i
    Z[0] = len(S)
    return Z


def zfindall(text, pattern, separator="$"):
    """テキストからパターンと一致する部分文字列を探す。
    開始インデックスを返す
    Zアルゴリズムを利用する
    """
    N = len(pattern)
    conc = pattern+separator+text
    Z = z_algorithm(conc)
    return [i-N-1 for i in range(len(conc)) if Z[i] == N]


def solve(N: int, a: "List[int]", b: "List[int]"):

    c = [a[i] ^ a[(i+1) % N]for i in range(N)]
    d = [b[i] ^ b[(i+1) % N]for i in range(N)]*2
    i = -1
    k_cand = zfindall(d, c, separator=[-1])
    # print(k_cand)

    ans = []
    if len(k_cand) == 0:
        return
    if k_cand[0] % N == 0:
        print(0, b[0] ^ a[0])
        for k in k_cand[:0:-1]:
            if k < N:
                print(-k % N, b[0] ^ a[-k % N])
    else:
        for k in k_cand[::-1]:
            if k < N:
                print(-k % N, b[0] ^ a[-k % N])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N - 1 - 0 + 1)]  # type: "List[int]"
    b = [int(next(tokens)) for _ in range(N - 1 - 0 + 1)]  # type: "List[int]"
    solve(N, a, b)


if __name__ == '__main__':
    main()


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

const int di[]={-1,0,1,0};
const int dj[]={0,-1,0,1};

int main(){
    int h,w;
    cin>>h>>w;
    vector<string>s(h);
    rep(i,h)cin>>s[i];
    int ans=0;
    rep(si,h){
        rep(sj,w){
            if(s[si][sj]=='#')continue;
            vector<vector<int>>dist(h,vector<int>(w,1e9));
            queue<pair<int,int>>q;
            auto update=[&](int i,int j,int x){
                if(dist[i][j]!=1e9)return;
                dist[i][j]=x;
                q.push(make_pair(i,j));
            };
            update(si,sj,0);
            while(!q.empty()){
                int i=q.front().first;
                int j=q.front().second;
                q.pop();
                rep(dir,4){
                    int ni=i+di[dir];
                    int nj=j+dj[dir];
                    if(ni<0||ni>=h||nj<0||nj>=w)continue;
                    if(s[ni][nj]=='#')continue;
                    update(ni,nj,dist[i][j]+1);
                }
            }
            rep(i,h)rep(j,w){
                if(dist[i][j]==1e9)continue;
                ans=max(ans,dist[i][j]);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

end = a[0] + k - a[n-1]
b = []
b.append(end)

for i in range(0,n-1):
    diff = a[i+1] - a[i]
    b.append(diff)

b.sort(reverse=True)
max = b[0]
print(k-max)

Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << ", "
template <typename T> ostream& operator<<(ostream& _o_, const vector<T>& _v_){ \
 if(!_v_.empty()){_o_<<'[';copy(_v_.begin(),_v_.end(),ostream_iterator<T>(_o_,", "));_o_<<"\b\b]";}return _o_;}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
typedef unsigned int uint;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unsigned char uchar;
struct secure_hash {
 static uint64_t splitmix64(uint64_t x) {
  x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); }
 size_t operator()(uint64_t x) const {
  static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } };
template<typename T> using V = vector<T>;
template<typename T, typename U> using umap = unordered_map<T,U,secure_hash>;
template<typename T> using uset = unordered_set<T,secure_hash>;
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using max_heap = priority_queue<T>;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    V<V<int>> a(n, V<int>(3));
    rep(i,0,n) rep(j,0,3) cin >> a[i][j];
    V<V<int>> dp(n, V<int>(3, INT_MIN));
    rep(j,0,3) dp[n-1][j] = a[n-1][j];
    rep(i,n-1,0) rep(j,0,3) rep(k,0,3) {
        if (j != k) dp[i][j] = max(dp[i][j], dp[i+1][k]+a[i][j]);
    }
    cout << max(dp[0][0], max(dp[0][1], dp[0][2])) << endl;
}


Measured memory_bytes: 11136
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap};
#[allow(unused_imports)]
use std::iter::FromIterator;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }

    #[allow(dead_code)]
    pub fn get2<T: FromStr, U: FromStr>() -> (T, U)
    where
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }

    #[allow(dead_code)]
    pub fn get3<S: FromStr, T: FromStr, U: FromStr>() -> (S, T, U)
    where
        <S as FromStr>::Err: Debug,
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
}

#[allow(unused_macros)]
macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn main() {
    let _n: usize = util::get();
    let ts: Vec<usize> = util::gets();
    let vs: Vec<usize> = util::gets();

    let mut dp = vec![0.0; 201];

    let mut now = 0;
    for (&t, &v) in ts.iter().zip(vs.iter()) {
        for k in 0..2 * t {
            now += 1;
            let mut next = vec![0.0; 201];
            let lim = min(now, 2 * v);
            for i in 0..lim + 1 {
                if i > 0 {
                    next[i] = dp[i - 1] + (i as f64 - 1.0) / 2.0 + (0.5 * 0.5) / 2.0;
                }
                if dp[i] + i as f64 / 2.0 > next[i] && dp[i] > 0.0 {
                    next[i] = dp[i] + i as f64 / 2.0 as f64;
                }

                if i < lim && dp[i + 1] > 0.0 {
                    if dp[i + 1] + (i as f64 + 1.0) / 2.0 - (0.5 * 0.5 / 2.0) > next[i] {
                        next[i] = dp[i + 1] + (i as f64 + 1.0) / 2.0 - (0.5 * 0.5 / 2.0);
                    }
                }
            }
            dp = next;
        }

    }

    println!("{}", dp[0] / 2.0);
}


Measured memory_bytes: 4352
N, M = map(int, input().split())
lst = [list(map(int, input().split())) for i in range(M)]
sorted_lst = sorted(lst, key=lambda x: x[0])
ans = 'IMPOSSIBLE'
lst_1 = [0] * N
for i in sorted_lst:
  if (i[0] == 1):
    lst_1[i[1]-1] = 1
  elif (lst_1[i[0]-1] and i[1] == N):
    ans = 'POSSIBLE'
print(ans)
    

Measured memory_bytes: 91096
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#define ll long long

using namespace std;

int main(void){
  ll ans = 0;
  ll num;
  cin >> num;
  vector<ll> height(num);
  ll maxi = 0;
  for(int i = 0;i < num;i ++){
    cin >> height[i];
    if(maxi < height[i]){
      maxi = height[i];
    }else{
      ans = ans +maxi - height[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4784
#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
#define ll long long
#include<math.h>
#define lim 10000
#define pb push_back
#define mp make_pair
#define eps 1e-6
#define INF 1e9
#define mp make_pair
#include<set>
#define F first
#define S second
#include<vector>
#include<queue>
#include<map>
#define pii pair<ll,ll>
#include<stdio.h>
#define sd(n) scanf("%lld",&n)
ll mod=7340033;
int main()
{
  ll n;
  cin>>n;
  ll mx=INF;
  ll s=0,x;
  while(n--)
    {cin>>x;
      s+=x;
      if(x%10)
        mx=min(mx,x);
    }
    if(s%10)
      cout<<s<<endl;
    else cout<<max(0LL,s-mx)<<endl;
}

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

void main() {
    string str = readln.chomp;
    for(int i=0; i+1<str.length; i++) {
        if (i>=0 && str[i..i+2]=="ST") {
            str = str[0..i]~str[i+2..$];
            i -= 2;
        }
    }
    str.length.writeln;
}


Measured memory_bytes: 5432
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
const int N=500010;
int op,n,now;
LL m,v,ans,tot,sum[N];
int main()
{
	scanf("%d%lld",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&v);
		sum[i]+=sum[i-1]+v;
	}
	ans=0x7fffffffffffffff;
	for(int i=1;i<=n;i++)
	{
		v=1;now=n-i*2;tot=(sum[n]-sum[max(n-i*2,0)])*5+m*(n+i);
		while(now>0)
		{
			tot+=(sum[now]-sum[max(0,now-i)])*(2*v+5);
			if(tot<0){tot=0x7fffffffffffffff;break;}now-=i;v++;
		}
		ans=min(ans,tot);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>

int main(){
  int ans;
  char s[2000];

  while (1) {
    ans = 0;
    scanf("%s", s);
    if (s[0] == '0') {
      break;
    }
    for (int i = 0; i < strlen(s); i++) {
      ans += s[i] - '0';
    }
    printf("%d\n", ans);
  }

  return 0;
}


Measured memory_bytes: 2760
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (isok).erase(unique(ALL((isok))),(isok).end())
# define LOWER(s)    transform(ALL((maze)),(maze).begin(),TL<char>)
# define UPPER(s)    transform(ALL((maze)),(maze).begin(),TU<char>)
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;

int main() {
	while (cin >> n&& n) {
		set<int> s[51];
		int a, b, ans = -1;
		bool day[51][31] = {};
		REP(i, n) {
			cin >> a;
			REP(j, a) {
				cin >> b;
				day[i][b] = true;
			}
			s[i].insert(i);
		}

		for (int i = 1; i <= 30; i++) {
			set<int> today;
			REP(j, n) {
				if (day[j][i]) {
					for (auto itr = s[j].begin(); itr != s[j].end(); itr++) {
						today.insert(*itr);
					}
				}
			}
			if (today.size() == n) {
				ans = i;
				break;
			}
			REP(j, n) {
				if (day[j][i])
					s[j] = today;
			}
		}

		cout << ans << endl;

	}
}


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

int main(void){
  string x,y;
  int tmp, c;
  int N;
  int cnt;
  cin >> N;

  for(int i = 0; i < N; i++){
    stack<int> a, b, ans;
    cnt = 0;

    cin >> x;
    cin >> y;

    for(int j = 0; j < x.length(); j++){
      a.push(x[j] - '0');
    }
    for(int j = 0; j < y.length(); j++){
      b.push(y[j] - '0');
    }

    c = 0;

    while(a.empty() != true || b.empty() != true){
      tmp = 0;
      
      if(a.empty() != true){
	tmp += a.top();
	a.pop();
      }
      if(b.empty() != true){
	tmp += b.top();
	b.pop();
      }
      tmp += c;

      ans.push(tmp % 10);
      cnt++;

      if(tmp >= 10)
	c = tmp / 10;
      else
	c = 0;
    }

    if(c != 0){
      ans.push(c);
      cnt++;
    }

    if(cnt > 80)
      cout << "overflow" << endl;
    else{
      while(ans.empty() != true){
	cout << ans.top();
	ans.pop();
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n], b[n];
    rep(i, 0, n) cin >> a[i];
    if (n % 2 == 0){
        for (int i = 0; i < n / 2; i++){
            b[i] = a[(n - 1) - 2 * i];
        }
        for (int i = 0; i < n / 2; i++){
            b[i + n / 2] = a[i * 2];
        }
    }
    else{
        for (int i = 0; i <= n / 2; i++){
            b[i] = a[(n - 1) - 2 * i];
        }
        for (int i = 0; i < n / 2; i++){
            b[i + (n / 2 + 1)] = a[i * 2 + 1];
        }
    }
    for (int i = 0; i < n; i++){
        cout << b[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;
  cin >> n >> a >> b;
  if((n <= b and n >= a) or (n < a and a%n == 0))puts("OK");
  else if(n > b)puts("NG");
  else {
     int k = a/n;n = n*(k+1);
    if(n > b)puts("NG");
    else puts("OK");
  }
  return 0;
}

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

using namespace std;

#define SWAP(x,y,z) {if ( y > z ) swap(y,z); if ( x > y ) swap(x,y); if (y > z) swap(y,z);}
typedef long long ll;
typedef unsigned long long ull;

double const eps = 1e-6;
double const pi = 3.1415926535;
ll const mod = 1e9+7;

int a[10000];

void solve()
{

}

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

    int a,b,c;
    cin >> a >> b >> c;
    if ( c >= a && c <= b ) cout << "Yes" << '\n';
    else cout << "No" << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll n;
int par[100000];
vector<int> e[100000];
ll dp[100000][2];

void makep(int v) {
    rep(i,e[v].size()) {
        if (e[v][i] == par[v]) continue;
        par[e[v][i]] = v;
        makep(e[v][i]);
    }
}

void dfs(int v) {
    rep(i,e[v].size()) {
        if (e[v][i] == par[v]) continue;
        dfs(e[v][i]);
    }
    dp[v][0] = 1;
    dp[v][1] = 1;
    rep(i,e[v].size()) {
        if (e[v][i] == par[v]) continue;
        dp[v][0] = (dp[v][0] * (dp[e[v][i]][0]+dp[e[v][i]][1])) % MOD;
        dp[v][1] = (dp[v][1] * dp[e[v][i]][0]) % MOD;
    }
}

int main() {
    cin >> n;
    rep(i,n-1) {
        int x, y; cin >> x >> y;
        x--; y--;
        e[x].push_back(y);
        e[y].push_back(x);
    }
    par[0] = 0;
    makep(0);
    dfs(0);
    cout << (dp[0][0] + dp[0][1]) % MOD << endl;
}



Measured memory_bytes: 11776
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string.h>

using namespace std;

typedef long long ll;

char s[200010];
char t[200010];


int main(){
    //string s,t;
    cin>>s>>t;
    
    vector<int> alphs(26,0);
    vector<int> alpht(26,0);
    
    
    
    size_t ls=strlen(s);
    size_t lt=strlen(t);
    vector<int> vecs(ls,0);
    vector<int> vect(lt,0);
    
    
    int counts=0;
    for(int i=0;i<ls;++i){
        if(alphs[s[i]-'a']==0){
            alphs[s[i]-'a']=counts;
            ++counts;
        }
        vecs[i]=alphs[s[i]-'a'];
    }
    
    int countt=0;
    
    bool ans=true;
    
    for(int i=0;i<lt;++i){
        if(alpht[t[i]-'a']==0){
           ++alpht[t[i]-'a']=countt;
            ++countt;
        }
        vect[i]=alpht[t[i]-'a'];
        
        if(vecs[i]!=vect[i]){
            ans=false;
            break;
        }
        
    }
    
  
    if(ans){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    
   

    
    
}


Measured memory_bytes: 5000
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
long long int p=1e9 +7;
int n;
int moves[100];
int ans[100007]={0};
int solve(int k){
    if(ans[k]){
        return ans[k];
    }
    for(int i=0;i<n;i++){
        if(k>=moves[i]){
        if(solve(k-moves[i])==2){
            ans[k]=1;
            return ans[k];
        }
      }
    }
   ans[k]=2;
   return ans[k];
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	   int k;
	   cin>>n>>k;
	   for(int i=0;i<n;i++){
	       cin>>moves[i];
	   }
	   ans[0]=2;
	   if(solve(k)==1){
	    cout<<"First";   
	   }
	   else{
	       cout<<"Second";
	   }
}


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define endl '\n'
void fastIO() {
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
}

int arr[100001];

int main() {
	fastIO();
	int n, m;
	cin >> n >> m;
	for(int i = 0 ; i < m ; ++i) {
		cin >> arr[i];
	}
	
	sort(arr, arr + m);
	
	vector<int> arr2;
	for(int i = 0 ; i + 1 < m ; ++i) {
		arr2.emplace_back(arr[i + 1] - arr[i]);
	}
	sort(arr2.begin(), arr2.end());
	
	int ans = 0;
	for(int i = 0 ; i < n - 1; ++i) {
		if(arr2.empty()) {
			ans = 1;
			break;
		}
		arr2.pop_back();
	}
	
	if(ans == 1) {
		cout << 0 << endl;
	}
	
	else {
		int sum = 0;
		for(int i = 0 ; i < arr2.size() ; ++i) {
			sum += arr2[i];
		}
		cout << sum << endl;
	}
}


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

int top, S[1000];

void push(int x) {
    S[++top] = x;
}

int pop() {
    top--;
    return S[top + 1];
}

int main()
{
    int a, b;
    top = 0;
    char s[100];

    while (scanf("%s", s) != EOF) {
        if (s[0] == '+') {
            a = pop();
            b = pop();
            push(a + b);
        }
        else if (s[0] == '-') {
        b = pop();
        a = pop();
        push(a - b);
        }
        else if (s[0] == '*') {
        a = pop();
        b = pop();
        push(a * b);
       }
       else {
        push(atoi(s));
       }
    }

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


Measured memory_bytes: 2048
n = int(input())
ls = map(int, input().lower().split())
even = []
for i in ls: 
  if i % 2 == 0:
    even.append(i)

count = 0
for i in even: 
  if i % 3 == 0 or i % 5 == 0:
    count = count + 1
    
if count == len(even):
  print("APPROVED")
else:
  print("DENIED")


Measured memory_bytes: 3060
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

n = int(sys.stdin.readline())
t_score = h_score = 0

for i in range(n):
    t_card, h_card = sys.stdin.readline().split()
    if t_card > h_card:
        t_score += 3
    elif t_card < h_card:
        h_score += 3
    else:
        t_score += 1
        h_score += 1

print(t_score, h_score)



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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

bool solve(void){
    lint n;
    cin >> n;

    vector<lint> a(n);
    lint sum = 0;
    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }

    lint s = n * (n + 1LL) / 2LL;
    if(sum % s != 0LL){
        return false;
    }

    lint k = sum / s;

    vector<lint> diff(n);
    rep(i, n){
        diff[i] = a[(i + 1) % n] - a[i] - k;
        if(diff[i] > 0LL || abs(diff[i]) % n != 0LL){
            return false;
        }
    }

    return true;
}

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

    if(solve()){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 1792
#C - Walking Takahashi

x, k, d = map(int, input().split())

p = abs(x)

if p/d < k:
  k = k - (p // d)
  p = p % d

  if k % 2 == 0:
    print(abs(p))
  elif p < 0:
    print(abs(p + d))
  else:
    print(abs(p - d))

elif x >= 0:
  print(abs(x - (k * d)))
else:
  print(abs(x + (k * d)))




Measured memory_bytes: 61696
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
int ac,wa,tle,re;
string s[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s[i];
		if(s[i]=="AC")
			ac++;
		else if(s[i]=="WA")
			wa++;
		else if(s[i]=="TLE")
			tle++;
		else if(s[i]=="RE")
			re++;
	}
	cout<<"AC x "<<ac<<"\n";
	cout<<"WA x "<<wa<<"\n";
	cout<<"TLE x "<<tle<<"\n";
	cout<<"RE x "<<re<<"\n";
	return 0;
}




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

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

int main() {
	int p, q;
	cin >> p >> q;
	
	int g = gcd(p, q);
	p /= g;
	q /= g;
	
	int ans = 1;
	for (int i = 2; i * i <= q; i++) {
		if (q % i != 0) continue;
		while (q % i == 0) { q /= i; }
		ans *= i;
	}
	ans *= q;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3096
N = int(input())
music =[]
time = []
count=0
for i in range(N):
  s,t = input().split()
  music.append(s)
  time.append(t)
S = input()
#print(S)
n = music.index(S)
for i in range(n+1,N):
  T = int(time[i])
  count +=T

print(count)


Measured memory_bytes: 3060