akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX 10000003
using namespace std;
void solve()
{
    ll n,m;   
    string a,b,c;  cin>>a>>b;
    n=sl(a), m=sl(b);
    vector<vector<ll>> dp(n+1,vector<ll>(m+1,0));
    rep(i,1,n+1)
    {
        rep(j,1,m+1)
        {
            if(a[i-1]==b[j-1])  dp[i][j]=1+dp[i-1][j-1];  
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    ll i=n,j=m;
    while(i>0 and j>0)
    {
        if(a[i-1]==b[j-1])
        {
            c+=a[i-1];
            i--;
            j--;
        }
        else
        {
            if(dp[i-1][j]>dp[i][j-1]) i--;
            else j--;
        }
    }
    reverse(all(c));
    cout<<c;
}
int main()
{
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    return 0;
}

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

void watch(int sec);

int main(){
    int sec;
    cin>>sec;
    watch(sec);
    return 0;
}

void watch(int sec){
    int wsec,wmin,whour;
    whour=sec/3600;
    sec=sec-3600*whour;
    wmin=sec/60;
    sec=sec-60*wmin;

    cout<<whour<<":"<<wmin<<":"<<sec<<endl;
}



Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
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(), greater<int>());

    int Alice = 0;
    int Bob = 0;
    for (int i = 0; i < N; i++){
        if(i % 2 == 0){
            Alice += a[i];
        }else{
            Bob += a[i];
        }
    }
    cout << (Alice - Bob) << endl;

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

public class Main {
	public static void main(String args[]) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int input = Integer.parseInt(br.readLine());

		int hour = input / 3600;
		int minutes = (input - hour * 3600) / 60;
		int seconds = input - (hour * 3600) - (minutes * 60);

		System.out.println(hour + ":" + minutes + ":" + seconds);

	}

}

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

int main()
{
    ll n,k,lol,hagu,ans;

    scanf("%lld %lld",&n ,&k);

    hagu = n%k; lol=abs(hagu-k);ans=lol;

    while(1)
    {
        lol=abs(lol-k);
        if(lol>=ans) break;
        else{
            ans=lol;
        }
    }

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



}


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

void func(void){
  cout<<"WA";
  exit(0);
}

int main(void){
  string S;
  cin >> S;
  if(S[0]!='A') func();
  string abc="abcdefghijklmnopqrstuvwxyz";
  int ctC=0;
  int i;
  int index;
  for(i=2;i<S.size()-1;i++){
    if(S[i]=='C'){
      ctC++;
      index=i;
    }
    if(ctC>1)  func();
  }
  if(ctC==0)  func();
  int j;
  for(i=1;i<S.size();i++){
    if(i==index)  continue;
    int flag=0;
    for(j=0;j<abc.size();j++){
      if(abc[j]==S[i])  flag++;
    }
    if(flag==0) func();
  }
  cout<<"AC";
}


Measured memory_bytes: 256
#include <iostream>
#include <set>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

