akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

void DiceRoll(int num[6], char cmd);
int DiceJudge(int Dice1[6], int Dice2[6]);

int main()
{
    int Dice1[6], Dice2[6];
    int i;
    
    for(i=0; i<6; i++) scanf("%d", &Dice1[i]);
    for(i=0; i<6; i++) scanf("%d", &Dice2[i]);
    
    if(DiceJudge(Dice1, Dice2) == 1) printf("Yes\n");
    else printf("No\n");
    
    return 0;
}

void DiceRoll(int num[6], char cmd)
{
    int tmp = num[0];
    switch(cmd){
        case 'N':
            num[0] = num[1];
            num[1] = num[5];
            num[5] = num[4];
            num[4] = tmp;
            break;
        case 'S':
            num[0] = num[4];
            num[4] = num[5];
            num[5] = num[1];
            num[1] = tmp;
            break;
        case 'W':
            num[0] = num[2];
            num[2] = num[5];
            num[5] = num[3];
            num[3] = tmp;
            break;
        case 'E':
            num[0] = num[3];
            num[3] = num[5];
            num[5] = num[2];
            num[2] = tmp;
            break;
        default:
            break;
    }
}


int DiceJudge(int Dice1[6], int Dice2[6])
{
    int i, count=0;
    int judge = 0;
    for(i=1; i<6; i++){
        if(Dice1[0] == Dice2[i]){
            switch(i){
                case 1:
                    DiceRoll(Dice2, 'N');
                    break;
                case 2:
                    DiceRoll(Dice2, 'W');
                    break;
                case 3:
                    DiceRoll(Dice2, 'E');
                    break;
                case 4:
                    DiceRoll(Dice2, 'S');
                    break;
                case 5:
                    DiceRoll(Dice2, 'N');
                    DiceRoll(Dice2, 'N');
                    break;
                default:
                    break;
            }
        }
    }
    for(i=0; i<6; i++){
        if(i>1 && i<5){
            if(Dice1[1] == Dice2[i]){
                switch(i){
                    case 2:
                        DiceRoll(Dice2, 'N');
                        DiceRoll(Dice2, 'W');
                        DiceRoll(Dice2, 'S');
                        break;
                    case 3:
                        DiceRoll(Dice2, 'N');
                        DiceRoll(Dice2, 'E');
                        DiceRoll(Dice2, 'S');
                        break;
                    case 4:
                        DiceRoll(Dice2, 'N');
                        DiceRoll(Dice2, 'W');
                        DiceRoll(Dice2, 'W');
                        DiceRoll(Dice2, 'S');
                        break;
                    default:
                        break;
                }
            }
        }
    }
    for(i=0; i<6; i++){
        if(Dice1[i] == Dice2[i]) count++;
    }
    if(count == 6) judge = 1;
    
    return (judge);
}

Measured memory_bytes: 580
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>


using namespace std;


using ll = long long;


