akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  ll ans=1;
  vector<ll> a(n);
  rep(i,n){
    cin >> a[i];
    if(a[i] ==0){
      cout << 0 << endl;
      return 0;
    }
  }
  
  rep(i,n){
    if(a[i] >1000000000000000000/ans){
      cout << -1 << endl;
      return 0;
    }
    else ans *= a[i];
    
  }
  cout << ans << endl;
}

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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadLineInt();
            var a = ReadLineIntSpilit();

            var g = a.Where(x => x % 2 == 0).ToList();
            var ok = 0;

            foreach (var item in g) {
                if (item % 3 == 0 || item % 5 == 0) { 
                    ok++;
                }
            }

            Console.WriteLine((g.Count() == ok) ? "APPROVED" : "DENIED");
            ReadLine();

        }

        //最大公約数
        static int gcd(int a, int b)
        {
            if (a > b) {
                return gcd(b, a);
            }

            while (b != 0) {
                var remainder = a % b;
                a = b;
                b = remainder;
            }

            return a;
        }

        //最小公倍数
        static int lcm(int a, int b) => a * b / gcd(a, b);

        /// <summary>
        /// コンビネーション
        /// </summary>
        static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        public static string ReadLine() => Console.ReadLine();
        public static int ReadLineInt() => int.Parse(Console.ReadLine());
        public static long ReadLineLongInt() => long.Parse(Console.ReadLine());
        public static string[] ReadLineStringSplit(char a = ' ') => ReadLine().Split(a).ToArray();
        public static int[] ReadLineIntSpilit(char a = ' ') => ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        public static long[] ReadLineLongSpilit(char a = ' ') => ReadLine().Split(a).Select(x => long.Parse(x)).ToArray();
        static string[] GetAplhaLowerArray() => new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
        static string[] GetAplhaUpperArray() => new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    int A,B;cin>>A>>B;
    cout<<max(0,A-2*B)<<endl;

}



Measured memory_bytes: 256
//in the name of <Allah>
#include <bits/stdc++.h>
using namespace std;

const int N = 1 * 100 * 1000 + 1;
int n, sz[N];
vector <int> adj[N];

bool dfs(int u, int par) {
    int odd = 0, res = 0;
    sz[u] = 1;
    for (auto v: adj[u])
        if (v ^ par) {
            res |= dfs(v, u);
            sz[u] += sz[v];
            odd += (sz[v] & 1);
        }
    return (res | (odd > 1));
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 1, u, v; i < n; i++) {
        cin >> u >> v;
        adj[--u].push_back(--v);
        adj[v].push_back(u);
    }   
    if (n & 1 || dfs(0, -1))
        return cout << "First\n", 0;
    cout << "Second\n";
}


Measured memory_bytes: 9624
function Main(input) {
  var tmp = input.split(" ");
  var A = parseInt(tmp[0]);
  var B = parseInt(tmp[1]);
  var H = parseInt(tmp[2]);
  var M = parseInt(tmp[3]);

  var deg = (5.5 * (H * 60 + M)) % 360;
  var cosdeg = Math.cos(deg * (Math.PI / 180));
　
  var result = Math.sqrt(A * A + B * B - 2 * A * B * cosdeg);
  console.log(result);
}

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

Measured memory_bytes: 29748
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n;
    long[] as;

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

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        as = new long[n];
        for (int i = 0; i < n; i++) {
            as[i] = sc.nextInt();
        }
        solve();
    }

    void solve() {
        long count = 0;
        for (int i = 0; i < n; i++) {
            while (as[i] % 2 == 0) {
                as[i] /= 2;
                count++;
            }
        }
        System.out.println(count);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 25300
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    int a, b;
    scan(a, b);

    if (a >= 9 || b >= 9) {
        writeln(":(");
    }
    else {
        writeln("Yay!");
    }
}













































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, y;
    cin >> n >> y;
    ll sum = 0, a = -1, b = -1, c = -1;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            int f = n - i - j;
            if (f >= 0) {
                sum = 10000 * i + 5000 * j + 1000 * f;
                if (sum == y) {
                    a = i; b = j; c = f;
                    break;
                }
            }
        }
    }
    cout << a << ' ' << b << ' ' << c << endl;
}

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;

const int N = 1e5 + 10, INF = 0x3f3f3f3f , MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int f[N][15];
int p[N][15];
int temp[N];

