akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007
#define INF 1001001001

char s[222222];

main(){
    scanf("%s", s);
    int l = strlen(s);
    int nyan = 0, nyaa = 1;
    for(int i=0; i<l; i++){
        if(nyaa && s[i]==s[i+1]){
            i++;
            nyaa = 0;
        }else{
            nyaa = 1;
        }
        nyan++;
    }
    printf("%d\n", nyan);
    return 0;
}

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

int main(){
    int A[3][3], n;
    
    rep(i,3)rep(j,3) cin >> A[i][j];

    cin >> n;
    rep(i,n){
        int b;
        cin >> b;
        rep(j,3)rep(k,3){
            if(A[j][k] == b) A[j][k] = 0;
        }
    }

    bool ans = false;
    rep(i,3){
        if(A[i][0] == 0 && A[i][1] == 0 && A[i][2] == 0) ans = true;
        if(A[0][i] == 0 && A[1][i] == 0 && A[2][i] == 0) ans = true;
    }
    if(A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0) ans = true;
    if(A[0][2] == 0 && A[1][1] == 0 && A[2][0] == 0) ans = true;

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int gcd(int a, int b){
    int r,temp;
    if (a < b){
        temp = a;
        a = b;
        b = temp;
    }
    while ( (r = a % b) != 0){
        a = b;
        b = r;
    }
    return b;
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N){
        cin >> A[i];
    }
    int ans = A[0];
    rep(i,N - 1){
        ans = gcd(ans, A[i + 1]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

using ll = long long;
using P = pair<int, int>;

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<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int main() {
    string s, t;
    cin >> s >> t;
    int ls = s.size(), lt = t.size();
    vector<vector<int>> dp(ls + 1, vector<int>(lt + 1));
    vector<vector<P>> pre(ls + 1, vector<P>(lt + 1, P(-1, -1)));
    rep(i, ls) rep(j, lt) {
        if (s[i] == t[j]) {
            dp[i + 1][j + 1] = dp[i][j] + 1;
            pre[i + 1][j + 1] = P(i, j);
        }
        else {
            dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
            if (dp[i][j + 1] > dp[i + 1][j]) pre[i + 1][j + 1] = P(i, j + 1);
            else pre[i + 1][j + 1] = P(i + 1, j);
        }
    }
    
    string ans;
    P p = P(ls, lt);
    while (true) {
        int si = p.first - 1, ti = p.second - 1;
        if (si == -1 || ti == -1) break;
        
        if (s.at(si) == t.at(ti)) ans += s.at(si);
        p = pre[p.first][p.second];
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

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

int main(void){
    int n, d, count = 0;
    cin >> n >> d;

    vector<vector<int>> x(n, vector<int>(d));
    rep(i, n){
        rep(j, d){
            cin >> x.at(i).at(j);
        }
    }

    int sum = 0;
    rep(i, n){
        for(int j = i+1; j < n; j++){
            rep(k, d){
                sum += (x.at(i).at(k)-x.at(j).at(k))*(x.at(i).at(k)-x.at(j).at(k));
            }
            for(int k = 1; sum >= k*k; k++){
                if(sum != 0 && sum == k*k){
                    count++;
                }
            }
            sum = 0;
        }
    }
    cout << count << endl;

    return 0;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  std::vector<string> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
    sort(v[i].begin(), v[i].end());
  }
  sort(v.begin(), v.end());
  ll res=0;
  string prev=v[0];
  ll cnt=1;
  for(int i=1;i<n;i++){
    if(prev==v[i]){
      cnt++;
    }else{
      prev = v[i];
      res += (cnt * (cnt-1)) / 2;
      cnt=1;
    }
  }
  res += (cnt * (cnt-1)) / 2;

  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 5760
n, m = map(int, input().split())

a = (n - 1) // 2
d = 1
memo = set([])
cnt = 0
for i in range(m):

    if (n - d in memo) or (2*d == n):
        cnt += 1
        d += 1
    memo.add(d)
    if cnt > 1 or a < 1 or a+d > n:
        print(1/0)
    print(a, a+d)
    a -= 1
    d += 2


Measured memory_bytes: 17360
#include <iostream>
#include <vector>
#include <stack>
#include <string>
using namespace std;

class Solution {
public:
    void ConvertRes(stack<char>& s, __int64_t n, int base);
    void ConvertIteration(stack<char>& s, __int64_t n, int base);
};

int main()
{
    Solution sol;
    stack<char> s;
    int num = 0;//十进制
    int sys = 0;//转换后的进制
    cin >> num >> sys;
    sol.ConvertRes(s, num, sys);
    int ans = 0;
    while (!s.empty())
    {
        //cout << s.top();
        ans++;
        s.pop();
    }
    cout << ans << endl;
    //system("pause");
    return 0;
}

//递归实现
void Solution::ConvertRes(stack<char>& s, __int64_t n, int base)
{
    static char digit[] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' };//新进制下的数位
    if (n > 0)//直到n->0
    {
        s.push(digit[n%base]);//存入
        ConvertRes(s, n / base, base);//第二个参数十进制数更新，通过递归得到所有更高位
    }
}

//迭代实现
void Solution::ConvertIteration(stack<char>& s, __int64_t n, int base)
{
    static char digit[] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' };//新进制下的数位
    while (n > 0)
    {
        int remainder = int(n%base);
        s.push(digit[remainder]);
        n /= base;
    }
}


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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    int n, x;
    cin >> n >> x;

    vector<int> a(n);

    rep(i, n){
        cin >> a[i];
    }

    sort(ALL(a));
    vector<int> candy(n);

    rep(i, n){
        candy[i] = min(a[i], x);
        x -= candy[i];

        if(i == n - 1){
            candy[i] += x;
        }
    }

    int ans = 0;

    rep(i, n){
        if(a[i] == candy[i]) ans++;
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
typedef long long ll;
using namespace std;
int n,a[200005],b[200005];
int main(){
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b,b+n);
	int l=b[n/2-1],r=b[n/2];
	for (int i=0;i<n;i++){
		if (a[i]<=l){
			cout<<r<<endl;
		}else{
			cout<<l<<endl;
		}
	}
} 

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define maxn 100003
using namespace std;
struct edge{int to,next;}e[maxn<<1];
int head[maxn],cnte,fa[maxn];
void add(int u,int v){e[++cnte].to=v,e[cnte].next=head[u],head[u]=cnte;}
int n,sz[maxn],s[maxn];
long long d[maxn],sum;
map<long long,int> b;
bool cmp(int x,int y){return d[x]<d[y];}
void dfs(int u,int depth){
	sum+=depth;
	for(int i=head[u];i;i=e[i].next){
		int v=e[i].to;
		if(v==fa[u])continue;
		dfs(v,depth+1);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld",d+i),s[i]=i,b[d[i]]=i,sz[i]=1;
	sort(s+1,s+n+1,cmp);
	for(int i=n;i>=2;i--){
		int v=s[i];
		long long d_u=d[v]-(n-sz[v])+sz[v];
		if(d_u>=d[v]||!b.count(d_u)){puts("-1");return 0;}
		int u=b[d_u];
		add(u,v),add(v,u),fa[v]=u;
		sz[u]+=sz[v];
	}
	if(cnte!=(n-1)*2){puts("-1");return 0;}
	dfs(s[1],0);
	if(sum!=d[s[1]]){puts("-1");return 0;}
	for(int u=1;u<=n;u++){
		for(int i=head[u];i;i=e[i].next){
			int v=e[i].to;
			if(v==fa[u])continue;
			printf("%d %d\n",u,v);
		}
	}
	return 0;
}
//sykakioi

Measured memory_bytes: 13056
package main

import "fmt"

func main() {
	var c1, c2 string
	fmt.Scan(&c1, &c2)
	if c2[2] == c1[0] && c2[1] == c1[1] && c2[0] == c1[2] {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}


Measured memory_bytes: 512
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner scn=new Scanner(System.in);
        int n=scn.nextInt();
        int k=scn.nextInt();
        int answer=1;
        for(int i=0;i<n;i++){
            answer=Math.min(answer*2,answer+k);
        }
      	System.out.println(answer);
    }
}

Measured memory_bytes: 20820
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	vi a(n);
	vector<ll> sum(n + 1); rep(i, n) cin >> a[i], sum[i + 1] = sum[i] + a[i];
	vector<vector<ll>> dp(n, vector<ll>(n, 1e18));
	rep(i, n) dp[i][i] = 0;
	for(int len = 2; len <= n; len++) rep(i, n - len + 1){
		int j = i + len - 1;
		for(int k = i; k < j; k++) dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + sum[j + 1] - sum[i]);
	}
	cout << dp[0][n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M = 2002;
const int mod = 998244353;
int n;
int csb[M],csr[M],dp[2*M][2*M];
int solve(int x,int y)
{
	if(dp[x][y] != -1)
		return dp[x][y];
	if(x>2*n)
		return 1;
	int id = min(x,n);
	int r = csr[id] - y;
	int b = csb[id] - (x-1-y);
	int res = 0;
	if(r)
		res += solve(x+1,y+1);
	if(b)
		res += solve(x+1,y);
	return dp[x][y] = res%mod;
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s;
	cin>>s;
	n = sz(s);
	for(int i=0;i<n;i++)
	{
		int b = s[i]-'0';
		csb[i+1] = csb[i] + b;
		csr[i+1] = csr[i] + 2 - b;
	}
	memset(dp,-1,sizeof(dp));
	cout<<solve(1,0)<<"\n";
	return 0;
}

Measured memory_bytes: 66616
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int h,w; cin >> h >> w;
    vector<string> pic(h);
    rep(i,h) cin >> pic[i];

    rep(i,w+2) cout << '#';
    cout << endl;

    rep(i,h) {
        cout << '#' << pic[i] << '#' << endl;
    }

    rep(i,w+2) cout << '#';
    cout << endl;
    return 0;
}

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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

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

    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++) {
        cin>>arr[i];
    }   
    sort(arr,arr+n);
    int ans = 0;
    ans+=arr[n-1];
    int mi = 2*(n-2)+1;
    for(int i=n-3;i>=0;i--) {
        ans+=arr[mi/2];
        mi--;
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 5224
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>

using namespace std;


int main(){
   string s;
   cin>>s;
   int a=0;
   int b=0;
   int c=0;
   for(int i=0;i<3;i++){
      if(s.at(i)=='a')a++;
      if(s.at(i)=='b')b++;
      if(s.at(i)=='c')c++;
   }
   if(a==1 && b==1 && c==1)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;

}

Measured memory_bytes: 256
N = int(input())
list_P = [int(x) for x in input().split()]
list_Q = [int(x) for x in input().split()]

import itertools
all_list = list(itertools.permutations(range(1,N+1)))
a = all_list.index(tuple(list_P))
b = all_list.index(tuple(list_Q))

print(abs(a-b))


Measured memory_bytes: 8052
using System;

class Program
{
    static void Main(string[] args)
    {
        // 支払総額N円
        string input = Console.ReadLine();
        int payTotal = int.Parse(input);

        // 1円硬貨枚数A
        input = Console.ReadLine();
        int one = int.Parse(input);

        // 支払総額を500円で割った余りを計算
        int surplus = payTotal % 500;

        if ( surplus <= one )
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std; 
  
typedef long long int ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pll> vll; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
typedef priority_queue <ll> pqb;
typedef priority_queue <ll, vector<ll>, greater<ll>> pqs;
double EPS = 1e-9; 
long long INF = 1000000000000000005ll; 
double PI = acos(-1); 
#define M 1000000007ll
#define D 998244353ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound  
#define SQR(x) ((LL)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a))
#define GCD(a,b) __gcd(a,b)
#define setbits(x)   __builtin_popcountll(x)
#define zerobits(x)  __builtin_ctzll(x) 
#define ps(x,y)  fixed<<setprecision(y)<<x
#define endl '\n'
#define ff first 
#define ss second 
#define mp make_pair  
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
  
inline string IntToString(ll a) 
{ 
    char x[100]; 
    sprintf(x, "%lld", a); 
    string s = x; 
    return s; 
} 
  
inline ll StringToInt(string a) 
{ 
    char x[100]; 
    ll res; 
    strcpy(x, a.c_str()); 
    sscanf(x, "%lld", &res); 
    return res; 
} 
  
 
inline string uppercase(string s) 
{ 
    int n = SIZE(s); 
    for(ll i=0;i<n;i++) 
    if (s[i] >= 'a' && s[i] <= 'z') 
        s[i] = s[i] - 'a' + 'A'; 
    return s; 
} 
  
inline string lowercase(string s) 
{ 
    int n = SIZE(s); 
    for(ll i=0;i<n;i++) 
    if (s[i] >= 'A' && s[i] <= 'Z') 
        s[i] = s[i] - 'A' + 'a'; 
    return s; 
}

bool cmp(pll a,pll b)
{
  ll as=a.ff-a.ss;
  ll bs=b.ff-b.ss;
    return (as>bs);
}

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

vl v[100005];
bool vis[100005];

int main() {
    FAST
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ll n;
    cin>>n;
    vvl v;
    for(ll i=0;i<n;i++){
    	ll x,y,z;
    	cin>>x>>y>>z;
    	v.pb({x,y,z});
    }
    vvl dp(n+1,vector <ll>(3));
    dp[1][0]=v[0][0];
    dp[1][1]=v[0][1];
    dp[1][2]=v[0][2];
    for(ll i=2;i<=n;i++){
    	dp[i][0]=max(dp[i-1][1]+v[i-1][0],dp[i-1][2]+v[i-1][0]);
    	dp[i][1]=max(dp[i-1][0]+v[i-1][1],dp[i-1][2]+v[i-1][1]);
    	dp[i][2]=max(dp[i-1][0]+v[i-1][2],dp[i-1][1]+v[i-1][2]);
    }
    cout<<max({dp[n][0],dp[n][1],dp[n][2]})<<endl;
    return 0; 
}

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

int main(){
	int a,b,c; cin>>a>>b>>c;
	rep(i,b){
		if((a*i)%b==c) {cout<<"YES"<<endl; return 0;}
	}
	cout<<"NO"<<endl;
}

Measured memory_bytes: 3612
#include<stdio.h>
int main(void)
{
    int a,b;
    scanf("%d%d",&a,&b);
    if (a<b) {
        printf("a < b\n");
    } else if (a>b) {
        printf("a > b\n");
    } else {
        printf("a == b\n");
    }

    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}

int modpow(int x, int n, int m){
    int a = 1;
    IREP(i, 64){
        a = (a * a) % m;
        if(((n >> i) & 1) == 1) a = (a * x) % m;
    }
    return a;
}

class Combination
{
public:

    vec fact, invfact;
    int MAX_N, mod;

    Combination(int MAX_N, int mod): MAX_N(MAX_N), mod(mod) {
        initialize();
    }

    void initialize(){
        fact = vec(MAX_N + 1);
        invfact = vec(MAX_N + 1);
        fact[0] = 1;
        FOR(i, 1, MAX_N + 1){
            fact[i] = (fact[i - 1] * i) % mod;
        }
        invfact[MAX_N] = modpow(fact[MAX_N], mod - 2, mod);
        IREP(i, MAX_N){
            invfact[i] = (invfact[i + 1] * (i + 1)) % mod;
        }
    }

    int nCr(int n, int r){
        if(r > n || r < 0 || n < 0) return 0;
        if(n > MAX_N){
            MAX_N = n;
            initialize();
        }
        int a = fact[n];
        a = (a * invfact[r]) % mod;
        a = (a * invfact[n - r]) % mod;
        return a;
    }

    int nPr(int n, int r){
        if(r > n || r < 0 || n < 0) return 0;
        if(n > MAX_N){
            MAX_N = n;
            initialize();
        }
        int a = fact[n];
        a = (a * invfact[n - r]) % mod;
        return a;
    }
};

signed main(){

    int H, W, K;
    cin >> H >> W >> K;
    int mod = 1000000007;
    Combination comb(H + W, mod);

    int ans = (K * comb.nPr(H + W, K)) % mod;
    if(K >= 2){
        int a0 = 0;
        int c0 = comb.nPr(H + W - 2, K - 2);
        FOR(k, 2, K + 1){
            int c = c0;
            c *= 2 * (k - 1);
            c %= mod;
            a0 = (a0 + c * (K - k + 1)) % mod;
        }
        a0 *= (H * W) % mod;
        ans = (ans + a0) % mod;
    }

    int a0 = 0;
    int c0 = comb.nPr(H + W - 1, K - 1);
    FOR(k, 1, K + 1){
        int c = c0;
        a0 = (a0 + c * (K - k + 1)) % mod;
    }
    a0 *= (H + W) % mod;
    ans = (ans + a0) % mod;

    cout << ans;
    
    return 0;
}

Measured memory_bytes: 312704
#include <iostream>
#include <vector>
#include <string>
#include <queue>

using namespace std;

int n;
vector<vector<int>> graph;
vector<int> dis;
bool possible = true;

void dfs(int v, int depth) {
    for (auto nextv:graph[v]) {
        if (dis[nextv] < 0) {
            dis[nextv] = depth + 1;
            dfs(nextv, depth + 1);
        } else if (dis[nextv] % 2 != (depth + 1) % 2)possible = false;
    }
}

int bfs(int v) {
    queue<int> que;
    que.push(v);
    que.push(-1);
    vector<bool> visited(n);
    visited[v] = true;

    int dis = 1;
    while (true) {
        int nowv = que.front();
        que.pop();
        if (nowv < 0) {
            if (que.empty())break;
            que.push(-1);
            dis++;
        } else {
            for (auto nextv:graph[nowv]) {
                if (!visited[nextv]) {
                    visited[nextv] = true;
                    que.push(nextv);
                }
            }
        }
    }

    return dis;
}

int main() {
    cin >> n;
    graph = vector<vector<int>>(n);
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < n; j++) {
            if (s[j] == '1')graph[i].push_back(j);
        }
    }

    dis = vector<int>(n, -1);
    dfs(0, 0);

    int ret = 0;
    for (int i = 0; i < n; i++) {
        int usi = bfs(i);
        ret = max(ret, usi);
    }

    cout << (possible ? ret : -1) << endl;
    return 0;
}

Measured memory_bytes: 512
n, m, p = map(int, input().split())
abcs = [list(map(int, input().split())) for _ in range(m)]
distance = [-1000000 * n] * (n + 1)

distance[1] = 0
reachable1 = set([1])
reachableN = set([n])
for _ in range(n + 1):
    for a, b, c in abcs:
        if distance[b] < distance[a] + c - p:
            distance[b] = distance[a] + c - p
        # 枝刈りが必要                                                                                                                                                                                                                
        if a in reachable1:
            reachable1.add(b)
        if b in reachableN:
            reachableN.add(a)

for a, b, c in abcs:
    if (distance[b] < distance[a] + c - p) and (a in reachable1) and (b in reachableN):
        print(-1)
        exit(0)

print(max(distance[n], 0))

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

int main(){
	vector<pair<int, int>> ydk;
	
	for(int i = 0;i < 6;i++){
		int h, w; cin >> h >> w;
		if(h > w) swap(h, w);
		ydk.push_back({h, w});
	}
	
	sort(ydk.begin(), ydk.end());
	
	for(int i = 0;i < 3;i++){
		if(ydk[i*2] != ydk[i*2+1]){
			cout << "no" << endl;
			return 0;
		}
	}
	
	pair<int, int> a, b, c;
	a = ydk[0], b = ydk[2], c = ydk[4];
	
	string OK = "no";
	if(a.first == b.first){
		if(b.second == c.first && c.second == a.second){
			OK = "yes";
		}else if(b.second == c.second && c.first == a.second){
			OK = "yes";
		}
	}
	
	if(a.first == b.second){
		if(b.first == c.first && c.second == a.second){
			OK = "yes";
		}else if(b.first == c.second && c.first == a.second){
			OK = "yes";
		}
	}
	
	if(a.second == b.first){
		if(b.second == c.first && c.second == a.first){
			OK = "yes";
		}else if(b.second == c.second && c.first == a.first){
			OK = "yes";
		}
	}
	
	if(a.second == b.second){
		if(b.first == c.first && c.second == a.first){
			OK = "yes";
		}else if(b.first == c.second && c.first == a.first){
			OK = "yes";
		}
	}
	
	cout << OK << endl;	
	return 0;
}
			 


Measured memory_bytes: 3176
# A = [list(map(int, input().split())) for _ in range(3)]
# n = int(input())
# B = [int(input()) for _ in range(n)]
# X = list(map(int, input().split()))
n, a, b = map(int, input().split())
total = a+b
diff = n % total
blue_in = n//total*a
if a <= diff:
    print(a+blue_in)
else:
    print(diff+blue_in)


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

int main(){
    long long N, a, b, ans=1e12+1;
    cin >> N;


    for(int i=1; i<=sqrt(N); i++){
	if(N%i==0){
	    a=i;
	    b=N/i;
	    ans = min(ans, a+b-2);
	}
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
/*  ***  In The Name of God ... ***  */
#include <bits/stdc++.h>

using namespace std ;
 
typedef long long ll ;
typedef long double ld ;

 
#define int long long
#define all(v) v.begin() , v.end()

template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

int a , b , c ; 

int32_t main()                     
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> a >> b >> c ;
	if ( a == b && b == c && a % 2 == 0 )
		return cout << -1 << '\n' , 0 ;
	int res = 0 ;
	while ( a % 2 == 0 && b % 2 == 0 && c % 2 == 0 ) {
		++ res ;
		int sa = a , sb = b , sc = c ;
		a = ( sb >> 1 ) + ( sc >> 1 ) ;
		b = ( sa >> 1 ) + ( sc >> 1 ) ;
		c = ( sa >> 1 ) + ( sb >> 1 ) ; 
	}
	cout << res << '\n' ; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	map<string,ll> m;
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++){
		string s;
		cin>>s;
		m[s]++;
	}
	cout<<"AC x "<<m["AC"]<<"\n";
	cout<<"WA x "<<m["WA"]<<"\n";
	cout<<"TLE x "<<m["TLE"]<<"\n";
	cout<<"RE x "<<m["RE"]<<"\n";
	return 0;
}

Measured memory_bytes: 3596
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<cstdio>
#define curr(P, i) P[(i) % P.size()]
#define next(P, i) P[(i+1) % P.size()]

using namespace std;

struct point{ double x, y; };

double areaPol(vector<point> t){
  double area=0;
  for(int i=0;i<t.size();i++)
    area+=(curr(t,i).x-next(t,i).x)*(curr(t,i).y+next(t,i).y);
  
  return abs(area)/2.0;
}

int main(void){
  int n,turn=1;
  point p;
  vector<point>t;

  while(cin >> n,n){
    t.clear();
    for(int i=0;i<n;i++){
      cin >> p.x >> p.y;
      t.push_back(p);
    }
    printf("%d %.1f\n",turn++,areaPol(t));
  }

  return 0;
}

Measured memory_bytes: 1264
#include <iostream>

int solve3(int x, int c) {
  if (c*50 - x >= 0) return 1;
  else return 0;
}

int solve2(int x, int b, int c) {
  int sum = 0;
  sum += solve3(x, c);
  while (x >= 100 && b > 0) {
    sum += solve3(x -= 100, c);
    b--;
  }
  return sum;
}

int solve1(int x, int a, int b, int c) {
  int sum = 0;
  sum += solve2(x, b, c);
  while (x >= 500 && a > 0) {
    sum += solve2(x -= 500, b, c);
    a--;
  }
  return sum;
}

int main() {
  int a, b, c, x;
  std::cin >> a >> b >> c >> x;
  std::cout << solve1(x, a, b, c);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N,M;
    cin >> N;
    int ans = 0;
    int p[N];
    REP(i,N){
        cin >> p[i];
    }
    REPP(i,1,N-1){
        if(p[i-1] < p[i] && p[i+1] > p[i]) ans++;
        else if(p[i-1] > p[i] && p[i+1] < p[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
#include<list>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//int型0~9を文字0~9に変換
char int_to_char(int c) {
	if (c == 0) return '0';
	if (c == 1) return '1';
	if (c == 2) return '2';
	if (c == 3) return '3';
	if (c == 4) return '4';
	if (c == 5) return '5';
	if (c == 6) return '6';
	if (c == 7) return '7';
	if (c == 8) return '8';
	if (c == 9) return '9';
	else return'x';
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}
//xとyのビットごとの排他的論理和
template<class T> T XOR(T x, T y)
{
	T n = 0;
	while (max(x, y) > pow(2, n)) n++;
	T ans=0;
	for (int i = 0; i <= n; i++)
	{
		T x1 = (x % (T)pow(2, i + 1)) / (T)pow(2, i);
		T y1 = (y % (T)pow(2, i + 1)) / (T)pow(2, i);
		if (x1 != y1) ans += (T)pow(2, i);
	}
	return ans;
}

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	char S[3];
	cin >> S;
	if (S[0] == S[1] && S[1] == S[2]) cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}

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

long long a, b;

int main()
{
	ios_base::sync_with_stdio(false);

	cin >> a >> b;

	if ((a*b) % 2) cout << "Odd";
	else cout << "Even";

	return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	string S=in<string>();
	int maxN = pow(2,S.size()-1);
	ll sum = 0;
	for(int i=0;i<maxN;i++){
		int v = i;
		ll s = 0;
		for(int j=0;j<S.size();j++){
			ll t = S[j]-'0';
			s *= 10;
			s += t;
			if(v&1){
				sum += s;
				s = 0;
			}
			v >>= 1;
		}
		sum += s;
	}
	
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
while True:
    try:
        a, b, c, d, e, f = map(int, input().split())
    except:
        break
    y = (c*d-f*a) / (b*d-e*a)
    x = (c - b*y) / a
    print("{:.3f} {:.3f}".format(x, y))

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

using namespace std;

int main(){
	string s; cin >> s;
	if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]){
		cout << "Bad" << endl;
	}else{
		cout << "Good" << endl;
	}
}

Measured memory_bytes: 256
a,b,k=map(int,input().split())
#l=[int(i) for i in input().split()]
#ans=chk=0
ans={a,b}
for i in range(a,min(a+k,b)):
    ans.add(i)
for i in range(b,max(a,b-k),-1):
    ans.add(i)
ans=list(ans)
ans.sort()
for i in ans:
    print(i)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
typedef long long ll;

int N, ans=0;

void dfs(ll cur, int mask) {
    if (cur > N) return;
    if (mask == 7) ans++;
    dfs(cur * 10 + 7, mask | 4);
    dfs(cur * 10 + 5, mask | 2);
    dfs(cur * 10 + 3, mask | 1);    
}

int main() {
    cin >> N;
    dfs(0, 0);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
// #include <atcoder/all>
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <stack>
using namespace std;
// using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
#define REP(i, m, n) for (ll(i) = (ll)(m); i < (ll)(n); ++i)
#define REP2(i, m, n) for (ll(i) = (ll)(n)-1; i >= (ll)(m); --i)
#define rep(i, n) REP(i, 0, n)
#define rep2(i, n) REP2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define rall(hoge) (hoge).rbegin(), (hoge).rend()
#define en '\n'
using Edge = pair<ll, ll>;
using Graph = vector<vector<Edge>>;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
// constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
template <class T> inline void print(T x) { cout << x << '\n'; }
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;
}
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
// ~~~~~~~~~~~~~~memo~~~~~~~~~~~~~~
// for (int i = 0; i < n; ++i)
// cout << res << endl;
// cout << res << '\n';
// int型の2次元配列(h×w要素の)の宣言
// vector<vector<int>> data(h, vector<int>(w));
// rotate(s.begin(), s.begin() + 1, s.end());
// sort(all(a),greater<int>());
// s.substr(0,2) 先頭から2文字切り出す
// for (auto it = mp.rbegin();it != mp.rend(); ++it)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,t;
    cin >> s >> t;
    sort(all(s));
    sort(all(t),greater<int>());
    if (s < t) {
        print("Yes");
    } else {
        print("No");
    }
    return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> pii;

int n, m;
int x, y, z;
int ans = 0;
int a[100009];
vector<pii> g[100009];

void dfs(int node, int w) {
  w = w % 2;
  a[node] = w;
  for(auto i:g[node]) {
    if(a[i.first]==-1) {
      // cout << i.first << endl;
      dfs(i.first, w + i.second);
    }
  }
}

int main() {
  memset(a, -1, sizeof(a));
  cin >> n;
  for(int i=0; i<n-1; i++) {
    cin >> x >> y >> z;
    z = z % 2;
    g[x].push_back(pii(y, z));
    g[y].push_back(pii(x, z));
  }
  dfs(1, 0);
  for(int i=1; i<=n; i++) {
    cout << a[i] << endl;
  }
}

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

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s;
	cin >> s;
	int n = (int)s.size() + 1;
	vector<int> l(n, 0);
	vector<int> r(n, 0);
	l.front() = r.back() = 0;
	for(int i = 1; i < n; i++){
		if(s[i-1] == '<'){
			l[i] = l[i-1] + 1;
		} else {
			l[i] = 0;
		}
	}
	for(int i = n-1; i > 0; i--){
		if(s[i-1] == '>'){
			r[i-1] = r[i] + 1;
		} else {
			r[i-1] = 0;
		}
	}
	long long ans = 0;
	for(int i = 0; i < n; i++){
		ans += max(l[i], r[i]);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 4764
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int g,t,xx;
    string a;
    vector<string>re;
    map<string,int>mm;
    scanf("%d",&t);
    for(g=0;g<t;g++){
        cin>>a;
        mm[a]++;
    }
    xx=-1e9;
    for(auto &x:mm)
        xx=max(xx,x.second);
    for(auto &x:mm)if(x.second==xx)
        re.push_back(x.first);
    sort(re.begin(),re.end());
    for(g=0;g<re.size();g++)
        printf("%s\n",re[g].c_str());
    return 0;
}


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

int main(){
    int w,h;
    cin >> w >> h;
    int x,y,r;
    cin >> x >> y >> r;
    if (y - r >= 0 && y + r <= h && x - r >= 0 && x + r <= w){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    } 
    return 0;
}


Measured memory_bytes: 3120
N = int(input())
def length(a,b):
    return ((a[0]-b[0])**2 + (a[1]-b[1])**2)**(1/2)
p = [list(map(int,input().split())) for _ in range(N)]
ans = 0
for i in range(N-1):
    for j in range(i+1,N):
        ans += length(p[i],p[j])
print(ans*2/N)

Measured memory_bytes: 9388
#include<stdio.h>
int main(void){
  int k,n,i,j,sum=0;
  scanf("%d",&k);
  int sec[k];
  for(i=0;i<k;i++){
    scanf("%d",&sec[i]);
  }
  scanf("%d",&n);
  int dr[n][2];
  for(i=0;i<n;i++){
    sum=0;
    scanf("%d %d",&dr[i][0],&dr[i][1]);
    for(j=0;j<k;j++){
      if((j+1)==dr[i][0]){
        sum+=dr[i][1];
      }else{
        sum+=sec[j];
      }
    }
    printf("%d\n",sum);
  }
  return 0;
}
    

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A , B , C;
  int max,min;
  cin >> A >> B >> C;
  if(A > B){
    max = A;
    min = B;
  } else if(A < B){
    max = B;
    min = A;
  }
  
  if(max > C && min < C){
    cout << "Yes" << endl;
    
  } else {
    cout << "No" << endl;
  }
    
    
}

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

int main() {
  // ここにプログラム
  int n, m;
  cin >> n >> m;
  vector<int> menu(m, 0);
  int k, tem;
  for(int i = 0; i < n; i++) {
    cin >> k;
    int j = 0;
    while(true) {
      if(j < k) {
        cin >> tem;
        menu.at(tem - 1)++;
        j++;
      }
      else {
        break;
      }
    }
  }
  int ans = 0;
  for(int i = 0; i < m; i++) {
    if(menu.at(i) == n) {
      ans++;
    }
  }
  cout <<ans << endl;

  
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N;
    cin >> N;
    pair<pair<string, int>, int> data[100];

    for (int i=0; i<N; i++) {
        string s;
        int p;
        cin >> s;
        cin >> p;
        data[i] = make_pair(make_pair(s, -p), i+1);
    }

    sort(data, data+N);
    for (int i=0; i<N; i++) {
        cout << data[i].second << endl;
    }

    return 0;
}

int main2() { 
    int N;
    cin >> N;
    vector<string> S;
    vector<int> P;
    map<string, vector<int>> dic;
    map<string, int> idx;

    for (int i=0; i<N; i++) {
        string s;
        int p;
        cin >> s;
        cin >> p;
        dic[s].push_back(p);
        if (find(S.begin(), S.end(), s) == S.end()) {
            S.push_back(s);
        }
        idx[s+to_string(p)] = i + 1;
    }
    sort(S.begin(), S.end());

    for (int i=0; i<S.size(); i++) {
        sort(dic[S[i]].begin(), dic[S[i]].end(), greater<int>());
        for (int j=0; j<dic[S[i]].size(); j++) {
            int pt = dic[S[i]][j];
            cout << idx[S[i]+to_string(pt)] << endl;
        }

    }
    
    return 0;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7, N = 2005;
int C[N][N];
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  C[0][0] = 1;
  for(int i = 1; i < N; i++) {
    C[i][0] = 1;
    for(int j = 1; j < N; j++) {
      C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
      if(C[i][j] >= MOD) C[i][j] -= MOD;
    }
  }
  int n, k; cin >> n >> k;
  for(int i = 1; i <= k; i++) {
    cout << (1ll * C[n - k + 1][i] * C[k - 1][i - 1] % MOD) << "\n";
  }
}

Measured memory_bytes: 16000
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

int a[200001];
int mapdata[200001];
int ans = 0;


signed main() {
	int N, H, W;
	cin >> N >> H >> W;
	cout << (N - H + 1)*(N - W + 1) << "\n";


	return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int N, M;
int A[100010], B[100010], C[100010], P[100010];
int imos[100010];
signed main() {
    cin >> N >> M;
    for(int i=0; i<M; i++) {
        cin >> P[i]; P[i]--;
    }

    for(int i=0; i<M-1; i++) {
        int u = min(P[i], P[i+1]), v = max(P[i], P[i+1]);
        imos[u]++;
        imos[v]--;
    }

    for(int i=0; i<N-1; i++) {
        cin >> A[i] >> B[i] >> C[i];
    }

    for(int i=0; i<N; i++) {
        imos[i+1] += imos[i];
    }

    int sum = 0;
    for(int i=0; i<N-1; i++) {
        int costA = imos[i] * A[i];
        int costB = imos[i] * B[i] + C[i];
        sum += min(costA, costB);
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 6992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main{
 
  public static void main(String[] args) throws IOException {
    try ( BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ) {

      StringBuilder output = new StringBuilder();
      String[] lines;
      int h,w;

      while (true) {
        lines = br.readLine().split(" ");
        h = Integer.parseInt(lines[0]);
        w = Integer.parseInt(lines[1]);

        if(h==0 && w==0){ break; }

        for( int i = 1; i <= h; i++){
          for( int j = 1; j <= w; j++){
            if( i == 1 || i == h) output.append("#");
            else {
              if( j == 1 || j == w) output.append("#");
              else output.append(".");
            }
          }
          output.append("\n");
        }

        System.out.println(output);

        output.setLength(0);
      }
    }
  }
}


Measured memory_bytes: 24948
import numpy as np

N = int(input())
tmpA = list(map(int,input().split()))

A = np.array(tmpA)
ans = 0
odd = 0

while odd == 0:
    for a in A:
        if a % 2 == 1:
            odd = 1
            break
    if odd != 1:
        A = A//2
        ans += 1
print(ans)


Measured memory_bytes: 12844
from functools import lru_cache
n,a,b,c,d=map(int,input().split())

mod=10**9+7
fac=[1]*(n+3)
finv=[1]*(n+3)

t=1
for i in range(1,n+1):
    t*=i
    t%=mod
    fac[i]=t
t=1
for i in range(1,n+1):
    t*=pow(i,mod-2,mod)
    t%=mod
    finv[i]=t

finvp = [finv]
for i in range(n-1):
    p=finvp[-1]
    q=[p[i]*finv[i]%mod for i in range(n+1)]
    finvp.append(q)

dp = [[0 for _ in range(n+1)] for _ in range(b+1)]
dp[a-1][0] = 1

for i in range(a-1,b):
    for j in range(n+1):
        dp[i+1][j]=dp[i][j]
        for k in range(c,1+min(d,j//(i+1))):
            x=j-k*(i+1)
            dp[i+1][j]+=fac[j]*finv[x]*finvp[k-1][i+1]*finv[k]*dp[i][x]%mod
        dp[i+1][j]%=mod
print(dp[b][n])

Measured memory_bytes: 134108
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    int n;
    cin>>n;
    ll ans = 0;
    ll mod = 1e9+7;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin>>a[i];
    vector<ll> sum(n+1);
    sum[0]=0;
    for(int i=0; i<n; i++) sum[i+1] = sum[i]+a[i];
    for(int i=0; i<n-1; i++){
        ll tmp1 = sum[n]-sum[i+1];
        tmp1 %= mod;
        ll tmp = a[i]*tmp1;
        tmp %= mod;
        ans += tmp;
        ans %= mod;
    }
    cout<<ans%mod<<endl;
}

Measured memory_bytes: 6420
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[] = new int[100];
        int sum = 0;
        for(int i = 0; i < N; i++) {
        	a[i] = sc.nextInt();
        }
        for(int i = 0; i < N; i++) {
        	for(int j = i+1; j < N; j++) {
        		sum += a[i] * a[j];
        	}
        }
        System.out.println(sum);
        }
    
}

Measured memory_bytes: 22996
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	cout << (n-1) / 2 << '\n';
	return 0;
}


Measured memory_bytes: 256
//By Vlgd
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x;cin>>n>>x;
	int maxn=-1000000000,minr=x;
	for(int i=1;i<n;i++){
		cin>>x;
		maxn=max(maxn,x-minr);
		minr=min(minr,x);
	}
	cout<<maxn<<endl;
	return 0;
}


Measured memory_bytes: 3100