akhauriyash/Code-Regression huggingface dataset:
/*
time:
Author:飞马の幻想
place:lzyz
type:
from:
input:
output:
*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define LL long long
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define per(i, a, b) for(int i = a; i >= b; --i)
#define clr(a,b)  memset((a),b,sizeof(a))
using namespace std;
inline int Read(){
	int s = 0, w = 1; char ch = getchar();
	while(ch < '0' || ch > '9')   { if(ch == '-') w = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9') { s = (s << 3) + (s << 1) + (ch ^ 48); ch = getchar(); }
	return s * w;
}
string s; 
void init() {
	cin >> s;
	int len = s.length();
	int bj = 0;
	rep(i, 0, len - 1) {
		if(s[i] == 'C' && bj == 0) bj++;
		if(bj == 1 && s[i] == 'F') cout << "Yes",exit(0);
	} 
	puts("No");
}
void solve() {

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


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

using LL = int64_t;
const int INF = 0x3f3f3f3f;

int main() {
    LL n;
    cin >> n;
    int ans = INF;
    auto check = [](int k) {
        int ans = 0;
        while (k) {
            ans++;
            k /= 10;
        }
        return ans;
    };
    for (int i = 1; i <= (int)sqrt(n); i++) {
        if (n % i == 0) {
            int j = n / i;
            ans = min(ans, max(check(i), check(j)));
        }
    }
    cout << ans << endl;
} 


Measured memory_bytes: 256
def main():
	x = int(input())
	rest = x
	dev = rest//11
	rest -= (dev)*11
	ans = 2*dev
	if rest > 0:
		if rest > 6:
			ans += 2
		else:
			ans += 1
	print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e16;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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


	ll res = inf;

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

	println(res);

}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ordered_set tree<ll int, null_type,less<ll int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,m,n;
        vi v[100005];
        ll in[100005],h[100005];
        clr(in,0);
        cin>>n>>m;
        for(i=0;i<m;i++)
        {
            cin>>k>>l;
            v[k].pb(l);
            in[l]++;
        }
        queue<ll> q;
        for(i=1;i<=n;i++)
        {
            if(in[i]==0)
            {
                q.push(i);
                h[i]=1;
            }
        }
        while(!q.empty())
        {
            ll x=q.front();
            q.pop();
            for(auto i:v[x])
            {
                in[i]--;
                h[i]=max(h[i],h[x]+1);
                if(in[i]==0)
                    q.push(i);
            }
        }
        ll ans=0;
        for(i=1;i<=n;i++)
            ans=max(ans,h[i]);
        cout<<ans-1;
    }
    return 0;
}

Measured memory_bytes: 7296
import sys
n = int (input())
words = []
No=" "
for i in range (n) :
    words.append(input())
for x in range(len(words)-1):
    if words.count(words[x]) > 1 or words[x+1][0] != words[x][-1]:
        No="No"
        print (No)
        sys.exit() 
if No != "No":
     print ("Yes")

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int a,b,c;
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	int ans=a*10+b+c;
	ans=max(ans,a+b*10+c);
	ans=max(ans,a+c*10+b);
	printf("%d",ans);
}

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

using namespace std;

const int N = 1000 + 77 , Mod = 1000000007;
int dp[N][N] , n , m;
char C[N][N];
int main(){
   //ios::sync_with_stdio(0);cin.tie(0);
   scanf("%d %d" , & n , & m);
   for(int i = 1;i <= n;++ i)
      scanf("%s" , C[i] + 1);
   dp[1][1] = 1;
   for(int i = 1;i <= n;++ i)
      for(int j = 1;j <= m;++ j){
         if(i == 1 && j == 1)
            continue ;
         dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % Mod;
         if(C[i][j] == '#')
            dp[i][j] = 0;
      }
   cout << dp[n][m];
   return 0;
}


Measured memory_bytes: 5504
#include<stdio.h>
int main(void){
    int M,D,c=0;

    scanf("%d %d",&M,&D);

    for (int sar = 1; sar <= M; sar++)
    {
        for (int i = 2; i <= 9; i++)
        {
            for (int j = 2; j <= 9; j++)
            {
                if(i*j==sar && i*10+j<=D) c++;
            }        
        }
    }    
    printf("%d",c);
    return 0;
}

Measured memory_bytes: 128
import std;
const int MAX = 1_000_009;
void main(){
  int n = readln.chomp.to!int;
  int[] as = readln.chomp.split.to!(int[]);
  as.sort();
  
  int[] cnt = new int[](MAX);
  foreach(a; as){
    cnt[a] += 1;
    if(cnt[a] >= 2) continue;
    else for(int b = a * 2; b < MAX; b += a) cnt[b] += 1;
  }
  
  int ans = 0;
  foreach(a; as) if(cnt[a] == 1) ans += 1;
  ans.writeln;
}

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

int bitCount(int bit) {
    if (bit == 0) return 0;
    return bitCount(bit >> 1) + (bit & 1);
}

int main(void) {

    int N;
    int A[16], x[16][16], y[16][16];
    int ans = 0;

    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        for (int j = 1; j <= A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }

    for (unsigned int bit = 0; bit < (1 << N); bit++) {

        bool flag = true;
        for (int i = 1; i <= N; i++) {
            if (!((bit >> (i - 1)) & 1)) continue;
            for (int j = 1; j <= A[i]; j++) {
                if (((bit >> (x[i][j] - 1)) & 1) ^ y[i][j]) flag = false;
            }
        }

        if (flag) ans = max(ans, bitCount(bit));
    }

    cout << ans << endl;

    return 0;
}

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

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

    long long n, m, a, b, ans=0;
    long long h[100001];
    long long good[100001]={0};
    cin >> n >> m;
    for(long long i=1 ; i<=n ; i++){
        cin >> h[i];
    }
    for(long long i=0 ; i<m ; i++){
        cin >> a >> b;
        if(h[a]>h[b]) good[b]=1;
        else if(h[a]<h[b]) good[a]=1;
        else if(h[a]==h[b]){
            good[a]=1;
            good[b]=1;
        }
    }
    for(long long i=1 ; i<=n ; i++){
        if(good[i]==0) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5216
#include <bits/stdc++.h>
using namespace std;
int main(){
 string s;
  cin>>s;
  long long int n=0,k=0;
  for (long long int i; i<s.length();i++){
  if(s[i]=='B'){
  n++;
  }
  else {
  k+=n;
  }}
  cout<<k<<endl;
return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);


//変数
LL N;
int len, ans;
vector<int> num;




//サブ関数
//入力
void input()
{
	cin >> N;
	ans = 0;
}

void make_list(LL N) {
	while (N > 0ll) {
		num.push_back(N % 10ll);
		N /= 10ll;
	}
	reverse(num.begin(), num.end());
	len = num.size();
}

int make_ans(int id) {
	int res = 0;
	if (num[id] == 0)return -1;

	REP(i, id+1) {
		res += num[i];
	}
	res--;
	res += 9 * (len - id - 1);
	//cout << res << endl;
	return res;
}


//計算
void calc()
{
	make_list(N);

	REP(i, len-1) {
		ans = max(ans, make_ans(i));
	}
	
	int cnt = 0;
	while (N > 0) {
		cnt += N % 10;
		N /= 10;
	}
	ans = max(ans, cnt);
}


//出力
void output()
{
		cout << ans << endl;
}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


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

signed main(){
  int N,sum=0;
  cin>>N;
  int NN=N;
  while(NN>0){
    sum+=NN%10;
    NN/=10;
  }
  string ans="No";
  if(N%sum==0)ans="Yes";
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n,m;
	llong k;
	cin>>n>>m>>k;
	
	vector<llong> a(n),b(m);
	REP(i,n) cin>>a[i];
	REP(i,m) cin>>b[i];
	REP(i,n-1) a[i+1]+=a[i];
	REP(i,m-1) b[i+1]+=b[i];
	
	vector<llong> dp(n+1,0);
	REP(i,n+1){
		if(i==0) dp[0]=upper_bound(ALL(b),k)-b.begin();
		else{
			llong kk=k-a[i-1];
			if(kk<0){}
			else dp[i]=i+(upper_bound(ALL(b),kk)-b.begin());
		}
	}
	//line(dp);
	
	llong ans=0;
	REP(i,n+1) ans=max(ans,dp[i]);
	
	cout<<ans<<endl;
}

Measured memory_bytes: 8008
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long LL;
const int maxn=1e6+100;
const double pi=4.0*atan(1.0);
int n,m,k,q;
int T;
string str;
int main()
{
    int A,B,H,M;
    scanf("%d%d%d%d",&H,&M,&A,&B);
    int s=A*3600+B*60;
    int s1=s%(12*3600);
    int s2=s%(3600);
    double d1=s1*1.0/(12*3600)*360;
    double d2=s2*1.0/(3600)*360;
    double d3=abs(d1-d2);
    if(d3>180)
        d3=360-d3;
    double res=H*H+M*M-2*H*M*cos(d3/180.0*pi);
    printf("%.9f\n",sqrt(res));
}

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

int main(){
    int n; string s; cin >> n >> s;
    int wcnt = 0, bcnt = 0, ans = INT_MAX;
    vector<pair<int, int>> cnt(n + 1); cnt[0] = {0, 0};
    for (auto i = 0; i < n; i++) {
        if(s[i] == '.') wcnt++;
        else bcnt++;
        cnt[i + 1] = {wcnt, bcnt};
    }
    if(n == wcnt or n == bcnt) {
        cout << 0 << endl; return 0;
    }
    for (auto i = 0; i <= n; i++) {
        ans = min(ans, cnt[i].second + (cnt[n].first - cnt[i].first));
//        cout << ans << " " << cnt[i].second << " " << cnt[i].first << " " << cnt[n].first << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5236
#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
void A()
{
    // 入力
    string N;
    cin >> N;
    
    // 出力
    if( N.find("7") != string::npos )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
 
void B()
{
    // 入力
    int N;
    cin >> N;
    
    long long int ans = 0;
    
    // "Fizz", "Buzz", "FizzBuzz"のいずれでもない場合を合算する
    for( int i = 1; i < N+1; ++i )
        if( (i % 3 != 0) && (i % 5 != 0) )
            ans += i;
    
    // 出力
    cout << ans << endl;
}
 
long long int gcd(long long int a, long long int b)
{
    long long int ret;
     
    if( a < b ){
        long long int tmp = a;
        a = b;
        b = tmp;
    }
     
    if( b == 0 ) return a;
     
    ret = a % b;
    ret = gcd(b, ret);
     
    return ret;
}
 
void C()
{
    // 入力
    int K;
    cin >> K;
    
    int ans = 0;
    
    // 2重GCDで解ける
    for( int a = 1; a < K+1; ++a )
        for( int b = 1; b < K+1; ++b )
            for( int c = 1; c < K+1; ++c )
                ans += gcd(gcd(a, b), c);
    
    // 出力
    cout << ans << endl;
}
 
void D()
{
    // 入力
    int N;
    string S;
    cin >> N >> S;
    
    // SをR, G, Bに分割する
    // int型だとansに代入する際に桁漏れする
    //long long int R = 0, G = 0, B = 0;
    int R = 0, G = 0, B = 0;
    for( int i = 0; i < N; ++i )
        switch( S[i] ){
            case 'R': ++R; break;
            case 'G': ++G; break;
            case 'B': ++B; break;
        }
    
    // {R, G, B}の組合せの数
    // 必ずR, G, Bそれぞれひとつずつの組合せになるが、i < j < k順に並びかえればいいので、それぞれの個数をかけた値になる
    long long int ans = (long long int)R * G * B;
    
    // (j − i) == (k − j)の組合せの数を引く
    // i, jが決まればkを求められる
    for( int i = 1; i < N+1; ++i )
        for( int j = i+1; j < N+1; ++j ){
            int k = 2*j - i;
            if( k < j || N < k ) continue;
            if( S[i-1] != S[j-1] && S[j-1] != S[k-1] && S[k-1] != S[i-1] )
                --ans;
        }
    
    // 出力
    cout << ans << endl;   
}
 
int main()
{
    //A();
    //B();
    //C();
    D();
    
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N + 2, 0);
    ll now = 0, sum = 0;
    rep(1, i, N + 1)
    {
        cin >> A.at(i);
    }

    rep(0, i, N + 2)
    {
        sum += abs(now - A.at(i));
        now = A.at(i);
    }

    rep(1, i, N + 1)
    {
        ll res = sum;
        res -= abs(A.at(i) - A.at(i - 1));
        res -= abs(A.at(i) - A.at(i + 1));
        res += abs(A.at(i - 1) - A.at(i + 1));
        cout << res << endl;
    }
}

Measured memory_bytes: 4020
#include <climits>
#include <cmath>
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
#include <tuple>
using namespace std;
int main(int, char**)
{
	long N;
	cin >> N;
	vector<long> A(N), B(N);
	for (long i = 0; i < N; ++i)
	{
		cin >> A[i];
		B[i] = A[i];
	}
	sort(B.begin(), B.end(), [](long l, long r) { return l > r; });
	for (long i = 0; i < N; ++i)
	{
		if (A[i] == B[0])
		{
			cout << B[1] << endl;
		}
		else
		{
			cout << B[0] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4736
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    long a;
    long b;
    long x;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.a = sc.nextLong();
        this.b = sc.nextLong();
        this.x = sc.nextLong();
    }
    
    //解答処理
    private long solve() {
    	long answer = 0;
        long A = a / x;
        long B = b / x;
        if (a % x == 0) { //aも条件を満たすとき
        	answer = B - A + 1;
        } else {
        	answer = B - A;
        }
        return answer;
    }
    
    //出力
    public void show(long answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 35656
#include <stdio.h>

int nth_decimal_places(int a, int b, int n)
{
	if (!n){
		return (0);
	}
	return ((a * 10) / b + nth_decimal_places(a * 10 % b, b, n - 1));
}

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

	while (~scanf("%d %d %d", &a, &b, &n)){
		printf("%d\n", nth_decimal_places(a % b, b, n));
	}

	return (0);
}

Measured memory_bytes: 596
n = int(input())
a = [int(x) for x in input().split()]

deta = [0] * (n+1)

for i in a:
    deta[i] += 1

ans = [0] * (n+1)

for j in range(n+1):
    if deta[j] > 1:
        ans[j] = deta[j]*(deta[j]-1)/2
    else :
        ans[j] = 0

add = sum(ans)

for k in a:
    print(int(add - deta[k]*(deta[k]-1)/2 + (deta[k]-1)*(deta[k]-2)/2))


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  vector<ll> A(3 * N);
  for (int i = 0; i < 3 * N; ++i) {
    scanf("%lld", &A[i]);
  }

  ll S = accumulate(A.begin(), A.begin() + N, 0LL);
  vector<ll> S1(N + 5);
  S1[0] = S;
  priority_queue<ll, vector<ll>, greater<ll>> que1(A.begin(), A.begin() + N);
  for (int i = N; i < 2 * N; ++i) {
    que1.push(A[i]);
    ll val = que1.top(); que1.pop();
    S += (A[i] - val);
    S1[i - N + 1] = S;
  }

  S = accumulate(A.begin() + 2 * N, A.end(), 0LL);
  vector<ll> S2(N + 5);
  priority_queue<ll> que2(A.begin() + 2 * N, A.end());
  S2[0] = S;
  for (int i = 1; i <= N; ++i) {
    que2.push(A[2 * N - i]);
    ll val = que2.top(); que2.pop();
    S += (A[2 * N - i] - val);
    S2[i] = S;
  }

  ll ans = -LLINF;
  for (int i = 0; i <= N; ++i) {
    ans = max(ans, S1[i] - S2[N - i]);
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 6516
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
    ll n,m;
    cin>>n>>m;
    if(n>=2&&m>=2){
    cout<<nCr(n,2)+nCr(m,2)<<endl;
    }else if(n>=2){
        cout<<nCr(n,2)<<endl;
    }else if(m>=2){
        cout<<nCr(m,2)<<endl;
    }else{
        cout<<0<<endl;
    }
}



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

int main() {

	string s; cin >> s;
	int a = 0;
	int b = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0') a++;
		if (s[i] == '1') b++;
	}
	cout << 2 * min(a, b) << endl;
	return 0;
}


Measured memory_bytes: 3764
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 300010

/* Rolling Hash */
// n = 9973, 10007, 10000019, 9999991

