akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const ll INF = ll(1e16);
const int mod = 998244353;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
} 
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r; 
}
template<typename T_vector> // neal
void output_vector(const T_vector &v, bool add_one = false, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = int(v.size());
 
    for (int i = start; i < end; i++)
        cout << v[i] + (add_one ? 1 : 0) << (i < end - 1 ? ' ' : '\n');
}
int get(char c){
	if(c >= 'A') c = tolower(c);
	return c;
}

ll pref[N];
void solve()
{ 
	long long n, x, m;
	cin >> n >> x >> m;
	long long cycleSize = 0;
	ll a[max(x, m) + 3];
	map<long long, int> pos;
	a[1] = x;
	pref[1] = x;
	pos[x] = 1;
	int last = 0, first = 0;
	for(ll i = 2; i <= min(n, max(x, m) + 2); ++i)
	{	
		a[i] = a[i - 1] * a[i - 1] % m;
		pref[i] += pref[i - 1] + a[i];
		if(!pos.count(a[i])){
			pos[a[i]] = i;
		}
		else{
			cycleSize = i - pos[a[i]];
			last = i;
			first = pos[a[i]];
			break;
		}
	}
	if(n <= m) cout << pref[n];
	else{
		ll sum = pref[first];
		n -= first;
		ll div = n / cycleSize;
		ll md = n % cycleSize;
		// cout << a[last] << " " << a[first - 1] << '\n';
		sum += div * (pref[last] - pref[first]);
		sum += pref[first + md] - pref[first]; 
		cout << sum << '\n';
	}
}
	


int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    // Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 7440
# ABC089C - March
import sys
input = sys.stdin.readline

from itertools import combinations


def main():
    n = int(input())
    lst = [input().rstrip() for _ in range(n)]
    cond = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0}
    for i in lst:
        if i[0] in "MARCH":
            cond[i[0]] += 1
    ans = 0
    for x, y, z in combinations("MARCH", 3):
        ans += cond[x] * cond[y] * cond[z]
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9772
//I am a  noo0o0o0o0o0o0o0o00oOb
#include <bits/stdc++.h>

 
using namespace std;
 
typedef long long ll;
#define pi   acos(-1) 
#define endl "\n"
const int mod = 1000000007; 

int main()
{
	char x;
	cin >> x;
	printf("%c\n",x + 1);
	return 0;
}

Measured memory_bytes: 3776
#include<iostream>
#include<cctype>
#include<string>
#include<vector>
using namespace std;

vector<string> decompose(string s){
  vector<string> res;
  string tmp;
  tmp = s[0];
  
  for(int i=1;i<s.size();i++){
    if(isupper(s[i])){
      res.push_back(tmp);
      tmp = s[i];
    }else if(s[i] == '_'){
      res.push_back(tmp);
      tmp = "";
    }else{
      tmp += s[i];
    }
  }
  res.push_back(tmp);
  return res;
}

string unite(vector<string> v,char c){
  string res;

  for(int i=0;i<v.size();i++){
    if(c == 'D' || (c == 'L' && i==0)){
      v[i][0] = tolower(v[i][0]);
    }else{
      v[i][0] = toupper(v[i][0]);
    }

    if(c == 'D' && i!=0)res += "_";
    res += v[i];
  }
  return res;
}

