akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
typedef long double ld;
int n,a,b,c,ans;
string s;
signed main(){
cin >>s;
if(s[2]==s[3]&&s[4]==s[5]){
cout <<"Yes";
}else{
  cout <<"No";
}
}

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

using namespace std;

int main(){
    int N, X; cin >> N >> X;
    int ans = 1, sum = 0;
    for (int i = 0; i < N; i++){
        int a; cin >> a;
        sum += a;
        if (sum <= X){
            ans ++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("codefi.txt", "r", stdin);
	freopen("codefo.txt", "w", stdout);
#endif

	int n, k;
	cin >> k >> n;
	int a[n];
	int i;
	fo(i, n)
	cin >> a[i];
	int m = 0;

	for (int i = 0; i<n - 1; i++)
	{
		if (i == 0)
		{
			int tmp = a[i] + k - a[n - 1];
			m = max(tmp, m);
		}
		else
		{
			m = max(m, a[i + 1] - a[i]);
		}
	}
	int mm=m;
	cout << k-mm << endl;
}

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

int main() {
  string S, T;

  cin >> S;
  cin >> T;
  int N = 0;
  for(int i=0; i<S.size(); i++) {
    if(S[i]!=T[i]) N++;
  }
  cout << N << endl;
  return 0;
}

Measured memory_bytes: 3832
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include<bits/stdc++.h>
using namespace std;
#define  fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll         long long
#define  debug      printf("Come here!")
#define  inf        1000000000000000000
#define  pb         push_back
#define  mp         make_pair
#define  sz(a)      a.size()
#define  mem(a,b)   memset(a,b,sizeof(a))
#define  clr(x)     x.clear()
#define  ff         first
#define  ss         second
#define  case(x)    cout << "Case " << x <<": "

#define  md         1000000007
#define  pi         acos(-1.0)
#define  cos(a)     cos(a*pi/180)
#define  sin(a)     sin(a*pi/180)
#define  tan(a)     tan(a*pi/180)
#define  cosi(a)    acos(a)/(pi/180)
#define  sini(a)    asin(a)/(pi/180)
#define  tani(a)    atan(a)/(pi/180)

#define  vl         vector <ll>
#define  vs         vector <string>
#define  vc         vector <char>
#define  vpll       vector < pair <ll, ll> >
#define  vpsl       vector < pair <string, ll> >
#define  vpls       vector < pair <ll, string> >
#define  pql        priority_queue<ll>
#define  minpql     priority_queue<ll,vector<ll>,greater<ll> >

#define  setbits(x)     __builtin_popcountll(x)
#define  zerobits(x)    __builtin_ctzll(x)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}

/* mpp.max_load_factor(0.25); mpp.reserve(1024); */
/* cout << fixed << setprecision(12);*/

int main()
{
    fastt;
    ll n, m, k, i, j, x, y, p=0, s=0, h, f=0;
    cin>>n>>m;
    ll a[n];
    vpll v;
    for(i=0; i<n; i++){
        cin>>a[i];
    }
    for(i=0; i<m; i++){
        cin>>x>>y;
        v.pb(mp(y, x));
    }
    sort(v.begin(), v.end());
    sort(a, a+n);
    reverse(v.begin(), v.end());
    f=0;
    for(i=0; i<v.size(); i++){
        x=v[i].ff;
        y=v[i].ss;
        for(j=p, k=0; j<n && k<y; j++, k++){
            if(a[j]<x){
                a[j]=x;
                p++;
            }
            else{
                f=1;
                break;
            }
        }
        if(f==1)break;
    }
    for(i=0; i<n; i++)s+=a[i];

    cout<<s<<endl;

    return 0;
}



Measured memory_bytes: 6096
#include <stdio.h>
#include <math.h>

int primenum(int num) //素数なら１を返す
{
  int i; 

  if(num==2) return 1;
  if(num<2 || num%2==0) return 0;
  for(i=3;i<=sqrt(num);i+=2){
    if(num%i==0)  return 0;
  }
  return 1;
}

int main(){
  int n,i,count=0;
  scanf("%d",&n);

  int num[n];
  for(i=0;i<n;i++){
    scanf("%d",&num[i]);
  }
  for(i=0;i<n;i++){
    if((primenum(num[i]))==1){
      count++;
    }
  }
  printf("%d\n",count);

  return 0;
}


Measured memory_bytes: 2036
N, L = map(int, input().split())


lis = []
for n in range(1, N+1):
    azi = L + n - 1
    lis.append(azi)

lis2 = [abs(l) for l in lis]

min = lis2.index(min(lis2))
del lis[min]

print(sum(lis))

Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))
A = list(map(lambda x:x//400,A))
#print(A)
C = [0]*9
for a in A:
  if a>=8:
    C[8] +=1
  elif C[a]==0:
    C[a] = 1
#print(C[:-1])
mi = sum(C[:-1])
mini = mi
if mi == 0:
  mini = 1
ma = mi+C[-1]
print(mini,ma)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

typedef struct node{
    int num;
    struct node *next;
}Node;

void add(Node *node,int t){
    Node* nn;
    if(node->next==NULL){
    	nn = (Node*)malloc(sizeof(Node));
        nn->num=t;nn->next=NULL;
        node->next=nn;
    }else{
        add(node->next,t);
    }
}

void tansa(Node node[],int num,int color,int ban[]){
    ban[num]=color;
    for(Node *no=node[num].next;no!=NULL;no=no->next){
        if(ban[no->num]==-1){
            tansa(node,no->num,color,ban);
        }
    }
}

int main(void){
    int n,m,q;
    int i,j,s,t,c;
    int *ban;
    Node *nodes;
    scanf("%d %d",&n,&m);
    nodes = (Node*)malloc(sizeof(Node)*n);
    ban = (int*)malloc(sizeof(int)*n);
    for(i=0;i<n;i++){nodes[i].next=NULL;ban[i]=-1;}
    for(i=0;i<m;i++){
        scanf("%d %d",&s,&t);
        add(&nodes[s],t);add(&nodes[t],s);
    }
    c=0;
    for(i=0;i<n;i++){
        if(ban[i]==-1){
            tansa(nodes,i,c,ban);
            c++;
        }
    }
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d %d",&s,&t);
        if(ban[s]==ban[t]){
            printf("yes\n");
        }else{
            printf("no\n");
        }
    }
}


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

namespace Atcoder177
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());

            long[] A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            long wa = 0;
            long[] was = new long[N];

            long ans = 0;

            foreach (long a in A)
            {
                wa += a;
            }
            wa -= A[0];

            long mod = 1000000007;

            for (long i = 0; i < N - 1; i++)
            {
                if (i == 0)
                {
                    was[i] = wa;
                    continue;
                }

                was[i] = (was[i - 1] - A[i]);
            }

            for (long i = 0; i < N - 1; i++)
            {
                ans += (A[i] * (was[i] % mod)) % mod;
                ans %= mod;
            }

            Console.WriteLine(ans % mod);
        }
    }
}


