akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cstring>
#include <ctime>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <climits>
#include <cassert>
#define fr first
#define sc second
#define MP make_pair
#define ad push_back
#define PB push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define lli long long int
#define y1 arayikhalatyan
#define j1 jiglypuff
#define ld long double
#define itn int
#define pir pair<int, int> 
#define all(x) (x).begin(), (x).end()
using namespace std;

lli gcd(lli a, lli b) { return (b == 0LL ? a : gcd(b, a % b)); }
ld dist(ld x1, ld y1, ld x2, ld y2)
{
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
lli S(lli a)
{
	return (a * (a + 1LL)) / 2;
}
char vow[] = { 'a', 'e', 'i', 'o', 'u' };
int dx[] = { 1, -1, 0, 0, -1, -1, 1, 1 };
int dy[] = { 0, 0, 1, -1, -1, 1, -1, 1 };


const int N = 1e5 + 30;
const lli mod = 998244353;
const ld pi = acos(-1);
const int T = 238;
const ld e = 1e-6;

lli bp(lli a, lli b = mod - 2LL)
{
	lli ret = 1;
	while (b)
	{
		if (b & 1) ret *= a, ret %= mod;
		a *= a;
		a %= mod;
		b >>= 1;
	}
	return ret;
}
ostream& operator<<(ostream& c, pir a)
{
	c << a.fr << " " << a.sc;
	return c;
}




int n, m;
int main()
{
	fastio;
	cin >> n >> m;
	if (n % 2 == 1)
	{
		for (int i = 1; i <= m; i++)
		{
			cout << i << " " << n - i << endl;
		}
	}
	else
	{
		for (int i = 1; i <= m - m / 2; i++)
		{
			cout << i << " " << n - i + 1 << endl;
		}
		for (int i = 1; i <= m / 2; i++)
		{
			cout << n / 2 - i << " " << n / 2 + i << endl;
		}
	}
	return 0;
}


/*


  __
*(><)*
  \/ /
  ||/
--||
  ||
  /\
 /  \
/    \
*/



Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ps push
#define pf push_front
#define mp make_pair
#define And &&
#define Or ||
#define ppb pop_back
#define ppf pop_front
#define inf INT_MAX
#define sz(name) name.size()
#define len(name) name.length()
#define ig cin.ignore()
#define Sort(name) sort(name.begin(),name.end())
#define For(name,start,finish) for(int name=start;name<finish;name++)
#define fast_in_out ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

//int row[]={-1,0,1,0};
//int col[]={0,1,0,-1};

const ll N=1e9+10;
const ll M=1e9+7;

ll Max(ll a,ll b){if(a>b)return a;return b;}
ll Min(ll a,ll b){if(a>b)return b;return a;}
ll big_mul(ll a,ll b,ll m){ll x=0,y=a%m;while(b>0){if(b&1)x=(x+y)%m;y=(2*y)%m;b>>=1;}return x%m;}
ll big_mod(ll a,ll b,ll m){ll x=1,y=a%m;while(b>0){if(b&1)x=(x*y)%m;y=(y*y)%m;b>>=1;}return x%m;}
ll Big_mod(ll a,ll b,ll m){ll x=1,y=a%m;while(b>0){if(b&1)x=big_mul(x,y,m);y=big_mul(y,y,m);b>>=1;}return x%m;}
ll mod_inverse(ll a,ll m){return big_mod(a,m-2,m);}  //a^-1 mod m = a^(m-2) mod m

vector<int> vec1;
vector<int> vec2;

int main()
{
    fast_in_out;

    int a;
    cin>>a;
    cout<<3*a*a<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  string s;
  while (getline(cin, s)) {
    int n = stoi(s);
    int res = 0;
    for (int a = 0; a < 10; ++a) for (int b = 0; b < 10; ++b) for (int c = 0; c < 10; ++c) for (int d = 0; d < 10; ++d) {
      if (a + b + c + d == n) ++res;
    }
    cout << res << '\n';
  }
}


Measured memory_bytes: 3084
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

string s;
string order[2] = {"First", "Second"};

int main()
{
    cin >> s;
    cout << order[((s.front() != s.back()) + s.size()) % 2] << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include<algorithm>
using namespace std;
int gcd(int a,int b){
    int r;
    if(a<b){
        r=a;
        a=b;
        b=r;
    }
    while( (r = a % b) != 0 ) {
            a = b;
            b = r;
    }
    return b;
}
int main() {
    int N;
    cin>>N;
    int A[100010];
    int GCDF[100010],GCDB[100010];
    for(int i=0;i<N;++i)cin>>A[i];

    GCDF[0]=A[0];
    for(int i=1;i<N;++i){
        GCDF[i]=gcd(GCDF[i-1],A[i]);
    }
    GCDB[N-1]=A[N-1];
    for(int i=N-2;i>=0;--i){
        GCDB[i]=gcd(GCDB[i+1],A[i]);
    }
    int m=GCDB[1];
    int G=0;
    for(int i=1;i<N-1;++i){
        G=gcd(GCDF[i-1],GCDB[i+1]);
        if(m<G){
            m=G;
        }
    }
    if(m<GCDF[N-2]){
        m=GCDF[N-2];
    }
    cout<<m<<endl;
}



Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;

ll digit_sum(ll i, ll b)
{
    ll ans = 0;
    while (i > 0)
    {
        ans += i % b;
        i /= b;
    }
    return ans;
}

const ll INF = 10000000000000000LL;

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

    ll ans = INF;

    if (n == s)
    {
        cout << n + 1 << endl;
    }
    else if (n < s)
    {
        cout << -1 << endl;
    }
    else
    {
        for (ll b = 2; b * b <= n; b++)
        {
            if (digit_sum(n, b) == s)
            {
                ans = min(ans, b);
            }
        }

        for (ll p = 1; p * p < n; p++)
        {
            const ll b = (n - s) / p + 1;
            if (b > 1 && digit_sum(n, b) == s) 
            {
                ans = min(ans, b);
            }
        }

        if (ans == INF)
        {
            cout << -1 << endl;
        } 
        else
        {
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

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

int main() {
	ll x, y;
	cin >> x >> y;
	cout << gcd(max(x, y), min(x, y)) << endl;
}

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

int main(){
    int n;
    cin>>n;
    while(n--){
        int x,y,b,p;
        cin>>x>>y>>b>>p;
        int _b=max(5,b);
        int _p=max(2,p);
        cout<<min(x*b+p*y,(_b*x+_p*y)*4/5)<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
public class Hello{
    public static void Main(){
        // Your code here!
        
            string[] inputs = System.Console.ReadLine().Split(' ');
            int a = int.Parse(inputs[0]);
            int b = int.Parse(inputs[1]);
            int c = int.Parse(inputs[2]);
            if (a < b && b < c)
            {
                System.Console.WriteLine("Yes");
            }
            else
            {
                System.Console.WriteLine("No");
            }
    }
}


Measured memory_bytes: 8912
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n, l, t; scanf("%d%d%d", &n, &l, &t);
	std::vector<int> latte;
	int malta = 0;
	while(n--) {
		int a, b; scanf("%d%d", &a, &b);
		
		if(b == 1) {
			malta -= (t - (l - a) + l) / l;
			latte.push_back((a + t) % l);
		} else {
			malta += (t - (a + 1) + l) / l;
			latte.push_back((a - t % l + l) % l);
		}
	}
	malta = (malta % (int)latte.size() + (int)latte.size()) % latte.size();
	sort(begin(latte), end(latte));
	
	for(int i = 0; i < latte.size(); i++) printf("%d\n", latte[(i - malta + (int)latte.size()) % latte.size()]);
	return 0;
}


Measured memory_bytes: 1656
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) cout << ", "; else first = false; cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  lli n, s = 0;
  cin >> n;
  for (lli x=n; x>0; x/=10) {
    s += x%10;
  }
  auto ans = n%s==0 ? "Yes" : "No";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

def gcd(a,b):
    while a%b:
        a,b=b,a%b
    return b

def lcm(a,b):
    return a*b/gcd(a,b)

for ab in sys.stdin:
    a,b=map(int, ab.split())
    a,b=max(a,b),min(a,b)
    print gcd(a,b),lcm(a,b)

Measured memory_bytes: 4204
#include <bits/stdc++.h>
#include<string>
    
using namespace std;
            
    #define ll long long
    #define do long double
    #define ff first
    #define ss second
    #define pb push_back
    #define mp make_pair
    #define inf LONG_LONG_MAX
    #define mod 998244353
    #define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


void solve()
{
	ll n,m,i,j,k;
	cin>>n;
	ll a[n];
	ll c=1;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]==c)
		{
			c++;
		}
	}
	if(c==1)
		cout<<-1;
	else
	cout<<n-c+1;

	
}



int main()
{
    FAST
    ll n,m,i,j;
    ll q;
    q=1;

    while(q--)
    	solve();
	

}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))