int main(){
  string s;
  char c;

  while(cin >> s >> c, c!='X'){
    vector<string> v = decompose(s);
    cout << unite(v,c) << endl;
  }
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#pragma optimize ("O3")
#pragma target ("sse4")
const int MAXN=35;
const int INF=1e9+17;
const int MOD=1000000021;
using namespace std;

bool prime[60000];
int a[MAXN];
int ms[MAXN], m, n;
void mainp()
{
    for(int i=0; i<=55555; i++) prime[i]=1;
    prime[0]=prime[1]=0;
    for(int i=2; i<=55555; i++)
        if(prime[i]) for(int j=2*i; j<=55555; j+=i) prime[j]=0;
    
    int o1=0, o2=0, o3=0, o4=0;
    for(int i=0; i<=55555; i++)
        if(prime[i]&&i%5==2) a[m++]=i;
        
    cin>>n;
    for(int i=0; i<n; i++) cout<<a[i]<<" ";
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mainp();
    return 0;
}

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

int main()
{
	int N;
	cin >> N;
	uint32_t *A = new uint32_t[200000];
	for(int n=0; n<N; n++){
		cin >> A[n];
	}

	uint64_t res = 0;
	uint32_t bits = 0x00;
	int nm = 0;
	for(int n=0; n<N; n++){
		while(nm < N && (A[nm] & bits) == 0x00){
			bits |= A[nm];
			nm ++;
		}
		res += nm - n;
		bits &= ~(A[n]);
	}

	cout << res;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 1000000000000000000
using P = pair<int,int>;
 
int main() {
  #define int long long
  int n;
  cin >> n;
  vint A(n);
  int MIN = INF;
  int MINUS = 0;
  int sum = 0;
  rep(i,n){
    cin >> A[i];
    MIN = min(MIN,abs(A[i]));
    if(A[i] < 0) MINUS++;
    sum += abs(A[i]);
  }
  if(MINUS % 2 == 0){
    cout << sum << endl;
  }
  else{
    cout << sum - 2*MIN << endl;
  }
} 

Measured memory_bytes: 1024
import sys
ans = [0, 0, 0, 0]
for a, b, c in (sorted(map(int, l.split())) for l in sys.stdin.readlines()):
    if a+b <= c:
        print(*ans)
        exit()
    n, m = a**2+b**2, c**2
    ans[0] += 1
    if n == m:
        ans[1] += 1
    elif n > m:
        ans[2] += 1
    else:
        ans[3] += 1



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

string S, T;
vector<string> v;

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> S >> T;
    rep(i, S.size()-T.size()+1) {
        bool flag = true;
        rep(j, T.size()) {
            if (S[i+j]=='?') continue;
            else flag &= S[i+j]==T[j];
        }
        if (flag) {
            string s = "";
            rep(j, S.size()) {
                if (i<=j && j<i+T.size()) s += T[j-i];
                else {
                    if (S[j]=='?') s += "a";
                    else s += S[j];
                }
            }
            v.pb(s);
        }
    }
    sort(v.begin(), v.end());
    if (v.size()==0) cout << "UNRESTORABLE" << endl;
    else cout << v[0] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		sc.close();

		Interval inter1 = new Interval(A, B);
		Interval inter2 = new Interval(C, D);

		Interval sect = Interval.GetIntersection(inter1, inter2);
		if(sect == null){
			sect = new Interval(0,0);
		}
		int ans = sect.GetLength();

		System.out.println(ans);
	}
}


class Interval{
	int Start;
	int End;

	Interval(int s, int e){
		Start = s;
		End = e;
	}

	static Interval GetIntersection(Interval i1, Interval i2){
		if(i1.Start > i2.Start){
			return GetIntersection(i2, i1);
		}
		if(i1.End < i2.Start){
			return null;
		}
		return new Interval(i2.Start, Math.min(i1.End, i2.End));

	}

	int GetLength(){
		return End - Start;
	}
}


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

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define vec vector
#define ref(a) &(a)

typedef long long ll;

using namespace std;

int main() {
  int n; cin >> n;
  vec<int> s;
  rep(i, n) {
    int x; scanf("%d", ref(x));
    s.pb(x);
  }
  int q; cin >> q;
  vec<int> t;
  rep(i, q) {
    int x; scanf("%d", ref(x));
    t.pb(x);
  }

  int sum;
  rep(i, q) {
    if (*lower_bound(s.begin(), s.end(), t[i]) == t[i])
      sum++;
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3712
sub f{my($u,$t)=@_;$v[$_]++||f($_,$t^R,push@$t,$_)for@$u}@n=1..<>;map{push@$_,$u-$_+$;for($u,$;)=split}<>;f 1,b;map{$s=++$x-3;$s+3>$.or$a[$_]||=$s+=3for@$_}@b>$./3&@0>$./3?(0,b):(@b>@0?b:0)x2,n;print"@a"

Measured memory_bytes: 275840
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N,W;
  scanf("%ld%ld",&N,&W);
  vector<long>dp(W+1);
  for(int i=0;i<N;i++){
  	vector<long>new_dp(W+1);
    long weight,value;
    scanf("%ld%ld",&weight,&value);
    for(int j=0;j<=W;j++){
      if(j>=weight)
    	new_dp[j] = max(dp[j],dp[j-weight]+value);
      else
        new_dp[j] = dp[j];
    }
    dp = new_dp;
  }
  printf("%ld\n",dp[W]);
}

Measured memory_bytes: 1804
#include <bits/stdc++.h>
using namespace std;
using Int = long long unsigned;

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

    string s,t; cin>>s>>t; vector<int> sa[26]; Int key=0; int ba=-1; bool ok=true;
    for (int i = 0; i < s.size(); i++){
        char c=s[i];
        sa[c-'a'].push_back(i);
    }
    for (int i = 0; i < t.size(); i++){
        char c=t[i];
        if(sa[c-'a'].size()==0){cout<<-1<<'\n'; exit(0);}
        vector<int>::iterator it=upper_bound(sa[c-'a'].begin(),sa[c-'a'].end(),ba);
        if(it==sa[c-'a'].end()){key++; ba=sa[c-'a'][0];}
        else ba=*it;
    }
    cout<<key*s.size()+ba+1<<'\n';
}

