akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] c1 = in.readLine().split("");
    String[] c2 = in.readLine().split("");
    if(c1[0].equals(c2[2]) && c1[1].equals(c2[1]) && c1[2].equals(c2[0]))
      System.out.println("YES");
    else
      System.out.println("NO");
  }
}

Measured memory_bytes: 33044
from heapq import *

# Aの中でxの根を求める
def find(A,x):
    p = A[x]
    if p == x:
        return x
    a = find(A,p)
    A[x] = a
    return a

# Aのリストでxとyの属する集合の併合
def union(A, x, y):
    if find(A,x) > find(A,y):
        bx, by = find(A,y), find(A,x)
    else:
        bx, by = find(A,x), find(A,y)
    # 根をbxに統一
    A[by] = bx

N = int(input())
X = [(0,0)] * N
Y = [(0,0)] * N
E = [(0,0)] * N

for i in range(N):
    x, y = map(int, input().split())
    X[i] = (x, i)
    Y[i] = (y, i)
    E[i] = (x, y)

X.sort()
Y.sort()
H = []
heapify(H)

for i in range(N - 1):
    x1, j1 = X[i]
    x2, j2 = X[i + 1]
    y1, k1 = Y[i]
    y2, k2 = Y[i + 1]
    # ヒープ構造を用いて常にHの最初に最小値を持ってくる
    # X座標とY座標でそれぞれHに追加
    heappush(H, (x2 - x1, j1, j2))
    heappush(H, (y2 - y1, k1, k2))

answer = 0
V = [i for i in range(N)]

while H:
    w, s, t = heappop(H)
    # sとtの集合が異なっていた時、道を作る
    if find(V, s) != find(V, t):
        union(V, s, t)
        answer += w

print(answer)


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

int main(){
  int x,y,z;
  cin>>x>>y>>z;
  swap(x,y);
  swap(x,z);
  cout<<x<<" "<<y<<" "<<z;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define MAXSECONDS 100

int main(int argc,char const* argv[])
{
  int a,b,c,d,answer;
  cin >> a >> b >> c >> d;
  if(b<c || d<a)
    {
      answer=0;
    }
  else if(c<=a && b<=d)
    {
      answer=b-a;
    }
  else if(a<=c && b<=d)
    {
      answer=b-c;
    }
  else if(c<=a && d<=b)
    {
      answer=d-a;
    }
  else if(a<=c && d<=b)
    {
      answer=d-c;
    }
  else answer=0;
  cout << answer;
  return 0;
}

Measured memory_bytes: 256
line = input()
n = int(input())

for _ in range(n):
    x = list(map(str, input().split()))
    a, b = int(x[1]), int(x[2])
    if x[0] == "print":
        print(line[a:b+1])
    elif x[0] == "reverse":
        line = line[:a] + line[a:b+1][::-1] + line[b+1:]
    else:
        line = line[:a] + x[3] + line[b+1:]



Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
#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 pb push_back
#define MP(a, b) make_pair((a), (b))
template <class T> vector<T> make_vec(size_t a, T val) {
    return vector<T>(a, val);
}
template <class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec(ts...))>(a, make_vec(ts...));
}
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
template <typename T> struct edge {
    int to;
    T cost;
    edge(int t, T c) : to(t), cost(c) {}
};
template <typename T> using WGraph = vector<vector<edge<T>>>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll res = 0;
    res += A[0] - 1;
    ll c = 1;
    for(int i = 1; i < N; i++) {
        if(A[i] == c + 1) {
            c++;
            continue;
        } else {
            res += (A[i] - 1) / (c + 1);
        }
    }
    cout << res << endl;
}

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

int main() {
	int num;
    cin >> num;
    
    for(int i = 0; i < num; i++) {
    	string color;
        cin >> color;
    
    	if (color == "Y") {
        	cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;    
    return 0;
}


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

int n, m;
pair<int, int> l[100000];

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> l[i].first >> l[i].second;
    }
    sort(l, l + n);

    priority_queue<int> que;
    int ans = 0;
    int tmp;

    for (int i = 0; i < n; i++) {
        if (i != 0 && l[i].first != l[i - 1].first) {
            for (int j = tmp; j < min(m + 1, l[i].first) && !que.empty(); j++) {
                ans += que.top();
                que.pop();
            }
        }
        tmp = l[i].first;
        if (tmp > m) break;
        que.push(l[i].second);
    }

    for (int i = tmp; i <= m && !que.empty(); i++) {
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;

}

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

typedef unsigned uint;
typedef long long INT;
typedef unsigned long long UINT;
const int INF = 1001001001;
const INT INFLL = 1001001001001001001LL;

 int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
INT lin() { INT x; scanf("%lld", &x); return x; }


int main(){
    int a, b, c;
    double fa, fb, fc;
    char sa[128], sb[128], sc[128];

    INT N = lin();
    INT K = lin();

    INT A = N % K;
    INT B = abs(A - K);

    printf("%ld", min(A, B));

    return 0;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

int main() {
	ll a, b, c;
	cin>>a>>b>>c;
	if((a&1) && (b&1) && (c&1)) {
		cout << min(min(a*b, b*c), a*c) << endl;
	} else
		puts("0");
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            string line;
            int a = 0, b = 0;
            while ((line = Console.ReadLine()) != null)
            {
                var d = line.Split(',').Select(int.Parse).ToArray();
                if (d[0] == d[1]) a++;
                else if (d[0] * d[0] + d[1] * d[1] == d[2] * d[2]) b++;
            }
            Console.WriteLine(b);
            Console.WriteLine(a);
        }
    }
}

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var abc = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = abc[0];
            var b = abc[1];
            var c = abc[2];

            Console.WriteLine(Math.Max(c - (a - b), 0));
        }
    }
}

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