Measured memory_bytes: 49180
n=int(input())
a=[0]
a.extend(list(map(int,input().split())))
a.append(0)
sa,x=0,0
for i in a:
    sa+=abs(x-i)
    x=i
x=0
for i in range(1,n+1):
    x=abs(a[i]-a[i-1])+abs(a[i+1]-a[i])-abs(a[i+1]-a[i-1])
    print(sa-x)

Measured memory_bytes: 14048
#include <stdio.h>

int main(int argc, char** argv)
{
	int i, j, k, h, l, cnt, n, x, result[1000];

	cnt = 0;
	
	memset(result, 0, sizeof(result));
	while (scanf("%d %d", &n, &x) != EOF) {
		int list_cnt = 0;
		int list[1500][3] = { { 0 } };
		for (i = 1; i <= n; i++) {
			if (i >= x) {
				break;
			}
			for (j = 1; j <= n; j++) {
				if (i == j) {
					continue;
				}

				int sum = i + j;
				if (sum >= x) {
					break;
				}

				for (k = 1; k <= n; k++) {
					if (i == k || j == k) {
						continue;
					}

					int sum = i + j + k;
					if (sum > x) {
						break;
					}
					else if (sum == x) {
						int ins_f = 1;
						for (h = 0; h < list_cnt; h++) {
							int match_cnt = 0;
							for (l = 0; l < 3; l++) {
								if (list[h][l] == i || list[h][l] == j || list[h][l] == k) {
									match_cnt++;
								}
							}

							if (match_cnt == 3) {
								ins_f = 0;
								break;
							}
						}

						if (ins_f) {
							list[list_cnt][0] = i;
							list[list_cnt][1] = j;
							list[list_cnt][2] = k;
							list_cnt++;
						}
						break;
					}
				}
			}
		}

		result[cnt] = list_cnt;

		if (n == 0 && x == 0) {
			break;
		}
		cnt++;
	}

	for (i = 0; i < cnt; i++) {
		printf("%d\n", result[i]);
	}
	return 0;
}

Measured memory_bytes: 628
n,m = map(int, input().split())
AB = []
for _ in range(n):
    a,b = map(int,input().split())
    AB.append((a,b))

AB.sort(key=lambda x:x[0])
# print(AB)
num = 0
money = 0
for i in range(n):
    if num+AB[i][1]<m:
        num += AB[i][1]
        money += AB[i][0]*AB[i][1]
    else:
        money += (m-num)*AB[i][0]
        print(money)
        break