Measured memory_bytes: 1228
X,Y,Z,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
list1=[]
for i in range(X):
  for j in range(Y):
      list1.append(A[i]+B[j])
list1.sort(reverse=True)
list1=list1[:K+1]
list2=[]
for i in range(min(X*Y,K)):
  for j in range(Z):
    list2.append(list1[i]+C[j])
list2.sort(reverse=True)
for i in range(K):
  print(list2[i])


Measured memory_bytes: 223264
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace C_test_For_Atcorder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var a = cin.ReadIntArray(N);
            Array.Sort(a);Array.Reverse(a);
            var alice = 0;
            var bob = 0;
            for (int i = 0; i < N;i++){
                if ((i % 2) == 0) alice += a[i];
                else bob += a[i];
            }
            WriteLine(alice-bob);

        }
    }


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue inputStream;

        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return (string)inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return (string)inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }

}

Measured memory_bytes: 13140
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   ll n,w;
   cin>>n>>w;
   pair<ll, ll> arr[n];
   
   for(int i=0;i<n;i++)
   {
   cin>>arr[i].first>>arr[i].second;
   }
   sort(arr,arr+n);
   ll dp[n+1][w+1]{};
   for(int i=1;i<=n;i++)
   {
       for(int j=1;j<=w;j++)
       {
           if(j<arr[i-1].first)
           {
               dp[i][j]=dp[i-1][j];
           }
           else
           {
               dp[i][j] = max(dp[i-1][j],dp[i-1][j-arr[i-1].first]+arr[i-1].second);
           }
       }
   }
   cout<<dp[n][w];

    return 0;
}


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

int main() {
  int x, y;
  cin >> x >> y;
  set<int> V={4,6,9,11};
  if (x==2 || y==2 || (V.count(x) && !(V.count(y))) || (V.count(y) && !(V.count(x)))) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


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

int main() {
    int n, c0=0, c1=0, c2=0, c3=0;
    cin >> n;
    vector<string> s(n);
    rep(i,n){
        cin >> s.at(i);
        if(s.at(i) == "AC") {
            c0++;
        } else if(s.at(i) == "WA"){
            c1++;
        } else if(s.at(i) == "TLE"){
            c2++;
        } else if(s.at(i) == "RE"){
            c3++;
        } 
    }
    cout << "AC x " << c0 << endl;
    cout << "WA x " << c1 << endl;
    cout << "TLE x " << c2 << endl;
    cout << "RE x " << c3 << endl;
    return 0;
}



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

using namespace std;

long long gcd( long long m, long long n )
{
    if(n==0ll)return m;
    else return gcd(n,m%n);
}//gcd


int main() {
    int n;
    cin>>n;
    long long time[n];
    for (int i = 0; i < n; ++i) {
        cin>>time[i];
    }
    long long re=time[0];
    for (int j = 1; j < n; ++j) {
        re=re/gcd(re,time[j])*time[j];
    }
    cout<<re<<endl;
    return 0;
}

Measured memory_bytes: 256
r1,c1,r2,c2 = map(int,input().split())

MOD = 10**9+7
MAXN = 2*10**6+5
fac = [1,1] + [0]*MAXN
finv = [1,1] + [0]*MAXN
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def ncr(n,r):
    if n < r: return 0
    if n < 0 or r < 0: return 0
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD

ans = 0
for r in range(r1,r2+1):
    ans += ncr(r+c2+1, r+1) - ncr(r+c1, r+1)
ans %= MOD
print(ans)

Measured memory_bytes: 104816
import sys
input = sys.stdin.readline
mod = 10**9 + 7

h, w, k = [int(x) for x in input().split()]

dp = [[0]*w for _ in range(h + 1)]
dp[0][0] = 1

for i in range(h):
    for j in range(w):
        x = 0 # right
        y = 0 # left
        z = 0 # remain
        for l in range(2**(w - 1)):
            l = bin(l)[2:].zfill(w - 1)
            if "11" in l:
                continue
            if j - 1 >= 0 and l[j - 1] == "1":
                y += 1
            elif j + 1 < w and l[j] == "1":
                x += 1
            else:
                z += 1
        if j + 1 < w:
            dp[i + 1][j + 1] += x * dp[i][j]
            dp[i + 1][j + 1] %= mod
        if j - 1 >= 0:
            dp[i + 1][j - 1] += y * dp[i][j]
            dp[i + 1][j - 1] %= mod
        dp[i + 1][j] += z * dp[i][j]
        dp[i + 1][j] %= mod

print(dp[-1][k - 1])
            
            


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

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

    vector<vector<int>> edge(n);
    for (int i = 0; i < n; i++) {
        int m, c;
        cin >> m >> c;
        for (int j = 0; j < c; j++) {
            int x;
            cin >> x;
            edge[i].push_back(--x);
        }
    }

    int timestamp = 1;
    vector <int> d(n, -1), f(n, -1);
    auto dfs = [&](auto dfs, int cur) -> void {
        d[cur] = timestamp++;
        for (int ch : edge[cur]) {
            if (d[ch] == -1) {
                dfs(dfs, ch);
            }
        }
        f[cur] = timestamp++;
    };

    for (int i = 0; i < n; i++) {
        if (d[i] == -1) {
            dfs(dfs, i);
        }
    }

    for (int i = 0; i < n; i++) {
        cout << i + 1 << ' ' << d[i] << ' ' << f[i] << '\n';
    }

    return 0;
}


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

