akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <stdio.h>
#include <vector>
#include <functional>
#include <unordered_set>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;

int main()
{
	long long k, a, b;
	cin >> k >> a >> b;
	if (k <= (a - 1)) {
		cout << 1 + k << endl;
		return 0;
	}
	k -= (a - 1);

	// starts with <a, 0>
	long long answer = a + k;
	if (b - a > 1) {
		long long cnt = k / 2;
		answer = max(answer, cnt * (b - a) + a + (k - 2 * cnt));
	}
	cout << answer << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<int,int>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i,n) for (ll i=(ll)n-1;i>=0;i--)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
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; }
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
#define INF 1<<30
#define INFTY 1LL<<60
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}//最大公約数
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}//最小公倍数
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
const int MOD = 1000000007;

inline ll mod_add(ll a,ll b){return (a+b)%MOD;}
inline ll mod_sub(ll a,ll b){return (a+MOD-b)%MOD;}
inline ll mod_mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;
x=x*x%mod;n>>=1;}return res;}
inline ll mod_inv(ll x){return mod_pow(x,MOD-2);}
inline ll mod_div(ll a, ll b){return mod_mul(a,mod_inv(b));}
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back
int h,w,d;
int A[310][310];
int q;
int cost[MAX6];
int main(){
    cin>>h>>w>>d;
    int n=h*w;
    map<int,P>m;
    rep(i,h)rep(j,w){
        cin>>A[i][j];
        m[A[i][j]-1]=P(i,j);
    }
    CLR(cost);
    rep(i,n){
        cost[i+d]=cost[i]+abs(m[i].fi-m[i+d].fi)+abs(m[i].se-m[i+d].se);
    }

    cin>>q;
    rep(i,q){
        int l,r;cin>>l>>r;
        cout<<cost[r-1]-cost[l-1]<<endl;
    }
}

Measured memory_bytes: 19152
import sys

A = input()
B = input()

if len(A)>len(B):
    print("GREATER")
elif len(A)<len(B):
    print("LESS")
else:
    for i in range(len(A)):
        if int(A[i])>int(B[i]):
            print("GREATER")
            sys.exit()
        elif int(A[i])<int(B[i]):
            print("LESS")
            sys.exit()
        else:
            continue
    else:
        print("EQUAL")

Measured memory_bytes: 9188
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() int {
	sc.Scan()
	data, _ := strconv.Atoi(sc.Text())
	return data
}

func main() {
	sc.Scan()
	input := sc.Text()

	switch input {
	case "A":
		fmt.Print("T")
	case "T":
		fmt.Print("A")
	case "C":
		fmt.Print("G")
	case "G":
		fmt.Print("C")
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int a,b,c;
  cin >> a >>b >> c;
  swap(a,b);
  swap(a,c);
  cout << a << " " << b << " " << c << endl;
  return 0;
}


Measured memory_bytes: 256
//#pragma GCC target ("avx2")
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long

using namespace std;
using namespace __gnu_pbds;

template <class T> using ordered_set =
tree<T, null_type, less<T>,
rb_tree_tag, tree_order_statistics_node_update>;

const int N = (int)(1e3 + 5);
const int M = (int)(1e9 + 7);
const int INF = (int)(1e18 + 9);
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};

char a[N][N];
int d[N][N];
bool used[N][N];

signed main() {
  ios_base :: sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j)
      cin >> a[i][j];
  }
  queue <pair <int, int> > q;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (a[i][j] == '#') {
        q.push(make_pair(i, j));
        used[i][j] = 1;
      }
    }
  }
  while (!q.empty()) {
    int i = q.front().first;
    int j = q.front().second;
    q.pop();
    for (int k = 0; k < 4; ++k) {
      if (a[i + dx[k]][j + dy[k]] == '.' && !used[i + dx[k]][j + dy[k]]) {
        used[i + dx[k]][j + dy[k]] = 1;
        d[i + dx[k]][j + dy[k]] = d[i][j] + 1;
        q.push(make_pair(i + dx[k], j + dy[k]));
      }
    }
  }
  int ret = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (a[i][j] == '.')
        ret = max(ret, d[i][j]);
    }
  }
  cout << ret;
  return 0;
}


