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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

auto chmin = [](auto&& a, auto b) { return b < a ? a = b, 1 : 0; };

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long> a(n);
  for (auto&& e : a) cin >> e;
  a.push_back(0);
  while (size(a) > 3) {
    auto t = a.back();
    a.pop_back();
    a.back() ^= t;
  }
  vector dp(2, vector(2, inf<long long>));
  dp[0][0] = 0;
  for (int i = 0; i < 40; ++i) {
    vector ndp(2, vector(2, inf<long long>));
    int a0 = a[0] >> i & 1;
    int a1 = a[1] >> i & 1;
    int a2 = a[2] >> i & 1;
    for (int f : {0, 1}) {
      for (int g : {0, 1}) {
        for (long long d : {0, 1}) {
          int nf = a0 - f - d < 0;
          int ng = a1 + g + d >= 2;
          if ((a0 - f + a1 + g + a2) & 1) continue;
          chmin(ndp[nf][ng], d << i | dp[f][g]);
        }
      }
    }
    swap(dp, ndp);
  }
  auto res = dp[0][0];
  if (res == inf<long long> or res == a[0]) {
    res = -1;
  }
  cout << res << '\n';
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main{

	public static void main (String[] args) {

		Main main = new Main();

		main.solve();
	}

	private void solve () {

		Scanner scanner = new Scanner (System.in);

		int people = scanner.nextInt();
		int foodType = scanner.nextInt();
		int[] likeList = new int[foodType];

		for (int index=0; index<people; index++) {
			int number = scanner.nextInt();
			for (int index2=0; index2<number; index2++) {
				int food = scanner.nextInt();
				likeList[food-1]++;
			}
		}

		int count=0;

		for (int index=0; index<foodType; index++) {
			if (likeList[index]==people) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 23336
import math
data = list(map(int,input().split()))
A = data[0]
B = data[1]
H = data[2]
M = data[3]
degree = abs(30 * H + 0.5 * M - 6 * M )
rad = math.radians(degree)
ab = A * A + B * B - 2 * A * B * math.cos(rad) 
print(math.sqrt(ab))

Measured memory_bytes: 62352
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  pair<lint,lint> x[N];
  REP(i,N){
    lint X,L;
    cin>>X>>L;
    x[i]=make_pair(X-L,X+L);
  }
  sort(x,x+N);
  lint r=x[0].second;
  int ans=1;
  FOR(i,1,N){
    // cerr<<x[i].first<<" "<<x[i].second<<" "<<r<<endl;
    if(x[i].first<r){
      r=min(r,x[i].second);
    }else{
      ans++;
      r=x[i].second;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
unsigned GetDigit(unsigned num)
{
    unsigned digit = 0;
    while (num != 0)
    {
        num /= 10;
        digit++;
    }
    return digit;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    ll ans = a[0];
    for (ll i = 1; i < n; i++)
    {
        ll route = pow(LONG_LONG_MAX, 0.5);
        if (ans < route && a[i] < route)
        {
            ans *= a[i];
        }
        else if (a[i] >= route && a[i] / route * ans < route)
        {
            ans *= a[i];
        }
        else if (ans >= route && ans / route * a[i] < route)
        {
            ans *= a[i];
        }
        else
        {
            cout << -1 << endl;
            return 0;
        }
        if (ans > 1000000000000000000)
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n;
    cin >> n;
    vector<pair<double, double>> v(n);
    for (Int i = 0; i < n; i++) {
        cin >> v[i].fi >> v[i].se;
    }
    sort(all(v));
    double sum = 0;
    do {
        for (Int i = 0; i < n - 1; i++) {
            double x = (v[i + 1].fi - v[i].fi) * (v[i + 1].fi - v[i].fi);
            double y = (v[i + 1].se - v[i].se) * (v[i + 1].se - v[i].se);
            sum += sqrt(x + y);
        }
    } while (next_permutation(all(v)));
    for (int i = 1; i <= n; i++) {
        sum /= (double)i;
    }
    printf("%.12lf\n", sum);
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp11
{
    class Class79
    {
        static void Main()
        {
            int[] NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NM[0];
            int M = NM[1];
            int Min = 0;
            int max = 100000;
            for(int i = 0; i < M; i++)
            {
                var read = Console.ReadLine().Split();
                Min = Math.Max(Min, int.Parse(read[0]));
                max = Math.Min(max, int.Parse(read[1]));
            }
            int ans = max - Min+1;
            Console.WriteLine(ans > 0 ? ans : 0);
        }
    }
}


Measured memory_bytes: 17472
#include <iostream>
#include <algorithm>
#include<vector>
#include <queue>
#include "math.h"
#include <string>
using namespace std;
int main()
{
	int h[105];
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
	}
	int	ans = 1000000000;
	int sum = 0;
	for (int i = -100; i <= 100; i++) {
		for (int j = 1; j <= n; j++) {
			sum += (h[j] - i)*(h[j] - i);
		}
		if (sum < ans)ans = sum;
		sum = 0;
	}
	cout << ans << endl;


}

Measured memory_bytes: 256
import sys, math
from collections import defaultdict
from itertools import product
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def f(i, lst):
    if lst[i]:
        salaries = list(map(lambda x: f(x, lst), lst[i]))
        return max(salaries)+min(salaries)+1
    else:
        return 1

def main():
    H, W = mi()
    m = 10**100
    for h in range(H):
        S = [h*W, math.ceil((H-h)/2)*W, math.floor((H-h)/2)*W]
        m = min(max(S)-min(S), m)
    for w in range(W):
        S = [math.ceil(H/2)*w, math.floor(H/2)*w, (W-w)*H]
        m = min(max(S)-min(S), m)
    W, H = H, W
    for h in range(H):
        S = [h*W, math.ceil((H-h)/2)*W, math.floor((H-h)/2)*W]
        m = min(max(S)-min(S), m)
    for w in range(W):
        S = [math.ceil(H/2)*w, math.floor(H/2)*w, (W-w)*H]
        m = min(max(S)-min(S), m)

    print(m)



if __name__ == '__main__':
    main()

Measured memory_bytes: 74340
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
using namespace std;
 
const int maxn = 3e5 + 10;
int cntr[maxn], cntc[maxn];
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m, k;
	cin >> n >> m >> k;
	int c[maxn], r[maxn];
	for(int i = 0; i < k; i++) {
		cin >> r[i] >> c[i];
		cntr[r[i]]++;
		cntc[c[i]]++;
	}
	int ansr = *max_element(cntr, cntr + maxn);
	int ansc = *max_element(cntc, cntc + maxn);
	int maxrows = 0, maxcols = 0;
	for(int i = 1; i <= n; i++) {
		if(cntr[i] == ansr) maxrows++;
	}
	for(int i = 1; i <= m; i++) {
		if(cntc[i] == ansc) maxcols++;
	}
  	int edges = 0;
	for(int i = 0; i < k; i++) {
		if(cntr[r[i]] == ansr and cntc[c[i]] == ansc) {
          	edges++;
		}
	}
	if(edges == 1ll * maxrows * maxcols) {
		cout << ansr + ansc - 1 << endl;
	}
	else cout << ansr + ansc << endl;
	return 0;
}

Measured memory_bytes: 8300
#include <stdio.h>
int main(void){
     
    int h, w;
    int i, j;
     
    while(1) {
        scanf("%d %d", &h, &w);
        if(h==0 && w==0)
            break;
     
        for (i=1; i<=h; i++) {
            for(j=1; j<=w; j++) {
                if(j%2==1) {
                    if(i%2==1) printf("#");
                    else printf(".");
                }
                else {
                    if(i%2==1) printf(".");
                    else printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2044
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n%2==1) {
			System.out.println("NA");
			return;
		}
		int[] x = new int[n];
		int[] y = new int[n];
		for(int i=0;i<n;i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		int cx2 = x[0]+x[n/2];
		int cy2 = y[0]+y[n/2];
		for (int i=1;i<n/2;i++) {
			int cx = x[i]+x[n/2+i];
			int cy = y[i]+y[n/2+i];
			if (!(cx2==cx && cy2==cy)) {
				System.out.println("NA");
				return;				
			}
		}
		System.out.println((double) cx2/2 + " " + (double) cy2/2 );
	}

}

Measured memory_bytes: 18524
#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
//#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve();
void precalc();
clock_t start;
//int timer = 1;

int testNumber = 1;

bool todo = true;

int main() {
#ifdef AIM
    freopen("/home/alexandero/ClionProjects/ACM/input.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    start = clock();
    int t = 1;
    cout.sync_with_stdio(0);
    cin.tie(0);
    precalc();
    cout.precision(10);
    cout << fixed;
    //cin >> t;
    int testNum = 1;
    while (t--) {
        //cerr << testNum << endl;
        //cout << "Case #" << testNum++ << ": ";
        solve();
        ++testNumber;
        //++timer;
    }

#ifdef AIM
    cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif

    return 0;
}

//BE CAREFUL: IS INT REALLY INT?

template<typename T>
T binpow(T q, T w, T mod) {
    if (!w)
        return 1 % mod;
    if (w & 1)
        return q * 1LL * binpow(q, w - 1, mod) % mod;
    return binpow(q * 1LL * q % mod, w / 2, mod);
}

template<typename T>
T gcd(T q, T w) {
    while (w) {
        q %= w;
        swap(q, w);
    }
    return q;
}
template<typename T>
T lcm(T q, T w) {
    return q / gcd(q, w) * w;
}

void precalc() {

}

#define int li

const int mod = 1000000007;

void solve() {
    int n;
    cin >> n;
    vector<pair<int, int>> a;
    for (int i = 0; i< n; ++i) {
        int cur;
        cin >> cur;
        a.push_back({cur, 0});
    }
    for (int i = 0; i< n; ++i) {
        int cur;
        cin >> cur;
        a.push_back({cur, 1});
    }
    sort(all(a));
    int res = 1;
    vector<int> has(2);
    for (int i = (int)a.size() - 1; i >= 0; --i) {
        int cur = a[i].second;
        if (has[cur ^ 1]) {
            res = res * has[cur ^ 1] % mod;
            --has[cur ^ 1];
        }
        else {
            ++has[cur];
        }
    }

    cout << res << "\n";

}

Measured memory_bytes: 4464
#include <iostream>
#include <complex>
#define EPS 1e-10
#define EQ(a,b) (abs(a - b) < EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()))
using namespace std;

typedef complex<double> P;

double cross (P a, P b) {
    return (a.real() * b.imag() - a.imag() * b.real());
}

double dot (P a, P b) {
    return (a.real() * b.real() + a.imag() * b.imag());
}

bool is_intersected_ls(P a1, P a2, P b1, P b2) {
    return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
        ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
}

bool is_intersected_l(P a1, P a2, P b1, P b2) {
    return !EQ( cross(a1-a2, b1-b2), 0.0 );
}

bool is_orthogonal(P a1, P a2, P b1, P b2) {
    return EQ( dot(a1 - a2, b1 - b2), 0.0);
}

int main ()
{
    double ax, bx, cx, dx, ay, by, cy, dy;
    while (cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy) {
        if (is_orthogonal(P(ax,ay), P(bx,by), P(cx,cy), P(dx,dy)))
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 1224
INF = -float("inf")
def gcd(x,y):
    if x == INF:
        return y
    if y == INF:
        return x
    if x<y:
        x,y = y,x
    r = (x%y)
    while r:
        x,y = y, r
        r = (x%y)
    return y
    
N = int(input())
A = list(map(int,input().split()))
lgcd = [INF]*N
rgcd = [INF]*N
lgcd[0] = A[0]
rgcd[0] = A[-1]
for i in range(1,N):
    lgcd[i] = gcd(lgcd[i-1], A[i])
    rgcd[i] = gcd(rgcd[i-1], A[N-i-1])
lgcd = [INF]+lgcd
rgcd = [INF]+rgcd
ans = INF
for i in range(N):
    ans = max(ans, gcd(lgcd[i],rgcd[N-i-1]))
print(ans)


Measured memory_bytes: 14436
n=int(input())
a_point=0
b_point=0
sum_list=[]
while(n!=0):
    list=[]
    for i in range(n):
        a,b=[int(i) for i in input().split()]
        if a>b:
            a_point+=(a+b)
        elif b>a:
            b_point+=(a+b)
        else:
            a_point+=a
            b_point+=b
    sum_list.append((a_point,b_point))
    a_point=0
    b_point=0
    n=int(input())

for i in range(len(sum_list)):
    print(sum_list[i][0],sum_list[i][1])

Measured memory_bytes: 7568
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    ArrayList<String> list = new ArrayList<>();
    ArrayList<String> anslist = new ArrayList<>();    
    int n = sc.nextInt();
    String[] a = new String[n];
    int max = 1;
    int count = 1;
    for(int i = 0;i < n;i++){
      a[i] = sc.next();
      list.add(a[i]);
    }
    Collections.sort(list);
    for(int j = 1;j < n;j++){
      if(list.get(j - 1).equals(list.get(j))){
        count++;
        if(j == n - 1) max = Math.max(max,count);
      }else{
        max = Math.max(max,count);
        count = 1;  
      }
    }
    for(int x = 0;x < n - max + 1;x++){
      if(list.get(x + max - 1).equals(list.get(x))){
        anslist.add(list.get(x));
      }
    }
    Iterator<String> it = anslist.iterator();
    while(it.hasNext()){
      System.out.println(it.next());
    }
  }
}


Measured memory_bytes: 81000
#include<stdio.h>
int main()
{
    int N,i,j,k=0,t=0,a[81];
    scanf("%d",&N);
    for(i=1;i<=9;i++)
    {
        for(j=1;j<=9;j++)
        {
            a[k++]=i*j;
        }
    }
    for(i=0;i<81;i++)
    {
        if(a[i]==N)
		{
        	printf("Yes");t++; 
        	break;
		}
    }
    if(t==0) printf("No");
}


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

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 1e6 + 5;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    ll A , B , N;
    cin >> N >> A >> B;
    ll tmp = N / (A + B);
    N = min(A , N % (A + B));
    if(A)cout << A * tmp + N;
    else cout << 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int a,b;
    cin >> a >> b;
    map<int,int> mp;
    int now = 0;
    for(int i=1;i<=999;++i){
        now+=i;
        mp[now]=i;
    }
    
    for(int i=1;i<=499500;++i){
        if((mp[b+i] - mp[a+i]) == 1 && mp[a+i] != 0){
            cout << i << endl;
            return 0;
        }
    }
}


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

const int N = 2510;
const int INF = 1e9;

int n, m, pp;

vector<pair<int, int>> G[N]; // {to, cost}
vector<int> To[N];
vector<int> Ot[N];
vector<int> D(N);

vector<bool> isIn(N); // isIn[i]: 頂点iが1からNまでのルートに含まれているか（経路長問わず）
vector<bool> isInNegativeCycle(N);
vector<bool> from1(N);
vector<bool> fromN(N);

// 頂点1からたどり着ける頂点を探索
void dfs1(int now){
    from1[now] = true;
    if(now == n - 1) return;
    for(int i = 0; i < To[now].size(); i++){
        int to = To[now][i];
        if(from1[to]) continue;
        dfs1(to);
    }
}

// 頂点Nからたどり着ける頂点を探索
void dfsN(int now){
    fromN[now] = true;
    if(now == 0) return;
    for(int i = 0; i < Ot[now].size(); i++){
        int to = Ot[now][i];
        if(fromN[to]) continue;
        dfsN(to);
    }
}


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

    cin >> n >> m >> pp;
    for(int i = 0; i < m; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        c -= pp;
        G[a].push_back({b, -c});
        To[a].push_back(b);
        Ot[b].push_back(a);

    }

    isIn.resize(n);
    isInNegativeCycle.resize(n);
    from1.resize(n);
    fromN.resize(n);

    dfs1(0);
    dfsN(n - 1);

    for(int i = 0; i < n; i++){
        isIn[i] = from1[i] & fromN[i];
    }

    // ベルマンフォード
    D.resize(n);
    for(int i = 0; i < n; i++){
        D[i] = INF;
    }
    D[0] = 0;
    for(int hoge = 0 ; hoge < n ; ++hoge)for(int i = 0; i < n; i++){
        for(int j = 0; j < G[i].size(); j++){
            pair<int, int> p = G[i][j];
            int to = p.first;
            int cost = p.second;
            if(D[to] > D[i] + cost){
                D[to] = D[i] + cost;
            }
        }
    }


    for(int hoge = 0 ; hoge < n ; ++hoge)for(int i = 0; i < n; i++){
        for(int j = 0; j < G[i].size(); j++){
            pair<int, int> p = G[i][j];
            int to = p.first;
            int cost = p.second;
            if(D[to] > D[i] + cost){
                D[to] = D[i] + cost;
                isInNegativeCycle[to] = true;
            }
        }
    }

    bool nc = false; // 負のサイクルが1からNまでの経路に含まれるか
    for(int i = 0; i < n; i++){
        // for(int j = 0; j < G[i].size(); j++){
        //     pair<int, int> p = G[i][j];
        //     int to = p.first;
        //     if(isIn[i] & isInNegativeCycle[i] & isIn[to] & isInNegativeCycle[to]){
        //         nc = true;
        //         break;
        //     }
        // }
        if(isIn[i] & isInNegativeCycle[i]){
            nc = true;
            break;
        }
    }

    if(nc){
        cout << -1 << endl;
    }else{
        cout << max(0, -1 * D[n - 1]) << endl;
    }


    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define N 100001
using namespace std;
typedef long long ll;
vector<ll> sum(N),sum2(N);
int n,k,x[N];
ll Sum(int i){return sum[i+k]-sum[i];}
ll Sum(int l,int r){
  if(l==r)return 0;
  return sum2[r]-sum2[l];
}
ll dfs2(int);

int main(){
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>x[i];
    sum[i+1]+=x[i]+sum[i];
    sum2[i+1]+=sum2[i];
    if(x[i]>0)sum2[i+1]+=x[i];
  }
  
  ll ans=0;
  for(int i=0;i<=n;i++){
    ll sum=0;
    if(i+k>n)break;
    if(Sum(i)>0)sum=Sum(i);
    sum+=Sum(0,i)+Sum(i+k,n);
    ans=max(ans,sum);
  }

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


Measured memory_bytes: 2304
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#define X first
#define Y second
using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

const int N=100010,mod=1e9+7; 

int n,p;
LL a[N],ans;
string s;

int main()
{
	cin>>n>>p>>s;
	
	LL mult=1,sum=0;
	
	a[0]=1;
	
	if(p==2||p==5)
	{
		for(int i=0;i<n;i++)
			if((s[i]-'0')%p==0)
				ans+=i+1;
		
		printf("%lld\n",ans);
		
		return 0;
	}
	
	for(int i=n-1;i>=0;i--)
	{
		sum=((s[i]-'0')*mult+sum)%p;
		mult=mult*10%p;
		ans+=a[sum];
		a[sum]++;
	}
	
	cout<<ans<<endl;
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}










Measured memory_bytes: 644
#include <iostream>
#include <string>
using namespace std;
string w[1000];
int main(){
	int i,j,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> w[i];
	}
	for(i=0;i<n;i++){
		for(j=0;j<i;j++){
			if(w[i]==w[j]){
				cout << "No" << endl;
				return 0;
			}
		}
		if(i!=0){
			if(w[i][0]!=w[i-1][w[i-1].size()-1]){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int w[108], sum[108];
int n; 
int ans;

int main()
{
    cin >> n;
    int i;
    sum[0] = 0;
    for(i = 1; i <= n; i++)
    {
        cin >> w[i];
        sum[i] = sum[i - 1] + w[i];
    }
    
    ans = abs(sum[1]-(sum[n] - sum[1]));
    for(i = 2; i < n; i++)
    {
        if(abs(sum[i] - (sum[n]- sum[i])) < ans)
            ans = abs(sum[i] - (sum[n]- sum[i]));
    }
    
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int, input().split()))
A=sorted(A)#小さい順に計算することで処理時間短縮
f=A[0]
for i in range(1,N):
    f*=A[i]
    if f>10**18:
        print(-1)
        exit()
            
print(f)

Measured memory_bytes: 21712
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a, b = map(int, input().split())
print(len(set(prime_factorize(a)) & set(prime_factorize(b))) + 1)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
	int i,a[5],k;
	for(i=0;i<5;i++) cin >> a[i];
	cin >> k;
	bool torf = true;
	int j;
	for(i=0;i<5;i++) for(j=i+1;j<5;j++) if(abs(a[i]-a[j])>k) torf = false;
	cout << (torf ? "Yay!" : ":(") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
 
using namespace std;
 
const ll MOD = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin >> N;
    vector<ll> ans(N+1);
    map<ll,pair<ll,ll>> mp;
    rep(i,N){
        ll a;
        cin >> a;
        if(!mp.count(a))mp[a].first = i;
        mp[a].second++;
    }
    ll total = 0;
    ll minv = N;
    for(auto itr = mp.rbegin();itr != mp.rend();itr++){
        auto v = *itr;
        auto it2 = itr;
        it2++;

        ll prev;
        if(it2 == mp.rend()) prev = 0;
        else prev = it2->first;

        total += v.second.second;
        minv = min(minv,v.second.first);
        ans[minv] += total * (v.first - prev);
    }
    for(int i=0;i<N;i++)cout << ans[i] << endl;
}

Measured memory_bytes: 9472
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

//行列は二次元vectorを用いることにする
typedef vector<LL> vec;
typedef vector<vec> mat;

//A*Bの計算
mat mul(mat &A, mat&B, int M) {
	mat C(A.size(), vec(B[0].size()));
	for (int i = 0; i < A.size(); i++) {
		for (int k = 0; k < B.size(); k++) {
			for (int j = 0; j < B[0].size(); j++) {
				C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % M;
			}
		}
	}
	return C;
}

//A^nの計算
mat pow(mat A, LL n, int M) {
	mat B(A.size(), vec(A.size()));
	for (int i = 0; i < A.size(); i++) {
		B[i][i] = 1;
	}
	while (n > 0) {
		if (n & 1)B = mul(B, A, M);
		A = mul(A, A, M);
		n >>= 1;
	}
	return B;
}

LL n, k;
const LL mod = 1e9 + 7;

int main(){
    cin >> n >> k;
    mat A(n, vec(n));
    REP(i, n)REP(j, n)cin >> A[i][j];
    A = pow(A, k, mod);
    LL ans = 0;
    REP(i, n)REP(j, n)(ans += A[i][j]) %= mod;
    cout << ans << endl;
}

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


void solve(long long A, long long B){
    if(1 != A && 1 != B){
        cout << 1 << endl;
    }else if(2 != A && 2 != B){
        cout << 2 << endl;
    }else{
        cout << 3 << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
def main():
    import sys

    sys.setrecursionlimit(10 ** 7)

    input = sys.stdin.readline

    N, Q = map(int, input().split())

    Graph = tuple(set() for _ in range(N))
    for _ in range(N - 1):
        a, b = (int(x) - 1 for x in input().split())
        Graph[a].add(b)
        Graph[b].add(a)

    ctr = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        p -= 1
        ctr[p] += x

    root = 0
    visited = [False] * N
    visited[root] = True

    def dfs(v):
        x = ctr[v]
        for u in Graph[v]:
            if visited[u]:
                continue
            visited[u] = True
            ctr[u] += x
            dfs(u)

    dfs(root)

    print(*ctr)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 295528
# coding: utf-8
# Your code here!

from collections import Counter

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  
n = int(input())
x = Counter(prime_factorize(n))
x_keys = list(x.keys())
x_values = list(x.values())
ans = 0
for i in range(len(x_keys)):
    z = x_values[i]
    mai = 1
    while z - mai >= 0:
        z -= mai
        mai += 1
        ans += 1
print(ans)        


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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
const int mxn = 1e6+5;
vector<bool>isComposite(mxn);
vll primes;

void seive(){
	isComposite[0]=isComposite[1]=1;
	for(ll i=2; i<mxn; i++){
		if(!isComposite[i]){
			primes.eb(i);
			for(ll j=2*i; j<mxn; j+=i)isComposite[i]=1;
		}
	}
	return;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	ll a,b; cin >> a >> b;
	ll gcd = __gcd(a,b);
	vll p;
	seive();
	for(auto x:primes){
		if(x>gcd)break;
		if(gcd%x==0)p.eb(x);
		while(gcd%x==0){
			gcd/=x;
		}
	}
	if(gcd>1)p.eb(gcd);
	cout << p.size()+1 << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 11736
#include <iostream>
using namespace std;
bool search(int A[], int n, int key);

int main(void){
    
    int n, q, key, sum = 0;
    int A[100001];
    
    // 入力：探索する数列情報
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> A[i];
    
    // 入力：探索したい情報    
    cin >> q;
    for(int j = 0; j < q; j++){
        cin >> key;
        
        // 判定：探索が出来ているか確認
        if( search(A, n, key) ) sum++;
    }
    
    cout << sum << endl;
}

bool search(int A[], int n, int key){
    
    int i = 0;
    A[n] = key;     // 番兵を決めている
    
    while(A[i] != key){
        i++;
    }
    
    return i != n;  // 判定：番兵の場合は ” false ” を返す
}




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


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

    int n;
    cin >> n;
    vector<long> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<long> c_sum(n);
    c_sum[n - 1] = a[n - 1];
    for (int i = n - 2; i >= 0; --i) {
        c_sum[i] = c_sum[i + 1] + a[i];
        c_sum[i] %= 1000000007;
    }

    long ans = 0;
    for (int i = 0; i < n - 1; ++i) {
        ans += a[i] * c_sum[i + 1];
        ans %= 1000000007;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6352
#include <iostream>
#include <string>
using namespace std;
string s, t;

int main() {
  int N; cin >> N;
  cout << 0 << endl;
  cin >> s;
  if(s == "Vacant") {
    return 0;
  }
  int l = 0, r = N;
  while(t != "Vacant") {
    int mid = (l+r) / 2;
    cout << mid << endl;
    cin >> t;
    if(mid % 2^s == t) l = mid;
    else r = mid;
  }
  return 0;
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
using ll=long long;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  int N; cin >> N;
  string S; cin >> S;
  int ans=0;
  for(int i=0;i<1000;i++){
    int C[3]={i/100,(i/10)%10,i%10};
    int f=0;
    for(int j=0;j<N;j++){
      if(S[j]=='0'+C[f]) f++;
      if(f==3) break; //forgotten
    }
    if(f==3) ans++;
  }
  cout << ans << endl;
}

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

using namespace std;

#define int long long

const int mod = 1e9 + 7;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for (int i = k; i <= n + 1; ++i)
    {
        int a = i * (i - 1) / 2;
        int b = i * n - a;
        ans += (b + 1 - a);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


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

const ll MOD = 1e9+7LL;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n), cum(n+1);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        cum[i+1] = (cum[i] + a[i]) % MOD;
    }
    ll sum = 0;
    for(int i = 0; i+1 < n; i++){
        ll temp = (cum[n]-cum[i+1] + MOD) % MOD;
        temp = temp * a[i] % MOD;
        sum = (sum + temp) % MOD;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 6372
#include<stdio.h>
#define room 10
#define rank 3
#define ridge 4
int main(){
  int house[ridge][rank][room];
  for(int i=0;i<ridge;i++){
    for(int j=0;j<rank;j++){
      for(int k=0;k<room;k++){
        house[i][j][k] = 0;
      }

    }

  }
  int n,b,f,r,v;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d %d %d %d",&b,&f,&r,&v);
    if(v > 0){
        house[b-1][f-1][r-1] += v;
    }else{
        if(house[b-1][f-1][r-1] + v < 0){
            house[b-1][f-1][r-1] = 0;
        }else{
            house[b-1][f-1][r-1] += v;
        }
    }
  }
  
  for(int i=0;i<ridge;i++){
    for(int j=0;j<rank;j++){
      for(int k=0;k<room;k++){
        printf(" %d",house[i][j][k]);
      }
      printf("\n");
    }
    if(i+1!=ridge){
        printf("####################\n");
    }
  }

}



Measured memory_bytes: 2072
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n,i,j,k,l;
	cin >> n;
	ll h[n+1];
	ll dp[n+1];
	dp[0]=0;
	for(i=0;i<n;i++)
	{
		cin >> h[i];
	}
	dp[1]=abs(h[1]-h[0]);
	for(i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main(){
  int a, b, c, d, e, out;
  c = 10000;
  cin >> a >> b;
  for(int i=0; i<c; i++){
  	d = i* 8/100;
  	e = i*1 / 10;
  	if(a == d && b == e){
      cout << i <<endl;
      return 0;
  }
  }
  cout << -1 << endl;
  return 0;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\n"
#define all(v) v.begin(),v.end()
#define mp make_pair
#define mm(a) memset(a,true,sizeof(a))
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define repn(i,a,b) for(ll i = a; i >= b; i--)
#define pb push_back
#define ff first
#define ss second
#define fto(k,m) for(auto k:m)
#define in_edges(m) repp(i, 1, m){ ll a, b; cin >> a >> b; adj[a].pb(b), adj[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define MOD 1000000000000000007
#define pii 3.14159265358979323846
// int/float to string = to_string(12.90);
vector<ll> v;
void sieve(ll l,ll n)
{
	bool prime[n+1];
	mm(prime);
	prime[1] = false;
	for( ll i=2;i*i <= n; i++)
	{
		if(prime[i] == true)
		{
			for(ll k = i*i;k<=n;k+=i)
			{
				prime[k] = false;
			}
		}
	}
	for(ll i=l;i<=n;i++)
	{
		if(prime[i])
		v.pb(i);
	}
}

int main()
{
	    // freopen("in.txt","r",stdin);
	    // freopen("out","w",stdout);
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	    ll t;t=1;
	    // cin >> t;
	    while(t--)
	    {
			ll n,k; cin>>n>>k;
			set<ll> s;
			rep(i,0,k)
			{
				ll d; cin >>d;
				rep(i,0,d)
				{
					ll k; cin >>k;
					s.insert(k);
				}
			}cout << n-s.size();
		}
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<pair<int, int>, int> ppi;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef bitset<60> Bitset;
const ll INFL = 1LL << 60;
const int INF = 1000000005;
const int MAX = 300000;
const int MOD = 1000000007;
struct Graph{int to,coin; ll cost;};
struct Edge{int from,to,coin; ll cost;};
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
//------------------------------------------------------------------------------------------------------------------------------

int main(void) {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    ll a,b,k;cin>>a>>b>>k;
    cout<<max(0LL,a-k)<<' '<<max(0LL,b-max(0LL,k-a))<<endl;
}


Measured memory_bytes: 3640
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] split = Console.ReadLine().Split(" ");
        int n = int.Parse(split[0]), x = int.Parse(split[1]) ,t = int.Parse(split[2]);

        int count = (n - (n % x)) / x;
        if (n % x != 0) count++;

        Console.WriteLine(count * t);
    }


 
}




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

const int N = 1e5+5;

int n , A[N] , dp[N];

main(){
  cin >> n;
  for(int i = 1 ; i <= n ; i++) cin >> A[i];
  dp[1] = 0 , dp[2] = abs(A[1]-A[2]);
  for(int i = 3 ; i <= n ; i++)
    dp[i] = min(dp[i-1]+abs(A[i]-A[i-1]),dp[i-2]+abs(A[i]-A[i-2]));
  cout << dp[n] << "\n";
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}

ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}

int main(){
    ld a,b;
    cin >> a >> b;
    a*=b;
    ll c=(ll)a;
    cout << fixed;
    cout << c << endl;
    return 0;
}
 
 



Measured memory_bytes: 3732
#include<stdio.h>

int main(void){
	int n,i,b,j=0;
	int ka[4][13]={{0}};
	char a,kaigyokun='0';
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%c",&kaigyokun);
		scanf("%c %d",&a,&j);
		if(a=='S')b=0;
		else if(a=='H')b=1;
		else if(a=='C')b=2;
		else if(a=='D')b=3;
		ka[b][j]=1;
	}
	for(i=0;i<4;i++){
		for(j=1;j<=13;j++){
			if((ka[i][j])!=1){
				if(i==0)a='S';
				else if(i==1)a='H';
				else if(i==2)a='C';
				else a='D';
				printf("%c %d\n",a,j);
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2096
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N;
    cin >> N;
    ll p,cnt=0,i;
    for(i=0;i<N;i++){
        cin >> p;
        if(p!=i+1)cnt++;
    }
    if(cnt<=2)cout << "YES";else cout<<"NO";
    return 0;
}


Measured memory_bytes: 3044
while True:
    m, f, r = map(int, input().split())

    if m == -1 and f == -1 and r == -1:
        break
    elif m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif 65 <= m + f < 80:
        print("B")
    elif 50 <= m + f < 65:
        print("C")
    elif 30 <= m + f < 50:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5596
import java.util.Scanner;

class Main{
	public static void main(String args[]){
	Scanner scan = new Scanner(System.in);
	int a = scan.nextInt();
	int b = scan.nextInt();
        System.out.printf( "%d %d %f\n", a/b, a%b, (double)a/b );
	}
}

Measured memory_bytes: 26256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        for (long i = -120; i < 120; i++) {
            for (long j = -120; j < 120; j++) {
                long a = (long) Math.pow(i, 5);
                long b = (long) Math.pow(j, 5);
                if(a - b == x) {
                    System.out.println(i + " " + j);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 38944
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  map<string, int> mp;
  mp[s] = a;
  mp[t] = b;
  string u;
  cin >> u;
  mp[u]--;
  cout << mp[s] << " " << mp[t] << endl;
  return 0;
}

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

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
using namespace std;
int p[55];
int a[55],b[55],c[55],d[55];
int sum=-inf;
int n,m,q;
void choc()
{
    int x=0;
    for(int i=0; i<q; i++)
    {
        if(p[b[i]]-p[a[i]]==c[i])
        {
            x+=d[i];
        }
    }
    sum=max(sum,x);
    return ;
}
void dfs(int now,int s)
{
    p[now]=s;
    if(now==n)
    {
        choc();
        return ;
    }
    for(int i=s;i<=m; i++)
    {
        dfs(now+1,i);
    }
}
int main()
{
    cin>>n>>m>>q;
    for(int i=0; i<q; i++)
    {
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    dfs(1,1);
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3564
#include <iostream>

using namespace std;

int main(){

  int n, k, x, y;

  cin >> n;
  cin >> k;
  cin >> x;
  cin >> y;

  if (n > k){
    cout << (k * x) + ((n - k) * y) << endl;
  }
  else {
    cout << (n * x) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;
typedef long long ll;

vector<ll> v;

int main() {
    int n;
    cin >> n;
    ll a[n],sum=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
    }
    for(int i=0;i<n-1;i++){
        sum -= 2*a[i];
        ll abs = max(sum, -sum);
        v.push_back(abs);
    }
    sort(v.begin(),v.end());
    cout << v.at(0) << endl;
}

Measured memory_bytes: 3956
#include <cstdio>
#include <algorithm>

int as[100005][3];
int dp[100005][3];
int N;

int main(){
  scanf("%d",&N);
  for(int i=1;i<=N;i++){
    for(int j=0;j<3;j++){
      scanf("%d",&as[i][j]);
    }
  }
  for(int i=1;i<=N;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
	if(j!=k){
	  dp[i][j]=std::max(dp[i][j],dp[i-1][k]+as[i][j]);
	}
      }
    }
  }
  printf("%d\n",*std::max_element(dp[N],dp[N]+3));
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld double
long double PI =3.14159265;
using ll = long long;

const ll modo=1e9+7;
const ll ms=1e5+5;
const ll inf=1e9+9;


int ar[2000][2000];
int dis[2000][2000];

int main()
{
    idfc;
    int n,m;
    cin>>n>>m;
    int x,y;
    cin>>x>>y;
    int a,b;
    cin>>a>>b;
    int i,j;
    char e;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
           cin>>e;
           if(e=='.')ar[i][j]=1;
           else ar[i][j]=0;
        }
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)dis[i][j]=modo;
    }
    dis[x][y]=0;
    set<pair<int,pair<int,int>>> ss;
    ss.insert({0,{x,y}});
    int w;
    int d;
    int aa,bb;
    while(!ss.empty())
    {
        w=(*ss.begin()).first;
        x=(*ss.begin()).second.first;
        y=(*ss.begin()).second.second;
        ss.erase(*ss.begin());


        for(i=-1;i<=1;i++)
        {
            for(j=-1;j<=1;j++)
            {
                d=abs(i)+abs(j);
                if(d==1)
                {
                    aa=x+i;
                    bb=y+j;
                    if(aa>=1&&aa<=n&&bb>=1&&bb<=m&&ar[aa][bb])
                    {
                        if(dis[aa][bb]>w)
                        {
                            ss.erase({dis[aa][bb],{aa,bb}});
                            dis[aa][bb]=w;
                            ss.insert({dis[aa][bb],{aa,bb}});
                        }
                    }
                }
            }
        }



        for(i=-2;i<=2;i++)
        {
            for(j=-2;j<=2;j++)
            {
                aa=x+i;
                bb=y+j;
                if(aa>=1&&aa<=n&&bb>=1&&bb<=m&&ar[aa][bb])
                {
                    if(dis[aa][bb]>(w+1))
                    {
                        ss.erase({dis[aa][bb],{aa,bb}});
                        dis[aa][bb]=w+1;
                        ss.insert({dis[aa][bb],{aa,bb}});
                    }
                }
            }
        }

    }

    if(dis[a][b]==modo)cout<<-1;
    else cout<<dis[a][b];


    return 0;
}

Measured memory_bytes: 19412
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int a,b,c,d,e,f;
      cin >> a;
      b = a % 10;
      c = a / 10;
      d = c % 10;
      e = c / 10;
      f = e % 10;
      cout << b + d + f << endl;
    }

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
#define spn setprecision
#define fr(x,a,b,c) for(int x = a; x <= b; x+=c)
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int arr[upperlimit];
int arr2[upperlimit];
int main() {
	int x,y,n,m,max1=-INF,min1=INF;
	sd(n);sd(m);sd(x);sd(y);
	for(int i = 1; i <= n; i++){
		sd(arr[i]);
		max1=max(max1,arr[i]);
	}
	for(int i = 1; i <= m; i++){
		sd(arr2[i]);
		min1=min(min1,arr2[i]);
	}
	if(max(max1,x)<min(min1,y)){
		printf("No War\n");
	}
	else{
		printf("War\n");
	}
	return 0;
}

Measured memory_bytes: 2304