int main(){
  int X;
  cin >> X;
  int ans=1;
  int num=0;
  if(X<4) num=1;
  else{
    for(int i=2; i<32; i++){
      for(int j=2; j<10;j++){
        ans=std::pow(i, j);
        if(ans>X) break;
        else num=max(num, ans);
      }
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <fstream>
#include <cstring>

using namespace std;

// AGC,ACG,GAC
long long int dp[101][4][4][4];
long long int MOD = 1e9 + 7;
string s = "ACGT";

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

	memset(dp, 0, sizeof(dp));

	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 4; j++)
		{
			for (int k = 0; k < 4; k++)
			{
				if (s[i] == 'A' && s[j] == 'C' && s[k] == 'G')
				{
					continue;
				}
				if (s[i] == 'A' && s[k] == 'C' && s[j] == 'G')
				{
					continue;
				}
				if (s[i] == 'G' && s[j] == 'A' && s[k] == 'C')
				{
					continue;
				}
				dp[3][i][j][k] = 1;
			}
		}
	}

	for (int i = 4; i <= 100; i++)
	{
		for (int a = 0; a < 4; a++)
		{
			for (int b = 0; b < 4; b++)
			{
				for (int c = 0; c < 4; c++)
				{
					for (int d = 0; d < 4; d++)
					{
						if (s[b] == 'A' && s[c] == 'G' && s[d] == 'C')
						{
							continue;
						}
						if (s[b] == 'A' && s[c] == 'C' && s[d] == 'G')
						{
							continue;
						}
						if (s[b] == 'G' && s[c] == 'A' && s[d] == 'C')
						{
							continue;
						}
						if (s[a] == 'A' && s[b] == 'G' && s[d] == 'C')
						{
							continue;
						}
						if (s[a] == 'A' && s[c] == 'G' && s[d] == 'C')
						{
							continue;
						}
						dp[i][b][c][d] = (dp[i][b][c][d] % MOD) + (dp[i - 1][a][b][c] % MOD);
						dp[i][b][c][d] %= MOD;
					}
				}
			}
		}
	}

	long long int res = 0;
	int n;

	cin >> n;

	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 4; j++)
		{
			for (int k = 0; k < 4; k++)
			{
				res = (res%MOD) + (dp[n][i][j][k] % MOD);
				res %= MOD;
			}
		}
	}

	cout << res << '\n';

	return 0;
}


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

using namespace std;