Measured memory_bytes: 19856
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    String S = sc.next();
    int ok = 0;
    for(int i = 0; i < N-2; i++) {
      if (S.substring(i,i+1).equals("A")) {
        if (S.substring(i,i+3).equals("ABC")) {
          ok++;
        }
      }
    }
    sc.close();

    System.out.println(ok);
  }
}
    


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

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

	int w,h;

	cin >> w >> h;

	cout << (w*h) - w - h + 1 << '\n';
	
	return 0;	
}


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

int main() {
    long long n;
    cin >> n;
    string s;
    cin >> s;
    long long r = 0, g = 0, b = 0;
    cin >> r >> g >> b;
    for(long long i = 0;i< n; i++){
        if(s[i] =='R')r++;
        else if(s[i] == 'G')g++;
        else b++;
    }
    long long k = 0;
    for(long long i = 0; i < n; i++){
        for(long long j = i + 1; j < n; j++){
            if(s[i] != s[j] && (2*j - i) < n){
                if(s[2*j - i] != s[j] && s[2*j - i] != s[i])
                    k++;
            }
        }
    }
   // cout << r << " " << g << "  " << b << " " << k << endl;
    cout << r*g*b - k << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int A[100000];

int main()
{
  int i,j,n,m;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
    }

  m=partition(0,n-1);

  for(i=0;i<n;i++)
    {
      if(i!=0)
        {
          printf(" ");
        }
      if(i==m)
        {
          printf("[");
        }
      printf("%d",A[i]);
      if(i==m)
        {
          printf("]");
        }
    }
  printf("\n");

  return 0;
}
 

int partition(int p,int r)
{
  int i,j,x,a;

  x=A[r];
  i=p-1;
  
  for(j=p;j<r;j++)
    {
      if(A[j]<=x)
        {
           a=A[j];
          A[j]=A[i+1];
          A[i+1]=a;
          i++;
        }
    }
          a=A[i+1];
          A[i+1]=A[r];
          A[r]=a;
        
    
   return i+1;
}


Measured memory_bytes: 2172
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int A[200005];
int32_t main(){
	boost;
	//freopen(".in","r",stdin);
	int n,k,ans=0;
	cin>>n>>k;
	for (int i = 0; i < n; ++i)
		cin>>A[i],ans=max(ans,A[i]);
	int l=1,r=INF;
	while(l<=r){
		int med=(l+r)>>1,rem=k,f=1;
		for (int i = 0; i < n; ++i)
		{
			if((((A[i]+med-1)/med )-1)>rem){f=0;break;}
			rem-=(((A[i]+med-1)/med )-1);
		}
		if(f)r=med-1,ans=min(ans,med);
		else l=med+1;
	}
	cout<<ans<<"\n";
	return 0;
}

//do smth instead of nothing and stay organized
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 5144
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
h = 0
D = 100000000
for x in H:
    d = abs(T - x * 0.006 - A)
    if D > d:
        D = d
        h = x
print(H.index(h) + 1)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};

typedef unsigned long long ull;

