akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define sz(v) (int)v.size()
#define debug(var) cout << #var << ": " << var << endl;
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int r, c, k;
    cin >> r >> c >> k;
    vector<vector<int>> a(r, vector<int>(c));
    while (k--) {
        int x, y, v;
        cin >> x >> y >> v;
        a[x - 1][y - 1] = v;
    }
    array<vector<array<ll, 4>>, 2> dp;
    dp.fill(vector<array<ll, 4>>(c + 1));
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            auto &dpc = dp[(i + 1) & 1][j + 1];
            auto &dpcu = dp[i & 1][j + 1];
            auto &dpcl = dp[(i + 1) & 1][j];

            ll umax = 0;
            for (int l = 0; l < 4; l++)
                umax = max(umax, dpcu[l]);

            // not select
            dpc[0] = max(dpcl[0], umax);
            for (int l = 1; l < 4; l++)
                dpc[l] = dpcl[l];

            // select
            dpc[1] = max(dpc[1], max(dpcl[0], umax) + a[i][j]);
            for (int l = 1; l < 4; l++)
                dpc[l] = max(dpc[l], dpcl[l - 1] + a[i][j]);

            // for (int l = 0; l < 4; l++) cout << dpc[l] << " ";
            // cout << endl;
            // cout << '(';
            // for (int l = 0; l < 4; l++) cout << dpc[l] << ",";
            // cout << ')';
        }
        // cout << endl;
    }
    ll ans = 0;
    for (int l = 0; l < 4; l++)
        ans = max(ans, dp[r & 1][c][l]);
    cout << ans;
}

Measured memory_bytes: 38972
package main
import (
	"fmt"
	"os"
	"bufio"
	"strings"
)

var stdin = bufio.NewScanner(os.Stdin)
var rdr = bufio.NewReaderSize(os.Stdin,1000000)
func readLine() string{
	//長いトークンを読み込みたい場合
	buf := make([]byte,0,1000000)
	for {
		read,isPrefix,error := rdr.ReadLine()
		if error!= nil{
			panic(error)
		}
		buf = append(buf,read...)
		if !isPrefix{
			break
		}
	}
	return string(buf)
}

func Input_Str() string {
	//かんたんに読み込みたい場合
	stdin.Scan()
	stringInput := stdin.Text()
	out := strings.TrimSpace(stringInput)
	return out
}

func main(){
	stdin.Split(bufio.ScanWords)
	s := readLine()
	count_W:=0
	count_B:=0

	for i:=0;i<len(s);i++{
		if i%2==0{
			if s[i]=='0'{
				count_W++
			}else{
				count_B++
			}
		}else{
			if s[i]=='1'{
				count_W++
			}else{
				count_B++
			}
		}
	}
	
	if count_W < count_B{
		fmt.Println(count_W)
	}else{
		fmt.Println(count_B)
	}
}



Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 25 17:57:31 2020