Measured memory_bytes: 18164
#include <iostream>
using namespace std;
const int NM_MAX = 50;
int main (void) {
    int N;
    int M;
    string A[NM_MAX];
    string B[NM_MAX];

    cin >> N >> M;
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < M; i++) cin >> B[i];

    int H = N - M;
    int BW = B[0].length();
    int W = A[0].length() - BW;
    for (int i = 0; i <= H; i++) {
        for (int j = 0; j <= W; j++) {
            bool match = true;
            for (int k = 0; k < M; k++) {
                if (A[i + k].substr(j, BW) != B[k]) {
                    match = false;
                }
            }
            if (match) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
from fractions import gcd
import itertools
from scipy.misc import comb
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n, k = LI()
    for i in range(k):
        i += 1
        c_list = comb(n-k+1, i, exact=True)
        c = c_list % MOD
        d_list = comb(k-1, i-1, exact=True)
        d = d_list % MOD
        print(c * d % MOD)




if __name__ == "__main__":
    main()

Measured memory_bytes: 14048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, K;
    cin >> N >> K;
    vl P(N), C(N);
    rep(i, N) cin >> P[i], P[i]--;
    rep(i, N) cin >> C[i];

    vc<ll> used(N, -1), Score, R;

    ll usei = 0;
    rep(i, N) {
        if (used[i] != -1) continue;
        R.eb(1);
        ll si = P[i];
        ll v = C[si];
        used[si] = usei;
        while (si != i) {
            si = P[si];
            v += C[si];
            used[si] = usei;
            R.back()++;
        }
        usei++;
        Score.eb(v);
    }

    ll ans = *max_element(all(C));

    // rep(i, N) {
    //     ll id = used[i];
    //     ll sc = Score[id], num = R[id];
    //     ll k = K / num, r = K % num;
    //     ll tmp = (sc > 0 ? sc * k : 0);

    //     if (k > 0) chmax(ans, sc * k);

    //     ll si = i;
    //     rep(_, r) {
    //         si = P[si];
    //         tmp += C[si];
    //         chmax(ans, tmp);
    //     }

    //     if (r == 0) {
    //         ll g = max(0ll, K / num - 1) * sc;
    //         chmax(g, 0ll);
    //         if (K / num - 1 > 0) chmax(ans, (K / num - 1) * sc);
    //         ll ci = i;
    //         rep(_, num) {
    //             ci = P[ci];
    //             g += C[ci];
    //             chmax(ans, g);
    //         }
    //     }
    // }

    rep(i, N) {
        ll id = used[i];
        ll sc = Score[id], num = R[id];
        ll k = K / num, r = K % num;

        ll tmp = 0;
        if (k > 0) {
            k--, r += num;
            chmax(tmp, sc * k);
        }
        ll si = i;
        rep(_, r) {
            si = P[si];
            tmp += C[si];
            chmax(ans, tmp);
        }
    }

        cout << ans << endl;
        // verr(used, used.size());
        // verr(Score, Score.size());
        // verr(R, R.size());
}

Measured memory_bytes: 3712
#include <cstdio>
#include <iostream>
#define abs(x) (x>0?x:-x)
long long a[1001],s[1001],b[1000000];
int main( ) {
	int n,k;
	long long ans=0;
	std::cin >> n >> k;
	for (int i=1; i<=n; ++i) {
		std::cin >> a[i];
		s[i] = s[i-1] + a[i];
	}
	for (int i=1; i<=n; ++i) 
		for (int j=1; j<=i; ++j){
			b[++b[0]] = s[i] - s[j-1];
//			std::cout << b[b[0]] << std::endl;
		}
	for (int j=40; ~j; --j) {
		int cur=0;
		for (int i=1; i<=b[0]; ++i) {
			if ((b[i] & ans) == ans && (b[i] & (1ll<<j))) ++cur;
		}
		if (cur >= k) ans |= 1ll<<j;
	}
	std::cout << ans << std::endl;
}


Measured memory_bytes: 4352
/**
*    created: 12.05.2020 12:38:55
**/
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n; cin >> n;
    int f[50];
    f[0] = f[1] = 1;
    rep2(i,2,50) {
        f[i] = f[i-1] + f[i-2];
    }
    cout << f[n] << endl;


    return 0;
}