using namespace std;

static const int A = 1e+9 + 7;
static const int MAX_N = 50;
static const int MAX_K = 1250;
unsigned long dp[MAX_N + 1][MAX_N + 1][MAX_K + 1];
int n, k;

void solve();

int main() {
    scanf("%d %d", &n, &k);
    if (k > n * n / 2) printf("0\n");
    else {
        solve();
        printf("%lu\n", dp[n][0][k]);
    }
    return 0;
}

void solve() {
    dp[1][0][0] = 1;
    dp[1][1][2] = 1;
    for (int i = 2; i <= n; i++) {
        for (int l = 0; l <= min(i * (i + 1), k) ; l++) {
            for (int j = 0; j <= n && l >= 2 * j; j++) {
                dp[i][j][l] = (2*j+1)*dp[i-1][j][l-2*j];
                if (j <= n) dp[i][j][l] += (j+1)*(j+1)*dp[i-1][j+1][l-2*j];
                if (j > 0) dp[i][j][l] += dp[i-1][j-1][l-2*j];
                dp[i][j][l] %= A;
//                printf("%d %d %d: %u\n", i, j, l, dp[i][j][l]);
            }
        }
    }
}


Measured memory_bytes: 23552
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main() {
	int x, n;
	cin >> x >> n;
	vector<int> a(n);
	rep(i, n)
		cin >> a[i];

	vector<int> b(102, 1);
	rep(i, n)
		b[a[i]]--;
	int min = 105;
	int ans;
	for (int i = 101; i >= 0; i--) {
		if (b[i] == 1) {
			if (abs(x - i) <= min) {
				min = abs(x - i);
				ans = i;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int mex(unordered_set<int> &s)
{
	int a=0;
	while(1)

	{
		if(s.find(a)==s.end())return a;
		a++;
	}
}
int main() {
	// your code goes here
	int n,k;
	cin>>n>>k;
	vector<int> A(n),dp(k+1);
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		cin>>A[i];
	}
	for(int i=1;i<=k;i++)
	{
		unordered_set<int> s;
		for(int x:A)
		{
			if(i-x<0)continue;
			s.insert(dp[i-x]);
		}
		dp[i]=mex(s);
	}
	if(dp[k])cout<<"First";
	else cout<<"Second";
	
	
}

Measured memory_bytes: 3768
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)

int main(){
	double a[40];
	int k[40];
	
	int t=1;
	for(int i=24;i>0;i--){
		a[i]=t;
		k[i]=1;
		t*=2;
	}
	double tt=1.0;
	for(int i=25;i<=31;i++){
		tt/=2;
		a[i]=tt;
		k[i]=i-24;
	}
	/*a[25]=0.5; k[25]=1;
	a[26]=0.25; k[25]=1;
	a[27]=0.125; k[25]=1;
	a[28]=0.0625; k[25]=1;
	a[29]=0.03125; k[25]=1;
	a[30]=0.015625; k[25]=1;
	a[31]=0.0078125; k[25]=1;*/
	
	int q;
	cin>>q;
	rep(ppp,q){
		string s,t="";
		cin>>s;
		rep(i,8){
			int b=s[i];
			if('a'<=b&&b<='f')b=10+b-'a';
			else b-=48;
			
			int c[4]={8,4,2,1};
			rep(j,4){
				if(b>=c[j])t+='1';
				else t+='0';
				b%=c[j];
			}
		}
		
		
		double ans=0.0;
		int K=1;
		
		rep1(i,31){
			if(t[i]=='1'){
				ans+=a[i];
				K=max(K,k[i]);
			}
		}
		
		if(t[0]=='1')printf("-");
		
		if(K==1)printf("%.1f\n",ans);
		if(K==2)printf("%.2f\n",ans);
		if(K==3)printf("%.3f\n",ans);
		if(K==4)printf("%.4f\n",ans);
		if(K==5)printf("%.5f\n",ans);
		if(K==6)printf("%.6f\n",ans);
		if(K==7)printf("%.7f\n",ans);
		if(K==8)printf("%.8f\n",ans);
	}
}

Measured memory_bytes: 1264
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    cout << N / 3 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;

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

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

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

  if (a >= 13)
    cout << b << en;
  else if (a <= 5)
    cout << 0 << en;
  else
    cout << b / 2 << en;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int n;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; i++) cin >> x[i];
    sort(x.begin(), x.end());
    int pos;
    int min_cons = -1;
    for (int i = x[0]; i <= x[n - 1]; i++){
        int temp_cons = 0;
        for (int j = 0; j < n; j++){
            temp_cons += pow(x[j] - i, 2);
        }
        if (min_cons >= 0){
            if (temp_cons < min_cons){
                min_cons = temp_cons;
                pos = i;
            }
        }
        else min_cons = temp_cons;
    }
    cout << min_cons << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
# import math
# import numpy as np
# from functools import lru_cache

from functools import reduce    # リストの積を作りたい時とか
# reduce(lambda a, b: a * b, array)

from collections import deque

args = sys.argv
if len(args) == 2:
  from IPython import embed
  em = True
else:
  em = False

# sys.setrecursionlimit(10000)

#### input
N = int(input())
# a, b = map(int, input().split())
As = list(map(int, input().split()))

if N == 1:
  print(As[0])
  exit()
# a = list(map(lambda x: int(x)*(-1), a))  # 各要素を-1倍


# n = int(input())
# t = [int(input()) for i in range(n)]
if em: sys.stdin = open('/dev/tty')

#### function
numerator = reduce(lambda a, b: a * b, As)

denominator = 0
for i in range(0, N):
  tmp = As.pop(0)
  denominator = denominator + reduce(lambda a, b: a * b, As)
  As.append(tmp)

print(numerator / denominator)
# @lru_cache(maxsize=10000)

#### process
# if em: embed()

## heapsort, O(NlogN)
# import heapq
# heapq.heapify(A)
# min = heapq.heappop(A)
# heapq.heappush(A, new_element)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
 
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;
 
vector<int> e[MAX_N];
 
// return value: pair{black, white}
pair<long long, long long> dfs(int a, int parent)
{
    long long black = 1, white = 1;
    for (int b : e[a]) {
        if (b != parent) {
            pair<long long, long long> p = dfs(b, a);
            black = (black * p.second) % MOD;
            white = (white * ((p.first + p.second) % MOD)) % MOD;
        }
    }
    return {black, white};
}
 
int main()
{
    int n;
    scanf("%d", &n);
    while (--n) {
        int a, b;
        scanf("%d%d", &a, &b);
        e[a].push_back(b);
        e[b].push_back(a);
    }
 
    pair<long long, long long> ret = dfs(1, -1);
    printf("%lld\n", (ret.first + ret.second) % MOD);
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(), (v).end()
#define sort(v) sort(all(v))
#define rev(x) reverse(all(x))
 
using ld = long double;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
 
const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

int main() {
  int n,m;cin>>n>>m;
  vi an(n,0);
  int a,b;
  rep(i,m) {
    cin>>a>>b;
    an[a-1]++;
    an[b-1]++;
  }
  rep(i,n) cout << an[i] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int d;
  ll g;
  cin >> d >> g;
  vector<ll> p(d), c(d);
  for (int i = 0; i < d; ++i) {
    cin >> p.at(i) >> c.at(i);
  }

  ll res = 1 << 29;

  //bit全探索
  for (int bit = 0; bit < (1 << d); ++bit) {
    ll sum = 0;
    ll num = 0;

    //bitflgが立ってるやつを足す
    for (int i = 0; i < d; ++i) {
      if (bit & (1 << i)) {
        sum += c.at(i) + p.at(i) * (i + 1) * 100;
        num += p.at(i);
      }
    }

    //true 条件を満たすnumの最小値 else 大きい配点から足す
    if (sum >= g) {
      res = min(res, num);
    } else {
      for (int i = d - 1; i >= 0; --i) {
        if (bit & (1 << i)) {
          continue;
        }
        for (int j = 0; j < p.at(i); ++j) {
          if (sum >= g) {
            break;
          }
          sum += 100 * (i + 1);
          ++num;
        }
      }
      res = min(res, num);
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include<cstdio>
int main()
{

    int n,x;
    int sum=0;
    int max=-1;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&x);
        if(x>max)
            max=x;
        sum+=x;
    }
    sum-=max/2;
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define iinf 2000000000
#define linf 1000000000000000000LL
#define ulinf 10000000000000000000ull
#define MOD1 1000000007
#define lson(v) ((v)<<1)
#define rson(v) (((v)<<1)^1)
#define mpr make_pair
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef unsigned short US;
typedef pair < int , int > pii;
clock_t __stt;
inline void TStart(){__stt=clock();}
inline void TReport(){printf("\nTaken Time : %.3lf sec\n",(double)(clock()-__stt)/CLOCKS_PER_SEC);}
template < typename T > T MIN(T a,T b){return a<b?a:b;}
template < typename T > T MAX(T a,T b){return a>b?a:b;}
template < typename T > T ABS(T a){return a>0?a:(-a);}
template < typename T > void UMIN(T &a,T b){if(b<a) a=b;}
template < typename T > void UMAX(T &a,T b){if(b>a) a=b;}
int n,a,b;
int main(){
    // inputing start
    scanf("%d%d%d",&n,&a,&b);
    #ifdef LOCAL
        TStart();
    #endif
    // calculation start
    int xb,x2,res=-1;
	for(xb=0;xb<1000000;++xb){
		if(xb&1){
			//B
			if(b==1 && a==2 || b==n && a==n-1){
				printf("Alice\n");
				return 0;
			}
			if(b==1) ++b;
			else if(b==n) --b;
			else if(a==b-1) ++b;
			else if(a==b+1) --b;
			else if(a>b && !((a-b)&1) || a<b && ((b-a)&1)) ++b;
			else --b;
		}
		else{
			//A
			if(a==1 && b==2 || a==n && b==n-1){
				printf("Borys\n");
				return 0;
			}
			if(a==1) ++a;
			else if(a==n) --a;
			else if(b==a-1) ++a;
			else if(b==a+1) --a;
			else if(b>a && !((b-a)&1) || b<a && ((a-b)&1)) ++a;
			else --a;
		}
	}
	printf("Draw\n");
    #ifdef LOCAL
        TReport();
    #endif
    return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int a = scanner.nextInt();
        String s = scanner.next();

        int max = 0;
        String bef;
        String aft;

        for (int i = 0;i<a;i++) {
        	bef = s.substring(0, i+1);
        	aft = s.substring(i+1,s.length());
        	int cnt = 0;

        	String[] bef2 = bef.split("");
        	Set<String> hash_set = new HashSet<String>();

        	for(String tmp : bef2) {
        		hash_set.add(tmp);
        	}

        	/*
        	for(int j=0;j<bef2.length;j++) {
        		hash_set.add(bef2[j]);
        	}
        	*/
        	for(String tmp : hash_set){
        		if(aft.contains(tmp)) {
        			cnt++;
        		}
        	}
        	/*
        	Iterator<String> iterator = hash_set.iterator();
        	for (int k=0;k<hash_set.size();k++) {
        		if(aft.contains(iterator.next())) {
        			cnt++;
        		}
        	}
        	*/
        	if (cnt >= max) {
        		max = cnt;
        	}
        }
        System.out.println(max);

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


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

int main()
{
  int m,f,r,goukei;
  char rank;

  while(1){

 cin >> m >> f >> r;

 goukei = m + f; 



 if(m == -1 && f == -1 && r == -1){

             break;
    }
 else if(m == -1 || f == -1){

   rank = 'F';
 }


else if(goukei >= 80){

    rank = 'A';

    }
else if(goukei < 80 && goukei >= 65){

      rank = 'B';

    }
else if(goukei < 65 && goukei >= 50){

      rank = 'C';

    }
else if(goukei < 50 && goukei >= 30){

  if(r >= 50){

	rank = 'C';

  }

  else rank = 'D';

  }

else if(m == -1 && f == -1 && r == -1){

             break;
    }
else if(goukei < 30){

	  rank = 'F';

    }
  
  cout << rank << "\n";

  }
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 

 int main(){
ll n ; cin>> n ;
vector<string> A(n) ;
rep(i,n) cin>>A[i] ;
vector<ll> sum(n) ,sa(n) ;
rep(i,n){
  ll k= A[i].size() ;
  ll now=0 ;
  ll ans=0 ;
  rep(j,k){
   if(A[i][j]==')') now-- ;
   else now++ ;
   chmin(ans,now)  ;
  }
  sum[i]= now ;
  sa[i]= ans ;
}
 vector<P> B, D ;
 ll zero =0 ;

  rep(i,n){
   if(sum[i]>0){
   P xx= mpa(sa[i],sum[i]) ;
   B.pb(xx) ;
   }
   if(sum[i]==0) chmin(zero,sa[i]) ;
   if(sum[i]<0){
     P yy= mpa(sum[i]-sa[i],sum[i]) ;
     D.pb(yy) ;
   }

  }

  sort(B.rbegin(),B.rend()) ;
  sort(D.begin(),D.end()) ;
  ll ok= B.size() ;
  ll ko= D.size() ; 
  ll start= 0 ;
  bool flag= 0;

  rep(i,ok){
  if(start+ B[i].fi<0) flag=1;
  start+= B[i].se ;
  }

  if(start+zero<0) flag=1 ;
  ll goal =0 ;
  rep(i,ko){
    if(goal-D[i].fi<0) flag=1 ;
     goal -= D[i].se ;
  }
  if(start!=goal) flag=1 ;
 
  if(flag) cout<<"No"<<endl ;
  else cout<<"Yes"<<endl ;
   return 0 ;
}



Measured memory_bytes: 65840
#include <cstdio>
#include <cstring>
const int maxn=1e5+10;
char s[maxn];
int main() {
    scanf("%s",s+1);
    int len=strlen(s+1);
    if (len==1) {
        puts("1 1");
        return 0;
    }
    if (len==2 && s[1]==s[2]) {
        puts("1 2");
        return 0;
    }
    if (len==2 && s[1]!=s[2]) {
        puts("-1 -1");
        return 0;
    }
    bool f=false;
    for (int i=1;i<len-1;i++) {
        if (s[i]==s[i+1]||s[i]==s[i+2]) {
            printf("%d %d\n", i,i+2);
            f=true;
            break;
        }
    }
    if (!f) puts("-1 -1");
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()

num_W = 0
num_E = S.count("E")
if S[0] == 'W':
    num_W = 1
else:
    num_E -= 1
minv = num_E
for i in range(1, N):
    if S[i] == 'W':
        num_W += 1
    else:
        num_E -= 1
    minv = min(minv, num_W+num_E)
print(minv)


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

int main(){
 int i,r,D,x;
 
  
 scanf("%d %d %d",&r,&D,&x);
  
 for(i=0;i<10;i++){
   x = r*x-D;
   printf("%d\n",x);
 }

}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
#include <tuple>
#include <iomanip>
#include <assert.h>

#define sqr(x) std::pow(x, 2.0)
#define INF 1e10
#define EPS 1e-10
#define REP(i, n) for (int i = 0; i < n; i++)
#define POS_OR_INF(x) (x > 0 ? x : INF)

using namespace std;

using ld = long double;

struct Point {
	Point() = default;
	Point(ld x, ld y) : x(x), y(y) {}
	Point(const Point& s, const Point& e) : x(e.x - s.x), y(e.y - s.y) {}

	Point normalized(void) const {
		return Point(x / norm(), y / norm());
	}

	ld norm(void) const {
		return sqrt(x * x + y * y);
	}

	Point flipped(void) const {
		return Point(-x, -y);
	}

	Point normal_vector(bool normalize = false) const {
		auto vec = Point(-y, x);
		return normalize ? vec.normalized() : vec;
	}

	ld theta(void) const {
		return atan2(y, x);
	}

	ld x, y;
};

using Vector = Point;

inline Vector points2vec(const Point& s, const Point& e) {
	return Vector(e.x - s.x, e.y - s.y);
}

inline ld distance(const Point& s, const Point& e) {
	return points2vec(s, e).norm();
}

inline ld distance_square(const Point& s, const Point& e) {
	return pow(points2vec(s, e).norm(), 2.0);
}

inline ld inner_product(const Point& p, const Point& q) {
	return p.x * q.x + p.y * q.y;
}

inline ld cross_product(const Point& p, const Point& q) {
	return p.x * q.y - p.y * q.x;
}

inline Vector operator * (const Vector& l, ld r) {
	return Vector(l.x * r, l.y * r);
}

inline Vector operator * (ld l, const Vector& r) {
	return r * l;
}

inline Vector operator / (const Vector& l, ld r) {
	return Vector(l.x / r, l.y / r);
}

inline Point operator + (const Point& l, const Point& r) {
	return Point(l.x + r.x, l.y + r.y);
}

inline Point operator - (const Point& l, const Point& r) {
	return Point(l.x - r.x, l.y - r.y);
}

inline istream& operator >> (istream& is, Point& p) {
	return is >> p.x >> p.y;
}


struct Hole {
	Point p;
	int i;
};

int main(int argc, char** argv) {
	int N;

	cout << fixed << setprecision(20);
	cin >> N;

	vector<Hole> h(N);

	for (int i = 0; i < N; i++) {
		cin >> h[i].p;
		h[i].i = i;
	}

	// 凸包を求める
	sort(h.begin(), h.end(), [](auto l, auto r) { return l.p.x < r.p.x || (l.p.x == r.p.x && l.p.y < r.p.y); });

	vector<Hole> convex(N * 2);
	int k = 0;
	for (int i = 0; i < N; i++) {
		while (k > 1 && cross_product(convex[k - 1].p - convex[k - 2].p, h[i].p - convex[k - 1].p) <= 0) k--;
		convex[k++] = h[i];
	}
	for (int i = N - 2, t = k; i >= 0; i--) {
		while (k > t && cross_product(convex[k - 1].p - convex[k - 2].p, h[i].p - convex[k - 1].p) <= 0) k--;
		convex[k++] = h[i];
	}
	int M = k - 1;
	convex.resize(M);

	vector<double> ans(N);

	for (int i = 0; i < M; i++) {
		Point cur = convex[i].p;
		Point prev = convex[(i + M - 1) % M].p;
		Point next = convex[(i + M + 1) % M].p;

		double diff = (next - cur).theta() - (cur - prev).theta();

		if (diff < 0) diff += 2 * M_PI;
		if (diff > 2 * M_PI) diff -= 2 * M_PI;

		ans[convex[i].i] = diff / (2 * M_PI);
	}

	for (int i = 0; i < N; i++)
		cout << ans[i] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>a>>b>>c>>n;
    rep(i,n+1){
        rep(j,n+1){
            sum=a*i+b*j;
            ll want=n-sum;
            if(want>=0&&want%c==0)ans++;
        }
    }
    Cout(ans);
    return 0;
}

Measured memory_bytes: 764
N = int(input())
A = list(map(int,input().split()))
C = {}
for i in range(N):
    a = A[i]
    if a not in C:
        C[a] = 0
    C[a] += 1
B2 = []
B4 = []
for a in C:
    if 3>=C[a]>=2:
        B2.append(a)
    elif C[a]>=4:
        B4.append(a)
B2 = sorted(B2,reverse=True)
B4 = sorted(B4,reverse=True)
cmax = 0
if len(B2)>=2:
    cmax = max(cmax,B2[0]*B2[1])
if B4:
    cmax = max(cmax,B4[0]**2)
if B2 and B4:
    cmax = max(cmax,B2[0]*B4[0])
print(cmax)

Measured memory_bytes: 98624
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;

int main()
{
    long long int dp[110][100010] = {};
    int N, W;
    cin >> N >> W;
    vector<int>w(N), v(N);
    for (int i = 0; i < N; i++)cin >> w[i] >> v[i];
    for (int i = 1; i <= N; i++)
    {
        for (int j = 1; j <= W; j++)
        {
        	dp[i][j]=dp[i-1][j];
        	if(j-w[i-1]>=0)dp[i][j]=max(dp[i][j],dp[i-1][j-w[i-1]]+v[i-1]);
        }
    }
    cout<<dp[N][W];
}

Measured memory_bytes: 86144
#include <bits/stdc++.h>
 
#define all(x) (x).begin(), (x).end()
#define li long long
#define itn int
 
using namespace std;
 
inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

int main(){

	int n = nxt(), a = nxt(), b = nxt();
	string s;
	cin >> s;

	int cur = 0, cur_o = 0;
	for (char c : s) {
		if (c == 'a') {
			if (cur < a + b) {
				puts("Yes");
				cur++;
			} else {
				puts("No");
			}
		} else if (c == 'b') {
			if (cur < a + b && cur_o < b) {
				puts("Yes");
				cur += 1;
				cur_o += 1;
			} else {
				puts("No");
			}
		} else {
			puts("No");
		}
	}

	return 0;
}

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

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}

int atcoder(){
    int n,x,ans=0;
    cin>>n>>x;
    Vi a(n);
    REP(i,0,n) cin>>a[i];
    
    SORTV(a);
    REP(i,0,n){
        x-=a[i];
        if(x<0) break;
        if(i==n-1 && x!=0) break;
        ans++;
    }
    cout<<ans<<ENT;
    return 0;
}


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


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

using namespace std;

int main(){
    int H, W, K;
    while(cin >> H >> W >> K){
        vector<string> vs(H);
        for(auto& s : vs) cin >> s;
        int ans = H+W;
        for(int div=0;div<(1<<(H-1));div++){
            int res = 0;
            for(int j=0;j<H-1;j++) res += (div>>j)%2;
            vector<int> cnt(H, 0);
            vector<int> add(H, 0);
            bool valid = true;
            for(int j=0;j<W;j++){
                fill(add.begin(), add.end(), 0);
                int idx = 0;
                add[idx] += vs[0][j] - '0';
                for(int k=0;k<H-1;k++){
                    if(div&(1<<k)) ++idx;
                    add[idx] += vs[k+1][j] - '0';
                }
                bool ok = true;
                for(int k=0;k<H;k++){
                    if(add[k] > K) valid = false;
                    if(cnt[k]+add[k] > K) ok = false;
                }
                if(ok){
                    for(int k=0;k<H;k++) cnt[k] += add[k];
                } else {
                    ++res;
                    cnt = add;
                }
            }
            if(valid) ans = min(res, ans);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    string s;
    cin >> s;
    int n = 0;
    int tmp = 0;
    rep(i,s.size()){
        if(s[i]!='A'&&s[i]!='C'&&s[i]!='G'&&s[i]!='T'){
            
            tmp=0;
            continue;
        }
        ++tmp;
        n = max(n,tmp);
    }
    cout << n << endl;
    return 0;

}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;


int main() {
    int n, l;
    cin >> n >> l;
    vector<string> terms(n);
    rep(i, n) cin >> terms[i];
    sort(terms.begin(), terms.end());
    for (string &s : terms) {
        cout << s;
    }
    cout << endl;
}

Measured memory_bytes: 256
import math
import itertools
import collections
import bisect
import heapq

def IN(): return int(input())
def sIN(): return input()
def MAP(): return map(int,input().split())
def LMAP(): return list(map(int,input().split()))
def TATE(n): return [input() for i in range(n)]
MOD = 10**9 + 7

n = IN()
a = LMAP()
c = 0
ans = 0

for i in a:
  c += 1
  if i%2 == 1 and c%2 ==1:
    ans += 1
    
print(ans)

Measured memory_bytes: 9408
N, *AS = $stdin.read.split.map(&:to_i)
ary = Array.new(N*2)
l = N-1
r = N
N.times do |i|
  if i.even?
    ary[r] = AS[i]
    r += 1
  else
    ary[l] = AS[i]
    l -= 1
  end
end
ary.compact!
ary.reverse! if N.odd?
puts ary.join(' ')


Measured memory_bytes: 28412
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから
using P=pair<int,ll>;
vector<vector<P>>g;
int n;
vector<int>c;
void dfs(int v){
  for(auto e:g[v]){
    if(c[e.first]==-1){
      if(e.second%2==0)c[e.first]=c[v];
      else c[e.first]=c[v]^1;
      dfs(e.first);
    }
  }
}

void solve(){
  cin>>n;
  c.resize(n,-1);
  g.resize(n);
  rep(i,n-1){
    int u,v;
    ll w;
    cin>>u>>v>>w;
    u--;v--;
    g[u].eb(v,w);
    g[v].eb(u,w);
  }
  c[0]=0;
  dfs(0);
  rep(i,n)cout<<c[i]<<"\n";
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}

Measured memory_bytes: 8832
def GSB(x):
	counter=0
	while x!=0:
		counter+=1
		x=x>>1
	return counter


N=[int(x) for x in (list(input()))]
combinations=[int(x) for x in range((2**4))]
for i in combinations:
	checker=[x for x in N]
	j=0
	z=GSB(i)
	while j!=z and i!=0:
		if i&1==1:
			checker[j]*=-1
		i=i>>1
		j+=1
	if sum(checker)==7 and checker[0]>=0:
		checker=checker + [-1]
		for i in range(4):
			if checker[i+1]>=0:
				print(checker[i],end="+")
			else:
				print(checker[i],end="")
		print("=7")
		exit()

Measured memory_bytes: 61952
S=str(input())
Q=int(input())
count=0
M=''
U=''
for i in range(Q):
	a=list(map(str,input().split()))
	if a[0]=="1":
		count+=1
	elif a[0]=="2":
		if count%2==0:
			if a[1]=="1":
				M=a[2]+M
			elif a[1]=="2":
				U=U+a[2]
		elif count%2==1:
			if a[1]=="1":
				U=U+a[2][::-1]
			elif a[1]=="2":
				M=a[2][::-1]+M
S=M+S+U
if count%2==1:
	print(S[::-1])
else:
	print(S)

Measured memory_bytes: 4632
let ms = Array.make_matrix 51 51 ~-1
let rec c n k = if ms.(n).(k) > -1 then ms.(n).(k) else (ms.(n).(k) <- if n < k then 0 else if n = k then 1 else if k = 0 then 1 else c (n - 1) (k - 1) + c (n - 1) k; ms.(n).(k))
let a, b, vs = Scanf.(scanf "%d %d %d" @@ fun n a b -> a - 1, b - 1, Array.init n @@ fun _ -> scanf " %d" (+) 0)
let m, s = Array.(sort (fun x y -> y - x) vs; vs.(0), sub vs 0 (a + 1))
let f = Array.(fold_left (fun c v -> if v = vs.(a) then c + 1 else c)) 0
let t = f vs
let _ = Array.(Printf.printf "%.6f\n%d\n" (float (fold_left (+) 0 s) /. (float a +. 1.)) @@ if vs.(a) = m then let s = ref 0 in for i = a + 1 to b + 1 do s := !s + c t i done; !s else c t (f s))

Measured memory_bytes: 512
#include<stdio.h>

#define MIN(x,y) (((x)<(y))?(x):(y))

int main(void){
  int min[2000][2000];
  long long a[2000];
  long long N,x;
  long long sum,summin;
  int i,j,k;

  scanf("%lld%lld",&N,&x);
  for(i=0;i<N;i++) scanf("%lld",&a[i]);
  
  for(i=0;i<N;i++){
    min[0][i]=a[i];
    sum+=a[i];
  }
  summin=sum;

  for(i=1;i<N;i++){
    sum=0;
    for(j=0;j<N;j++){
      k=(j-i>=0)?j-i:N+j-i;
      min[i][j]=MIN(min[i-1][j],a[k]);
      sum+=min[i][j];

    }
    sum+=i*x;
    if(sum<summin) summin=sum;
  }
  printf("%lld\n",summin);
  return 0;
}

  


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

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

    cout<<pow(n,3)<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = 1000000007;

int main() {
    // input
    ll a, b, c, x;
    cin >> a >> b >> c >> x;

    ll ans = 0;
    rep(i, a + 1) {
        rep(j, b + 1) {
            rep(k, c + 1) {
                if ((i)*500 + (j)*100 + (k)*50 == x) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    ll n; cin >> n;
    n -= 1;
    unsigned long long res = n * (n + 1) / 2;
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#define ll long long
#define lld long double
#define llu unsigned long long int
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define gll(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define mod 1000000007
#define mod1 998244353
#define pi 3.1415926535897
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("B-small-attempt0.in", "r", stdin);freopen("output.txt", "w", stdout);
    //std::cout << std::setprecision(9);
    //std::cout << std::fixed;
    ll n,d,i,j,k;
    cin>>n>>d;
    vector<ll> v[n];
    for(i=0;i<n;i++)
    {
        for(j=0;j<d;j++)
        {
            ll x;
            cin>>x;
            v[i].pb(x);
        }
    }
    ll ans=0;
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            ll sum=0;
            for(k=0;k<d;k++)
            {
                sum+=abs(v[i][k]-v[j][k])*abs(v[i][k]-v[j][k]);
            }
            lld root=sqrt(sum);
            if((ll)root==root)
                ans++;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 384
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  vector<pair<int,int>> A(N);
  int temp_A;
  for(int i=0;i<N;i++){
    cin >> temp_A;
    A.at(i)=make_pair(temp_A,i+1);
  }
  sort(A.begin(),A.end());

  for(int i=0;i<N;i++) cout << A.at(i).second << " ";
  cout << endl;

  return 0;
}


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

int main() {
  uint64_t n, k;
  std::cin >> n >> k;
  std::vector<uint64_t> a(n);
  for (auto & i : a) {
    std::cin >> i;
  }

  uint64_t bit[40][2];
  uint64_t one = 1;

  for (int i = 0; i < 40; i++) {
    uint64_t v0 = 0, v1 = 0;
    uint64_t flag = one << i;
    for (const auto j : a) {
      v0 += (j & flag) ^ 0;
      v1 += (j & flag) ^ flag;
    }
    bit[i][0] = v0;
    bit[i][1] = v1;
  }

  uint64_t ans = 0;
  for (int i = 0; i < 40; i++) {
    uint64_t val = 0;
    for (int j = 0; j < 40; j++) {
      if (i < j) {
        int flag = (k & (one << j)) != 0;
        val += bit[j][flag];
      } else if (i == j) {
        val += bit[j][0];
      } else {
        if ((k & (one << i)) != 0) {
          val += std::max(bit[j][0], bit[j][1]);
        } else {
          int flag = (k & (one << j)) != 0;
          val += bit[j][flag];
        }
      }
    }
    ans = std::max(ans, val);
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

#define N 25
#define NIL -1

typedef struct node{
  int p;
  int l;
  int r;
}Node;

Node T[N];

void preorder(int u){
  if(u == NIL)return;
  printf(" %d",u);
  preorder(T[u].l);
  preorder(T[u].r);
}
void inorder(int u){
  if(u == NIL)return;
  inorder(T[u].l);
  printf(" %d",u);
  inorder(T[u].r);
}
void postorder(int u){
  if(u == NIL)return;
  postorder(T[u].l);
  postorder(T[u].r);
  printf(" %d",u);
}

int main(){
  int i,id,root,n,left,right,j;
  
  scanf("%d",&n);
  for(i = 0; i < n; i++)T[i].p = NIL;
  id = NIL;
  for(i = 0; i < n; i++){
    scanf("%d %d %d",&id,&left,&right);
    T[id].l = left;
    T[id].r = right;
    if(left != NIL)T[left].p = id;
    if(right != NIL)T[right].p = id;
    for(j = 0; j < i; j++){
      if(T[j].p == NIL)root = j;
    }
  }
 
  printf("Preorder\n");
  preorder(root);
  printf("\n");
  printf("Inorder\n");
  inorder(root);
  printf("\n");
  printf("Postorder\n");
  postorder(root);
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 2048
n, k = map(int, input().split())
sumA=0
index=1
while index <= n:
    if index >= k:
        sumA+=1/n
    else:
        index2=0
        while index2 < 18:
            if index*(2**index2) >= k:
                break
            index2+=1
        sumA+=(1/n)*((1/2)**index2)
    index+=1
print(sumA)

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

using namespace std;
using ll = long long;

int main(void){
	ll n = 0;
	cin >> n;

	ll sum=0;
	vector<ll> a(n,0);

	for(int i=1;i<=n;i++){
		ll k=i;
		while(k<=n){
			a[k]+=k;
			k+=i;
		}
		sum += a[i];
	}

	cout << sum << endl;
}

Measured memory_bytes: 81404
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<cstdio>
#include<complex>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
 
typedef complex<int> P;
 
namespace std{
  bool operator<(const P & a,const P & b){
    if (a.real() != b.real())return a.real() < b.real();
    return a.imag() < b.imag();
  }
}
 
const double eps = 1e-10;
 
inline double myabs(P a){
  return sqrt(a.real()*a.real() + a.imag()*a.imag());
}

inline bool is_point_online(P a,P b,P c){
  return myabs(a-c) + myabs(b-c) < myabs(a-b) + eps;
}
 
inline int dot(P a,P b){
  return a.real()*b.real() + a.imag()*b.imag();
}
 
inline int cross(P a,P b){
  return a.real()*b.imag() - a.imag()*b.real();
}
 
inline bool is_intersected_ls(P a1,P a2,P b1,P b2){
  //if ( is_point_online(a1,a2,b1))return true;
  //if ( is_point_online(a1,a2,b2))return true;
  //if ( is_point_online(b1,b2,a1))return true;
  //if ( is_point_online(b1,b2,a2))return true;
  if (  ( cross(a2-a1,b1-a1) * cross(a2-a1,b2-a1)<-eps ) && //-EPS
    ( cross(b2-b1,a1-b1)*cross(b2-b1,a2-b1)<-eps))return true;
  else return false;
}
 
inline double distance_ls_p(P a,P b,P c){
 if (dot(b-a,c-a) < eps)return myabs(c-a);
 if (dot(a-b,c-b) < eps)return myabs(c-b);
 return abs( cross(b-a,c-a))/myabs(b-a);
}
 
inline double distance_ss_p(P a,P b,P c,P d){
 return min(  min( distance_ls_p(a,b,c),distance_ls_p(a,b,d)),min(distance_ls_p(c,d,a),distance_ls_p(c,d,b)));
}
 
main(){
  int n;
  static int cnt[101][101];
  while(cin>>n){
    rep(i,101)rep(j,101)cnt[i][j] = 0;
    vector<P> a(n),b(n);
    vector<pair<P,P> > all;
    double ans = 1e10;
    rep(i,n){
      int y,x,y2,x2;
      scanf("%d%d",&x,&y);
      cnt[y][x]++;
      a[i] = P(x,y);
      scanf("%d%d",&x2,&y2);
      cnt[y2][x2]++;
      b[i] = P(x2,y2);
    }
    rep(i,101){
      rep(j,101){
	if (cnt[i][j] > 1){ans = 0;goto end;}
      }
    }
    rep(i,n){
      REP(j,i+1,n)if (is_intersected_ls(a[i],b[i],a[j],b[j])){ans = 0;goto end;}
    }
    rep(i,n)all.push_back(make_pair(a[i],b[i]));
    sort(all.begin(),all.end());
    rep(i,all.size()){
      REP(j,i+1,all.size()){
	ans = min(ans,distance_ss_p(all[i].first,all[i].second,all[j].first,all[j].second));
      }
    }
  end:;
    printf("%.10lf\n",ans);
  }
  return 0;
}

Measured memory_bytes: 2392