int main()
{
	ll i,j,k;
	ll N,M,T;
	ll p[200010] = {0};
	ll q = 0;
	cin >> N >> M;
	for(i=0;i<N;++i)
	{
		cin >> j;
		p[i] = j;
	}
	for(i=0;i<M;++i)
	{
		q += p[i];
	}
	k = q;
	for(i=0;i<N-M;++i)
	{
		q += p[M+i] - p[i];
		if(q > k)
			k = q;
	}
	printf("%0.8lf",((double)(k+M))/2.0);
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <deque>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using ll = long long;


int main() {
	string s, t;
	cin >> s >> t;

	set<char> A[300], B[300];
	rep(i, s.size()) {
		A[s[i]].insert(t[i]);
		B[t[i]].insert(s[i]);
	}
	string ans = "Yes";
	rep(i, 300) {
		if (A[i].size()>1) {
			ans = "No";
		}
		if (B[i].size()>1){
			ans = "No";
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3900
N = int(input())

max = 0
next = 0
count_m = 0
for i in range(N):
    a = int(input())
    if a >= max:
        next = max
        max = a
        count_m = i

    if max > a > next:
        next = a

for j in range(N):
    if j == count_m:
        print(next)
    else:
        print(max)



Measured memory_bytes: 4668
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/
class disjoint_set {
    vector<int> p;
public:
    int count;
    disjoint_set(int n) : p(n, -1), count(0) {}
    int root(int i) { return p[i] >= 0 ? p[i] = root(p[i]) : i; }
    bool same(int i, int j) { return root(i) == root(j); }
    int size(int i) { return -p[root(i)]; }
    void merge(int i, int j) {
        count++;
        i = root(i), j = root(j);
        if (i == j) return;
        if (p[i] > p[j]) swap(i, j);
        p[i] += p[j], p[j] = i;
    }
    int size(int i, int j) {
        if(same(i,j)) return size(i);
        else return size(i) + size(j);
    }
};

vector<vi> g;

int main(){
    int N,M;
    cin >> N >> M;
    g.resize(M);
    rep(i,N){
        int k;cin>>k;
        rep(j,k){
            int l;
            cin >> l;
            l--;
            g[l].push_back(i);
        }
    }

    disjoint_set uf(N);

    for(int i=0;i<M;i++){
        for(int j=1;j<g[i].size();j++){
            uf.merge(g[i][0],g[i][j]);
        }
    }

    int sz = uf.size(0);
    if(sz == N){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 4608
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> ps(N);
  for (int i = 0; i < N; ++i) {
    cin >> ps[i];
  }
  sort(ps.begin(), ps.end());
  ll sum = 0;
  for (int i = 0; i < K; ++i) {
    sum += ps[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 3584
p['   '];t['   '];n,x,j;main(i){for(;i++<1e6;)for(x=i;x<1e6;p[x+=i]=1);for(;scanf("%d%d",&n,&x),n;memset(t,!printf(x<2?"NA\n":"%d\n",x),4e6)){for(;n--;)for(i=-scanf("%d",t);++i<x;)t[i]&&++t[i+*t];for(;p[x]|!t[x];x--);}}

Measured memory_bytes: 15000
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	int A,B;
	cin>>A>>B;
	int ans=0;
	rep(i,2){
	  if(A<B){
		ans+=B;
		B--;
	  }
	  else{
		ans+=A;
		A--;
	  }
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
/*Stay true to yourself, yet always be open to learn. Work hard, and never give up on your dreams, 
even when nobody else believes they can come true but you. These are not cliches but real tools you 
need no matter what you do in life to stay focused on your path.
*/
 
 /*Pppppppp    UU      UU     CCCCCCCC    CCCCCCCC     HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pppppppp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pp          UU      UU     CC          CC           HH     HH     UU      UU
   pp          UUUUUUUUUU     CCCCCCCC    CCCCCCCC     HH     HH     UUUUUUUUUU
   */
 
#include <bits/stdc++.h>
using namespace std;

#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define ford(i,a,b) for(int i=b;i>=a;i--)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int,int>
#define vii vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define endl "\n"
#define mp make_pair
const ll inf = 1e18;
const ll mod = 1e9 + 7;

signed main()
{

    fast;
    int k ,n;
    cin >> k >> n;
    readarr(a,n);
    vi d(n);
    for(int i=0;i<n-1;i++){
      d[i] = a[i+1]-a[i];
    }
   d[n-1] = a[0]+k-a[n-1];
  int ans=0;
  sort(d.begin(),d.end());
  for(int i=0;i<n-1;i++)
    ans+=d[i];
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    string s,t;
    cin>>s>>t;
    int ans = 0;
    rep(i, 0, 3){
        if(s[i]==t[i]) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
 
int cnt[2][4005][4005];
 
int getCount(int xmax, int ymax, int xmin, int ymin, int color){
    if (xmin == 0 && ymin == 0) return cnt[color][xmax][ymax];
    if (xmin == 0) return cnt[color][xmax][ymax]-cnt[color][xmax][ymin-1];
    if (ymin == 0) return cnt[color][xmax][ymax]-cnt[color][xmin-1][ymax];
    return cnt[color][xmax][ymax] + cnt[color][xmin-1][ymin-1] - cnt[color][xmin-1][ymax] - cnt[color][xmax][ymin-1];
}
int main(){
    int n, k;
    scanf("%d%d",&n, &k);
    char str[2];
    int x, y;
    for(int i = 0; i < n; i ++){
        scanf("%d%d%s", &x, &y, str);
        x %= 2*k;
        y %= 2*k;
        int color = (str[0]=='W')?0:1;
        cnt[color][x][y] ++;
        cnt[color][x+2*k][y] ++;
        cnt[color][x][y+2*k] ++;
        cnt[color][x+2*k][y+2*k] ++;
    }
    for(int color = 0; color < 2; color ++){
        for(int i = 1; i < 4*k; i ++){
            cnt[color][0][i] += cnt[color][0][i-1];
        }
        for(int i = 1; i < 4*k; i ++){
            for(int j = 0; j < 4*k; j ++){
                if (j == 0) cnt[color][i][j] += cnt[color][i-1][j];
                else cnt[color][i][j] += cnt[color][i][j-1] + cnt[color][i-1][j] - cnt[color][i-1][j-1];
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < 2*k; i ++){
        for(int j = 0; j < k; j ++){
            int a = getCount(i+k-1, j+k-1, i, j, 1);
            int b = getCount(i+k-1, j+2*k-1, i, j+k, 0);
            int c = getCount(i+2*k-1, j+k-1, i+k, j, 0);
            int d = getCount(i+2*k-1, j+2*k-1, i+k, j+k, 1);
            ans = max(ans, a+b+c+d);
        }
    }
    printf("%d\n", ans);
    
}

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

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

    ll a,b,k;
    cin >> a >> b >> k;

    if(k > a) {
        if(b - (k - a) >= 0) b = b - (k - a);
        else b = 0;
        a = 0;
    } else {
        a -= k;
    }
    cout << a << " " << b << endl;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
class BIT:
    #1-indexed
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
        self.p = 2**(n.bit_length() - 1)
        self.dep = n.bit_length()
    def get(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
    
    def bl(self, v):
        if v <= 0:
            return -1
        s = 0
        k = self.p
        for _ in range(self.dep):
            if s + k <= self.size and self.tree[s+k] < v:
                s += k
                v -= self.tree[s+k]
            k //= 2
        return s + 1

def count(P):
    res = 0
    T = BIT(N)
    Pi = [None]*N
    for i in range(N):
        Pi[P[i]] = i
    for i in range(N):
        p = Pi[i]
        res += i-T.get(p+1)
        T.add(p+1, 1)
    return res
 

N = int(readline())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))
uhalf = -(-N//2)
dhalf = N - uhalf
inf = 10**9+7
ans = inf
for S in range(1<<N):
    card = [A[i] if S&(1<<i) else B[i] for i in range(N)]
    parity = [(1&(S>>i))^(i&1) for i in range(N)]
    even = [(card[i], i) for i in range(N) if parity[i]]
    odd = [(card[i], i) for i in range(N) if not parity[i]]
    if len(even) != uhalf or len(odd) != dhalf:
        continue
    even.sort()
    odd.sort()
    if any(e[0] > o[0] for e, o in zip(even, odd)) or any(e[0] < o[0] for e, o in zip(even[1:], odd)):
        continue
    perm = [even[i//2][1] if not i&1 else odd[i//2][1] for i in range(N)]
    ans = min(ans, count(perm))
print(ans if ans < inf else -1)


Measured memory_bytes: 63704
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    Int x;
    cin >> x;
    Int a = 0, b = 0;
    for (Int i = -1000; i<= 1000; i++) {
        for (Int j = -1000; j <= 1000; j++) {
            if (pow(i,5) - pow(j,5) == x) {
                a = i;
                b = j;
                // cout << i << " " << j << endl;
            }
        }
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 4028
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        // string a = Console.ReadLine();
        long n = Read.Int();
        long[] a = Read.ints();
   
        long x = a.Sum(), y = 0;
        long yabaisa = int.MaxValue;
        for (long i = 0; i < a.Length; i++)
        {
            x -= a[i];
            y += a[i];
            if (i != a.Length - 1)
            {
                yabaisa = Math.Min(yabaisa, Math.Abs(x - y));
            }
        }
        Console.WriteLine(yabaisa);
        Console.ReadLine();
 
    }
 
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b)
    {
        return a * b / gcd(a, b);
    }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
 
        for (long i = 2; i < n; i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
 
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] longs()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static long[] ints()
    {
        return Console.ReadLine().Split().Select(long
            .Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}


Measured memory_bytes: 36548
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

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

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    int m; cin >> m;
    vector<ll> x, y, z;
    F0R(i, n) {
        ll a, b, c; cin >> a >> b >> c;
        x.pb(a); y.pb(b); z.pb(c);
    }

    ll best = 0;

    FOR(a, -1, 2) {
        FOR(b, -1, 2) {
            FOR(c, -1, 2) {
                if (a == 0 || b == 0 || c == 0) continue;
                vector<ll> data;
                F0R(i, n) {
                    data.pb(x.at(i) * a + y.at(i) * b + z.at(i) * c);
                }
                sort(data.begin(), data.end());
                ll count = 0;
                F0R(i, m) {
                    count += data.at(n - i - 1);
                }
                best = max(best, count);
            }
        }
    }
    cout << best << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define line puts("-------");
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    if(n==m)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 1000
#define MM 200000
struct edge{edge*nx;int t;}e[MM*3+5],*h[MN+5],*r[MN+5],*c[MN+5];
int en=1,x[MM+5],y[MM+5];
int d[MN+5],l[MN+5],cnt,z[MN+5],zn,inz[MN+5],p[MN+5],pn,ph[MN+5];
int g[MN+5][MN+5],q[MN+5],qn,u[MN+5],uu[MM+5];
inline void ins(edge**h,int x,int y){e[++en]=(edge){h[x],y};h[x]=e+en;}
void dfs(int x)
{
	d[x]=l[x]=++cnt;inz[z[zn++]=x]=1;
	for(edge*i=h[x];i;i=i->nx)
		if(!d[i->t])dfs(i->t),l[x]=min(l[x],l[i->t]);
		else if(inz[i->t])l[x]=min(l[x],d[i->t]);
	if(d[x]==l[x])for(ph[++pn]=x;z[zn]!=x;)inz[z[--zn]]=0,p[z[zn]]=pn;
}
void d1(edge**h,int x,int z)
{
	u[x]=1;
	for(edge*i=h[x];i;i=i->nx)if(!u[i->t])d1(h,i->t,z),uu[i-e>>1]|=z;
}
bool d2(edge**h,int x,int d,int s)
{
	memset(u,0,sizeof(u));int i;
	for(u[q[i=qn=0]=x]=1;i<=qn;++i)for(edge*j=h[q[i]];j;j=j->nx)
	{
		if((j-e>>1)!=d&&!u[j->t])u[q[++qn]=j->t]=1;
		if(u[s])return false;
	}
	return true;
}
int main()
{
	int n=read(),m=read(),i,j;
	for(i=1;i<=m;++i)x[i]=read(),y[i]=read(),ins(h,x[i],y[i]),ins(r,y[i],x[i]);
	for(i=1;i<=n;++i)if(!d[i])dfs(i);
	memset(h,0,sizeof(h));memset(r,0,sizeof(r));en=1;
	for(i=1;i<=m;++i)if(p[x[i]]==p[y[i]])ins(h,x[i],y[i]),ins(r,y[i],x[i]);else en+=2;
	for(i=1;i<=pn;++i)d1(h,ph[i],1);
	memset(u,0,sizeof(u));
	for(i=1;i<=pn;++i)d1(r,ph[i],2);
	for(i=1;i<=m;++i)if(p[x[i]]!=p[y[i]])ins(c,p[x[i]],p[y[i]]);
	for(i=1;i<=pn;++i)for(g[i][q[j=qn=1]=i]=1;j<=qn;++j)
		for(edge*k=c[q[j]];k;k=k->nx)if(!g[i][k->t]++)q[++qn]=k->t;
	for(i=1;i<=m;++i)
		if(p[x[i]]!=p[y[i]])puts(g[p[x[i]]][p[y[i]]]>1?"diff":"same");
		else puts(((uu[i]&1)&&d2(h,ph[p[x[i]]],i,y[i]))
				||((uu[i]&2)&&d2(r,ph[p[x[i]]],i,x[i]))?"diff":"same");
}

Measured memory_bytes: 16768
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    std::string s; std::cin >> s;
    int n = s.size();
    bool ok = true;
    for (int i = 0; i < n - 1; i++) {
        ok &= s[i] == s[n - i - 2];
    }
    if (!ok || s.back() == '1' || s[0] == '0') {
        std::cout << -1 << std::endl;
        return 0;
    }
    std::vector<std::pair<int, int>> ans;
    ans.emplace_back(1, 2);
    int prev = 2;
    for (int i = 1; i < n - 1; i++) {
        ans.emplace_back(prev, i + 2);
        if (s[i] == '1') prev = i + 2;
    }
    for (const auto &p : ans)
        std::cout << p.first << " " << p.second << std::endl;
    return 0;
}


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

#define ris   return *this
#define tmplt template<class T
#define dbgo  debug& operator<<
tmplt > struct rge { T b, e; };
tmplt > rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
~debug(){cerr<<endl;}
tmplt > dbgo(T x){cerr<<boolalpha<<x;ris;}
tmplt, class C > dbgo(pair<T, C> x){ris<<"("<<x.first<<", "<<x.second<<")";}
tmplt > dbgo(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}ris<<"]";}
tmplt > dbgo(vector<T> x){ris<<range(x.begin(),x.end());}
#else
tmplt > dbgo(const T&){ris;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;

#define forn(i, n) for(int i = 0; i < int(n); i++)
#define ford(i, n) for(int i = n-1; i >= 0; i--) 

template<typename T> 
void min_self(T& a, T b) { 
    a = min(a, b); 
}
template<typename T>
void max_self(T& a, T b) { 
    a = max(a, b); 
}


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

    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> pre(n+1), suf(n+1);
    forn(i, n) {
        pre[i+1] = pre[i] + (s[i] == 'W');
    }
    ford(i, n) {
        suf[i] = suf[i+1] + (s[i] == 'E');
    }
    debug() nav(pre);
    debug() nav(suf);
    int ans = n;
    forn(i, n) {
        min_self(ans, pre[i]+suf[i+1]);
    }
    cout << ans << endl;
}













// Don't worry, you're getting better

// Read statement carefully
// Solve on paper first!
// Make your infinity big enough
// Overflows (long long)

// Author: blondie


Measured memory_bytes: 2964
'use strict'

function main(s) {

  s = s.split('\n');
  const K = Number(s[0].split(' ')[1]);
  const balls = s[1].split(' ').map(el => Number(el));
  const countBucket = [...Array(200001)].fill(0);

  for (const num of balls) {
    countBucket[num] += 1;
  }

  countBucket.sort((a, b) => b - a);

  const answer = countBucket.slice(K).reduce((a, b) => a + b);
  console.log(answer);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 42264
#include <iostream>
using namespace std;
int main(void){
  int a,b;
  cin >> a >> b;
  
  if(a == 1)
    a *= 100;
  if(b == 1)
    b *= 100;
  
  if(a > b)
    cout << "Alice" << endl;
  else if(a < b)
    cout << "Bob" << endl;
  else
    cout << "Draw" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    ll N, K;
    cin >> N >> K;
    vector<pair<int, int>> p(N);
    REP(i, N) {
        int a, b;
        cin >> a >> b;
        p[i] = {a, b};
    }
    SORT(p);
    int ans;

    REP(i, N) {
        K -= p[i].second;
        if (K <= 0) {
            ans = p[i].first;
            break;
        }
    }

    std::cout << ans << '\n';

    return 0;
}

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse( ReadLine() );
            var array = ReadLine().Split(' ');
            var h = array.Select(x=>long.Parse(x)).ToArray();
            //dpテーブル
            long[] dp = new long[n];
            for(int i = 0;i < n;i++ )
                dp[i] = long.MaxValue;

            dp[0] = 0;
            dp[1] = Math.Abs( h[1]-h[0]);

            for(int i = 2;i < n;i++){
                long c1 = Math.Abs( h[i-1] - h[i]) + dp[i-1];
                long c2 = Math.Abs(h[i-2] - h[i]) + dp[i-2];
                
                Util.ChMin(ref c1, c2);
                dp[i] = c1;
            }


            WriteLine(dp[n-1]);
        }
    }


    static class Util{
        public static void ChMin(ref long a,long b){
            
            if(a > b){
                a = b;
            }
        }

        public static void ChMax(ref long a,long b){
            if(a < b){
                a = b;
            }
        }
    }
}


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

using namespace std;

int main()
{
    int a,b,res,ans;
    scanf("%d%d",&a,&b);
    res=a+b;
    if(res%2==1)
    {
        ans=(res/2)+1;
        printf("%d\n",ans);
    }
    else
    {
        ans=(res/2);
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define N 2e5

int main()
{
    int n;
    cin >> n;
    ll p = 1;
    int ok = 1;
    while (n--)
    {
        ll t;
        cin >> t;
        if ((log(p) * 1.0) / log(10) + (log(t) * 1.0) / log(10) > 18)
        {
            ok = 0;
        }
        p = p * t;
        if (p > 1000000000000000000)
        {
            ok = 0;
        }
        if (t == 0)
        {
            ok = 1;
            break;
        }
    }
    if (p > 1000000000000000000)
    {
        ok = 0;
    }
    if (ok == 1)
        cout << p << endl;
    else
    {
        cout << "-1\n";
    }
}

Measured memory_bytes: 3832
from heapq import heappush, heappushpop

Q = int(input())

b = 0
la = []
sl = 0
ra = []
sr = 0

cnt = 0
for _ in range(Q):
    q = tuple(map(int, input().split()))
    # print(la, ra)
    if q[0] == 2:
        # 求値
        x = -la[0]
        cl = (cnt + 1) // 2
        cr = cnt - cl
        print(x, (cl * x - sl) + (sr - cr * x) + b)
    else:
        # 更新
        b += q[2]
        cnt += 1
        if cnt % 2 == 1:
            sr += q[1]
            x = heappushpop(ra, q[1])
            sr -= x
            sl += x
            heappush(la, -x)
        else:
            sl += q[1]
            x = heappushpop(la, -q[1])
            x *= -1
            sl -= x
            sr += x
            heappush(ra, x)


Measured memory_bytes: 11296
from functools import reduce

m, n = map(int, input().split())
mod = 10 ** 9 + 7


def ncr(p, k):
    if k == 0:
        return 1
    elif k < 0:
        return 0
    else:
        num = reduce(lambda x, y: x * y % mod, range(p, p - k, -1))
        den = reduce(lambda x, y: x * y % mod, range(1, k + 1))
        return num * pow(den, mod - 2, mod) % mod


if (m + n) % 3 != 0:
    print(0)
else:
    p = (m + n) // 3
    k = m - p
    print(ncr(p, k))


Measured memory_bytes: 3572
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int l = stdIn.nextInt();

        if(l > 0) {
            System.out.println((n-1)*l+(n*(n-1))/2);
        }else if(l < -n+1) {
            System.out.println((n-1)*l+(n*(n-1))/2-(n-1));
        }else {
            System.out.println(n*l+(n*(n-1))/2);
        }
    }
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int h,w;
    while (true) {
        cin>>h>>w;
        if (!h&&!w) break;
        rep(i,h) {
            rep(j,w) {
                if ((i+j)%2) cout<<'.';
                else cout<<'#';
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


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

using namespace std;

#define ll long long

const int mod  = 1e9 + 7;
const ll INF = 1e14;

bool valid(int i, int j, int h, int w){
    if(i < 0 || j < 0) return false;
    if(i >= h || j >= w) return false;
    return true;
}

void solve(){

    int h, w; cin >> h >> w;
    int x, y; cin >> x >> y;
    int dx, dy; cin >> dx >> dy;
    --x, --y, --dx, --dy;

    char arr[h][w];
    for(int i = 0; i < h; ++i)
        for(int j = 0; j < w; ++j)
            cin >> arr[i][j];

    vector<vector<bool>> vis (h, vector<bool> (w, false));
    set<pair<ll, pair<int, int>>> set;
    set.insert({0, {x, y}});
    vector<ll> wt (h*w, INF);
    wt[x*w + y] = (ll)0;

    while(!set.empty()){
        pair<ll, pair<int, int>> it = *set.begin();
        set.erase(set.begin());
        int xc = it.second.first;
        int yc = it.second.second;

        vis[xc][yc] = true;

        for(int i : {-1, 0, 1} ){
            for(int j : {-1, 0, 1} ){
                if(abs(i) != abs(j) && valid(xc+i, yc+j, h, w)){
                    if(arr[xc+i][yc+j] == '.' && vis[xc+i][yc+j] == false){
                        if(wt[w*(xc+i)+yc+j] > wt[w*xc+yc]){
                            if(set.find({wt[w*(xc+i) + yc+j], {xc+i, yc+j}}) != set.end())
                                set.erase({wt[w*(xc+i) + yc+j], {xc+i, yc+j}});
                            wt[w*(xc+i) + yc+j] = wt[w*xc + yc];
                            set.insert({wt[w*(xc+i) + yc+j], {xc+i, yc+j}});
                        }
                    }
                }
            }
        }
        for(int i : {-2, -1, 0, 1, 2}){
            for(int j : {-2, -1, 0, 1, 2}){
                if((i != 0 || j != 0) && valid(xc+i, yc+j, h, w)){
                    if(arr[xc+i][yc+j] == '.' && !vis[xc+i][yc+j]){
                        if(wt[w*(xc+i) + yc+j] > wt[w*xc + yc] + 1){
                            if(set.find({wt[w*(xc+i) + yc+j], {xc+i, yc+j}}) != set.end())
                                set.erase({wt[w*(xc+i) + yc+j], {xc+i, yc+j}});
                            wt[w*(xc+i) + yc+j] = wt[w*xc + yc] + 1;
                            set.insert({wt[w*(xc+i) + yc+j], {xc+i, yc+j}});
                        }
                    }
                }
            }
        }
    }
    cout << (wt[dx*w + dy] == INF ? -1 : wt[dx*w + dy]) << "\n";
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  	solve();
	return 0;
}



Measured memory_bytes: 12412
import sys
from collections import Counter

input = sys.stdin.readline


def main():
    N = int(input())
    W = [""] * N
    for i in range(N):
        W[i] = input().rstrip()

    condition_1 = True
    for i in range(N - 1):
        if W[i][-1] != W[i + 1][0]:
            condition_1 = False

    c = Counter(W)
    values = c.values()
    condition_2 = all(v == 1 for v in values)

    if condition_1 and condition_2:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int ans = b;
    ans += min(c, a + b + 1);
    cout << ans << endl;
    return 0;
   // comment
// comment
// comment
// comment
// comment
// comment
// comment
// comment
// comment// comment
// comment
// comment
// comment
}


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

int GCD(int m, int n)
{
	if (n == 0)return m;
	return GCD(n, m % n);
}

int main()
{
	int a, b, c, gcd, n, res = -1;
	cin >> a >> b >> c;
	gcd = GCD(60,c);
	n = 60/gcd + (a+b);
	for (int i = 0; i < n; i++) {
		if ((c + 60 * i) % (a + b) >= 0 && (c + 60 * i) % (a + b) <= a) {
			res = c + 60 * i;
			break;
		}
	}
	cout << res << endl;
	return 0;
}

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

long long ans (long long n)
{
  if (n & 1LL) return ((n + 1) / 2) & 1LL;
  else return ((n / 2) & 1LL) ^ n;
}

int main()
{
  long long a, b;
  cin >> a >> b;
  cout << (ans(a > 0 ? a - 1 : a) ^ ans(b)) << endl;
}

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

int main(){

int kalimat;
char input[100];
		
scanf("%d", &kalimat);
scanf("%s", input);

//masukin nya gimanee
int len = strlen(input);

//ok
for(int i = 0; i < len; i++){
			
    if(kalimat >= len){
		printf("%s", input);
		break;
	}
			
    else if(i < kalimat){
		printf("%c", input[i]);
	}
			
    else{printf("...\n");
		break;
	}
}
		
return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

set<int> S;

int main(){
  ll N,K;
  cin >> N >> K;
  ll T=pow(2,N);
  if(((N==1)&&K>=1 )|| K>=T){
    cout << -1 << endl;
    return 0;
  }
  if(K==0){
    rep(i,T){
      if(i!=T-1){
        cout << i <<" "<< i << " ";
      }
      else{
        cout << i <<" "<< i << endl;
      }
    }
    return 0;
  }
  rrep(i,T){
    if(i!=K){
      cout << i << " ";
    }
  }
  cout << K << " ";
  rep(i,T){
    if(i!=K){
      cout << i << " ";
    }
  }
  cout << K << endl;
}

Measured memory_bytes: 1792
import java.io.*;
import java.util.*;

public class Main {
  private static int solve(int n, String s) {
    return (n - s.replaceAll("ABC", "").length()) / 3;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    String s = reader.next();
    out.println(solve(n, s));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;

const int MAX_V = 110;  //??????????????????????????????
struct edge { int to, cap, rev; };
vector<edge> G[MAX_V];
bool used[MAX_V];

int V, E;
int v1, v2, c;

//from??????to??????????????????cap???????????°?????????????????????
void add_edge(int from, int to, int cap)
{
    G[from].push_back((edge){to, cap, G[to].size()});
    G[to].push_back((edge){from, 0, G[from].size() - 1});
}

//?¢?????????????DFS??§??¢???
int dfs(int v, int t, int f)
{
    if (v == t) return f;
    used[v] = true;
    for (int i=0; i<G[v].size(); i++) {
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

//s??????t???????????§???????±???????
int max_flow(int s, int t)
{
    int flow = 0;
    for (;;) {
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if (f == 0) return flow;
        flow += f;
    }
}

signed main()
{
    cin >> V >> E;
    REP(i,E) {
        cin >> v1 >> v2 >> c;
        add_edge(v1, v2, c);
    }
    cout << max_flow(0, V - 1) << endl;
}

Measured memory_bytes: 3180
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

// 2^59 > 10^13
constexpr int MAX = 60;
int cnt[MAX][MAX];

int main() {
  int n;
  cin >> n;
  string s;
  ll ans = 0;
  ll a;
  rep(i, 0, n) {
    cin >> s;
    if (s.find('.') == string::npos) {
      a = stol(s) * 1000000000;
    } else {
      int j = s.find('.');
      string t = s.substr(0, j);
      string u = s.substr(j + 1);
      while (u.size() < 9) u += '0';
      a = stol(t + u);
    }

    int two = 0, five = 0;
    while (a % 2 == 0) {
      two++;
      a /= 2;
    }
    while (a % 5 == 0) {
      five++;
      a /= 5;
    }

    rep(t, 0, MAX) rep(f, 0, MAX) {
      if (two + t >= 18 && five + f >= 18) ans += cnt[t][f];
    }
    cnt[two][five]++;
  }
  cout << ans << endl;
  return 0;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

// greatest common divisor
LL GCD(LL a,LL b){
    LL t; LL r;
    if(a<b){t=a;a=b;b=t;}
    if(b==0){return a;}
    while(a%b!=0){r=a%b;a=b;b=r;}
    return b;
}

// least common multiple
LL LCM(LL a,LL b){LL ab=(a*b);return ab/GCD(a%b,b);}

int main(){
    LL a,b;
    cin>>a>>b;
    
    cout<<LCM(a,b)<<endl;

    return 0;
}

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

int i,j,k;
int n[5],ans1=0,ans2=0;

int main(){
	while(scanf("%d,%d,%d",&n[0],&n[1],&n[2])!=EOF){
		if(n[0]==n[1])ans1++;
		else if(n[0]*n[0]+n[1]*n[1]==n[2]*n[2])ans2++;
	}
	printf("%d\n%d\n",ans2,ans1);
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){
cin.tie(0);
int x,n;
vector<int> tempResult;
cin >>x >>n;
int p[110];
if(n==0){cout <<x;return 0;}
for(int i=1;i<=n;i++){
  cin >>p[i-1];
}
for(int i=0;i<=n+1;i++){
  int k=0;
  if(i==0)k=x;
  else if(i%2==0)k=x+(i/2);
  else k=x-((i+1)/2);
  int c=0;
  for(int m=0;m<n&&c==0;m++){
   if(p[m]==k)c=1; 
  }
  //cout <<"k:" <<k <<"c:" <<c <<endl;
  //printf("k:%d c:%d\n",k,c);
  if(c==0){cout <<k;return 0;}
}

  
  
return 0;
}



Measured memory_bytes: 3620
import numpy as np

W, H, x, y = [int(i) for i in input().split()]

ans_1 = W*H/2

if (x == W/2) & (y == H/2):
    ans_2 = 1
else:
    ans_2 = 0
    
ans = str(ans_1) + " " + str(ans_2)

print(ans)

Measured memory_bytes: 12388
import java.util.*;

public class Main {

    static List<Integer> divisor(int n) {
        List<Integer> list = new ArrayList<Integer>();
        for (int i=1;i<=Math.sqrt(n);i++) {
            if (n%i==0) {
                list.add(i);
                if (i*i!=n) {
                    list.add(n/i);
                }
            }
        }
        Collections.sort(list);
        return list;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        for (int i=0;i<N;i++) {
            A[i] = sc.nextInt();
            if (map.containsKey(A[i])) {
                map.put(A[i], map.get(A[i])+1);
            } else {
                map.put(A[i], 1);
            }
        }

        int cnt = 0;
        for (int i=0;i<N;i++) {
            if (map.get(A[i])>1) {
                map.put(A[i], map.get(A[i])-1);
            } else {
                map.remove(A[i]);
            }

            ArrayList<Integer> div = new ArrayList<Integer>(divisor(A[i]));
            boolean flag = false;
            for (Integer element : div) {
                if (map.containsKey(element)) flag = true;
            }
            if (!flag) cnt++;

            if (map.containsKey(A[i])) {
                map.put(A[i], map.get(A[i])+1);
            } else {
                map.put(A[i], 1);
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 86820
#include <iostream>
#include <vector>

using namespace std;
constexpr long long int MOD = 1'000'000'007;

int main(void) {
    long long int N;
    cin >> N;
    vector<long long int> num(60);
    for(int i=0; i<N; i++) {
        long long int A;
        cin >> A;
        for(int j=0; j<60; j++) {
            if(A & (1LL << j)) {
                ++num.at(j);
            }
        }
    }

    long long int ans = 0;
    for(int j=0; j<60; j++) {
        long long int tmp1 = (1LL << j) % MOD;
        long long int tmp2 = (num.at(j) * (N-num.at(j))) % MOD;
        ans += (tmp1 * tmp2) % MOD;
        // ans =  (ans + ((num.at(j) * ((N-num.at(j))) * ((1LL << j) % 1'000'000'007LL)) % 1'000'000'007LL) % 1'000'000'007LL) % 1'000'000'007LL;
    }

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


Measured memory_bytes: 256