const int inf = 999999999;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	int n; cin >> n;
	string s = to_string(n);
	int t = 0;
	Rep(i, s.length()){
		t += s[i] - '0';
	}
	if(n % t == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int ans=0,x=0;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        if(a==b)x++;
        else x=0;
        if(x>=3)ans=1;
    }
    cout<<(ans ? "Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin >> a;
    string odd = "RUD";
    string even = "LUD";
    int evenkey = 0;
    int oddkey = 0;
    for(int i = 0;i<a.size();i++){
        evenkey = 0;
        oddkey = 0;
        if(i%2 == 0){
            for(int j = 0;j<odd.size();j++){
                if(a.at(i) == odd.at(j)){
                    oddkey = 1;
                }
            }
            if(oddkey != 1)
                break;
        }
        else{
            for(int j = 0;j<even.size();j++){
                if(a.at(i) == even.at(j)){
                    evenkey = 1;
                }
            }
            if(evenkey != 1)
                break;        
        }
    }
    if(evenkey == 1 || oddkey == 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
} 
    


Measured memory_bytes: 764
#include <iostream>
#include <numeric>
#include <vector>
#include <math.h>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <string>
#define mod 1000000007
using namespace std; 

int main(){
	long long a,b,c,k; cin >> a >> b >> c >> k;
	long long ans=0;
	if (a+b>k){
		cout << k << "\n";
	}
	else{
		cout << a-(k-a-b) << "\n";
	} 
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
 
using namespace std;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<long long , long long>
#define pb push_back
#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
ll power(ll x,ll y,ll m){ll r=1;for(;y;y>>=1){if(y&1)r=r*x%m;x=x*x%m;}return r;}
const ll mod = 1e9 + 7;
const ld pi = 3.14159265358979;
 
int run_test(){
      int n, m;
      cin >> n >> m;
      vector<int> v[n + 1];
      for(int i=0; i<m; i++){
            int a, b;
            cin >> a >> b;
            v[a].pb(b);
            v[b].pb(a);
      }
      int ans[n + 1];
      queue<int> q;
      q.push(1);
      int visited[n + 1];
      fill(visited, 0);
      visited[1] = 1;
      while(!q.empty()){
            int k = q.front();
            q.pop();
            for(auto to: v[k]){
                  if(!visited[to]){
                        visited[to] = 1;
                        q.push(to); ans[to] = k;
                  }
            }
      }
      cout << "Yes\n";
      for(int i=2; i<n + 1; i++){
            cout << ans[i] << "\n";
      }
      return 0;
}
 
int main(){
    FAST;
    ll t;
    t = 1;
 
    
    while(t--){
        run_test();
    }
}

Measured memory_bytes: 11016
N, K = gets.chomp.split.map(&:to_i)
v = gets.chomp.split.map(&:to_i)

# K個のうちkことってK-k個返すことにする
# TLEになったらそこだけ累積和にしてみる
ans = 0

def max(a, b)
  a > b ? a : b
end

r = [N, K].min

0.upto(K) do |i|
  0.upto(K) do |j|
    m = i + j
    next if m > r
    tmp = (v[0,i] + v[N-j,j]).sort

    # 空な場合は飛ばす
    next if tmp.empty?

    # 和を取る
    tmp_sum = tmp.inject(:+)

    # p tmp
    # p tmp_sum
    # p K-m
    

    # k-m回まで取り除くことが可能
    len = [(K-m), tmp.size].min

    len.times do |l|
      break if tmp[l] >= 0
      tmp_sum -= tmp[l]
    end

    # p tmp_sum

    ans = max(ans, tmp_sum)
  end
end

p ans


Measured memory_bytes: 3836
N = int(input())

S = input()
# 仮にn=6の場合3より後と3までが一緒ならyes
if N % 2 == 0:
   if S[:int(N/2)] == S[int(N/2):]:
       print("Yes")
   else:
       print("No")
# 奇数ならそもそもno
else:
   print("No")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,count=0,j=1;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    if(a.at(i)!=j)count++;
    else j++;
  }
  cout << ((count<n)?count:-1) << endl;
}

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

