akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
namespace IO{
    const int SIZE = (1 << 20) + 1;
    char ibuf[SIZE], *iS, *iT, obuf[SIZE],*oS = obuf, *oT = obuf + SIZE - 1;
    char _st[55];
    int _qr = 0;
    inline char gc(){
        return (iS == iT ? iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS++) : *iS++);
    }
    inline void qread(){}
    template<class T1, class ...T2>
    inline void qread(T1 &IEE, T2&... ls){
        register T1 __ = 0, ___ = 1;
        register char ch;
        while(!isdigit(ch = gc())) ___ = (ch == '-') ? -___ : ___;
        do{
            __ = (__ << 1) + (__ << 3) + (ch ^ 48);
        }while(isdigit(ch = gc()));
        __ *= ___;
        IEE = __;
        qread(ls...);
        return ;
    }
    inline void flush(){
        fwrite(obuf, 1, oS - obuf, stdout);
        oS = obuf;
        return ;
    }
    inline void putc_(char _x){
        *oS++ = _x;
        if(oS == oT) flush();
    }
    inline void qwrite(){}
    template<class T1, class ...T2>
    inline void qwrite(T1 IEE, T2... ls){
        if(!IEE) putc_('0');
        if(IEE < 0) putc_('-'), IEE = -IEE;
        while(IEE) _st[++_qr] = IEE % 10 + '0', IEE /= 10;
        while(_qr) putc_(_st[_qr--]);
        qwrite(ls...);
        return ;
    }
    struct Flusher_{~Flusher_(){flush();}}io_flusher;
}
using namespace IO;
ll x, cur;
char ch[maxn];
ll mod(ll x){
    return x % 26 == 0 ? 26 : x % 26;
}
int main(){
    cin >> x;
    while(x){
        ch[++cur] = (char)(mod(x) - 1 + 'a');
        x = (x - mod(x)) / 26;
    }
    for(int i = cur;i >= 1;i--){
        cout << ch[i];
    }
    puts("");
    return 0;
}

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

	public static void main(String[] args) {
		Scanner seer = new Scanner(System.in);
		int a = seer.nextInt();
		int b = seer.nextInt();
		int c = seer.nextInt();
		System.out.println(Integer.min(Integer.min(a+b, b+c), c+a));
	}

}


Measured memory_bytes: 23764
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#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>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

#define ll long long
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}


ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int N, K;
vector<int> D;

bool J(int x){
  int X = x;
  while(X > 0){
    int a = X % 10;
    X /= 10;
    rep(i, D.size()){
      if(a == D[i]) return 0;
    }
  }
  return 1;
}

int main(){
  cin >> N >> K;
  D.resize(K);
  rep(i, K) cin >> D[i];
  for(int i = N;;i++){
    if(J(i)){
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1e9+7;
ll B,W,inv[200005],f[200005],p[200005],w[200005],b[200005];
ll C(ll n,ll m)
{
    ll ans=f[n]*inv[n-m]%mod*inv[m]%mod;
    return ans;
}
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
int main()
{
    scanf("%lld%lld",&B,&W);
    f[0]=1;inv[0]=1;
    for(int i=1;i<=B+W;i++)
        f[i]=f[i-1]*i%mod,inv[i]=qpow(f[i],mod-2);
    p[0]=1;
    for(int i=1;i<=B+W;i++)
        p[i]=p[i-1]*(mod-mod/2)%mod;
    for(int i=B;i<B+W;i++)
        b[i]=p[i]*C(i-1,i-B)%mod;
    for(int i=W;i<B+W;i++)
        w[i]=p[i]*C(i-1,i-W)%mod;
    for(int i=1;i<=B+W;i++)
    {
        w[i]=(w[i]+w[i-1])%mod;
        b[i]=(b[i]+b[i-1])%mod;
    }
    for(int i=1;i<=B+W;i++)
    {
        ll ans=w[i-1]+(1-w[i-1]-b[i-1])*(i==B+W?1:(mod-mod/2))%mod;
        printf("%lld\n",(ans%mod+mod)%mod);
    }
}


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

using namespace std;
long long a[100005];
int main(){
	long long n;
	cin>>n;
	long long mn=1e9;
	long long ans=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]<=0)ans++;
		mn=min(mn,abs(a[i]));
	}
	long long ans2=0;
	for(int i=0;i<n;i++)ans2+=abs(a[i]);
	if(ans%2!=0){
		ans2-=2*(mn);
	}
	cout<<ans2<<endl;
	return 0;
}

Measured memory_bytes: 1024
list = [int(input()) for i in range(5)]
k = int(input())
n=False

for i in range(5):
    for j in range(5):
        if(abs(list[i] - list[j]) > k):
            print(":(")
            n=True
            break
    if n:
        break

if not n:
    print("Yay!")


Measured memory_bytes: 3060
class Array
  def gcd
    inject(:gcd)
  end
end
n, x = gets.chomp.split(" ").map(&:to_i)
spots = gets.chomp.split(" ").map(&:to_i)
abss = []
spots.each do |spot|
  abss << (spot - x).abs
end
abss.uniq!
puts abss.gcd


Measured memory_bytes: 16516
#include <iostream>

using namespace std;