struct RollingHash{
  int N, base;
  vector<ll> hash, pow;

  template <typename Type>
  RollingHash(int base, int n, Type *arr):
    N(n), base(base), hash(n+1), pow(n+1)
  {
    hash[0] = 0;
    pow[0] = 1;
    for(int i=0; i<N; i++){
      hash[i+1] = (hash[i] + arr[i]) * base % mod;
      pow[i+1] = pow[i] * base % mod;
    }
  }

  // get [l,r)
  ll getHash(int l, int r) {
    return (mod + hash[r] - hash[l] * pow[r-l] % mod) % mod;
  }
};

int main(){
  int N, M;
  char s[SIZE];
  int l = 0, r = 1;

  scanf("%d%d%s", &N, &M, s);

  RollingHash hash1(10000019, N, s), hash2(9999991, N, s);

  set<ll> ss;

  for (int i=0; i<M; i++) {
    string str;
    cin >> str;
    if (str == "R++") r++;
    if (str == "R--") r--;
    if (str == "L++") l++;
    if (str == "L--") l--;

    ss.insert(((ll)hash1.getHash(l, r) << 32) + hash2.getHash(l, r));
  }

  cout << ss.size() << endl;

  return 0;
}



Measured memory_bytes: 26612
def main():
    n=int(input())
    A=list(zip(list(map(int,input().split())),range(n)))
    A.sort(reverse=True)
    DP=[[0]*(n+1) for _ in range(n+1)]
    for i in range(n+1):
        for j in range(n+1):
            if i+j>n:
                break
            a,idx=A[i+j-1]
            if i>0:
                DP[i][j]=max(DP[i][j],DP[i-1][j]+a*abs(idx-(i-1)))
            if j>0:
                DP[i][j]=max(DP[i][j],DP[i][j-1]+a*abs(idx-(n-j)))
    ans=0
    for i in range(n+1):
        ans=max(ans,DP[i][n-i])
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 105728
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

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