int main(){
    int N, M, A;
    while(std::cin >> N >> M >> A, N){
        A--;

        int amida[100][1001];
        REP(i, N){
            REP(j, 1001){
                amida[i][j] = -1;
            }
        }

        REP(i, M){
            int from, to, h;
            std::cin >> h >> from >> to;
            from--; to--;

            amida[from][1000-h] = to;
            amida[to][1000-h] = from;
        }

        int n = A, height = 0;
        while(height <= 1000){
            if(amida[n][height] != -1){
                n = amida[n][height];
                height++;
            }else{
                height++;
            }
        }

        std::cout << n+1 << std::endl;
    }
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B >> C;
    map<int, int> nums;
    nums[A]++;
    nums[B]++;
    nums[C]++;
    if (nums[A] == 2 || nums[B] == 2 || nums[C] == 2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

int acgt(string s){
  for(int i=0; i<s.size(); i++){
    if(s[i] !='A' && s[i] != 'C' && s[i] !='G' && s[i] != 'T'){
      return 0;
    }
  }
  return s.size();
}

int main(){

  string s;
  cin >> s;
  int ans = 0;
  int leng = s.size();
  for(int i=0; i<leng; i++){
    for(int j=1; j<=leng-i; j++){
      string s_ = s.substr(i,j);
      ans = max(ans,acgt(s_));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

N = int(input().split()[0])
xlt_list = []

for _ in range(N):
    x, l = list(map(int, input().split()))
    xlt_list.append((x, l, x + l))

xlt_list = sorted(xlt_list, key=lambda x: x[2])
count = 0
before_t = -float("inf")
for i, xlt in enumerate(xlt_list):
    x, l, t = xlt
    if x - l >= before_t:
        count += 1
        before_t = t

ans = count
print(ans)


Measured memory_bytes: 23036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

constexpr ll MOD {998244353};
const int MAX {510000};

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long m) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % m;
    a = a * a % m;
    n >>= 1;
  }

  return res;
}

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

  COMinit();

  ll N,M,K;
  cin >> N >> M >> K;

  ll ans = 0;
  for (ll k = 0; k <= K; ++k) {
    ll c = COM(N-1, k);
    ll rem = modpow(M-1, N-1-k, MOD);
    ans += (c * M % MOD) * rem % MOD;
    ans %= MOD;
  }

  cout << ans << endl;
}

Measured memory_bytes: 15604
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>

#define int long long
#define double long double
#define endl '\n'
#define gcd __gcd
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(), x.end()
const int inf = __LONG_LONG_MAX__;

using namespace std;

void fast_io() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}

bool eq(vector<int>& a, vector<int>& b) {
	for (int i = 0; i < a.size(); i++)
		if (a[i] != b[i])
			return false;
	return true;
}

signed main() {
  fast_io();

  int n;
  cin >> n;

  vector<int> v(n);
  for (int i = 0; i < n; i++)
  	v[i] = i + 1;

  vector<int> p1(n);
  vector<int> p2(n);

  for (int i = 0; i < n; i++)
  	cin >> p1[i];

  for (int i = 0; i < n; i++)
  	cin >> p2[i];

  int a = -1, b = -1;
  int t = 0;

  while (next_permutation(all(v))) {
  	if (eq(p1, v))
  		a = t;
  	if (eq(p2, v))
  		b = t;

  	if (a != -1 && b != -1)
  		break;

  	t++;
  }

  cout << abs(a - b) << "\n";

  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]


def climb_stairs(n):
    """
    :param n: int
    :param danger: list
    :return: int
    """
    if n == 1 or n == 2:
        return n
    else:
        a, b = 1, 2
        for i in range(n-2):
            a, b = b, a + b
        return b


now_s = 0
cost = 1
for j in a:
    if now_s == j:
        cost *= 0
        break
    elif now_s == j - 1:
        now_s = j + 1
    else:
        cost *= climb_stairs((j - 1) - now_s)
        now_s = j + 1

if now_s != N:
    cost *= climb_stairs(N - now_s)

print(cost % 1000000007)