int main(void)
{
  int k,n,i,max,ans;
  cin>>k>>n;
  int a[200000];
  
  for(i=0;i<n;i++){cin>>a[i];}
   
  int b[200000];
 for(i=0;i<n-1;i++){b[i]=a[i+1]-a[i];}
  b[n-1]=a[0]+k-a[n-1];
  max=0;
for(i=0;i<n;i++) {if(b[i]>max)max=b[i];}
  ans=k-max;
  cout<<ans<<endl;
	return 0;

}

Measured memory_bytes: 5168
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

fn main() {
    let n: usize = read!();
    let k: usize = read!();
    let mut p = Vec::with_capacity(n);
    for _ in 0..n {
        let pi: usize = read!();
        p.push(pi);
    }
    p.sort();
    println!("{}", p.iter().take(k).sum::<usize>());
}


Measured memory_bytes: 2188
#include <vector>
#include <functional>

using namespace std;

template<typename T>
class SegmentTree
{
    int n;
    function<T(T,T)> op;
    vector<T> V;

    T q(int l, int r)
    {
        if (l >= r)
            return V[0];
        T a = q((l+1)/2, r/2);
        if (l%2 != 0)
            a = op(a, V[l]);
        if (r%2 != 0)
            a = op(a, V[r-1]);
        return a;
    }

public:
    SegmentTree(int n_, function<T(T,T)> op, T init):
        op(op)
    {
        n = 1;
        while (n < n_)
            n *= 2;
        V = vector<T>(2*n, init);
        for (int i=n-1; i>0; i--)
            V[i] = op(V[i*2], V[i*2+1]);
    }

    T get(int p) const
    {
        return V[p+n];
    }

    void set(int p, T v)
    {
        p += n;
        V[p] = v;
        for (p/=2; p>0; p/=2)
            V[p] = op(V[p*2], V[p*2+1]);
    }

    //  init OP v[l] OP v[l+1] OP ... OP v[r-1]
    T query(int l, int r)
    {
        return q(l+n, r+n);
    }
};
#include <iostream>
#include <algorithm>

int main()
{
    int H, W, M;
    cin>>H>>W>>M;
    vector<int> h(M), w(M);
    for (int i=0; i<M; i++)
    {
        cin>>h[i]>>w[i];
        h[i]--, w[i]--;
    }

    vector<vector<int>> B(H);
    for (int i=0; i<M; i++)
        B[h[i]].push_back(w[i]);

    SegmentTree<int> ST(W, [&](int x, int y){return max(x, y);}, 0);
    for (int i=0; i<M; i++)
        ST.set(w[i], ST.get(w[i])+1);

    int ans = 0;
    for (int y=0; y<H; y++)
    {
        for (int x: B[y])
            ST.set(x, ST.get(x)-1);

        ans = max(ans, (int)B[y].size()+ST.query(0, W));

        for (int x: B[y])
            ST.set(x, ST.get(x)+1);
    }

    cout<<ans<<endl;
}


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

int main(){
	int n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	int lr = 0;
	int rl = 0;
	int ret = 0;
	for(int i=1; i<n; i++){
		if(s[i-1]==s[i]) ret++;
		else{
			if(s[i]=='R') lr++;
			else rl++;
		}
	}
	int two = min(lr,rl);
	if(k>=two){
		ret+=2*two;
		k-=two;
		int left = max(lr,rl)-two;
		ret+=min(left,k);
	}
	else ret+=2*k;
	cout<<ret;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 998244353
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}

