akhauriyash/Code-Regression huggingface dataset:
/**
*   @Author : MeGaCrazy
*   @InitTime : Wed Jan 02 17:39:58 2019
*   @Idea :
*
*
*
*
*
*  Happy Solving :)
**/
#include <bits/stdc++.h>
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
 //  freopen("in","r",stdin);
   //freopen("out","w",stdout);
#endif
   long long n;
   cin>>n;
   long long l=0,r=1e15;
   if(n<6){
   	cout<<1<<endl;
   	return 0;
   }
   while((r-l)>1){
    	long long mid=(l+r)>>1;
    	if(mid*5ll + mid*6ll >=n)r=mid;
    	else l=mid+1;
   }   
   if(1ll*5*(r-1)+(1ll*6*(r-1)) >=n)r--;

   if(1ll*5*(r-1)+(1ll*6*(r))>=n){
        cout<<(r)+(r-1)<<endl;
   }else{
   	cout<<(r*2)<<endl;
   }

}

Measured memory_bytes: 256
input1 = input()
input2 = input()
#input1 = "20"
#input2 = "xxzaffeeeeddfkkkkllq"
N = int(input1)
hairetu = list(input2)

i=0
s=0
a=0

for s in range (N*N):
    if len(hairetu)<i+2:
        break
    elif hairetu[i]==hairetu[i+1]:
        a = hairetu.pop(i+1)
    else:
        i=i+1

    
p = len(hairetu)
print(p)

Measured memory_bytes: 4084
#include <string.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define ll long long
#define inf 0x3f3f3f3f
#define ms(x,a) memset(x,a,sizeof(x))
#define sd(x) scanf("%d",&x)
#define sdd(x,y) scanf("%d%d",&x,&y)
#define sddd(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld%lld",&x,&y)
#define slll(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define sf(x) scanf("%lf",&x)
#define sff(x,y) scanf("%lf%lf",&x,&y)
#define sfff(x,y,z) scanf("%lf%lf%lf",&x,&y,&z)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define repp(i,n,a) for(int i=n;i>=a;i--)
#define pd(x) printf("%d\n",x)
#define pdd(x,y) printf("%d%d\n",x,y)
#define pddd(x,y,z) printf("%d%d%d\n",x,y,z)
#define pl(x) printf("%lld\n",x)
#define pll(x,y) printf("%lld%lld\n",x,y)
#define plll(x,y,z) printf("%lld%lld%lld\n",x,y,z)
#define debug() printf("***\n")
using namespace std;
int n,m;
ll a,b,c;

int main() {
	slll(a,b,c);
	if(b+c>=a)pl(b+c-a);
	else printf("0\n");
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#define llint long long

using namespace std;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int a, b;
	cin >> a >> b;
	if(a <= 9 && b <= 9) cout << a*b << endl;
	else cout << -1 << endl;
	
	return 0;
}

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