int main() {
  
  string s;
  cin >> s;
  
  if(s == "SSS") cout << 0;
  if(s == "RSS") cout << 1;
  if(s == "SRS") cout << 1;
  if(s == "SSR") cout << 1;
  if(s == "RRS") cout << 2;
  if(s == "RSR") cout << 1;
  if(s == "SRR") cout << 2;
  if(s == "RRR") cout << 3;
  
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(max({a,b,c})==7){
        if (min({a,b,c})==5 && a+b+c==17) {
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
    while(1){
        int d,c;
        cin >> d >>c;
         
        if(d==0 && c==0)break;
        for(int j=0;j<d;j++)
		{
			for(int i=0;i<c;i++)
			{
				if((i+j)%2==0)
				{
					cout<<"#";
				}
				else
				{
					cout<<".";
				}
				
			}
			cout<<"\n";
		}
		cout<<"\n";
    }
     
    return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            var A = N[0];
            var B = N[1];
            var K = N[2];

            var min = Math.Min(A, K);

            if (min == A)
            {
                var BL = A + B - K;
                if (BL < 1)
                {
                    Console.WriteLine("0 0");
                }
                else
                {
                    Console.WriteLine($"0 {A + B - K}");

                }
            }
            else
            {
                Console.WriteLine($"{A - K} {B}");
            }

        }

    }

}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main(){
  string T;
  cin >> T;
  string P;
  cin >> P;
  int N = T.size();
  int M = P.size();
  vector<int> ans;
  for (int i = 0; i <= N - M; i++){
    bool ok = true;
    for (int j = 0; j < M; j++){
      if (T[i + j] != P[j]){
        ok = false;
      }
    }
    if (ok){
      ans.push_back(i);
    }
  }
  int cnt = ans.size();
  for (int i = 0; i < cnt; i++){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 3176
open System

[<EntryPoint>]
let main argv =
  let xs = Console.ReadLine().Split(' ') |> Array.map int in
  let n = xs.[0] in
  let a = xs.[1] in
  let b = xs.[2] in
  let digitSum x =
    x
    |> string
    |> Seq.sumBy (fun c -> int c - int '0') in
  
  [1..n]
  |> Seq.sumBy (fun x -> if (digitSum x >= a) && (digitSum x <= b) then x else 0)
  |> Console.WriteLine
  0


Measured memory_bytes: 13396
#include <stdio.h>
#include <string.h>

int main(){
  char S[100];
  char S1[100] = "Sunny";
  char S2[100] = "Cloudy";
  char S3[100] = "Rainy";
  
  scanf("%s", S);
  
  if(strcmp(S,S1)==0){
    printf("Cloudy\n");
  }
  else if(strcmp(S,S2)==0){
    printf("Rainy\n");
  }
  else if(strcmp(S,S3)==0){
    printf("Sunny\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import defaultdict
from itertools import accumulate

N, K = map(int, input().split())

sushi = defaultdict(list)

for i in range(N):
    a,b = map(int, input().split())
    sushi[a].append(b)

first = []
second = []

for nums in sushi.values():
    nums.sort(reverse=True)
    for i, j in enumerate(nums):
        if i == 0:
            first.append(j)
        else:
            second.append(j)
first.sort(reverse=True)
second.sort(reverse=True)

first_cum = [0] + list(accumulate(first))
second_cum = [0] + list(accumulate(second))

ans = 0

for i in range(K, 0, -1):
    neta = min(i, len(first))
    tmp = neta * neta + first_cum[neta]

    if K - neta > len(second):
        break
    
    tmp += second_cum[K - neta]

    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 69084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e9;
const int maxN = 100 + 9;

int n;
vector<int> b;

void read(){
  cin >> n;
  b.resize(n);
  for(int i = 0; i < n; i++)
    cin >> b[i];
}

void solv(){
  vector<int> ans(n);

  int k = n;
  while(true){
    int idx = -1;
    for(int i = (int)b.size() - 1; i >= 0; i--){
      if((b[i] == i + 1) && (b[i] <= k)){
        idx = i;
        //cerr << b[i] << '\n';
        break;
      }
    }

    //cerr << idx << '\n';
    if(idx == -1)
      break;

    ans[k - 1] = b[idx]; k--;
    b.erase(b.begin() + idx);
  }

  if(b.size()){
    cout << "-1\n";
    return;
  }

  for(int i = 0; i < n; i++)
    cout << ans[i] << '\n';
}

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

  read();
  solv();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}




int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    cout<<n*n*n<<endl;

    return 0;
    }


Measured memory_bytes: 256
import java.util.*;
import java.math.*;

class Main {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        final int H = Integer.parseInt(sc.next());
        final int W = Integer.parseInt(sc.next());
        sc.close();

        BigInteger ans0 = BigInteger.ZERO;
        long ans1 = 0;
        long ans2 = 0;
        if (W % 2 == 0) {
            ans1 = W / 2;
            ans2 = W / 2;
        } else {
            ans1 = W / 2 + 1;
            ans2 = W / 2;
        }
        if (H % 2 == 0) {
            ans0 = ans0.add(BigInteger.valueOf(ans1)).add(BigInteger.valueOf(ans2)).multiply(BigInteger.valueOf(H))
                    .divide(BigInteger.valueOf(2));
        } else {
            ans0 = ans0.add(BigInteger.valueOf(H).divide(BigInteger.valueOf(2)).add(BigInteger.valueOf(1))
                    .multiply(BigInteger.valueOf(ans1)));
            ans0 = ans0.add(BigInteger.valueOf(H).divide(BigInteger.valueOf(2)).multiply(BigInteger.valueOf(ans2)));
        }

        if (H == 1 || W == 1) {
            System.out.println(1);
        } else {
            System.out.println(ans0);
        }
    }
}

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

// GCD, LCM
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main()
{
    int A,B;
    cin>>A>>B;

    if(A>=13){
        cout<<B<<endl;
    }else if(A>=6){
        cout<<B/2<<endl;
    }else{
        cout<<0<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int X=gi();
	    int N=gi();
	    int[] P=new int[N];

        for(int i=0;i<N; i++) {
        	P[i]=gi();
	    }
        int q=0;
        int Y=X;
        while(true) {
        	Y+=Math.pow(-1, q)*q;
        	boolean flg=false;
        	for(int i=0;i<N; i++) {
            	if (P[i]==Y) {
            		q++;
            		flg=true;
            		break;
            	}
    	    }
        	if (!flg) {
        	    break;
        	}
        }

        System.out.println(Y);
//        if (flg) {
//        	System.out.print("YES");
//        }else {
//        	System.out.print("NO");
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35616
#define _GLIBCXX_DEBUG
#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++)

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



int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    int sum = 0;

    rep(i,N){
        cin >> A[i];
        sum += A[i];
    }

    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());

    double check = sum / double((4*M));
    bool flag = true;
    rep(i,M){
        if(double(A[i]) < check){
            flag = false;
            break;
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3644
// Name: Kanisht Agarwal Copyright Think before u copy //
//Connect with me at LinkedIn

#include <bits/stdc++.h>
#define mod 1000000007
#define ull unsigned ll
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.1415926535897932
#define nui 100
#define INF 100000000000
using namespace std;


ll binpow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
        {
            res *= a;
        }
        a *= a;
        b >>= 1;
    }
    return res;
}

ll fermat_inv(ll y) {return binpow(y, mod - 2);}

clock_t time_p = clock();

void TLE()
{
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}

struct point
{
    int x; int y;
};
bool segment(point p, point q, point r)
{
    if (q.x <= max(p.x, r.x) && q.y <= max(p.y, r.y) && q.x >= min(p.x, r.x) && q.y >= min(p.y, r.y))
        return true;

    return false;
}
int orientation(point p, point q, point r)
{
    int o = (r.x - q.x) * (q.y - p.y) - (r.y - q.y) * (q.x - p.x);
    if (o == 0)return 0;
    return (o > 0) ? 1 : 2;
}
bool intersection(point p, point q, point r, point s)
{
    int o1 = orientation(p, q, r);
    int o2 = orientation(p, q, s);
    int o3 = orientation(r, s, p);
    int o4 = orientation(r, s, q);
    if (o1 != o2 && o3 != o4)return true;
    if (o1 == 0 && segment(p, r, q))return true;
    if (o2 == 0 && segment(p, s, q))return true;
    if (o3 == 0 && segment(r, p, s))return true;
    if (o4 == 0 && segment(r, q, s))return true;

    return false;
}

int main()
{


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

    int l, r, d;
    cin >> l >> r >> d;
    cout << (r / d) - ((l - 1) / d) << "\n";


    return 0;
}



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


using namespace std;

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> v(n + 1, 0);

	rep(i, m) {
		int a, b;
		cin >> a >> b;
		v[a]++;
		v[b]++;
	}

	rep(i, n + 1) {
		if (v[i] % 2 == 1) {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;


	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;

template <typename T = int>
struct Range {
    struct RangeIterator {
        T i, step;

        RangeIterator(T i, T step): i{i}, step{step} {}

        T& operator*() { return i; }
        RangeIterator& operator++() {
            i += step;
            return *this;
        }
        bool operator!=(const RangeIterator& rhs) const {
            return (step > 0 && i < rhs.i) || (step < 0 && i > rhs.i);
        }
    };

    T start, stop, step;

    Range(T start, T stop, T step): start{start}, stop{stop}, step{step} {}
    Range(T start, T stop): Range(start, stop, 1) {}
    Range(T stop): Range(0, stop, 1) {}
    
    RangeIterator begin() const { return RangeIterator(start, step); }
    RangeIterator end() const { return RangeIterator(stop, step); }
};

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

    int n;
    std::cin >> n;

    std::vector<int> b(n);
    for (const int i : Range<>(n)) {
        std::cin >> b[i];
        b[i]--;
    }

    std::vector<int> ans;
    for (const int i : Range<>(n)) {
        int cnt = 0,
            x = -1;
        for (const int j : Range<>(n)) {
            if (b[j] == cnt) {
                x = j;
            }
            if (b[j] >= 0) {
                cnt++;
            }
        }
        if (x < 0) {
            std::cout << -1 << std::endl;
            return 0;
        }
        ans.push_back(b[x] + 1);
        b[x] = -1;
    }
    std::reverse(ans.begin(), ans.end());

    for (int x : ans) {
        std::cout << x << std::endl;
    }

    return 0;
}


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

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

const long long INF = 1LL << 60;

int main() {
    int N;
    cin >> N;
    vector<vector<int>> a(N + 1, vector<int>(3));
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j < 3; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    vector<vector<long long>> dp(100010, vector<long long>(3, 0));
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j == k) continue;
                chmax(dp[i][k], dp[i - 1][j] + a[i][k]);
            }
        }
    }

    cout << max(max(dp[N][0], dp[N][1]), dp[N][2]) << endl;

    return 0;
}

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

