akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int A[2222],B[2222];

int L[2222],R[2222];

int ans;

void solve(){
    fill_n(L,N,1001001001);
    fill_n(R,N,1001001001);


    rep(i,N){
        rep(j,N){
            if(B[j]==1){
                if(i==j)L[i]=R[i]=0;
                else if(i<j){
                    chmin(L[i],i+N-j);
                    chmin(R[i],j-i);
                }
                else{
                    chmin(L[i],i-j);
                    chmin(R[i],j+N-i);
                }
            }
        }
    }

    for(int d=0;d<N;d++){
        int cnt=0;
        vpint v;
        rep(i,N){
            if(A[(i+d)%N]==B[i])continue;
            cnt++;
            if(R[i]<=d)continue;
            v.pb({R[i]-d,L[i]});
        }
        sort(all(v));
        reverse(all(v));
        int l=0;
        int cur=0;
        for(int dd=N-1;dd>=0;dd--){
            while(cur<v.size()&&v[cur].fi>dd){
                chmax(l,v[cur].se);
                cur++;
            }
            chmin(ans,cnt+d+(dd+l)*2);
        }
    }
}

signed main(){
    string ei;
    cin>>ei;
    N=ei.size();
    rep(i,N)A[i]=ei[i]-'0';
    cin>>ei;
    rep(i,N)B[i]=ei[i]-'0';


    if(count(B,B+N,1)==0){
        if(count(A,A+N,1)==0){
            cout<<0<<endl;
        }
        else{
            cout<<-1<<endl;
        }
        return 0;
    }


    ans=1001001001;
    solve();
    reverse(A,A+N);
    reverse(B,B+N);

    solve();
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
import copy

n, m = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(n)]

ans = 0

for i in range(2**3):
    l = copy.deepcopy(xyz)

    for j in range(3):
        if ((i >> j) & 1):
            for k in range(n):
                l[k][j] *= -1

    for k in range(n):
        l[k] = sum(l[k])

    l.sort(reverse=True)

    ans = max(ans, sum(l[:m]))

print(ans)

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

#define times(n, i) uptil(0, n, i)
#define upto(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi  i <= _##i poi  i++)
#define uptil(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi  i < _##i poi  i++)
#define downto(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi  i >= _##i poi  i--)
#define downtil(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi  i > _##i poi  i--)

#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define poi ;
#define poipoi << "\n"

#define fuwafuwa(n, c) dokidoki((n) + (c) - 1, c)
#define dokidoki(n, c) ((n) / (c) * (c))

template<class T> bool read(T& t){
    return cin >> t poi
}
template<class T, class...U> bool read(T& t, U&... u){
    unless(cin >> t) return false poi
    return read(u...) poi
}

int main(){
    int d poi
    while(read(d)){
        int pyon = 0 poi
        times(600 / d, i) pyon += i * i poi
        cout << pyon * d * d * d poipoi poi
    }
    return 0 poi
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{

	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; string s;

	cin >> n >>s;
	
	vector<VI> dp(n+2, VI(n+2));
	repr(i, n-1, 0) repr(j, n-1, 0){
		if(s[i]!=s[j]) dp[i][j] = 0;
		else dp[i][j] =  dp[i+1][j+1]+1;
	}
	int ans = 0;
	//for(auto xl: dp){for(auto x :xl) printf("%2d ",x); puts("");}
	rep(i, n) rep2(j, i+1,n){
		if(i + dp[i][j] <= j) ans = max(ans, dp[i][j]);
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 98176
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <iomanip> //cout << fixed << setprecision(12) << ans << endl;
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define loop(i, l, r) for(int i = l; i < r; i++)
#define rloop(i, l, r) for(int i = l; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vec_i;
typedef pair<int,int> pair_ii;
typedef pair<ull,ull> pair_ull;
 
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int INF = 1e9;
const int MOD = 1e9+7;
 
int main()
{
	ll n;
	cin >> n;
	cout << (n-1)*n/2 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
	int a;
	scanf("%d", &a);
	
	int x = 0;
	int jml = 0;
	
	char array[100];
	scanf("%s", array);
	
	int arraylen = strlen(array);
	
	for(int i = 0; i < arraylen; i++){
		if(array[i] == 'I'){
			jml++;
		}
		else if(array[i] == 'D'){
			jml--;
		}
		if(x < jml){
			x = jml;
		}
	}
	printf("%d\n", x);
	return 0;
}

Measured memory_bytes: 1712
using System;
class abc162_c_2{
  public static void Main(){
    int n = int.Parse(Console.ReadLine());
    int sum = 0;
    int[,] dp = new int[n+1,n+1];
    for(int i=1; i<=n; i++){
      for(int j=i; j<=n; j++){
        dp[i,j] = dp[j,i] = gcd(i,j);
        //Console.WriteLine("gcd({0},{1}) = {2}",i,j,dp[i,j]);
      }
    }
    for(int i=1; i<=n; i++){
      for(int j=1; j<=n; j++){
        for(int k=j; k<=n; k++){
          if(j==k)
            sum += dp[i,dp[j,k]];
          else
            sum += dp[i,dp[j,k]] * 2;
        }
      }
    }
    Console.WriteLine(sum);
  }
  public static int gcd(int m, int n){
    if(m > n){
      int temp = n;
      n = m;
      m = temp;
    }
    while(true){
      if(n%m == 0){
        return m;
      }
      else{
        int a = n/m;
        int b = n - m*a;
        n = m;
        m = b;
      }
    }
  }
}


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

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var line = Console.ReadLine().Split(); 
            var s = line[0];
            var t = line[1];

            var str = string.Join("",Enumerable.Range(0,n).Select(i => s[i].ToString() + t[i].ToString()));
            Console.WriteLine(str);
        }
    }
}


