akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int H, W;
string S[2005];
int Right[2005][2005], Left[2005][2005], Up[2005][2005], Down[2005][2055];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W;
    for(int i = 1; i <= H; i++) {
        cin >> S[i];
        S[i] = "#" + S[i] + "#";
    }
    for(int i = 0; i <= W + 2; i++) {
        S[0].push_back('W');
        S[H+1].push_back('W');
    }
    for(int h = 1; h <= H; h++) {
        int now = 0;
        for(int w = 1; w <= W; w++) {
            Left[h][w] = now;
            //cerr << h << " " << w << " " << Left[h][w] << endl;
            if(S[h][w] == '#') now = w;
        }
        now = W+1;
        for(int w = W; w >= 1; w--) {
            Right[h][w] = now;
            if(S[h][w] == '#') now = w;
        }
    }
    for(int w = 1; w <= W; w++) {
        int now = 0;
        for(int h = 1; h <= H; h++) {
            Up[h][w] = now;
            if(S[h][w] == '#') now = h;
        }
        now = H+1;
        for(int h = H; h >= 1; h--) {
            Down[h][w] = now;
            if(S[h][w] == '#') now = h;
        }
    }
    int ans = 0;
    for(int h = 1; h <= H; h++) {
        for(int w = 1; w <= W; w++) {
            if(S[h][w] == '#') continue;
            chmax(ans, Down[h][w] - Up[h][w] + Right[h][w] - Left[h][w] + 1);
            //cerr << h << " " << w << " " << ans << endl;
        }
    }
    cout << ans - 4 << endl;
    return 0;
}


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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var N = int.Parse(Console.ReadLine());
			string s = Console.ReadLine();
			var array = new bool[N];
			for (int i = 0; i < N; i++)
			{
				array[i] = s[i] == 'o';
			}
			var result = new bool[][] { new[] { true, true }, new[] { true, false }, new[] { false, true }, new[] { false, false } };
			for (int i = 0; i < 4; i++)
			{
				if(GetString(result[i], array, N) != "-1")
				{
					Console.WriteLine(GetString(result[i], array, N));
					return;
				}
			}
			Console.WriteLine("-1");
		}
		static string GetString(bool[] K,bool[] s, int N)
		{
			var answer = new bool[N+1];
			answer[0] = K[0];
			answer[1] = K[1];
			for (int i = 1; i < N; i++) answer[i+1] = answer[i] == answer[i - 1] ?s[i]:!s[i];
			return answer[0] == answer[N] && ((s[0] == answer[0] == answer[1] == answer[N - 1]) || (!s[0] == !(answer[0] == answer[1] == answer[N - 1]))) ? string.Join("", answer.Take(N).Select(z => z ? "S" : "W")) : "-1";
		}
	}
}


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

using namespace std;

int main()
{
    int a,b,k;
    cin>>k>>a>>b;

    for(int i=a; i<=b; i++){
        if(i%k==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;

}


Measured memory_bytes: 3632
// ABC 073 D joisino's travel

using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static int N;
    static int M;
    static int R;
    static int[] r;
    static int[,] Edge; // Edge[i,j] : 頂点i+1,j+1間の道の長さ(なければ1e9)
    static int[,] Dis; // Dis[i,j] : 頂点i+1,j+1間の最短距離

    static void Main()
    {
        /* 入力の受け取り、変数の初期化 */
        int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        N = input[0];
        M = input[1];
        R = input[2];
        r = Console.ReadLine().Split().Select(s => int.Parse(s) - 1).ToArray();
        Edge = new int[N, N];
        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++)
                Edge[i, j] = (int)1e9;
        for (int i = 0; i < M; i++)
        {
            input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = input[0] - 1;
            int b = input[1] - 1;
            int c = input[2];
            Edge[a, b] = c;
            Edge[b, a] = c;
        }
        Dis = new int[N, N];
        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++)
                Dis[i, j] = Edge[i, j];
        for (int i = 0; i < N; i++)
            Dis[i, i] = 0;

        /* Warshall-Floyd法により、頂点間の最短距離を求める */
        for (int k = 0; k < N; k++)
            for (int i = 0; i < N; i++)
                for (int j = 0; j < N; j++)
                    if (Dis[i, j] > Dis[i, k] + Dis[k, j])
                        Dis[i, j] = Dis[i, k] + Dis[k, j];

        /* すべてのrの順番について、距離を求める */
        int ans = int.MaxValue;
        Permutation perm = new Permutation();
        foreach (var n in perm.Enumerate(r))
        {
            int dis = 0;
            for (int i = 0; i < n.Length - 1; i++)
                dis += Dis[n[i], n[i + 1]];
            ans = Math.Min(ans, dis);
        }
        Console.WriteLine(ans);
    }
}

class Permutation // 順列
{
    public IEnumerable<T[]> Enumerate<T>(IEnumerable<T> nums)
    {
        return _GetPermutations<T>(new List<T>(), nums.ToList());
    }