int main() {
  int N, neg=0, pos=0;// neg; 負のAiの個数 ,pos 正の．
  cin >> N;
  vector<int> A(N);
  rep(i, N) {
      cin >> A[i];
      if(A[i]<0) neg++;
      else if(A[i]>0) pos++;
  }
  sort(A.begin(), A.end());

  vector<int> x(N-1), y(N-1);
  int start = 0;
  int tmp = 0;

  if(neg==N) { // 全て負の時
    x[0] = A[N-1]; 
    y[0] = A[N-2];
    tmp = x[0] - y[0];
    for(int i=1; i<N-1; i++) {
        x[i] = tmp;
        y[i] = A[N-i-2];
        tmp = x[i] - y[i];
    }
  } else if(pos==N) { // 全て正の時
    x[0] = A[0];
    y[0] = A[1];
    tmp = x[0] - y[0];
  
    for(int i=1; i<N-2; i++){ // small - big
      x[i] = tmp;
      y[i] = A[i+1];
      tmp = x[i] - y[i];
    }
    // 最後の一回は A[N-1] - tmp
    x[N-2] = A[N-1];
    y[N-2] = tmp;
    tmp = x[N-2] - y[N-2];
  }
  else { // 正，負がともにN個未満
    // 負の数字が1個になるまでA[N-1]から 0以下の数字を引く
    // 負の数字が0個のとき，正の数字がN個未満なので，0が1個以上のこる．
    int i = 0;
    for(; i<neg-1; i++) {
      x[i] = A[N-1];
      y[i] = A[i];
      A[N-1] = x[i] - y[i];
    } 
    tmp = A[i];
    if(i<N-2) {
      x[i] = A[i];
      y[i] = A[i+1];
      tmp = x[i] - y[i];
      i++;
      for(; i<N-2; i++) {
        x[i] = tmp;
        y[i] = A[i+1];
        tmp = x[i] - y[i];
      }
    }
    // 最後の1回は  A[N-1] - tmp
    x[N-2] = A[N-1];
    y[N-2] = tmp;
    tmp = x[N-2] - y[N-2];
  }
  
  cout << tmp << endl; // tmp = M 
  rep(i, N-1) {
      cout << x[i] << ' ' << y[i] << endl;
  }

  return 0;
}


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