int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    int n;cin>>n;
    for(int i = 0;i < n;i++) {
        for(int j = 0;j < 10;j++) {
            cin>>f[i][j];
        }
    }
    for(int i = 0;i < n;i++) {
        for(int j = 0;j <= 10;j++) {
            cin>>p[i][j];
        }
    }
    ll res = -INF;
    for(int i = 1;i < (1<<10);i++) {
        memset(temp,0,sizeof temp);
        for(int j = 0;j < n;j++) {
            for(int k = 0;k < 10;k++) {
                if(f[j][k] && ((1<<k)&i)) {
                    temp[j]++;
                }
            }
        }
        ll t = 0;
        for(int j = 0;j < n;j++) {
            t += p[j][temp[j]];
        }
        res = max(res,t);
    }
    cout<<res<<endl;
    return 0;
}
















Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

#define pi 3.1415926535


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


void solve(){
	
	double a,b,h,m;
	cin >> a >> b >> h >> m;

	double angh = 2*pi/12.0*(h+(m/60.0));
	// cout << angh << endl;
	double angm = 2*pi/60.0 * (m);
	double theta = abs(angh - angm);
	// cout << theta << endl;
	double c2 = a*a + b*b - 2*a*b*cos(theta);
	c2 = sqrt(c2);
	cout << fixed << setprecision(12) << c2 << endl; 

}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("in","r",stdin);
		freopen("out","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


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

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

#define REPR(i,n) for(int i =n; i >=0; --i)

#define _REP(i,m,n) for(int i =m; i <n; ++i)

#define INF 2e9

using namespace std;

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


    char t = s[0];
    int ans = 1;
    REP(i,n){
        if(t != s[i]){
            t = s[i];
            ans++;

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

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

#define PI 3.1415926535897932384662433832795028841971
#define pb push_back

typedef long long ll;

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

	// https://www.mathsisfun.com/algebra/trig-cosine-law.html
	int A, B, H, M;
	cin >> A >> B >> H >> M;
	
	double c = abs((M / 60.0) * (2 * PI) - ((H + (M / 60.0)) / 12.0) * (2 * PI));
	c = min(c, 2 * PI - c);
	
	double C = sqrt(A * A + B * B - 2 * A * B * cos(c));
	
	cout << fixed;
    cout << setprecision(10);
	cout << C << endl;
    return 0;
}

Measured memory_bytes: 4108
(w, h, n) = map(int, input().split())
(x, y, a) = zip(*[map(int, input().split()) for _ in range(n)])

x_min = 0
x_max = w
y_min = 0
y_max = h

for i in range(n):
    if a[i] == 1:
        x_min = max(x_min, x[i])
    elif a[i] == 2:
        x_max = min(x_max, x[i])
    elif a[i] == 3:
        y_min = max(y_min, y[i])
    else:
        y_max = min(y_max, y[i])

if x_max > x_min:
    x_delta = x_max - x_min
else:
    x_delta = 0
if y_max > y_min:
    y_delta = y_max - y_min
else:
    y_delta = 0
print(x_delta * y_delta)


Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define vll vector<ll>
#define fast ios:: sync_with_stdio(false),cin.tie(0);
#define COUT cout<<fixed<<setprecision(12)
#define SET set<ll,greater<ll>>gquiz
#define ITERATOR set<ll,greater<ll>> :: iterator itr
#define V vector<ll>vector
#define sz size()
#define A vector<pair<ll,ll>>vect
ll N=100000,M=100000;
#define B vect.push_back(make_pair(N,M));
ll MOD=1000000007;
 
ll gcd(ll a,ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main()
{
	ll n;
	cin>>n;
	ll a[n+1];
	for(ll i=0;i<n;i++)
	cin>>a[i];
	
	ll sum=0;
	for(ll i=0;i<n;i++){
		for(ll j=i+1;j<n;j++)
		{
			sum=sum+a[i]*a[j];
		}
	}
	cout<<sum;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

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

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    int N;
    cin >> N;
    int maxDivisibleByTwo = 1;

    while (maxDivisibleByTwo <= N) {
        maxDivisibleByTwo = maxDivisibleByTwo << 1;
    }
    cout << (maxDivisibleByTwo >> 1) << endl;
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <unordered_map>
#include <vector>
#include <set>
#include <string.h>
#include <algorithm>
#define mod 1000000007
#define inf 1LL<<61
#define ll long long
#define pr pair<int,int>
#define all vec.begin(),vec.end()
#define rep(i,a,b) for (int i = a; i < b; i++)
#define fi first
#define se second
#define pushb push_back
#define makep make_pair

using namespace std;

int main(){
	int size;
	cin >> size;
	int arr[size];
	rep(i,0,size)
		cin >> arr[i];
	char mark[8];
	memset(mark,0,sizeof(mark));
	int count = 0;
	rep(i,0,size){
		if(arr[i]/400 <=  7)
			mark[arr[i]/400] = 1;
		else
			count++;

	}
	int cnt = 0;
	rep(i,0,8)
		if(mark[i])
			cnt++;
	if(cnt == 0)
		cout << 1 << " " << cnt + count;
	else
		cout << cnt << " " << cnt + count;
	return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    int N;
    cin >> N;
    set<ll> A;
    vector<ll> IN;
    REP(i,N){
        ll a;
        cin >> a;
        A.insert(a);
        IN.push_back(a);
    }

    map<ll, int> conv;
    int idx = 1;
    for(auto&& a : A){
        conv[a] = idx++;
    }

    int ans = 0;
    REP(i,N){
        int x = conv[IN[i]];
        if((x % 2) != ((i+1) % 2)) ans++;
    }

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


Measured memory_bytes: 12020
#include <stdio.h>
int main(){
  int n,x,i,j,k,count,tmp;
  while(scanf("%d %d",&n,&x),n+x!=0){
    count=tmp=0;
    for(i=1;i<n-1;i++){
      for(j=i+1;j<n;j++){
        for(k=j+1;k<=n;k++){
          if(i+j+k==x) count++;
        }
      }
    }
    printf("%d\n",count);
  }
  return 0;
}


Measured memory_bytes: 2076
n = int(input())
ans = []
for i in range(1,n):
    j = n-i
    si = 0
    sj = 0
    for s in str(i):
        si += int(s)
    for t in str(j):
        sj += int(t)
    ans.append(si+sj)

print(min(ans))


Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n;
  long long int w;
  cin>>n>>w;
  long long int W[n];
  long long int v[n];
  for(long long int i=0;i<n;i++)
  {
    cin>>W[i]>>v[i];
  }
  long long int dp[w+1][n+1];
  for(long long int i=0;i<(w+1);i++)
    dp[i][0]=0;
  for(long long int i=0;i<(n+1);i++)
    dp[0][i]=0;
  for(long long int i=0;i<n;i++)
  {
    for(long long int j=1;j<=w;j++)
    {
      if((j-W[i])>=0)
      dp[j][i+1]=max(dp[j][i],dp[j-W[i]][i]+v[i]);
      else
        dp[j][i+1]=dp[j][i];
    }
  }
  cout<<dp[w][n]<<endl;
  return 0;
}

Measured memory_bytes: 82272
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int an[101][101];
int main(){
    int n,h,w;
    R(h,w,n);
    VI a(n);
    REP(i,n)R(a[i]);
    int k=0;
    REP(i,h)REP(j,w){
        if(i&1){
            an[i][j]=k+1;
        }
        else{
            an[i][w-1-j]=k+1;
        }
        a[k]--;
        if(!a[k])k++;
    }
    REP(i,h)W(VI(an[i],an[i]+w));
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdint>
#include<algorithm>

uint32_t n, a, b, c;

int main() {
  std::cin >> n >> a >> b >> c;
  for(int i = 1; i < n; ++i) {
    uint32_t aa, bb, cc;
    std::cin >> aa >> bb >> cc;
    aa += std::max(b, c);
    bb += std::max(a, c);
    cc += std::max(a, b);
    a = aa; b = bb, c = cc;
  }
  a = std::max(a, b);
  a = std::max(a, c);
  std::cout << a << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 int main()
{
 int m, f, r;
 while(1)
{
 scanf("%d %d %d ", &m, &f, &r);
 if(m==-1&&f==-1&&r==-1)break;
 if(m==-1||f==-1)
{
 printf("F\n");
 }
else if(m+f>=80)
{
 printf("A\n");
 }
else if(m+f>=65)
{
 printf("B\n");
 }
else if(m+f>=50)
{
 printf("C\n");
 }
else if(m+f>=30)
{
 if(r>=50)
{
 printf("C\n");
 }
else
{
 printf("D\n");
 }
 }
else
{
 printf("F\n");
 }
 }
 return 0;
 }
 



Measured memory_bytes: 2108
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 105000;

int n, m;
string v;
int pn;
int ansP, ansAc;
int cnt[MAXN];

int main() { 

  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> pn >> v;
    if (cnt[pn] == -1) {
      continue;
    }
    if (v == "AC") {
      ansP += cnt[pn];
      cnt[pn] = -1;
      ansAc++;
    } else {
      cnt[pn]++;
    }
  }

  cout << ansAc << " " << ansP << endl;

  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.contains("7")) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}
}


Measured memory_bytes: 27012
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int X;
    in(X);

    if (X >= 30)
    {
        outl("Yes");
    }
    else
    {
        outl("No");
    }
    return 0;
}

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

int main() {
  int a, b, c;
  cin >> a;
  
//  cout << "0:" << a << " " << b << endl;
  if (a >= 100) {
//    cout << ":0:" << a << " " << b << endl;
    a += -100;
    b++;
  }
//  cout << "1:" << a << " " << b << endl;
  if (a >= 10) {
    a = a - 10;
    b++;
  }
//  cout << "2:" << a << " " << b << endl;
  if (a > 0) {
    b++;
  }
//  cout << "3:" << a << " " << b << endl;
  cout << b << endl;
}


Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));
$vArray = explode(" ", trim(fgets(STDIN)));