int main()
{
    vector<ll> a;
    ll N;
    cin >> N;

    ll min_p = LONG_LONG_MAX;
    ll max_p = LONG_LONG_MIN;
    for (ll i = 1; i <= N; i++) {
        ll tmp;
        cin >> tmp;
        tmp -= i;
        min_p = min(min_p, tmp);
        max_p = max(max_p, tmp);
        a.push_back(tmp);
    }

    sort(a.begin(), a.end());
    auto med = a[a.size() / 2];
    ll s = 0;
    for (auto e : a) {
        s += abs(e - med);
    }
    cout << s << endl;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;
bool sortbysec(const pair<lli,lli> &a,
              const pair<lli,lli> &b)
{
    return (a.second < b.second);
}
lli modulo(string num, lli a)
{
    lli res = 0;
    for (lli i = 0; i < num.length(); i++)
         res = (res*10 + (int)num[i] - '0') %a;

    return res;
}

int main()
{
//cout.precision(9);
//cout.setf(ios::fixed,ios::floatfield);
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
	lli T=1;
    //cin>>T;
	while(T--)
	{
        lli n,i,r,j,z;
        cin>>n;
        vector<lli> h;
        lli dp[n];
        for(i=0;i<n;i++)
        {
            cin>>z;
            h.pb(z);
        }
        if(n==2)
        {
            cout<<h[1]-h[0]<<endl;
            return 0;
        }
        dp[0]=0;
        dp[1]=abs(h[1]-h[0]);
        for(i=2;i<n;i++)
        {
            dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
        }
        cout<<dp[n-1]<<endl;
    }
}
/*
5
1 2 3 4 5
*/


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

using namespace std;

int main()
{
  string S1, S2, S3;
  cin >> S1 >> S2 >> S3;
  cout << (char) toupper(S1[0]) << (char) toupper(S2[0]) << (char) toupper(S3[0]) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		String[] s = sc.next().split("");
		String kanri = s[0];
		for(int i = 1; i< 3;i++) {
			if(kanri.equals(s[i])) {
				continue;
			}else {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");

	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	string S;
	cin >> S;
	int ans = 0;
	
	int pos = 0;
	string prv;
	while (pos < S.size()) {
		string cur;
		cur += S[pos++];
		while (prv == cur && pos < S.size()) {
			cur += S[pos++];
		}
		
		if (prv != cur) {
			prv = cur;
			++ans;
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <cstdio>
using namespace std;

int main(){
  double xp1,yp1,xp2,yp2;
  cin >> xp1 >> yp1 >> xp2 >> yp2;
  pair<double,double> p1 = make_pair(xp1,yp1);
  pair<double,double> p2 = make_pair(xp2,yp2);

  pair<double,double> a = make_pair(p2.first-p1.first,p2.second-p1.second);

  int q;
  cin >> q;
  vector<pair<double,double>> query;
  for(int i = 0;i < q;i++){
    double xp,yp;
    cin >> xp >> yp;
    pair<double,double> p = make_pair(xp,yp);
    pair<double,double> b = make_pair(p.first-p1.first,p.second-p1.second);

    //同様に正射影を用いればよい.
    double dot_ab = a.first * b.first + a.second * b.second;
    double dot_aa = a.first * a.first + a.second * a.second;
    pair<double,double> prj = make_pair(a.first*dot_ab/dot_aa,a.second*dot_ab/dot_aa);

    //prj=(p1->p(=b) + p1->x)/2
    pair<double,double> p1x = make_pair(2*prj.first-b.first,2*prj.second-b.second);
    pair<double,double> ans = make_pair(p1.first+p1x.first,p1.second+p1x.second);

    query.push_back(ans);
  }

  for(int i = 0;i < q;i++){
    printf("%.14lf %.14lf\n",query[i].first,query[i].second);
  }
}



Measured memory_bytes: 3332
S = input()
s = list(S)
cnt = 1
k = 1
flag = 0
for i in range(1,len(s)):
    #print(i)
    if(flag==1):
        cnt += 1
        flag = 0
        continue
    
    if(s[i-1]==s[i] and k==1):
        flag = 1
        k = 2
        continue
    else:
        cnt += 1
        k = 1
    

print(cnt)

Measured memory_bytes: 4968
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define reps(i,s,n) for(int (i) = (s); (i) < (n); ++(i))
#define rep(i,n) reps(i,0,n)
using ll = long long;
     
int main(){
	int n;
	string s,ans;
	cin >> n;
	cin >> s;
	ans = s;
	int l=0,r=0;
	rep(i,s.length()){
		if(s[i] ==')') r++;
		else if(s[i] == '(') l++;
	}
	int count = abs(r-l);
	//cout << r << "," << l << "," << count << endl;
	
bool test = false;
bool ef =false;
int cnt = 0;
	while(1){
		test = false;
		rep(i,s.length()-1){
			if(s[i]=='(' && s[i+1] == ')'){
				if(s.length() == 2){
					cout << ans << endl;
					return 0;
				}
				s.erase(s.begin()+i,s.begin()+i+2);
				//cout << s << endl;
				test = true;
			}
		}
		if(test == false)break;
	}
	     
	while(1){
		if(s[0] == ')'){
			s = '(' + s;
			ans = '(' + ans;
		}else if(s[s.length()-1] == '('){//cout << "cc"<<endl;
			s = s + ')';
			ans = ans + ')';
		}else {
			//s = ')' + s;
			s.insert(s.begin()+1,')');
			ans.insert(ans.begin()+1,')');			
			//ans = ')' + ans;		
		}
		//cout << s <<"  |  " << ans << endl;
	
		while(1){
			test = false;
			rep(i,s.length()-1){
				if(s[i]=='(' && s[i+1] == ')'){
					if(s.length() == 2){
						ef=true;
						break;
					}else{
						s.erase(s.begin()+i,s.begin()+i+2);
						//cout << s << "  |  " << ans<< endl;
						test = true;
					}
				}
			}
			if(test == false)break;
		}
		if(ef == true ){
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=9999999999999999;

int main() {
   int N,K;
   string S;
   cin>>N>>K>>S;
   S[K-1]=(char)(S[K-1]-'A'+'a');
   cout<<S<<endl;
return 0;}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	string s;
	cin >> s;
	int g = 0, p = 0;
	int point = 0;
	for (int i = 0; i < s.size(); ++i)
	{
		if (p+1 <= g)
		{
			p++;
			if (s[i] == 'g')
			{
				point++;
			} 
		} else {
			g++;
			if (s[i] == 'p')
			{
				point--;
			}
		}

	}	
	cout << point << endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int A=stdIn.nextInt();
		int B=stdIn.nextInt();
		if((A+B)%2==0)
			System.out.println((A+B)/2);
		else
			System.out.println("IMPOSSIBLE");
	}
}


Measured memory_bytes: 21844
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 = sc.nextInt();
        int B = sc.nextInt();
        int[] P = new int[N];
        int Ap = 0;
        int ABp = 0;
        int Bp = 0;
        for(int i=0;i<N;i++) {
        	P[i] = sc.nextInt();
        	if(P[i]<=A) {
        		Ap++;
        	}
        	if(P[i] >= A+1 && P[i] <=B) {
        		ABp++;
        	}
        	if(P[i] >= B+1) {
        		Bp++;
        	}
        }
        
        int ans = Math.min(Math.min(Ap, ABp), Math.min(ABp, Bp));

        System.out.println(ans);
        
        sc.close();
    }
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,Int k){
    Mint num(1),dom(1);
    for(Int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE
signed main(){
  Int h,w,t;
  cin>>h>>w>>t;

  Int gh=__gcd(h,t),gw=__gcd(w,t);
  Int ch=h/gh,cw=w/gw;

  using M = Mint<Int>;
  M res{1};
  res+=M(2).pow(__gcd(ch,cw))-M(2);
  res+=M(2).pow(ch)-M(1);
  res+=M(2).pow(cw)-M(1);
  cout<<res.pow(gh*gw)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

//yy && mm  yy && mm
//yy && mm  yy || mm
//yy mm
//mm yy

bool isYear(int num) {
	return 0 <= num && num <= 99;
}

bool isMonth(int num) {
	return 1 <= num && num <= 12;
}

struct ym {
	int value;
	bool is_year;
	bool is_month;

	ym(int num) {
		value = num;
		is_year = isYear(num);
		is_month = isMonth(num);
	}
};

int main()
{
	int s;
	std::cin >> s;

	int upper_2, lower_2;
	upper_2 = s / 100;
	lower_2 = s - (upper_2 * 100);

	ym upper(upper_2);
	ym lower(lower_2);

	if (upper.is_year && upper.is_month) {
		if (lower.is_year && lower.is_month) {
			std::cout << "AMBIGUOUS" << std::endl;
		}
		else if (lower.is_year) {
			std::cout << "MMYY" << std::endl;
		}
		else if (lower.is_month) {
			std::cout << "YYMM" << std::endl;
		}
		else {
			std::cout << "NA" << std::endl;
		}
	}
	else if (upper.is_year) {
		if (lower.is_month) {
			std::cout << "YYMM" << std::endl;
		}
		else {
			std::cout << "NA" << std::endl;
		}
	}
	else if (upper.is_month) {
		if (lower.is_year) {
			std::cout << "MMYY" << std::endl;
		}
		else {
			std::cout << "NA" << std::endl;
		}
	}
	else {
		std::cout << "NA" << std::endl;
 	}
	return 0;
}

Measured memory_bytes: 3616
from collections import deque
N = 3
def g(i, j, a):
    if i > j:
        i, j = j, i
    return a[:i] + a[j] + a[i + 1:j] + a[i] + a[j + 1:]
goal = "123456780"
def solve():
    m = {8:{7, 5}, 7:{8, 6, 4}, 6:{7, 3}, 5:{8, 4, 2}, 4:{7, 5, 3, 1}, 3:{6, 4, 0}, 2:{5, 1}, 1:{4, 2, 0}, 0:{3, 1}}
    MAP = "".join(input().replace(" ", "") for _ in range(N))
    if MAP == goal:
        return 0
    start = MAP.find("0")
    dp = deque([(0, MAP, start, 1), (0, goal, 8, 0)])
    TABLE = {MAP:(1, 0), goal:(0, 0)}
    while dp:
        cnt, M, yx, flg = dp.popleft()
        cnt += 1
        for nyx in m[yx]:
            CM = g(yx, nyx, M)
            if CM in TABLE:
                if TABLE[CM][0] != flg:
                    return TABLE[CM][1] + cnt
                continue
            TABLE[CM] = (flg, cnt)
            dp.append((cnt, CM, nyx, flg))
def MAIN():
    print(solve())
MAIN()



Measured memory_bytes: 8884
def solve(n, a):
    ans = 0
    for i in range(n):
        while a[i] % 2 == 0:
            a[i] /= 2
            ans += 1
    return ans

assert solve(3, [5,2,4]) == 3
assert solve(4, [631,577,243,199]) == 0
assert solve(10, [2184,2126,1721,1800,1024,2528,3360,1945,1280,1776]) == 39

n = input()
a = map(int, raw_input().split())
print solve(n, a)

Measured memory_bytes: 3460
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define ll long long int
#define lim 100010
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define ABS(x) ((x)>0?(x):-(x))

int compare_int(const void *a, const void *b){return *(int*)a - *(int*)b;}

int main(void){
	int n;
	scanf("%d",&n);
	int s;
	int sum=0,t=200;;
	for(int i=0;i<n;i++){
		scanf("%d",&s);
		sum += s;
		if(s%10!=0)t=MIN(t,s);
	}
	if(sum%10!=0)printf("%d",sum);
	else if(t!=200) printf("%d",sum-t);
	else printf("0");
	
	return 0;
}

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

typedef long long ll;
const int N=1e5+10;

int n,m,v,p;
int a[N];

bool check(int mid){
	ll ans=0;
	if(a[mid]+m<a[p]) return false;
	for(int i=1;i<=n;i++){
		if(i>=p&&i<mid) ans+=(ll)(a[mid]+m-a[i]);
		else ans+=(ll)m;
	}
//	cout<<' '<<ans<<endl; 
	if((ll)m*(ll)v>ans) return false;
	return true;
}

bool cmp(int a,int b){
	return a>b;
}

int main(){
	cin.tie(0);
	cin>>n>>m>>v>>p;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1,cmp);
	int l=1,r=n;
	while(l<r){
		int mid=(l+r+1)>>1;
		if(mid<=p) l=mid;
		else if(check(mid)) l=mid;
		else r=mid-1;
//		cout<<l<<' '<<r<<' ';
//		cout<<check(mid)<<endl;
	}
	cout<<l<<endl;
	return 0;
}
/*
	while(r>=l){
        mid=(r+l)>>1;
       // cout << "*******" << '\n';
        ll z=check(mid);
        if(z<m)
        r=mid-1;
        else{
            l=mid+1;
        }
    }
*/

Measured memory_bytes: 640
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll a,b,c;
int32_t main(){
CODE_START;
cin>>a;
cin>>b;
cin>>c;
a=a-c;
cout<<a/(b+c);
return 0;}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const long long int MOD = 1000000007;
const int MAXN = 200005;
long long int fact[MAXN];
long long int power(long long int a, int b)
{
	if(!b)
		return 1;
	long long int ans = power(a,b/2);
	ans = (ans*ans)%MOD;
	if(b%2)
		ans = (ans*a)%MOD;
	return ans;
}
long long int ways(int r1, int c1, int r2, int c2)
{
	if(r1 > r2 || c1 > c2)
		return 0;
	long long int ans = fact[r2 + c2 - r1 - c1];
	ans = (ans * power(fact[r2 - r1], MOD - 2))%MOD;
	ans = (ans * power(fact[c2 - c1], MOD - 2))%MOD;
	return ans;
}
int main()
{
	fact[0] = 1;
	for (int i = 1; i < MAXN; ++i)
	{
		fact[i] = (fact[i-1] * i)%MOD;
	}
	int h,w,a,b;
	cin>>h>>w>>a>>b;
	long long int ans = 0;
	for (int i = 0; i < h - a; ++i)
	{
		ans = (ans + ways(0,0,i,b-1)*ways(i,b,h-1,w-1))%MOD;
	}
	cout<<ans<<"\n";
	return 0;
}

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


int main()
{
    struct dice{
        int top;
        int south;
        int east;
        int north;
        int west;
        int bottom;
    };

    int n1,n2,n3,n4,n5,n6;
    cin >> n1 >> n2 >> n3 >> n5 >> n4 >> n6;
    string order;
    cin >> order;
    int len = order.size();

    dice before = {n1,n2,n3,n4,n5,n6};
    dice after = {n1,n2,n3,n4,n5,n6};

    rep(i,len){
        before = after;
        if(order[i]=='E'){
            after ={before.west,before.south,before.top,before.north,before.bottom,before.east};
        }else if(order[i]=='N'){
            after ={before.south,before.bottom,before.east,before.top,before.west,before.north};
        }else if(order[i]=='S'){
            after ={before.north,before.top,before.east,before.bottom,before.west,before.south};          
        }else{
            after ={before.east,before.south,before.bottom,before.north,before.top,before.west};
        }
    }

    cout << after.top << endl;

    return 0;

}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

ll modPow(ll n, ll p, ll mod) {
    n %= mod;
    // return (n^p) % mod
    if (p == 0)
        return 1;
    ll res = modPow(n * n % mod, p / 2, mod);
    if (p % 2 == 1)
        res = res * n % mod;
    return res;
}

struct combination {
    combination(ll Nmax, ll mod) {
        (this->MOD) = mod;
        (this->Nmax) = Nmax;
        factorial.resize(Nmax + 1, 1);
        inverse_factorial.resize(Nmax + 1, 1);
        init_factorial();
    }

    ll calc(ll n, ll r) {
        if (r < 0 || r > n)
            return 0;
        ll ret = (factorial[n] * inverse_factorial[r]) % MOD;
        ret = (ret * inverse_factorial[n - r]) % MOD;
        return ret;
    }

    vector<ll> factorial;
    vector<ll> inverse_factorial;

private:
    ll MOD, Nmax;

    void init_factorial() {
        for (ll i = 1; i <= Nmax; i++) {
            factorial[i] = (factorial[i - 1] * i) % MOD;
        }
        inverse_factorial[Nmax] = modPow(factorial[Nmax], MOD - 2, MOD);
        for (ll i = Nmax - 1; i >= 1; i--) {
            inverse_factorial[i] = (inverse_factorial[i + 1] * (i + 1)) % MOD;
        }
    }
};

int main() {
    ll N, M, K;
    cin >> N >> M >> K;
    ll mod = 998244353;
    combination con(N, mod);

    ll ans = 0;
    for (int i = 0; i <= K; i++) {
        ll temp = con.calc(N - 1, i);
        temp = (temp * M) % mod;
        temp = temp * modPow(M - 1, N - 1 - i, mod);
        temp %= mod;
        ans = (ans + temp) % mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6364
using System;
using static System.Console;
class program{
  static void Main(string[] args){
    program p = new program();
    p.Run();
  }
  void Run(){
    int a=int.Parse(ReadLine());
    ReadLine();
    ReadLine();
    ReadLine();
    int e=int.Parse(ReadLine());
    int k=int.Parse(ReadLine());
    
    if (Math.Abs(e-a) <=k){
      WriteLine("Yay!");
    }else{
      WriteLine(":(");
    }
  }
}

Measured memory_bytes: 11092
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main() {
  int N;
  cin >> N;
  vector<int> plist(N + 2);
  int acc = 0;

  plist[0] = 0;
  for (int i = 1; i <= N; i++) {
    cin >> plist[i];
    acc += abs(plist[i] - plist[i - 1]);
  }
  plist[N + 1] = 0;
  acc += abs(plist[N + 1] - plist[N]);

  for (int i = 1; i <= N; i++) {
    int ans = acc;
    ans -= abs(plist[i] - plist[i - 1]);
    ans -= abs(plist[i + 1] - plist[i]);
    ans += abs(plist[i + 1] - plist[i - 1]);
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 1664
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}
ll f(vector<ll> &r, vector<ll> &g, vector<ll> &b) {
  ll ans = 0;
  for(auto x: r) {
    auto it = upper_bound(g.begin(), g.end(), x);
    for(; it!=g.end(); it++) {
      auto itt = upper_bound(b.begin(), b.end(), *it);
      for(; itt!=b.end(); itt++) {
	if(*it-x == *itt-*it) continue;
	ans++;
      }
    }
  }
  return ans;
}

void solve(long long N, std::string S){
  ll ans = 0;
  vector<ll> r;
  vector<ll> g;
  vector<ll> b;
  for(ll i=0; i<N; i++) {
    if(S[i]=='R')
      r.push_back(i+1);
    else if(S[i]=='G')
      g.push_back(i+1);
    else
      b.push_back(i+1);
  }
  sort(r.begin(), r.end());
  sort(g.begin(), g.end());
  sort(b.begin(), b.end());
  ans += f(r, g, b);
  ans += f(r, b, g);
  ans += f(g, r, b);
  ans += f(g, b, r);
  ans += f(b, r, g);
  ans += f(b, g, r);
  

  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::string S;
  std::cin >> S;
  solve(N, S);
  return 0;
}



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

typedef signed long long ll;
typedef long double ld;

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

#define DEBUG

int main()
{
	int n, l;
	int ans = 0;

	cin >> n >> l;

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

	if((l-n) < 0 && l > 0)
	{
		cout << ans << endl;
	}
	else if(ans >= 0)
	{
		ans -= (l - n);
		cout << ans << endl;
	}
	else
	{
		ans -= l - 1;
		cout << ans << endl;
	}

	return 0;
}


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

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	if(n<105){
		cout<<0<<'\n';
	}
	else if(n<135){
		cout<<1<<'\n';
	}
	else if(n<165){
		cout<<2<<'\n';
	}
	else if(n<189){
		cout<<3<<'\n';
	}
	else if(n<195){
		cout<<4<<'\n';
	}
	else{
		cout<<5<<'\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    lint ret = 0;
    for (int i = 0; i < n; ++i) {
        vector<string> t(n, string(n, 'a'));
        for (int j = 0; j < n; ++j) {
            for (int k = 0; k < n; ++k) {
                t[j][k] = s[j][(k + i) % n];
            }
        }
        bool ok = true;
        [&] {
            for (int j = 0; j < n; ++j) {
                for (int k = 0; k < n; ++k) {
                    if (t[j][k] != t[k][j]) {
                        ok = false;
                        return;
                    }
                }
            }
        }();
        if (ok)
            ret += n;
    }
    cout << ret << "\n";
    return 0;
}

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

double x[200],y[200];
double ans[2000];

int main(){
	int n;scanf("%d",&n);
	rep(i,n)scanf("%lf%lf",&x[i],&y[i]);
	double R=1e11;
	double K=1000000;
	rep(i,K){
		double rad=2*M_PI*i/K;
		double X=cos(rad)*R,Y=sin(rad)*R;
		double Min=INFINITY;
		int id=-1;
		rep(j,n){
			double d=hypot(X-x[j],Y-y[j]);
			if(d<Min){
				Min=d;id=j;
			}
		}
		ans[id]+=1/K;
	}
	rep(i,n){
		printf("%.7lf\n",ans[i]);
	}
}

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

signed main(void)
{
	long long sum;
	int n;
	cin >> n;
	vector<long long> a(n, 0), x(n, 0);

	sum = 0;
	rep(i, n)
	{
		cin >> a[i];
		sum += a[i];
	}
	x[0] = sum;
	for(int i = 1; i < n; i+=2)
		x[0] -=  2 * a[i]; 
	rep(i, n - 1)
	{
		x[i + 1] = 2 * a[i] - x[i];
	}
	rep(i, n)
		printf("%d%c", x[i], i==n-1?'\n':' ');
	return 0;
}


Measured memory_bytes: 2816
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as M
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM





getBysplit = map read . words <$> getLine


count :: [String] -> [Int]
count lst = let
              xs = if (head . head) lst == '0' then [] : lst else lst
              ys = if (head . last) lst == '0' then xs ++ [] else xs
            in map length ys


solve :: Int -> V.Vector Int -> Int -> Int
solve width vec limit = foldl f 0 [0,2..limit]
      where
        f acc x = let
                    left = vec V.! x
                    right = vec V.! min (x + width) limit
                  in max (right - left) acc

main :: IO ()
main = do
  [n, k] <- getBysplit :: IO [Int]
  s <- getLine :: IO String
  let nums = (count . group) s --group 連続するものをリストに分割して二次元リストを返す
  let sums = scanl (+) 0 nums -- 累積和を作成する関数
  let width = 2 * k + 1
  let vec = V.fromList  sums
  let limit = length nums
  print $ solve width vec limit


Measured memory_bytes: 30076
#pragma GCC optimize("Ofast,fast-math,unroll-loops")

#include <bits/stdc++.h>

#define int ll
//#define double long double
//#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
#define PI 3.14159265358979

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;

/*
const ll MAX_MEM = 3e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/

template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}

template <class T>
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}

template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}

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

inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

signed main()
{
    Start();
    ld r;
    cin >> r;
    cout << r * r;
    return 0;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
#define M 1000000007
using namespace std;
string g[2];
bool hori[52];
long long mem[53][2][2][2][2][2][2];
int n;
long long C(int i, bool canRtop, bool canCtop, bool canYtop, bool canRbot, bool canCbot, bool canYbot) {
    if(mem[i][canRtop][canCtop][canYtop][canRbot][canCbot][canYbot] == -1) {
        long long ans;
        if(i == n) {
            ans = 1;
        } else if(hori[i]) {
            ans = 0;
            if(canRtop && canCbot) {
                ans += C(i + 2, 0, 1, 1, 1, 0, 1);
                ans %= M;
            }
            if(canRtop && canYbot) {
                ans += C(i + 2, 0, 1, 1, 1, 1, 0);
                ans %= M;
            }
            if(canCtop && canRbot) {
                ans += C(i + 2, 1, 0, 1, 0, 1, 1);
                ans %= M;
            }
            if(canCtop && canYbot) {
                ans += C(i + 2, 1, 0, 1, 1, 1, 0);
                ans %= M;
            }
            if(canYtop && canRbot) {
                ans += C(i + 2, 1, 1, 0, 0, 1, 1);
                ans %= M;
            }
            if(canYtop && canCbot) {
                ans += C(i + 2, 1, 1, 0, 1, 0, 1);
                ans %= M;
            }
        } else {
            ans = 0;
            if(canRtop && canRbot) {
                ans += C(i + 1, false, true, true, false, true, true);
                ans %= M;
            }
            if(canCtop && canCbot) {
                ans += C(i + 1, true, false, true, true, false, true);
                ans %= M;
            }
            if(canYtop && canYbot) {
                ans += C(i + 1, true, true, false, true, true, false);
                ans %= M;
            }
        }
        mem[i][canRtop][canCtop][canYtop][canRbot][canCbot][canYbot] = ans;
    }
    return mem[i][canRtop][canCtop][canYtop][canRbot][canCbot][canYbot];
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> g[0] >> g[1];
    for(int i = 0; i < n; i++) {
        hori[i] = g[0][i] != g[1][i];
    }
    memset(mem, -1, sizeof mem);
    cout << C(0, 1, 1, 1, 1, 1, 1) << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a_list = []
first = 0
second = 0
for i in range(n):
    a = int(input())
    if a >= first:
        second = first
        first = a
    elif a >= second:
        second = a
    a_list.append(a)

for i in a_list:
    if i == first:
        print(second)
    else:
        print(first)

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

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

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

int main(){
		
	double A, B, H, M;
	double degA, degB;
	
	cin >> A >> B >> H >> M;
	
	double T = H / 12.0 + M / 60.0 / 12.0;
	degA = 2.0 * M_PI * T;
	degB = 2.0 * M_PI * M / 60.0;
	
	double Ax = A *cos(degA);
	double Ay = A *sin(degA);
	
	double Bx = B *cos(degB);
	double By = B *sin(degB);
	
	cout << std::fixed << std::setprecision(12) << sqrt( (Ax - Bx) * (Ax - Bx) + (Ay - By) * (Ay - By) );
	
	return 0;
	
}


Measured memory_bytes: 4116
#include <bits/stdc++.h>
using namespace std;
int INF = 10000000;
int main(){
  while (1){
    int d, w;
    cin >> d >> w;
    if (d == 0 && w == 0){
      break;
    }
    vector<vector<int>> e(d, vector<int>(w));
    for (int i = 0; i < d; i++){
      for (int j = 0; j < w; j++){
        cin >> e[i][j];
      }
    }
    int ans = 0;
    for (int i = 0; i < d; i++){
      for (int j = i + 2; j < d; j++){
        for (int k = 0; k < w; k++){
          for (int l = k + 2; l < w; l++){
            int mn = INF;
            for (int y = i; y <= j; y++){
              for (int x = k; x <= l; x++){
                if (y == i || y == j || x == k || x == l){
                  mn = min(mn, e[y][x]);
                }
              }
            }
            bool ok = true;
            int sum = 0;
            for (int y = i + 1; y <= j - 1; y++){
              for (int x = k + 1; x <= l - 1; x++){
                if (e[y][x] >= mn){
                  ok = false;
                } else {
                  sum += mn - e[y][x];
                }
              }
            }
            if (ok){
              ans = max(ans, sum);
            }
          }
        }
      }
    }
    cout << ans << endl;
  }
}


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

int main(){
    int n,m; cin>>n>>m;
    int cnt=0;
    vector<int> ball(n,1);
    vector<bool> red(n,false);
    red[0] = true;

    for(int i=0; i<m; i++){
        int bef,aft;
        cin>>bef>>aft;
        bef--; aft--;
        ball[bef]--;
        ball[aft]++;
        if(red[bef])red[aft] = true;
        if(ball[bef] == 0){
            red[bef] = false;
        }
    }

    for(int i=0; i<n; i++){
        if(red[i])cnt++;
    }   

    cout<<cnt<<endl;

    return 0;
}

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

int main() {
    int N, _N, SN = 0;
    cin >> N;
    _N = N;

    while (N > 0) {
        SN += N % 10;
        N /= 10;
    }

    if (_N % SN == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main (void){
  int a,b,c = 0;

  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);

  if(21 - (a+b+c) >= 0){
    printf("win\n");
  }else{
    printf("bust\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
int pre[200005]; //里面全是掌门
set<int> st;
int boom[200005];
int a[200005],b[200005];
int unionsearch(int root)
{
	int son, tmp;
	son = root;
	while(root != pre[root]) //寻找掌门ing……
		root = pre[root];
	while(son != root) //路径压缩
	{
		tmp = pre[son];
		pre[son] = root;
		son = tmp;
	}
	return root; //掌门驾到~
}

int main()
{
    int n,m;cin>>n>>m;
    int mx=0;
    for(int i=1;i<=n;i++)
    {
        pre[i]=i;
    }
    int sum=n;
    for(int i=0;i<m;i++)
    {
        cin>>a[i]>>b[i];
        int t1=unionsearch(a[i]);
        int t2=unionsearch(b[i]);
        if(t1!=t2)
        {
            pre[t1]=t2;
        }
    }
    for(int i=1;i<=n;i++)
    {
        int t1=unionsearch(i);
        if(t1!=pre[i])
        {
            pre[i]=t1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        st.insert(pre[i]);
        boom[pre[i]]++;
        mx=max(boom[pre[i]],mx);
    }
    cout<<mx<<endl;
	return 0;
}


Measured memory_bytes: 14348
let solve (n, q) =
  let s = Array.init n (fun i -> i) in
  let rec find u =
    if u = s.(u) then u
    else begin
      s.(u) <- find s.(u);
      s.(u)
    end in
  for _ = 0 to q - 1 do
    let (n, x, y) = Scanf.scanf "%d %d %d " (fun n x y -> (n, x, y)) in
    if n = 0 then s.(find x) <- find y
    else print_endline (if find x = find y then "1" else "0")
  done

let () = Scanf.scanf "%d %d " (fun n q -> (n, q)) |> solve

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

int main(void){
    int n = 0; 
    long long int l[101];
    int ans = 0;

    scanf("%d", &n);
/*    if(n < 3){
        printf("0\n");
        return 0;
    }
*/
    for(int i = 0; i < n; i++){
        scanf("%lld", &l[i]);
    }

    for(int i = 0; i < n - 2; i++){
        for(int j = i + 1; j < n - 1; j++){
            if(l[j] != l[i]){
                for(int k = j + 1; k < n; k++){
                    if(l[k] != l[i] && l[k] != l[j]){
    
                        if( l[i] < l[j] + l[k] && l[i] > l[j] && l[i] > l[k]){
                            ans++;
//                            printf("a ");
                        }else if(l[j] < l[i] + l[k] && l[j] > l[i] && l[j] > l[k]){
                            ans++;
//                            printf("b ");
                        }else if(l[k] < l[i] + l[j] && l[k] > l[i] && l[k] > l[j]){
                            ans++;
//                            printf("c ");
                        }
//                        printf("i=%d, j=%d, k=%d\n", i + 1, j + 1, k+1);
                    }
                }
            }
        }
    }

    printf("%d\n", ans);
    return 0;

} 



Measured memory_bytes: 3836
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int AB = scan.nextInt();
        int BC = scan.nextInt();
        int CA = scan.nextInt();
        System.out.println(AB*BC/2);
    }
}


Measured memory_bytes: 22612
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define MOD 1000000007
using namespace std;
typedef long long ll;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

inline ll fastpow(ll bas, ll ex){
	register ll res = 1; bas %= MOD;
	for(; ex; ex >>= 1, bas = bas * bas % MOD) if(ex & 1) res = res * bas % MOD;
	return res;
}

inline int kazu(int a, const int &b) {return (a += b) >= MOD ? a - MOD : a;}
inline int hiku(int a, const int &b) {return (a -= b) < 0 ? a + MOD : a;}

int N, H, D, fac[1000005] = {1}, sumfac = 0, isumfac, f[1000005], sumf;

int main(){
	getint(N), getint(H), getint(D);
	for(register int i = 1; i <= N; i++) fac[i] = fac[i - 1] * (ll)i % MOD;
	for(register int i = 1; i <= N; i++) sumfac = kazu(sumfac, fac[i]);
	isumfac = fastpow(sumfac, MOD - 2), sumf = f[0] = 1;
	for(register int i = 1; i <= H; i++){
		if(i > D) sumf = hiku(sumf, f[i - D - 1]);
		f[i] = sumf * (ll)sumfac % MOD, sumf = kazu(sumf, f[i]);
	}
	return printf("%lld\n", f[H] * (ll)fac[N] % MOD * isumfac % MOD), 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b[110000];
double d[110000],e=0.0;
string s;
signed main()
{
	cin>>a;
	rep(i,a){
		cin>>b[i];
		d[i]=b[i]*1.0;
		e+=1/d[i];
	}
	printf("%.7f",1/e);
}

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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			C();
		}

		public static void C()
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			int k = cin.Int();
			double rate = 0;
			double oldRate = 0;
			double coef = 1.0 / n;


			for (int i = n; i >= 1; --i) {
				if (i >= k) {
					rate += coef;
				} else {
					int n2 = i;
					int count = 1;
					while (n2 < k) {
						count += 1;
						n2 *= 2;
					}
					
					int num = count - 1;
					rate += coef * Math.Pow(0.5, num);
				}

				/*
				if (rate - oldRate < 1e-9) {
					Console.WriteLine(rate);
					return;
				}*/
			}

			Console.WriteLine(rate);
		}
	}

	public class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}


		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 11092
//https://agc013.contest.atcoder.jp/tasks/agc013_e#
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
int in[MAXN], s[MAXN], len, m;
class Ma
{
public:
    static const int N = 3;
    int m[4][4];
    Ma() { memset(m, 0, sizeof(m)); };
    Ma(int t)
    {
        memset(m, 0, sizeof(m));
        if (t == 1)
        {
            for (register int i = 1; i <= 3; ++i)
                m[i][i] = 1;
        }
    }
    friend Ma operator*(const Ma &a, const Ma &b)
    {
        Ma rec(0);
        for (register int i = 1; i <= N; ++i)
        {
            for (register int k = 1; k <= N; ++k)
            {
                for (register int j = 1; j <= N; ++j)
                {
                    rec.m[i][j] = (rec.m[i][j] + (long long)a.m[i][k] * b.m[k][j] % MOD) % MOD;
                }
            }
        }
        return rec;
    }
    inline void out()
    {
        for(register int i  =1; i <= N; ++i)
        {
            for(register int j = 1; j <= N; ++j)
            {
                cerr << m[i][j] <<" ";
            }
            cerr << '\n';
        }
    }
} m1, m2;
template <typename T>
T power(T a, int b)
{
    T rec(1);
    for (; b; b >>= 1)
    {
        if (b & 1)
            rec = rec * a;
        a = a * a;
    }
    return rec;
}
int main()
{
#ifdef lky233
    freopen("testdata.in", "r", stdin);
    freopen("testdata.out", "w", stdout);
#endif
    m1.m[1][1] = m1.m[2][1] = m1.m[2][2] = m1.m[3][1] = m1.m[3][3] = 1;
    m1.m[3][2] = 2;
    m2.m[1][1] = m2.m[1][3] = m2.m[2][1] = m2.m[2][2] = m2.m[2][3] = m2.m[3][1] = 1;
    m2.m[3][2] = m2.m[3][3] = 2;
    // m1.out(),m2.out();
    cin >> len >> m;
    for (register int i = 1; i <= m; ++i)
        cin >> in[i];
    for (register int i = 1; i <= m; ++i)
        s[i] = in[i] - in[i - 1] - 1;
    s[++m] = len - in[m - 1];
    Ma ans(1);
    for (register int i = 1; i <= m; ++i)
    {
        ans = ans * power<Ma>(m2, s[i]);
        if (i < m)
            ans = ans * m1;
    }
    cout << ans.m[3][1] << '\n';
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <utility>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long int H, W; cin >> H >> W;
  char a[110][110];
  for (int j = 0; j < H; j++) {
    for (int i = 0; i < W; i++)
      cin >> a[j][i];
  }
  int h[110]; int w[110];
  for (int i = 0; i < 110; i++) {
    h[i] = 1; w[i] = 1;
  }
  for (int i = 0; i < W; i++) {
    int c = 0;
    for (int j = 0; j < H; j++)
      c += (a[j][i] == '.');
    if (c == H)
      w[i] = 0;
  }
  for (int j = 0; j < H; j++) {
    int c = 0;
    for (int i = 0; i < W; i++)
      c += (a[j][i] == '.');
    if (c == W)
      h[j] = 0;
  }
  for (int j = 0; j < H; j++) {
    for (int i = 0; i < W; i++) {
      if (!(h[j] == 0 || w[i] == 0))
        cout << a[j][i];
    }
    if (h[j] != 0)
      cout << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
struct UnionFind{
    int n;
    set<int> dame;
    vi p;
    vi use;
    UnionFind(int N):n(N){
        p.resize(n);
        use.resize(n);
    	iota(all(p),0);
    	rep(i,n){
    	    int tmp;
    	    cin>>tmp;
    	    unite(i,tmp+i);
    	}
    }
    void unite(int a, int b){int c=root(a),d=root(b); if(c!=d) p[c]=d; else if(a!=b) dame.insert(root(a));}
    int root(int a){return p[a]=(p[a]==a?a:root(p[a]));}
    bool same(int a, int b){return root(a)==root(b);}
    void useable(){
        rep(i,n){
            use[i]=dame.find(root(i))==dame.end();
        }
    }
};
int main(){
	int n;
	cin>>n;
	UnionFind uf(n);
	uf.useable();
    vi turn(n,-1);
    turn[0]=0;
    queue<int> que;
    que.push(0);
    while(turn[n-1]==-1){
        int c=que.front();que.pop();
        range(d,1,7){
            if(c+d<n && uf.use[c+d] && turn[uf.p[c+d]]==-1){
                que.push(uf.p[c+d]);
                turn[uf.p[c+d]]=turn[c]+1;
            }
        }
    }
    cout<<turn[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 4624
#include<stdio.h>

int main(){
    int n, i, j, k, work,sum=0;
    int kushi[200]={};

    scanf("%d",&n);

    

    for(i=0;i<n*2;i++){
        scanf("%d",&kushi[i]);
    }

    for(i=0;i<n*2;i++){
        for(j=i+1;j<n*2;j++){
            if(kushi[i]<kushi[j]){
               work = kushi[i];
               kushi[i] = kushi[j];
               kushi[j] = work; 
            }
        }
    }

    for(k=1;k<n*2;k+=2){
        sum += kushi[k];
    }

    printf("%d",sum);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

const string suffix[] = {"dream", "dreamer", "erase", "eraser"};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    int n = s.length();
    int p = n;
    
    while(p) {
        bool f = false;
        
        rep(i, 4) {
            int l = suffix[i].length();
            
            if (p < l) {
                continue;
            }
            
            string ss = s.substr(p - l, l);
            
            if (ss == suffix[i]) {
                f = true;
                p -= l;
                break;
            }
        }
        
        if (!f) {
            cout << "NO" << endl;
            return 0;
        }
    }
    
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 512