int  main()
{
	// ifstream in("in/02-random-00.txt");
	// cin.rdbuf(in.rdbuf());
	int n,m;
	cin >> n >> m;
	int s[m],c[m];
	vector<set<int> > st(n+1);
	int ans = 0;
	st[0].insert(-1);
	rep(i, m)
	{
		cin >> s[i] >> c[i];
		st[s[i]].insert(c[i]);
		if (st[s[i]].size() > 1)
			ans = -1;
		if (n != 1 && s[i] == 1 && c[i] == 0)
			ans = -1;
	}
	if (ans == -1)
	{
		cout << -1 << endl;
		return 0;
	}
	int sum = 0;
	for(int i = 1;i <= n ; i++)
	{
		if (!st[i].empty())
		{
			rep(j, 10)
			{
				if (st[i].count(j))
				{
					cout << j;
					break;
				}
			}
		}
		else
		{
			if (i == 1 && n != 1)
			{
				cout << 1;
			}
			else
			{
				cout << 0;
			}
		}
	}
	// cout << sum << endl;
	return (0);
}

Measured memory_bytes: 256
import sys
from collections import defaultdict
from math import gcd

mod = 1000000007
N = int(input())

def reduce(vec):
	vec = list(vec)
	if vec[0]==0:
		if vec[1] == 0:
			return (0,0)
		else:
			return (0,1)
	elif vec[1] == 0:
		return (1,0)
	else:
		if vec[0]<0:
			vec[0] = -vec[0]
			vec[1] = -vec[1]
		d = gcd(vec[0],vec[1])
		return (vec[0]//d, vec[1]//d)

counter0 = defaultdict(int)
counter1 = defaultdict(int)
origin = 0

for i in range(N):
	a,b = map(int, input().split())
	if a==0 and b==0:
		origin += 1
		continue
	a,b = reduce((a,b))
	if b>0:
		counter0[(a,b)] += 1
	else:
		counter0[(-b,a)] += 0
		counter1[(-b,a)] += 1

ans = origin
k = 1
for key, cnt0 in counter0.items():
	cnt1 = counter1[key]
	tmp = (pow(2, cnt0, mod) + pow(2, cnt1, mod) - 1)% mod
	k = (k*tmp) % mod

ans = ans + k-1
ans %= mod
print(ans)



Measured memory_bytes: 72100
#include<iostream>
#include<string>
using namespace std;
int main(){
  int h,at=0,bt=0,ot=0,abt=0;
  char c;
  string b;
  while(cin>>h>>c>>b){
    if(b=="A") at++;
    if(b=="B") bt++;
    if(b=="O") ot++;
    if(b=="AB") abt++;
  }
    cout << at << endl << bt << endl << abt << endl << ot << endl;
  return 0;
}   

Measured memory_bytes: 1204
def findSumOfDigits(n):
	sum = 0
	while n > 0:
		sum += n % 10
		n //= 10
	return sum

def main():
	n, a, b = list(map(int, input().split()))

	total = 0
	for i in range(1, n+1):
		sum = findSumOfDigits(i)
		if sum >= a and b >= sum:
			total += i

	print(total)

if __name__ == '__main__':
	main()


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    ll N, T; cin >> N >> T;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    ll mi = INF;
    map<ll, ll> m;
    rep(i, N){
        mi = min(mi, a[i]);
        m[a[i]-mi]++;
    }
    ll res = 0;
    for(auto p: m){
        res = p.second;
    }
    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

using namespace std;

int a,b,k;

int main()
{
    cin>>k>>a>>b;
    int x=a/k;
    if (x*k<a) x++;
    if (x*k<=b) cout<<"OK";
    else cout<<"NG";
    return 0;
}


Measured memory_bytes: 3636
package main

// Solution for https://atcoder.jp/contests/abc070/tasks/abc070_c

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b > 0 {
		a, b = b, a%b
	}
	return a
}