Measured memory_bytes: 3164
#include<stdio.h>
#include<stdlib.h>
int main(){
  int j,i,n,A[100000],x,temp;
  scanf("%d",&n);
  for(i=1;i<=n;i++)  scanf("%d",&A[i]);
  x=A[n];
  i=0;
  for(j=1;j<n;j++){
    if(A[j]<=x){
      i++;
      temp=A[i];
      A[i]=A[j];
      A[j]=temp;
    }
  }
  temp=A[i+1];
  A[i+1]=A[n];
  A[n]=temp;
  for(j=1;j<=n;j++){
    if(j==i+1) printf("[");
    printf("%d",A[j]);
    if(j==i+1) printf("]");
    if(j!=n) printf(" ");
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std ; 
# define pb push_back
# define ll long long 
# define endl "\n"

void solve() {
	int n ; 
  	cin >> n ; 
  	
  	string s ; 
  	string tmp[] = { "AC" , "WA" , "TLE" , "RE"} ; 
  	int ac = 0 , wa = 0 , tle = 0 , re = 0 ; 
  	for(int i  =0 ; i < n ; ++i){
  		cin >> s ; 
  		if(s == tmp[0])
  			++ac ; 
  		else if(s == tmp[1])
  			++wa; 
  		else if(s==tmp[2])
  			++tle; 
  		else 
  			++re; 
  	}

  	cout << tmp[0] << " x " << ac << endl ; 
  	cout << tmp[1] << " x " << wa << endl ; 
  	cout << tmp[2] << " x " << tle << endl ; 
  	cout << tmp[3] << " x " << re << endl ; 
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
   	int t; 
   	t=1; 
   	while(t--) {
   		//cout << "ANS : " ;
   		solve() ; 
   	}
    return 0; 
}

 

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const int INF=1<<30,MOD=1000000007;
const ll LINF=1ll<<60;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPARR(i,v) for(int i=0;i<v.size();++i)
#define all(v) (v).begin(),(v).end()
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define bit(n) (1ll<<(n))
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"":"im")<<"possible"<<endl
#define Poss(n) cout<<((n)?"P":"Imp")<<"ossible"<<endl
template<typename T>ostream&operator<<(ostream&o,const vector<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<typename T>ostream&operator<<(ostream&o,const set<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T,typename U>ostream&operator<<(ostream&o,const pair<T,U>&v){o<<v.first<<' '<<v.second;return o;}

int main(){
    string a="keyence";
    string s;
    cin>>s;
    int n=s.size();
    int ai=0;
    REP(i,7){ // mae
        cerr<<a[ai]<<s[i]<<endl;
        if(a[ai]==s[i]){
            ai++;
        }else{
            ai--;
            break;
        }
    }
    cerr<<ai<<endl;
    REP(i,1,7-ai){
        cerr<<a[7-i]<<s[n-i]<<endl;
        if(s[n-i]!=a[7-i]){
            YES(0);
            return 0;
        }
    }
    YES(1);
    return 0;
}


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

const int mxN = 1e5;
int h[mxN],dp[mxN+1],n,k;
array<int,3> s[mxN];

int main(){
    cin >> n ; 
    array<int,3> dp{0};
    for(int i=0 ; i< n ; ++i){
        array<int,3> ndp{0};
        array<int,3> cs;
        cin >> cs[0] >> cs[1] >> cs[2];

        for(int j = 0 ; j<3 ; j++){
            for(int k=0 ; k<3 ; k++){
                if(j!=k){
                    ndp[j] = max(ndp[j] , dp[k]+cs[j]);
                }
            }
        }
        dp = ndp;

    }   
    cout << max({dp[0],dp[1] , dp[2]});  
    
       
}

Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#define INF 1<<28
using namespace std;
 
int p[222];
int memo[1000001];
int memo2[1000001];
 
int solve(int n){

  if(!n) return 0;
  if(memo[n]) return memo[n];
   
  int ans = INF;
  for(int i=1;p[i]<=n; i++) ans = min(ans, solve(n-p[i])+1);
   
  return memo[n] = ans;
}
 
int solve2(int n){
   
  if(!n) return 0;
  if(memo2[n]) return memo2[n];
   
  int ans = INF;
  for(int i=1;p[i]<=n;i++){
    if(p[i]&1) ans = min(ans, solve2(n-p[i])+1);
  }
   
  return memo2[n] = ans;
}
 
int main(){
   
  int n;
   
  for(int i=0;i<=181;i++) p[i] = i*(i+1)*(i+2)/6;
  for(int i=1;i<=1000000;i+=100) solve(i), solve2(i);
   
  while(cin >> n, n) cout << solve(n) << " " << solve2(n) << endl;
}

Measured memory_bytes: 8976
using System;

class Program
{
    static void Main()
    {
    	var taro = 0;
    	var hanako = 0;
    	
    	var m = int.Parse(Console.ReadLine());
    		
		for(int i = 0; i < m; i++) {
			var w = Console.ReadLine().Split(' ');
			
			var result = string.Compare(w[0], w[1]);
			if(result > 0) {
				taro += 3;
			} else if (result < 0) {
				hanako += 3;
			} else {
				taro += 1;
				hanako += 1;
			}
		}
    	
    	Console.WriteLine(taro + " " + hanako);
    }
}

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

typedef long long ll;
const int MAX_N = 100030;    // Change as necessary
const ll  MODD = 1000000009; //

int A[MAX_N];

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int n; cin >> n;
  ll sum = 0, TT=0,AA=0;
  for(int i=0;i<n;i++){
    ll T,A; cin >> T >> A;
    ll k = max(1ll,max((TT+T-1)/T,(AA+A-1)/A));
    sum = k*(A+T);
    AA = k*A;
    TT = k*T;
  }
  
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));

 		
int main() {

int N,M;
cin>>N>>M;
int field[N+2][M+2];
vec(K);
int X=0;
fx(N){
	fy(M){
		cin>>field[x+1][y+1];
	}
}

fzg(N+1,1){
	fyg(M+1,1){
		if(field[z][y]%2==1){
			if(y+1<=M&&(z+1<=M&&field[z+1][y]%2==0)){
				field[z][y]--;field[z][y+1]++;
				//cout<<z<<' '<<y<<' '<<z<<' '<<y+1<<endl;
pb(K,z)pb(K,y)pb(K,z)pb(K,y+1)
X++;
			}else if(z+1<=N){
				field[z][y]--;field[z+1][y]++;
				//cout<<z<<' '<<y<<' '<<z+1<<' '<<y<<endl;
pb(K,z)pb(K,y)pb(K,z+1)pb(K,y)
X++;
			}else if(y+1<=M){
field[z][y]--;field[z][y+1]++;
				//cout<<z<<' '<<y<<' '<<z<<' '<<y+1<<endl;
pb(K,z)pb(K,y)pb(K,z)pb(K,y+1)
X++;
}
		}
	}
}
ce(X)
int i=0;
while(i<X*4){
cout<<K.at(i)<<' '<<K.at(i+1)<<' '<<K.at(i+2)<<' '<<K.at(i+3)<<endl;
i+=4;
}
	
}

Measured memory_bytes: 5104
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new _K(); }
class _K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public _K()
	{
		//SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		WriteLine(Solve());
		//Out.Flush();
	}
	int K, L;
	int[,,] sum;
	int Solve()
	{
		var I = G;
		K = I[1];
		L = 4 * K;
		sum = new int[L + 1, L + 1, 2];
		for (var i = 0; i < I[0]; i++)
		{
			var S = Strs;
			Add(int.Parse(S[0]) % (2 * K) + 1, int.Parse(S[1]) % (2 * K) + 1, S[2] == "B" ? 0 : 1);
		}
		for (var c = 0; c < 2; c++)
		{
			for (var x = 0; x < L; x++) for (var y = 0; y <= L; y++) sum[x + 1, y, c] += sum[x, y, c];
			for (var x = 0; x <= L; x++) for (var y = 0; y < L; y++) sum[x, y + 1, c] += sum[x, y, c];
		}
		var max = 0;
		for (var i = 0; i < 2 * K; i++)
		{
			for (var j = 0; j < 2 * K; j++)
			{
				var tmp = Sum(i, j, 0) + Sum(i + K, j + K, 0) + Sum(i, j + K, 1) + Sum(i + K, j, 1);
				//WriteLine($"{i} {j} {tmp}");
				max = Max(max, tmp);
			}
		}
		return max;
	}
	void Add(int x, int y, int c)
	{
		//WriteLine($"{x} {y} {c}");
		sum[x, y, c]++;
		sum[x + 2 * K, y, c]++;
		sum[x + 2 * K, y + 2 * K, c]++;
		sum[x, y + 2 * K, c]++;
		//WriteLine("OK");
	}
	int Sum(int i, int j, int c) => sum[i + K, j + K, c] - sum[i + K, j, c] - sum[i, j + K, c] + sum[i, j, c];
}


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