int main(){
  string s; cin>>s;
  //int a,b,c; cin>>a>>b>>c;
  //cout<<c<<" "<<a<<" "<<b<<endl;
  cout<<(s[2]==s[3]&&s[4]==s[5]?"Yes":"No");

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const ll N = 1e5 + 5, MOD = 1e9+7;

string s;
ll a[10];

int main(){

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

    cin>>s;

    for( ll i=0; i<s.size(); i++ )      a[i]=s[i]-'0';

    if(a[0]<1){
        if(a[1]!=0){
            if(a[2]<1 && a[3]!=0 || a[2]==1 && a[3]<=2)    cout<<"AMBIGUOUS"<<endl;
            else                                           cout<<"MMYY"<<endl;
        }
        else{
            if(a[2]<1 && a[3]!=0 || a[2]==1 && a[3]<=2)    cout<<"YYMM"<<endl;
            else                                           cout<<"NA"<<endl;
        }
    }
    else if(a[0]==1){
        if(a[1]<=2){
            if(a[2]<1 && a[3]!=0 || a[2]==1 && a[3]<=2)    cout<<"AMBIGUOUS"<<endl;
            else                                           cout<<"MMYY"<<endl;
        }
        else{
            if(a[2]<1 && a[3]!=0 || a[2]==1 && a[3]<=2)    cout<<"YYMM"<<endl;
            else                                           cout<<"NA"<<endl;
        }
    }
    else{
        if(a[2]<1 && a[3]!=0 || a[2]==1 && a[3]<=2)    cout<<"YYMM"<<endl;
        else                                           cout<<"NA"<<endl;
    }
    return 0;
}




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

int main() {
  int n;
  cin >> n;
  int s, t;
  cin >> s >> t;
  if(n == 1) {
    cout << "Hello World" << endl;
  }
  else if(n == 2) {
    cout << s + t << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1)
using namespace std;
int a[200005];
int main()
{
//    int n;
//    scanf("%d",&n);
//    for(int i=1;i<=n;i++)
//    {
//        scanf("%d",&a[i]);
//    }
//    int T;
//    scanf("%d",&T);
//    while(T--)
//    {
//        int n;
//        scanf("%d",&n);
//        for(int i=1;i<=n;i++)
//        {
//            scanf("%d",&a[i]);
//        }
//    }
    double x;
    scanf("%lf",&x);
    printf("%.10f\n",pi*2*x);
}


Measured memory_bytes: 3788
use std::io::*;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn main() {
    let s1 = read::<String>();
    let s2 = read::<String>();
    let s3 = read::<String>();
    println!("{}{}{}",s1.chars().nth(0).unwrap(),s2.chars().nth(1).unwrap(),s3.chars().nth(2).unwrap());
}


Measured memory_bytes: 4352
n, m = map(int, input().split())

s = []
for i in range(m):
    s.append(list(map(int, input().split())))

if n == 1:
    a = [str(i) for i in range(10)]
elif n == 2:
    a = [str(i) for i in range(10,100)]
elif n == 3:
    a = [str(i) for i in range(100,1000)]

ans = []

for i in a:
    b = True
    for j in s:
        if int(i[j[0]-1]) != j[1]:
            b = False
            break
    if b:
        ans.append(i)

if len(ans) == 0:
    print(-1)
else:
    print(min(ans))



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

int main(){
  char s[55][55]; int h, w, hoge = 0;
  std::cin >> h >> w;
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++) std::cin >> s[i][j];
  }

  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      if(s[i][j]=='#' && s[i-1][j]!='#' && s[i+1][j]!='#' && s[i][j-1]!='#' && s[i][j+1]!='#') hoge++;
    }
  }

  if(hoge == 0) {
    std::cout << "Yes"; std::cout << "\n";
  }
  else {
    std::cout << "No"; std::cout << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.stdio;
import std.string;

void main()
{
    Input input = void;
    parseInput(input, stdin);
    main2(&input);
//    writeln(result);
}

auto main2(Input* input)
{
	uint[100000] seikaisuu;
	foreach (ai; input.a)
	{
		seikaisuu[ai-1]++;
	}

	for (int i = 0; i < input.n; i++)
	{
		if (input.q - seikaisuu[i] >= input.k)
		{
			writeln("No");
		}
		else
		{
			writeln("Yes");
		}
	}
}

struct Input
{
	uint n,k,q;
    uint[] a;
}

void parseInput(T)(out Input input, T file)
{
    with (file) with (input)
    {
		auto nkq = readln().strip().split().array().map!(a=>a.to!uint);
		n = nkq[0];
		k = nkq[1];
		q = nkq[2];
		a.length = q;
		foreach (i; 0..q)
		{
			a[i] = readln().strip().to!uint;
		}
    }
}

void parseExample(out Input input, string example)
{
    struct Adapter
    {
        import std.string;
        string[] _lines;
        this(string input) { _lines = input.splitLines(); }

        string readln()
        {
            auto line = _lines[0];
            _lines = _lines[1..$];
            return line;
        }
    }
    Adapter a = Adapter(example);
    parseInput(input, a);
}


Measured memory_bytes: 4220
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  int n=b-a;
  cout<<n*(n+1)/2-b<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,p;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>a>>p;
	cout<<(a*3+p)/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string.h>
using namespace std;
const int AX = 1e5+66;
int a[AX];
int s[AX];
map<int,int>mp;
int main(){
	int flag = 0;
	int g = 0;
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		mp[a[i]] = 1;
	}
	sort(a,a+n);
	if(a[n-1]<=k) flag = 0;
	else flag = 1;
	if(flag == 1){
	for(int i=0;i<n;i++){
		if(mp[k-a[i]] == 1){
		g = 1;
		break;
		}
	}
}
if((flag && g) || mp[k]) printf("POSSIBLE\n");
else printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 6016
h,w=map(int,input().split())
c=[]
for i in range(10):
    c.append([int(j) for j in input().split()])
a=[]
for i in range(h):
    a.append([int(j) for j in input().split()])


n=10
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

d=warshall_floyd(c)
ans=0

for i in range(h):
    for j in a[i]:
        if j!=-1:
            ans+=d[j][1]

print(ans)

Measured memory_bytes: 3316
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <queue>
#include <algorithm>

using namespace std;

// AOJ 0168
// KannonDou
// input n = year
// EOF = 0


int main(){

	long long a[30] = {1, 2, 4};	//a[0] = 1, a[1] = 2, a[2] = 4??§?????????
									//i+1????????§?????????????????°
	for(int i=3 ; i<30 ; i++){
		a[i] = a[i-1] + a[i-2] + a[i-3];	//a[3]???3-4,2-4,1-4????????????
											//????????°1-4??§2???3?????¢??????????????????1?????????????????????
											//????????????????????????????¨?????????????????????£??????????????????????????§?§£??????
	}
	while(1){
		int n;
		cin >> n;
		if(n==0) return 0;
		int temp = a[n-1];
		temp /= 365;
		temp /= 10;
		cout << temp + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner reader=new Scanner(System.in);
		CharSequence c=reader.next();
		String voyel="aeiou";
		if (voyel.contains(c)){
			System.out.print("vowel");
		}
		else {
			System.out.print("consonant");

		}
		
	}
	
	

}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#include <iostream>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;

#define nl '\n'
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: ", cout << to_string(__VA_ARGS__) << endl
/*compact version*/
template <typename T, size_t N> int SIZE(const T (&t)[N]) { return N; } template<typename T> int SIZE(const T &t) { return t.size(); } string to_string(string &s, int x1 = 0, int x2 = 1e9) { return '"' + ((x1 < s.size()) ? s.substr(x1, x2 - x1 + 1) : "") + '"'; } string to_string(const char* s) { string tmp(s); return to_string(tmp); } string to_string(bool b) { return (b ? "true" : "false"); } string to_string(char c) { return string({c}); } template<size_t N> string to_string(bitset<N> &b, int x1 = 0, int x2 = 1e9) { string t = ((x1 < b.size()) ? (b.to_string()).substr(x1, x2 - x1 + 1) : ""); reverse(begin(t), end(t)); return '"' + t + '"'; } template <typename A, typename... C> string to_string(A (&v), int x1 = 0, int x2 = 1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if (l_v_l_v_l == 0) res += nl; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2 - x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if (e != l) { if (rnk > 1) { res += nl; t_a_b_s = l_v_l_v_l; }; } else { t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if (l_v_l_v_l == 0) res += nl; return res; }
/*end of compact version*/


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
#endif

    int t = 1;
    // cin >> t;

    while (t--) {
        int n;
        cin >> n;
        set<string> si;
        while (n--) {
            string s;
            cin >> s;
            si.insert(s);
        }
        cout << si.size() << endl;
    }

    return 0;
}

Measured memory_bytes: 19208
// Problem: A - Payment
// Contest: AtCoder - AtCoder Beginner Contest 173
// URL: https://atcoder.jp/contests/abc173/tasks/abc173_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 1e6 + 5;

int n;

int32_t main() { cin.tie(0)->sync_with_stdio(0);
  cin >> n;
  cout << (1000 - n % 1000) % 1000;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string o,e;
  cin>>o>>e;
  
  int d = o.length() - e.length();
  
  rep(i,e.length()) {
    cout<<o[i]<<e[i];
  }
  
  if(d==1) {
    cout<<o[o.length()-1];
  }
  
  return 0;
}

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

using namespace std;

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree < int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update >
#define smallk order_of_key
#define kth find_by_order
*/

#define nl '\n'
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pb push_back

typedef long long ll;

const int N = (int)1e5 + 123;
const int M = 1e9 + 7;
const int K = 500;

int n;
int a[4][N], dp[4][N];
int main(){

    //ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

    #ifdef LOCAL
        freopen("C.txt", "r", stdin);
    #endif // LOCAL

    cin >> n;
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= 3; ++j){
            cin >> a[j][i];
        }
    }
    dp[1][1] = a[1][1];
    dp[2][1] = a[2][1];
    dp[3][1] = a[3][1];
    for(int i = 2; i <= n; ++i){
        dp[1][i] = max(dp[2][i - 1], dp[3][i - 1]) + a[1][i];
        dp[2][i] = max(dp[1][i - 1], dp[3][i - 1]) + a[2][i];
        dp[3][i] = max(dp[2][i - 1], dp[1][i - 1]) + a[3][i];
    }
    cout << max(dp[1][n], max(dp[2][n], dp[3][n]));
    return 0;
}



Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(i=a;i<b;i++)
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define vll vector<ll>
#define vlll vector<vll>
#define all(x) x.begin(),x.end()
ll power(ll x, ll y, ll p) {
    ll res = 1;    x = x % p;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y = y>>1;    x = (x*x) % p;
    } return res;
}
int main()
{
    Imposter

    int t=1;
    //cin>>t;
    while(t--)
    {
        int n,x,t;
        cin>>n>>x>>t;
        int temp=ceil(double(n)/x);
        cout<<temp*t<<endl;
    }
    return 0;
}


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

