akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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 INF = 1e10;
typedef pair<ll,ll> P;

int main(){
    string s;
    cin >> s;
    s += ".";
    vector<ll> a;
    ll c = 1;
    ll l = 0;
    rep(i,s.length()-1){
        if (s[i] == s[i+1]){
            c++;
        }
        else{
            a.push_back(c);
            c = 1;
            l++;
        }
    }
    ll m,n;
    ll ans = 0;
    if (s[0] == '<'){
        rep(i,l/2){
            m = max(a[2*i],a[2*i+1]);
            n = min(a[2*i],a[2*i+1])-1;
            ans += m*(m+1)/2+n*(n+1)/2;
        }
        if (l%2) ans += a[l-1]*(a[l-1]+1)/2;
    }
    else{
        ans += a[0]*(a[0]+1)/2;
        rep(i,(l-1)/2){
            m = max(a[2*i+1],a[2*i+2]);
            n = min(a[2*i+1],a[2*i+2])-1;
            ans += m*(m+1)/2+n*(n+1)/2;
        }
        if (l%2 == 0) ans += a[l-1]*(a[l-1]+1)/2;
    }
    PRINT(ans);
}


Measured memory_bytes: 3068
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>


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


map<string, int> mp;

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    int d = 0, e = 0, f = 0;
    char ans = 'a';
    for (int i = 0; i<a.size() + b.size() + c.size(); i++) {
        if (ans == 'a') {
            ans = a[d];
            if (d == a.size()) {
                cout << 'A' << endl;
                return 0;
            }
            d++;
        }
        if (ans == 'b') {
            ans = b[e];
            if (e == b.size()) {
                cout << 'B' << endl;
                return 0;
            }
            e++;
        }
        if (ans == 'c') {
            ans = c[f];
            if (f == c.size()) {
                cout << 'C' << endl;
                return 0;
            }
            f++;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

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

    long long N, A[5], B[5];
    cin >> N;
    cin >> A[0];
    cin >> A[1];
    cin >> A[2];
    cin >> A[3];
    cin >> A[4];

    long long max_count = -1;
    for (int i = 0; i < 5; ++i)
    {
        B[i] = N / A[i];
        if (N % A[i] != 0)
            ++B[i];
        if (max_count < B[i])
        {
            max_count = B[i];
        }
        else
        {
            B[i] = max_count;
        }
        B[i] += i;
    }

    long long result = B[0];
    for (int i = 1; i < 5; ++i)
    {
        result += (B[i] - B[i - 1]);
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
    var line = chunk.toString().split('\n');
    var S = Number(line[0]);
    var h = Math.floor(S/3600);
    var m = Math.floor(S%3600/60);
    var s = S%60
    console.log(h + ":" + m + ":" + s);
});

Measured memory_bytes: 15564
#include<bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <limits>
#include <iostream>
#include <assert.h>

#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	int x,y,cost;
};
int d[100001]={};
int main(){

	int x;
	cin>>x;

	d[100]=1;
	d[101]=1;
	d[102]=1;
	d[103]=1;
	d[104]=1;
	d[105]=1;

	for(int i=200; i<x+1; i++){
		for(int j=100; j<106; j++){
			if(d[i-j]==1)d[i]=1;
		}
	}
	if(d[x]==1)cout<<"1"<<endl;
	else cout<<"0"<<endl;
	return 0;

}



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

using namespace std;

#define Rep(i,a,b)  for (int i=(a);i<(b);i++)
#define rep(i,n)    for (int i=0;i<(n);i++)
#define all(x)      (x).begin(), (x).end()

#define ll long long

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

	auto S = [](int n) {
		string s = to_string(n);
		int ret = 0;
		rep (i, s.length()) {
			char c = s[i];
			int a = atoi(&c);
			ret += a;
		}
		return ret;
	};

	if (n % S(n) == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;


}



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