func (con *contest) main() error {
	var n int
	con.Scan(&n)
	t := make([]int, n)
	for i := 0; i < n; i++ {
		con.Scan(&t[i])
	}
	x := t[0]
	for i := 1; i < n; i++ {
		x = x / gcd(x, t[i])
		x *= t[i]

	}
	con.Println(x)
	return nil
}


Measured memory_bytes: 1848
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define MOD 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int p = 0; string s;
	cin >> s;
	for (int i = 0; i < s.length(); ++i)
	{
		if (s[i] == '+')
			++p;
		else
			--p;
	}
	cout << p;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int x,a,b;
    scanf("%d%d%d", &x, &a, &b);
    int xa, xb;
    if(x>a){
        xa= x-a;
    }else (xa= a-x);
    if(x>b){
        xb= x-b;
    }else(xb=b-x);
    if(xa>xb){
        printf("B\n");
    }else printf("A\n");
    return 0;
}

Measured memory_bytes: 1648
/*********************
*@Author:   CKang *
*@Language: C++11    *
*********************/
#include<bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
//#define DEBUG
#define RI register int
#define endl "\n"

using namespace std;

typedef long long ll;
//typedef __int128 lll;
//const int N=100000+10;
const int M=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-9;
const int INF = 0x3fffffff;
const ll LINF = 0x3fffffffffffffff;