$gcdArray[0] = $vArray[0];
for($i = 1; $i < $n; $i++){
    $gcdArray[$i] = gcd($gcdArray[$i-1], $vArray[$i]);
}
$gcdArray2[$n-1] = $vArray[$n-1];
for($i = $n-2; $i >= 0; $i--){
    $gcdArray2[$i] = gcd($gcdArray2[$i+1], $vArray[$i]);
}
$max = 0;
for($i = -2; $i < $n; $i++){
    $max = max($max, @gcd($gcdArray[$i], $gcdArray2[$i+2]));
}
echo $max;

function gcd($m, $n){
    if(!$n)return $m;
    return gcd($n, $m % $n);
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	int n;
	cin >> n;
	string a, b, c;
	cin >> a >> b >> c;
	int ans = 0;

	rep(i,n){
		if(a[i] == b[i] || b[i] == c[i] || a[i] == c[i]){
			if(a[i] == b[i] && b[i] == c[i]) {
				;
			} else {
				ans += 1;
			}
		} else {
			ans += 2;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
using System;

namespace Aizu1_3_C
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] str = Console.ReadLine().Split(' ');
                int a = int.Parse(str[0]);
                int b = int.Parse(str[1]);
                if (a == 0 && b == 0)
                {
                    break;
                }
                if(a>b)
                {
                    int c = b;
                    b= a;
                    a = c;
                }
                Console.WriteLine("{0} {1}", a, b);
            }
        }
    }
}

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