int main() {
	int a[3] = {0};
	for(int i = 0; i < 3; i++){
		cin >> a[i];
	}
	sort(a, a + 3);
	if(((a[0] == a[1]) && (a[1] != a[2])) || ((a[1] == a[2]) && (a[0] != a[1])))cout << "Yes" << '\n';
	else cout << "No" << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K; cin >> N >> K;
  vector<int> h(N);
  for(int i=0;i<N;i++){
    cin >> h[i];
  }
  sort(h.rbegin(),h.rend());
  int ans=0;
  for(int i=0;i<N;i++){
    if(K<=h[i]){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 1000000007
ll ar[5000];
ll solve(ll x){
if(x==3 || x==4 || x==5){
      return ar[x]=1;
     }
   if(x<3){
     return ar[x]=0;
    }
   if(ar[x]!=-1){
      return ar[x];
    }
   ll ans=1;
   for(int i=3;i<x;i++){
      ans+=solve(x-i);
    }
   return ar[x]=ans%mod;
}
int main() {
	ll x;
    cin>>x;
   memset(ar,-1,sizeof(ar));
   cout<<solve(x);
 
	return 0;
}

Measured memory_bytes: 3676
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        if (n % k != 0) {
            System.out.println(1);
        } else {
            System.out.println(0);
        }


    }

}




Measured memory_bytes: 22740
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define pii pair<int, int>
#define pll pair<long long, long long>
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<MOD>;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,M; cin >> N >> M;
    vector<ll> H(N),W(M);
    rep(i,N) cin >> H[i];
    rep(i,M) cin >> W[i];

    vector<mint> h(N-1),w(M-1);
    rep(i,N-1) h[i] = H[i+1] - H[i];
    rep(i,M-1) w[i] = W[i+1] - W[i];

    mint y = 0;
    mint x = 0;
    for (ll i = 0; i < N-1; i++) {
        y += h[i]*(i+1LL)*(N-1LL-i);
    }
    for (ll i = 0; i < M-1; i++) {
        x += w[i]*(i+1LL)*(M-1LL-i);
    }

    cout << (y*x).a << endl;
} 

Measured memory_bytes: 3456
# include <stdio.h>
# include <iostream>
# include <algorithm>
# include <math.h>
using namespace std;