int main(){
    while (true){
        ll n,x,ans=0;
        cin >> n >> x;
        if (n==0 and x==0)break;
        for (ll i=1;i<=n-2;i++){
            for (ll j=i+1;j<=n-1;j++){
                for (ll k=j+1;k<=n;k++){
                    if (i+j+k==x){
                        ans++;
                        break;
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}    



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  int i,f=0;
  cin>>s;
  for(auto it:s)
  {
    if(it=='7')
      	f=1;
  }
  if(f)
    cout<<"Yes";
 else
   cout<<"No";
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const int MAX_N = 100000;
ll fact[MAX_N + 1];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll ans;
    fact[0] = 0;
    fact[1] = 1;
    ll fs = 1;
    for (int i = 2; i < MAX_N + 1; i++){
        fs = (fs*i) % MOD;
        fact[i] = (fact[i-1] + fs) % MOD;
    }
    while (1){
        int N, R;
        cin >> N;
        if (N == 0) break;
        vector<int> word(N);
        for (int i = 0; i < N; i++) word[i] = i;
        word.push_back(0);
        ans = 0;
        cin >> R;
        vector<int> s(2*R+2, 0);
        s[2 * R + 1] = N;
        for (int i = 0; i < R; i++){
            cin >> s[i] >> s[i+R];
            s[i]--; s[i+R]--;
            s.push_back(s[i] + 1);
            s.push_back(s[i+R] + 1);
            swap(word[s[i]], word[s[i+R]]);
        }
        sort(s.begin(), s.end());
        s.erase(unique(s.begin(), s.end()), s.end());
        for (int i = 0, R = s.size() - 1; i < R; i++){
            ans =(ans + word[s[i]] * (fact[N - s[i] - 1] - fact[N - s[i+1] - 1])) % MOD;
            int dif = s[i+1] - s[i];
            for (int j = i + 1; j < R; j++){
                word[s[j]] -= (word[s[j]] > word[s[i]] ? dif : 0);
            }
        }
        cout << (ans + MOD) % MOD << endl;
    }
    return 0;
}

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

int main(){
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);

  int sum = 0;
  int count = 0;
  
  for(int i = 0; i < M; i++){
    int val;
    cin >> val;
    B[i] = val;
  }

  for(int i = 0; i < N; i++){
    sum = 0;                                          //初期化
    for(int j = 0; j < M; j++){
      int val;
      cin >> val;
      sum += val * B[j];
    }
    if(sum + C > 0)
      count++;
  }

  cout << count << endl;
  return 0;

}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)

n = int(input())
edges = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)
clst = list(map(int, input().split()))
clst.sort(reverse = True)
ans = [0 for _ in range(n)]
ind = 0
total = 0
def dfs(pos, b_pos, b_num):
    global ind, total
    ans[pos] = clst[ind]
    total += min(ans[pos], b_num)
    ind += 1
    for n_pos in edges[pos]:
        if n_pos == b_pos:
            continue
        dfs(n_pos, pos, ans[pos])
        
dfs(0, -1, 0)
print(total)
print(*ans)

Measured memory_bytes: 19656
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ba = sorted((y, x) for x, y in zip(a, b))
a = [x for y, x in ba]
b = [y for y, x in ba]

# print(a)
# print(b) 

ap = sorted((x, i) for i, x in enumerate(a))

# print(ap) 
if any(ap[i][0] > b[i] for i in range(n)):
    print('No')
    exit()
if any(ap[i + 1][0] <= b[i] for i in range(n - 1)):
    print('Yes')
    exit()

rep = [ap[i][1] for i in range(n)]
p = 0
c = 0
while True:
    c += 1
    p = rep[p]
    if p == 0:
        break
print(['No', 'Yes'][c != n])

Measured memory_bytes: 29672
N = int(input())
W = list(map(int, input().split()))

sum1 = sum(W)
sum2 = 0

result = sum1
for w in W:
    # 差の正負が逆になるときが差の絶対値の最小値になる
    if sum1 - sum2 - w * 2 <= 0:
        result = sum1 - sum2
        if result > -(sum1 - sum2 - w * 2):
            result = sum1 - sum2 - w * 2
        break
    sum1 -= w
    sum2 += w

if result < 0:
    result = -result
print(result)


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define long long long
#define ull unsigned long long
#define up(i,a,b) for (int i=a; i<=b; i++)
#define upadj(i,adj) if (adj.size()>0) up(i,0,adj.size()-1)
#define down(i,a,b) for (int i=a; i>=b; i--)
#define endl '\n'
#define pb push_back
#define X first
#define Y second
#define II pair<int, int>
#define III pair<int, pair<int, int> >
#define V vector
#define debug(X) cerr<< #X << "=" <<X << endl
#define show(X,a,b) {cerr << #X << " = "; up(__,a,b) cerr << X[__] << ' '; cerr << endl;}
#define gc getchar
#define pc putchar
using namespace std;

inline void read(int &x)
{
    register int c = gc();
    x = 0;
    int neg = 0;
    for (;((c<48 || c>57) && c != '-') ;c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}
inline void writeln(int x){

         char buffor[21];
         register int i=0;
         int neg=0; if (x<0) {neg=1; x= -x;}
         do{
               buffor[i++]=(x%10)+'0';
               x/=10;
            } while(x);
           i--;
           if (neg) pc('-');
           while(i>=0) pc(buffor[i--]);
           pc('\n');
       }
const int N= (int) 1e5+10;
int n,a[N];
V<II> g;
void input()
{
    cin>>n;
    up(i,1,n) cin>>a[i];

}

void solve()
{
    sort(a+1,a+1+n);
    a[0]= -1;
    up(i,1,n)
     if (a[i]!= a[i-1])
     {
         int j= i;
         while (j<=n and a[j]== a[i]) j++;
         g.pb(II(a[i],j-i) );
     }

        int res=0;

        up(i,0,(int)g.size()-1)
        {
            int r=g[i].Y;
            if (i>0 and g[i].X== g[i-1].X+1) r+= g[i-1].Y;
            if (i< g.size()-1 and g[i].X+1== g[i+1].X) r+= g[i+1].Y;
            res= max(res,r);
        }

        cout<<res;


}

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

    #ifdef I_Love_Pork
    #define TASK "tmp"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
    #endif

    input();
    solve();

    return 0;
}


Measured memory_bytes: 1276
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(true){
            int x= scanner.nextInt();
            int y= scanner.nextInt();
            if( x==0&&y==0) break;
             if(x<y){System.out.println(x +" "+y);}
             else{System.out.println(y +" "+x);}
        }
    }
}

Measured memory_bytes: 35424
def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

N = int(input())
N *= 2

def crt(a, n, b, m, inv):
    out = a
    #inv = pow(n, -1, m)
    out += (b - a) * n * inv
    return out % (n * m)

p = []

i = 2
while i * i <= N:
    curr = 1
    while N % i == 0:
        N//= i
        curr *= i
    if curr != 1:
        p.append(curr)
    i += 1
    
if N != 1:
    p.append(N)