int main(){
   
    long long N;
    long long A[200009];
    long long ans;
    long long max=0,sec=0,cnt=0;

    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        if(A[i] > max){
            sec = max;
            max = A[i];
            cnt = 0;
            
        }else if(A[i] == max){
            cnt++;
            sec = A[i];
        }else if(A[i] > sec){
            sec = A[i];
        }
    }

    for(int i = 0; i < N; i++){
       if(A[i]==max){
           cout << sec << endl;
       }else{
           cout << max << endl;
       }
    }

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

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

int main()
{int N;
 cin >> N;
 long long C[N];
 long long h=0;
 long long w=0;
 int count =0;
 for(int i=0; i<N; i++){
   cin >> C[i];}
 sort(C, C+N, greater<int>());
 for(int i=0; i<N-1; ++i){
   if(C[i]==C[i+1]){
     if(h==0){
       h=C[i];
     	++i;
     	}
     else{
       w=C[i];
     	break;}}}
 cout << h*w << endl;
      
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
char grid[1000][1000];
int steps[1000][1000];
queue<pair<int,int> > q;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
bool ok(int i,int j){
	return i>=0&&i<n&&j>=0&&j<m;
}
void BFS(int x,int y){
	memset(steps,0x3f,sizeof(steps));
	q.push(make_pair(x,y));
	steps[x][y]=0;
	while(!q.empty()){
		pair<int,int> cur=q.front();
		q.pop();
		for(int i=0;i<4;i++){
			int nx=cur.first+dx[i];
			int ny=cur.second+dy[i];
			if(ok(nx,ny)&&grid[nx][ny]!='#'&&steps[nx][ny]>=1e9){
				steps[nx][ny]=steps[cur.first][cur.second]+1;
				q.push(make_pair(nx,ny));
			}
		}
	}
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>m>>k;
	pair<int,int> stt;
	for(int i=0;i<n;i++)
	{
		scanf("%s",grid[i]);
		for(int j=0;j<m;j++){
			if(grid[i][j]=='S')
				stt=make_pair(i,j);
		}
	}
	BFS(stt.first,stt.second);
	int res=1e9;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(grid[i][j]!='#'&&steps[i][j]<=k){
				int mmin=min(min(i,j),min(n-i-1,m-j-1));
				res=min(res,(mmin+k-1)/k+1);
			}
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>
#include <math.h>
#include <string.h>

int main()
{
  int n;
  double ss, s;
  double average = 0.0;
  double data[1001];

  while( scanf("%d",&n) ) {
    if ( n == 0 ) break;

    for ( int i = 0; i < n; i++ ){
      scanf(" %lf", &data[i] );
      average += data[i];
    }

    average /= n;

    for ( int i = 0; i < n; i++ ){
      ss += (data[i] - average) * (data[i] - average); 
    }

    ss /= n;

    s = sqrt(ss);

    printf( "%10.10lf\n", s );

    average = 0.0;
    ss = 0.0;
    s = 0.0;

  }

  return 0;
}


Measured memory_bytes: 2044
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 1000000007;
const int MOD = 1000000007;

string AIDUNYAN = "AIDUNYAN";
string AIZUNYAN = "AIZUNYAN";

int main(){
    sort(AIDUNYAN.begin(), AIDUNYAN.end());
    string s;
    cin >> s;
    for(int i = 0; i + AIDUNYAN.size() <= s.size(); i++){
        string t = s.substr(i, AIDUNYAN.size());
        sort(t.begin(), t.end());
        if(t == AIDUNYAN){
            s.replace(i, AIZUNYAN.size(), AIZUNYAN);
            i += AIZUNYAN.size() - 1;
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 1212
#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long 
using namespace std;

int main(){
  int N;
  cin>>N;
  int h[N];
  rep(i,N){
    cin>>h[i];
  }
  int block[101];
  rep1(i,101){
    block[i]=0;
    int up=0,down=0;
    rep(j,N-1){
      if( h[j]<i && h[j+1]>=i ){
        up++;
      }else if( h[j]>=i && h[j+1]<i ){
        down++;
      }
    }
    if(up!=down){
      block[i]=max(up,down);
    }else if(h[0]<i){
      block[i]=up;
    }else{
      block[i]=up+1;
    }
  }
  int answer=0;
  rep1(i,101){
    answer+=block[i];
  }
  cout<<answer<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int i,j;
    int flag=0;
    for(i=1;i<=9;i++){
        for(j=1;j<=9;j++){
            int t=i*j;
            if(t==n){
                flag=1;
            }
        }
    }
    if(flag==1)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.sort()
if n % 2 == 0:
  A = sum(a[1::2])
  B = sum(a[::2])
else:
  A = sum(a[::2])
  B = sum(a[1::2])

print(A-B)

Measured memory_bytes: 3060
n=int(input())
s=[int(input()) for i in range(n)]
t=0
ans=sum(s)
s.sort()
if ans%10!=0:
  print(ans)
else:
  for i in s:
    if i%10!=0:
      t=i
      break
  if t!=0:
    print(ans-t)
  else:
    print(0)

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
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;}

int main(){
	int h,w;
	cin >> h >> w;
	vector<vector<char>> a(h,vector<char>(w));
	REP(i,h){
		string s;
		cin >> s;
		REP(j,w){
			a[i][j] = s[j];
		}
	}
	
	vector<bool> hflag(h,true);
	vector<bool> wflag(w,true);
	REP(i,h){
		REP(j,w){
			if(a[i][j] == '#'){
				break;
			}
			if(j==w-1){
				hflag[i] = false;
			}
		}
	}
	REP(j,w){
		REP(i,h){
			if(a[i][j] == '#'){
				break;
			}
			if(i==h-1){
				wflag[j] = false;
			}
		}
	}
	
	REP(i,h){
		REP(j,w){
			if(hflag[i] && wflag[j]){
				cout << a[i][j];
			}
		}
		if(hflag[i]) cout << endl;
	}
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 3600
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int h, w; rd(h, w);
  auto c=new char[][](h, w);
  foreach(i; 0..h) c[i]=readln.chomp.to!(char[]);

  auto dd=[[1, 0], [0, 1], [-1, 0], [0, -1], [1, 1], [1, -1], [-1, 1], [-1, -1]];
  foreach(i; 0..h)foreach(j; 0..w)if(c[i][j]!='#'){
    int cnt=0;
    foreach(d; dd){
      auto ni=i+d[0], nj=j+d[1];
      if(ni<0 || nj<0 || ni>=h || nj>=w) continue;
      if(c[ni][nj]=='#') cnt++;
    }
    c[i][j]=to!char(cnt+'0');
  }

  foreach(i; 0..h) writeln(c[i]);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
using namespace std;

#define ll long long
#define forn(i,n)for(i=0;i<n;i++)
#define forc(i,c,n)for(i=c;i<=n;i++)
typedef list<ll> LST;
typedef vector<ll> VEC;
typedef map<ll, ll> MAP;

int main() {
	ifstream fin("Text.txt");
	int i, j, q;
	ll a, b, c, h,w,e, f, n, t, m, r, d, k, x, y, ans;
	string st;
	cin >> n >> m >> k;
	forc(i, 0, m) {
		forc(j, 0, n) {
			if ((n - j)*i + (m - i)*j == k) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

int main(int argc, char *argv[])
{
    int alpha_counts[26] = {};
    for (char str[1201]; fgets(str, 1201, stdin);)
    {
        for (char *elm = str; *elm; ++elm)
        {
            if (isalpha(*elm))
            {
                ++alpha_counts[tolower(*elm) - 'a'];
            }
        }
    }
    for (int i = 0; i < 26; ++i)
    {
        printf("%c : %d\n", 'a' + i, alpha_counts[i]);
    }
    return 0;
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    ll n;
    cin >> n;
    ll res = INF;
    ll tmp;

    for(ll i = 1; i <= sqrt(n); i++) {
        if(n % i == 0) {
            res = min(res, i + n / i - 2);
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#! /usr/bin/env python

from itertools import product, starmap, dropwhile
from math import log

n = int(input())
m = int(log(n, 3)) + 2
for a in product([-1, 0, 1], repeat=m):
    if n == sum(starmap(lambda t, x: 3 ** t * x, zip(reversed(range(m)), a))):
        print("".join(map(lambda x: "-0+"[x + 1], dropwhile(lambda x: x == 0, a))))
        break




Measured memory_bytes: 5724
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

int lcm(int x,int y){
  return x/__gcd(x,y)*y;
}

int f(int n, int c, int d){
  return n-n/c-n/d+n/lcm(c, d);
}

signed main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  cout << f(B, C, D)-f(A-1, C, D) << endl;

  return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

pll A[100005];
bool V[100005];
bool U[100005];
bool E[100005];

int main()
{
    ll N, K;
    cin >> N >> K;

    ll mv = 0;
    REP(i, N)
    {
        cin >> A[i].first >> A[i].second;
        if (!V[A[i].first])
        {
            mv++;
            V[A[i].first] = true;
        }
    }

    //! 食べられる最大の種類数
    mv = std::min(K, mv);
    ll sum = 0;
    int k = 0; //! 食べた数
    int v = 0; //! 被っているものを食べた数
    sort(A, A + N, [](pll a, pll b) { return a.second > b.second; });
    int l = 0;
    int i = 0;
    while (i < N)
    {
        if (k == K)
            break;
        if (E[i])
        {
            ++i;
            continue;
        }
        if (!U[A[i].first])
        {
            sum += A[i].second;
            U[A[i].first] = true;
            E[i] = true;
            i++;
        }
        else
        {
            if (v + mv + 1 <= K)
            {
                v++;
                sum += A[i].second;
                U[A[i].first] = true;
                E[i] = true;
                i++;
            }
            else
            {
                //! 既に食べた種類の中で一番大きなものを食べるか、食べていない種類の中で一番大きなものを食べるか選ぶ
                bool e = false;
                FOR(j, N, l)
                {
                    if (E[j])
                        continue;
                    if (U[A[j].first])
                        continue;
                    l = j;
                    e = true;
                    break;
                }
                if (!e)
                    l = N;
                //! 種類が減ることによって種類ボーナスは2mv-1減る。
                if (!e || 2 * mv - 1 + A[l].second < A[i].second)
                {
                    //! 被ってるものを食べたほうがいい
                    v++;
                    mv--;
                    sum += A[i].second;
                    U[A[i].first] = true;
                    E[i] = true;
                    i++;
                }
                else
                {
                    //! 被っていないものを食べた方がいい
                    sum += A[l].second;
                    U[A[l].first] = true;
                    E[l] = true;
                }
            }
        }
        ++k;
    }
    cout << sum + mv * mv << endl;
    return 0;
}

Measured memory_bytes: 2048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
	static int cost = 0;
	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = 0;
		//int costA = 0;
		//int costB = 0;
		int tmp = br.read();
		while(tmp != 13 && tmp != 10){
			n = n * 10 + (tmp - '0');
			tmp = br.read();
		}

		int[] array = new int[n];
		int[] sortedArray = new int[n];
		int num = 0;
		int i1 = 0;
		int min = Integer.MAX_VALUE;
		int minIndex = -1;
		tmp = br.read();
		if(tmp == 13 || tmp == 10){
			tmp = br.read();
		}
		while(tmp != -1 && tmp != 10 && tmp != 13){
			num = 0;
			while(tmp >= '0' && tmp <= '9'){
				num = num * 10 + (tmp - '0');
				tmp = br.read();
			}
			if(tmp == -1){
				break;
			}
			array[i1] = num;
			sortedArray[i1] = num;
			if(min > num){
				min = num;
				minIndex = i1;
			}
			i1++;
			tmp = br.read();
		}

		Arrays.sort(sortedArray);
		int[] trueIndex = new int[n];
		for(int i = 0; i < n; i++){
			trueIndex[i] = Arrays.binarySearch(sortedArray, array[i]);
		}

		//??????????????¢???
		boolean[] checked = new boolean[n];
		Arrays.fill(checked, false);

		for(int i = 0; i < n ; i++){
			if(i == trueIndex[i] || checked[i] == true){
				continue;
			}
			ArrayList<Integer> cycle = new ArrayList<Integer>();
			cycle.add(array[i]);
			int j = trueIndex[i];
			while(j != i){
				checked[j] = true;
				cycle.add(array[j]);
				j = trueIndex[j];
			}

			//????????????????°?????????§??????????????????????????????????¨??¨????
			int minInCycle = cycle.get(0);
			int costA = 0;
			int costB = 0;
			for(int k = 0; k < cycle.size(); k++){
				if(minInCycle > cycle.get(k)){
					minInCycle = cycle.get(k);
				}
				costA+=cycle.get(k);
				costB+=cycle.get(k);
			}
			costA += minInCycle*(cycle.size() - 2);
			costB += minInCycle + min*(cycle.size() + 1);

			cost += Math.min(costA, costB);

		}


		//quickSort(array, 0, array.length - 1);

		System.out.println(cost);
		/*
		StringBuilder sb = new StringBuilder(array.length * 5 / 2);
		int outLen = array.length;
		sb.append(array[0]);
		for(int i = 1; i < outLen ; i++){
			sb.append(" "+array[i]);

		}
		System.out.println(sb);
		*/
	}
	/*
	static void quickSort(int[] array, int p, int r){
		if(p < r){
			int q = partition(array, p, r);
			quickSort(array, p, q - 1);
			quickSort(array, q + 1, r);
		}
	}*/
	/*
	static int partition(int[] array, int p, int r){
		int x = array[r];
		int i = p - 1;
		for(int j = p ; j <= r -1 ;j++){
			if(array[j] <= x){
				i++;
				int tmp = array[i];
				array[i] = array[j];
				array[j] = tmp;

			}
		}

		if(true || array[i + 1] != array[r]){
			cost += array[i + 1] + array[r];
			System.out.println("add cost " +array[i + 1]+" " + array[r]);
		}
		int tmp = array[i + 1];
		array[i + 1] = array[r];
		array[r] = tmp;
		return i + 1;
	}
	*/
}

Measured memory_bytes: 24336
#include<iostream>
#include<algorithm>

using namespace std;

const int MAXN = 2005, INF = 1e9;
int d[MAXN], x[MAXN], y[MAXN], w[MAXN];
int n, m, r;

bool bellman_ford(int r)
{
	fill(d, d + n, INF);
	d[r] = 0;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			d[y[j]] = min(d[y[j]], d[x[j]] + w[j]);
	for(int j = 0; j < m; j++)
		if(d[y[j]] > d[x[j]] + w[j] && d[y[j]] < INF / 10)
			return true;
	return false;
}

int main()
{
	cin >> n >> m >> r;
	for(int i = 0; i < m; i++)
		cin >> x[i] >> y[i] >> w[i];
	if(bellman_ford(r))
		cout << "NEGATIVE CYCLE" << endl;
	else
		for(int i = 0; i < n; i++)
			if(d[i] > INF / 10)
				cout << "INF" << endl;
			else
				cout << d[i] << endl;
	return 0;
}

Measured memory_bytes: 1188
n = int(input())
AL = [chr(ord('a') + i) for i in range(26)]

def number_to_alphabet(n):
    N = n-1
    a = ''
    while True:
        d = N % 26
        a = AL[d]+ a
        if N == 0: break
        N = N//26-1
        if N < 0: break
    return a

print(number_to_alphabet(n))


Measured memory_bytes: 61712
import sys
input = sys.stdin.readline
def col(n, m):
    X = [[] for _ in range(n)]
    for _ in range(m):
        a, b = map(int, input().split())
        X[a-1].append(b-1)
        X[b-1].append(a-1)
    C = [-1] * n
    c = 0
    for i in range(N):
        if C[i] >= 0: continue
        Q = [i]
        C[i] = c
        while Q:
            x = Q.pop()
            for y in X[x]:
                if C[y] == -1:
                    C[y] = C[x]
                    Q.append(y)
        c += 1
    return C

N, K, L = map(int, input().split())
A = col(N, K)
B = col(N, L)
D = {}
for a, b in zip(A, B):
    t = (a<<18) + b
    if t in D: D[t] += 1
    else: D[t] = 1

print(*[D[(a<<18)+b] for a, b in zip(A, B)])

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

int main(){

  int h1,h2,m1,m2,k;

  cin >> h1 >> m1 >> h2 >> m2 >> k;

  int sumTime=(h2*60+m2)-(h1*60+m1)-k;
  cout << sumTime << endl;
}

Measured memory_bytes: 3592
#include <stdio.h>

int main(void)
{
	int n,k,x,y;
	
	scanf("%d\n%d\n%d\n%d",&n,&k,&x,&y);
	
	if(n<=k){
		printf("%d\n",n*x);
	}else{
		printf("%d\n",k*x+(n-k)*y);
	}
	
	return 0;
}

Measured memory_bytes: 128
from collections import Counter


n, k, l = map(int, input().split())

def root(x):
    while p[x] >= 0:
        x = p[x]
    return x

def unite(x, y):
    x, y = root(x), root(y)
    if x == y:
        return
    if x > y:
        x, y = y, x
    p[x] += p[y]
    p[y] = x

def g(x):
    global p
    p = [-1]*n
    for _ in range(x):
        a, b = map(int, input().split())
        unite(a-1, b-1)
    return [root(i) for i in range(n)]

z = [*zip(g(k), g(l))]
count = Counter(z)
print(*[count[t] for t in z])


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

int main() {
    int n,flag=0;
    cin>>n;
    while(n) {
        if(n%10==7) {
            flag=1;
            break;
        }
        n=n/10;
    }
    if(flag)
        printf("Yes\n");
    else
        printf("No\n");
}



Measured memory_bytes: 3636
//IncubatorMan
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll mod =(ll)(1e9 +7);
void solve(){
    ll n,k;
    ll ans =0;
    read(n);
    read(k);
    for(ll i=k;k<=(n+1);k++){
            ll x = (k*(k-1))/2;
            ll last = ((n+(n-k+1))*k)/2;
            ll cnt = (last - x +1)%mod;
            ans += cnt;
            ans %= mod;
    }
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
        int test=1;
        //read(test);
        while(test--){
            solve();
        }
    return 0;
}

Measured memory_bytes: 3660