ll f[300010];

// int pow2(int t, int mod) {
//     if (t == 0) return 1;
//     int a = pow(t/2, mod);
//     a *= a;
//     a %= mod;
//     if (t%2==1) a *= 2;
//     a %= mod;
//     if (a < 0) a = (a + mod) % mod;
//     return a;
// }

ll pow2(ll t, ll mod) {
    if (t == 0) return 1;
    ll a = pow2(t/2, mod);
    a = a * a;
    a %= mod;
    if (t % 2 == 1) a *= 2;
    a %= mod;
    return a;
}

int main() {
    ll N;
    string X;
    cin >> N >> X;

    f[0] = 0;
    for (ll i = 1; i < 300000; i++) {
        ll now = i % (ll)__builtin_popcount(i);
        f[i] = 1 + f[now];        
    }

    // rep(i, 11) {
    //     printf("f[%d] = %d\n", i, f[i]);
    // }

    // rep(i, 11) {
    //     printf("pow(%d, %d) = %d\n", i, 12, pow2(i, 12));
    // }

    ll first_pop_count = 0;
    ll first_mod_plus = 0;
    ll first_mod_minus = 0;

    rep(i, N) {
        if (X[i] == '1') first_pop_count++;
    }

    ll digit = 1;
    rep(i, N) {
        ll ri = N - 1 - i;
        if (X[ri] == '1') {
            first_mod_plus += digit;
            first_mod_plus %= (first_pop_count + 1);
            // first_mod_minus += digit;
            // first_mod_minus %= (first_pop_count - 1);
        }
        digit *= 2;
        digit %= (first_pop_count + 1);
    }

    digit = 1;
    if (first_pop_count > 1) {
        rep(i, N) {
            ll ri = N - 1 - i;
            if (X[ri] == '1') {
                // first_mod_plus += digit;
                // first_mod_plus %= (first_pop_count + 1);
                first_mod_minus += digit;
                first_mod_minus %= (first_pop_count - 1);
            }
            digit *= 2;
            digit %= (first_pop_count - 1);
        }
    }
    



    rep(i, N) {
        ll ri = N - 1 - i;
        ll now;
        if (X[i] == '1') {
            // ri桁目が1から0になった時のf(X)を求める
            if (first_pop_count == 1) {
                cout << 0 << endl;
            } else {
                now = first_mod_minus - pow2(ri, first_pop_count - 1);
                now %= (first_pop_count - 1);
                if (now < 0) now = (now + first_pop_count - 1) % (first_pop_count - 1);
                cout << 1 + f[now] << endl;
            }
        } else {
            // ri桁目が0から1になった時のf(X)を求める
            now = first_mod_plus + pow2(ri, first_pop_count + 1);
            // now = (now + first_pop_count + 1) % (first_pop_count + 1);
            now %= (first_pop_count + 1);
            if (now < 0) now = (now + first_pop_count + 1) % (first_pop_count + 1);
            cout << 1 + f[now] << endl;
        }
    }
}