poss = [0]
mod = 1
for v in p:
    new = []
    #inv = pow(mod, -1, v)
    inv = modinv(mod, v)
    for u in poss:
        new.append(crt(u, mod, 0, v, inv))
        new.append(crt(u, mod, -1, v, inv))
    poss = new
    mod *= v
poss.sort()
poss += [mod]
print(poss[1])

Measured memory_bytes: 68352
def gcd(a,b):
    r = a%b
    if r == 0:
        return b
    else:
        return gcd(b,r)

def lcm(a,b):
    return (a*b) // gcd(a,b)

A, B, C, D = map(int, input().split())

a1 = -(-A // C)
a2 = -(-A // D)
a3 = -(-A // lcm(C,D))

b1 = B // C
b2 = B // D
b3 = B // (lcm(C,D))

ans = (B-A+1) - ((b1-a1+1) + (b2-a2+1) - (b3-a3+1))
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <complex>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <sstream>
#include <numeric>
#include <functional>
#include <bitset>
#include <iomanip>

using namespace std;

// INF
#define IINF (INT_MAX/2)
#define INF (1<<29)

// math
#define SQ(x) ((x)*(x))

// container utility
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair
#define PB push_back
#define EACH(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)

// rep
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define rep(i,n) REP(i,0,n)

// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;

typedef long long ll;

// conversion
template<class T> inline string toStr(T a) { ostringstream oss; oss << a; return oss.str(); }
inline int toInt(string s) { return atoi(s.c_str()); }

// prime
bool isPrime(int a) { for(int i=2; i*i <=a; i++) if(a%i == 0) return false; return true; }

// dx, dy
int const dx[] = {-1,0,1,0,-1,1,1,-1};
int const dy[] = {0,-1,0,1,-1,-1,1,1};

// inRange
inline bool inRange(int x, int y, int W, int H) {
  return 0<=x && x<W && 0<=y && y<H;
}

// isPalindrome
inline bool isPalindrome(string s) {
  return equal(s.begin(), s.end(), s.rbegin());
}

int check(char grid[2][2]) {
  if(grid[0][0] == '#'
     && grid[0][1] == '.'
     && grid[1][0] == '.'
     && grid[1][1] == '.') {
    return +1;
  }
  
  if(grid[0][0] == '.'
     && grid[0][1] == '#'
     && grid[1][0] == '#'
     && grid[1][1] == '#'
  ) {
    return +1;
  }
  
  if(grid[0][0] == '#'
     && grid[0][1] == '#'
     && grid[1][0] == '#'
     && grid[1][1] == '.'
  ) {
    return -1;
  }

  if(grid[0][0] == '.'
     && grid[0][1] == '.'
     && grid[1][0] == '.'
     && grid[1][1] == '#'
  ) {
    return -1;
  }
  
  return 0;
}

int main() {
  
  int H, W;
  while(cin >> H >> W) {
    H+=2, W+=2;
    vector<vector<char>> G(H, vector<char>(W, '.'));
    REP(i, 1, H-1) {
      REP(j, 1, W-1) {
        cin >> G[i][j];
      }
    }
    
    vector<pair<double, int>> event;
    
    // rep(i, H) {rep(j, W) {cout << G[i][j];}cout << endl;}
    
    rep(i, H-1) {
      rep(j, W-1) {
        
        char grid[2][2];
        grid[0][0] = G[i][j];
        grid[0][1] = G[i][j+1];
        grid[1][0] = G[i+1][j];
        grid[1][1] = G[i+1][j+1];
        
        int num = check(grid);
        if(num!=0) {
          double ang = atan2((H-2)-i, j);
          event.PB(MP(atan2((H-2)-i, j), num));
        }
        
      }
    }
    
    sort(ALL(event));
    
    int mx = 2;
    int cnt = 1;
    for(auto e : event) {
      cnt += e.second;
      mx = max(mx, cnt);
    }
    cout << mx << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3580
#include<stdio.h>

int main(void){
	int H, W;
	int i, j;
	while(1){
		scanf("%d %d", &H, &W);
		if(H == 0 && W == 0) break;
		for(i=0; i<H; i++){
			for(j=0; j<W; j++){
				if(i%2 == 1){
					if(j%2 == 1) printf("#");
					else printf(".");
				}else{
					if(j%2 == 1) printf(".");
					else printf("#");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define infy 2e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
const int N = five;
ll dp[N][102][2];
int a[N];
int d;
int n;
ll f(int i,int j,int k)
{
       if(i==n){return (j==0);}
       if(dp[i][j][k] != -1){return dp[i][j][k];}
       dp[i][j][k] = 0;
       if(k==1){
              fri(l,0,a[i]){
                     dp[i][j][k] += f(i+1,((j-l)%d+d)%d,0);
                     dp[i][j][k] %= mod;
              }
              dp[i][j][k] += f(i+1,((j-a[i])%d+d)%d,1);
       }
       else{
              fri(l,0,10){
                     dp[i][j][k] += f(i+1,((j-l)%d+d)%d,0);
                     dp[i][j][k] %= mod;
              }
       }
       return dp[i][j][k];
}
int main()
{
       memset(dp,-1,sizeof dp);
       string s;
       cin>>s;
       n = s.size();
       fri(i,0,n){
              a[i] = s[i]-'0';
       }
       cin>>d;
       ll ans = 0;
       fri(i,0,a[0]){
              //cout<<i<<" "<<f(1,((-i%d)+d)%d,0)<<endl;
              ans += f(1,((-i%d)+d)%d,0);

              ans %= mod;
       }
       int i = a[0];
       ans += f(1,((-i%d)+d)%d,1);
       //cout<<ans<<endl;
       ans %= mod;
       cout<<(ans+mod-1)%mod<<endl;
}


Measured memory_bytes: 160640
#!/usr/bin/env python
# coding: utf-8

def main():
    import sys
    #raw = ["2 5", "2 3"]
    raw = [sys.stdin.readline(),
           sys.stdin.readline()]
    N, K = map(int, raw[0].split())
    xs = list(map(int, raw[1].split()))

    M = K + 1
    memo = [False] * M

    for i in range(1, M):
        for j in range(N):
            if i >= xs[j]:
                memo[i] |= not memo[i - xs[j]]

    if memo[K]:
        print("First")
    else:
        print("Second")

    #print(" ".join(map(str, memo)))

main()


Measured memory_bytes: 3828
#import collections as c
#ip = lambda : map(int, input().split())

#################
N = int(input())
b = []
for n,i in enumerate(input().split()):
    b.append(n+1 - int(i))
r = []

for i in range(N):
    for j in range(len(b)):
        if b[-1-j] == 0:
            r.insert(0,len(b)-j)
            del b[-1-j]
            break
        else:
            b[-1-j] -= 1

        if j==len(b)-1:
            print(-1)
            exit()

for i in r:
    print(i)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>

using namespace std;

vector<int> F;
vector<int> L;
vector<bool> seen;

void dfs(vector<vector<int>> &G,int v,int &t){
    F[v]=t++;

    seen[v]=true;

    for(int i=0;i<G[v].size();i++){
        if(seen[G[v][i]])continue;
        dfs(G,G[v][i],t);
    }

    L[v] = t++; 
}

int main(){

    int n;
    cin >> n;

    vector<vector<int>> G(n);

    for(int i=0;i<n;i++){
        int a,k;
        cin >> a >> k;
        for(int j=0;j<k;j++){
            int b;
            cin >>b;
            G[i].push_back(b-1);
        }
    }

    seen.assign(n,false);
    F.resize(n);
    L.resize(n);
    int t=1;
    
    

    for(int i=0;i<n;i++){
        if(!seen[i])dfs(G,i,t);
        cout << i+1 << " " << F[i] << " " << L[i] << endl;
    }

    return 0;




}


Measured memory_bytes: 3144
import Control.Monad
import Data.List
import Data.Ord
import qualified Data.ByteString.Char8 as B
import qualified Data.IntMap as M
import qualified Data.Vector.Storable as V

main=do
    n<-readLn::IO Int
    as<-sort.map (\(i,a)->a-i).zip [1..].unfoldr (B.readInt.B.dropWhile(==' ')) <$> B.getLine::IO[Int]
    let n = as !! (length as `div` 2)
    print $ sum $ map (\a->abs $ a-n) as


Measured memory_bytes: 32124
#include <bits/stdc++.h>
using namespace std;
#define LL long long

void work()
{
    int a[3];
    for(int i = 0; i < 3; i++) cin >>a[i];

    sort(a, a + 3);
    int res = 10 * a[2] + a[1] + a[0];
    cout <<res <<endl;
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
    work();
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, p = map(int, input().split())
    A = list(map(int, input().split()))
    odd = len([a for a in A if a % 2 != 0])
    even = len([a for a in A if a % 2 == 0])

    # 奇数のビスケットが入った袋を偶数個(０を除く）選ぶパターン
    tot_odd = 0
    for i in range(2, odd + 1, 2):
        bunbo = 1
        bunsi = 1
        for j in range(1, i + 1):
            bunbo *= (odd - j + 1)
            bunsi *= j
        cmb = bunbo // bunsi
        tot_odd += cmb

    # 偶数のビスケットが入った袋を選ぶパターン
    tot_even = 0
    for i in range(even + 1):
        if i == 0:
            tot_even += 1
            continue
        bunbo = 1
        bunsi = 1
        for j in range(1, i + 1):
            bunbo *= (even - j + 1)
            bunsi *= j
        cmb = bunbo // bunsi
        tot_even += cmb

    even_pattern = tot_odd * tot_even + tot_even
    odd_pattern = 2 ** n - even_pattern
    print(even_pattern if p == 0 else odd_pattern)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
x = gets.chomp.to_i
ans = (x/11) * 2
if x % 11 == 0 then
    puts ans
    exit
end
if x/11 > 0 then
    x %= 11
    x -= 6
    ans += 1
    if x > 0 then
        x -= 5
        ans += 1
    end
else
    x -= 6
    ans += 1
    if x > 0 then
        x -= 5
        ans += 1
    end
end
puts ans

Measured memory_bytes: 14356
def honest_or_unkind_2(N: int, testimonies: dict)->int:
    ans = 0
    for i in range(1 << N):
        honest_num = 0
        for j in range(N):
            if i & (1 << j) == 0:
                continue
            honest_num += 1

            # 正直者の場合はその人の証言が全て正しいことをチェックする
            for k, is_honest in testimonies[j]:
                if bool(i & (1 << k)) != is_honest:
                    # 証言の矛盾
                    break
            else:
                # 証言に矛盾なし。次の人をチェック
                continue
            # 証言に矛盾があった
            break
        else:
            # 正直者全員の証言に矛盾なし。この組み合わせは成り立つ。
            ans = max(ans, honest_num)
        # i の表す正直者と嘘つきの組み合わせは証言に矛盾がある

    return ans


if __name__ == "__main__":
    N = int(input())
    testimonies = {}

    for i in range(N):
        A = int(input())
        testimonies[i] = [None] * A
        for a in range(A):
            x, y = map(int, input().split())
            testimonies[i][a] = (x-1, bool(y))

    ans = honest_or_unkind_2(N, testimonies)
    print(ans)


Measured memory_bytes: 3064
n, k = map(int, input().split())
A = list(map(int, input().split()))
array = {}
ans = 0

for a in A:
    if a in array.keys():
        array[a] += 1
    else:
        array[a] = 1

array = sorted(array.values())

if len(set(A)) > k:
    num = len(array) - k
    for i in range(num):
        ans += array[i]

print(ans)


Measured memory_bytes: 32184
fun main(args: Array<String>){
	val ina = readLine()!!.split(" ")
	val inb = readLine()!!.split(" ")
	val inc = readLine()!!.split(" ")
	var list = mutableListOf<Int>()

	list.add(ina[0].toInt())
	list.add(ina[1].toInt())
	list.add(inb[0].toInt())
	list.add(inb[1].toInt())
	list.add(inc[0].toInt())
	list.add(inc[1].toInt())

	var co1 = 0
	var co2 = 0
	var co3 = 0
	var co4 = 0

	for(i in 0..5){
		when(list[i]){
			1-> co1++
			2-> co2++
			3-> co3++
			4-> co4++
		}
	}

	if(co1 > 2 || co2 > 2 || co3 > 2 || co4 > 2){
		println("NO")
	}
	else{
		println("YES")
	}
}


Measured memory_bytes: 37940
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H, W;
  cin >> H >> W;
  while (H != 0 || W != 0) {
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (i == 0 || j == 0 || i == H - 1 || j == W - 1) {
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
    cin >> H >> W;
  }
  return 0;
}



Measured memory_bytes: 3096
class Twelvefold(): #n <= 1000程度
    def __init__(self, n, mod):
        self.mod = mod
        self.fct = [0 for _ in range(n + 1)]
        self.inv = [0 for _ in range(n + 1)]
        self.stl = [[0 for j in range(n + 1)] for i in range(n + 1)]
        self.bel = [[0 for j in range(n + 1)] for i in range(n + 1)]
        self.prt = [[0 for j in range(n + 1)] for i in range(n + 1)]
        self.fct[0] = 1
        self.inv[0] = 1
        self.stl[0][0] = 1
        self.bel[0][0] = 1
        for i in range(n):
            self.fct[i + 1] = self.fct[i] * (i + 1) % mod
        self.inv[n] = pow(self.fct[n], mod - 2, mod)
        for i in range(n)[::-1]:
            self.inv[i] = self.inv[i + 1] * (i + 1) % mod
        for i in range(n):
            for j in range(n):
                self.stl[i + 1][j + 1] = self.stl[i][j] + (j + 1) * self.stl[i][j + 1]
                self.stl[i + 1][j + 1] %= mod
        for i in range(n):
            for j in range(n):
                self.bel[i + 1][j + 1] = self.bel[i + 1][j] + self.stl[i + 1][j + 1] % mod
                self.bel[i + 1][j + 1] %= mod
        for j in range(n):
            self.prt[0][j] = 1
        for i in range(n):
            for j in range(n):
                if i - j >= 0:
                    self.prt[i + 1][j + 1] = self.prt[i + 1][j] + self.prt[i - j][j + 1]
                else:
                    self.prt[i + 1][j + 1] = self.prt[i + 1][j]
                self.prt[i + 1][j + 1] %= mod

    def solve(self, element, subset, equate_element=False, equate_subset=False, less_than_1=False, more_than_1=False):
        assert not less_than_1 or not more_than_1
        n = element
        k = subset
        a = equate_element
        b = equate_subset
        c = less_than_1
        d = more_than_1
        id = a * 3 + b * 6 + c + d * 2
        tw = [self.tw1, self.tw2, self.tw3, self.tw4, self.tw5, self.tw6, self.tw7, self.tw8, self.tw9, self.tw10, self.tw11, self.tw12]
        return tw[id](n, k)

    def tw1(self, n, k):
        return pow(k, n, self.mod)

    def tw2(self, n, k):
        if k - n < 0: return 0
        return self.fct[k] * self.inv[k - n] % self.mod

    def tw3(self, n, k):
        return self.stl[n][k] * self.fct[k] % self.mod

    def tw4(self, n, k):
        if k == 0: return 0
        return self.fct[n + k - 1] * self.inv[n] * self.inv[k - 1] % self.mod

    def tw5(self, n, k):
        if k - n < 0: return 0
        return self.fct[k] * self.inv[n] * self.inv[k - n] % self.mod

    def tw6(self, n, k):
        if n - k < 0 or k == 0: return 0
        return self.fct[n - 1] * self.inv[k - 1] * self.inv[n - k]

    def tw7(self, n, k):
        return self.bel[n][k]

    def tw8(self, n, k):
        if k - n < 0: return 0
        return 1

    def tw9(self, n, k):
        return self.stl[n][k]

    def tw10(self, n, k):
        return self.prt[n][k]

    def tw11(self, n, k):
        if k - n < 0: return 0
        return 1

    def tw12(self, n, k):
        if n - k < 0: return 0
        return self.prt[n - k][k]

n, k = map(int, input().split())
t = Twelvefold(1000, 10**9 + 7)
print(t.solve(n, k, 0, 0, 0, 1))


Measured memory_bytes: 110660
package main

import "fmt"

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)

	if k < a {
		a -= k
	} else if k > a+b {
		a, b = 0, 0
	} else {
		k -= a
		a = 0
		b -= k
	}

	fmt.Println(a, b)
}


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

using namespace std;

const long long mo = 998244353;
const int maxi = 310;
long long dp[maxi][maxi][610];
int n, k;
string s;
int a[maxi];
int suf[maxi];
int main()
{
    cin>>s>>k;

    n = s.size();
    s = '#' + s;
    int zero = 0;
    int ones = 0;

    for (int i = 1;i<=n;i++)
        if (s[i] == '1') ones++; else
    {
        a[++zero] = ones;
        ones = 0;
    }

    a[zero + 1] = ones;

    suf[zero+1] = a[zero + 1];

    for (int i = zero;i>0;i--)
        suf[i] = suf[i+1] + a[i];

    k = min(k, n - zero);

    dp[0][0][0] = 1;


    for (int i = 1;i<=zero + 1;i++) //current group
        for (int j = 0; j<=k;j++) //performed operations
          for (int l = 0; l<=min(j, suf[i+1]); l++) //operations from suffix
          for (int w = -min(a[i], j); w<=l;w++){
                int o = max(0, w);
                dp[i][j][l]+=dp[i-1][j - o][l-w];
                if (dp[i][j][l]>=mo) dp[i][j][l]-=mo;
          }

   long long ans = 0;

   for (int i = 0;i <=k;i++)
   {
       ans+=dp[zero+1][i][0];
       if (ans>=mo) ans-=mo;
   }

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


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

using namespace std;

#define ll long long int
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<ll>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.14159265
#define pb push_back
#define bits(n) __builtin_popcount(n)

void solve()
{
    int n;
    cin>>n;
    cout<<ceil(n/2.0);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t=1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3800
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

ll Max=-1000000000,Min=1e9+1;
       
int main(){
    int b,x=0,y=0,z=0,n,m,h,k,w,sum=0,ans=0;
    string s[50],t[50];
    bool f=true;
    cin >> n >> m;
    rep(i,n){
        cin >> s[i];
    }
    rep(i,m){
        cin >> t[i];
    }

    for(int i=0; i<=n-m; i++){
        for(int j=0;j<=n-m; j++){
            int x = i;
            for(int k=0;k<m;k++){
                if(t[k] != s[x].substr(j,m)){
                    break;
                }
                else if (k==m-1){
                    cout << "Yes" << endl;
                    return 0;
                }
                x++;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void) {                                                                
    char *rank[] = {"AAA", "AA", "A", "B", "C", "D", "E", "NA"};                
    double time500[] = {35.5, 37.5, 40.0, 43.0, 50.0, 55.0, 70};                
    double time1000[] = {71.0, 77.0, 83.0, 89.0, 105.0, 116.0, 148.0};          
    double t500, t1000;                                                         
                                                                                
    while (scanf("%lf%lf", &t500, &t1000) !=EOF) {                              
        int i, j;                                                               
        for (i = 0; i < sizeof(time500) / sizeof(double); i++) {                
            if (t500 < time500[i] && t1000 < time1000[i])                       
                break;                                                          
        }                                                                       
        printf("%s\n", rank[i]);                                                
    }                                                                           
    return 0;                                                                   
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, h, m, i, j, a[101];
string s;
queue<int> hi,mi;
int main(){
	cin >> n >> s;
	for(i=0;i<n;i++){
		if(s[i]=='('){
			hi.push(i);
		}else{
			mi.push(i);
		}
	}
	while(!hi.empty()||!mi.empty()){
		if(hi.empty()==1){
			while(!mi.empty()){
				mi.pop();
				h++;
			}
		}else if(mi.empty()==1){
			while(!hi.empty()){
				hi.pop();
				m++;
			}
		}else if(mi.front()<hi.front()){
			h++;
			mi.pop();
		}else if(mi.front()>hi.front()){
			mi.pop();
			hi.pop();
		}
	}

	for(i=0;i<h;i++){
		cout << '(' ;
	}

	cout << s ;

	for(i=0;i<m;i++){
		cout << ')' ;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

ll gcd(ll a, ll b) {
  if(a<b) swap(a,b);
  ll c = -1;
  while(c != 0){
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}

ll lcm(ll a,ll b) {
  return a / gcd(a,b) * b;
}
  
int main() {
  ll A,B;
  cin >> A >> B;
  cout << lcm(A,B) << endl;
  return 0;
}

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


int main(){
    string s; cin>>s;
    rep(i,8){
        ll tmp=s[0]-'0';
        rep(j,3){
            if(i>>j & 1) tmp+=s[j+1]-'0';
            else tmp-=s[j+1]-'0';
        }
        if(tmp==7){
            cout<<s[0];
            rep(j,3){
                if(i>>j & 1) cout<<'+';
                else cout<<'-';
                cout<<s[j+1];
            }
            cout<<"=7"<<endl;
            return 0;
        }
    }
    return 0;
}

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

int main(){
  string st;
  int ans,half;
  cin >> st;

  //cout << st.size() << endl;

  //iでサイズを1つずつ下げる
  for(int i = st.size(); i > 0;){
    int flg = 0;
    i -= 2;
    half = i/2;

    for(int j = 0; j < half; j++){
      if(st[j] != st[half+j]) flg = 1;
      //cout << st[j] << ' ' << st[half+j] << endl;
    }
    if(flg == 0){
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define endl '\n'
#define mod 998244353
#define pi 3.14159265358979323846
#define rep(i,a,b) for(int i=a;i<b;i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define inf INT_MAX
#define maxx 2*100000 + 5

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



    int n;
    cin >> n;

    int a = (n/500)*1000;
    n = n - 500*(n/500);
    a += (n/5)*5;

    cout << a;

    return 0;
}

 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include <iomanip>
#include <bits/stdc++.h>
#include <fstream>
#include <map>
using namespace std;
typedef long long ll;
//#define INF 1000000000000 //10^12:極めて大きい値,∞
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int A,B,C,K,ans=0,temp=0;
    cin >> A >> B >> C >> K;
    temp = K - A;
    if(K <= A){
        cout << K << endl;
        return 0;
    }
    else{
        ans += A;
        K = K - A;
    }
    if(K <= B){
        cout << ans << endl;
        return 0;
    }
    else{
        K = K - B;
    }
    ans += -1*(K);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String X = sc.next();
			String Y = sc.next();
			
			int a = X.compareTo(Y);
			if(a > 0) System.out.println(">");
			if(a == 0) System.out.println("=");
			if(a < 0) System.out.println("<");
		}
	}
}


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

int main() 
{
    int N, K;
    cin >> N >> K;
    vector<int> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];
    int ans = 0;
    for (int i = 0; i < N; i++) 
    {
        if (v[i] >= K) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
/**
*    author:  yuya1234
*    created: 29.08.2020 21:00:02
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SORT(x) sort(x.begin(),x.end())
#define SORTD(x) sort(x.rbegin(),x.rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SZ(x) ll(x.size())

#define MEMSET(v, h) memset((v), h, sizeof(v))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

  double d,t,s;
  cin>>d>>t>>s;

  if(d/s<=t)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}

Measured memory_bytes: 3736
/*
{
######################
#       Author       #
#        Gary        #
#        2020        #
######################
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
int n,q;
const int N=1<<18;
LL ten[N+1],one[N+1];
const int MOD=998244353;
struct SEGMENT_TREE{
	int lazy[N+N]={0};
	struct node{
		int size;
		LL val;
		node operator + (const node & x) const{
			node rest;
			rest.size=x.size+size;
			rest.val=(x.val+ten[x.size]*val)%MOD;
			return rest;
		}
	}tree[N+N];
	void push_down(int index){
		if(lazy[index]){
			tree[index].val=(one[tree[index].size]*lazy[index])%MOD;
			if(index<N)
			lazy[index<<1]=lazy[index<<1|1]=lazy[index];
			lazy[index]=0;
		}
	}
	node query(int a,int b,int now=1,int l=1,int r=N+1){
		push_down(now);
		if(r<=a||l>=b){
			return node{0,0};
		}
		if(r<=b&&l>=a){
			return tree[now];
		}
		int mid=(l+r)>>1;
		return query(a,b,now<<1,l,mid)+query(a,b,now<<1|1,mid,r);
	}
	node modify(int a,int b,int val,int now=1,int l=1,int r=N+1){
		push_down(now);
		if(r<=a||l>=b){
			return tree[now];
		} 
		if(r<=b&&l>=a){
			lazy[now]=val;
			push_down(now);
			return tree[now];
		}
		int mid=(l+r)>>1;
		return tree[now]=modify(a,b,val,now<<1,l,mid)+modify(a,b,val,now<<1|1,mid,r);
	}
	void build(){
		rl(i,N+N-1,1){
			if(i<N){
				tree[i].size=tree[i<<1].size<<1;
				tree[i].val=one[tree[i].size];
			}
			else{
				tree[i]=node{1,1};
			}
		}
	}
}sgt;
int main(){
	fastio;
	R2(n,q);
	ten[0]=1ll;
	one[0]=0ll;
	rb(i,1,N){
		ten[i]=ten[i-1]*10ll%MOD;
		one[i]=(one[i-1]*10ll+1ll)%MOD;
	}
	sgt.build();
	rb(i,1,q){
		int l,r,q;
		R2(l,r);
		cin>>q;
		sgt.modify(l,r+1,q);
		cout<<sgt.query(1,n+1).val<<endl;
	}
	return 0;
}
/** 程序框架：
  *
  *
  *
  *
  **/


Measured memory_bytes: 17980