inline ll read(){
    long long 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<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
int sumn[105]={0},sumk[105]={0};
void init(){
    for(int i=0;i<105;i++)
        sumn[i]=sumk[i]=0;
    return ;
}
void solve(){
    init();
    int d,n=read(),k=read(),ans=0;
    while(k--){
        d=read();
        while(d--)
            sumn[read()]++;
    }
    for(int i=1;i<=n;i++)
        if(sumn[i]==0)ans++;
    cout<<ans<<endl;
    return ;
}

int main()
{
#ifdef DEBUG
    freopen("input.in", "r", stdin);
    //freopen("output.out", "w", stdout)
#endif
    //cout.tie(0);
    //for(ll t=read();t;t--)
        solve();
#ifdef DEBUG
    printf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
#endif
    //cout << "Fuck You !" << endl;
    return 0;
}


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

int main() {
  ll n,k;cin>>n>>k;
  ll a=n%k;
  ll ans=min(a,k-a);
  cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
	int N;
    string S, T;
    cin >> N >> S;

    if(N % 2 != 0) {
        cout << "No" << endl;
    } else {
        string sub = S.substr(0, N / 2);
        T = sub + sub;
        if(S == T) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

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

// #include <string>
using namespace std;

using ll = long long; // int64
const int mod = 1e9 + 7;

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int cnt[2020] = {0};
    cnt[0] = 1; // 2019で割り切れる数ならば それ自体が答えになる.
    int d = 1;
    int ans = 0;
    int acc = 0;
    int m = 0;

    for (int i = n-1; i >= 0; i--) {
        m = s[i] - '0';
        acc = (d*m + acc) % 2019;
        ans += cnt[acc];
        cnt[acc]++;
        d = (d * 10) % 2019;
    }

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

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

using namespace std;

int main(void)
{
	int r;

	cin>>r;

	if(r<1200) cout<<"ABC"<<endl;
	else if(1200<=r&&r<2800) cout<<"ARC"<<endl;
	else if(2800<=r) cout<<"AGC"<<endl;

	return 0;
}


Measured memory_bytes: 256
/*
Aldew
PROB: Save Konoha
CLASSIFICATION: Priority Queue
DIFFICULTY:
*/

#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <cmath>
#include <string>
#include <map>
#include <math.h>
#include <cstdio>
#include <stack>
#define check(x) cout<<(#x)<<": "<<x<<" ";
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


typedef long long ll;
typedef unsigned long long ull;

using namespace std;

//void io()
//{
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    #endif
//}

vector <int> factors(int x) {
    vector <int> result;
    int i = 1;
    while(i*i <= x) {
        if(x % i == 0) {
            result.push_back(i);
            if(x/i != i) {
                result.push_back(x/i);
            }
        }
        i++;
    }
    return result;
}

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

    ll it;
    ll s = 0;

    map<int, int> m;
    for (int i = 0; i < n; i++){
        cin >> it;
        s += it;
        m[it] ++;
    }

    ll q;
    cin >> q;

    ll b, c;
    while (q--){
        cin >> b >> c;

        //cout << "here" << m[b] << endl;
        s -= (b * m[b]);
        s += (c * m[b]);

        m[c] += m[b];
        m[b] = 0;

        cout << s << endl;
    }

    return 0;
}


Measured memory_bytes: 7956
#include<iostream>
#include<vector>
#include<queue>
#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 a,b,c,d;
  cin >> a >> b >> c >> d;

  while(true) {
    c = c - b;
    a = a - d;
    if ( c <= 0 ) {
      cout << "Yes" << endl;
      return 0;
    }
    if ( a <= 0 ) {
      cout << "No" << endl;
      return 0;
    }
  }

  
}


Measured memory_bytes: 3096
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// 中間試験m点、期末試験f点、再試験r点の入力準備
		Scanner sc = new Scanner(System.in);
		int m;
		int f;
		int r;
		// 成績を入れる配列をつくる
		ArrayList<String> list = new ArrayList<String>();

		// 入力値によって成績を判定
		while (true) {
			// 中間試験m点、期末試験f点、再試験r点の数値を取得
			m = sc.nextInt();
			f = sc.nextInt();
			r = sc.nextInt();

			// 中間試験と期末試験のいずれかを欠席した場合→F
			if ((m == -1 || f == -1) && (!(m == -1 && f == -1 && r == -1))) {
				list.add("F");

				// 中間試験と期末試験の合計が80点以上だった場合→A
			} else if ((m + f) >= 80) {
				list.add("A");

				// 中間試験と期末試験の合計が65点以上80点未満だった場合→B
			} else if ((65 <= (m + f)) && ((m + f) < 80)) {
				list.add("B");

				// 中間試験と期末試験の合計が50点以上65点未満だった場合→C
			} else if ((50 <= (m + f)) && ((m + f) < 65)) {
				list.add("C");

				// 中間試験と期末試験の合計が30点以上50点未満だった場合→D
				// ただし、再試験の点数が50点以上ならば成績はC
			} else if ((30 <= (m + f)) && ((m + f) < 50) && (!(r >= 50))) {
				list.add("D");
			} else if ((30 <= (m + f)) && ((m + f) < 50) && (r >= 50)) {
				list.add("C");

				// 中間試験と期末試験の合計点数が30点未満だった場合→F
			} else if (((m + f) < 30) && (!(m == -1 && f == -1 && r == -1))) {
				list.add("F");
			} else {
			}

			// 入力終了
			if (m == -1 && f == -1 && r == -1) {
				break;
			}
		}

		// 成績を表示する
		for (String grade : list) {
			System.out.println(grade);
		}
	}
}