    private IEnumerable<T[]> _GetPermutations<T>(IEnumerable<T> perm, IEnumerable<T> nums)
    {
        if (nums.Count() == 0)
        {
            yield return perm.ToArray();
        }
        else
        {
            foreach (var n in nums)
            {
                var result = _GetPermutations<T>(perm.Concat(new T[] { n }),
                                                 nums.Where(x => x.Equals(n) == false)
                              );
                foreach (var xs in result)
                    yield return xs.ToArray();
            }
        }
    }
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    string s;
    ll k;
    cin >> s >> k;
    ll n = s.length();

    if (k <= n) {
        rep(i, k) {
            if (s[i] != '1') {
                cout << s[i] << endl;
                return 0;
            }
        }
        cout << 1 << endl;
    } else {
        rep(i, n) {
            if (s[i] != '1') {
                cout << s[i] << endl;
                return 0;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  int a=h+w-1,b=0;
  char g[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> g[i][j];
      if(g[i][j]=='#')b++;
    }
  }
  if(a==b)cout << "Possible";
  else cout << "Impossible";
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

ll choose2(ll n){
    return n*(n-1)/2;
}

int main()
{
 int n;
 cin >> n;
 vector<int> a(n);
 rep(i,n) cin>>a[i];
 rep(i,n) a[i]--;
 vector<int> cnt(n);
 rep(i,n) cnt[a[i]]++;
 ll tot = 0;
 rep(i,n){
     tot+= choose2(cnt[i]);
 }
rep(i,n){
    ll ans = tot;
    ans -= choose2(cnt[a[i]]);
    cnt[a[i]]--;
    ans +=choose2(cnt[a[i]]);
    cout<<ans<<endl;
    cnt[a[i]]++;
}
/*
 ll N;
 cin>>N;
 ll d[N];
 for(int i=0;i<N;++i)cin>>d[i];

int num[N];

 for(int i = 0;i<N;++i)
{
  num[i] = 0;
}

for(int i = 0;i<N;++i)
{
 num[d[i]]++;
}

ll ans = 0;

for(int i = 0; i < N;i++){
    ans+=num[i]*(num[i]-1)/2;
}

cout<<endl;

for(int i = 0; i < N;i++){
    if(num[d[i]]>0){
    ans-=(num[d[i]]-1);
    cout<<ans<<endl;
    ans+=(num[d[i]]-1);
    }
}
*/


 return 0;  
}

Measured memory_bytes: 4224
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>


using namespace std;

void solve3() {
	int N, K;
	cin >> N >> K;
	vector<string> v;
	for (int i = 0; i < K; i++)
	{
		string s;
		cin >> s;
		v.push_back(s);
	}
	int ans = N;
	while (1) {
		bool flag = true;
		string ss = to_string(ans);
		for (int i = 0; i < ss.size(); i++)
		{
			for (int j = 0; j < K; j++)
			{
				if (ss[i] == v[j][0]) {
					flag = false;
				}
			}
		}
		if (flag) {
			cout << ans << endl;
			return;
		}
		ans++;
	}
}

void solve2() {
	int N,L;
	vector< string> v;
	cin >> N>>L;
	for (int i = 0; i < N; i++)
	{
		string s;
		cin >> s;
		v.push_back(s);

	}
	sort(v.begin(), v.end());
	for (int i = 0; i < N; i++)
	{
		cout << v[i];
	}
	cout << endl;
}


void solve1() {
	int A, B, C;
	cin >> A >> B >> C;
	vector<int> v;
	v.push_back(A);
	v.push_back(B);
	v.push_back(C);
	sort(v.begin(), v.end());
	if (v[0] == 5 && v[1] == 5 && v[2] == 7)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

int main() {
	solve3();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> // Common file
#include<ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define ld long double
ll t = 1, tt;
ll dp[2005][2005];
inline ll add(ll x,ll y){x+=y;return x%hell;}
inline ll mult(ll x,ll y){x%=hell;y%=hell;return (x*y)%hell;}
inline ll powMod(ll base,ll expo){
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base);
		expo>>=1;
	}
	return ans;
}
ll go(ll l,ll r,ll n,vector<pp>& v){
	if(l+r>=n)return 0;
	if(dp[l][r]!=-1)return dp[l][r];
	dp[l][r]=0;
	return dp[l][r]=max(abs(l-v[l+r].se)*v[l+r].fi+go(l+1,r,n,v),abs(n-1-r-v[l+r].se)*v[l+r].fi+go(l,r+1,n,v));
}
void solve(){
	ll n;
	cin>>n;
	memset(dp,-1,sizeof dp);
	vector<pp> v(n);
	rep(i,0,n){
		cin>>v[i].fi;
		v[i].se=i;
	}
	sort(all(v));
	reverse(all(v));
	cout<<go(0,0,n,v);
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	//cin>>t;
	tt=t;
    while(t--){
        solve();
        if(t!=0)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 35208
import sys
input = sys.stdin.buffer.readline

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
            
n, q = map(int, input().split())
bit = Bit(n)
alst = list(map(int, input().split()))
for i, a in enumerate(alst, start = 1):
    bit.add(i, a)
for _ in range(q):
    qq = list(map(int, input().split()))
    if qq[0] == 0:
        bit.add(qq[1] + 1, qq[2])
    else:
        print(bit.sum(qq[2]) - bit.sum(qq[1]))

Measured memory_bytes: 62548
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
    int a[3],i,j,k,ans,tmp;

    for ( i = 0; i < 3; i++)
    {
        scanf("%d",a+i);
    }

    ans=a[0]+a[1]+a[2];

    for ( i = 0; i < 3; i++)
    {
        for ( j = 0; j < 3; j++)
        {
            if(j!=i)
            {
                k=3-i-j;
                tmp=abs(a[j]-a[i])+abs(a[k]-a[j]);
                if(ans>tmp) ans=tmp;
            }
        }
    }

    printf("%d",ans);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pll;

const int maxN = 1e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b){return !b ? a : gcd(b, a % b);}
ll modP(ll a, ll b) {return (!b ? 1 : (modP(a, b / 2) * modP(a, b / 2) * (b % 2 ? a : 1)) % MOD);}

int n, k;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	cout << (k <= n / 2 + n % 2 ? "YES" : "NO") << endl;
	return 0;
}



Measured memory_bytes: 256
require 'matrix'

class SparseMatrix
	def initialize(m, n)
		@m, @n = m, n
		@rows = (1..m).map{ Hash.new(0) }
	end

	def [](i)
		@rows[i]
	end

	def rank
		save = Marshal.load(Marshal.dump(self))
		rank = 0
		j = 0
		(0..@m-1).each{|i|
			pivot_idx = nil
			j += 1 until j >= @n || pivot_idx = @rows.index{|row| row[j] && row[j] != 0}
			break if j >= @n
			rank += 1

			pivot_row = @rows.delete_at(pivot_idx)
			a = pivot_row[j]
			
			@rows.each{|row|
				b = row[j]
				if b && b != 0
					r = b / a
					pivot_row.each{|k, val|
						row[k] -= r * val
						row.delete(k) if row[k] == 0
					}
				end
			}

			j += 1
		}		
		@rows = save.rows
		rank
	end

	def map(&block)
		m = self.class.new(@m, @n)
		(0..@n-1).each{|i|
			@rows[i].each{|k, x|
				m[i][k] = block.call(x)
			}
		}
		m
	end

	def *(other)
		if other.kind_of?(Numeric)
			map{|x| x * other}
		elsif other.kind_of?(Vector)
			raise "hogehoge" if other.size != @n
			a = Array.new(@m, 0)
			(0..@m-1).each{|i|
				(0..@n-1).each{|j|
					 a[i] += @rows[i][j] * other[j]	
				}
			}
			Vector[*a]
		elsif other.kind_of?(SparseMatrix)
			prod = self.class.new(@m, @n)	
			(0..@m-1).each{|i|
				row = @rows[i]
				(0..other.n-1).each{|j|
					sum = 0
					@rows[i].each{|k, x|
						sum += x * other[k][j]	
					}
					prod[i][j] = sum if sum != 0
				}
			}
			prod
		else
			raise 'hoge'
		end

	end

	attr_reader :rows, :m, :n
end

def exp(n, k, mod = nil)
	x = 1	
	r = n
	while k > 0
		x = r * x if k & 1 == 1
		r *= r		
		if mod
			x %= mod
			r %= mod
		end
		k >>= 1
	end
	x
end

class SparseMatrix
	def %(mod)
		map{|x| x % mod}
	end
end

loop {
	n, m, a, b, c, t = gets.split.map &:to_i 
	break if n == 0
	states = Vector[*gets.split.map(&:to_i)]

	mat = SparseMatrix.new(n, n)
	(0..n-1).each{|i|
		(0..n-1).each{|j|
			if j == i-1
				mat[i][j] = a
			elsif j == i
				mat[i][j] = b
			elsif j == i+1
				mat[i][j] = c
			end
		}
	}

	puts (exp(mat, t, m) * states).to_a.map{|x| x % m}.join(" ")
}

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

using namespace std;

typedef pair<int, int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector<VI> VVI;

typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(), a.end()
#define SET(a, b) memset(a, b, sizeof(a))
#define si(n) scanf("%d", &n)
#define dout(n) printf("%d\n", n)
#define sll(n) scanf("%lld", &n)
#define lldout(n) printf("%lld\n", n)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define fast_io                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)

#define endl '\n'

int main() {
  fast_io;
  string s;
  cin >> s;
  int sn = ::stoi(s);
  int f = sn / 100;
  int b = sn % 100;
  if (f <= 12 && (b > 12 || b == 0) && f) {
    cout << "MMYY";
  } else if ((f > 12 || f == 0) && b <= 12 && b) {
    cout << "YYMM";
  } else if (f <= 12 && b <= 12 && f && b) {
    cout << "AMBIGUOUS";
  } else {
    cout << "NA";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

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


        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i=0; i<n; i++){
            long tmp = sc.nextLong();
            a[i] = tmp;
        }

        long sum = 0;

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


        long[] tmp = new long[n-1];
        tmp[0] = a[0];

        for (int i=1; i<n-1; i++){
            tmp[i] = tmp[i-1]+a[i];
        }

        long[] tmp2 = new long[n-1];

        for (int i=0; i<n-1; i++){
            tmp2[i] = sum-tmp[i];
        }

        long ans = Long.MAX_VALUE;

        for (int i=0; i<n-1; i++){
            ans = Math.min(ans, Math.abs(tmp2[i]-tmp[i]));
        }

        System.out.println(ans);
//        System.out.println(tmp[1]);
    }
}

Measured memory_bytes: 89572
N,W = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
dp = [[10**12 for _ in range(10**5+1)] for _ in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    for j in range(10**5+1):
        dp[i][j] = dp[i-1][j]
        if A[i-1][1]<=j:
            dp[i][j] = min(dp[i][j],dp[i-1][j-A[i-1][1]]+A[i-1][0])
vmax = 0
for j in range(10**5+1):
    if dp[N][j]<=W:
        vmax = max(vmax,j)
print(vmax)

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

int main() {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    for (int i = 0; i < b; i++) {
        cout << a;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int n;

    int i, j, k;

    scanf("%d", &n);

    int A[n][26];
    int Amin[26];
    char S[n][51];
    int check;

    for(i = 0; i < n; i++){
        scanf("%s", S[i]);
    }

    for(i = 0; i < n; i++){
        for(j = 0; j < 26; j++){
            A[i][j] = 0;
        }
    }

    for(i = 0; i < 26; i++){
        Amin[i] = 50;
    }

    for(i = 0; i < n; i++){
        for(j = 0; S[i][j]; j++){
            A[i][S[i][j] - 'a']++;
        }
    }

    for(i = 0; i < n; i++){
        for(j = 0; j < 26; j++){
            if(Amin[j] > A[i][j]){
                Amin[j] = A[i][j];
            }
        }
    }


    for(i = 0; i < 26; i++){
        for(j = 0; j < Amin[i]; j++){
            putchar('a' + i);
        }
    }
    putchar('\n');

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>

#define div1 1000000007

using namespace std;

int main(void)
{
    string S;
    int i, ans=0;

    cin >> S;

    for(i=0; i<S.size()-1; i++){
        if(S[i] != S[i+1]){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
	// your code goes here
	int n,m,res=0;
	cin>>n>>m;
	if(n>=m){
	for(int i=0;i<n;i++)
	res=res*10+m;
	cout<<res<<endl;}
	else{
	    for(int i=0;i<m;i++)
	res=res*10+n;
	cout<<res<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import sys

INPUT = lambda: sys.stdin.readline().rstrip()

sys.setrecursionlimit(10 ** 9)


def main():
    b = INPUT()

    if b == 'A': print('T')
    elif b == 'T': print('A')
    elif b == 'C': print('G')
    else: print('C')


if __name__ == '__main__':
    main()

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

int main() {
  int n;
  cin >> n;
  vector<long long> A(n, 0);
  for (int i = 0; i<n; i++) cin >> A[i];
  long long cnt=0, acm=0, ans=0;
  for(int i = 0; i<n; i++) {
    acm+=A[i];
    if(i%2) {
      if(acm>0);
      else {
        cnt += abs(acm) + 1;
        acm = 1;
      }
    }
    else {
      if(acm<0);
      else {
        cnt += abs(acm) + 1;
        acm = -1;
      }
    }
  }
  
  ans = cnt;
  cnt=0;
  acm=0;
  for(int i = 0; i<n; i++) {
    acm+=A[i];
    if((i+1)%2) {
      if(acm>0);
      else {
        cnt += abs(acm) + 1;
        acm = 1;
      }
    }
    else {
      if(acm<0);
      else {
        cnt += abs(acm) + 1;
        acm = -1;
      }
    }
  }
  ans = min(ans,cnt);
  
  cout << ans << "\n";
}

Measured memory_bytes: 1024
using System;
using System.Linq;

namespace JOI_0652
{
    class Program
    {
        static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToList();
            int i = 1, sum = 0;
            for(; i < input[2]; i++)
            {
                sum += input[0];
                if (i % 7 == 0) sum += input[1];
                if (sum >= input[2]) break;
            }
            Console.WriteLine(i);
        }
    }
}



Measured memory_bytes: 16472
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;

    cout << (ll)n * (n - 1) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
int d[200010],dp[1010][1010];
double w[1000],v[1000];
double box[200010];
char field[200][200];

double dot(double a,double b,double c, double x,double y,double z){
  return a * x + b * y + c * z;
}

int main(){
  double x[500],y[500],z[500];
  while(1){
    cin >> n;
    if(!n)break;
    ll ans = 0;
    clr(d,0);
    rep(i,0,n)cin >> x[i] >> y[i] >> z[i];
    cin >> m;
    rep(i,0,m){
      double a,b,c,r;
      cin >> a >> b >> c >> r;
      double abs1 = sqrt(dot(a,b,c, a,b,c));
      rep(j,0,n){
        double abs2 = sqrt(dot(x[j],y[j],z[j], x[j],y[j],z[j]));
        double Cos = dot(a,b,c, x[j],y[j],z[j]) / abs1 / abs2;
        double q = acos(Cos);
        if(q < r + 0.00000001)d[j]++;
      }
    }
    rep(i,0,n)if(d[i])ans++;
    print(ans);
  }
  return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;

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

const ll mod = 1e9 + 7;



int main(){
    char c;
    cin >> c;
    string S = "aeiou";
    rep(i,5){
        if (c==S[i]){
            cout << "vowel" << endl;
            return 0;
        }
    }
    cout << "consonant" << endl;
}


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

char finish (char x) {
  if (x == 'S') {
    return 'W';  
  }  
  return 'S';
}

int main () {
  int n;
  cin >> n;
  string h;
  cin >> h;
  char box[4][2] = {
    {'S', 'S'}, {'S', 'W'}, {'W', 'S'}, {'W', 'W'}  
  };
  for (int i = 0; i < 4; i++) {
    string ans = "";
    for (int j = 0; j < n; j++) {
      ans = ans + "x";  
    }
    for (int j = 0; j < n; j++) {
      if (j < 2) {
        ans[j] = box[i][j];  
        if (j == 1) {
          if ((h[j] == 'o' && ans[j] == 'S') || 
              (h[j] == 'x' && ans[j] == 'W')) {
            ans[j + 1] = ans[j - 1];  
          }  
          else {
            ans[j + 1] = finish(ans[j - 1]);  
          }
        }
      }   
      else {
        if (j < n - 1) {
          if ((h[j] == 'o' && ans[j] == 'S') || 
              (h[j] == 'x' && ans[j] == 'W')) {
            ans[j + 1] = ans[j - 1];  
          }  
          else {
            ans[j + 1] = finish(ans[j - 1]);  
          }
        }
      }
    } 
    bool ok = false; 
    if ((h[n - 1] == 'o' && ans[n - 1] == 'S') || 
        (h[n - 1] == 'x' && ans[n - 1] == 'W')) {
      if (ans[n - 2] == ans[0]) {
        ok = true;  
      }  
    }
    else {
      if (ans[n - 2] != ans[0]) {
        ok = true;  
      }  
    }
    if ((h[0] == 'o' && ans[0] == 'S') || 
        (h[0] == 'x' && ans[0] == 'W')) {
    	if (ans[1] != ans[n - 1]) {
          ok = false;
        }
    }
    else {
      if (ans[1] == ans[n - 1]) {
        ok = false;
      }
    }
    if (ok) {
      for (int j = 0; j < n; j++) {
        cout << ans[j];    
      }  
      cout << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    if (d <= x / k) {
        cout << x - d*k << endl;
    } else {
        li num = x / d;
        li rest = k - num;
        li xx = x % d;
        cout << (rest % 2 == 0 ? xx : d - xx) << endl;
    }

    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(void){
    ios_base::sync_with_stdio(false);
	int n,p;
    while(cin>>n>>p){
        vector<int> str;
        for(int i = 0; i < n; i++){
            char c;
            cin>>c;
            str.push_back(c-'0');
        }
        if(p ==2 || p ==5){
            long long int total = 0;
            for(int i = n-1; i >= 0; i--){
                if(str[i]%p==0){
                    total += i+1;
                }
            }
            cout<<total<<'\n';
        }
        else{
            long long multi = 1;
            vector<long long> remainder(n+1,0);
            for(int i = n-1; i >= 0; i--){
                remainder[i]=(remainder[i+1]+multi*str[i]%p)%p;
                multi = multi*10%p;
            }
            long long total = 0;
            map<int,int> ls;
            for(int i = n; i >= 0; i--){
                // cout<<remainder[i]<<'\n';
                auto iter = ls.find(remainder[i]);
                if(iter != ls.end()){
                    total+=iter->second;
                }
                iter = ls.find(remainder[i]);
                if(iter == ls.end()){
                    ls.insert({remainder[i],1});
                }
                else{
                    iter->second++;
                }
            }
            cout<<total<<'\n';
        }
    }
}

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

long long f(long long x)
{
    return x * x * x;
}

long long g(long long n, long long k, long long mod)
{
    long long count = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i % k == mod)
        {
            count++;
        }
    }
    return count;
}

int main()
{
    long long N, K;
    cin >> N >> K;

    long long ans = f(g(N, K, 0));
    if (K % 2 == 0)
    {
        ans += f(g(N, K, K / 2));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Main main = new Main();
    main.solve();
    main.show();
  }

  String s;
  int n;
  int ans;

  public Main() {
    Scanner sc = new Scanner(System.in);
    try {
      s = sc.next();
      n = s.length();
    } finally {
      sc.close();
    }
  }
  
  void solve() {
    for (int i = 0; i < n / 2; i++) {
      if (s.charAt(i) != s.charAt(n-1-i)) ans++;
    }
  }

  void show() {
    System.out.println(ans);
  }
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;

#define rep(i,m,n) for(ll i=m;i<n;i++)

ll n;

vll divisor(ll x){
  vll res;
  for(ll i=1;i*i<=x;i++){
    if(x%i!=0) continue; 
    res.emplace_back(i);
    if(i*i!=x) res.emplace_back(x/i);
  }
  return res;
}

void solve(){
  cin >> n;
  ll res=0;
  res+=divisor(n-1).size()-1;
  
  for(auto p:divisor(n)){
   if(p==1) continue; 
   ll tmp=n;
    while(tmp%p==0) tmp/=p;
   if(tmp%p==1) res++;
  }
  
  cout << res  << endl;
  
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}  

Measured memory_bytes: 384
import math
n,d=map(int,input().split())
co=[]
for _ in range(n):
    x=list(map(int,input().split()))
    co.append(x)
ans=0
for i in range(n):
    for j in range(n):
        if i<j:
            a=0
            for k in range(d):
                a+=(co[i][k]-co[j][k])**2
            b=int(math.sqrt(a))
            if b*b-a==0:
                ans+=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define dscf(n) scanf("%lf",&n)
#define lpri(n) printf("%lld ",n)
#define dpri(n) printf("%lf ",n)
#define dprin(n) printf("%lf\n",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;
 
void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

int main()
{
	int n;
	scf(n);
	int ans;
	if(n%1000==0)
	ans=0;
	else
	{
	      ans=((n/1000)+1);
	      ans=ans*1000-n;
	}
	pri(ans);
return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    auto b = a;
    sort(all(a));//昇順そーと
    rep(i,n){
        if(b[i] != a[n-1]) cout << a[n-1] << endl;
        else cout << a[n-2] << endl;
    }
}


Measured memory_bytes: 3200
N = int(input())
rng = []
for i in range(N):
    x, l = map(int, input().split())
    rng.append([x+l, x-l])

rng.sort()
count = 1
border = rng[0][0]


for i, j in enumerate(rng[1:]):
    if border <= j[1]:
        count += 1
        border = j[0]
print(count)


Measured memory_bytes: 20480
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000001
#define r(i,a,b)    for(i=a;i<b;i++)
#define ra(i,a,b)   for(i=a;i<=b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ss          set<ll int>
using namespace std;
 
#define N 1000000
#define M 100000000

struct unit {
  ll int a[N];  
};

ll fact (ll int x)
{if(x==1 || x==0)return 1;
else return x*fact(x-1);}

ll power(ll int x,ll int n)
{if(n==0)return 1;
else if(n%2 == 0)return power(x*x,n/2);
else return x*power(x*x,(n-1)/2);}

bool cmp (const pii&a,const pii&b)
{ return((a.F-a.S) > (b.F-b.S));
/*if(a.S<=b.S){if(a.S==b.S)return a.F<b.F;else return a.S<b.S;}
else return a.S<b.S;*/}

ll dp[100005];
ll visited[100005];
vector<vi> v(100005);
vi cnt(100005,0);
ll x;

ll dfs (ll i)
{
    if(visited[i]==0){
    visited[i]=1;
    for(auto x:v[i])
    {
        dp[x]=max(dp[x],dp[i]+1);
        --cnt[x];
        if(cnt[x]==0)
        dfs(x);
    }}
    else
    return 0;
}


int main()
{
    cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);
    ll i,j,k,l,m,n,a=0,b=0;
    cin>>n>>m;
    memset(dp,0,sizeof(dp));
    memset(visited,0,sizeof(visited));
    r(i,0,m)
    {
        cin>>k>>l;
        v[k].pb(l);
        cnt[l]++;
    }
    ra(j,1,n)
    {
        if(visited[j]==0 && cnt[j]==0)
        dfs(j);
    }
    cout<<*max_element(dp,dp+100005);
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define lli long long int
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}	
	}
	return true;
}

int main()
{
ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);
int n;
cin>>n;
int l,r;
int cnt=0;
int flag=0;
for(int i=0;i<n;i++)
{
	cin>>l>>r;
	if(l==r)
	{
		cnt++;
		if(cnt>=3)
		{
			flag=1;
		}
	}
	else
	{
		cnt=0;
	}
}
if(flag==1)
{
	cout<<"Yes"<<endl;
}
else
{
	cout<<"No"<<endl;
}
}



 

Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=2020202;
char s[N];
int a[N];
int n,sum,ans;
int check(int x,int y,int z){
	return x+y>z&&x+z>y&&y+z>x;	
}
int main(){
	scanf("%d",&n);
	for (int i=1; i<=n; i++)
		scanf("%d",&a[i]);
	for (int i=1; i<=n; i++)
		for (int j=i+1; j<=n; j++)
			for (int k=j+1; k<=n; k++)
			if (a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k]&&check(a[i],a[j],a[k]))	ans++;
	printf("%d\n",ans);	
    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
  int n;
  cin >>n;
  long sum = 0;
  for(int i = 0; i < n; i++){
      int a;
      cin >> a;
      sum += a-1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    char a[4];
    int ans=0;
    for(int i=0;i<4;i++){
        cin>>a[i];
        if(a[i]=='+'){
            ans++;
        }else{
            ans--;
        }
    }
    cout<<ans<<endl;;
    
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
      int i,j,a,b;

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



Measured memory_bytes: 2108
import itertools

a=[int(input()) for i in range(5)]
b=list(itertools.permutations(a))
c=[]
for i in range(120):
    summary=0
    for j in range(5):
        if j==4:
            summary=summary+b[i][j]
        elif b[i][j]%10!=0:
            summary=summary+((10-b[i][j]%10)+b[i][j])
        else:
            summary=summary+b[i][j]
    c.append(summary)

print(min(c))


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

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

   else return(gcd(b, a%b));
}

ll lcm(ll a, ll b) {
   return a * b / gcd(a, b);
}

int main(){
    ll A,B;
    cin >> A >> B;
    if(A < B) swap(A,B);
    cout << lcm(A,B) << endl;
}


    


Measured memory_bytes: 256
import math
N,M = map(int,input().split())
def comb(n):
    return math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))

if N >=2:
    a = comb(N)
else:
    a = 0

if M  >=2:
    b = comb(M)
else:
    b = 0

print(a+b) 

Measured memory_bytes: 3060
#include <stdio.h>

const int map[7][2]={
	{0,0}, /* 0:? */
	{2,3}, /* 1:A */
	{0,4}, /* 2:X */
	{2,0}, /* 3:Y */
	{5,6}, /* 4:Z */
	{6,3}, /* 5:W */
	{3,2}, /* 6:B */
};

int main(void) {
	char route[200];
	int i,now;
	while(1) {
		scanf("%s",route);
		if(route[0]=='#' && route[1]==0)break;
		now=1;
		for(i=0;route[i];i++)now=map[now][route[i]-'0'];
		puts(now==6?"Yes":"No");
	}
	return 0;
}

Measured memory_bytes: 524
#include <stdio.h>

int main(void) {
	int a,b;
	
	scanf("%d %d",&a,&b);

	if(a==1&&a!=b || a!=1&&b!=1&&a>b) {
		printf("Alice\n");
	}
	else if(b==1&&a!=b || b!=1&&a!=1&&b>a) {
		printf("Bob\n");
	}
	else {
		printf("Draw\n");
	}

	return 0;
}


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

int main() {
    ll n;
    cin >> n;
    ll a[n+1][4];
    //ll dp[n+1][4];
    ll* dp = new ll[n+1];
    for(ll i = 0; i < n; i++) {
        for(ll j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }
    //ll ans = INT_MIN;
    /*dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];*/
   
    /*ll faltu = a[0][0] + max(a[1][1], a[1][2]);
    ans = max( ans, faltu);
    faltu = a[0][1] + max(a[1][0], a[1][2]);
    ans = max( ans, faltu);
    faltu = a[0][2] + max(a[1][0], a[1][1]);
    ans = max( ans, faltu);
    dp[1] = ans;*/
   
    for(ll i = 1; i < n; i++ ) {
        for(ll j = 0; j < 3; j++) {
            if(j == 0)
                a[i][j] = a[i][j] + max( a[i-1][j+1] , a[i-1][j+2]);
            else if(j==1)
                a[i][j] = a[i][j] + max( a[i-1][j-1] , a[i-1][j+1]);
            else if(j==2)
                a[i][j] = a[i][j] + max( a[i-1][j-1] , a[i-1][j-2]);  
        }
    }
    cout << max( a[n-1][0] , max( a[n-1][1] , a[n-1][2]) );
    // for(ll i =0;i <n; i++) {
    //     for(ll j = 0; j<3;j++) {
    //         cout<<a[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
}


Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>

#define rep(i, n) for(int i=0;i<(int)(n);i++)

using namespace std;

const int MAX_N = 100;

int N;
char S[MAX_N];
map<char, bool> included;

int main() {
    cin >> N;
    rep(i, N) cin >> S[i];

    for (int i = 0; i < N; i++) {
        included[S[i]] = true;
    }

    int cnt = 0;
    for (auto i = included.begin(); i != included.end(); ++i) {
        cnt++;
    }

    if (cnt == 4) {
        cout << "Four" << endl;
    } else {
        cout << "Three" << endl;
    }
}


Measured memory_bytes: 256
A, B, M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = min(a) + min(b)
for i in range(M):
  x, y, c = map(int,input().split())
  ans = min(ans, a[x-1] + b[y-1] -c)
print(ans)

Measured memory_bytes: 18736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    char s[100010];
    scanf("%s", s);

    vector<bool> alp(26, false);
    for(int i = 0; s[i] != '\0'; i++)
        alp[s[i]-'a'] = true;

    for(int i = 0; i < 26; i++){
        if(!alp[i]){
            cout << (char)(i + 'a') << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll MOD = 1000000007;
ll f1[200010], f2[200010], fv[200010];
void init() {
	f2[0] = f2[1] = fv[0] = fv[1] = f1[1] = 1;
	for(ll i = 2; i < 200010; i ++) {
		f1[i] = MOD - f1[MOD % i] * (MOD / i) % MOD;
		f2[i] = f2[i - 1] * i % MOD;
		fv[i] = fv[i - 1] * f1[i] % MOD;
	}
}
ll comp(ll a, ll b) {
	if(a < b) {
		return 0;
	}
	return f2[a] * (fv[b] * fv[a - b] % MOD) %  MOD;
}
int main() {
	ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
	init();
	int H, W, A, B;
	cin >> H >> W >> A >> B;
	W --, H --;
	ll res = comp(H + W,W);
	for(int i = 0; i < B; i ++) {
		ll rel = comp(H - A + i, i);
		ll des = comp(W + A - i - 1, A - 1);
		res -= rel * des % MOD;
		if(res < 0) {
			res += MOD;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 4992
import collections
import math
def Comb(N,R):
    return math.factorial(N)//(math.factorial(N-R)*math.factorial(R))

N = int(input())
S = ['']*N
for T in range(0,N):
    S[T] = ''.join(sorted(input()))
Count = list(collections.Counter(S).values())
Sum = 0
for TT in range(0,len(Count)):
    if Count[TT]>=2:
        Sum += Comb(Count[TT],2)
print(Sum)

Measured memory_bytes: 24156
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * @author:26019
 */
public class Main {


    public static void main(String[] args) throws Exception {
        solve();
    }

    private static void solve() throws Exception {
        //BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File("C:\\Users\\26019\\Downloads\\out.txt"))));
        FastScanner cin = new FastScanner();
        int a = cin.nextInt(), b = cin.nextInt(), c = cin.nextInt();
        int k = cin.nextInt();
        while (k-- > 0) {
            if (a >= b) {
                b *= 2;
            } else if (b >= c) {
                c *= 2;
            }
        }
        if (a < b && b < c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("C:\\Users\\26019\\Downloads\\P1190_9.in"))));
        StringTokenizer st = new StringTokenizer("");

        FastScanner() throws FileNotFoundException {
        }

        public String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        public String nextLine() { // 读取带空格的字符串
            String res = null;
            try {
                res = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return res;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }
}


Measured memory_bytes: 32724
#include <cstdio>
int max(int a,int b)
{
	if(a>b)
		return a;
	return b;
}
int main(void)
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int upbd=3*max(max(a,b),c);
	int s=a+b+c;
	if((upbd-s)%2==0)
		printf("%d\n",(upbd-s)/2);
	else
	{
		upbd=3*(max(max(a,b),c)+1);
		printf("%d\n",(upbd-s)/2);
	}
	return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>


constexpr int MAXLENGTH = 1000;
int C[MAXLENGTH + 1][MAXLENGTH + 1];
int lcs(std::string lhs, std::string rhs) {
    int lnum = lhs.length();
    int rnum = rhs.length();
    for (int i = 0; i <= lnum; i++) {
        C[i][0] = 0;
    }
    for (int i = 0; i <= rnum; i++) {
        C[0][i] = 0;
    }
    for (int il = 1; il <= lnum; il++) {
        for (int ir = 1; ir <= rnum; ir++) {
            if (lhs[il-1] == rhs[ir-1]) {
                C[il][ir] = C[il - 1][ir - 1] + 1;
            }else if(C[il - 1][ir] >= C[il][ir - 1]) {
                C[il][ir] = C[il-1][ir];
            }else{
                C[il][ir] = C[il][ir - 1];
            }
        }
    }
    return C[lnum][rnum];
}

int main() {
    int n;
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::string l, r;
        std::cin >> l;
        std::cin >> r;
        std::cout << lcs(l, r) << std::endl;
    }
}


Measured memory_bytes: 7124