Measured memory_bytes: 7056
#include<stdio.h>
int n;
int a[100010];
int main(){
	scanf("%d",&n);
	int ans=0;
	for (int i=1;i<=n;i++){
		scanf("%d",a+i);
		if (a[i]<i&&a[a[i]]==i){
			ans++;
		}
	}
	printf("%d\n",ans);
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<int> a(n);
    each (i, a) cin >> i;

    map<int, int> no;
    each (i, a) {
      if (no.count(i) == 0) {
        int x = no.size();
        no[i] = x;
      }
    }
    each (i, a) {
      i = no[i];
    }

    // each (i, a) cout << i << ' ' ; cout << endl;
    
    const int N = 100 + 10;
    int dp[N][N];
    fill(&dp[0][0], &dp[N - 1][N - 1] + 1, 1 << 28);
    dp[0][N - 1] = 0;

    for (int i = 0; i < a.size(); ++i) {
      for (int j = 0; j < N; ++j) {
        for (int k = 0; k < 100; ++k) {
          if (j != k) {
            dp[i + 1][k] = min(dp[i + 1][k], dp[i][j] + (k != a[i]));
          }
        }
      }
    }

    int mn = 1 << 28;
    for (int i = 0; i < N; ++i) {
      mn = min(mn, dp[n][i]);
    }
    cout << mn << endl;
    // cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<vector<ll>>> vvvll;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================





int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================



	string S;
	cin >> S;

	int ans = 0;
	for (int i = 0; i < S.length(); i++)
	{
		ans += int(S[i]) - int('0');
	}

	cout << ans << endl;
}





Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if(s<t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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


void solve(long long X, long long Y, long long Z){
    cout << Z << " " << X << " " << Y << endl;
    return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    long long Z;
    scanf("%lld",&Z);
    solve(X, Y, Z);
    return 0;
}


Measured memory_bytes: 256
n, k, s = gets.split.map(&:to_i)
a = Array.new(n, 0)
for i in 0...n do
  if i < k
    a[i] = s
  else
    a[i] = (s < 10 ** 9) ? (s + 1) : (s - 1)
  end
end
puts a.join(" ")


Measured memory_bytes: 4732
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> c(H);
    REP(i, H) cin >> c[i];
    int ans = 0;
    for(int i=0; i<(1<<H); i++){
        for(int j=0; j<(1<<W); j++){
            int cnt = 0;
            for(int a=0; a<H; a++){
                for(int b=0; b<W; b++){
                    if((1<<a)&i) continue;
                    if((1<<b)&j) continue;
                    if(c[a][b]=='#') cnt++;
                }
            }
            if(cnt==K) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<deque>
using namespace std;

int n;
deque<int> d;

void solve(int k, int r)
{
    if(r==0){
        for(int i=0;i<d.size();i++){
            printf("%d",d[i]);
            printf((i!=d.size()-1)?" ":"\n");
        }
    }
    for(int i=k;i>0;i--){ 
        if(r-i>=0){
            d.push_back(i);
            solve(i,r-i);
            d.pop_back();
        }
    }
}

int main()
{
    while(scanf("%d",&n),n){
        d.clear();
        solve(n,n);
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int N,K; cin >>N >>K;
  vector<ll> X(N),Y(N),Xsort(N),Ysort(N);
  rep(i, N) cin >>X[i] >>Y[i];
  rep(i, N) Xsort[i] = X[i], Ysort[i] = Y[i];
  sort(all(Xsort)); sort(all(Ysort));
  ll res = 4000000000000000000;
  for (int l=0; l<N; l++){
    for (int r=l+1; r<N; r++){
      for (int d=0; d<N; d++){
        // 下左右を固定。
        // x1<=x<=x2, y1<=y<=y2を満たすような点がK個以上あるようなy2の最小値を求める
        ll x1 = Xsort[l];
        ll x2 = Xsort[r];
        ll y1 = Ysort[d];
        vector<ll> tmp;
        for (int i=0; i<N; i++){
          if (X[i] < x1 || x2 < X[i]) continue;
          if (Y[i] < y1) continue;
          tmp.push_back(Y[i]);
        }
        if (tmp.size() < K) continue;
        sort(all(tmp));
        ll y2 = tmp[K-1];
        chmin(res, abs(x1-x2)*abs(y1-y2));
      }
    }
  }
  cout <<res <<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int  A,B,C,count=0;
    scanf("%d%d%d",&A,&B,&C);

    if((A==B&&A!=C&&B!=C)||(B==C&&B!=A&&C!=A)||(C==A&&C!=B&&A!=B))
    {
        printf("Yes\n");
    }
    else
        printf("No\n");

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
#define ll long long
using namespace std;
int x[5];

int main(){
	for(int i=1;i<=5;i++)
        scanf("%d",x+i);
    for(int i=1;i<=5;i++)
        if(x[i]==0)
        printf("%d\n",i);
	return 0;
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	int N;
	cin >> N;
	vector<int> L(N);
	rep(i,N) cin >> L[i];
	int ans=0;
	rep(i,N){
		for(int j=i+1; j<N; j++){
			for(int k=j+1; k<N; k++){
				if(L[i]==L[j] or L[i]==L[k] or L[j]==L[k]) continue;
				if(L[i]+L[j]<=L[k]) continue;
				if(L[i]+L[k]<=L[j]) continue;
				if(L[j]+L[k]<=L[i]) continue;
				ans++;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    int L = A+B;
    int R = C+D;
    
    if(L > R)
        cout << "Left" << endl;
    else if(L < R)
        cout << "Right" << endl;
    else
        cout << "Balanced" << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
judge = []

for i in A:
    if i % 2 == 0:
        if i % 3 == 0 or i % 5 ==0:
            judge.append("APPROVED")
        else:
            judge.append("DENIED")
    else:
        pass

if "DENIED" in judge:
    print("DENIED")
else:
    print("APPROVED")

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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int h, w, a[50][50], s[51][51];
ll b[50], c[50];
int hh, ww;


int main(){
	cin >> h >> w;
	rep(i, h) rep(j, w){
		cin >> a[i][j];
		s[i + 1][j + 1] = s[i + 1][j] + s[i][j + 1] - s[i][j] + a[i][j];
	}
	
	rep(i, h) rep(j, w){
		int t; cin >> t;
		if(t) b[i] |= 1ll << j;
	}
	
	cin >> hh >> ww;
	rep(i, hh) rep(j, ww){
		int t; cin >> t;
		if(t) c[i] |= 1ll << j;
	}
	
	int mask = (1ll << ww) - 1;
	int ans = -inf;
	
	rep(i, h - hh + 1) rep(j, w - ww + 1){
		
		bool ok = 1;
		rep(k, hh) if((b[i + k] >> j & mask) != c[k]) ok = 0;
		
		if(!ok) continue;
		
		ans = max(ans, s[i + hh][j + ww] - s[i][j + ww] - s[i + hh][j] + s[i][j]);
	}
	if(ans == -inf) cout << "NA" << endl;
	else cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1180
package main

import "fmt"

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	as := make([][]int, h)
	for i := 0; i < h; i++ {
		as[i] = make([]int, w)
		for j := 0; j < w; j++ {
			fmt.Scan(&as[i][j])
		}
	}

	steps := make([][4]int, 0)

	for i := 0; i < h; i++ {
		if i%2 == 0 {
			for j := 0; j < w; j++ {
				if as[i][j]%2 == 0 {
					continue
				}
				if j+1 < w {
					as[i][j]--
					as[i][j+1]++
					steps = append(steps, [4]int{i, j, i, j + 1})
				} else if i+1 < h {
					as[i][j]--
					as[i+1][j]++
					steps = append(steps, [4]int{i, j, i + 1, j})
				}
			}
		} else {
			for j := w - 1; j >= 0; j-- {
				if as[i][j]%2 == 0 {
					continue
				}
				if j-1 >= 0 {
					as[i][j]--
					as[i][j-1]++
					steps = append(steps, [4]int{i, j, i, j - 1})
				} else if i+1 < h {
					as[i][j]--
					as[i+1][j]++
					steps = append(steps, [4]int{i, j, i + 1, j})
				}
			}
		}
	}

	fmt.Println(len(steps))
	for _, s := range steps {
		fmt.Printf("%d %d %d %d\n", s[0]+1, s[1]+1, s[2]+1, s[3]+1)
	}
}


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

using namespace std;

int main() {
    string str;
    cin >> str;
    if (str[0] != 'A') {
        cout << "WA" << endl;
        return 0;
    }
    
    int index;
    int flag = 0;
    for (int i = 2; i < str.size() - 1; i++) {
        if (str[i] == 'C') {
            flag = 1;
            index = i;
        }
    }
    
    int up = 0;
    
    for (int i = 1; i < str.size(); i++) {
        if (i == index) {
            continue;
        }
        if (isupper(str[i])) {
            up = 1;
        }
    }
    
    if (up == 0 && flag == 1) {
        cout << "AC" << endl;
    } else {
        cout << "WA" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
char a[60][60],memo[60][60];
int ans,gx,gy;
set<tuple<int,int,int>> dp;
void move(int x,int y,int direc){
  int count=0;
  while(1){
    decltype(dp)::iterator it =dp.find(make_tuple(x,y,direc));
    if(it!=dp.end()) return;
    dp.insert(make_tuple(x,y,direc));
    if(memo[x][y]==0){
      count++;
      memo[x][y]=1;
    }
    if(x==gx&&y==gy){
      ans=count;
      return;
    }
    if(direc==1){
      if(a[x][y+1]=='.'){
	y++;
	direc=4;
      }
      else{
	if(a[x+1][y]=='#') direc=2;
	else x++;
      }
    }
    else if(direc==2){
      if(a[x+1][y]=='.'){
	x++;
	direc=1;
      }
      else{
	if(a[x][y-1]=='#') direc=3;
	else y--;
      } 
    }
    else if(direc==3){
      if(a[x][y-1]=='.'){
	y--;
	direc=2;
      }
      else{
	if(a[x-1][y]=='#') direc=4;
	else x--;
      } 
    }
    else if(direc==4){
      if(a[x-1][y]=='.'){
	x--;
	direc=3;
      }
      else{
	if(a[x][y+1]=='#') direc=1;
	else y++;
      }
    }
  }
  return;
}
    
int main(){
    int n,m;
    cin>>n>>m;
    lp(i,60){
      lp(j,60){
	a[i][j]='#';
	memo[i][j]=0;
      }
    }
    int direc,sx,sy;
    lp(i,n+1){
      if(i==0) continue;
      lp(j,m+1){
	if(j==0) continue;
	cin>>a[j][i];
	if(a[j][i]=='G'){
	  gx=j;
	  gy=i;
	  a[j][i]='.';
	}
	if(a[j][i]=='<'){
	  sx=j;
	  sy=i;
	  direc=3;
	  a[j][i]='.';
	}
	if(a[j][i]=='^'){
	  sx=j;
	  sy=i;
	  direc=2;
	  a[j][i]='.';
	}
	if(a[j][i]=='>'){
	  sx=j;
	  sy=i;
	  direc=1;
	  a[j][i]='.';
	}
	if(a[j][i]=='v'){
	  sx=j;
	  sy=i;
	  direc=4;
	  a[j][i]='.';
	}
      }
    }
    ans=0;
    dp.clear();
    move(sx,sy,direc);
    if(ans==0) cout<<"-1"<<endl;
    else cout<<ans<<endl;
  return 0;
}




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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, n;
  cin >> h >> n;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    sum += a;
  }
  if (h <= sum)
    cout << "Yes" << '\n';
  else
    cout << "No" << '\n';
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  vector<int> vec={a,b,c};
  sort(vec.begin(),vec.end());
  if(vec.at(0)+vec.at(1)==vec.at(2)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

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

#define INF 1e9
#define LINF 1e18
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define VPII vector<PII>

int N;
VI H;
VI cost;

int dp(int n){
    if(cost[n] != -1){
        return cost[n];
    }
    return cost[n] = min(dp(n-1)+abs(H[n]-H[n-1]),dp(n-2)+abs(H[n]-H[n-2]));
}
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(11);
    cerr << fixed << setprecision(6);

    cin >> N;
    H.assign(N,-1);
    cost.assign(N,-1);
    R(i,N) cin >> H[i];
    cost[0] = 0;
    cost[1] = abs(H[0]-H[1]); 
    dp(N-1);
    cout << to_string(cost[N-1]) << endl;
}


Measured memory_bytes: 6324
input = require('fs').readFileSync('/dev/stdin', 'utf8')
s = input.split('\n').shift() * 1
o = []
i = 1
while (o[s] === undefined) {
    o[s] = 1
    if (s%2) {
        s = 3 * s + 1 
    } else {
        s = s / 2
    }
    i++
    if (o[s] == 1) {
        break;
    }
}
console.log(i)

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/***********************************************************************/

int32_t main() {
 
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  using ld = long double;
  int n;
  cin >> n;
  ld ans = 0;
  for (int i = 0; i < n; ++i) {
    ld x;
    cin >> x;
    ans += 1 / x;
  }
  ans = 1 / ans;
  cout.precision(10);
  cout << fixed << ans << endl;
    
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long int mod=1000000007;
bool visited[100000+10]={false};
long int ans_b[100000+10];
long int ans_w[100000+10];
vector<long int> tree[100000+10];
 
vector<long int> dfs(long int u)
{
  visited[u]=true;
  long int b=1,w=1;
  for(long int i:tree[u])
  {
    if(!visited[i])
    {
      vector<long int> x=dfs(i);
      b=(b*x[1])%mod;
      w=(w*(x[0]+x[1])%mod)%mod;
    }
  }
  vector<long int> k;
  k.push_back(b);
  k.push_back(w);
  return k;
}
 
int main()
{
	long int n;
  	cin>>n;
  memset(ans_b,-1,sizeof ans_b);
  memset(ans_w,-1,sizeof ans_w);
  for(long int i=1;i<n;i++)
  {
  	long int u,v;
    cin>>u>>v;
    tree[u].push_back(v);
    tree[v].push_back(u);
  }
  vector<long int> k=dfs(1);
  cout<<(k[0]+k[1])%mod<<endl;
}

Measured memory_bytes: 18884
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
#include <string>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef long long int ll;
int res[30],tmp[30];
void printr(){
  for(int i=0;i<30;i++){
    cout<<res[i]<<" ";
  }
  cout<<endl;
}
int main(void){
  int n;
  cin>>n;

  memset(res,0,sizeof(res));
  string s;
  cin>>s;
  for(int j=0;j<s.size();j++){
    res[s[j]-'a']++;
  }
  for(int i=1;i<n;i++){
    cin>>s;
    memset(tmp,0,sizeof(tmp));
    for(int j=0;j<s.size();j++){
      tmp[s[j]-'a']++;
    }
    for(int j=0;j<30;j++){
      res[j]=min(res[j],tmp[j]);
    }
  }
  for(int i=0;i<30;i++){
    for(int j=0;j<res[i];j++){
      cout<<(char)(i+'a');
    }
  }
  cout<<endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  cout << a[N-1]-a[0] << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n,x,y,i;
    cin>>n;
    vector<ll>v1(n),v2(n);
    for(i=0;i<n;i++)
    {
        cin>>x>>y;
        v1[i]=x+y;
        v2[i]=x-y;
        }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    cout<<max(v1[n-1]-v1[0],v2[n-1]-v2[0]);
    
    
    return 0;
}

Measured memory_bytes: 6424
#include <iostream>
#include <string>
#include <math.h>

using namespace std;



int main(void){
  
  int A,B;

  cin >> A >> B;

  double K = (double) (A+B)/2;

  if( ceil(K) ==  floor(K)){
    cout << (int)K << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll unsigned long long
#define ull unsigned long long
#define dd double
#define oo 1001007000
#define ff float
#define ooo 1000000100000000000
#define iii pair<ll,ll>
#define vii vector<ll>
#define viii vector<iii>
#define sss pair<str,str>
#define str string
#define sii set<ll>
#define siii set<iii>
#define st size_t
#define r0 return 0
#define pb push_back
#define sz size
using namespace std;

const char E='\n';
const int N=1005;
const int NN=1000001;
const ll md=998244353;



int main(){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
    dd a;
    cin >> a;
    dd l=a/3.0;
    dd s=l*l*l;

    cout.setf(ios::fixed);
    cout.precision(8);
    cout << s << E;
    r0;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d) cout << "Left" << '\n';
  else if (a + b < c + d) cout << "Right" << '\n';
  else cout << "Balanced" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define ll long long
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int>>
const  long double eps = 1e-2;
const long double pi = acos(-1.0);
using namespace std;

ll n, s;

ll f(ll b, ll n){
    if (n < b) return n;
    else
        return (n % b) + f(b, n / b);
}

void solve(){
    cin >> n >> s;
    ll ans = 1e18;

    if (n == s){
        cout << n + 1;
        return;
    }

    for (ll b = 2; b * b <= n; b++){
            
            if (f(b, n) == s)
                ans = min(ans, b);        
    }

    if (n - s > 0){
        for (ll b = 1; b * b <= n - s; b++){
            if ((n - s) % b) continue;
            if (b > 1 && f(b, n) == s) ans = min(ans, b);
            if (f((n - s) / b + 1, n) == s) ans = min(ans, (n - s) / b + 1);
        }
    }
    if (ans == 1e18) cout << -1;
    else
        cout << ans;
        
}
int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(3);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int step;
	step = 1;
    for (int i = 1; i <= step; i++){
         solve();
    }
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> w(n);
  int s1=0;
  int s2=0;
  for(int i=0;i<n;i++){
    cin>>w.at(i);
    s2+=w.at(i);
  }
  int d=s2;
  for(int i=0;i<n;i++){
    s1+=w.at(i);
    s2-=w.at(i);
    d=min(d,max(s2-s1,s1-s2));
  }
  cout<<d<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
set<string> c;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
map<int,bool> used;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,m;cin>>n>>m;
vector<ll> a(n),sum(n+1,0);
for(int i=0;i<n;i++)cin>>a[i];
multiset<ll> s;
for(int i=0;i<n;i++){
    (sum[i+1]=sum[i]+a[i])%=m;
    s.insert(sum[i]%m);
}
s.insert(sum[n]);
ll ans=0;
for(int i=0;i<n;i++){
  if(used[sum[i]])continue;
  used[sum[i]]=true;
  ll comb=s.count(sum[i]);
  //cout<<comb<<endl;
  if(comb>0)ans+=comb*(comb-1LL)/2LL;
}
cout<<ans<<endl;
}


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

int main(){
    string s,t; cin>>s>>t;
    int n = s.size();
    int ans=0;
    for (int i=0; i<n; i++){
        if (s[i]!=t[i]) ans++;
    }
    cout << ans << endl;
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c) cout << 1 << endl;
    else if (a == b && b != c || a == c && c != b || b == c && a != b) cout << 2 << endl;
    else cout << 3 << endl;

    return 0;
}


Measured memory_bytes: 256
def d(i, j):
    if i == j:
        return "z"
    if i < j:
        return "p"
    else:
        return "m"

n = int(input())
a = [int(x) for x in input().split()]
if n < 3: print(1)
else:
    ans = 1
    s = d(a[0], a[1])
    for i in range(1, n):
        tmp = d(a[i-1], a[i])
        if tmp == "z": continue
        elif s == tmp: continue
        else:
            if s == "z":
                s = tmp
                continue
            else:
                s = "z"
                ans += 1
    print(ans)

Measured memory_bytes: 14252
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		String[] sArr = s.split("");
		Arrays.sort(sArr);
		if (sArr[0].equals(sArr[1]) && sArr[2].equals(sArr[3]) && !sArr[1].equals(sArr[2])) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

}


Measured memory_bytes: 22996
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

// GCC __gcd(long long A, long long B)

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

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

int main(){
  int n, x;

  cin >> n >> x;

  ll ans = 0;

  for(int i=0;i<n;i++){
    int a;
    cin >> a;

    int p = abs(x-a);

    ans = gcd(ans, p);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn.readInt

object Main {
  val angle = Math.PI/3
  def main(args:Array[String]) = {
    val n = readInt
    var list = IndexedSeq(((0D,0D),(100D,0D)))
    var last = (0D,0D)
    (1 to n).foreach { _=>
      list = for{
        i<-list;
        p1 = (i._1._1*2/3+i._2._1/3,i._1._2*2/3+i._2._2/3)
        p2 = (i._1._1/3+i._2._1*2/3,i._1._2/3+i._2._2*2/3)
        x = (p2._1-p1._1)*Math.cos(angle)-(p2._2-p1._2)*Math.sin(angle)+p1._1
        y = (p2._1-p1._1)*Math.sin(angle)+(p2._2-p1._2)*Math.cos(angle)+p1._2
        p3 = (x,y)
        j<-List((i._1,p1),(p1,p3),(p3,p2),(p2,i._2))
      } yield j
    }

    for(i<-list) {
      printf("%.8f %.8f\n",i._1._1,i._1._2)
    }
    printf("%.8f %.8f\n",list.last._2._1,list.last._2._2)
  }
}

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

using namespace std;
typedef long long ll;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n));

void fast() {

    cin.tie(0);
    cin.sync_with_stdio(0);
}


int main() {
    fast();
    int n,l;cin>>n>>l;
    vector<string>v;
    for (int i = 0; i < n; ++i) {
        string s;cin>>s;
        v.push_back(s);
    }
    sort(all(v));
    for (int j = 0; j <n ; ++j) {
        cout<<v[j];
    }
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int n = sc.nextInt();
    int m = sc.nextInt();
    
    long[] x = sc.nextLongList(n);
    long[] y = sc.nextLongList(m);
    
    long mod = 1000000000 + 7;
    
    long retx = 0;
    for (int i = 1; i < n; i ++) {
      retx += (x[i] - x[i - 1]) * (n - i) * i;
      retx %= mod;
    }
    long rety = 0;
    for (int i = 1; i < m; i ++) {
      rety += (y[i] - y[i - 1]) * (m - i) * i;
      rety %= mod;
    }
    System.out.println(retx * rety % mod);
  }

}


class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 25388