int main(void){
    // Here your code !
    long long N, A, B;
    cin >> N >> A >> B;

    long long  H[N];

    for (long long i = 0; i < N; i++) {
        cin >> H[i];
    }

    long long start = 0;
    long long last = 1000000000;
    long long T, TB, SUM, temp;

    while (abs(last - start) > 1) {
        T = start + (last - start) / 2;
        TB = T * B;
        SUM = 0;
        for (int i = 0; i < N; i++) {
            temp = (H[i] - TB);
            if (temp > 0) SUM += (temp + (A - B) - 1) / (A - B);
        }
        // cout << start << " " << " " << last << endl;

        if (SUM > T) {start = T;}
        else {last = T;}

    }

    cout << last << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;
int N;
int a[201];
int main() {
	cin >> N;
	int cnt = 0;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	bool flag = true;
	for(;;){
		for (int i = 0; i < N; ++i) {
			if (a[i] % 2 == 0) {
				a[i] /= 2;
				if (i == N - 1) cnt++;
			}
			else {
				flag = false;
				break;
			}
		}
		if (!flag) break;
	}
	cout << cnt << endl;
	return 0;
}

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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(s) s.begin(),s.end()
#define vll vector<ll>
#define vi vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define vd vector<double>
#define vull vector<ull>
#define vc vector<char>
#define vs vector<string>
#define fi first
#define se second
#define sz(x) x.size()
#define cinarr(n,a) for(int i = 0; i < n; i++) cin >> a[i];
#define coutarr(n,a) for(int i = 0; i < n; i++) cout << a[i] << (i+1==n?'\n':' ');
#define fori(i,a,b,x) for(int i = a; i <= b; i+=x)
#define ford(i,a,b,x) for(int i = a; i >= b; i-=x)
#define tc int t; cin >> t; for(int cs = 1; cs <= t; cs++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define ld long double
#define reset(x,y) memset(x,y,sizeof x);
#define sqr(x) 1LL*(x)*(x)
#define cube(x) 1LL*(x)*(x)*(x)
#define ub(v, a) upper_bound(all(v), a)
#define lb(v, a) lower_bound(all(v), a)
#define EPS 1e-10
#define INF 2000000000
#define mod 1000000007
#define minof(a) min_element(all(a))
#define maxof(a) max_element(all(a))
#define debug(val) cerr << "The value of " << #val << " is = " << val << endl;
#define testing cerr << "--------------------------\n";

//input space ---> scanf("%[^\n]%*c",s);

ll n,k,ans;
vll a(200005),b(200005);

bool can(ll x) {
	ll K = k;
	fori(i,0,n-1,1) {
		K -= max(0LL,a[i]-x/b[i]);
	}
	return K >= 0;
}

int main() {
	IOS
	cin >> n >> k;
	fori(i,0,n-1,1) {
		cin >> a[i];
	}
	fori(i,0,n-1,1) {
		cin >> b[i];
	}
	sort(a.begin(),a.begin()+n,greater<ll>());
	sort(b.begin(),b.begin()+n);
	ll l = 0,r = 1e12+5;
	while(l <= r) {
		ll m = (l+r)/2;
		if(can(m)) {
			if(!can(m-1)) {
				ans = m;
				break;
			}
			r = m-1;
		} else {
			l = m+1;
		}
	}
	cout << max(0LL,ans) << endl;
}


Measured memory_bytes: 3456
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<=b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

string s;

int main(){
    INIT;
    cin >> s;
    int cnt=0;
    REP(i,s.size()) {
        if(s[i] == 'o') cnt++;
    }
    if(8 <= (15-s.size())+cnt)  cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 256
import Control.Monad
import Data.Array

main = sol <$> get >>= print

get = fmap read . words <$> getLine

sol [h,w,a,b] = sum [sq x b*sq (h-x+1) (w-b) | x <- [1..h-a]]
  where
  sq x y = chs (x+y-2) (x-1)
  chs n m = fac!n * inv (fac!m * fac!(n-m))
  fac = array (0,w+h-1) $ (0,1):[(i,fac!(i-1) * Modulo i) | i <- [1..w+h-1]]

inv :: Modulo -> Modulo
inv 1 = 1
inv a = pwr a (p-2)

-- Modular power
pwr :: Modulo -> Int -> Modulo
pwr a n
  | n == 0    = 1
  | odd n     = a*r
  | otherwise = r
  where
  q = pwr a (n `div` 2)
  r = q*q

p = 10^9+7 :: Int

-- | Modulo of Int
newtype Modulo = Modulo { getInt :: Int } deriving (Eq, Ord)

instance Num Modulo where
  Modulo a + Modulo b = Modulo ((a + b) `mod` p)
  Modulo a - Modulo b = Modulo ((a - b) `mod` p)
  Modulo a * Modulo b = Modulo ((a * b) `mod` p)
  abs = undefined
  negate = undefined
  signum = undefined
  fromInteger i = Modulo (fromIntegral i `mod` p)

instance Show Modulo where
  show (Modulo i) = show i

-- Modular inverse as needed
instance Fractional Modulo where
  recip = inv
  fromRational = undefined

{-
-- Modular multiplicative inverse
inv :: Modulo -> Modulo
inv 1 = 1
inv a = pwr a (p-2)

-- Modular power Int
pwr :: Modulo -> Int -> Modulo
pwr a n
  | n == 0    = 1
  | odd n     = a*r
  | otherwise = r
  where
  q = pwr a (n `div` 2)
  r = q*q

-- Modular factorial Int
fac :: Int -> Modulo
fac 0 = 1
fac n = Modulo n*fac (n-1)

-- Modular choose
choose :: Int -> Int -> Modulo
choose n m = fac' n m' * inv (fac m')
  where 
  m' = min m (n-m)

fac' :: Int -> Int -> Modulo
fac' _ 0 = 1
fac' n m = Modulo n*fac' (n-1) (m-1)
-}

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

int main(){
    
    int N;cin>>N;
    vector<int> A(N),B(N),C(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int i=0;i<N;i++){
        cin>>B[i];
    }
    for(int i=0;i<N;i++){
        cin>>C[i];
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
    long long int ans=0;
    for(int i=0;i<N;i++){
        long long int x=distance(A.begin(),lower_bound(A.begin(),A.end(),B[i]));
        long long int y=distance(upper_bound(C.begin(),C.end(),B[i]),C.end());
        ans+=(x*y);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

bool table[26];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s;cin>>s;
    int cnt = 0;
    REP(i,s.size()){
        if(table[s[i]-'a']) continue;
        ++cnt; table[s[i]-'a']=true;
    }
    cout << (s.size()==cnt ? "yes" : "no") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const char WHITE = '.';
const char BLACK = '#';

vector<vector<char>> board;

int main(void) {
    int W, B;
    cin >> W >> B;

    const char HEIGHT = 100;
    const char WIDTH = 100;

    board.resize(HEIGHT, vector<char>(WIDTH));
    for (int h = 0; h < HEIGHT; h++) {
        for (int w = 0; w < WIDTH; w++) {
            if (h < HEIGHT / 2) {
                board[h][w] = WHITE;
            } else {
                board[h][w] = BLACK;
            }
        }
    }

    int black = 1;
    for (int h = 0; h < HEIGHT / 2 - 1; h += 2) {
        for (int w = (h % 2 == 0) ? 0 : 1; w < WIDTH; w += 2) {
            if (black < B) {
                board[h][w] = BLACK;
                black++;
            }
        }
    }

    int white = 1;
    for (int h = HEIGHT / 2 + 1; h < HEIGHT; h += 2) {
        for (int w = (h % 2 == 0) ? 0 : 1; w < WIDTH; w += 2) {
            if (white < W) {
                board[h][w] = WHITE;
                white++;
            }
        }
    }

    cout << 100 << " " << 100 << endl;
    for (int h = 0; h < HEIGHT; h++) {
        for (int w = 0; w < WIDTH; w++) {
            cout << board[h][w];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
ll inf = 1e10;
ll w[105], v[105];
ll arr[300005] = {};
ll d[100005] = {};
vector<int> g[100005];

int main() {
	ll x;
	cin >> x;
	if (x == 2) {
		cout << 2 << endl;
		return 0;
	}
	for (int i = 0; i <= 100003; i++) {
		if (i % 2 == 0) {
			arr[i] = 1;
		}
		else {
			arr[i] = 1e5;
		}
	}
	
	if (x % 2 == 0) {
		x += 1;
	}
	for (int i = x; i <= 100003;) {
		for (int j = 3; j <= sqrt(100000);) {
			if (i % j == 0&&i!=j) {
				
				arr[i] = 1;
			}
			j = j + 2;
		}
		i = i + 2;
	}
	arr[2] = 1e5;
	for (int i = x; i <= 100003; i+=2) {
		if (arr[i] == 1e5) {
			cout << i << endl;
			return 0;
		}
	}
}


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

int main()
{
  int n;
  cin>>n;
  int arr[n];
  for(int i = 0; i < n ; i++)
  	cin>>arr[i];
  int dp[n];
  for(int i = 0 ; i < n ; i++)
  	dp[i] =  0;
  dp[0] = 0;
  dp[1] = abs(arr[1] - arr[0]);
  for(int i = 2 ; i < n ; i++)
  {
    dp[i] = min(dp[i-1] + abs(arr[i]-arr[i-1]) ,  abs(arr[i]-arr[i-2]) + dp[i-2]);
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 1024
# AOJ GRL_3_B
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_B

import sys

sys.setrecursionlimit(100000)

V, E = list(map(int, input().split()))
Edge = [list(map(int, input().split())) for _ in range(0, E)]

ord = [0 for _ in range(0, V)]
low = [0 for _ in range(0, V)]
used = [False for _ in range(0, V)]
bridge = []

G = [ [] for _ in range(0, V)]
for s, t in Edge:
    G[s] += [t]
    G[t] += [s]

# pは親となる頂点
def dfs(s, p, k):
    global articulation
    used[s] = True
    ord[s] = k
    low[s] = ord[s]
    k += 1
    c = 0
    
    # sから始まる辺
    for t in G[s]:
        # まだ探索していないか
        if used[t] == False:
            c += 1
            dfs(t, s, k)
            # DFSの葉の方向進める頂点のlowlinkの最小値
            low[s] = min(low[s], low[t])
        # 後退辺か
        elif t != p:
            # ord[t]の最小値
            low[s] = min(low[s], ord[t])

for s in range(0, V): 
    if used[s] == False:
        dfs(s, -1, 0)

for s, t in Edge:
    if ord[s] < low[t] or ord[t] < low[s]:
        if s < t:
            bridge += [(s, t)]
        else:
            bridge += [(t, s)]

bridge.sort()
for s, t in bridge:
    print(s, t)


Measured memory_bytes: 24592
N, K = map(int, input().split())
A = [i for i in range(N+1)]
mod = 10**9+7
ans = 0
head = sum(A[:K-1]) if K > 1 else 0
tail = sum(A[-K+1:]) if K > 1 else 0
for i in range(K, N+2):
    head += A[i-1]
    tail += A[-i] 
    ans += tail-head+1
    ans = ans % mod

print(ans)

Measured memory_bytes: 18372
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  bool f = false;
  if(t.size() - s.size() == 1 && s == t.substr(0,(int)s.size())) f = true;
  YesorNo(f);
  return 0;
}
//templete by private_yusuke

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

bool papers(vector<int> &vec) {
  for (auto x : vec) {
    if (x % 2 == 0 && x % 3 != 0 && x % 5 != 0) {
      return false;
    }
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  auto vec = vector<int>(n);
  for (auto &x : vec) {
    cin >> x;
  }
  cout << (papers(vec) ? "APPROVED" : "DENIED") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long  
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    string s;s='#';string s1;
    cin>>s1;s+=s1;int cnt=0;ll a,b,c;
    a=0;b=0;c=0;
    for(int i=1;i<=n;i++)
    {
        if(s[i]=='R')
        {a++;}
        else if(s[i]=='B')
        {b++;}
        else
        {
            c++;
        }
    }
    ll ans=a*c*b; 
    for(int i=2;i<n;i++)
    {
        for(int j=1;j+i<=n&&i-j>=1;j++)
        {
           if(s[i]!=s[i-j]&&s[i]!=s[i+j]&&s[i-j]!=s[i+j])
            cnt++; 
        }
    }
    ans-=cnt;
   
    cout<<ans;
    return 0;
}
//make all values ll


Measured memory_bytes: 3676
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>

template<typename T>
auto distance(T begin1, T end1, T begin2){
    long long retval = 0;
    for(auto it = begin1; it < end1; it++){
        retval += std::abs(*it - *begin2) * std::abs(*it - *begin2);
        begin2++;
    }

    return retval;
}

int main(){
    
    size_t n, d;
    size_t cnt = 0;

    std::cin >> n >> d;

    std::vector<std::vector<long>> x(n, std::vector<long>(d));

    for(auto&& e : x){
        for(auto&& ee : e){
            std::cin >> ee;
        }
    }

    for(size_t i = 0; i < n - 1; i++){
        for(size_t j = i + 1; j < n; j++){
            auto dis = distance(x[i].begin(), x[i].end(), x[j].begin());

            if(dis == std::pow(static_cast<long long>(std::sqrt(dis)), 2.0)) cnt++;
        }
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define llINF 1e19
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n,K;cin>>n>>K;
  vector<ll>x(n);
  vector<ll>y(n);
  vector<ll>x2(n);
  vector<ll>y2(n);
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
    x2[i]=x[i];
    y2[i]=y[i];
  }
  ll ans=llINF;
  sort(x2.begin(),x2.end());
  sort(y2.begin(),y2.end());
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int k=0;k<n;k++){
	for(int l=k+1;l<n;l++){
	  ll le=x2[i],ri=x2[j];
	  ll down=y2[k],up=y2[l];
	  int ccc=0;
	  for(int ii=0;ii<n;ii++){
	    if(le<=x[ii]&&x[ii]<=ri&&down<=y[ii]&&y[ii]<=up)
	      ccc++;
	  }
	  if(ccc>=K){
	    // cout<<ccc<<" "<<k<<endl;
	    ans=min(ans,(ll)(ri-le)*(up-down));
	  }
	}
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

int main() {
	string s, rb, a;
	int q,t,f;
	string c;
	cin >> s >> q;
	int tcnt = 0;

	REP(i,q) {
		cin >> t;
		if(t == 1) {
			tcnt++;
		} else {
			// t = 2
			cin >> f >> c;
			if(f == 1 && tcnt %2 == 0) {
				rb += c;
			} else if(f == 2 && tcnt %2 == 0) {
				a += c;
			} else if(f == 1 && tcnt %2 == 1) {
				a += c;
			} else if(f == 2 && tcnt %2 == 1) {
				rb += c;
			}
		}
	}
	if(tcnt %2 ==0) {
		reverse(rb.begin(), rb.end());
		cout << rb << s << a << endl;
	} else {
		reverse(a.begin(), a.end());
		reverse(s.begin(), s.end());
		cout << a << s << rb << endl;
	}

}



Measured memory_bytes: 1088
#include <iostream>
#include <list>
#include <string>
#include <ios>
using namespace std;
struct Trie
{
	struct Node
	{
		Node() :isEnd(false) {}
		Node(char _v) : v(_v), isEnd(false) {}
		~Node()
		{
			for (list<Node*>::iterator it = nodes.begin();
				it != nodes.end();
				++it)
			{
				delete *it;
			}
		}
		Node* FindChild(char c){
			for (list<Node*>::iterator it = nodes.begin();
				it != nodes.end();
				++it)
			{
				if ((*it)->v == c)
					return *it;
			}
			return 0;
		}

		bool isEnd;
		char v;
		list<Node*> nodes;
	};

	void Add(const string& str){
		Node* n = &root;
		Node* cn = 0;
		int s = str.size();
		std::string::size_type p = 0;
		for (; p < s; ++p){
			char c = str[p];
			cn = n->FindChild(c);
			if (cn)
				n = cn;
			else{
				cn = new Node(c);
				n->nodes.push_back(cn);
				n = cn;
			}
		}
		n->isEnd = true;
	}
	bool Find(const string& str){
		Node* n = &root;
		Node* cn = 0;
		int s = str.size();
		std::string::size_type p = 0;
		for (; p < s; ++p){
			char c = str[p];
			cn = n->FindChild(c);
			if (!cn)
				return false;
			n = cn;
			if (p == s - 1)
				return n->isEnd;
		}
	}
	Node root;
};

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

	int n, i;
	cin >> n;
	string com, str;
	Trie trie;
	for (i = 0; i < n; ++i){
		cin >> com >> str;
		if (com == "insert") trie.Add(str);
		if (com == "find")
			cout << (trie.Find(str) ? "yes\n" : "no\n");
	}

	return 0;
}

Measured memory_bytes: 22952