int main() {

    int a, b;
    cin >> a >> b;

    if (a % 2 != 0 && b % 2 != 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 100005;
struct Edge{
	int to,next,w;
}e[MAXN<<1];
int head[MAXN],n,m,cnt;
inline void insert(int u,int v)
{
	e[++cnt].to=v,e[cnt].next=head[u],head[u]=cnt,e[cnt].w=1;
	e[++cnt].to=u,e[cnt].next=head[v],head[v]=cnt,e[cnt].w=2;
}
int mark[MAXN],sz,ecnt;
bool succ;
int t[5];
void dfs(int x)
{
	++t[mark[x]];
	++sz;
	for(int i=head[x];i;i=e[i].next){
		int v=e[i].to;
		++ecnt;
		if(mark[v]==-1)mark[v]=(mark[x]+e[i].w)%3,dfs(v);
		else if(mark[v]!=(mark[x]+e[i].w)%3)succ=false;
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i){
		int u,v;
		scanf("%d%d",&u,&v);
		insert(u,v);
	}
	memset(mark,-1,sizeof(mark));
	long long ans=0;
	for(int i=1;i<=n;++i)
		if(mark[i]==-1){
			sz=0;
			succ=true;
			memset(t,0,sizeof(t));
			mark[i]=0;
			ecnt=0;
			dfs(i);
			if(!succ)ans+=(long long)sz*sz;
			else{
				int flag=1;
				for(int i=0;i<3;++i)flag&=bool(t[i]);
				if(flag){
					ans+=(long long)t[0]*t[2]+(long long)t[1]*t[0]+(long long)t[2]*t[1];
				}else ans+=ecnt/2;
			}
		}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    for(int i = 1; n >= i; i++){
        if(i % 3 == 0){
            cout << " " << i;
        } else {
            int x = i;
            while(x != 0){
                if(x % 10 == 3){
                    cout << " " << i;
                    x = 0;
                }else{
                    x /= 10;
                }
            }
        }
    }
    cout << endl;
}




Measured memory_bytes: 3108
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <cmath>
using namespace std;
typedef long long ll;

int main(){
    int n; cin >> n;
    ll res = 0;
    for(ll i=1; i<=n; ++i){
        ll m = n/i;
        ll fx = (2*i + (m-1)*i) * m/2;
        res += fx;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;


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

	int a, b, c;
	cin >> a >> b >> c;
	if (a == b&&b == c) puts("1");
	else if (a == b || b == c || a == c) puts("2");
	else puts("3");
	return 0;
}

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

#define WHITE 0
#define BRACK 1

int **matrix;
int *d;
int *parent;
int *color;

void prim(int);

int main(){
  int n,i,j;
  int cost=0;
  scanf("%d",&n);

  color =  malloc(n * sizeof(int ));
  d =  malloc(n * sizeof(int ));
  parent = malloc(n * sizeof(int));

  matrix = malloc(n * sizeof(int *));
  for(i=0;i<n;i++)
    matrix[i] = malloc(n * sizeof(int));

  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      matrix[i][j] = -1;
  
  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      scanf("%d",&matrix[i][j]);

  prim(n);

  for(i=0;i<n;i++)
    cost += d[i];
   
  printf("%d\n",cost);

  free(d);
  free(color);
  free(parent);
  for(i=0;i<n;i++) free(matrix[i]);
  free(matrix);

  return 0;
  
}


void prim(int n){
  int mincost;
  int i,j,u;

  for(i=0;i<n;i++){
    d[i] = 2001;
    parent[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(1){
    mincost = 2001;

    for(i=0;i<n;i++){
      if(color[i] != BRACK && d[i] < mincost){
	mincost = d[i];
	u = i;
      }
    }

    if(mincost == 2001) break;

    color[u] = BRACK;

    for(i=0;i<n;i++){
      if(color[i] != BRACK && matrix[u][i] != -1 && matrix[u][i] < d[i]){
	d[i] = matrix[u][i];
	parent[i] = u;
      }
    }
  }
}

Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

a, b, c = MAP()

if a + b == c:
	print("Yes")
elif a + c == b:
	print("Yes")
elif b + c == a:
	print("Yes")
else:
	print("No")

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

namespace abc105_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(x[0] % x[1] == 0 ? 0 : 1);
        }
    }
}


Measured memory_bytes: 13268
import heapq


def dijkstra(n, s, g):
    h = [(0, s)]
    heapq.heapify(h)
    cost = [float("Inf")] * (n + 1)  # cost: i -> j
    cost[s] = 0

    while h:
        c, v = heapq.heappop(h)
        if c > cost[v]:
            continue
        for d, u in g[v]:
            d_s_u = d + cost[v]
            if d_s_u < cost[u]:
                cost[u] = d_s_u
                heapq.heappush(h, (d_s_u, u))

    return cost


def main():
    n, m, *abc = map(int, open(0).read().split())
    g = [[] for _ in range(n + 1)]

    for a, b, c in zip(*[iter(abc)] * 3):
        g[a].append([c, b])
        g[b].append([c, a])

    ans = 0
    checked = [[False] * (n + 1) for _ in range(n + 1)]
    for i in range(1, n + 1):
        cost = dijkstra(n, i, g)
        for j, k in g[i]:
            if checked[i][k]:
                continue
            if j > cost[k]:
                ans += 1

            checked[i][k] = True
            checked[k][i] = True

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9328
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kishan Sairam Adapa
 */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define ll long long int
#define MOD ((int)(1e9) + 7)

using namespace std;

class BSmallAndLargeIntegers {
public:
    void solve(istream& cin, ostream& cout) {
        ll a, b, k;
        cin >> a >> b >> k;
        ll e1 = a+k-1, s2 = b+1-k;
        if(s2 > e1) {
            for(int i=a; i<=e1; i++) cout << i << '\n';
            for(int i=s2; i<=b; i++) cout << i << '\n';
        } else
            for(int i=a; i<=b; i++) cout << i << '\n';
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    BSmallAndLargeIntegers solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

int b[200];
int a[200];
int main(){
	int n;cin>>n;
	memset(a,0x3f,sizeof(a));
	rep(i,n-1){
		cin>>b[i];
		a[i]=min(a[i],b[i]);
		a[i+1]=min(a[i+1],b[i]);
	}
	int ans=0;
	rep(i,n)ans+=a[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 256
def dfs(v)
  @used[v] = true;
  G[v].size.times do |i|
    u = G[v][i]
    w = @match[u];
    if w < 0 || !@used[w] && dfs(w)
      @match[v] = u
      @match[u] = v
      return true
    end
  end
  false
end

def bipartite_matching
  res = 0
  @match = Array.new(V, -1);
  V.times do |v|
    if @match[v] < 0
      @used = Array.new(V, false)
      res += 1 if dfs(v)
    end
  end
  res
end

N = gets.to_i
rs = Array.new(N) { gets.split.map(&:to_i) }
bs = Array.new(N) { gets.split.map(&:to_i) }

V = N * 2
G = Array.new(N * 2) { Array.new }

N.times do |i|
  N.times do |j|
    if rs[i][0] < bs[j][0] && rs[i][1] < bs[j][1]
      G[i] << N + j
      G[N + j] << i
    end
  end
end

puts bipartite_matching


Measured memory_bytes: 4092
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,v,k,a[20],x[200005],f[200005][20],L[200005][20],R[200005][20],dpl[262222],dpr[262222],dp[200005];
void upda(int &x,int y){if(y>x)x=y;}
void updi(int &x,int y){if(y<x)x=y;}
int main(){
    scanf("%d%d",&n,&v);
    for(int i=1;i<=n;++i)scanf("%d",x+i);
    for(int i=1;i<n;++i)x[i]=x[i+1]-x[i];
    a[0]=v/2;
    while(a[k])a[k+1]=a[k]/2,++k;
    a[++k]=v;
    for(int i=1;i<n;++i)f[i][0]=x[i];
    for(int j=0;j<17;++j){
        for(int i=1;i<=n-(2<<j);++i)f[i][j+1]=max(f[i][j],f[i+(1<<j)][j]);
    }
    for(int i=1;i<=n;++i){
        for(int j=0;j<=k;++j){
            int o=i;
            for(int _=17;_>=0;--_)if(o>(1<<_)&&f[o-(1<<_)][_]<=a[j])o-=(1<<_);
            L[i][j]=o;
            o=i;
            for(int _=17;_>=0;--_)if(o+(1<<_)<=n&&f[o][_]<=a[j])o+=(1<<_);
            R[i][j]=o;
        }
    }
    for(int _=0;_<(1<<k);++_){
        int d=min(dpl[_]+1,n);
        for(int i=0;i<k;++i){
            if(_&(1<<i)) continue;
            upda(dpl[_|(1<<i)],R[d][i]);
        }
        dpr[_]=n+1;
    }
    memset(dp,-1,sizeof(dp));
    for(int _=0;_<(1<<k);++_){
        int d=max(dpr[_]-1,0);
        for(int i=0;i<k;++i){
            if(_&(1<<i)) continue;
            updi(dpr[_|(1<<i)],L[d][i]);
        }
        upda(dp[dpr[_]],dpl[((1<<k)-1)^_]);
    }
    for(int i=2;i<=n+1;++i)upda(dp[i],dp[i-1]);
    for(int i=1;i<=n;++i){
        if(dp[R[i][k]+1]>=L[i][k]-1)puts("Possible");
        else puts("Impossible");
    }
    //system("pause");
    return 0;
}


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

    using namespace std;
    template <typename T>
    void debug(string t, T input) {
        cout<<t<<"-> "<<input<<"\n";
    }
    template <typename T>
    void debug(int i,string t, T input) {
        cout<<"Case#"<<i<<" "<<t<<"-> "<<input<<"\n";
    }

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int n,k;
        cin>>n>>k;
        vector<int>a(n);
        for(int i=0;i<k;i++){
            int d;
            cin>>d;
            for(int j=0;j<d;j++){
                int x;
                cin>>x;
                --x;
                a[x]++;
            }
        }
        int total=0;
        for(int i=0;i<n;i++){
            if(a[i]==0)
                total++;
        }
        cout<<total;
        return 0;
    }


Measured memory_bytes: 3652
#!/usr/bin/env python3
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a_idx = a.index(min(a))
b_idx = b.index(min(b))
#print(a_idx,b_idx)

ans = min(a)+min(b)
for i in range(m):
    x,y,c = map(int,input().split())
    if x-1 != a_idx or y-1 != b_idx:
        ans = min(ans,a[x-1]+b[y-1]-c)
    if x-1 == a_idx and y-1 == b_idx:
        ans = min(ans,a[x-1]+b[y-1]-c)
print(ans)

Measured memory_bytes: 70980
s = list(input())
s_setted = list(set(s))
if len(s_setted) == 2:
    s_one = 0
    s_two = 0
    for s_elem in s:
        if s_elem == s_setted[0]:
            s_one += 1
        if s_elem == s_setted[1]:
            s_two += 1
    if s_two == 2 and s_one == 2:
        print("Yes")
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 3060
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

d = str(input())

d=d.swapcase()

print(d)



Measured memory_bytes: 6848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  int N; cin>>N;
  map<string, int> plist;
  int cumu[N+1]; cumu[0] = 0;
  REP(i,N){
    string s; cin>>s;
    int t; cin>>t;
    plist[s] = i+1;
    cumu[i+1] = cumu[i] +t;
  }
  string X; cin>>X;
  int idx = plist[X];
  cout << cumu[N]-cumu[idx] <<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
int lcm(int a,int b)
{
	return a/__gcd(a,b)*b;
}

int main()
{
	puts(abs(read()-read())<=1?"Brown":"Alice");
	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>

using namespace std;


#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;


/*vectorの要素を全部確認するやつだよ。普通に拡張for文したほうがいいよ。

for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}

*/


/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}

*/


/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/


/*実行開始からの経過時間を表すよ。

while (clock() < 1900000) {  }

*/


/*まだ使えないテクニックのメモだよ。

for (int bit = 0; bit < (1<<n); ++bit)//bit全探索用のfor文だよ

*/


/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; ++i) {
	for (int j = 0; j < w; ++j) {

	}
}

*/

int main() {

	int n;

	int a[1005];
	for (int i = 0; i <= 1002; i++) {
		a[i] = i;
	}

	while (1) {
		cin >> n;
		if (n == 0) { return 0; }

		int tmp = 0;

		int r = 1, l = 1;
		int ans = 0;

		while (r < n) {
			tmp += r;
			//cout << l << " " << r << endl;
			while (tmp > n) { tmp -= l; l++; }
			if (tmp == n) { ans++; }
			r++;
		}

		cout << ans << endl;

	}

	return 0;
}



Measured memory_bytes: 3084
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> H >> W;
	int ans = LINF;
	rep(_, 2) {
		for (int i = 1; i < H; i++) {
			int H2 = H - i;
			int W2 = W;
			rep(__, 2) {
				int H3 = H2 / 2, H4 = H2 - H3;
				int Smax = max(i * W, max(H3 * W2, H4 * W2));
				int Smin = min(i * W, min(H3 * W2, H4 * W2));
				chmin(ans, Smax - Smin);
				swap(H2, W2);
			}
		}
		swap(H, W);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#include <algorithm>
#include <queue>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

const int maxn = 100005;
struct obj {
	int a, b;
};
obj ob[maxn];
ll lget[maxn], rget[maxn];

int main() {
	int x = read, y = read, z = read;

	int n = x + y + z;
	ll ans = 0;
	for(int i = 1; i <= n; i ++) {
		int v = read;
		ans += v;
		ob[i].a = read - v;
		ob[i].b = read - v;
	}

	std::sort(ob + 1, ob + n + 1, [](obj x, obj y) {
				return x.a - x.b > y.a - y.b;
			});

	/* debug("%lld\n", ans); */
	/* for(int i = 1; i <= n; i ++) */
	/* 	debug("%d %d\n", ob[i].a, ob[i].b); */

	std::priority_queue<int, std::vector<int>, std::greater<int> > biggest;

	for(int i = 1; i <= n; i ++) {
		lget[i] = lget[i - 1] + ob[i].a;
		biggest.push(ob[i].a);
		if(int(biggest.size()) > y) {
			lget[i] -= biggest.top();
			biggest.pop();
		}
	}

	while(!biggest.empty()) biggest.pop();
	for(int i = n; i; i --) {
		rget[i] = rget[i + 1] + ob[i].b;
		biggest.push(ob[i].b);
		if(int(biggest.size()) > z) {
			rget[i] -= biggest.top();
			biggest.pop();
		}
	}

	/* for(int i = 1; i <= n; i ++) */
	/* 	debug("l=%lld r=%lld\n", lget[i], rget[i]); */

	ll max = - 1000000000000000000;
	for(int k = y; k <= n - z; k ++)
		max = std::max(max, lget[k] + rget[k + 1]);

	printf("%lld\n", ans + max);
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
long long s1,s2,s3;
int main()
{
	cin>>n>>a>>b;
	for(int i=1,x;i<=n;i++)
	{
		cin>>x;
		if(x<=a)s1++;
		else if(x>b)s3++;
		else s2++;
	}
	cout<<min(s1,min(s2,s3))<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
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;}
template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){return a/GCD(a,b)*b;}

int main(){
	int n;
	cin >> n;
	vector<int> prime;
	for(int i=11;i<=55555;i+=10){
		int num=i;
		bool a=1;
		for(int j=2;j*j<=i;j++){
			if(num%j==0){
				a=0;
			}
		}
		if(a){
			prime.push_back(i);
		}
	}

	FOR(i,n){
		cout << prime[i] << " ";
	}

	cout << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int x = (a % 2) + (b % 2) + (c % 2);
    cout << (x <= 1 ? "Tem" : "Hom") << endl;

    return 0;
}



Measured memory_bytes: 3136
H, W, K = map(int, input().split())
Ss = [list(map(int, input().replace("\n", ""))) for _ in range(H)]

cut_yoko_patterns = ["0","1"]
options = ["0","1"]

import copy

for i in range(H-2):
    cut_yoko_patterns = [cut_yoko_patterns[i] + options[j] for i in range(len(cut_yoko_patterns)) for j in range(len(options))]

answer = int(1e+5)
for cut_yoko_pattern in cut_yoko_patterns:
    yoko_cut_num = cut_yoko_pattern.count("1")
    boxs = [0 for _ in range(yoko_cut_num+1)]
    box_num = [0 for _ in range(H)]
    for i in range(H-1):
        if cut_yoko_pattern[i] == "1":
            box_num[i+1] = box_num[i] + 1
        else:
            box_num[i+1] = box_num[i]
    
    tate_cut_num = 0
    for j in range(W):
        temp_boxs = [0 for _ in range(yoko_cut_num+1)]
        for i in range(H):
            if Ss[i][j] == 1:
                temp_boxs[box_num[i]] += 1
        Impossible = False
        Should_cut = False
        for i in range(yoko_cut_num+1):
            if temp_boxs[i] > K:
                Impossible = True
            
            elif boxs[i] + temp_boxs[i] > K:
                Should_cut = True
        
        if Impossible == True:
            break
        elif Should_cut ==True:
            boxs = copy.deepcopy(temp_boxs)
            tate_cut_num += 1
        else:
            for i in range(yoko_cut_num+1):
                boxs[i] += temp_boxs[i]
    else:
        
        if tate_cut_num+yoko_cut_num < answer:
            answer = tate_cut_num + yoko_cut_num
print(answer)

Measured memory_bytes: 70840
package main

import (
	"fmt"
	"math"
)

func main() {

	var n int
	fmt.Scan(&n)
	x := make([]float64, n)
	y := make([]float64, n)
	for i:=0; i<n; i++ {
		fmt.Scan(&x[i])
	}
	for i:=0; i<n; i++ {
		fmt.Scan(&y[i])
	}

	dis1, dis2, dis3, disInf := 0.0, 0.0, 0.0, 0.0

	for i:=0; i<n; i++ {
		abs := math.Abs(x[i]-y[i])
		dis1 += abs
		dis2 += abs*abs
		dis3 += abs*abs*abs
		disInf = math.Max(abs,disInf)
	}

	fmt.Println(dis1)
	fmt.Println(math.Pow(dis2,1.0/2.0))
	fmt.Println(math.Pow(dis3,1.0/3.0))
	fmt.Println(disInf)

}


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

int main(){
    int n;
    cin >> n;
    int h;
    int hmax = 0;
    int ans = 0;
    rep(i,n){
        cin >> h;
        if(h>=hmax)ans++;
        hmax = max(hmax, h);
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256