Measured memory_bytes: 26400
#include <bits/stdc++.h>
using namespace std;
     
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
     
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;
int main()
{
    int x,y,z;
    cin>>x>>y>>z;
    int a=x-z,b=y+z;
    cout<<a/b<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  ll a, b; cin >> a >> b;
  ll x = 0;
  FOR(i, 2, n) {
    ll ai; cin >> ai;
    x ^= ai;
  }
  ll a_and_b = a + b - x;
  if (a_and_b < 0 || (a_and_b & 1)) {
    cout << "-1\n";
    return 0;
  }
  a_and_b >>= 1;
  if ((a ^ b) == x) {
    cout << "0\n";
    return 0;
  }
  // cout << a_and_b << endl;
  const int X = 42;
  vector dp(X, vector(2, vector(2, LINF)));
  vector prev(X, vector(2, vector(2, make_pair(-1, -1))));
  dp[0][false][false] = 0;
  REP(i, X - 1) {
    int digit = (a + b) >> i & 1, b_d = b >> i & 1;
    // cout << i << " : " << digit << ' ' << b_d << '\n';
    ll wei = 1LL << i;
    REP(j, 2) REP(k, 2) {
      if (a_and_b >> i & 1) {
        if (j == digit) {
          ll nx = dp[i][j][k] + wei;
          if (nx < dp[i + 1][true][k | !b_d]) {
            dp[i + 1][true][k | !b_d] = nx;
            prev[i + 1][true][k | !b_d] = {j, k};
          }
        }
        continue;
      }
      if (digit ^ j) {
        // (1, 0)
        ll nx = dp[i][j][k];
        if (nx < dp[i + 1][j][k & !b_d]) {
          dp[i + 1][j][k & !b_d] = nx;
          prev[i + 1][j][k & !b_d] = {j, k};
        }
        // (0, 1)
        nx = dp[i][j][k] + wei;
        if (nx < dp[i + 1][j][k | !b_d]) {
          dp[i + 1][j][k | !b_d] = nx;
          prev[i + 1][j][k | !b_d] = {j, k};
        }
      } else {
        // (0, 0)
        ll nx = dp[i][j][k];
        if (nx < dp[i + 1][false][k & !b_d]) {
          dp[i + 1][false][k & !b_d] = nx;
          prev[i + 1][false][k & !b_d] = {j, k};
        }
      }
    }
  }
  if (dp[X - 1][false][true] >= a + b) {
    cout << "-1\n";
    return 0;
  }
  ll ans_b = 0;
  int j = false, k = true;
  for (int i = X - 2; i >= 0; --i) {
    auto [nx_j, nx_k] = prev[i + 1][j][k];
    if (dp[i + 1][j][k] > dp[i][nx_j][nx_k]) ans_b |= 1LL << i;
    j = nx_j;
    k = nx_k;
    // cout << j << ' ' << k << endl;
  }
  // assert(((a + b - ans_b) ^ ans_b) == x && b < ans_b && ans_b < a + b);
  cout << ans_b - b << '\n';
  return 0;
}