Measured memory_bytes: 6096
#include <iostream>
#include <map>
#include <queue>
#include <sstream>

using namespace std;

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

class state {
public:
    int tx, ty;
    int kx, ky;
    int time;
    state(int a, int b, int c, int d, int e) {
        tx = a;
        ty = b;
        kx = c;
        ky = d;
        time = e;
    }
};

int h, w;
int grid[55][55];
int tx, ty, kx, ky;

void solve()
{
    int ans = -1;
    state s(tx, ty, kx, ky, 0);
    map<string, bool> m;
    queue<state> q;
    ostringstream oss;

    oss << tx << "," << ty << "," << kx << "," << ky;
    q.push(s);
    m[oss.str()] = true;

    while (!q.empty()) {
        state now = q.front();
        q.pop();

        if (now.time >= 100)
            break;
        if (now.tx == now.kx && now.ty == now.ky) {
            ans = now.time;
            break;
        }

        for (int i = 0; i < 4; i++) {
            int ntx = now.tx + dx[i];
            int nty = now.ty + dy[i];
            int nkx = now.kx + dx[(i + 2) % 4];
            int nky = now.ky + dy[(i + 2) % 4];

            if (ntx < 1 || ntx > w)
                ntx = now.tx;
            if (nty < 1 || nty > h)
                nty = now.ty;
            if (nkx < 1 || nkx > w)
                nkx = now.kx;
            if (nky < 1 || nky > h)
                nky = now.ky;
            if (grid[nty][ntx] != 0) {
                ntx = now.tx;
                nty = now.ty;
            }
            if (grid[nky][nkx] != 0) {
                nkx = now.kx;
                nky = now.ky;
            }
                
            oss.str("");
            oss << ntx << "," << nty << "," << nkx << "," << nky;

            if (m.count(oss.str()) != 0)
                continue;
            state next(ntx, nty, nkx, nky, now.time + 1);
            q.push(next);
            m[oss.str()] = true;

            // for (int y = 1; y <= h; y++) {
            //     for (int x = 1; x <= w; x++) {
            //         if (y == nty && x == nty)
            //             cout << "t";
            //         else if (y == nky && x == nky)
            //             cout << "k";
            //         else
            //             cout << grid[y][x];
            //     }
            //     cout << endl;
            // }
            // cout << endl;
//            cout << oss.str() << endl;
        }
    }
    if (ans == -1 || ans >= 100)
        cout << "NA" << endl;
    else
        cout << ans << endl;
}

