akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();//カード枚数
        
        int cards[][] = new int[4][13];
        
        for(int i = 0; i < 4; i++){
            for(int j= 0;j <13; j++){
                cards[i][j] = 0;
            }
        }
        
        //0S 1H 2C 3D
        for(int loop = 0; loop<n; loop++){
            String mark = sc.next();
            int num = sc.nextInt();
            
            if(mark.equals("S")){
                cards[0][num-1]=1;
            }else if(mark.equals("H")){
                cards[1][num-1]=1;
            }else if(mark.equals("C")){
                cards[2][num-1]=1;
            }else if(mark.equals("D")){
                cards[3][num-1]=1;
            }
        }
        
        for(int i = 0; i < 4; i++){
            for(int j= 0;j <13; j++){
               
               if(cards[i][j] == 0){
                   if(i == 0){
                       System.out.println("S " + (j+1));
                   }else if(i == 1){
                       System.out.println("H " + (j+1));
                   }else if(i == 2){
                       System.out.println("C " + (j+1));
                   }else if(i == 3){
                       System.out.println("D " + (j+1));
                   }
               }
            }
        }
        
    }
}


Measured memory_bytes: 26300
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstring>
#include <map>

#define ll long long
const ll MOD = 1e9 + 7;
const ll INF = 1 << 29;


int main()
{
    std::string S;
    std::cin >> S;

    const std::string ABC = "ABC";
    const std::string ARC = "ARC";
    if (S == ABC)
        std::cout << ARC << std::endl;
    else
        std::cout << ABC << std::endl;
}


Measured memory_bytes: 3612
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  n = InputLine.to_i

  case (n % 10)
  when 2, 4, 5, 7, 9 then
    puts 'hon'
  when 0, 1, 6, 8 then
    puts 'pon'
  when 3 then
    puts 'bon'
  end
end

if self.to_s == 'main' then
  main(ARGV)
end

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

int main() {
	
	int x, a, b;
	cin >> x >> a >> b;
	x -= a;
	while(x >= b){
		x -= b;
	}
	cout << x << endl;
	return 0;
}

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

typedef pair<int, pair<int,int> > Order;

int S[2];
stack<Order> V;
bool vis[2][50001];
int cnt[2];