int main()
{
    string s; int x=0,y=0;
    cin>>s;
    for(int i=0;s[i]!='\0';i++)
    {
        if(s[i]=='A')
            x++;
        else
            y++;
    }
    if(x!=0 && y!=0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int k;
  cin >> k;
  ll sum = 0;
  rep2(i, 1, k+1){
    rep2(j, 1, k+1){
      int g = __gcd(i, j);
      rep2(l, 1, k+1){
        sum += __gcd(g, l);
      }
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3632
a,b,c=map(int,input().split())
print(min(abs(b-a)+abs(c-b),abs(c-a)+abs(b-c),abs(a-b)+abs(c-a),abs(c-b)+abs(a-c),abs(a-c)+abs(b-a),abs(b-c)+abs(a-b)))

Measured memory_bytes: 3060
n=int(input())
l=list(map(int,input().split()))
l.append(l[n-1])
xsum=abs(l[0]-l[1])
ysum=0
for x in range(2,n+1):
    if x%2==0:
        if abs(l[x-1]-l[x])+xsum<=abs(l[x-2]-l[x])+ysum:
            ysum=xsum+abs(l[x-1]-l[x])
        else:
            ysum+=abs(l[x-2]-l[x])
    else:
        if abs(l[x-1]-l[x])+ysum<=abs(l[x-2]-l[x])+xsum:
            xsum=abs(l[x-1]-l[x])+ysum
        else:
            xsum+=abs(l[x-2]-l[x])

print([xsum,ysum][xsum>ysum])

Measured memory_bytes: 13908
N = int(input())
a, b = [], []
for i in range(N):
    c, d = map(int, input().split())
    a.append(c)
    b.append(d)
a.sort()
b.sort()
if N%2 == 1:
    print(b[N//2] - a[N//2] + 1)
else:
    print((b[N//2]+b[N//2-1]) - (a[N//2]+a[N//2-1]) + 1)

Measured memory_bytes: 25476
import math
import collections
import heapq
from collections import defaultdict
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n = int(input())
    maxv = n*(n-1)//2
    a = [list(map(int, input().split())) for i in range(n)]
    for i in range(n):
        for j in range(n-1):
            a[i][j] -= 1

    # 試合を頂点とする(ex 1-2,2-4 : i < j)
    v = 0  # 頂点数
    # 頂点にIDをふる
    Id = [[-1 for i in range(n)] for j in range(n)]
    for i in range(n):
        for j in range(n):
            if i < j:
                Id[i][j] = v
                Id[j][i] = v
                v += 1


    # 頂点間の辺を貼る
    e = [[] for i in range(maxv)]
    for i in range(n):
        # a[i][j]にIDを代入する Id[1][3]=1 => a[1][3] = a[3][1] = 1
        for j in range(n - 1):
            a[i][j] = Id[i][a[i][j]]

        # 逆向きに辺をはる
        for j in range(n - 2):
            e[a[i][j]].append(a[i][j+1])



    calculated = [False for i in range(maxv)]
    dp = [-1 for i in range(maxv)]

    def dfs(v):
        if dp[v] != -1:  # サイクル検知
            if not calculated[v]:
                return -1
            return dp[v]
        dp[v] = 1
        for u in e[v]:
            ret = dfs(u)
            if ret == -1:
                return -1
            dp[v] = max(dp[v], ret + 1)
        calculated[v] = True
        return dp[v]

    ans = 0
    for i in range(v):
        ret = dfs(i)
        if ret == -1:  # サイクル検知
            print(-1)
            exit()
        ans = max(ans, ret)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 154828
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  string s; cin >>s;
  int n=s.size();
  vector<int> a;
  rep(i,n){
    if(s[i]=='0') a.push_back(0);
    if(s[i]=='1') a.push_back(1);
    if(s[i]=='B') {
      if(a.size()>0) a.erase(a.begin()+a.size()-1);
    }
  }
  rep(i,a.size()-1){
    cout <<a[i];
  }
  cout <<a[a.size()-1]<<endl;
}

Measured memory_bytes: 256
n=int(input())
s=[input() for _ in range(n)]
c0=0
c1=0
c2=0
c3=0
for i in s:
  if i=="AC":
    c0+=1
  elif i=="WA":
    c1+=1
  elif i=="TLE":
    c2+=1
  elif i=="RE":
    c3+=1
print("AC"+" "+"x"+" "+str(c0))
print("WA"+" "+"x"+" "+str(c1))
print("TLE"+" "+"x"+" "+str(c2))
print("RE"+" "+"x"+" "+str(c3))
  

Measured memory_bytes: 16332
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        string s;
        cin>>s;
        if(s=="ARC")
        {
            cout<<"ABC"<<endl;
        }
        else
        {
            cout<<"ARC"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3620
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    rep(i, 5){
        ll x;
        cin >> x;
        if(x == 0){
            cout << i+1;
            return 0;
        }
    }
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n=0;
    cin >> n;
    vector<int> a(n),b(n,-1);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=n;1<=i;i--){
        int m = 2;
        int cnt = 0;
        while(i*m<=n){
            cnt += b[m*i-1];
            m++;
        }
        if(m==2) b[i-1] = a[i-1];
        else b[i-1] = abs(a[i-1]-cnt)%2;
    }
    bool flag = 0;
    int cnt = 0;
    for(int i=0;i<n;i++){
        if(b[i]==-1) flag = 1;
        if(b[i]==1) cnt++;
    }
    if(flag){
        cout << -1 << endl;
        return 0;
    } 
    cout << cnt << endl;
    for(int i=0;i<n;i++){
        if(b[i]==1) cout << i+1 << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

const ll mod = 1e9+7;


void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


/* 注意 

    1LL<<60 * N とかのオーバーフローに気を付けろ
    制約がヒントになる、ちゃんと全ての制約を見ろ

*/



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

    ll n; cin >> n;
    if (n%2 == 1) { cout << 0 << endl; return 0; }

    ll cnt2 = 0, cnt5 = 0;
    
    for(int i=1; i<=60; ++i) {
        ll p = 1LL<<i;
        cnt2 += n/p;
    }

    for(int i=1; i<=25; ++i) {
        ll p = pow(5, i);
        cnt5 += n/p/2;
    }

    cout << min(cnt2, cnt5) << endl;
    
    return 0;
}


Measured memory_bytes: 512
cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
}
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    cards[s][int(r) - 1] = 1
    
for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print(s, r + 1)

Measured memory_bytes: 6724
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w;
  cin >> h >> w;
  char s[h+2][w+2];
  for (int i=1; i<h+1; i++) {
    for (int j=1; j<w+1; j++) {
      cin >> s[i][j];
    }
  }
  for (int j=0; j<w+2; j++) {
    s[0][j] = '.';
    s[h+1][j] = '.';
  }
  for (int i=0; i<h+2; i++) {
    s[i][0] = '.';
    s[i][w+1] = '.';
  }

  int ans = 1; // yes
  for (int i=1; i<h+1; i++) {
    for (int j=1; j<w+1; j++) {
      if (s[i][j] == '#') {
        if (s[i-1][j] == '.' &&
            s[i][j-1] == '.' &&
            s[i][j+1] == '.' &&
            s[i+1][j] == '.') {
          ans = 0;
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}


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

int search(int i, int left, int count){
	if(i == 10){
		return left == 0 && count == 0;
	}
	return search(i + 1, left, count) + search(i + 1, left - i, count - 1);
}

int main(){
	int n, s;

	while(scanf("%d%d", &n, &s), n + s){
		std::cout << search(0, s, n) << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1212
/*
    g++ -std=c++14 -O2 -Wall a.cpp -o a && a < in.txt > out.txt
    */

//  io
#include <iostream>
//#include <fineam> //http://www.cplusplus.com/reference/fineam/fineam/
//#include <cstdio>
#include <iomanip> //http://www.cplusplus.com/reference/iomanip/
#include <limits>
//  util
#include <string>
#include <cstring>
#include <algorithm>
//#include <utility>
//#include <functional> //http://www.cplusplus.com/reference/functional/
//#include <cstdlib>
#include <cmath>
//#include <complex>
//#include <random>
//#include <bitset>
//  containers https://en.cppreference.com/w/cpp/container
#include <vector>
#include <queue>
#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//  time
//#include <ctime>
//#include <chrono>
//                  https://en.cppreference.com/w/cpp/header/chrono
//                  http://www.cplusplus.com/reference/chrono/

using namespace std;
typedef vector<int> arri;
typedef vector<float> arrf;
typedef pair<int, int> pairi;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 0x7fffffffffffffff;
const ll infneg = -0x7fffffffffffffff;

//file input routed to stdinout
/*
    std::ifineam inFile("input.txt");
    std::ofineam outFile("output.txt");
    std::cin.rdbuf(inFile.rdbuf());
    std::cout.rdbuf(outFile.rdbuf());
    */

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

    int a, b;

    cin >> a >> b;

    int used = 0;
    int socketNum = 1;

    while (socketNum < b)
    {
        socketNum += a - 1;
        used++;
    }

    cout << used;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    
    int money = 0;
    
    int r = 0;
    
    cin >> money;
    
    int count_coin1 = 0;
    int count_coin2 = 0;

    
    int amari = 0;
    
    
    count_coin1 = money / 500 ;
        
        amari = money % 500;
        
        count_coin2 = amari / 5;
        
        
        int r1 = 0;
        int r2 = 0;
        
        r1 = count_coin1 * 1000;
        r2 = count_coin2 * 5;    
        
    
    cout << r1 + r2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int nonempty[1000];
int empty[1000];
vector<int> g[1000];
string type[1000];
int MOD = 1e9 + 7;

void dfs(int x){
	// preprocess
	for(int j = 0 ; j < g[x].size() ; j++){
		dfs(g[x][j]);			
	} 
	if( type[x][0] != 'E' ){
		// main process
		empty[x] = type[x].back() == '?';
		if( type[x][0] == 'R' ){
			for(int i = 1 ; i < (1<<g[x].size()) ; i++){
				int emp = 1;
				int sub = 1;
				for(int j = 0 ; j < g[x].size() ; j++){
					if( i >> j & 1 ){
						emp *= empty[g[x][j]];
						sub *= empty[g[x][j]] + nonempty[g[x][j]];
						sub %= MOD;
					}
				}
				sub -= emp;
				empty[x] |= emp;
				nonempty[x] += sub;
				nonempty[x] %= MOD;
			}
		}else{
			for(int j = 0 ; j < g[x].size() ; j++){
				empty[x] |= empty[g[x][j]];
				nonempty[x] += nonempty[g[x][j]];
				nonempty[x] %= MOD;
			}
		}
	}else{
		empty[x] = type[x].back() == '?';
		int sub = 1;
		int emp = 1;
		for(int j = 0 ; j < g[x].size() ; j++){
			emp *= empty[g[x][j]];
			sub *= (empty[g[x][j]]+nonempty[g[x][j]]);
			sub %= MOD;
			
		}
		nonempty[x] = sub;
		
		
	}
	//cout << x+1 << "  emp:" << empty[x] << " nonemp:" << nonempty[x] << "(" << type[x] << endl;
	
	
	
}
signed main(){
	int N;
	cin >> N;
	for(int i = 0 ; i < N ; i++)
		cin >> type[i];
	for(int i = 0 ; i < N - 1 ; i++){
		int s,t;
		cin >> s >> t;
		--s,--t;
		g[s].push_back(t);
	}
	dfs(0);
	cout << ((nonempty[0] + empty[0])%MOD+MOD)%MOD << endl;
	
	

}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(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; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    ll N;
    cin >> N;
    string S;
    cin >> S;
    map<char,ll> mp;
    for (ll i = 0;i<N;i++) {
        mp[S.at(i)]++;
    }
    ll cnt = 1;
    for (pair<char,ll> p : mp) {
        ll pattern = 1 + p.second;
        pattern %= MOD;
        cnt *= pattern;
        cnt %= MOD;
    }
    cout << cnt - 1 << endl;
    
}

Measured memory_bytes: 512
n = gets.to_i
a = []
b = Hash.new(0)
n.times do
  a << gets.to_i
end

c = 1
loop do
  if c == 2
    p b.values.inject(:+)
    break
  elsif b[c] == 0
    b[c] += 1
    c = a[c-1]
  else
    puts '-1'
    break
  end
end


Measured memory_bytes: 10036
class SegTree():
    def __init__(self, N):
        # N:  処理する区間の長さ
        self.N0 = 2**(N-1).bit_length()
        self.INF = 2**31-1
        self.seg_max = [-self.INF]*(2*self.N0)

    def update(self, index, value):
        index += self.N0 - 1
        self.seg_max[index] = value
        while index > 0:
            index = (index - 1) // 2
            self.seg_max[index] = max(self.seg_max[index * 2 + 1], self.seg_max[index * 2 + 2])

    def query(self, first, last):
        first += self.N0 - 1
        last += self.N0 - 1
        ret = -self.INF
        while first <= last:
            if not first & 1:
                ret = max(ret, self.seg_max[first])
            if last & 1:
                ret = max(ret, self.seg_max[last])
            first = first // 2
            last = last // 2 - 1
        return ret


N = int(input())
h = list(map(int, input().split()))
a = list(map(int, input().split()))

rnk2idx = {}
for i in range(N):
    rnk2idx[h[i]] = i+1
segtree = SegTree(N+1)
for i in range(1, N+1):
    segtree.update(i, 0)
for i in range(1, N+1):
    idx = rnk2idx[i]
    segtree.update(idx, segtree.query(1, idx) + a[idx-1])

print(segtree.query(1, N))


Measured memory_bytes: 122832
n = int(input())
b = [int(i) for i in input().split()] 
pool = []

def search_num(num):
  try:
    nn = b.index(num)
    if nn + 1 == num:
      b.remove(num)
      return num
    else: return search_num(num-1)
  except:
    if num-1 > 0:
      return search_num(num-1)
    else: return -1

if n != len(b):
  print('-1')
else:
  for i in range(n, 0, -1):
    num = search_num(i+1)
    if num == -1:
      print('-1')
      break
    else:
      pool.append(str(num))
      if i == 1:
        for i in (reversed(pool)):
          print(i)
        break

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

int main() {
  string s;
  cin>>s;
  if (s == "Sunny") {
    cout<<"Cloudy"<<endl;
  } else if (s == "Cloudy") {
    cout<<"Rainy"<<endl;
  } else {
    cout<<"Sunny"<<endl;
  }

}

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

void cas(int i,char ch) {
    cout<<"Case "<<i<<":"<<ch;
}

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

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
//int dx[]={+1,-1,+0,+0};///Four Directions
//int dy[]={+0,+0,+1,-1};///Four directions
//int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions
//int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions

//int mark[10007];vi prime;void seive(){for(int i=2;i<10000;i++){if(mark[i]==0){prime.pb(i);for(int j=i+i;j<=10000;j+=i)mark[j]=1;}}}

//freopen("input.txt", "r", stdin);

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    double n; cin>>n;

    n=n/3.00;
    cout<<fixed<<setprecision(7)<<n*n*n<<endl;
}


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

int main(){

	int x;
	cin >> x;
	vector<int>prime(x);

	int a=0,sqrtx = sqrt(x);
	int pop;

	rep(i,sqrtx-1) {
		pop = 0;

		for (int j=0;j<i-1;j++) {
			if ((i + 2) % (j + 2) == 0) pop = 1;
		}

		if (pop == 0) {
			prime[a] =i+2;
			a++;
		}
	}
  
	pop = 0;
	while (true) {
		rep(i, a) if (x % prime[i] == 0) pop = 1;
		if (pop == 0) break;
		pop = 0;
		x++;
	}

	cout << x << endl;

}

Measured memory_bytes: 640
H, W, D = list(map(int, input().split()))

Amap = []
for i in range(H):
    Amap.append(list(map(int, input().split())))

xx = [0 for i in range(90002)]
yy = [0 for i in range(90002)]
for y in range(H):
    for x in range(W):
        xx[Amap[y][x]] = x
        yy[Amap[y][x]] = y
Q = int(input())

coord = []
for i in range(Q):
    coord.append(list(map(int, input().split())))

# magic point calculation
mp = [0 for i in range(90002)]

for i in range(D+1, 90002):
    mp[i] = mp[i-D] + abs(xx[i] -xx[i-D]) + abs(yy[i] - yy[i-D])

for i in coord:
    print(mp[i[1]] - mp[i[0]])

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

int main() {

    while(true){
    
        // 1. input end check.
        int H, W;
        cin >> H >> W;
        
        if(H == 0 && W == 0) break;
        
        // 2. output answer.
        for(int i = 0; i < H; i++){
            string s;
            for(int j = 0; j < W; j++) s += '#';
            cout << s << endl;
        }
        cout<< endl;
    
    }
    
    return 0;
    
}


Measured memory_bytes: 3144
#[allow(dead_code)]
fn rd() -> String {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input.trim().to_owned()
}

/// 1行の文字を空白で分割してVec<T>にする。
#[allow(dead_code)]
fn rd_vec<T : std::str::FromStr>() -> Vec<T> {
    rd().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}

/// 1つの要素を入力で受け取る
#[allow(dead_code)]
fn rd_one<T : std::str::FromStr>() -> T {
    rd().parse().ok().unwrap()
}

/// 複数回read_splitを行う
#[allow(dead_code)]
fn rd_vec_mul<T : std::str::FromStr>(count : i32) -> Vec<Vec<T>> {
    (0..count).map(|_| rd_vec()).collect()
}

/// Vecを1列で出力する
#[allow(dead_code)]
fn op_vec<T : std::fmt::Display>(item : Vec<T>, splitter : char) {
    let cnt = item.len();
    let mut c = 0;
    for i in item.iter() {
        c+=1;
        if cnt > c {print!("{}{}", i, splitter);} else {println!("{}", i);}
    }
}

fn main() {
    let input : i64 = rd_one();
    let answer : i64 = input * (input - 1) / 2;
    
    println!("{}", answer);
}


Measured memory_bytes: 4352
// https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_b

#include <bits/stdc++.h>
using namespace std;

int main()
{
    long H, W;
    cin >> H >> W;

    cout << (H == 1 | W == 1 ? 1 : (H * W + 1) / 2) << endl;
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
  ll n,m;
  cin>>n>>m;
 // ll t=n*m;
  
  
 // if(t%2==0)cout<<t/2;
  //else cout<<(t+1)/2;
  if(n==1||m==1)cout<<"1";
 else if(n%2==0&&m%2!=0)cout<<(n/2)*m;
  else if(m%2==0&&n%2!=0)cout<<(m/2)*n;
  else if(m%2==0&&n%2==0)cout<<(m/2)*n;
  else cout<<((m+1)/2)*(n+1)-(m+n)/2;
  
  
  
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)

// Write From This Line
int main()
{
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	rep(i,n) cin >> a[i] >> b[i];
	int m = -1;	
	// a[i]が一番小さいやつの a[i] + b[i]が答え
	int ans = 0;
	rep(i,n) {
		if(m < a[i]){
		ans = a[i] +b[i];
			m = a[i];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 
  int N;
  cin >> N; //山数
  
  vector<long long> A(N); //ダムに貯まった水
  int sum = 0; //雨量の総和

  for(int i=0; i<N; i++){
    cin >> A.at(i);
    sum += A.at(i);
  }

  int calc = 0;
  for(int i=1; i<N-1; i+=2)
    calc += A.at(i);
  
  int rain = sum - 2*calc;
  cout << rain << ' ';

  for(int i=0; i<N-1; i++){
    rain = 2*A.at(i) - rain;
    cout << rain << ' ';  
  }

}

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

int main() {
  int64_t a, b, c, d;
  cin >> a >> b >> c >> d;
  vector<int64_t> product(4);
  product.at(0) = a*c;
  product.at(1) = a*d;
  product.at(2) = b*d;
  product.at(3) = b*c;
  sort(product.begin(), product.end());
  cout << product.at(3) << endl;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] a = new int[n];
		long count = 0L;

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		for (int i = 0; i < n - 1; i++) {
			if (a[i] > a[i + 1]) {
				count += (a[i] - a[i + 1]);
				a[i + 1] = a[i];
			}
		}

		System.out.println(count);

	}
}

Measured memory_bytes: 60040
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        // 主処理
        int num = Integer.parseInt(Integer.toString(a) + Integer.toString(b));
        boolean judge = (int) Math.sqrt(num) * (int) Math.sqrt(num) == num;
        String result = judge ? "Yes" : "No";

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 21204
// Problem : B - String Palindrome
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#define DEBUG(...) cerr << #__VA_ARGS__ << ": ", debug(__VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator << (ostream &os, const vector<T> &v) {os << "["; for (int i=0; i<(int)v.size(); i++) {if (i) os << ", "; os << v[i];} return os << "]";}
void debug() {cerr << "\n";} template<typename T, typename... Args> void debug(T x, Args... args) {cerr << x << "; "; debug(args...);}

bool isPalindrome(string s) {
    for (int i=0; i<=s.length()/2; i++)
        if (s[i] != s[s.length()-i-1])
            return false;
    return true;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    string s;
    cin >> s;
    
    int n = s.length();
    cout << (isPalindrome(s) && isPalindrome(s.substr(0, (n - 1) / 2)) && isPalindrome(s.substr((n + 3) / 2 - 1)) ? "Yes" : "No") << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main{
  public static void main(String[] args){
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      try{
        String a = br.readLine();
        int X = Integer.parseInt(a);

        if(X >= 30){
          System.out.println("Yes");
        }else{
          System.out.println("No");
        }
      }catch(IOException e){
      }catch(NumberFormatException e){
      }
  }
}

Measured memory_bytes: 32756
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i = 0; i < (n); ++i)
#define repe(i, n) for (int64_t i = 0; i <= (n); ++i)
#define reps(i, s, n) for (int64_t i = (s); i < (n); ++i)
#define repse(i, s, n) for (int64_t i = (s); i <= (n); ++i)
#define repr(i, n) for (int64_t i = (n); i >= 0; --i)
const int64_t inf = (int64_t)1e18;
const int64_t mod = (int64_t)1e9 + 7;


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

  int N, Q; cin >> N >> Q;
  string S; cin >> S;

  vector<int> ac(N, 0);
  reps(i, 1, N) {
    if (S[i - 1] == 'A' && S[i] == 'C') {
      ac[i] = ac[i - 1] + 1;
    }
    else {
      ac[i] = ac[i - 1];
    }
  }

  rep(i, Q) {
    int l, r; cin >> l >> r;
    cout << ac[r - 1] - ac[l - 1] << endl;
  }

  return 0;
}

Measured memory_bytes: 1488
import math
def comb(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))

check_list = []
for i in range(N + 1):
  check_list.append([i, 0, 0])

for a in A:
  check_list[a][1] += 1

count = 0
for check in check_list:
  if (check[1] < 2):
    continue
  else:
    c = comb(check[1], 2)
    check_list[check[0]][2] = c
    count += c

for k in range(1, N + 1):
  rid = A[k - 1]
  if (check_list[rid][1] >= 1):
    minus = check_list[rid][1] - 1
  else:
    minus = 0
  result = count - minus
  print(result)


Measured memory_bytes: 121804
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 1234567890

const int maxn = 2e5 + 10;


//initialization here
//

int fa1[maxn],fa2[maxn];
P pr[200000];

//
//initialization finish


// your function is here
//


int Find(int x,int fa[]) {
	return fa[x] == x ? x : fa[x] = Find(fa[x],fa);
}

void Union(int x, int y,int fa[]) {
	int fx = Find(x,fa), fy = Find(y,fa);
	if (fx == fy) return;
	else if(fx < fy)fa[fy] = fx;
	else fa[fx] = fy;
}
//
// your function finished



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

	// your code is here
	//
	int n, k, l; cin >> n >> k >> l;

	rep(i, n) fa1[i] = fa2[i] = i;

	int p, q, r, s;
	rep(i, k) {
		cin >> p >> q;
		p--, q--;
		Union(p, q, fa1);
	}

	rep(i, l)
	{
		cin >> r >> s;
		r--, s--;
		Union(r, s, fa2);
	}

	
	rep(i, n) pr[i] = mp(Find(i,fa1), Find(i, fa2));
	sort(pr, pr + n);

	rep(i, n)
	{
		P sol = mp(Find(i, fa1), Find(i, fa2));
		cout << upper_bound(pr, pr + n, sol) - lower_bound(pr, pr + n, sol) << " ";
	}
	cout << endl;
	//
	// your code finished
	return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, T t){return v2<T>(r, vector<T>(c, t));}

void solve(){
    int a, b;
    cin >> a >> b;
    cout << a*b << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
ll p;
map<ll,ll> insuu;
void prime_factor(ll p){
    ll k=p;
	for(ll i=2;i*i<=p;i++){
	    while(k%i==0){
	        insuu[i]++;
	        k/=i;
	    }
	}
	if(k!=1) insuu[k]=1;
	return ;
}
int main(){
  ll n;
  cin>>n>>p;
  ll ans=1;
  prime_factor(p);
  for(auto p:insuu){
    for(int i=0;i<p.S/n;i++){
      ans*=p.F;
    }
  }
  COUT(ans);
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
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.equals("ABC")) {
			System.out.println("ARC");
		} else if (s.equals("ARC")) {
			System.out.println("ABC");
		}
	}

}


Measured memory_bytes: 35688
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  ;
  cin >> N;
  va.resize(N);
  rep(i, 0, N - 1) { cin >> va[i]; }
}
int facts[MX * 2];
long long modinv(long long a) {
  long long b = MOD - 2, r = 1;
  while (b) {
    if (b & 1) r = r * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return r;
}
void solve() {
  vi a(MX);
  facts[1] = 1;
  rep(i, 2, MX - 1) { facts[i] = facts[i - 1] * i % MOD; }
  rep(i, 0, N - 2) { a[i] = va[i + 1] - va[i]; }
  vi c(N);
  c[0] = 1 * facts[N - 1];
  //  c[1] = c[0] *
  vi f(MX);
  f[1] = facts[N - 1] % MOD;
  rep(i, 2, N) {
    f[i] = f[i - 1] + facts[N - 1] * modinv(i) % MOD;
    f[i] %= MOD;
  }

  int ans = 0;
  rep(i, 1, N - 1) {
    ans += f[i] * a[i - 1];
    ans %= MOD;
  }
  cout << ans << endl;
}
signed main() {
  input();
  solve();
  return 0;
}

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

int main()

{




int n;
cin>>n;
string str;
cin>>str;


char c=str[0];int counter=1;
for(int i=1;i<str.size();i++){

    if(c!=str[i])counter++;
    c=str[i];

}

cout<<counter;

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    ll a,b,c;cin>>a>>b>>c;
    cout << (a+b>=c ? "Yes" : "No") << ednl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
const int inf=0x7fffffff;
const double PI=3.141592653589793;
typedef long long int ll;
using namespace std;
int main()
{
//#ifdef DEBUG
//	freopen("in", "r", stdin);
////	freopen("out", "w", stdout);
//#endif
	
	double a,b,ang;
	scanf("%lf%lf%lf", &a,&b,&ang);
	//cout<<ang<<endl;
	ang=ang/180*PI;
//	cout<<ang<<endl;
	printf("%f\n%f\n%f\n", a*b*sin(ang)/2,a+b+sqrt(a*a+b*b-2*a*b*cos(ang)),b*sin(ang));
	//insert code above
	return 0;
}
//aoj1_10_b.cc

Measured memory_bytes: 1256
using System;

namespace atcoder_070B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
			string[] array = Console.ReadLine().Split(' ');
			int A = int.Parse(array[0]);
			int B = int.Parse(array[1]);
			int C = int.Parse(array[2]);
			int D = int.Parse(array[3]);

			if (A - C >= 0 && D - B >= 0) 
			{
				Console.WriteLine(B - A);
				return;
			}
			
			if (C - A >= 0 && B - D >= 0) 
			{
				Console.WriteLine(D - C);
				return;
			}

			if (A - C >= 0 && D - A >= 0 && B - D >= 0) 
			{
				Console.WriteLine(D - A);
				return;
			}

			if (C - A >= 0 && B - C >= 0 && D - B >= 0) 
			{
				Console.WriteLine(B - C);
				return;
			}

			if (C - B >= 0 || A - D >= 0)
			{
				Console.WriteLine(0);
				return;
			}
        }
    }
}


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

int main() {
  int n, x;
  cin >> n >> x;
  int l[n];
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }

  int d = 0;
  int cnt = 1;
  for (int i = 0; i < n; i++) {
    d = d + l[i];
    if (d > x) break;
    cnt++;
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3664
#include<stdio.h>
#include <time.h>

#define SIZE 10000

int main(){
  int a,b,c,d;
  int left,right;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);
  left = a + b;
  right = c + d;
  if(left > right)
    printf("Left\n");
  else if(left == right)
    printf("Balanced\n");
  else 
    printf("Right\n");

  return 0;
}

Measured memory_bytes: 128
n = int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())
A = max(a)
b = sorted(a,reverse=True)
import collections
c = collections.Counter(a)
if c[A] >= 2:
    for i in range(n):
        print(A)
else:
    for i in range(n):
        if a[i] == A:
            print(b[1])
        else:
            print(A)

Measured memory_bytes: 22104
#include "bits/stdc++.h"
 
using namespace std;
 
typedef pair<int, int> pii;
typedef long long ll;
 
#define MAX_N 100000
 
ll dp[MAX_N], h[MAX_N], N;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
 
    cin >> N;
 
    for (int i = 0; i < N; i++)
        cin >> h[i];
 
    dp[1] = abs(h[1] - h[0]), dp[0] = 0;
 
    for (int i = 2; i < N; i++) {
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
    }
 
    cout << dp[N - 1] << "\n";
 
    // --------------------
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll MOD = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    ll n; cin>>n;
    vector<ll> h(n);
    rep(i,n) cin>>h[i];
    ll ans=0,tmp=0;
    rep(i,n){
        if(tmp<=h[i]){
            tmp=h[i];
            ++ans;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = [0] * N

for i, a in list(enumerate(A))[::-1]:
    i += 1
    d = sum(B[i - 1::i])
    if a != (d % 2):
        B[i - 1] = 1
print(sum(B))
for i, b in enumerate(B):
    if b != 0:
        print(i+1)


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

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int a[22][22], b[22][22];
int main()
{
	int n, m, k;
	cin >> n >> m >> k;
	vector<pii> v;
	for(int i = 1; i <= n; i ++)
	for(int j = 1; j <= m; j ++)
	{
		char x;
		cin >> x;
		a[i][j] = (x == '#');
		if(x == '#')
			v.pb(M(i, j));
	}
	int e = v.size();
	int ans = 0;
	for(int i = 0; i < (1 << n); i ++)
	{
		vi r(n + 1, 0);
		for(int j = 0; j < n; j ++)
		{
			if(i & (1 << j))
			{
				r[j + 1] = 1;
			}
		}
		for(int ii = 0; ii < (1 << m); ii ++)
		{
			vi c(m + 1, 0);
			for(int jj = 0; jj < m; jj ++)
			{
				if(ii & (1 << jj))
				{
					c[jj + 1] = 1;
				}
			}
						int cnt = 0;
		for(int j = 1; j <= n; j ++)
		for(int l = 1; l <= m; l ++)
			if(r[j] == 0 && c[l] == 0 && a[j][l])
				cnt ++;
		if(cnt == -1)
		{
			cout << "\n\n";
			deb(cnt);
			for(int i = 1; i <= n; i ++)
				if(r[i])
					deb(i);
				cout << "\n";
			
				for(int i = 1; i <= m; i ++)
					if(c[i])
						deb(i);
		}
		ans += (cnt == k);
		}
	}
	cout << ans << '\n';
	return 0;
	for(int i = 0; i < (1 << e); i ++)
	{
		if(__builtin_popcount(i) != k)
			continue;
		vi c(n + 1, 0),r(m + 1, 0);
		for(int j = 1; j <= n; j ++)
		for(int l = 1; l <= m; l ++)
			b[j][l] = a[j][l];
		for(int j = 0; j < e; j ++)
		{
			if((1 << j) & i)
			{
				int x = v[j].F, y = v[j].S;
				c[x] = r[y] = 1;
				b[x][y] = 0;
			}
		}
		int cnt = 0;
		for(int j = 1; j <= n; j ++)
		for(int l = 1; l <= m; l ++)
		{
			if(b[j][l])
			{
				if(c[j] && c[l])
				{
					cnt = 1;
					break;
				}
			}
		}
		if(!cnt)
		{
			deb(i);
			ans ++;
		}
	}
	
	cout << ans;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

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

int main(void){

  int n,m;
  int quiz[20][20];
  int cnt;
  int max = 0;

  cin >> n >> m;


 for( int i = 0 ; i < n ; i++ ){
    for( int j = 0 ; j < m ; j++ ){

      quiz[i][j] = 0;

    }
  }


  for( int i = 0 ; i < n ; i++ ){

    cnt = 0;

    for( int j = 0 ; j < m ; j++ ){

      cin >> quiz[i][j];
      if( quiz[i][j] == 1 ) cnt++;

    }

    if( max < cnt ) max = cnt;

  }

  cout << max << endl;

  return 0;

}

Measured memory_bytes: 1164