int main()
{
    while (cin >> w >> h, w || h) {
        cin >> tx >> ty >> kx >> ky;
        for (int y = 1; y <= h; y++)
            for (int x = 1; x <= w; x++) 
                cin >> grid[y][x];
        solve();
    }

    return 0;
}

Measured memory_bytes: 20544
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int a[n + 2];
	a[0] = 0;
    a[n + 1] = 0;
	for (int i = 1 ; i <= n ; i++) cin >> a[i];
	int b = 0;
	for (int i = 1 ; i <= n + 1 ; i++) b += abs(a[i] - a[i - 1]);
	for (int i = 1 ; i <= n ; i++) {
        int ans = b;
        ans = ans - abs (a[i] - a[i - 1]) - abs (a[i] - a[i + 1]) + abs (a[i - 1] - a[i + 1]);
        cout << ans << endl;
    }
}
/*
3 + 6 + 2 + 1
3
step 1:- a[i] - a[i - 1]
6 + 2 + 1
step 2:- a[i + 1] - a[i]
6 + 1
step 3:+ a[i + 1] - a[i - 1]
5 + 6 + 1
*/

Measured memory_bytes: 4008
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long

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

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  string s, t; cin >> s >> t;
  vector<ll> cnts(26, 0), cntt(26, 0);
  for (char si : s) cnts[si-'a']++;
  for (char ti : t) cntt[ti-'a']++;
  vector<ll> x(26), y(26);
  rep(i, 26) x[i] = cnts[i];
  rep(i, 26) y[i] = cntt[i];
  sort(x); sort(y);
  rep(i, 26) {
    if (x[i] != y[i]) {
      No();
      return;
    }
  }
  Yes();
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
	int a, b, x;
	cin >> a >> b >> x;
	if (a <= x && a + b >= x) {
		cout << "YES" << endl; 
	}
	else {
		cout << "NO" << endl;
	}
} 

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