int main() {
  int Q;
  while(cin >> S[0] >> S[1] >> Q && (S[0] || S[1] || Q)) {
    while(!V.empty()) V.pop();
    for(int i = 0; i < Q; ++i) {
      Order o;
      cin >> o.first >> o.second.first >> o.second.second;
      V.push(o);
    }
    for(int i = 0; i < 2; ++i) {
      fill(vis[i], vis[i]+S[i], false);
      cnt[i] = 0;
    }
    int ans = 0;
    while(!V.empty()) {
      Order s = V.top(); V.pop();
      if(vis[s.first][s.second.first]) continue;
      vis[s.first][s.second.first] = true;
      if(s.second.second)
	ans += S[1-s.first] - cnt[1-s.first];
      ++cnt[s.first];
      if(cnt[s.first] == S[s.first]) break;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
#include <cassert>
typedef long long ll;
using namespace std;
template <typename T> T sq(T x) { return x * x; }
template <typename T> T cb(T x) { return x * x * x; }
int main() {
    while (true) {
        int e; cin >> e;
        if (not e) break;
        ll m = e;
        ll z = 0;
        while (cb(z + 1) <= e) ++ z;
        for (; z >= 0; -- z) {
            ll y = 0;
            while (sq(y + 1) + cb(z) <= e) ++ y;
            assert (sq(y) + cb(z) <= e and e < sq(y + 1) + cb(z));
            ll x = e - sq(y) - cb(z);
            m = min(m, x + y + z);
        }
        cout << m << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
N = int(input())
CSF = []
for i in range(N - 1):
    c, s, f = map(int, input().split())
    CSF.append((c, s, f))

ans = [(0, i) for i in range(N)]
for i in range(N - 1):
    for j in range(N - i - 1):
        Cj, Sj, Fj = CSF[ans[j][1]]
        if ans[j][0] <= Sj:
            ans[j] = (Sj + Cj, ans[j][1] + 1)
        elif ans[j][0] % Fj == 0:
            ans[j] = (ans[j][0] + Cj, ans[j][1] + 1)
        else:
            ans[j] = (ans[j][0] + Fj - (ans[j][0] % Fj) + Cj, ans[j][1] + 1)

for a in ans:
    print(a[0])


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define ITR(i,x) for(auto i=(x).begin();i!=(x).end();++i)
using namespace std;

typedef pair<int, int> P;
typedef long long ll;
const int mod = 1000000007;

bool square(ll a){ll n=(ll)sqrt(a);return a==n*n;}
int digitsum(ll N,int a);//a進数におけるNの各桁の和、計算量はloga(N)
ll mpow(ll x, ll n);
ll inv_mod(ll a){return mpow(a,mod-2);}
int gcd(int x,int y){return y ? gcd(y,x%y) : x;};//xとyの最大公約数
int lcm(int x,int y){return x*y/gcd(x,y);}//xとyの最小公倍数

int main(){
    int N;
    cin>>N;
    vector<int> a(N),b(N),c(N);
    REP(i, N) cin >> a[i]>>b[i]>>c[i];
    vector<vector<int>> dp(N+1,vector<int>(3));
    dp[0][0]=dp[0][1]=dp[0][2]=0;
    REP(i,N){
        dp[i+1][0]=max(dp[i][1]+a[i],dp[i][2]+a[i]);
        dp[i+1][1]=max(dp[i][0]+b[i],dp[i][2]+b[i]);
        dp[i+1][2]=max(dp[i][0]+c[i],dp[i][1]+c[i]);
    }
    cout<<max({dp[N][0],dp[N][1],dp[N][2]})<<endl;
}

int digitsum(ll N,int a){
    if(N==0) return 0;
    int ret=0;
    ret+=digitsum(N/a,a)+N%a;
    return ret;
}
ll mpow(ll x, ll n){ //x^n(mod division) ←普通にpow(x,n)では溢れてしまうため，随時mod計算 2分累乗法だから早い
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}
/*
class Factorial{//階乗とその逆元を求めて計算に利用するクラス
private:
    vector<ll> fac;
public:
    
    Factorial(ll N){
        fac.push_back(1);
        for(int i=0;i<N;i++) fac.push_back(fac[i]*(i+1)%mod);
    }

    ll fact(ll a){return fac[a];}
    ll ifact(ll a){return inv_mod(fac[a]);}

    ll cmb(ll a,ll b){
        if(a==0&&b==0) return 1;
        if(a<b||a<0) return 0;
        ll tmp =ifact(a-b)*ifact(b)%mod;
        return tmp*fac[a]%mod;
    }
};
*/

/*
class UnionFind{//UnionFind木
 private:
    vector<int> Parent;
 public:
    UnionFind(int N){
        for(int i=0;i<N;i++) Parent.push_back(-1);
    }

    int root(int A){
        if(Parent[A]<0) return A;
        return Parent[A]=root(Parent[A]);
    }

    int size(int A){
        return -Parent[root(A)];
    }

    bool connect(int A,int B){
        A=root(A);
        B=root(B);
        if(A==B) return false;
        if(size(A)<size(B)) swap(A,B);
        Parent[A]-=Parent[B];
        Parent[B]=A;
    }
};
*/

Measured memory_bytes: 6912
float a,b,c,d,e,f,g;main(){for(;g=~scanf("%f%f%f%f%f%f",&a,&b,&c,&d,&e,&f);printf("%.3f %.3f\n",(c*e-b*f)/g+4e-4,(a*f-c*d)/g+4e-4))g=a*e-b*d;}

Measured memory_bytes: 652
defmodule Main do
  def main do
    n = IO.gets("") |> String.trim() |> String.to_integer()
    Enum.reduce([2,3], n, fn x, acc -> mathround(n, x) + acc end) |> IO.puts()
  end
  
  defp mathround(n, k) do
    :math.pow(n, k) |> round
  end
end

Measured memory_bytes: 31152
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>

using namespace std;

typedef long long ll;

typedef pair<vector<int>, int> P;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin >> N;

	vector<int> tmp;
	tmp.push_back(1);
	queue<P> q[2];
	queue<P>& crt = q[0];
	queue<P>& nxt = q[1];
	crt.push(make_pair(tmp, 1));
	for (int n = 2; n <= N; n++) {
		while (crt.size()) {
			auto nw = crt.front(); crt.pop();

			for (int i = 1; i <= nw.second + 1; i++) {
				auto nxt_ar = nw.first;
				nxt_ar.push_back(i);
				nxt.push(make_pair(nxt_ar, max(nw.second, i)));
			}

		}
		swap(crt, nxt);
	}
	
	vector<vector<int>> sl;
	while (crt.size()) {
		sl.push_back(crt.front().first);
		crt.pop();
	}
	sort(sl.begin(), sl.end());
	for (int i = 0; i < sl.size(); i++) {
		for (int j = 0; j < sl[i].size(); j++) {
			cout << char(sl[i][j] + 'a' - 1);
		}
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 13424
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <vector>
#include <set>
#include <complex>
#define ls id<<1
#define rs id<<1|1
#define mem(a,b) memset(a,b,sizeof(a))
#define defor(i,a,b) for(int i=a;i>=b;--i)
#define infor(i,a,b) for(int i=a;i<=b;++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod=1e9+7;
const double pi=acos(-1.0);
template <class _E> inline void read(_E &e){
	e=0;bool ck=0;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')ck=1;ch=getchar();}
	while(ch>='0'&&ch<='9'){e=e*10+ch-'0';ch=getchar();}
	if(ck)e=-e;
}
ll s;
struct ans{
	ll x,y;
}a[4];

int main(){
	cin>>s;
//	freopen("A.out","w",stdout);
//	s=1e18;
//	cout<<s<<endl;
//	while(s>=100000000000000000LL){
//		s--;
		a[1].x=a[1].y=0;
	/*	if(s<=1e9){
			a[2].x=0,a[2].y=1;
			a[3].x=s,a[3].y=0;
			for(int i=1;i<=3;++i)printf("%lld %lld ",a[i].x,a[i].y);
			return 0;
		}
		if(s>1e9){*/
			ll ans=sqrt((long double)s);
//			cout<<ans<<endl;
			if(ans*ans==s){
				a[2].x=0,a[2].y=ans;
				a[3].x=ans,a[3].y=0;
				for(int i=1;i<=3;++i)printf("%lld %lld ",a[i].x,a[i].y);
				return 0;
			}
			ans++;
			a[2].x=a[3].y=ans;
			ll tmp=ans*ans-s;
			a[2].y=1,a[3].x=tmp;
			for(int i=1;i<=3;++i)printf("%lld %lld ",a[i].x,a[i].y);
		puts("");
//	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.Stream;
import java.util.ArrayList;
public class Main{
    public static void main(String[] args) {
 
 
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(); 
        int K = sc.nextInt(); 
        String str = sc.next(); 
        String [] strArray = str.split("");
        int[] ia = new int[N];
        int sum = 0;
        int max = 0;
        int kaisu = 0;
        int range = 0;

        for (int i = 0; i < N; i++) {
            ia[i] = Integer.parseInt(strArray[i]); 
        }

        ArrayList<Integer> array = new ArrayList<Integer>();

        int count = 0;
        int now = 1;

        for(int i = 0; i < N ; i++){
            
            if(ia[i] == '1' || ia[i] == now ){
                count++; 
            }
            
            else{
                array.add(count);
                now = 1 - now;
                count = 1;
            }
        }
        array.add(count);

        if (array.size() % 2 == 0) {
            array.add(0);
        }


        for(int i = 0; i < array.size() ; i = i+2){
            int cnt = i;
            sum = 0;
            for(int j = cnt; j < (range = (cnt + 1 + K * 2) < array.size() ? (cnt + 1 + K * 2) : array.size()); j++){
                sum = sum + array.get(j) ;
//                    System.out.println(j);
                }
//                System.out.println(i + " " +sum);
            max = Math.max(max, sum);
        }

        System.out.println(max);
    }
}

Measured memory_bytes: 32616
# ABC 123 B

a = 10

arr = []

for i in range(5):
    num = int(input())
    if num % 10 != 0:
        a = min(a, num % 10)
        num -= num % 10
        num += 10
    arr.append(num)

ans = sum(arr)
if a != 10:
    ans -= (10-a)

print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	long long n,a[300000],ans=0;
	cin>>n;
	for(int i=0;i<3*n;i++)cin>>a[i];
	sort(a,a+(3*n));
	for(int i=1;i<=n;i++)ans+=a[(3*n)-(i*2)];
	cout<<ans<<endl;
	return 0;
}


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

int main(){
  int64_t K,MfromC,CfromM; 
  cin >> K >> MfromC >> CfromM;
  
  int64_t Kremain= max(K- (MfromC- 1), (int64_t)0);

  int64_t ans= (Kremain==0)          ? K+1
              :(CfromM- MfromC <= 2) ? K+1
              :(Kremain % 2==1)      ? MfromC+ 1+ (Kremain/2)*(CfromM- MfromC)
                                     : MfromC+    (Kremain/2)*(CfromM- MfromC);

  cout << ans << endl;
}

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

int main(){
  int a,b;
  cin>>a>>b;
  string s;
  cin>>s;
  bool ok=1;
  for(int i=0;i<a+b+1;i++){
    if(i==a){
      if(s[i]!='-') ok=0;
    }else{
      if(s[i]=='-') ok=0;
    }
  }
  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ipair pair<int,int>
#define rep(I,N) for(int I=0; I<N; I++)
#define rrep(I,N) for(int I=N; I>=0; I--)
#define repj(i,j,n) for(int i=j;i<n;i++)
 
#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
 
#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl
 
int main() {
  char s[11];
  cin >> s;
  int N = strlen(s);
  long res = 0;
 
  rep(i, 1 << (N-1)) {
    long sm = 0;
    long a = s[0] - '0';
    rep(j, N-1) {
      if (i & (1 << j)) {
        sm += a;
        a = 0;
      }
      a = a * 10 + (s[j+1] - '0');
    }
    sm += a;
    res += sm;
  }
 
  printf("%ld\n", res);
  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 int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll calc(ll x){
	if(x <= 0) return 0;
	ll res = 0;
	rep(i,40){
		ll hoge = (1LL << (i+1));
		ll foo = x / hoge;
		ll bar = x % hoge;
		ll cnt = foo * hoge / 2;
		cnt += max(bar - hoge / 2 + 1, 0LL);
		if(cnt%2 == 1) res |= (1LL << i);
	}
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b;
	cin >> a >> b;
	ll ans = calc(b) ^ calc(a-1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def read_int_list():
    return list(map(int,input().split()))
    
N, M = read_int_list()
g = [[] for i in range(N)]

for i in range(M):
    a,b = read_int_list()
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)
    
def dfs(v):
    if len(v) == N:return 1
    ans=0
    for u in set(g[v[-1]]) - set(v):
        ans += dfs(v + [u])
    return ans
print(dfs([0]))

Measured memory_bytes: 3064
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n, m; cin >> n >> m;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    priority_queue<ll> q;
    REP(i, n) q.push(a[i]);

    REP(i, m) {
        ll u = q.top();
        q.pop();
        q.push(u / 2);
    }

    ll ans = 0;
    while (!q.empty()) {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, K;
vector<pair<int, int>>v;

int main() {
	cin >> N >> K;
	if (K > (N - 1)*(N - 2) / 2) {
		cout << -1 << endl;
		return 0;
	}
	K = (N - 1)*(N - 2) / 2 - K;
	for (int i = 1; i < N; ++i) {
		v.push_back(mkp(i, N));
	}
	for (int i = 1; i < N&&K > 0; ++i) {
		for (int j = i + 1; j < N&&K > 0; ++j,--K) {
			v.push_back(mkp(i, j));
		}
	}
	cout << v.size() << endl;
	for (auto p : v) {
		cout << p.first << sp << p.second << endl;
	}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
long long int power(long long int x, unsigned int y, long long int p)  
{  
    int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
int main()
{
    long long int n;
    cin>>n;
    map<string,int>m;
    for(int i=0;i<n;i++)
    {
        string temp;
        cin>>temp;
        m[temp]++;
    }
    cout<<m.size();
}

Measured memory_bytes: 19120
#include<stdio.h>
#define N 101
int sum[N][N],tum[N],a;

void num(int xu){
	int Q[100000],fan,zin, i;
	fan=zin=0;

	Q[zin]=xu;	
	++zin;


	while(fan!=zin){
	
		xu=Q[fan];
		++fan;
		for(i=1;i<=a;i++){
			if(sum[xu][i]){
				if(tum[i]>=0)continue;

			
				Q[zin]=i;	++zin;
				tum[i]=tum[xu]+1;
			}
		}
	}
}

int main(){
	int i,j,u,k,v;

	scanf("%d",&a);
	for(i=0;i<a;i++){
		scanf("%d%d",&u,&k);
		tum[u]=-1;
		for(j=0;j<k;j++){
			scanf("%d",&v);
			sum[u][v]=1;
		}
	}
	tum[1]=0;

    num(1);
	for(i=1;i<=a;i++){
		printf("%d %d\n",i,tum[i]);
	}

	return 0;
}



Measured memory_bytes: 2112
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;


int main(){
	char s1[4003],s2[4003];
	
	while(1<scanf("%s %s",s1,s2)){
		int maxcom=0;
		int s1len=strlen(s1),s2len=strlen(s2);
		for(int i=0;i<s1len+s2len;i++){
			int is1,is2;
			if(i<s1len){
				is1=i;
				is2=0;
			}else{
				is1=0;
				is2=i-s1len;
			}
			int tmax=0;
			for(int k=0;is1+k<s1len && is2+k<s2len;k++){
				if(s1[is1+k]==s2[is2+k])++tmax;
				else{
					maxcom=max(tmax,maxcom);
					tmax=0;
				}
			}
			maxcom=max(tmax,maxcom);
			
		}
		
		cout<<maxcom<<endl;
	}
}

Measured memory_bytes: 896
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(llint i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
const ll mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const ll INF = 1000000000;



int main() {
	int h, w, d;
	cin >> h >> w >> d;
	hei(int) x(h * w+1), y(h * w+1);
	rep(i, 0, h) {
		rep(j, 0, w) {
			int number;
			cin >> number;
			x[number] = i;
			y[number] = j;
		}
	}
	whei(int) dist(d, hei(int)(2+(h*w)/d,0));
	for (int i = 0; i < d; i++) {
		for (int j = 1; i+j*d <= h * w; j++) {
			int v = i + j * d;
			dist[i][j] = dist[i][j - 1] + abs(x[v] - x[v-d]) + abs(y[v] - y[v-d]);
		}
	}
	
	int q;
	cin >> q;
	hei(int) ans(q,0);
	rep(i, 0, q) {
		int l, r;
		cin >> l >> r;
		ans[i] = dist[r % d][r / d] - dist[l % d][l / d];
	}
	rep(i,0,q)cout << ans[i] << "\n";
    return 0;
}

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    int y[x];
    for (int i=0; i<x; i++)
        cin>>y[i];
    int a[x]= {},ans=0;
    while (1)
    {
        int cnt=0;
        for (int i=0; i<x; i++)
        {
            if (a[i]==y[i])
            {
                if (cnt)
                {
                    ans++;
                    for (int j=i-cnt; j<i; j++)
                        a[j]++;
                }
                cnt=0;
            }
            else
            {
                cnt++;
            }
        }
        if (cnt)
        {
            ans++;
            for (int j=x-cnt; j<x; j++)
                a[j]++;
        }
        bool end=1;
        for (int i=0; i<x; i++)
            if (a[i]!=y[i])
                end=0;
        if (end)
            break;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define x real() 
#define y imag() 
using namespace std;
typedef complex<double> P;
 
int ccw(P a,P b,P c){
  b-=a;
  c-=a;
  if(imag(conj(b)*c)>0)return 1;
  if(imag(conj(b)*c)<0)return -1;
  return 0;
}
 
int main(){
  int H,R;
  while(cin>>H>>R,H){
    P h[100];
    for(int i=0;i<H;i++)
      cin>>h[i].x>>h[i].y;
    int m[3];
    double d[3],w[100],a[100];
    P p[3][10];
    cin>>m[0]>>m[1]>>m[2]>>d[0]>>d[1]>>d[2];
 
    for(int i=0;i<3;i++)
      for(int j=0;j<m[i];j++)
    cin>>p[i][j].x>>p[i][j].y;
 
    for(int i=0;i<R;i++)cin>>w[i]>>a[i];
 
    int c[100]={};
 
    for(int i=0;i<R;i++){
      bool f[100]={};
      for(int j=0;j<H;j++){
    P D=P(a[i]*cos((M_PI*(w[i]-d[0]/2)/180)),a[i]*sin((M_PI*(w[i]-d[0]/2)/180)));
    P U=P(a[i]*cos((M_PI*(w[i]+d[0]/2)/180)),a[i]*sin((M_PI*(w[i]+d[0]/2)/180)));
    if(abs(h[j])<=a[i]&&ccw(P(0,0),U,h[j])<=0&&ccw(P(0,0),D,h[j])>=0)f[j]=1;
      }
 
      for(int j=0;j<3;j++)
    for(int k=0;k<m[j];k++)
      for(int l=0;l<H;l++){
        P D=P(a[i]*cos((M_PI*(w[i]-d[j]/2)/180)),a[i]*sin((M_PI*(w[i]-d[j]/2)/180)));
        P U=P(a[i]*cos((M_PI*(w[i]+d[j]/2)/180)),a[i]*sin((M_PI*(w[i]+d[j]/2)/180)));
        if(abs(p[j][k]-h[l])<=a[i]&&ccw(p[j][k],p[j][k]+U,h[l])<=0&&ccw(p[j][k],p[j][k]+D,h[l])>=0)
          f[l]=0;
      }
      for(int j=0;j<H;j++)c[j]+=f[j];
    }
     
    int mx=0;
    vector<int> ans;
    for(int i=0;i<H;i++)mx=max(mx,c[i]);
    if(mx){
      for(int i=0;i<H;i++)
    if(mx==c[i])ans.push_back(i+1);
      for(int i=0;i<ans.size();i++){
    if(i)cout<<" ";
    cout<<ans[i];
      }
    }
    else cout<<"NA";
    cout<<endl;
  }
  return 0;
}

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

typedef long long ll;

int N;
ll A[100010],B[100010];

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)scanf("%lld%lld",A + i,B + i);

    ll ans = 0;
    for(int i = N - 1; i >= 0; i--)
    {
        A[i] += ans;
        if(A[i] % B[i] == 0);
        else if(B[i] >= A[i])ans += B[i] - A[i];
        else ans += B[i] - A[i] % B[i];
    }
    printf("%lld\n",ans);
    return 0;
}


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

int main(){
  int N,count = -1;
  cin >> N;
  vector<int> A(N);
  
  for(int i = 0;i < N;i++){
	cin >> A.at(i);
  }
  
  bool flag = true;
  
  while(flag){
    count++;
    
    for(int i = 0;i < N;i++){
      if(A.at(i) % 2 == 1){
        flag = false;
        break;
      }else{
        A.at(i) /= 2;
      }
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3030;
long long f[4][maxn<<2];
int main(){
	f[0][0] = 1;
	int a[3]; 
	for(int i = 0; i < 3; i++) cin >> a[i];
	int n; cin >> n;
	for(int i = 0; i < 3; i++){
		for(int k = 0; k*a[i] <= n; k++){
			for(int j = 0; j < maxn; j++){
				f[i+1][j+k*a[i]] += f[i][j];
			}
		}
	}
	cout << f[3][n] << endl;
	return 0;
}


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

namespace AtCoderTest
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string[] boin = new string[] { "a", "e", "i", "o", "u" };

            if(boin.Contains(s))
            {
                Console.WriteLine("vowel");
            }

            else
            {
                Console.WriteLine("consonant");
            }
        }
    }
}


Measured memory_bytes: 2648
#include <iostream>
#include <cstring>
using namespace std;
const int M = 1e5 + 10;
int a[M];
int main() {
    int n;
    cin >> n;
    for(int i = 1 ; i <= n ; i++) cin >> a[i];
    int l = a[1] , r = a[1];
    for(int i = 2 ; i <= n ; i++) {
        l = min(a[i] , l);
        r = max(a[i] , r);
    }
    if(r - l > 1) cout << "No" << endl;
    else {
        if(l == r) {
            int gg = n - l;
            if(gg == 1) cout << "Yes" << endl;
            else {
                if(n == 1 || gg >= l) cout << "Yes" << endl;
                else cout << "No" << endl;
            }
        }
        else {
            int cnt1 = 0 , cnt2 = 0;
            for(int i = 1 ; i <= n ; i++) {
                if(a[i] == l) cnt1++;
                if(a[i] == r) cnt2++;
            }
            if(cnt1 >= r) cout << "No" << endl;
            else {
                int gg = n - r;
                if(gg >= r - cnt1) cout << "Yes" << endl;
                else cout << "No" << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	long long ans=0;
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j+=i)
			ans+=j;
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
 
using namespace std;
 
#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define double long double
#define endl '\n'
 
signed main() {
    fio;
    char c; cin >> c;
    if(c >= 'A' and c <= 'Z') {
        cout << 'A' << endl;
    } else {
        cout << 'a' << endl;
    }
    
    return 0;
}
 

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

int main() {
  // input
  string S;
  cin >> S;
  
  // judge
  int N;
  int ans = 1000;
  for (int i = 0; i < S.size() - 2; i++) {
    N = stoi(S.substr(i, 3));
    ans = min(ans, abs(N - 753));
  }
  
  // output
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
n,m=map(int,input().split())
p,s=[],[]
for i in range(m):
    P,S=input().split()
    p.append(int(P))
    s.append(S)

pena=0
cnt_ac=defaultdict(lambda :0)
cnt_wa=defaultdict(lambda :0)
for x,y in zip(p,s):
    if cnt_ac[x]==0:
        if y=='AC':
            cnt_ac[x]=1
            pena+=cnt_wa[x]

        elif y=='WA':
            cnt_wa[x]+=1

print(sum(cnt_ac.values()),pena)


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

int main() {
    int N;
    cin >> N;
    int tmp = 0;
    vector<int> ans;
    int cnt = 0;

    while(N != 0){
        if (N % -2 == 0){
            ans.push_back(0);
            N /= -2;
        }
        else {
            ans.push_back(1);
            if (N < 0){
                N = -N / 2 + 1;
            }
            else {
                N = -(N / 2);
            }
        }
    }
    for (int i = ans.size() - 1; i >= 0; i--){
        cout << ans[i];
    }
    if (ans.size() == 0){
        cout << 0;
    }

    cout << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<vi> vvi;
typedef std::vector<ll> vll;
typedef std::vector<vll> vvll;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int t, x;
  scan(t, x);
  print((double)t / x);
  return 0;
}


Measured memory_bytes: 760
#include <stdio.h>

void printArray(int* as, int n)
{
  int i;
  for (i = 0; i < (n - 1); i++) {
    printf("%d ", as[i]);
  }
  printf("%d\n", as[n - 1]);
}

void insertionSort(int* as, int n)
{
  int i, j, k;
  int key;

  printArray(as, n);

  for (i = 1; i < n; i++) {
    key = as[i];
    j = i - 1;
    while (j >= 0 && as[j] > key) {
      as[j + 1] = as[j];
      j--;
    }
    as[j + 1] = key;
    printArray(as, n);
  }
}

int main(int argc, char *argv[])
{
  char row[4];
  int n = atoi(fgets(row, sizeof(row), stdin));
  int as[n];
  int i;

  for (i = 0; i < n; i++) {
    scanf("%d", &as[i]);
  }

  insertionSort(as, n);

  return 0;
}

Measured memory_bytes: 608
#include <stdio.h>

int main(void)
{
	int num;
	int ans;
	int price;
	
	while (1){
		scanf("%d", &price);
		
		if (price == 0)break;
		
		price = 1000 - price;
		
		ans = 0;
		while (price){
			if (price - 500 >= 0){
				price -= 500;
				ans++;
			}
			else if (price - 100 >= 0){
				price -= 100;
				ans++;
			}
			else if (price - 50 >= 0){
				price -= 50;
				ans++;
			}
			else if (price - 10 >= 0){
				price -= 10;
				ans++;
			}
			else if (price - 5 >= 0){
				price -= 5;
				ans++;
			}
			else if (price - 1 >= 0){
				price -= 1;
				ans++;
			}
		}
		
		printf("%d\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  string s;
  cin>>n>>s;

  int ans=0;
  for(int i=0; i<=n-3; i++){
    if(s.at(i)=='A' && s.at(i+1)=='B' && s.at(i+2)=='C')
    ans++;

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
 
int main() {
  int a, b, c, d, e, f, g, h, t, s1, s2;
  cin >> a >> b >> c >> d >> e >> f;
  a *= 100;
  b *= 100;
 
  for(int i = 0; i <= 30 && i*a <= f; ++i) {
    for(int j = 0; j <= 30 && j*b + i*a <= f; ++j) {
      if(i + j) {
        g = i*a + j*b;
        h = min(g*e/100, f-g);
        t = 0;
 
        for(int k = 0; k <= 100 && c*k <= h; k++) {
          for(int l = 0; l <= 100 && c*k + d*l <= h; l++) {
            t = max(t, c*k+d*l);
          }
        }
        if(s1 == 0 || t*(s1+s2) > s2*(g+t)) {
          s1 = g;
          s2 = t;
        }
      }
    }
  }
 
  cout << s1+s2 << " " << s2 << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
char a[5];
	int u[5],b,c,j,k;
void e(int i){
	if(k){
if(i==4){
	if(c==7){
		printf("%d",u[0]);
		for(j=1;j<4;j++){
			if(u[j]>=0)printf("+%d",u[j]);
			else printf("%d",u[j]);
		}
		printf("=7");
		k=0;
		}
	}
	else {
	c+=u[i];
	e(i+1);
	c-=u[i];
   u[i]*=-1;
   c+=u[i];
   e(i+1);
   c-=u[i];
   u[i]*=-1;
}
}
}
int main(){
	int i;
 scanf("%s",a);
 for(i=0;i<4;i++){
 	u[i]=a[i]-'0';
 }
 c=u[0];
 k=1;
 e(1);
 return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int sum = 0;
		for(int i=1;i<=n;i++) {
			sum = sum+i;
		}
		
		System.out.println(sum);
	}
}


Measured memory_bytes: 35632
a,b =map(int,input().split())
cnt =b-a+1

if a <0 and b>0 or a==0 or b==0:
    ans = "Zero"
elif (a>0 and b>0) or(a<0 and b<0 and cnt%2==0) :
    ans="Positive"
    
elif(a<0 and b<0 and cnt%2!=0):
    ans="Negative"
    
print(ans)

Measured memory_bytes: 3064
N = int(input())
V = [int(input()) for i in range(1,N+1)]
cnt = 1
val = V[0]
while True:
  if val == 2:
    print(cnt)
    break
  if (cnt >= N):
    print(-1)
    break
  cnt += 1
  val = V[val-1]


Measured memory_bytes: 13052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int N;  cin >> N;
  int Q;  cin >> Q;
  vector<ll> a(N);
  for(int i = 0;i < N;i++)cin >> a[i];

  vector<ll> answers;

  for(int l = 0;l < Q;l++){
    ll x; cin >> x;

    ll answer = 0;
    ll sum = 0;
    int r = 0;

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

      while(r != N && sum + a[r] <= x){
        sum += a[r];
        r++;
      }


      answer += r - i;
      sum -= a[i];
    }

    answers.push_back(answer);

  }

  for(int l = 0;l < Q;l++)cout << answers[l] << endl;

  return 0;
}



Measured memory_bytes: 3544
#include<cstdio>
#include<algorithm>
#include<set>
using namespace std;
const int N=1e5+5;
int n,m,maxd,cnt;
multiset<int>S[N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,x,y;i<=m;++i){
		scanf("%d%d",&x,&y);
		S[x].insert(y);S[y].insert(x);
	}
	for(int i=1;i<=n;++i){
		if(S[i].size()&1)return puts("No"),0;
		if(maxd<S[i].size())
			maxd=S[i].size(),cnt=1;
		else if(maxd==S[i].size())
			++cnt;
	}
	if(maxd>=6)return puts("Yes"),0;
	if(maxd==4&&cnt>=3)return puts("Yes"),0;
	if(maxd==4&&cnt==2){
		int A=0,B=0;
		for(int i=1;i<=n;++i){
			if(S[i].size()==4)A?B=i:A=i;
			if(S[i].size()==2){
				int x=*S[i].begin(),y=*S[i].rbegin();
				S[x].erase(S[x].find(i));
				S[y].erase(S[y].find(i));
				S[x].insert(y);S[y].insert(x);
			}
		}
		return puts(S[A].find(A)!=S[A].end()?"Yes":"No"),0;
	}
	return puts("No"),0;
}


Measured memory_bytes: 14336
N = int(input())
H = list(map(int, input().split()))

cnt = 0
peak = 0
prev = 0
down = False
for h in H:
    if down and h > prev:
        cnt += peak - prev
        peak = prev
        down = False
    elif h < prev:
        down = True
    peak = max(peak, h)
    prev = h
else:
    cnt += peak

print(cnt)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n, x;
    cin >> n >> x;
    vector<int> vec(n);
    for (int i=0; i<n; i++) cin >> vec[i];
    for (int i=0; i<n; i++) x -= vec[i];
    int cnt=n;
    int mini = *min_element(all(vec));
    while (x >= mini){
        x -= mini;
        cnt++;
    }
    out(cnt);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int  main(){
 int a,b;
 cin >> a>>b;
 if(b>=a){
     cout << "unsafe" << endl;
 }else{
     cout << "safe" << endl;
 }

return 0;
}

Measured memory_bytes: 3624
#include "stdio.h"

int main(void){
	int H, W;

	scanf("%d%d", &H, &W);

	if(((H+W)/2*2)<H+W){
		printf("%d\n", (H+W)/2+1);
	}else{
		printf("%d\n", (H+W)/2);
	}
	return 0;
}

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

int main() {
	long long N, M, ANS = 0;
	static vector<long long> V[100000];
	priority_queue<long long> PQ;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		long long A, B;
		cin >> A >> B;
		A--;
		V[A].push_back(B);
	}
	for (int i = 0; i < M; i++) {
		for (int j : V[i]) PQ.push(j);
		if (!PQ.empty()) ANS += PQ.top(), PQ.pop();
	}
	cout << ANS << endl;
}

Measured memory_bytes: 5632
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long f(long n) {
    if (n <= 0) return 0;

    // 0, 1, 2, ..., n の排他的論理和を求める
    if (n % 2 == 1) {
        if ((n + 1) / 2 % 2 == 0) return 0; // 偶数奇数のペアが偶数個
        return 1;
    }
    else {
        // 0, 1, 2, ..., (n - 1) までの偶数奇数のペアが偶数個
        if (n / 2 % 2 == 0) return n;
        return n ^ 1;
    }
}

long calc(long a, long b) {
    return f(a - 1) ^ f(b);
}

void main() {
    auto ab = reads!long;
    long a = ab[0], b = ab[1];

    auto ans = calc(a, b);
    writeln(ans);
}


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

int main() {
    int h, w, n; cin >> h >> w >> n;
    int ci, cj; cin >> ci >> cj; ci--, cj--;
    string s, t; cin >> s >> t;
    int ch;
    int ci_min = ci, ci_max = ci;
    int cj_min = cj, cj_max = cj;
    for (int i = 0; i < n; i++) {
        ch = s[i];
        if (ch == 'U') ci_min--;
        if (ch == 'D') ci_max++;
        if (ch == 'L') cj_min--;
        if (ch == 'R') cj_max++;
        if (ci_min < 0 || ci_max >= h || cj_min < 0 || cj_max >= w) {
            cout << "NO" << endl;
            return 0;
        }
        ch = t[i];
        if (ch == 'U') ci_max = max(ci_max - 1, 0);
        if (ch == 'D') ci_min = min(ci_min + 1, h - 1);
        if (ch == 'L') cj_max = max(cj_max - 1, 0);
        if (ch == 'R') cj_min = min(cj_min + 1, w - 1);
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 776
import java.util.*;
import java.io.*;

import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		String d = sc.next() + "________";
		String ans = "";
		HashSet<String> aidunyan = azunyan();
		for (int i=0;i<d.length() - 8;i++) {
			if (aidunyan.contains(d.substring(i, i+8))) {
				ans += "AIZUNYAN";
				i += 7;
			} else {
				ans += d.charAt(i);
			}
		}
		System.out.println(ans);
	}

	HashSet<String> azunyan() {
		int[] az = {'A', 'I', 'D', 'U', 'N', 'Y', 'A', 'N'};
		sort(az);
		Permutation p = new Permutation(az.length);
		p.set(az);
		HashSet<String> set = new HashSet<String>();
		while (p.hasNext()) {
			int[] pure = p.next();
			set.add(ar2str(pure));
		}
		return set;
	}
	
	String ar2str(int[] ar) {
		String s = "";
		for (int i : ar) {
			s += (char)i;
		}
		return s;
	}

	class Permutation {
		private final int size;

		public Permutation(int size) {
			if (size <= 0) throw new IllegalArgumentException();
			this.size = size;
			source = new int[size];
		}
		
		void set(int[] source) {
			System.arraycopy(source, 0, this.source, 0, size);
		}

		int[] source;
		boolean isFirst = true;

		public boolean hasNext() {
			if (isFirst) {
				isFirst = false;
				return true;
			}

			int n = source.length;
			for (int i = n - 1; i > 0; i--) {
				if (source[i - 1] < source[i]) {
					int j = n;
					while (source[i - 1] >= source[--j]);
					swap(source, i - 1, j);
					reverse(source, i, n);
					return true;
				}
			}
			reverse(source, 0, n);
			return false;
		}

		public int[] next() {
			return source;
		}

		private void swap(int[] is, int i, int j) {
			int t = is[i];
			is[i] = is[j];
			is[j] = t;
		}

		private void reverse(int[] is, int s, int t) {
			while (s < --t) swap(is, s++, t);
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 36160
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

K=gets.to_i
ans=0
1.upto(K) do|i|
    1.upto(K) do|j|
        1.upto(K) do|k|
          ans+=i.gcd(j.gcd(k))
        end
    end
end
puts ans

Measured memory_bytes: 14380
n = int(input())
*A, = map(int, input().split())
for i in range(n):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(*A)

Measured memory_bytes: 8084
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    string a,b;
    cin>>a>>b;
    string s=a+b;
    int n=0;
    for(int i=0;i<s.size();i++){
        n+=pow(10,s.size()-i-1)*(s[i]-'0');
    }
    int x=(int)(floor(sqrt(n)));
    cout<<(n==x*x?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val w = readLine()!!

    val m = mutableMapOf<String, Int>()
    w.forEach {
        val key = it.toString()
        if (m[key] == null) m[key] = 0
        m[key]?.plus(1)?.let { i -> m[key] = i }
    }

    if (m.values.filter { it % 2 != 0 }.isEmpty()) {
        println("Yes")
    } else {
        println("No")
    }
}


Measured memory_bytes: 31880
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

void solve() {
    LL n;
    cin >> n;
    map<int,int> m;
    for (LL i = 2; i * i <= n; ++i) {
        if (n % i != 0) continue;
        while (n % i == 0) {
            n /= i;
            m[i]++;
        }
    }
    if (n > 1) m[n]++;
    LL ans = 0;
    for (auto p: m) {
        int v = p.second;
        LL cnt = 1;
        while (cnt * (cnt + 1) / 2 <= v) {
            ++cnt;
            ++ans;
        }
        dump(ans);
    }
    cout << ans << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 3632
N = int(input())
L = list(map(int,input().split()))

ans = 0

L.sort() #replace in ordered

for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            L1 = L[i]
            L2 = L[j]
            L3 = L[k]
            if L1 == L2 or L2 == L3 or L3 == L1:
                continue
            if L1 + L2 > L3:
                ans += 1
            else:
                break

print(ans)


Measured memory_bytes: 9048
def main():
    mod = 998244353
    n = int(input())
    ab = sorted([tuple(map(int, input().split())) for _ in [0]*n])
    next_idx = [-1]*n
    for i in range(n-1, -1, -1):
        dist = sum(ab[i])
        now = i
        while now < n-1:
            a1, b1 = ab[now+1]
            if a1 < dist:
                now = next_idx[now+1]
            else:
                break
        next_idx[i] = now
    dp = [0]*(n+1)
    dp[n] = 1
    for i in range(n-1, -1, -1):
        dp[i] = (dp[i+1]+dp[next_idx[i]+1]) % mod
    print(dp[0])
 
 
main()

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

using namespace std;

using ll = long long;

ll solve(int n, vector<int>& a) {
    if (a[0] != 0) return -1;
    for (int i = 1; i < n; i++) {
        if (a[i] - a[i - 1] >= 2) return -1;
    }

    vector<int> cnt(n, 0);
    for (int i = n - 1; i >= 1; i--) {
        if (i < n - 1 && a[i + 1] - a[i] == 1) continue;
        if (i - a[i] < 0 || i - a[i] >= n) return -1;
        cnt[i]++;
        cnt[i - a[i]]--;
    }

    for (int i = n - 1; i > 0; i--) {
        cnt[i - 1] += cnt[i];
    }

    ll res = 0;
    for (int i = 0; i < n; i++) {
        res += cnt[i];
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    cout << solve(n, a) << endl;

    return 0;
}

Measured memory_bytes: 1920