int main() {
  // ここにプログラムを追記
  string  a;
  cin >> a;
  int x= 0;
  for (int i=0; i<3;i++){
      if(a.at(i)=='1'){
          x++;
      }
  }


  cout << x << endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };
const double PI = 3.14159265358979323846;

int main() {

	int a, b;
	cin >> a >> b;
	int c = a + b;

	if (a % 3 == 0 || b % 3 == 0 || c % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
   
	return 0;
	
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <time.h>
#include <vector>

using namespace std;
typedef long long ll;
template <class T = ll>
T in() {
    T x;
    cin >> x;
    return (x);
}
template <class T>
void print(T x) {
    cout << x << "\n";
}
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define reps(x, c) for (auto x : c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a)
#define mp(a, b) make_pair((a), (b))
#define pl pair<ll, ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cerr << #x "=" << (x) << "\n"
#define dbgv(x) \
    cerr << #x << "\n"; \
    reps(y, x) { cerr << y << " "; } \
    cerr << "\n"

int main() {
    string s = in<string>();
    int n    = s.size();
    ll ans1 = 0, ans2 = 0;
    bool flg = true;
    rep(i, n) {
        if (flg) {
            if (s[i] == '0') {
                ans2++;
            }
            else {
                ans1++;
            }
        }
        else {
            if (s[i] == '1') {
                ans2++;
            }
            else {
                ans1++;
            }
        }
        flg = !flg;
    }
    cout << min(ans1, ans2) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cctype>
#include <iomanip>
#include <limits>
#include <bitset>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef unsigned long long int ull;
const ll mod = 1000000007;
const ll linf = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = (m); i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<>()
#define SUM(a) accumulate((a).begin(), (a).end(), 0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecb vector<bool>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
template <typename T>
int len(T tmp)
{
	int res = 0;
	while (tmp > 0)
	{
		res++;
		tmp /= 10;
	}
	return res;
}
template <typename T>
T gcd(T a, T b)
{
	T t;
	while (b != 0)
	{
		t = a % b;
		a = b;
		b = t;
	}
	return a;
}
template <typename T>
T recfact(T start, T n)
{
	T i;
	if (n <= 16)
	{
		T r = start;
		for (i = start + 1; i < start + n; i++)
			r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
template <typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}
template <typename T>
T fct(T n)
{
	return recfact<T>(1, n);
}
template <typename T>
T ncm(T n, T m)
{
	if (n < m)
		return 0;
	T x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr)
{
	if (firstItr < 0 || secondItr > int(str.size() - 1))
		return str;
	while (firstItr < secondItr)
	{
		swap(str[firstItr], str[secondItr]);
		firstItr++;
		secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str)
{
	int itr = 0;
	std::string res;
	while (itr < int(str.size()))
	{
		char tmp = str[itr++];
		int length = 1;
		while (itr < int(str.size()) && str[itr] == tmp)
		{
			++itr;
			++length;
		}
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
str split(str str, size_t first_itr, size_t second_itr)
{
	string tmp;
	for (size_t i = first_itr; i < second_itr + 1; i++)
	{
		tmp.push_back(str.at(i));
	}
	return tmp;
}

int main(void)
{
	int n, m;
	cin >> n >> m;
	int l = 0, r = 100000;
	rep(i,m){
		int ltmp, rtmp;
		cin >> ltmp >> rtmp;
		l = max(ltmp, l);
		r = min(rtmp, r);
	}
	cout << max(r - l + 1, 0) << endl;
	return 0;
}


Measured memory_bytes: 256
N=int(input())
d={}
l="MARCH"
c=[0 for _ in range(5)]
for n in range(N):
    S=input()
    for n in range(len(l)):
        if l[n]==S[0]:
            c[n]+=1
ans=0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            ans+=c[i]*c[j]*c[k]
print(ans)


Measured memory_bytes: 9132
def min(a,b); a < b ? a : b; end
INF = 1 << 30
H, N = gets.split.map(&:to_i)
S = N.times.map{ gets.split.map(&:to_i) }

dp = Array.new(1 << 14, INF); dp[0] = 0

S.sort_by!{|a,b| b.to_f / a }
S.each do |a,b|
  (a ... H + a).each do |i|
    dp[i] = min(dp[i], dp[i - a] + b) if dp[i - a] < INF
  end
  break if dp[H] < INF
end
puts dp[H .. -1].min



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

int main(){
  string s[3];
  rep(i,0,3){cin>>s[i];}

  cout<<"A"<<s[1].substr(0,1)<<"C"<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

#define MAXN 109

struct myc {
    int x;
    long long y;
    inline bool operator < (const myc &u) const {
        if (x == u.x) return y < u.y;
        else return x < u.x;
    }
};

std::vector < int > g[MAXN];
int d[2][MAXN];
bool viz[MAXN];
int v[MAXN];
int cul[MAXN];
int urm[MAXN];
int t, r[2][MAXN];

void dfs(int x) {
    viz[x] = 1;
    for (auto &y : g[x]) {
        if (viz[y] == 0) {
            d[t][y] = d[t][x] + 1;
            urm[y] = x;
            dfs(y);
        }
    }
}

inline myc adevSolve() {
    int val = (v[0] + 1) / 2, p = 0, q = 1;
    long long cnt = 0, ans = r[0][0];
    while (q < val) {
        for (int i = 1; i <= r[p][0]; i++)
            cul[r[p][i]] = q;
        q++;
        int best = 0, sum = 0;
        for (int i = 1; i <= r[p][0]; i++) {
            int cat = 0;
            for (auto &x : g[r[p][i]])
                if (cul[x] == 0)
                    cat++, r[1 - p][++r[1 - p][0]] = x;
            best = std::max(best, cat);
            sum += cat;
        }

        cnt = (cnt + r[p][0]) * best - sum;
        ans = cnt + sum;

        r[p][0] = 0;
        p = 1 - p;
    }

    for (int i = 1; i <= r[p][0]; i++)
        cul[r[p][i]] = q;
    for (int i = 1; i <= r[p][0]; i++)
        for (auto &x : g[r[p][i]])
            if (cul[x] == 0)
                return {MAXN, 0};

    return {val, ans};
}

inline myc solve(int n) {
    for (int i = 1; i <= n; i++)
        viz[i] = 0;
    t = 0;
    d[0][1] = 0;
    dfs(1);
    int a = 1;
    for (int i = 2; i <= n; i++)
        if (d[0][i] > d[0][a])
            a = i;

    for (int i = 1; i <= n; i++)
        viz[i] = 0;
    t = 1;
    d[1][a] = 0;
    dfs(a);
    int b = 1;
    for (int i = 2; i <= n; i++)
        if (d[1][i] > d[1][b])
            b = i;

    v[0] = 0;
    while (b != a) {
        v[++v[0]] = b;
        b = urm[b];
    }
    v[++v[0]] = a;

    r[0][0] = r[1][0] = 0;
    for (int i = 1; i <= n; i++)
        cul[i] = 0;
    if (v[0] % 2 == 0) {
        r[0][++r[0][0]] = v[v[0] / 2 + 1];
        r[0][++r[0][0]] = v[v[0] / 2];
        return adevSolve();
    } else {
        r[0][++r[0][0]] = v[v[0] / 2 + 1];
        myc ans = adevSolve();
        for (auto &x : g[v[v[0] / 2 + 1]]) {
            r[0][0] = r[1][0] = 0;
            for (int i = 1; i <= n; i++)
                cul[i] = 0;
            r[0][++r[0][0]] = v[v[0] / 2 + 1];
            r[0][++r[0][0]] = x;
            ans = std::min(ans, adevSolve());
        }
        return ans;
    }

    return {MAXN, 0};
}

int main() {
    int n;
    scanf("%d", &n);

    for (int i = 1; i < n; i++) {
        int x, y;
        scanf("%d%d", &x, &y);

        g[x].push_back(y);
        g[y].push_back(x);
    }

    myc ans = solve(n);

    printf("%d %lld\n", ans.x, ans.y);

    return 0;
}


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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

ll gcd(ll x,ll y)
{
	if(x==0) return y;
	return gcd(y%x,x);
}

int n,k,a[100010],x;
 
signed main(){
	cin >>n>>k;
	rep(i,0,n){
	    cin>>a[i];
	    if(i==0)x=a[i];
	    else x=gcd(x,a[i]);
	}
	sort(a,a+n);
	if(k>a[n-1]){
	    cout<<"IMPOSSIBLE"<<endl;
	    return 0;
	}
	if(a[n-1]==k){
	        cout<<"POSSIBLE"<<endl;
	        return 0;
	    }
	//cout<<x<<endl;
	while(a[n-1]){
	    a[n-1]-=x;
	    if(a[n-1]==k){
	        cout<<"POSSIBLE"<<endl;
	        return 0;
	    }
	}
	cout<<"IMPOSSIBLE"<<endl;
	
	
	
	
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;


int main(void) {
    ll N, M;
    cin >> N >> M;
    ll x[MAX], s[MAX];
    ll i;
    ll ans=0;
    for(i=0; i<M; i++) {
        cin >> x[i];
    }
    sort(x, x+M);
    ans=x[M-1]-x[0];
    for(i=0; i<M-1; i++) {
        s[i]=x[i+1]-x[i];
    }
    sort(s, s+M-1);
    reverse(s, s+M-1);
    
    if(N>=M) {
        pt(0);
        return 0;
    }
    
    for(i=0; i<N-1; i++) {
        ans-=s[i];
    }
    
    pt(ans);
}



Measured memory_bytes: 1792
use proconio::{input, fastout, derive_readable};

#[fastout]
fn main() {
    input!{
        n : usize,
    }
    let mut ans = vec![0_usize; n + 1];
    for x in 1 .. 100_usize {
        for y in 1 .. 100_usize {
            for z in 1 .. 100_usize {
                let f = x * x + y * y + z * z + x * y + y * z + z * x;
                if f <= n {
                    ans[f] += 1;
                }
            }
        }
    }
    for i in 1 ..= n {
        println!("{}", ans[i]);
    }
}


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

using namespace std;
vector<tuple<int,int,int>> a;
int main()
{
    int n;
    cin >> n;
    for (int i=0;i<n;i++)
    {
        int x ,y;
        cin >> x >> y;
        a.push_back(make_tuple(x,y,x+y));
    }
    sort(a.begin(),a.end(),[](const tuple<int,int,int>&a,tuple<int,int,int>&b)
    {
        int ax,ay,az,bx,by,bz;
        tie(ax,ay,az)=a;
        tie(bx,by,bz)=b;
        return (az==bz?ax==bx?ay>by:ax>bx:az>bz);
    });
    //for (int i=0;i<n;i++) cout << get<0>(a[i]) <<" "<< get<1>(a[i])<< endl;
    long long ans=0;
    int pos=0,who=0;
    while(pos<n)
    {
        if(who==0) ans+=get<0>(a[pos]);
        else ans-=get<1>(a[pos]);
        pos++;
        who^=1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1912
#!/usr/bin/env fsharpi

open System;

let ParseIntN ( str : string ) =
    str.Split(' ')
    |> Array.map System.Int32.Parse

let ParseInt1 ( str : string ) =
    ParseIntN str |> fun arr -> arr.[0]

let ParseInt2 ( str : string ) =
    ParseIntN str |> fun arr -> (arr.[0],arr.[1])

let ParseInt3 ( str : string ) =
    ParseIntN str |> fun arr -> (arr.[0],arr.[1],arr.[2])

let ReadLinesN ( n : int ) =
    fun _ -> Console.ReadLine()
    |> Seq.initInfinite
    |> Seq.take n

let ReadLines =
    fun _ -> Console.ReadLine()
    |> Seq.initInfinite
    |> Seq.takeWhile ((<>) null)

let (n,l) = ParseInt2 <| Console.ReadLine()
ReadLinesN n
|> Seq.sort
|> Seq.fold (+) ""
|> Console.WriteLine


Measured memory_bytes: 15328
n, m = gets.to_s.split.map{|t|t.to_i}
h    = [0] + gets.to_s.split.map{|t|t.to_i}

ans = [1] * (n+1)
ans[0] = 0

m.times do
  
  a, b = gets.to_s.split
  a, b = a.to_i, b.to_i
  
  if h[a] < h[b]
    ans[a] = 0
  elsif h[a] > h[b]
    ans[b] = 0
  else
    ans[a] = ans[b] = 0
  end
end

puts ans.sum

Measured memory_bytes: 23412
#include <stdio.h>
int main(){
  int r,c,i,j,sum,s[101][101];
  scanf("%d %d", &r, &c);
  for (i = 0; i < r; i++){
    sum=0;
    for (j = 0; j < c; j++){
      scanf("%d",&s[i][j]);
      sum+=s[i][j];
    }
    s[i][c]=sum;
  }
  for (j = 0; j < c+1; j++){
    sum = 0;
    for (i = 0; i < r; i++)
      sum += s[i][j];
    s[r][j]=sum;
  }
  for (i = 0; i < r+1; i++){
    for (j= 0; j < c+1; j++){
      printf("%d",s[i][j]);
      if (j!=c) printf("%s"," ");
    }
    printf("%s","\n");
  }
  return 0;
}




Measured memory_bytes: 2076
#include<iostream>
using namespace std;
int main(){
 int n,m;
 cin >> n >> m;
 int ar[m],br[m];
 int a,b,i,j;
for(i=0;i<m;i++){
 cin >> a >> b;
 ar[i]=a;
 br[i]=b;
}
int startnum=ar[0];
int endnum=br[0];
int s=1;

for(i=1;i<m;i++){
  if(startnum<=ar[i] && endnum>=ar[i]){
   startnum=ar[i];
}
 if(endnum >=br[i] && br[i]>=startnum){
  endnum=br[i];
}
if(endnum<ar[i] || startnum>br[i]){
s=0;
}
}

if(s==0){
 cout<<s<<endl;
}else{
cout<<(endnum-startnum+1)<<endl;
}
return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int a,b,m;
    ll ans;ll yasui=1000000000000;
    int reizo_m=1000000,densi_m=1000000;
    cin >> a >> b >> m;
    vector<int>reizo(a);
    vector<int>densi(b);
    rep(i,a){
        cin >> reizo[i];
        reizo_m = min(reizo[i],reizo_m);
    }
    rep(i,b){
        cin >> densi[i];
        densi_m = min(densi[i],densi_m);
    }
   
    ll j=densi_m + reizo_m;
    rep(i,m){
        int x,y,c;
        
        ll nedan=0;

        cin >> x >> y >> c;
        nedan = reizo[x-1] + densi[y-1] - c;
        yasui = min(yasui,nedan);
        
    }
    cout << min(yasui,j) << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int D = Integer.parseInt(sc.next());
    int G = Integer.parseInt(sc.next());
    int[] p = new int[D];
    int[] c = new int[D];

    for (int i=0; i < D; i++) {
      p[i] = Integer.parseInt(sc.next());
      c[i] = Integer.parseInt(sc.next());
    }
    int min = Integer.MAX_VALUE;
    out : for(int i=0; i<Math.pow(2,D); i++){
      boolean flag[] = new boolean[D];
      Arrays.fill(flag, false);
      int sum = 0; // 点数の合計
      int num = 0;//  解いた問題の合計
      for(int j=0; j<D; j++){
        if((i>>j&1)==1){
          num = num + p[j];
          sum = sum + p[j]*(j+1)*100 + c[j];
          flag[j] = true;
        }
      }
      if(sum >= G ){
        min = Math.min(min, num);
        continue out;
      }
      // in : for(int j=D-1; j>=0; j--){
      //   if(!flag[j]){
			// 		for(int k = 1; k < p[j]-1; k++) {
			// 			sum += 100 * (j+1);
			// 			num++;
			// 			if(sum >= G) {
			// 				min = Math.min(min, num);
			// 				break in;
			// 			}
      //     }    
      //   }    
        
      // }
			in : for(int j = 0; j < D; j++) {
				if(!flag[D - 1 - j]) {
					for(int k = 0; k < p[D - 1 - j]; k++) {
						sum += 100 * (D - j);
						num++;
						if(sum >= G) {
							min = Math.min(num, min);
              break in;
					
            }
					}
				}
			}
    }
    System.out.println(min);
    return;
  }
}




Measured memory_bytes: 22736
<?php
// define('DEBUG', true);
define('DEBUG', false);

fscanf(STDIN, "%d", $N);

$TT = $AA = 1;
for ($i = 0; $i < $N; $i++) {
	fscanf(STDIN, "%d %d", $T, $A);
	if (DEBUG) {
		echo gettype($AA) . PHP_EOL;
	}

	// printf("%d %d %d %d %d %d %s\n", $TT, $T, divceil($TT, $T), $AA, $A, divceil($AA, $A), gettype(divceil($AA, $A)));

	$ratioT = divceil($TT, $T);
	$ratioA = divceil($AA, $A);
	$ratio = intval(max($ratioT, $ratioA));

	$TT = intval(omulti($T, $ratio));
	$AA = intval(omulti($A, $ratio));
	if (DEBUG) {
		echo gettype($AA) . PHP_EOL;
		echo $T . ":" . $A . " " . $TT . " " . $AA . " " . $ratio . PHP_EOL;
		printf("%d:%d %d %d %d\n", $T, $A, $TT, $AA, $ratio);
		echo PHP_EOL;
	}

}
printf("%d\n", $TT + $AA);

function omulti($a, $b) {
	$aa = str_split(strval($a));
	$bb = str_split(strval($b));
	foreach ($aa as $ka => $va) {
		foreach ($bb as $kb => $vb) {
			$res[$ka + $kb + 1] += intval($va) * intval($vb);
		}
	}
	for ($i = max(array_keys($res)); $i > 0; $i--) {
		if ($res[$i] > 9) {
			$res[$i - 1] += floor($res[$i] / 10);
			$res[$i] %= 10;
		}

	}
	ksort($res);
	return implode("", $res);
}

function divceil($dividend, $divisor) {
	return intdiv($dividend, $divisor) + ($dividend % $divisor !== 0);
}


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

typedef long long ll;

vector <int> v(10000000+100);

int main(void)
{
    ll n, i, j;
    cin >> n;

    for(i = 1; i <= n; i++)
    {
        for(j = i; j <= n; j += i)
        {
            v[j]++;
        }
    }

    ll sum = 0;
    for(i = 1; i <= n; i++)
    {
        sum += i*v[i];
    }
    cout << sum << "\n";

    return 0;
}



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

namespace kyo
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = x[0] % x[1];
            if (a == 0) { Console.WriteLine("0"); }
            else { Console.WriteLine("1"); }
        }
    }
}

Measured memory_bytes: 13396
#include<cstdio>
#include<algorithm> 
#include<cstring>
#include<cstdlib>
#include<bitset> 
#define LL long long
using namespace std;
const int N=2e3+5;
const int M=2e6+5;
bitset<M>f;
int n,sum,c,a[N];
int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)a[i]=read(),sum+=a[i];
	f[0]=1;
	for(int i=1;i<=n;i++)f|=(f<<a[i]);
	for(int i=sum/2;i>=0;i--)
		if(f[i]){c=i;break;}
	printf("%d",sum-c);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int X, Y, Z; cin >> X >> Y >> Z;
  cout << Z << " " <<  X << " " << Y << endl;
}

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 300001
#define maxl 100001

int N,Q,V[maxn],W[maxn];
int twok[maxn][10];
int dp[550][maxl];
int depth[maxn];

int curidx = 0;

void dfs(int x,int d){
	if (d == 9) return;
	
	FOR(i,0,maxl - 1){
		dp[x][i] = dp[x/2][i];
		if (W[x] <= i) dp[x][i] = max(dp[x/2][i - W[x]] + V[x],dp[x][i]);
	}
	
	dfs(x * 2 , d+1); dfs(x * 2 + 1, d + 1);
}

int main(){
	fast;
	
	cin>>N;
	
	FOR(i,1,N) cin>>V[i]>>W[i];
	cin>>Q;
	
	dfs(1,0);
	
	depth[1] = 0;
	FOR(i,2,N) depth[i] = depth[i/2] + 1;
	
	
	FOR(i,1,Q){
		int x,L; cin>>x>>L;
		
		if (depth[x] < 9) cout<<dp[x][L]<<'\n';
		else{
			vpi stuff;
			int ans = 0;
			int cur = x;
			while (depth[cur] >= 9){
				stuff.pb(pi(V[cur],W[cur]));
				cur /= 2;
			}
			
			FOR(bm,0,(1LL<<stuff.size()) - 1){
				pi res = pi(0,0);
				FOR(j,0,stuff.size() - 1) if (bm & (1LL << j)){res.f += stuff[j].f; res.s += stuff[j].s;}
				if (res.s > L) continue;
				ans = max((ll)ans,res.f + dp[cur][L - res.s]);
			}
			cout<<ans<<'\n';
		}
	}
	
	
	
}


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

int main() {
  int A,B;
  cin >>A>>B;
  
  if(A*B == 2)
    cout << 3 << endl;
  if(A*B == 3)
    cout << 2 << endl;
  if(A*B == 6)
    cout << 1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int suuji,i;
	i = 1, suuji = 1;

	while (0 <= suuji,i && suuji,i <= 10000 && suuji != 0)
	{
		scanf("%d", &suuji);

		if (0 <= suuji && suuji <= 10000 && suuji != 0)
		{
			printf("Case %d: %d\n", i, suuji);
			i++;
		}
		else
		{
			break;
		}
		
	}
	return 0;
}


Measured memory_bytes: 2032
I = "MARCH"
C = Array.new(5,0)
N = gets.to_i
N.times do
  s = gets.chomp
  i = I.index(s[0])
  C[i] += 1 if i
end
puts C.combination(3).inject(0){|s, (a,b,c)| s + a * b * c}


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

using namespace std;
using ll = long long;


const int MOD = 998244353;

class Edge{
public:
    ll from,to, value;
    Edge(int f,int t, int c){
        from = f;
        to = t;
        value = c;
    }
};

int main(){
    int N;cin >> N;
    string s;cin >> s;
    if(s.substr(0, s.size()/2) == s.substr(s.size()/2,s.size())){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e8)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<string> V(N);
    for (int n = 0; n < N; ++n) cin >> V[n];
    
    vector<vector<int>> D(N, vector<int>(N, INF));
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i == j) D[i][j] = 0;
            else if (V[i][j] == '1') D[i][j] = 1;
        }
    }
    for (int k = 0; k < N; ++k) {
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
            }
        }
    }
    int Max = 0;
    int iMax = -1, jMax = -1;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (D[i][j] != INF && D[i][j] > Max) {
                Max = D[i][j];
                iMax = i; jMax = j;
            }
        }
    }
    bool bPossible = true;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (V[i][j] == '1') {
                if (D[iMax][i] == D[iMax][j]) {
                    bPossible = false;
                }
            }
        }
    }
    if (bPossible) {
        cout << Max+1 << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}


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