typedef long long ll;

int main() {
  string s;
  ll k;
  cin >> s >> k;
  char* ptr = &s[0];
  for (int i = 0; i < s.length(); i++) {
    if (*ptr != 'a' && k > 'z' - *ptr) {
      k -= 'z' - *ptr + 1;
      *ptr = 'a';
    }
    ptr++;
  }
  ptr--;
  k %= 26;
  for (int i = 0; i < k; i++) {
    if (*ptr == 'z') {
      *ptr = 'a';
    }
    else {
      *ptr += 'b' - 'a';
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
int main(void)
{
    char s[3];
    scanf("%s",s);
    int i=0;
    while(s[i]){
        if(s[i]=='7'){
            printf("Yes\n");
            return 0;
        }
        i++;
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 1660
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class DStringEquivalence {
public:
    int N;
    void dfs(vector<string>& res, string cur, int m, int d) {
        if (d == N) {
            res.push_back(cur);
            return;
        }

        FOR(i, 0, m + 1) {
            char c = i + 'a';
            dfs(res, cur + c, max(i, m), d + 1);
        }
    }
    void solve(std::istream& cin, std::ostream& cout) {
        cin >> N;

        vector<string> res;
        dfs(res, "", -1, 0);
        REP(i, res.size()) {
            cout << res[i] << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DStringEquivalence solver;
    solver.solve(in, out);
    return 0;
}


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

#define  all(v)            v.begin(), v.end()
#define  sz(x)             (int)x.size()
#define  debug(x)          cout << #x << ':' << x << endl;
#define  rep(i,n)          for(long long i = 0; i <  n ; i++)
#define  reps(i,n)         for(long long i = 1; i <= n ; i++)
#define  make_unique(v)    sort(all(v));v.erase(unique(all(v)), v.end());
#define  REMOVE(v,a)       v.erase(remove(v.begin(),v.end(), a), v.end());
#define  pb                push_back
#define  mp                make_pair
#define  endl              '\n'
#define  fi                first
#define  se                second
#define  ajs(a)            (a<0)?(-1*a):a

using namespace std;
typedef long long          ll;
typedef vector<long long>  vll;
typedef pair<ll,ll>        pll;
const ll MOD = 1e9+7;
bool cmp(int X, int Y) {return X > Y;}
const double EPS = (1e-7);
int dcp(double A, double B){return fabs(A-B)<=EPS ? 0 : A<B ? -1:1;}
ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll lcm(ll a, ll b) {return (a / gcd(a, b)) * b;}
ll modpow(ll a, ll b, ll m=MOD){a %= m; ll res = 1; while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){if(b<0){return 0;}ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
 
const int N = 100005;
vll adj[N];




int main(){ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n;cin>>n;
vector<pll>d;
rep(i,n){
	ll x,y;cin>>x>>y;
	d.pb({x,y});
	}
	bool check = false;
ll ans = 0;
rep(i,n){
	if(d[i].fi == d[i].se){
		ans++;
		}else{
		if(ans>=3){check = true;}
		ans = 0;
			}
	}
if(check || ans>=3){
	cout<<"Yes"<<endl;
	}else{
	cout<<"No"<<endl;
		}
}		
		
				




Measured memory_bytes: 5996
#          .g          `
#       .J.,M|  ..+NMMJMMMMNg..     `        `      `   `
#       ?TMa,5.MMMMMMM?MMMMMMMMt    _Z771,   (w.  j771. j_  z  `  `  `  `  `
#      dNHk;.NMMMB3???<ZZZZZW#^  `  _I  (Z  -C?l  j_  O j_  z`                `
#         .dMMM3_1????{ZZZZX=       _Ozr>`  J>.z_ jIz7! j7?7O`
#    `    dMMM!..__1=?>wZZC`        _I _O. (>  ?I j_    j_  z`
#        .MMM%.._Tm,?1>z0^          _C  _1.J`   (:j`    j`  z`   `  `  `  `  `
#        .Hmm..-?=!..``-gNNg-...`                -.
#     `  JMMMz>>????<<..WMMMMMMMMNe              !_                            `
#        ,MMMp?>?<<(;:(yI1rrwVMMMMM| z771.  `(v-  (C71+ (}  (:  `
#         WMMN<<(::;:!dyyIjtrrrdMMM\`O   w~  J<I  (}  (:(}  ({     `  `  `  `
#    `  `  TgMNx;;:;;(yyyyn1trqMMM# .OvO2!  (l.({ (Izv^ (C771{         .. .. .,
#           TMMMNgJ+!dyyyyynjMMMM#! `O _1. .v~`~z.(}    (}  ({    O?z(_.J..o.l,
#            .TMMMMM(MMMMMMMNWMM"    O  `1-(:   (l(}    (}  ({
#     `          ?""WMMMMMMW9^
#       `                                                      `


import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def dijkstra(n, start, nbl):
    """n: 頂点数, start: 始点, nbl: 隣接リスト"""
    import heapq
    WHITE = 1<<5
    GRAY = 1<<10
    BLACK = 1<<15
    color = [WHITE] * n
    distance = [INF] * n
    # parent = [-1] * n
    q = []

    distance[start] = 0
    heapq.heappush(q, (0, start))
    while len(q) != 0:
        du, u = heapq.heappop(q)
        # print("u: {}, du: {}".format(u, du))
        color[u] = BLACK
        if distance[u] < du:
            continue
        for next, cost in nbl[u]:
            if color[next] != BLACK and distance[u] + cost < distance[next]:
                distance[next] = distance[u] + cost
                color[next] = GRAY
                heapq.heappush(q, (distance[next], next))
    return distance

def main():
    n, m = map(int, input().strip().split())
    nbl = [[] for _ in range(n)]
    for i in range(n-1):
        nbl[i+1].append((i, 0))
    for i in range(m):
        l, r, c = map(int, input().strip().split())
        l -= 1
        r -= 1
        nbl[l].append((r, c))
    d = dijkstra(n, 0, nbl)
    if d[-1] == INF:
        print(-1)
    else:
        print(d[-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 79392
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <cmath>

using namespace std;

int main(int args, char *argc[]){
  int n;
  while(cin>>n){
    if(n==0)
      return 0;
    int a=0,b=0;
    for(int i=0;i<n;i++){
      int ia,ib;
      cin>>ia>>ib;
      if(ia==ib){
        a+=ia;
        b+=ib;
      }
      else if(ia<ib)
        b+=(ia+ib);
      else
        a+=(ia+ib);
    }
    printf("%d %d\n",a,b);
  }
  return 0;
}


Measured memory_bytes: 1144
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 1e5 + 5;
ll n, m, ans, a[N];
map<int, vector<int>>mp;
int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(i) a[i] += a[i - 1];
        mp[a[i] % m].push_back(i);
    }
    int rem = 0;
    for(int i = 0; i < n; i++){
        if(i) rem = (a[i - 1]) % m;
        if(!mp.count(rem)) continue;
        if(mp[rem].back() < i) continue;
        int idx = lower_bound(mp[rem].begin(), mp[rem].end(), i) - mp[rem].begin();
        ans += mp[rem].size() - idx;
    }
    cout << ans ;
    return 0;
}


Measured memory_bytes: 7936
#include<bits/stdc++.h>
        #define vll vector<ll>
        #define vi vector<int>
        #define vvi vector<vector<int>>
        #define vpll vector<pair<ll,ll>>
        #define pii pair<int,int>
        #define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
        #define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
        #define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
        #define MOD 1000000007
        #define INF 0x7FFFFFFF
        #define ALL(v) v.begin(), v.end()  
        #define m0(x) memset(x,0,sizeof(x))
        typedef long long ll;
         
        using namespace std;
         
        int main(){
            int N;
            cin >> N;
            int ans = pow(N, 3);
            
            cout << ans << endl;
            return 0;
        }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define deb(x) cout<<#x<<" = "<<x<<"\n";
#define mod 1000000007
int a[1000][1000];
int dp[1000][1000];
signed main()
{
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//#endif
	/************************************/
	
	int h, w; cin>>h>>w;
	for(int i=0; i<h; i++)
	{
		string s; cin>>s;
		for(int j=0; j<w; j++)
			a[i][j] = s[j] == '.';
	}
	for(int i=0; i<h; i++)
	{
		for(int j=0; j<w; j++)
		{
			if(i==0 && j==0) dp[i][j] = 1;
			else if(a[i][j] == 0) dp[i][j] = 0;
			else if(i==0) dp[i][j] = dp[i][j-1];
			else if(j==0) dp[i][j] = dp[i-1][j];
			else dp[i][j] = dp[i-1][j] + dp[i][j-1];
			if(dp[i][j] > mod) dp[i][j] -= mod;
		}
	}
	cout<<dp[h-1][w-1];
return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	string s;
	cin >> s;
	bool can = true;
	rep(i, 0, s.size()) {
		if (i % 2) {
			if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D')continue;
			else {can = false;break; }
		}
		else {
			if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D')continue;
			else { can = false;break; }
		}
	}
	if (can)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
deck = {"S":[0]*13, "H":[0]*13, "C":[0]*13, "D":[0]*13} 
 
n = input()
 
for i in range(0, n):
    suit, num = raw_input().split(" ")
    deck[suit][int(num)-1] = 1
 
for i in ["S", "H", "C", "D"]:
    for j in range(0, 13):
        if (deck[i][j] == 0):
            print("%s %d" % (i, j+1))

Measured memory_bytes: 6424