Measured memory_bytes: 11348
#include<iostream>
using namespace std;
int main(){
	int n;
	int ans[6]={0};
	cin>>n;
//	for(int i=0;i<6;i++)cout<<ans[i];
	while(n--){
		
		double input;
		cin>>input;
		if(input<165)ans[0]++;
		else if(165<=input&&input<170)ans[1]++;
		else if(170<=input&&input<175)ans[2]++;
		else if(175<=input&&input<180)ans[3]++;
		else if(180<=input&&input<185)ans[4]++;
		else if(185<=input)ans[5]++;
	}
	for(int i=0;i<6;i++){
		cout<<i+1<<":";
//	cout<<ans[i];
		for(int j=0;j<ans[i];j++)
			cout<<"*";			
		cout<<endl;
	}

}

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

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

#define ll long long
#define vl vector<ll>
#define vll vector<vl>

const int INF = 1e9;

int main() {
	int n;
	int a[200010];
	cin >> n;
	rep(i, n) cin >> a[i];
	if(n%2==1)
	{
		int sum=0;
		rep(i, n) sum=(sum+a[i])%2;
		if(sum==1) cout << "First" << endl;
		else cout << "Second" << endl;
		return 0;
	}
	int s=0;
	rep(i, n) s=(s+a[i])%2;
	sort(a, a+n);
	if(s==1)
	{
		if(a[0]%2==0) cout << "First" << endl;
		else cout << "First" << endl;
	}
	else
	{
		if(a[0]%2==1) cout << "First" << endl;
		else cout << "Second" << endl;
	}
	return 0;
}


Measured memory_bytes: 3896
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
using namespace std;

int main(){
  
  int n; cin >> n;
  vector<int> d(n);
  for (int i=0; i<n; i++) cin >> d[i];
  
  sort(d.begin(), d.end());
  
  cout << d[n/2]-d[n/2-1];
 
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int H, W, R, C; char s[1001][1007], t[1001][1007];
unsigned long long pw1, pw2, h1[1001][1007], h2[1001][1007], h3[1001];
int main() {
	scanf("%d%d", &H, &W);
	for(int i = 0; i < H; i++) scanf("%s", s[i]);
	scanf("%d%d", &R, &C); pw1 = 1, pw2 = 1;
	for(int i = 0; i < R; i++) scanf("%s", t[i]), pw2 *= 1000000007;
	for(int i = 0; i < C; i++) pw1 *= 257;
	for(int i = 0; i < H; i++) {
		unsigned long long w = 0;
		for(int j = 0; j < C; j++) w = w * 257 + s[i][j]; h1[i][0] = w;
		for(int j = C; j < W; j++) w = w * 257 + s[i][j] - pw1 * s[i][j - C], h1[i][j - C + 1] = w;
	}
	for(int i = 0; i <= W - C; i++) {
		unsigned long long w = 0;
		for(int j = 0; j < R; j++) w = w * 1000000007 + h1[j][i]; h2[0][i] = w;
		for(int j = R; j < H; j++) w = w * 1000000007 + h1[j][i] - pw2 * h1[j - R][i], h2[j - R + 1][i] = w;
	}
	for(int i = 0; i < R; i++) {
		for(int j = 0; j < C; j++) h3[i] = h3[i] * 257 + t[i][j];
	}
	unsigned long long h4 = 0;
	for(int i = 0; i < R; i++) h4 = h4 * 1000000007 + h3[i];
	for(int i = 0; i <= H - R; i++) { 
		for(int j = 0; j <= W - C; j++) {
			if(h2[i][j] == h4) printf("%d %d\n", i, j);
		}
	}
}

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

int main(int, char**) {
        int S, W;
        std::cin >> S >> W;
        if (W >= S) {
                std::cout << "unsafe" << std::endl;
        } else {
                std::cout << "safe" << std::endl;
        }
        return 0;
}


Measured memory_bytes: 3632
# Problem D - String Equivalence

from collections import deque

# input
N = int(input())

char_list = [chr(i) for i in range(97, 97+26)]

def dfs(a_list, a_len):
    if a_len==N:
        print("".join(a_list))
        return
    else:
        biggest = 97
        count = len(set(a_list)) # N<=10だからさほど時間はかからない
        for c in range(biggest, biggest + count + 1):
            ch = chr(c)
            a_list.append(ch)
            dfs(a_list, a_len+1)
            a_list.pop()

# initialization
a_nums = deque([])

# dfs search
dfs(a_nums, 0)


Measured memory_bytes: 4764
from math import sqrt, atan2
def intersection01(cx, cy, r, x1, y1, x2, y2):
    xd = x2 - x1; yd = y2 - y1
    X = x1 - cx; Y = y1 - cy
    a = xd**2 + yd**2
    b = xd * X + yd * Y
    c = X**2 + Y**2 - r**2
    D = b**2 - a*c
    result = []
    if D > 0:
        d = sqrt(D)
        if 0 < -b - d < a:
            s = (-b - d) / a
            result.append((x1 + xd*s, y1 + yd*s))
        if 0 < -b + d < a:
            s = (-b + d) / a
            result.append((x1 + xd*s, y1 + yd*s))
    elif D == 0:
        if 0 < -b < a:
            s = -b / a
            result.append((x1 + xd*s, y1 + yd*s))
    return result
def calc(x0, y0, x1, y1, rr):
    if x0**2 + y0**2 - rr <= 1e-8 and x1**2 + y1**2 - rr <= 1e-8:
        return (x0 * y1 - x1 * y0) / 2.
    theta = atan2(x0*y1 - x1*y0, x0*x1 + y0*y1)
    return theta*rr/2.

n, r = map(int, input().split())
P = [list(map(int, input().split())) for i in range(n)]

rr = r**2
def solve(xb, yb):
    ans = 0
    for i in range(n):
        x0, y0 = P[i-1]; x1, y1 = P[i]
        x0 -= xb; y0 -= yb
        x1 -= xb; y1 -= yb
        result = intersection01(0, 0, r, x0, y0, x1, y1)
        px = x0; py = y0
        for x, y in result:
            ans += calc(px, py, x, y, rr)
            px = x; py = y
        ans += calc(px, py, x1, y1, rr)
    return ans

x0 = sum(x for x, y in P)/n
y0 = sum(y for x, y in P)/n
ans = solve(x0, y0)
import random
random.seed()
randint = random.randint
for i in range(1000):
    ma = ans; nxt = None
    for j in range(100):
        dx = randint(-1000000, 1000000) / 10000 / (i+1)
        dy = randint(-1000000, 1000000) / 10000 / (i+1)
        res = solve(x0 + dx, y0 + dy)
        if ma < res:
            ma = res
            nxt = (x0 + dx, y0 + dy)
    if nxt is not None:
        ans = ma
        x0, y0 = nxt
print(ans)

Measured memory_bytes: 12008
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        long n = N;
        long[] DP = new long[N];
        long sum = N;
        DP[N-1] = N;
        for(int i=N-2;i>=0;i--){
            long count = 0;
            if(i == N-2){
                count += DP[i+1] + n*(n-1);
                count %= Define.mod;
            }
            else{
                count += (n-1)*(n-1);
                count += sum + Define.mod - DP[i+2] + i + 2;
                count %= Define.mod;
            }
            DP[i] = count;
            sum = (sum + count) % Define.mod;
        }
        sb.Append(DP[0]+"\n");
    }
}
public static class Define{
    public const long mod = 1000000007;
}