Measured memory_bytes: 3624
def main():
    N = int(input())
    a = list(map(int, input().split()))
    next = 1
    b = 0
    for i in range(N):
        if a[i] == next:
            b += 1
            next += 1
    if b == 0:
        print(-1)
    else:
        print(N - b)
main()


Measured memory_bytes: 24744
//38
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int N;
  cin>>N;
  while(N--){
    int h=0,l=0;
    bool fail=false;
    for(int i=0;i<10;i++){
      int n;
      cin>>n;
      if(h<n){
	h=n;
      }else if(l<n){
	l=n;
	if(h<l){
	  swap(h,l);
	}
      }else{
	fail=true;
      }
    }
    cout<<((fail)?"NO":"YES")<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	int N, K, X, Y, sum;
	cin >> N >> K >> X >> Y;
	if(N <= K){
		cout << N * X << endl;
	}
	else{
		cout << K * X + (N - K) * Y << endl; 
	}
}

Measured memory_bytes: 256
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

A, B, H, M = rl()


h = H + M/60
t1 = math.pi/6 * h - math.pi/2
x1, y1 = A*math.cos(t1), A*math.sin(t1)

t2 = math.pi/30 * M - math.pi/2
x2, y2 = B*math.cos(t2), B*math.sin(t2)

d = math.sqrt((x1-x2)**2 + (y1-y2)**2)
print(d)


Measured memory_bytes: 62520
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
int main(void) {
    int N,K,R,S,P;
    string T;

    cin >> N >> K >> R >> S >> P;
    cin >> T;
    int dp[100100][3];
    int value[3] = {R,S,P};
    int t[N];
    //0:R,1;S,2:Pとする
    //勝てる手リストを作る
    rep(i,N){
        if(T[i] == 'r') t[i]=2;
        if(T[i] == 's') t[i]=0;
        if(T[i] == 'p') t[i]=1;
    }
    
    //modKで分割して考える
    rep(i,K){
        //グループのスタート、0から始まる、1から始まる,.....,K-1から始まる
        dp[i][t[i]] = value[t[i]];//グループごとの初期値、分割したので最初は何の制限もないので買っておいて損はない
        for (int j = i+K; j < N; j+=K){
        //ここはグループごと
        //modKで分割したのでK個ごとに更新
            rep(l,3){
                if(t[j] == l){//もしkが勝てる手だったら
                    //K個とびの更新なので注意,ここで(l+1)%3、(l+2)%3としてK個前と同じ手は出さないという制約を守っている
                    dp[j][l] = max(dp[j-K][(l+1)%3],dp[j-K][(l+2)%3])+value[l];
                }else{
                    dp[j][l] = max(dp[j-K][(l+1)%3],dp[j-K][(l+2)%3]);
                }
            }
        }
        
    }
    int ans = 0;
    rrep(i,K){
        ans += max(dp[N-i][0],max(dp[N-i][1],dp[N-i][2]));
    }
    fin(ans);
}

Measured memory_bytes: 2048