@author: Paras
"""

n,k = map(int, input().split())
marks = list(map(int, input().split()))
i = 0
j = i+k
while j<n:
    if marks[j]>marks[i]:
        print("Yes")
    else:
        print("No")
    i+=1
    j+=1

Measured memory_bytes: 31408
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int ac=0, prob[n]={0},pen=0;
  for(int i=0;i<m;i++){
  string s; int k;
    cin>>k>>s;
    if(prob[k-1]==-1) continue;
    else if(s=="WA" && prob[k-1]!=-1) prob[k-1]++;
    else if(s=="AC") {
      ac++;
      pen+=prob[k-1];
      prob[k-1]=-1;
    }
      
  }
  cout<<ac<<" "<<pen<<endl;
return 0;
}

Measured memory_bytes: 640
s = input()
f = False
for i,c in enumerate(s):
    if i == 0:
        if c != 'A':
            print('WA')
            exit()
    elif i == 1 or i == len(s) - 1:
        if ord('A') <= ord(c) <= ord('Z'):
            print('WA')
            exit()
    elif c == 'C':
        if f:
            print('WA')
            exit()
        f = True
    elif ord('A') <= ord(c) <= ord('Z'):
        print('WA')
        exit()
if f:
    print('AC')
else:
    print('WA')


Measured memory_bytes: 3064
n,m=(int(i) for i in input().split())
mtrx=[[int(i) for i in input().split()] for j in range(m)]
#print(mtrx)
mtrx+=[[mtrx[i][1],mtrx[i][0]] for i in range(m)]
#print(mtrx)
mylist=[10*mtrx[i][0]+mtrx[i][1] for i in range(len(mtrx))]
#print(mylist)
# 順列を格納するリスト
perm = []
cnt=[]
# 順列の生成
def make_perm(n, m = 0):
    if n == m and perm[0]==1:
        flag=1
        for i in range(len(perm)-1):
            myval=10*perm[i]+perm[i+1]
            myval1=mylist.count(myval)
            flag=flag*myval1
        cnt.append(flag)
        
    else:
        for x in range(1, n + 1):
            if x in perm: continue
            perm.append(x)
            make_perm(n, m + 1)
            perm.pop()
            
make_perm(n)
print(sum(cnt))

Measured memory_bytes: 3064
import statistics
import sys
import math
INPUT = sys.stdin.readline
#入力関数
def SORO_INT(): return int(INPUT())
def MULT_INT_LIST(): return list(map(int, INPUT().split()))
def MULT_INT_MAP(): return map(int, INPUT().split())
def SORO_STRING(): return INPUT()
def MULT_STRING(): return INPUT().split()
 
def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False
    
A = MULT_INT_LIST()
mean = statistics.mean(A)
 
if is_integer_num(mean):
  print(int(mean))
else:
  print('IMPOSSIBLE')

Measured memory_bytes: 5404
def main():
    D, G = map(int, input().split())
    P = [0]*D
    C = [0]*D
    for i in range(D):
        P[i], C[i] = map(int, input().split())
    S = [0]*D
    ans = sum(P)
    for i in range(D):
        S[i] = (i + 1) * 100 * P[i] + C[i]
    # print(D, G, P, C, S)
    for i in range(2**D):
        score = 0
        count = 0
        num_solved = 0
        solved = [0]*D

        while i > 0:
            if i % 2 == 1:
                score += S[count]
                num_solved += P[count]
                solved[count] = 1
            i //= 2
            count += 1
        if score >= G:
            ans = min(ans, num_solved)
        else:
            d = G - score
            # print('d={}'.format(d))
            for j in range(D):
                index = D - j - 1
                # print('index={}, solved={}'.format(index, solved))
                if solved[index] == 1:
                    continue
                required = (d + (index + 1) * 100 - 1) // ((index + 1) * 100)
                # print('required={}'.format(required))
                if required < P[index]:
                    num_solved += required
                    ans = min(ans, num_solved)
                break
    print(ans)

if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
	int n;
	while (cin >> n && n) {
		vector<string> f(n);
		for (int i = 0; i < n; ++i) cin >> f[i];
		int cnt = 0;
		for (int i = 1; i < n; ++i)
			if (f[i - 1][1] == f[i][1]) cnt++, i++;
		cout << cnt << endl;
	}

	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <math.h>
using namespace std;

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

  int ans = 1;
  for(int i = 1; i <= sqrt(m); i++){
    if(m % i == 0){
      if(i <= m/n) ans = max(ans, i);
      if(m/i <= m/n) ans = max(ans, m/i);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

typedef complex<int> point;

int main() {
  vector<point> a(4);
  for (int i = 0; i < 2; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    a[i] = point(x, y);
  }
  a[2] = a[1] + (a[1] - a[0]) * point(0, 1);
  a[3] = a[2] + (a[2] - a[1]) * point(0, 1);
  printf("%d %d %d %d\n", a[2].real(), a[2].imag(), a[3].real(), a[3].imag());
  return 0;
}


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

int main()
{
int n,x,c=1;
cin >> n >> x;
int l[n],d[n+2];
d[1] = 0;
for(int i=1;i<=n;i++) cin >> l[i];
for(int i=2;i<=n+1;i++){
  d[i]=d[i-1]+l[i-1]; 
  if(d[i]<=x)
    c++;}
cout << c;

}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
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;
 
#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()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    ll A, B; cin >> A >> B;
    char C; cin >> C;
    int D; cin >> D;
    B *= 100; B += D;
    ll X = A*B; X /= 100;
    cout << X << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343
 

Measured memory_bytes: 3640
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
	int N;
	int a;
	cin >> N;
	for (int i = 0; i < 100; i++) {
		if (N < pow(2, i)) break;
		a = pow(2, i);
		}
	cout << a<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long sum=0;
		sc.close();
		for(int i=1;i<=n;i++) {
			if(!(i%3==0 || i%5==0)) sum+=(long)i;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 35528
#include <bits/stdc++.h>
#define ll long long
#define res register int
#define N 1005
#define inf 0x3f3f3f3f
using namespace std;
int n, f[N * 5], g[N], a[N];
vector<int> son[N];
inline int read(){
    res w = 0, X = 0; register char ch = 0;
    while(!isdigit(ch)){w |= ch == '-'; ch = getchar();}
    while(isdigit(ch)){X = (X << 1) + (X << 3) + (ch ^ 48); ch = getchar();}
    return w ? -X : X;
}
inline void dfs(res now, res fa){
	for(res i = 0; i < son[now].size(); i++)
	  dfs(son[now][i], now);
	memset(f, inf, sizeof(f));
	f[0] = 0;
	for(res i = 0; i < son[now].size(); i++)
	  for(res j = a[now]; ~j; j--){
	  	res sum = inf;
	    if(j >= g[son[now][i]]) sum = min(sum, f[j - g[son[now][i]]] + a[son[now][i]]);
	    if(j >= a[son[now][i]]) sum = min(sum, f[j - a[son[now][i]]] + g[son[now][i]]);
	    f[j] = sum;
	  }
	res sum = inf;
	for(res i = 0; i <= a[now]; i++)
	  sum = min(sum, f[i]);
	if(sum == inf){
		puts("IMPOSSIBLE");
		exit(0);
	}
	g[now] = sum;
}
int main(){
	n = read();
	for(res i = 2; i <= n; i++){
		res fa = read();
		son[fa].push_back(i);
	}
	for(res i = 1; i <= n; i++)
	  a[i] = read();
	dfs(1, 0);
	puts("POSSIBLE");
	return 0;
}

Measured memory_bytes: 384
#create date: 2020-03-22 21:01

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n, m = na()
    print(n*(n-1)//2 + m*(m-1)//2)

if __name__ == "__main__":
    main()

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define repU(i,s,t) for(int i = (s); i <= (t); ++i)
#define repD(i,t,s) for(int i = (t); i >= (s); --i)
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1)/(d) + 1)
#define parity(a,b) (((a)^(b)) & 1 ^ 1)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = (1 << 30) - 1;
const ll INF_64 = (1LL << 62) - 1;
const int MOD = 1e9 + 7;

ull next_subset(ull s){
	ull tem = s + (s & -s);
	ull btm = (~tem & s) / (s & -s) >> 1;
	return btm | tem;
}


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

	int n,a[3],b,c,d,m;
	string s,t; cin>>s>>t;
	rep(i,s.size()){
		string u;
		repU(j,i,s.size()-1) u.pub(s[j]);
		repU(j,0,i - 1) u.pub(s[j]);
		if(u == t){
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No"<<endl;
}


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

using namespace std;
using LL = long long;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = (int)1e9 + 7;

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

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

    cout << min(a, b) << " " << max((a + b) - n, 0) << endl;
}

Measured memory_bytes: 256
s=int(input())
INF=10**9 + 7

dp=[0]*(s+1)
dp[0]=1

for i in range(1,s+1): #敷居の数
	for j in range(0,(i-3)+1):
		dp[i]+=dp[j]
		dp[i]%=INF

print(dp[-1])

Measured memory_bytes: 9136
#include "bits/stdc++.h"
using namespace std;

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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


#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/

// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
	os << "(" << pair_var.first << ", " << pair_var.second << ")";
	return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	os << "{";
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
	}
	os << "}";
	return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
	os << "{";
	repi(itr, map_var) {
		os << *itr;
		itr++;
		if (itr != map_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
	os << "{";
	repi(itr, set_var) {
		os << *itr;
		itr++;
		if (itr != set_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}

#define DUMPOUT cerr

void dump_func() {
	DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
	DUMPOUT << head;
	if (sizeof...(Tail) > 0) {
		DUMPOUT << ", ";
	}
	dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif



signed main() {

	double a, b, x;
	cin >> a >> b >> x;

//	dump(tan(4.236394));

	double theta;
	if (x >= a * a * b / 2.0) {
		double t = (2 * b - 2 * x / a / a) / a;
//		dump(t);
		theta = atan((2 * b - 2*x / a / a) / a);
//		dump(theta);
	}
	else {
		theta = atan(a* b* b / x / 2.0);
	}
	cout << fixed << setprecision(15) << theta * 180.0 / 3.14159265358979 << endl;


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

vector<vector<int>> g;

int max_dist = 0;
int max_v = -1;
void dfs(int v, int p = -1, int d = 0){
	if(d >= max_dist){
		max_dist = d;
		max_v = v;
	}
	for(auto nv : g[v]){
		if(nv == p)continue;
		dfs(nv, v, d + 1);
	}
}

int main(){
  int n;
  cin >> n;
  g.resize(n);
  for(int i = 0; i < n - 1; ++i){
  	int a, b;
  	cin >> a >> b;
  	--a;
  	--b;
  	g[a].push_back(b);
  	g[b].push_back(a);
  }

  dfs(0);
  dfs(max_v);
  if(max_dist % 3 == 1)cout << "Second" << endl;
  else cout << "First" << endl;

  return 0;
}


Measured memory_bytes: 20608
x,y = map(int,input().split())
s = (2 * y -x) / 3
t = (2 * x -y) / 3
if s.is_integer() and t.is_integer() and s >= 0 and t >= 0:
    def comb(n, r, mod=10 ** 9 + 7):
        a = 1
        b = 1
        r = min(r, n - r)
        for i in range(r):
            a = a * (n - i) % mod
            b = b * (i + 1) % mod
        return a * pow(b, mod - 2, mod) % mod
    s = int(s)
    t = int(t)
    print(comb(s + t, t, mod=10 ** 9 + 7))
else:
    print(0)

Measured memory_bytes: 3188
n, k = list(map(int, input().split()))
move = []
for i in range(k):
    s, t = list(map(int, input().split()))
    move.append([s, t])

mod = 998244353

dp = [0] * (n + 1)
dp[1] = 1

ruiseki = [0] * (n + 1)
ruiseki[1] = 1

for i in range(n):
    p = i + 1
    temp = 0
    for j in range(k):
        s, t = move[j]
        r = max(0, p - s)
        l = max(0, p - t - 1)
        temp += ruiseki[r] - ruiseki[l]
    dp[p] += temp % mod
    ruiseki[p] = ruiseki[p - 1] + dp[p]

print(dp[n])


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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL


int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	int left = 0;
	int right = n-1;
	int leftsex;
	int rightsex;
	cout << 0 << endl;
	string s;
	cin >> s;
	if(s.at(0) == 'V') {
		return 0;
	} else {
		leftsex = (s.at(0) == 'M' ? 1 : 2);
	}
	cout << n-1 << endl;
	cin >> s;
	if(s.at(0) == 'V') {
		return 0;
	} else {
		rightsex = (s.at(0) == 'M' ? 1 : 2);
	}
	while(left < right) {
		int mid = (left+right)/2;
		if(right == left+1) {
			cout << left << endl;
			cin >> s;
			if(s.at(0) == 'V') {
				return 0;
			}
			cout << right << endl;
			return 0;
		}
		cout << mid << endl;
		cin >> s;
		int sex = (s.at(0) == 'M' ? 1 : 2);
		if(s.at(0) == 'V') {
			return 0;
		} else {
			int dist1 = mid-left;
			if((sex == leftsex && dist1%2 == 1) || (sex != leftsex && dist1%2 == 0)) {
				right = mid;
				rightsex = sex;
			} else {
				left = mid;
				leftsex = sex;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 852
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <cmath>

using namespace std;

void solve()
{

}



int main()
{
  char a; cin >> a;
  if(a>='A' && a<='Z') cout << 'A';
  else cout << 'a';
  return 0;
}


Measured memory_bytes: 3516
#c
a,b,h,m=map(int, input().split())
b_k = 360*(1/60)*m
a_k = 360*(1/12)*h+(360/12)*(1/60)*m

import math
if abs(b_k-a_k) > 180:
    k_dif = 360-abs(b_k-a_k)
else:
    k_dif = abs(b_k-a_k)
c_2 = a**2+b**2-(2*a*b*math.cos(math.radians(k_dif)))  
answer = math.sqrt(c_2)
print(answer)

Measured memory_bytes: 9584
#include<stdio.h>

int main(){
	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
	};
	int n;
	scanf("%d",&n);
	printf("%d",a[n-1]);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{

    static int max = 0;
    static void Main(string[] args)
    {
        //入力
        var a = crI();
        Console.WriteLine(a+a*a+a*a*a);
       
    }

   
  



        //入力受け取り用
    static string crS() { return Console.ReadLine(); }
    static int crI() { return int.Parse(Console.ReadLine()); }
    static int[] arrInt(){return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();}
    static long[] arrLong(){ return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray(); }
    static string[] arrStr(){return Console.ReadLine().Split(' ').ToArray();}
    static List<int[]> mapInt(int h)
    {
        List<int[]> mapInt = new List<int[]>();
        for (int i = 0; i < h; i++)
        {
            mapInt.Add(arrInt());
        }
        return mapInt;
    }
}

Measured memory_bytes: 27540
#include "bits/stdc++.h"

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	int x,a,b;
	cin >> x >> a >> b;
	P((abs(x-a) < abs(x-b) ? "A" : "B"));
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;


int main(){
  ll n,m,x;cin>>n>>m>>x;
  ll mn=1e9;
  string ans="No";
  vector<int>c(n);
  vector<vector<int>>a(n,vector<int>(m));
  rep(i,n){
    cin>>c[i];
    rep(j,m){
      cin>>a[i][j];
    }
  }

  for(int tmp=0;tmp<(1<<12);tmp++){
    bitset<12> s(tmp);
    vector<int>b(m,0);
    int sum=0;
    rep(i,n){
      if(s.test(i)){
        sum+=c[i];
        rep(j,m){
          b[j]+=a[i][j];
        }
      }
    }
      sort(all(b));
      if(sum<mn&&b[0]>=x){
        mn=sum;
        ans="Yes";
      }
  }
  cout<<(ans=="Yes"?mn:-1);
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>

typedef long long ll;
using namespace std;

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

  if(a!=1&&b!=1){
    cout<<1<<endl;
  }
  
  if(a!=2&&b!=2){
    cout<<2<<endl;
  }

  if(a!=3&&b!=3){
    cout<<3<<endl;
  }


  return 0;
}


Measured memory_bytes: 256
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

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

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

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "abc171_d.cpp"

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

  int n;
  cin >> n;
  map<ll, ll> mp;
  ll sum = 0;
  REP(i, n) {
    ll a;
    cin >> a;
    mp[a]++;
    sum += a;
  }

  int q;
  cin >> q;
  REP(i, q) {
    ll b, c;
    cin >> b >> c;
    sum += mp[b] * (c - b);
    cout << sum << endl;
    mp[c] += mp[b];
    mp[b] = 0;
  }
}


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

int main() {
    string s; cin >> s;
    int ans = 0;
    rep(i, s.size()) {
        if (i%2 && s[i] == 'g') ans++;
        else if (i%2==0 && s[i] == 'p') ans--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3724
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String S = sc.nextLine();
    
    int n1 =0, n2 = 0;
    int s = S.length();
    for(int i = 0; i < s; i++){
      if((i%2 == 0 && S.charAt(i) == '0') || (i%2 == 1 && S.charAt(i) == '1')){
        n1++;
      }else{
        n2++;
      }
    }
    
    System.out.println(Math.min(n1, n2));
  }
}

Measured memory_bytes: 26176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int main(){
	int a,b,c;cin>>a>>b>>c;
	cout <<max(0,c-a+b)<<endl;
}

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
    return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
    return a / gcd(a, b) * b;
}

string IntToString(int number)
{
    stringstream ss;
    ss << number;
    return ss.str();
}

int main()
{
    int a[10];
    int k;
    rep(i, 5) ci >> a[i];
    ci >> k;

    bool ans = true;
    rep(i, 5) rep(j, 5)
	if(abs(a[i] - a[j]) > k) ans = false;

    if(ans) co << "Yay!" << en;
    else    co << ":(" << en;
    
    return 0;
}


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

using namespace std;

template<class INT>
INT mod_pow(INT n, INT k, INT p){
    if (k == 0)
        return 1;
    if (k % 2 == 0){
        INT res = mod_pow(n, k / 2, p);
        return res * res % p;
    }
    return mod_pow(n, k - 1, p) * n % p;
}


template<class INT>
vector<INT> fact(INT n, INT p=INT(1e9 + 7)){
    vector<INT> f(n + 1);
    f[0] = 1;
    for (INT i = 0; i < n; i++)
        f[i + 1] = (i + 1) * f[i] % p;
    return f;
}

template<class INT>
vector<INT> invfact(INT n, const vector<INT> &f, INT p=INT(1e9 + 7)){
    vector<INT> inv(n + 1);
    inv[n] = mod_pow<INT>(f[n], p - 2, p);
    for (INT i = n; i > 0; i--)
        inv[i - 1] = inv[i] * i % p;
    return inv;
}

template<class INT>
INT comb(INT a, INT b, const vector<INT> &f, const vector<INT> &invf, INT p){
    if (a < b)
        return 0;
    if (a < 0 or b < 0)
        return 0;
    return f[a] * invf[b] % p * invf[a - b] % p;
}

int main(){
    int x, y;
    cin >> x >> y;
    const int64_t p = 1e9 + 7;
    if ((x + y) % 3 != 0){
        cout << 0 << endl;
        return 0;
    }

    int64_t n = (2 * y - x) / 3;
    int64_t m = (2 * x - y) / 3;

    auto f = fact<int64_t>(n + m, p);
    auto invf = invfact<int64_t>(n + m, f, p);

    cout << comb<int64_t>(n + m, n, f, invf, p) % p << endl;
    
}


Measured memory_bytes: 10624
n,m=map(int,input().split())
a=[[0 for h in range(n)] for i in range(2**n)]
b1=[[0 for i in range(m)] for h in range(2**n)]
#0~2**n-1を2進数表記し、リストaに記録する(各位の10はスイッチのonoffに対応)
for i in range(2**n):
  b=i
  for j in range(n):
    c=b//(2**(n-j-1))
    a[i][j]+=c
    b-=c*(2**(n-j-1))
#それぞれの数について、電球が点灯するかどうかを検証する（各位が電球の点灯する条件を満たしているか）
for i in range(m):
  lights=list(map(int,input().split()))
  for j in range(2**n):
    for h in range(len(lights)-1):
      b1[j][i]+=a[j][lights[h+1]-1]
check=list(map(int,input().split()))
#検証パート
ans=0
for i in range(2**n):
  flag=0
  for j in range(m):
    if b1[i][j]%2 != check[j]:
      flag=1
      break
  if flag==0:
    ans+=1
print(ans)

Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int main(){
	int w, h;
	cin>>w>>h;
	vi p(w), q(h);
	rep(i, w) cin>>p[i];
	rep(i, h) cin>>q[i];
	ll ans = 0LL;
	rep(i, w) ans += p[i];
	rep(j, h) ans += q[j];
	vector<pair<int, int> > v;
	rep(i, w) v.pb({p[i], 0});
	rep(j, h) v.pb({q[j], 1});
	int d[2]={};
	ll pass = 0LL;
	sort(all(v));
	rep(i, v.size()){
		ll k = 0LL;
		if(v[i].se == 0){
			if(h-d[0]<0) continue;
			if(pass+h-d[0]>(ll)w*h){
				k = (ll)w*h-pass;
			}
			else k = h-d[0];
			ans += k*v[i].fi;
			d[1]++;
		}
		else{
			if(w-d[1]<0) continue;
			if(pass+w-d[1]>(ll)w*h){
				k = (ll)w*h-pass;
			}
			else k =w-d[1];
			ans += k*v[i].fi;
			d[0]++;
		}
		pass += k;
		//cout<<" "<<ans<<" "<<d[0]<<" "<<d[1]<<" "<<pass<<endl;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3188
using System.Collections.Generic;
using System.Linq;
using System;

public class Team
{
    public int tid { get; set; }
    public int pena { get; set; }
    public int correct { get; set; }
    public int[] wrong { get; set; }
}
public class hello
{
    public static void Main()
    {
        while (true)
        {
            var teams = new List<Team>();
            string[] line = Console.ReadLine().Trim().Split(' ');
            var t = int.Parse(line[0]);
            var p = int.Parse(line[1]);
            var r = int.Parse(line[2]);
            if (t == 0 && p == 0 && r == 0) break;
            for (int i = 0; i < t; i++)
                teams.Add(new Team { tid = i + 1, wrong = new int[p] });
            for (int i = 0; i < r; i++)
            {
                string[] s = Console.ReadLine().Trim().Split(' ');
                GetJ(s, teams);
            }
            var ans = teams.OrderByDescending(x => x.correct).ThenBy(x => x.pena).ThenBy(x => x.tid);
            foreach (var x in ans)
                Console.WriteLine("{0} {1} {2}", x.tid, x.correct, x.pena);
        }
    }
    public static void GetJ(string[] s, List<Team> t)
    {
        var tid = int.Parse(s[0]);
        var pid = int.Parse(s[1]);
        var time = int.Parse(s[2]);
        switch (s[3])
        {
            case "WRONG":
                t[tid - 1].wrong[pid - 1]++;
                break;
            case "CORRECT":
                t[tid - 1].correct++;
                t[tid - 1].pena += t[tid - 1].wrong[pid-1] * 1200 + time;
                break;
        }
    }
}

Measured memory_bytes: 10352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buffer[] = new String[3];
		int array[] = new int[3];
		String ans;

		while(true){


			try {
				buffer = br.readLine().split("\\s+");
				for(int i = 0; i < buffer.length; i++){
					array[i] = Integer.parseInt(buffer[i]);
				}
				if(array[0] == -1 && array[1] == -1 && array[2] == -1)break;

				if(array[0] == -1 || array[1] == -1){
					ans = "F";
				}else if(array[0]+array[1] >= 80){
					ans = "A";
				}else if(array[0]+array[1] >= 65){
					ans = "B";
				}else if(array[0]+array[1] >= 50){
					ans = "C";
				}else if(array[0]+array[1] >= 30){
					if(array[2] >= 50){
						ans = "C";
					}else{
						ans = "D";
					}
				}else{
					ans = "F";
				}

				System.out.printf("%s\n", ans);

			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}




Measured memory_bytes: 24620
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>
#include <climits>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;



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

    vector<ll> a(n);
    ll up = 1e18;
    rep(i,n){
        cin >> a[i];
        if(a[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }

    //cout << LLONG_MAX <<endl;
    
    ll total = 1;

    rep(i,n){
        ll tmp = LLONG_MAX / total;
        if(tmp < a[i]){
            cout << -1 << endl;
            return 0;
        }else{
            total *= a[i];
            if(total > up){
                cout << -1 << endl;
                return 0;
            }
        }
    }

    if(total <= up){
        cout << total << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 4020
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    string s;
    cin >> n >>s;
    int cnt = 1;
    char pre = s[0];
    for(int i=1;i<n;i++){
        if(pre==s[i]) continue;
        else{
            pre = s[i];
            ++cnt;
        }
    }
    cout << cnt;

    return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define ms(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10) 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge{ int from, to, cost; };

int main()
{
	int n;
	while (cin >> n, n)
	{
		bool data[105][105] = {};
		REP(i, n)
		{
			int k; cin >> k;
			REP(j, k)
			{
				int x; cin >> x;
				data[i][x] = true;
			}
		}
		int k; cin >> k;
		vector<int> v;
		REP(i, k)
		{
			int x; cin >> x;
			v.push_back(x);
		}
		int ans = -2;
		bool ansb = true;
		REP(i, n)
		{
			bool f = true;
			REP(j, k)
			{
				if (data[i][v[j]] == false) f = false;
			}
			if (f)
			{
				if(ans == -2) ans = i;
				else ansb = false;
			}
		}
		if (ansb) cout << ans+1 << endl;
		else cout << -1 << endl;
	}

	return 0;
}

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

int main() {
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2 << endl;
    return 0;
}

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

int main(){
    int N,A;
    cin>>N>>A;
    long cards[N];
    int sum=0;
    for(int i=0; i<N; i++){
        cin>>cards[i];
        sum+=cards[i];
    }
    long dp[N+1][sum+1][N+1];
    for(int i=0; i<=N; i++){
        for(int j=0; j<=sum; j++){
            for(int k=0; k<=i; k++){
                dp[i][j][k]=0;
            }
        }
    }
    dp[0][0][0]=1;
    for(int i=0; i<N; i++){
        for(int j=0; j<sum; j++){
            for(int k=0; k<=i; k++){
                if(dp[i][j][k]>0){
                    dp[i+1][j][k]+=dp[i][j][k];
                    dp[i+1][j+cards[i]][k+1]+=dp[i][j][k];
                }
            }
        }
    }
    long SOUWA=0;
    for(int i=1; i<=min(N,(sum/A)); i++){
        SOUWA+=dp[N][A*i][i];
    }
    cout<<SOUWA<<endl;
}

Measured memory_bytes: 51072
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
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;}
const int INF = 1e9;
const ll LINF = 1e18;
// clang-format on
const string YES = "YES";
const string NO = "NO";

void solve(long long A, long long B, long long C) { cout << ((A + B + C == 17) ? YES : NO) << endl; }

int main() {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);
  solve(A, B, C);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
signed main() {
	int n; cin >> n;
	int a[223456]; a[0] = 0;
	for1(i, n) { cin >> a[i]; a[i] += a[i - 1]; }
	int ans = a[n] * 2;
	for1(i, n)ans = min(ans, abs(2*a[i]-a[n]));
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int N = 2e5+5;

ll p[N], inv[N], ans = 1;

ll power(ll a, ll b)
{
	ll res = 1;
	while (b)
	{
		if (b & 1)	res = (res * a) % mod;
		a = (a * a) % mod; b >>= 1;
	}
	return res;
}

ll C(ll n, ll m)
{
	return p[n] * inv[m] % mod * inv[n-m] % mod;
}

int main()
{
	ll n, k;
	cin >> n >> k;
	p[0] = 1; inv[0] = power(p[0], mod-2);
	for (ll i = 1; i <= n; i++)
	{
		p[i] = p[i-1] * i % mod;
		inv[i] = power(p[i], mod-2);
	}
	k = min(k, n - 1);
	for (ll i = 1; i <= k; i++)
	{
		ans = (ans + C(n, i) * C(n-1, i) % mod) % mod;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long
#define N 100000
#define modn 1000000007
using namespace std;
ll n,m,x[N+5],y[N+5];
int main(void){
	scanf("%lld%lld",&n,&m);
	for(int i=0;i<n;++i){
		scanf("%lld",x+i);
	}
	for(int i=0;i<m;++i){
		scanf("%lld",y+i);
	}
	ll a=0;
	for(ll i=0;i<n;++i){
		a+=(x[i]*i - x[i]*(n-i-1));
		a%=modn;
	}
	ll b=0;
	for(ll i=0;i<m;++i){
		b+=(y[i]*i - y[i]*(m-i-1));
		b%=modn;
	}
	ll ans = a*b;
	printf("%lld\n",ans%modn);
}

Measured memory_bytes: 1792
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		HashMap<String, Integer> map = new HashMap<String, Integer>();
		map.put("AC", 0);
		map.put("WA", 0);
		map.put("TLE", 0);
		map.put("RE", 0);
		
		for(int i = 0; i < n; i++){
			String str = sc.next();

			if(!map.containsKey(str)){
				map.put(str, 1);
			}
			else {
				map.put(str, map.get(str) + 1);
			}
		}

		System.out.println("AC x "+ map.get("AC"));
		System.out.println("WA x "+ map.get("WA"));
		System.out.println("TLE x "+ map.get("TLE"));
		System.out.println("RE x "+ map.get("RE"));
	}

}


Measured memory_bytes: 48740
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
typedef long long ll;
typedef unsigned un;
typedef std::string str;
typedef std::pair<ll,ll> pll;
ll read(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return f*x;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
void umax(ll& a,ll t){if(t>a)a=t;}
void umin(ll& a,ll t){if(t<a)a=t;}
const ll INF=1ll<<58;
#define MAXN 5001
ll f[MAXN];
struct one
{
	ll a,p;
}a[MAXN];
ll ans=0;
void solve(ll n)
{
	for(ll i=1;i<=n;++i)f[i]=INF;
	for(ll i=1;i<=n;++i)
	{
		for(ll j=i;j;--j)
			if(f[j-1]<=a[i].a)umin(f[j],f[j-1]+a[i].p);
	}
	for(ll i=1;i<=n;++i)
		if(f[i]<INF)umax(ans,i);
}
bool cmp1(one a,one b)
{
	return a.a==b.a?a.p<b.p:a.a<b.a;
}
bool cmp2(one a,one b)
{
	if(a.a+a.p==b.a+b.p)return a.p==b.p?a.a<b.a:a.p<b.p;
	return a.a+a.p<b.a+b.p;
}
bool cmp3(one a,one b)
{
	if(a.a-a.p==b.a-b.p)return a.p==b.p?a.a<b.a:a.p<b.p;
	return a.a-a.p<b.a-b.p;
}
int main()
{
	ll n=read();
	for(ll i=1;i<=n;++i)a[i].a=read(),a[i].p=read(),f[i]=INF;
	std::sort(a+1,a+n+1,cmp1),solve(n);
	std::sort(a+1,a+n+1,cmp2),solve(n);
	std::sort(a+1,a+n+1,cmp3),solve(n);
	std::reverse(a+1,a+n+1),solve(n);
	std::cout<<ans;
	return 0;
}

Measured memory_bytes: 3248
#include <stdio.h>

/* 配列の要素を順番に出力 */
void trace(int A[],int N) {
    int i;
    for(i=0;i<N;i++) {
        /* 隣接する要素の間に1つの空白を出力 */
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}

/* 挿入ソート(0オリジン配列) */
void insertionSort(int A[], int N) {
    int i,j,v;
    for(i=1;i<N;i++) {
        v=A[i];
        j=i-1;
        while(j>=0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1]=v;
        trace(A,N);
    }
}

int main(void)
{
    int N, i;
    int A[100];
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);
    
    trace(A,N);
    insertionSort(A,N);
    return 0;
}


Measured memory_bytes: 1960
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair <ll,ll>
#define vl vector <ll>
#define vp vector <pair<ll,ll>>
#define sort(x) sort(x.begin(), x.end())
#define N 1000000007
using namespace std;
ll dp[1<<21];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,j,c,k;
    cin>>n;
    ll a[n][n];
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            cin>>a[i][j];
    dp[(1<<n)-1] = 1;
    for(i=(1<<n)-2;i>=0;i--)
    {
        dp[i] = 0;
        c = 0;
        for(j=0;j<n;j++)
            if((i&(1<<j)) != 0)
                c++;
        for(j=0;j<n;j++)
            if((i&(1<<j)) == 0 and a[c][j] == 1)
                dp[i] = (dp[i] + dp[i+(1<<j)])%N;

    }
    cout<<dp[0];
    return 0;
}


Measured memory_bytes: 16640
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	string f, m, v;
	f = "Female";
	m = "Male";
	v = "Vacant";
	cin >> N;
	cout << 0 << endl;
	string s;
	cin >> s;
	L = 1;
	R = N - 1;
	if (s == v) {
		return 0;
	}
	vector<string>box(N + 1);
	box[0] = s;
	box[N] = s;
	for (int i = 2; i < 20; i++) {
		int mid = (L + R) / 2;
		cout << mid << endl;
		cin >> s;
		if (s == v) {
			return 0;
		}
		if ((mid - L) & 1) {
			if (s == box[L - 1]) {
				L = mid + 1;
			}
			else {
				R = mid - 1;
			}
		}
		else {
			if (s == box[L - 1]) {
				R = mid - 1;
			}
			else {
				L = mid + 1;
			}
		}
		box[mid] = s;
	}
	return 0;
}


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

int main() {
	string S;
	cin >> S;
	while (!S.empty()) {
		if (S.size() >= 6 && S.substr(0, 6) == "eraser") S.erase(0, 6);
		else if (S.size() >= 10 && S.substr(0, 10) == "dreamerase") S.erase(0, 5);
		else if (S.size() >= 7 && S.substr(0, 7) == "dreamer") S.erase(0, 7);
		else if (S.size() >= 5 && (S.substr(0, 5) == "dream" || S.substr(0, 5) == "erase")) S.erase(0, 5);
		else break;
	}
	if (S.empty()) cout << "YES";
	else cout << "NO";
}

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

int main() {
  int n; cin >> n;
  vector<char> s(n);
  string ans = "Three";
  for (auto& e: s) {
    cin >> e;
    if (e == 'Y') ans = "Four";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
MOD = 998244353


def main():
    N, S = map(int, input().split())
    A = list(sorted(map(int, input().split())))
    prev = [0] * (S+1)
    prev[0] = pow(2, N, MOD)
    half = pow(2, MOD-2, MOD) % MOD
    for i in range(N):
        cur = list(prev)
        for total in range(S+1):
            if total + A[i] > S:
                continue
#            key = encode(num+1, total + A[i], S)
            cur[total + A[i]] = (cur[total + A[i]] +
                                 prev[total] * half) % MOD
        prev = cur
    print(cur[S])


if __name__ == "__main__":
    main()


Measured memory_bytes: 68336
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.IO;
    using System.Text;

    class Program
    {

        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] input = new string[n];
            for (int i = 0; i < n; i++)
            {
                input[i] = Console.ReadLine();
            }
            var cnt = input.Distinct().Count();
            Console.WriteLine(cnt.ToString());
        }
    }

Measured memory_bytes: 41148
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;
 
int main(){
  using namespace std;
  int n;
  cin>>n;
  int a[n];
  REP(i, n){
    cin>>a[i];
  }
  long long cnt[n + 1] = {};
  REP(i, n){
    cnt[a[i]]++;
  }
  long long s = 0;
  REPP(i, n){
    s += cnt[i] * (cnt[i] - 1) / 2;
  }
  REP(i, n){
    long long ans = s;
    long long c = cnt[a[i]];
    ans -= c * (c - 1) / 2;
    ans += (c - 1) * (c - 2) / 2;
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 4864