Measured memory_bytes: 18656
#include <iostream>
#include <vector>
#include <algorithm>

using ll = long long;
#define MAX 114514

std::vector<ll> fact(MAX + 1);

ll extgcd(ll a, ll b, ll& x, ll& y)
{
    ll d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }
    else {
        x = 1; y = 0;
    }
    return d;
}

ll mod_inverse(ll a, ll m)
{
    ll x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}

ll mod_fact(ll n, ll p, ll& e)
{
    e = 0;
    if (n == 0)
        return 1;

    ll res = mod_fact(n / p, p, e);
    e += n/p;
    if (n / p % 2 != 0)
        return res * (p - fact[n % p]) % p;

    return res * fact[n % p] % p;
}

ll mod_comb(ll n, ll k, ll p)
{
    if (n < 0 || k < 0 || n < k)
        return 0;

    ll e1, e2, e3;
    ll a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n - k, p, e3);
    if (e1 > e2 + e3)
        return 0;

    return a1 * mod_inverse(a2 * a3 % p, p) % p;
}

void init(ll M)
{
    fact[0] = 1;
    for(ll i = 0; i < MAX; i++){
        fact[i + 1] = fact[i] * (i + 1) % M;
    }
}

ll mod(ll x, ll M)
{
    if (x < 0)
        x += M;

    return x % M;
}

int main()
{
    ll N, K;
    constexpr ll M = 1e9 + 7;
    init(M);
    std::cin >> N >> K;
    std::vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        std::cin >> A[i];
    }
    std::sort(A.begin(), A.end());
    ll min_sum = 0;
    ll max_sum = 0;
    for (ll i = 0; i < N; i++) {
        ll w = mod_comb(N - 1 - i, K - 1, M);
        min_sum = mod(min_sum - mod(A[i] * w, M), M);
        max_sum = mod(max_sum + mod(A[N - 1 - i] * w, M), M);
    }
    std::cout << mod(max_sum + min_sum, M) << std::endl;
    return 0;
}


Measured memory_bytes: 1920
import java.io.*;
  
class Main{
	public static void main(String[] args) throws IOException{

		int x,y,d,r;
		double f;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str[] = br.readLine().split(" ");
		x = Integer.parseInt(str[0]);
		y = Integer.parseInt(str[1]);

		d = x / y;
		r = x % y;
		f = 1.0 * x / y;

		System.out.printf("%1d %1d %1.5f",d, r, f);
    	}
}

Measured memory_bytes: 17072
#include <iostream>

using namespace std;