using namespace std;
typedef long long ll;

ll a[210000];
ll b[210000];
ll c[210000];
ll N;

ll binary_search(ll f[], ll x, ll N){
  ll l = -1, r = N;
  while(r-l > 1){
    ll m = (l+r)/2;
    if(f[m] >= x){
      r = m;
    }
    else{
      l = m;
    }
  }
  return r;
}

int main(){
  cin >> N;
  for(ll i = 0; i < N; i++)  cin >> a[i];
  for(ll i = 0; i < N; i++)  cin >> b[i];

  ll p = 1;
  ll result = 0;
  for(ll i = 0; i < 30; i++){
    p *= 2;
    for(ll j = 0; j < N; j++){
      c[j] = b[j] % p;
    }
    sort(c, c+N);
    ll count = 0;
    for(ll j = 0; j < N; j++){
      ll x = p/2-a[j]%p;
      ll y = p-a[j]%p;
      ll z = p+p/2-a[j]%p;
      ll x_index = binary_search(c, x, N);
      ll y_index = binary_search(c, y, N);
      ll z_index = binary_search(c, z, N);
      count += (y_index-x_index)+(N-z_index);
    }
    result += (p/2)*(count%2);
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define MAX 500005
 #include<iomanip>
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define x first
 #define y second
using namespace std;
int gcd(int a, int b);
  
int power(int x, unsigned int y, unsigned int m)
{
    if (y == 0)
        return 1;
    int p = power(x, y/2, m) % m;
    p = (p * p) % m;
  
    return (y%2 == 0)? p : (x * p) % m;
}
ll modInverse(int a, int m)
{
    int g = gcd(a, m);
   
    {
        // If a and m are relatively prime, then modulo inverse
        // is a^(m-2) mode m
      
             return power(a, m-2, m);
    }
}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
//void spf(ll num)
//{
//    fore(i,0,num+1)arr[i]=i;
//    for(ll i=2;i<=num;i+=2)
//    {
//        arr[i]=2;
//    }
//    for(ll i=3;i<=num;i+=2)
//    {
//        if(arr[i]==i)
//        for(ll j=i;j<=num;j+=i)
//        {
//           if(arr[j]==j) arr[j]=i;
//        }
//    }
//}
 
 int32_t main()
{
    Need_for_speed(activated);
//    satisfy
//    {}
    ll n;cin>>n;
    if(n%2)
    {
        cout<<"0"<<endl;
    }
    else
    {
        ll a=1;
        ll count=0;ll ten=10;
        ll p=n;
        while(ten<=p)
        {
            count+=p/ten;
            ten*=5;
        }
        cout<<count<<endl;
    }
    return 0;
    }


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
 
int main()
{
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int m = max(max(a, b), c);
  int n = m;
  for(int i = 0; i < k; i++){
    n *= 2;
  }
  cout << n + a + b + c - m << endl;
}

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

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;

int main()
{

    //ifstream cin("input.txt");
    //ofstream cout("triangles.out");

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

    string s;
    cin >> s;

    for (int i = 0; i < sz(s); ++i) {
        if (s[i] == ',') {
            cout << " ";
        } else {
            cout << s[i];
        }
    }
    cout << "\n";

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class Main {
    public static void main(String[] args) throws IOException {
        try (PrintWriter writer = new PrintWriter(System.out); InputReader reader = new InputReader(System.in)) {
            String input = reader.readLine();

            List<String> allCaseList = new ArrayList<>((int)Math.pow(2, input.length() - 1));
            allCaseList.add(input);
            for (int i = 1; i < input.length(); i++) {
                ListIterator<String> iterator = allCaseList.listIterator();
                while (iterator.hasNext()) {
                    String string = iterator.next();
                    iterator.add(string.substring(0, input.length() - i) + "+" + string.substring(input.length() - i));
                }
            }

            long sum = 0;
            for (String string : allCaseList) {
                String[] a = string.split("\\+");
                for (String b : a) {
                    sum += Long.parseLong(b);
                }
            }

            System.out.println(sum);
        }
    }
}

class InputReader implements Closeable, AutoCloseable {
    private final BufferedReader br;

    InputReader(InputStream inputStream) {
        this.br = new BufferedReader(new InputStreamReader(inputStream));
    }

    String readLine() throws IOException {
        return this.br.readLine();
    }

    int readInt() throws IOException {
        return Integer.parseInt(this.br.readLine());
    }

    long readLong() throws IOException {
        return Long.parseLong(this.br.readLine());
    }

    String[] readStringsSplitByDelimiter(String delimiter) throws IOException {
        return this.br.readLine().split(delimiter);
    }

    int[] readIntsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.br.readLine().split(delimiter);

        int stringsLength = strings.length;
        int[] ints = new int[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }

        return ints;
    }

    long[] readLongsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.br.readLine().split(delimiter);

        int stringsLength = strings.length;
        long[] longs = new long[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            longs[i] = Long.parseLong(strings[i]);
        }

        return longs;
    }

    @Override
    public void close() throws IOException {
        br.close();
    }
}

Measured memory_bytes: 23124
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

# define INF 0x3f3f3f3f

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

int a[100010] = {};

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

  int N, x;
  cin >> N >> x;
  REP(i, N) {
    cin >> a[i];
  }
  ll ans = 0;
  if (a[0] > x) {
    ans += a[0] - x;
    a[0] = x;
  }
  REP(i, N - 1) {
    if (a[i] + a[i + 1] > x) {
      int diff = a[i] + a[i + 1] - x;
      ans += diff;
      a[i + 1] -= diff;
    }
  }

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


Measured memory_bytes: 640
import java.util.Scanner;

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

    long p = ((long)a*(long)b);
    long ans = p/gcd(a,b);
    System.out.println(ans);
  }

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

Measured memory_bytes: 24276