int main(){
    int n,k,x,y;
    cin>>n>>k;
    for(int i=0;i<k;++i){
        cin>>x>>y;
        cout<<(min(min(x,n-x+1),min(y,n-y+1))+2)%3+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3080
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define int long long

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N, K; cin >> N >> K;
    ll dp[110][100000];
	ll sdp[100000];
	ll num[100000];
	vector<ll> vec;
	for(int i = 1; i * i <= N; i++) {
		vec.push_back(i);
		if(i * i != N) vec.push_back(N / i);
	}
	sort(all(vec));
	int M = vec.size();
	num[0] = 1LL;
	rep(i, M - 1) {
		num[i + 1] = vec[i + 1] - vec[i];
	}
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1LL;
	rep(i, K) {
		sdp[0] = 0;
		rep(j,  M) {
			sdp[j + 1] = sdp[j] + dp[i][j];
			sdp[j + 1] %= mod;
		}
		rep(j, M) {
			dp[i + 1][j] = sdp[M - j] * num[j] % mod;
		}
	}
	ll ans = 0;
	rep(j, M) {
		(ans += dp[K][j]) %= mod;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	int h,w,d,n,a;
	while(cin >> h >> w >> d,h){
		cin >> n;
		for(int i = 0;i < n;++i){
			cin >> a;
			a *= 2;
			if((a * a > w * w + d * d) || (a * a > h * h + w * w) || (a * a > h * h + d * d)){
				cout << "OK" << endl;
			}
			else cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <utility>
#include <set>
#include <vector>
#include <functional>
#include <map>
#include <queue>
using namespace std;
int main()
{
  int A,B,C;
  cin>>A>>B>>C;
  puts((A+B>=C)?"Yes":"No"); 
  //system("pause");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    char s[n+1];
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }
    int c=0;
    for(int i=0;i<n-1;i++)
    {
        if(s[i]!=s[i+1])
        {
            c++;
        }
    }
    cout<<c+1;
}


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

int n,m;
vector<int> b;
vector<vector<int> > A;

int main(){
    cin>>n>>m;
    A.resize(n);
    for(int i=0;i<n;++i){
        A[i].resize(m);
        for(int j=0;j<m;++j){
            int num;
            cin>>num;
            A[i][j]=num;
        }
    }
    b.resize(m);
    for(int i=0;i<m;++i){
        int num;
        cin>>num;
        b[i]=num;
    }

    for(int i=0;i<n;++i){
        int ci=0;
        for(int j=0;j<m;++j){
            ci+=A[i][j]*b[j];
        }
        cout<<ci<<endl;
    }
    return 0;
}


Measured memory_bytes: 3140
n,m=map(int,input().split())
a1=set()
an=set()
for i in range(m):
    ai,bi=map(int,input().split())
    if ai==1:
        a1.add(bi)
    elif bi==n:
        an.add(ai)

if len(a1&an)==0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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 ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  ll cnt=0;
  vll a(n);
  ll min=INF;
  ll sum=0;
  rep(i,n){
    cin>>a[i];
    if(a[i]<0){
      cnt++;
    }
    chmin(min,abs(a[i]));
    sum+=abs(a[i]);
  }
  if(cnt%2){
    cout<<sum-min*2<<endl;
  }
  else{
    cout<<sum<<endl;
  }
  
}


Measured memory_bytes: 1024
N,M = list(map(int,input().split()))
list_dis = []
import math
total = 0
for i in range(N):
    list_dis.append(list(map(int,input().split())))
for i in range(N-1):
    A = list_dis[i]
    for j in range(N-1-i):
        f_total = 0
        B = list_dis[N-j-1]
        for k in range(M):
            f_total += abs(A[k]-B[k]) ** 2
        f_total = math.sqrt(f_total)
        if f_total.is_integer() == True:
            total += 1
print(total)

Measured memory_bytes: 3064
import itertools
N = int(input())
SL = [input()[0] for i in range(N)]

M = SL.count("M")
A = SL.count("A")
R = SL.count("R")
C = SL.count("C")
H = SL.count("H")

l = [M,A,R,C,H]
ans = 0
for i in list(itertools.combinations(l,3)):
  ans += i[0]*i[1]*i[2]
  
print(ans)

Measured memory_bytes: 3968
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

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

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007
#1_A
"""
import math

n = int(input())
m = n
ans = []
i = 2
k = math.sqrt(n)
while i <= k:
    if n%i == 0:
        n = n//i
        ans.append(i)
        i -= 1
        if n == 1:
            break
    i += 1
if len(ans) == 0 or n != 1:
    ans.append(n)
print(m,end = ": ")
for i in range(len(ans)-1):
    print(ans[i], end = " ")
print(ans[-1])
"""

#1_B
"""
m,n = map(int, input().split())
b = bin(n)[2:]
num = [m]
for i in range(len(b)-1):
    num.append(num[-1]**2%1000000007)
ans = 1
for i in range(len(b)):
    ans *= num[i] if b[len(b)-1-i] == "1" else 1
    ans %= 1000000007
print(ans)
"""

#1_C
"""
import math

l = int(input())
a = list(map(int, input().split()))
dict = {}
for n in a:
    ans = []
    i = 2
    k = math.sqrt(n)
    dic = {}
    while i <= k:
        if n%i == 0:
            n = n//i
            ans.append(i)
            i -= 1
            if n == 1:
                break
        i += 1
    if len(ans) == 0 or n != 1:
        ans.append(n)
    for i in ans:
        if i in dic:
            dic[i] += 1
        else:
            dic[i] = 1
    for i in dic.keys():
        if i in dict:
            dict[i] = max(dict[i], dic[i])
        else:
            dict[i] = dic[i]
sum = 1
for x,y in dict.items():
    sum *= x**y
print(sum)
"""

#1_D
"""
import math

n = int(input())
m = n
ans = []
i = 2
k = math.sqrt(n)
dic = {}
while i <= k:
    if n%i == 0:
        n = n//i
        ans.append(i)
        i -= 1
        if n == 1:
            break
    i += 1
if len(ans) == 0 or n != 1:
    ans.append(n)
ans = list(set(ans))
sum = m
for i in ans:
    sum *= (1-1/i)
print(int(sum))
"""

#1_E
"""
def gcd(a,b):
    if a==0:
        return b
    return gcd(b%a,a)
a,b = LI()
g = gcd(a,b)
a//=g
b//=g
if b == 1:
    print(0,1)
    quit()
if b < 4:
    f = b-1
else:
    p = []
    x = 2
    m = b
    while x**2 <= b:
        if not m%x:
            p.append(x)
            while not m%x:
                m//=x
        x += 1
    if m != 1:p.append(m)
    f = b
    for i in p:
        f *= (1-1/i)
    f = int(f)
x_ = pow(a,f-1,b)
y_ = (1-a*x_)//b
ans = [x_,y_,abs(x_)+abs(y_)]
for i in range(-10000,10000):
    s = -b*i+x_
    t = a*i+y_
    m = abs(s)+abs(t)
    if m < ans[2]:
        ans = [s,t,m]
    elif m == ans[2] and s <= t:
        ans = [s,t,m]
print(ans[0],ans[1])
"""

#2
#2-A
a,b = LI()
print(a+b)



Measured memory_bytes: 8484
// finish date: 2018/01/10
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int i=a;i<b;i++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long

bool isExist(char c, string str) {
    rep(i, str.length()) {
        if (c == str[i]) return true;
    }
    return false;
}

int fact(int n) {
    int ans = 1;
    FOR(i, 1, n + 1) {
        ans *= i;
    }
    return ans;
}

int main() {
    string s;
    cin>>s;
    rep(i,s.length()) cout << ((s[i]!=',')?s[i]:' ');
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    ll L, R; cin >> L >> R;
    ll ans = 1LL<<59;

    for(ll i=L; i<=min(R, L+2019); ++i){
        for(ll j=i+1; j<=min(R, i+2020); ++j){
            chmin(ans, (i*j)%2019);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+5,M=2e6+5,MOD=1e9+7,OO=1e9;

struct train
{	
	int c,s,f;
};
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();

	int n;

	scanf("%d",&n);

	std::vector<train> a(n);

	for(int i=0;i<n-1;i++)scanf("%d %d %d",&a[i].c,&a[i].s,&a[i].f);

	for(int i=0;i<n-1;i++){
		int curr = a[i].s;
		for(int j=i;j<n-1;j++){
			curr = max(curr,a[j].s);
			while(curr%a[j].f)curr++;
			curr+=a[j].c;
		}
		printf("%d\n",curr );
	}
	printf("0\n");
}


Measured memory_bytes: 256
x,y,z = map(int,input().split())

def Seekmin(x,y,z):
  min = x + y
  if x+y <= y+z and x+y <= x+z:
    return x+y
  elif x+y >= y+z and z+y <= x+z:
    return y+z
  else:
    return x+z
  
print(Seekmin(x,y,z))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
inline long long in(){long long x=0;char c=getchar();bool neg=false;while(c!='-'&&('0'>c||c>'9')) c=getchar();if(c=='-') neg=true,c=getchar();while('0'<=c&&c<='9') x=10*x+c-'0',c=getchar();if(neg) x=-x;return x;}
inline void out(long long x){if(x<0) putchar('-'),x=-x;if(x>9) out(x/10);putchar(x%10+'0');}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define task "N"
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define _ putchar(' ')
#define __ putchar('\n')
const int N=1010;
int n;
int a[N],s[N];
int f[N][N];
int F(int l,int r)
{
    if(l==r) return 0;
    if(f[l][r]>-1) return f[l][r];
    int ans=1e18;
    forinc(i,l,r-1)
    {
        ans=min(ans,F(l,i) + F(i+1,r) + s[r]-s[l-1]);
    }

    return f[l][r]=ans;
}
main()
{
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    cin>>n;
    forinc(i,1,n) cin>>a[i],s[i]=s[i-1]+a[i];
    reset(f,-1);
    cout<<F(1,n);
}


Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,m;cin>>n>>m;
  if(abs(n-m)>1){
    cout <<0<<endl;
    return 0;
  }
  int64_t num=min(n,m);
  int64_t mod=1000000007;
  int64_t ans=1;
  if(n==m)ans=2;
  for(int64_t i=0;i<num;i++){
    ans*=(n-i);
    ans%=mod;
    ans*=(m-i);
    ans%=mod;
  }
  cout <<ans<<endl;
}

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

int main(){
  int N;
  string s;
  cin >> N >> s;
  int T_W= 0;
  for (int i=0; i<N; i++){if (s.at(i) == 'W'){T_W += 1;}}
  int T_R= N-T_W;
  int t_w = 0;
  int i = 0;
  int t_r = T_R;
  while (t_w < t_r){
    if (s.at(i) == 'W'){t_w += 1;} else{t_r -= 1;}
    i++;
  }
  cout << t_w;
}

Measured memory_bytes: 3392
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	int k;
	int n;
	cin >> k;
	n = k%10;

	if (n == 3) {
		cout << "bon";
		return 0;
	}
	else if (n == 0 || n == 1 || n == 6 || n == 8) {
		cout << "pon";
		return 0;
	}
	else {
		cout << "hon";
	}
	return 0;
}

Measured memory_bytes: 3596
#include <cstdio>
#include <algorithm>
#include <queue>
#include <climits>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#define f first
#define s second
#define mp make_pair

inline int getInt(){ int s; scanf("%d", &s); return s; }

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

using namespace std;

struct Edge{
  int cap; // capacity
  int to;
  int rev; // reverse edge id

  Edge(){}
  Edge(int c, int t, int r) :
    cap(c), to(t), rev(r){}
};

struct CostEdge : public Edge{
  int cost;
  CostEdge() : Edge() {}
  CostEdge(int c, int t, int cs, int r) :
    Edge(c, t, r), cost(cs){}
};
  
template<class E> // Edge type
class Graph{
public:
  typedef std::vector<std::vector<E> > G;

private:
  G g;

public:
  Graph(int n) : g(G(n)) {}

  void addEdge(int from, int to, int cap){
    g[from].push_back(E(cap, to, g[to].size()));
    g[to].push_back(E(0, from, g[from].size() - 1));
  }

  void addEdge(int from, int to, int cap, int cost){
    g[from].push_back(E(cap, to, cost, g[to].size()));
    g[to].push_back(E(0, from, -cost, g[from].size() - 1));
  }

  G &getRowGraph(){
    return g;
  }
};

template<class E>
int minCostFlow(Graph<E> &graph, int s, int t, int f){
  typename Graph<E>::G &g = graph.getRowGraph();
  int n = g.size();
  int res = 0;
  vector<int> prevv(n);
  vector<int> preve(n);
  const int inf = 200000000;
  
  while(f > 0){
    vector<int> dist(n, inf);
    dist[s] = 0;
    
    bool update = true;
    
    while(update){
      update = false;
      for(int v = 0; v < n; v++){
	if(dist[v] == inf) continue;
	for(int i = 0; i < (int)g[v].size(); i++){
	  E &e = g[v][i];
	  if(e.cap > 0 && dist[e.to] > dist[v] + e.cost){
	    dist[e.to]  = dist[v] + e.cost;
	    prevv[e.to] = v;
	    preve[e.to] = i;
	    update      = true;
	  }
	}
      }
    }
    
    if(dist[t] == inf){
      return -1;
    }
    
    int d = f;
    for(int v = t; v != s; v = prevv[v]){
      d = min(d, g[prevv[v]][preve[v]].cap);
    }
    
    f   -= d;
    res += d * dist[t];
    
    for(int v = t; v != s; v = prevv[v]){
      E &e = g[prevv[v]][preve[v]];
      e.cap           -= d;
      g[v][e.rev].cap += d;
    }
  }
  return res;
}

int main(){
  int m = getInt();
  int n = getInt();
  int k = getInt();

  vector<int> w(n);
  vector<int> a(k);

  Graph<CostEdge> g(k);

  REP(i,n) w[i] = getInt();
  REP(i,k) a[i] = getInt() - 1;

  int ans = 0;
  REP(i,k) ans += w[a[i]];

  vector<int> prevs(n, -1);

  REP(i,k){
    if(i != k - 1) g.addEdge(i, i + 1, 10000, 0);
    int aa = a[i];
    if(prevs[aa] != -1){
      int j = prevs[aa];
      if(j + 1 == i){
	ans -= w[a[i]];
      }else{
	g.addEdge(j + 1, i, 1, - w[a[i]]);
      }
    }
    prevs[aa] = i;
  }

  ans += minCostFlow(g, 0, k - 1, m - 1);

  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdio>
using namespace std;

int h,w;
int sx,sy,gx,gy;
char rec[1000][1000];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int used[1001][1001];

bool check(int x, int y){
  return x >= 0 && y >= 0 && x < w && y < h && rec[y][x] != 'X' 
    && used[y][x] == 0;
}

int bfs(int p){
  queue<pair<int,int> > que;
  que.push(make_pair(sy,sx));
  for(int i=0; i<1001; i++)
    for(int j=0; j<1001; j++)
      used[i][j] = 0;
  
  while(!que.empty()){
    pair<int,int> pos = que.front();
    for(int i=0; i<4; i++){
      int yy = pos.first + dy[i];
      int xx = pos.second + dx[i];

      if(check(xx,yy)){
	que.push(make_pair(yy,xx));
	used[yy][xx] = used[pos.first][pos.second] + 1;
      }
         
      if(rec[yy][xx] == p + '0'){
	sx = xx;
	sy = yy;
	return used[sy][sx];
      }
    }
    que.pop();
  }
}

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

  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin>>rec[i][j];
      if(rec[i][j] == 'S'){
	sy = i;
	sx = j;
      }
    }
  }

  int res = 0;

  for(int i=1; i<=n; i++) {
    res += bfs(i);
  }
  cout<<res<<endl;

  return 0;
  
}

Measured memory_bytes: 6108
n=int(input())
cnt=0
# c(i,j)={先頭がiで末尾がjであるkの個数}
c=[[0 for _ in range(10)] for _ in range(10)]
for i in range(1,n+1):
  l=int(str(i)[0])
  r=int(str(i)[-1])
  c[l][r]+=1
'''
for i in range(10):
  for j in range(10):
    print(c[i][j], end=' ')
  print('')
'''
sum=0
for i in range(1,10):
  for j in range(1,10):
    sum+=c[i][j]*c[j][i]
print(sum)

Measured memory_bytes: 3064
import sys
import bisect
from functools import lru_cache
from collections import defaultdict
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
s=input()
t=input()
max=10000
for i in range(len(s)-len(t)+1):
    num=0
    for j in range(len(t)):
        if(t[j]!=s[i+j]):
            num+=1  
    if num<max:
        max=num
print(max) 

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

using namespace std;
using ll = long long;

int f(ll a, ll b){
    ll x = max(a,b);
    int ans=0;
    while(x>0){
        x = x/10;
        ans++;
    }
    return ans;
}

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

    int ans=f(n,1);

    for(ll a=1; a*a<=n; a++){
        if(n%a != 0)continue;

        ll b=n/a;
        int cur=f(a,b);

        if(ans>cur)ans=cur;
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
strong :: String -> Bool
strong s = s == reverse s
           && firstS == reverse firstS
           && secondS == reverse secondS
                where
                    firstS = take half1 s
                    secondS = take half1 $ reverse s
                    half1 = ((length s) - 1) `div` 2

main = do
    s <- getLine
    if strong s then putStrLn "Yes"
                else putStrLn "No"

Measured memory_bytes: 508
#include <iostream>

using namespace std;

template<class T>
T chMax(T &a, const T b) { if (a < b) { return a = b; }}

int dp[3005][3005] = {0};

int main() {
    string s, t;
    cin >> s >> t;
    int ss = s.size(), ts = t.size();
    for (int i = 0; i < ss; ++i)
        for (int j = 0; j < ts; ++j) {
            int tmp = max(dp[i + 1][j], dp[i][j + 1]);
            if (s[i] == t[j]) chMax(tmp, dp[i][j] + 1);
            dp[i + 1][j + 1] = tmp;
        }

    int y = ss, x = ts;
    string res = "";
    while (y > 0 && x > 0) {
             if (dp[y][x - 1] == dp[y][x])x--;
        else if (dp[y - 1][x] == dp[y][x])y--;
        else {x--;y--;res=s[y]+res;}
    }
    cout << res << endl;
}


Measured memory_bytes: 35456
#include<queue>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
double dis[1007][1007];
double r[1007],x[1007],y[1007];
double ds[1007];
bool vis[1007];
int n;
priority_queue<pair<double,int > > q;
void dijkstra()
{
  for(int i=1;i<=n;i++)
  ds[i]=1e10;
  ds[1]=0;
  q.push(make_pair(0,1));
  while(q.size())
  {
   int u=q.top().second;
   q.pop();
   if(vis[u]) continue;
   vis[u]=1;
   for(int i=1;i<=n;i++)
   {
   	 if(i==u) continue;
   	 if(ds[u]+dis[u][i]<ds[i])
   	 {
   	    ds[i]=ds[u]+dis[u][i];
   	    q.push(make_pair(-ds[i],i));
   	 }
   }
  }
  
	
}
int main()
{
 while(scanf("%lf%lf%lf%lf",&x[1],&y[1],&x[2],&y[2])!=EOF)
 {
   memset(vis,0,sizeof(vis));
   scanf("%d",&n);
   n+=2;
   for(int i=3;i<=n;i++)
   scanf("%lf%lf%lf",&x[i],&y[i],&r[i]);
   r[1]=r[2]=0;
   for(int i=1;i<=n;i++)
   {
    for(int j=1;j<=n;j++)
    {
      	double tmp=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
      	tmp-=r[i]+r[j];
      	if(tmp<0)
      	dis[i][j]=0;
      	else dis[i][j]=tmp;
    }
   }
   dijkstra();
   printf("%.10lf\n",ds[2]);
 }
 return 0;	
}

Measured memory_bytes: 14320
#include<stdio.h>
#include<math.h>

int main(void){
    double x1, y1, x2, y2;
    scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
    printf("%lf\n", sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
}


Measured memory_bytes: 2100
#include <iostream>
using namespace std;
int main() {
	int a,b;
	cin >> a >> b;
	if (a<b) {
		cout << "a < b" <<endl;
	} else 
	if (a>b) {
		cout << "a > b" <<endl;
	}
	if (a==b) {
		cout << "a == b" <<endl;
	}
	return 0;
	}


Measured memory_bytes: 3060
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: i64,
        k: i64,
    }

    let zero = n / k;
    let half = (n + k / 2) / k;

    let ans = zero * zero * zero + if k % 2 == 0 { half * half * half } else { 0 };

    println!("{}", ans);
}


Measured memory_bytes: 4352
// This template code suggested by KT BYTE Computer Science Academy
//   for use in reading and writing files for USACO problems.

// https://content.ktbyte.com/problem.java

import java.util.*;
import java.io.*;

public class Main {

    static StreamTokenizer in;

    static int nextInt() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    static double nextDouble() throws IOException {
        in.nextToken();
        return in.nval;
    }

    public static void main(String[] args) throws Exception {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        int n = nextInt();

        double[] probabilities = new double[n];

        for (int i = 0; i < n; i++) {
            probabilities[i] = nextDouble();
        }

        double[][] dp = new double[n + 1][n + 1]; // coins, and the number of heads = probabilities

        dp[0][0] = 1.0;

        for (int i = 1; i <= n; i++) {
            for (int j = 0; j <= i; j++) {
                if (j - 1 >= 0) dp[i][j] = dp[i-1][j-1] * probabilities[i - 1];
                dp[i][j] += dp[i-1][j] * (1 - probabilities[i - 1]);
            }
        }

        double result = 0;

        for (int j = 0; j <= n; j++) {
            if (j > n - j) {
                result += dp[n][j];
            }
        }

        out.println(result);

        out.close();
    }
}




Measured memory_bytes: 105224
#include <algorithm>
#include<cfenv>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include<numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
using namespace std;
typedef long long llong;
vector<llong> AllDivisors(llong N) {
	vector<llong> ANS;
	for (llong i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			ANS.push_back(i);
			if (N / i != i)ANS.push_back(N / i);
		}
	}
	sort(ANS.begin(), ANS.end());
	return ANS;
}
bool IsPrime(llong N) {
	for (llong i = 2; i * i <= N; i++) {
		if (N % i == 0) return false;
	}
	return true;
}
//ここまで共通
int N;
vector<string> S;
int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		S.push_back(s);
	}
	sort(S.begin(), S.end());
	int ans = 1;
	for (int i = 1; i < N; i++) {
		if (S[i] != S[i - 1]) {
			ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 11568
n = int(input())
a = list(map(int,input().split()))
if n%2 == 0:
  a.append(-float("inf"))
  n += 1
if n == 3:
  print(max(a))
  exit()
p0 = a[0]
z0 = -float("inf")
z1 = a[1]
y0 = a[0]+a[2]
y1 = -float("inf")
y2 = a[2]
x0 = -float("inf")
x1 = max(p0,z1)+a[3]
x2 = -float("inf")
for i in range(4,n-1):
  w0 = y0+a[i]
  w1 = max(y1,z0)+a[i]
  w2 = max(y2,z1,p0)+a[i]
  p0 = z0
  z0 = y0
  z1 = y1
  y0 = x0
  y1 = x1
  y2 = x2
  x0 = w0
  x1 = w1
  x2 = w2
w0 = y0+a[n-1]
w1 = max(y1,z0)+a[n-1]
w2 = max(y2,z1,p0)+a[n-1]
print(max(y0,x1,w2))

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veaci;
typedef vector<long long> vecll;
typedef vector<unsigned long long> vecull;


ll H, W;
int main(void) {
    cin >> H >> W;

    ll best = H * W;
    REP(i, 1, H) {

        ll h = H - i;

        ll a = W * i;

        ll b = W / 2 * h;
        ll c = W / 2 * h;
        if (W % 2 != 0) b += h;

        best = min(best, max(a, max(b, c)) - min(a, min(b, c)));

        b = h / 2 * W;
        c = h / 2 * W;
        if (h % 2 != 0)
            b += W;

        best = min(best, max(a, max(b, c)) - min(a, min(b, c)));
    }

    REP(i, 1, W) {

        ll w = W - i;

        ll a = H * i;

        ll b = w / 2 * H;
        ll c = w / 2 * H;
        if (w % 2 != 0)
            b += H;

        best = min(best, max(a, max(b, c)) - min(a, min(b, c)));

        b = H / 2 * w;
        c = H / 2 * w;
        if (H % 2 != 0)
            b += w;

        best = min(best, max(a, max(b, c)) - min(a, min(b, c)));
    }

    cout << best << endl;
    return 0;
}

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

def solve():
    n, k = map(int, input().split())
    if n % 2 == 1:
        print("YES" if (n // 2 + 1) >= k else "NO")
    else:
        print("YES" if (n // 2) >= k else "NO")

if __name__=="__main__":
    solve()


Measured memory_bytes: 2940
a = input()
l = map(int, raw_input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

def gcd(l):
	l = sorted(l, reverse=True)
	l1 = make_divisors(l[0])
	l2 = make_divisors(l[1])
	l_mix = list(set(l1 + l2))
	l_mix = sorted(l_mix)
	r = 0
	for i in l_mix:
		f = 0
		for j in l:
			if j % i != 0:
				f += 1
			if f > 1:
				break
		if f <= 1:
			r = i
	return r 

print gcd(l)

Measured memory_bytes: 11324
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a[20];
ll dfs(int l,int r,int x,int y) {
	if(l+1>=r) return 0;
	ll ans=1e18;
	for(int i=l+1;i<r;i++) {
		ans=min(ans,dfs(l,i,x,x+y)+dfs(i,r,x+y,y)+a[i]*(x+y));
	}
	return ans;
}
int main() {
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	printf("%lld\n",a[1]+a[n]+dfs(1,n,1,1));
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
   int i,n=0,ra=700;
   char s[4];

   scanf("%s",s);

   for(i=0;i<3;i++){
     if(s[i]=='o')
       n += 1;
   }
   ra += n*100;

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


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Solve s= new Solve();
		s.solve();
	}

}
class Solve{
	 Scanner sc = new Scanner(System.in) ;

	 void solve() {
		 long A = sc.nextLong();
		 long B = sc.nextLong();
		 long C = sc.nextLong();
		 long D = sc.nextLong();

		 long last_d=0;
		 long last_cd=0;
		 long last_c,first_c,first_d,first_cd;

		 long gcd=getGCD(C,D);
		 long lcm=getLCM(C,D,gcd);
		 if(B%C==0) {
			 last_c=B/C;
		 }else {
			 last_c=B/C;
		 }
		 if(A%C==0) {
			 first_c=A/C;
		 }else {
			 first_c=A/C+1;
		 }

		 if(B%D==0) {
			 last_d=B/D;
		 }else {
			 last_d=B/D;
		 }
		 if(A%D==0) {
			 first_d=A/D;
		 }else {
			 first_d=A/D+1;
		 }

		 if(B%lcm==0) {
			 last_cd=B/lcm;
		 }else {
			 last_cd=B/lcm;
		 }
		 if(A%lcm==0) {
			 first_cd=A/lcm;
		 }else {
			 first_cd=A/lcm+1;
		 }



		 long c=last_c-first_c+1;
		 long d=last_d-first_d+1;
		 long cd=last_cd-first_cd+1;
		 long res=c+d-cd;


	//	 System.out.println(last_d);


		 System.out.println(B-A+1-res);
	}
	 private static long getGCD(long a,long b) {

		 if(b==0) return a;
			 return getGCD(b,a%b);
	 }
	 private static long getLCM(long a,long b,long gcd) {

		 return a*b/gcd;

		 }
}

Measured memory_bytes: 23892
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
for i in range(n):
    a,b=map(int,input().split())
    if ans < a:
        ans = a; mans = b
print(ans+mans)

Measured memory_bytes: 42348
import fractions


N, K = map(int, input().split())
A = list(map(int, input().split()))
if K in A:
    print("POSSIBLE")
    exit()
temp = A[0]
for a in A:
    temp = fractions.gcd(temp, a)
if temp == 1:
    if K <= max(A):
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
else:
    if K > max(A):
        print("IMPOSSIBLE")
    elif K % temp == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


Measured memory_bytes: 16240