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

int compare(int a,int b){
    if (a < b){
        return a;}else{
            return b;
        }
}
int main(void){
    int A,B,C,D,Tr,Bu;
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&C);
    scanf("%d",&D);
    Tr = compare(A,B);
    Bu = compare(C,D);
    printf("%d",Tr + Bu);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <complex>
#include <vector>
#include <assert.h>

static const double EPS = 1e-5;
using namespace std;

typedef complex<double> Complex;
typedef vector<Complex> Polygon;

double cross(const Complex a, Complex b) {
  return imag(conj(a) * b);
}

double dot(Complex a, Complex b) {
  return real(conj(a) * b);
}

double ccw(Complex a, Complex b) {
  return a.real() * b.imag() - a.imag() * b.real();
}

int ccw3(Complex a, Complex b, Complex c) {
  b -= a; c -= a;
  if (cross(b, c) > 0) return 1;
  if (cross(b, c) < 0) return -1;
  if (dot(b, c) < 0) return +2;
  if (dot(b, c) > 0) return -2;
  return 0;
}

double area(Complex a, Complex b, Complex c) {
  Complex v1 = b - a;
  Complex v2 = c - a;
  return abs(v1.real() * v2.imag() - v2.real() * v1.imag()) / 2.0;
}

Complex intersection(const Complex s1, Complex e1, Complex s2, Complex e2) {
  double a = cross(e1 - s1, e2 - s2);
  double b = cross(e1 - s1, e1 - s2);
  if (abs(a) < EPS && abs(b) < EPS) { return s2; }
  if (abs(a) < EPS) { assert(false); }
  return s2 + b / a * (e2 - s2);
}

Polygon convex_cut(const Polygon &P, const Complex s1, const Complex e1) {
  Polygon Q;
  for (int i = 0; i < (int)P.size(); i++) {
    Complex a = P[i];
    Complex b = P[0];
    if (i != (int)P.size() - 1) {
      b = P[i + 1];
    }
    if (ccw3(s1, e1, a) != -1) { Q.push_back(a); }
    if (ccw3(s1, e1, a) * ccw3(s1, e1, b) < EPS) {
      Q.push_back(intersection(s1, e1, a, b));
    }
  }
  return Q;
}

void tyuusen(Complex a, Complex b, Complex &s1, Complex &e1) {
  Complex center = (a + b) / 2.0;
  s1 = center + (b - a) * Complex(0.0, -1000.0);
  e1 = center + (b - a) * Complex(0.0, 1000.0);
}

Polygon island;
Complex point[100];

int main() {
  int n, m;
  while (scanf("%d %d", &n, &m), n|m) {
  island.clear();
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    island.push_back(Complex(a, b));
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    point[i] = Complex(a, b);
  }
  for (int i = 0; i < m; i++) {
    Polygon voronoi = island;
    for (int j = 0; j < m; j++) {
      if (i == j) { continue; }
      Complex a, b;
      tyuusen(point[i], point[j], a, b);
      voronoi = convex_cut(voronoi, a, b);
    }
    double ans = 0.0;
    for (int k = 0; k < (int)voronoi.size(); k++) {
      Complex next = voronoi[0];
      if (k != (int)voronoi.size() - 1) { next = voronoi[k + 1]; }
      if (abs(voronoi[k].real() - next.real()) < EPS && abs(voronoi[k].imag() - next.imag()) < EPS) { continue; }
      ans += area(point[i], voronoi[k], next);
    }
    printf("%lf\n", ans);
  }
  }
  return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace CsharpSpiral {
    partial class Program {
        static void Main(string[] args) {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }
        public void Solve(ConsoleInput cin) {
            var S = cin.Read;
            Console.WriteLine(S[0]==S[1] && S[1]==S[2]?"No":"Yes");
        }


    }

    static class ExtendClass {
        public static void Swap<T>(this T[] X, int i, int j) {
            T tmp = X[i];
            X[i] = X[j];
            X[j] = tmp;
        }
        public static string Join<T>(this T[] X, string separator = " ") => string.Join(separator, X);
        public static S[] Clone<S>(this S[] src) where S : struct {
            var res = new S[src.Length];
            Array.Copy(src, res, src.Length);
            return res;
        }
    }

    class ConsoleInput {
        private readonly TextReader _stream;
        private readonly char _separator = ' ';
        private readonly Queue<string> inputStream;
        public ConsoleInput(TextReader stream, char separator = ' ') {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read {
            get {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) {
            var ret = new string[N];
            for(long i = 0; i < N; ++i)
                ret[i] = Read;
            return ret;
        }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 11220
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

dt = {'AC':0,'WA':0,'TLE':0,'RE':0}
for _ in range(inp()):
    s = input().strip()
    dt[s] += 1
for i in ['AC','WA','TLE','RE']:
    print(i,'x',dt[i])


Measured memory_bytes: 67876
n,k=map(int,input().split())
a=[]
b=[]
for i in range(n):
    ia,ib=map(int,input().split())
    a.append(ia)
    b.append(ib)
bit=0
while k>=(1<<bit):
    bit+=1
ret=0
for i in range(n):
    if k==k|a[i]:
        ret+=b[i]
for i in range(bit):
    if k&(1<<i):
        mask=((1<<bit)-1)^((1<<(i+1))-1)
        ok=(k&mask)|((1<<i)-1)
        tmp=0
        for j in range(n):
            if ok==ok|a[j]:
                tmp+=b[j]
        ret=max(ret,tmp)
print(ret)

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

int main(){
  long long n,i=0;
  cin>>n;
  long long count=2*(n/11),plus=0;
  while(11*count/2<n){
    if(i%2==0){
      plus++;
      n-=6;
      i++;
    }else{
      plus++;
      n-=5;
      i++;
    }
  }cout<<count+plus<<endl;
}

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

int main()
{
    string s,t; 

    cin>>s>>t; 

    string ans ; 

    int count =0  ,min_1 =INT_MAX; 
    for(int i=0 ;i<s.size() - t.size() +1; i++ )
    {
        int j;
        count =0 ; 
        for(j =0  ; j<t.size() ; j++)
        {
            if(s[i +j]!= t[j])
            {
                count++ ;
            }
        }

        min_1 = min(min_1 , count );
    }

    cout<<min_1; 


    

    
}

Measured memory_bytes: 3644
n,m = map(int,input().split())
ks = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))

ans = 0
for i in range(2**n):
	flag = True
	for j in range(m):
		res = 0
		for k in ks[j][1:]:
			res += (i//(2**(k-1)))&1
		if res%2 != p[j]:
			flag = False
	if flag == True:
		ans += 1
print(ans)

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

bool isNoWar(vector<int> &vecN, vector<int> &vecM, int z) {
  for(int i = 0; i < vecN.size(); i++) {
    if(vecN[i] >= z) return false;
  }
  for(int i = 0; i < vecM.size(); i++) {
    if(vecM[i] < z) return false;
  }
  return true;
}

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

  int n, m, x, y;
  cin >> n >> m >> x >> y;

  vector<int> vecN(n);
  for(int i = 0; i < n; i++) {
    cin >> vecN[i];
  }
  vector<int> vecM(m);
  for(int i = 0; i < m; i++) {
    cin >> vecM[i];
  }

  for(int z = x+1; z <= y; z++) {
    if(isNoWar(vecN, vecM, z)) {
      cout << "No War" << endl;
      return 0;
    }
  }

  cout << "War" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<queue>
#include<algorithm>
using namespace std;
string s[10000];
bool flag[10000][2];
int main(){
    int n;
    long a_cnt=0, b_cnt=0, ab_cnt=0;;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> s[i];
        if(s[i][0]=='B') flag[i][0]=true;
        else flag[i][0]=false;

        if( s[i][s[i].length()-1]=='A') flag[i][1]=true;
        else flag[i][1]=false;

        if( flag[i][0]&&flag[i][1] ) ab_cnt++;
        else if( flag[i][0] ) b_cnt++;
        else if( flag[i][1] ) a_cnt++;
    }
    int res=0;
    string st="AB";
    for(int i=0; i<n; i++){
        auto tmp = search(s[i].begin(), s[i].end(), st.begin(), st.end());
        while(tmp != s[i].end()){
            res++;
            tmp = search(tmp+1, s[i].end(), st.begin(), st.end());
        }
    }
    if( ab_cnt>0 ){
        res += ab_cnt-1;
        if( a_cnt>0){ res++; a_cnt--; }
        if( b_cnt>0){ res++; b_cnt--; }
    
    }
    if( a_cnt < b_cnt ) res+= a_cnt;
    else res+= b_cnt;

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main ( )
{
	//freopen(.in,r,stdin);
	//freopen(.out,w,stdout);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	if(n%2!=0)
	{
		cout<<n/2+1;
	 } 
	 else
	 {
	 	cout<<n/2;
	 }
	return 0;
 } 

Measured memory_bytes: 384
import collections
N=int(input())
lst=[]
for i in range(N):
    S, P=input().split()
    lst.append((i+1, S, int(P)))


lst.sort(key=lambda el:el[2], reverse=True)
lst.sort(key=lambda el:el[1])
#print(lst)
for el in lst:
    print(el[0])


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

int main(){
	int n;
	cin >> n;
	vector<int> h(n);
	for(int i=0;i<n;i++){
		cin >> h.at(i);
	}
	int cnt = 0;
	for(int i=0;i<n;i++){
		bool flag = true;
		for(int j=0;j<i;j++){
			if(h[j] > h[i]){
				flag = false;
			}
		}
		if(flag){
			cnt++;
		}
	}
	cout << cnt << endl;
}


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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i, m, n) for(int i = (int)m; i < (int)n; i++)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;

const int inf = 1e9;
/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n, k; cin >> n >> k;
    vi h(n); rep(i,n) cin >> h[i];
    vi cost(n, inf);
    cost[0] = 0;
    for(int i = 1; i < n; i++){
        for(int j = 1; (i < k ? j <= i : j <= k); j++){
            cost[i] = min(cost[i], cost[i-j] + abs(h[i] - h[i-j]));
        }
    }
    cout << cost[n-1] <<'\n';
}


Measured memory_bytes: 1024
n = gets.to_i

ans = Array.new(n+1, 0)
for x in 1..98
  for y in 1..98
    for z in 1..98
      rslt = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if rslt <= n
        ans[rslt] += 1
      end
    end
  end
end

for i in 1..n
  puts ans[i]
end

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

int main(){
  int N,dmin = 1000;
  cin >> N;
  for(int i = 0; i < N; i++){
    int A;
    cin >> A;
    int m = 0;
    while(A % 2 == 0){
      A /= 2;
      m++;
    }
    dmin = min(dmin,m);
  }
   cout << dmin << endl;   
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int sum = 0;
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                sum += a[i];
            }
            for (int ca : a) {
                if (ca >= sum - ca) {
                    out.println("No");
                    return;
                }
            }
            out.println("Yes");
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
            this.bufPointer = 0;
            this.bufLength = 0;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int nextInt() {
            int n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

    }
}



Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int q[102] = {};
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        q[p] = 1;
    }

    pair<int, int> r = { 1 << 30, -1 };
    for (int i = 0; i <= 101; i++) {
        if (!q[i]) {
            r = min(r, pair<int, int>{ abs(x - i), i });
        }
    }

    cout << r.second << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 100000000000000000
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int ka[100010];

int comb(int x, int y) {
	if (y > x)return 0;
	return ka[x] * mod_pow(ka[x - y], mod - 2, mod) % mod * mod_pow(ka[y], mod - 2, mod) % mod;
}

string s;
int x, y;
bool bl[16010], bl2[16010];
queue<int> que;

signed main() {
	cin >> s >> x >> y;
	int cnt = 0;
	bl[8000] = true;
	bl2[8000] = true;
	int k = 0;
	for (int j = 0; j < (int)s.size(); j++) {
		if (s[j] == 'F')cnt++;
		else {
			if (k == 0) {
				bl[8000] = false;
				bl[8000 + cnt] = true;
				cnt = 0;
				k = 2;
			}
			else if (k == 1) {
				for (int i = 0; i <= 16000; i++) {
					if (bl[i]) {
						if (i + cnt <= 16000)que.push(i + cnt);
						if (0 <= i - cnt)que.push(i - cnt);
						bl[i] = false;
					}
				}
				while (!que.empty()) {
					bl[que.front()] = true; que.pop();
				}
				cnt = 0;
				k = 2;
			}
			else if (k == 2) {
				for (int i = 0; i <= 16000; i++) {
					if (bl2[i]) {
						if (i + cnt <= 16000)que.push(i + cnt);
						if (0 <= i - cnt)que.push(i - cnt);
						bl2[i] = false;
					}
				}
				while (!que.empty()) {
					bl2[que.front()] = true; que.pop();
				}
				cnt = 0;
				k = 1;
			}
		}
	}
	if (k == 0) {
		bl[8000] = false;
		bl[8000 + cnt] = true;
		cnt = 0;
		k = 2;
	}
	else if (k == 1) {
		for (int i = 0; i <= 16000; i++) {
			if (bl[i]) {
				if (i + cnt <= 16000)que.push(i + cnt);
				if (0 <= i - cnt)que.push(i - cnt);
				bl[i] = false;
			}
		}
		while (!que.empty()) {
			bl[que.front()] = true; que.pop();
		}
		cnt = 0;
		k = 2;
	}
	else if (k == 2) {
		for (int i = 0; i <= 16000; i++) {
			if (bl2[i]) {
				if (i + cnt <= 16000)que.push(i + cnt);
				if (0 <= i - cnt)que.push(i - cnt);
				bl2[i] = false;
			}
		}
		while (!que.empty()) {
			bl2[que.front()] = true; que.pop();
		}
		cnt = 0;
		k = 1;
	}
	if (bl[8000 + x] && bl2[8000 + y])cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 384
using System;
namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            string input;
            while((input = Console.ReadLine()) != null){
                int weight = int.Parse(input);
                string output = string.Empty;
                for(int i=0;i < 10;++i){
                    output += ((weight >> i) & 0x01) == 0x01 ? Math.Pow(2, i).ToString() + " " : "";
                }
                Console.WriteLine(output.Trim());
            }
        }
    }
}

Measured memory_bytes: 5688
#include<bits/stdc++.h>
#include<math.h>
//#include<vector>
//#include <iostream>
//#include <algorithm>
#include <limits>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
int max(int a,int b){
	if(a>b){
		return a;
 
	}else{
		return b;
	}
}
void printdp(ll **dp,int N,ll Vmax){
	rep(i,N+1){
		for(ll j=0;j<Vmax+1;j++){
			if(dp[i][j]==llMAX)continue;
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;
	return;
}
int main(void){
	int N;
	int m=0;
	ll W;
	int i,k;
	ll j;
	cin >> N>>W;
	int v[N+1];
	long long Vmax=0;
	ll w[N+1];
	rep(i,N){
		cin >> w[i+1]>>v[i+1];
		Vmax += v[i+1];
	}
	ll **dp = (ll**)malloc(sizeof(ll *)*(N+1));
	rep(i,N+1){
		dp[i]=(ll *)malloc(sizeof(ll)*(Vmax+1));
		if (dp[i] == NULL) {
        	printf("Memory cannot be allocated.");
    	}
	}
	
	rep(i,Vmax+1){
		dp[0][i]=llMAX;
	}
	rep(i,N+1){
		dp[i][0] = 0;
	}
	//cout << "fsdfssdf";
	for(i=1;i<N+1;i++){
		for(j=1;j<Vmax+1;j++){
			//printdp(dp,N,Vmax);
			if(v[i]>j){
				dp[i][j]=(ll)(dp[i-1][j]);
				continue;
			}
			if(W<(ll)abs(dp[i-1][j-v[i]]+w[i])){
				dp[i][j]=(ll)(dp[i-1][j]);
			}else{
				dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
				m = max(j,m);
			}
		}
	}
	cout <<m;
	rep(i,N+1)free(dp[i]);
	free(dp);
	return 0;
}

Measured memory_bytes: 79488
#include <iostream>
#include <deque>
using namespace std;
int H,W,sx,sy,gx,gy;
string s[1000];
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int d[1000][1000];
int INF=1<<30;
main()
{
    cin>>H>>W;
    cin>>sx>>sy;
    cin>>gx>>gy;
    --sx;--sy;--gx;--gy;
    for(int i=0;i<H;++i)cin>>s[i];
    for(int i=0;i<H;++i)for(int j=0;j<W;++j)d[i][j]=INF;
    d[sx][sy]=0;
    deque<pair<int,int>> q;
    q.push_back({sx,sy});
    while(!q.empty())
    {
        int x=q.front().first;
        int y=q.front().second;
        q.pop_front();
        for(int i=0;i<4;++i)
        {
            int nx=x+dx[i];
            int ny=y+dy[i];
            if (nx<0||ny<0||nx>=H||ny>=W||s[nx][ny]=='#'||d[nx][ny]<=d[x][y])continue;
            d[nx][ny]=d[x][y];
            q.push_front({nx,ny});
        }
        for(int i=-2;i<=2;++i)for(int j=-2;j<=2;++j)
        {
            int nx=x+i;
            int ny=y+j;
            if (nx<0||ny<0||nx>=H||ny>=W||s[nx][ny]=='#'||d[nx][ny]<=d[x][y]+1)continue;
            d[nx][ny]=d[x][y]+1;
            q.push_back({nx,ny});
        }
    }
    cout<<(d[gx][gy]==INF?-1:d[gx][gy])<<endl;
}

Measured memory_bytes: 9420
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back

int N,A,B;
int ans=0;
int MOD=1000000007;
signed main(){
    scanf("%lld %lld %lld",&N,&A,&B);
    ans=min(A*N,B);
    printf("%lld\n",ans);
}


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

int main()
{ 
  int a, b, c ;
  cin >> a >> b >> c ;
  if((c > a && c < b) || (c > b && c < a))
  {
    cout << "Yes" << endl ;
  }
  else
  {
    cout << "No" << endl ;
  }
  
}

  



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

using namespace std;
int main() {

	char okada[55][55];
	int a = 0, b = 0, h = 0, w = 0;
	std::string str ;
	char c;
	int k = 0;
	std::cin >> k;
	b=k;
	while (k>0) {
	    a += k % 10;
		k = k / 10;
		
	}
	
	if (b%a == 0) {
		std::cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define pf push_front
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define rep(i,n) for(ll i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int M = 1000000007;
int ll_max=1e6;



int main() {
	// your code goes here
	IOS;
	ll n,m,i,j,d;
	
	
      ll x,y,t,a,b,c,k;
      cin>>x>>y;
      a=(4*x-y)/2;
      b=(y-2*x)/2;
      if(a<0||b<0){
            cout<<"No";
      }
      else{
            if((4*x-y)%2==0&&(y-2*x)%2==0){
                  cout<<"Yes";
            }
            else{
                  cout<<"No";
            }
      }
      return 0;
}

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

int main(){
    int a, b, c, ab, ac, bc;
    cin >> a >> b >> c;
    ab = a+b;
    ac = a+c;
    bc = b+c;
    int min = ab;
    if(ac <= min)
        min = ac;
    if(bc <= min)
        min = bc;
    cout << min << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include "iomanip"
#include <cstdio>
#include <cstring>
#include <set>
#include <vector>
#include <fstream>
#include <algorithm>
#include <queue>
#include <cassert>
#include <stack>


using namespace std;


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


    int n;
    cin >> n;
    cout << (int)pow(n, 3);
    return 0;
}


Measured memory_bytes: 256
tap_socket_num, required_socket = map(int, input().split())

if required_socket <= 1:
    print(0)
elif required_socket <= tap_socket_num:
    print(1)
else:
    n = (required_socket-tap_socket_num)%(tap_socket_num - 1)
    if n == 0:
        print((required_socket - tap_socket_num)//(tap_socket_num - 1) + 1)
    else:
        print((required_socket - tap_socket_num)//(tap_socket_num - 1) + 2)



Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int n;
  int m[31] = {1,1,2};
  
  loop(i,3,31){
    m[i] = m[i-1] + m[i-2] + m[i-3];
  }
  while(cin>>n,n){
    cout<<m[n] / 3650 + 1 <<endl;
  }
}

Measured memory_bytes: 1160
from math import gcd
from bisect import bisect_left, bisect_right

MOD = 10 ** 9 + 7
pow2 = [1] * (2 * 10 ** 5 + 1)
for i in range(1, 2 * 10 ** 5 + 1):
	pow2[i] = (pow2[i - 1] * 2) % MOD

N = int(input())
zero = 0
iwasies = []
for i in range(N):
	A, B = map(int, input().split())
	if A == 0 and B == 0:
		zero += 1
	elif A == 0:
		iwasies.append((0, 1))
	elif B == 0:
		iwasies.append((1, 0))
	else:
		g = gcd(A, B)
		A //= g
		B //= g
		if A < 0:
			iwasies.append((-A, -B))
		else:
			iwasies.append((A, B))

numiwasi = len(iwasies)
iwasies.sort()
badpairs = set()
for i in range(numiwasi):
	A, B = iwasies[i]
	abcount = bisect_right(iwasies, (A, B)) - bisect_left(iwasies, (A, B))
	
	Ao, Bo = B, -A
	if Ao < 0:
		Ao, Bo = -Ao, -Bo
	
	aobocount = bisect_right(iwasies, (Ao, Bo)) - bisect_left(iwasies, (Ao, Bo))
	
	if aobocount > 0:
		if (A, B) < (Ao, Bo):
			badpairs.add(((A, B, abcount), (Ao, Bo, aobocount)))
		else:
			badpairs.add(((Ao, Bo, aobocount), (A, B, abcount)))

sociable = numiwasi
ans = 1

for bp in badpairs:
	count1 = bp[0][2]
	count2 = bp[1][2]
	sociable -= (count1 + count2)
	ans = (ans * (pow2[count1] + pow2[count2] - 1)) % MOD
ans = (ans * pow2[sociable]) % MOD

print((ans + zero - 1) % MOD)	

Measured memory_bytes: 102012
#include <set>
#include <cstdio>
#include <algorithm>

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

using namespace std;

int main(){
	int n,r,L; scanf("%d%d%d",&n,&r,&L);

	set< pair<int,int> > S;
	rep(i,n) S.insert(make_pair(0,i));

	int t_prev=0;
	static int score[100000],total[100000];
	while(r--){
		int d,t,x; scanf("%d%d%d",&d,&t,&x); d--;

		total[S.begin()->second]+=t-t_prev;

		S.erase(S.find(make_pair(-score[d],d)));
		score[d]+=x;
		S.insert(make_pair(-score[d],d));

		t_prev=t;
	}
	total[S.begin()->second]+=L-t_prev;

	printf("%d\n",max_element(total,total+n)-total+1);

	return 0;
}

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

using namespace std ;

vector < string > v ;

int a , b ;

int x ;

int c [ 10001 ] ;

string s ;

bool ok ( int x )
{
    int d = x ;
    while ( x ){
        if ( c [ x % 10 ] == 1 ){
            return true ;
        }
        x /= 10 ;
    }
    cout << d ;
    return false ;
}

int main ()
{
    cin >> a >> b ;
    for ( int i = 1 ; i <= b ; ++ i ){
        cin >> x ;
        c [ x ] = 1 ;
    }
    x = a ;
    while ( ok ( x ) ){
        x ++ ;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N;
	cin >> N;
	set <ll> S;
	rep(i, N) {
		ll A;
		cin >> A;
		if (S.count(A)) {
			S.erase(A);
		}
		else {
			S.insert(A);
		}
	}
	cout << S.size() << endl;

}


Measured memory_bytes: 4864
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    vector<int> num(n,0);
    for(int i=0;i<m;i++){
        int s,c;
        cin >> s >> c;
        if(num.size()>=2 && s==1 && c==0){
            cout << -1 << endl;
            return 0;
        }
        if(num.at(s-1)==0 || num.at(s-1)==c){
            num.at(s-1)=c;
        }else{
            cout << -1 << endl;
            return 0;
        }
    }

    if(num.at(0)==0 && num.size()>=2) num.at(0)=1;
    for(int i=0;i<n;i++) cout << num.at(i);
    cout << endl;
}

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    ll a,b;
    char c; cin >> a >> c >> b;
    if(c == '+')out(a+b);
    else out(a-b);
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;


int main() {

    int N; cin >> N;
    vector<int> A(N);
    bool flag = true;

    REP(i, N){cin >> A[i];}

    REP(i, N){
        if( A[i] % 2 == 0 ){
            if(A[i] % 3 != 0 && A[i] % 5 != 0){
                flag = false;
                break;
            }
        }
    }

    if(flag == true){
        cout << "APPROVED" << endl;
    }else {
        cout << "DENIED" << endl;       
    }
    
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


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

    cout << (X-A)%B << endl;

    return 0;
}

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

int main() {
	int a,b;
	while(1){
		cin>>a>>b;
		if (a==0 && b==0){break;}
	for(int i=0; i<a; i++){
		for(int j=0; j<b; j++){
			cout<<"#";
		}
		
		cout<<endl;
	}
		cout<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3124
{-# LANGUAGE BangPatterns #-}

import qualified Data.ByteString.Char8 as C
import Data.Maybe
import Data.Vector.Unboxed ((!))
import qualified Data.Vector.Unboxed as V

main = sol <$> readLn <*> get >>= put

get = V.unfoldr (C.readInt . C.dropWhile (<'0')) <$> C.getLine

put = mapM_ (putStrLn . show)

sol n v = f <$> [1..n+1]
  where
  h = V.unsafeAccumulate_ (+) (V.replicate (n+1) 0) v (V.replicate (n+1) 1) :: V.Vector Int
  d = fromJust $ V.elemIndex 2 h
  i = V.elemIndices d v
  m = n-(V.last i-V.head i)
  f k
    | k==1      = n
    | k==n+1    = 1
    | k-1<=m    = (chs (n+1) k-chs m (k-1)) `mod` p
    | otherwise = chs (n+1) k
  chs i j = (fac!i) `prd` (ifac!j) `prd` (ifac!(i-j))
  nat = V.enumFromN 1 (n+1)
  fac = V.scanl' prd 1 nat
  bnd = inv $ fac!(n+1)
  ifac = V.scanr' prd bnd nat

inv 1 = 1
inv a = pwr a (p-2)

pwr :: Int -> Int -> Int
pwr !a !n
  | n == 0    = 1
  | odd n     = prd a r
  | otherwise = r
  where
  q = pwr a (n `div` 2)
  r = prd q q

prd = flip flip p . (mod .) . (*)

p = 10^9+7 :: Int

Measured memory_bytes: 10176
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int a,b,c,d; cin >> a >> b >> c >> d;
    if(a+b>c+d){out("Left");}
    else if(a+b==c+d){out("Balanced");}
    else out("Right")

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int n, A[50];

int solve(int i, int m){
	if(m == 0) return 1;
	if(i >= n) return 0;
	int res = solve(i + 1,m) || solve(i + 1,m - A[i]);
	return res;
}

int main(){
	int q,M,i;
	
	scanf("%d",&n);
	for(i = 0;i < n; i++) scanf("%d",&A[i]);
	scanf("%d",&q);
	for(i = 0;i < q; i++){
	scanf("%d",&M);
	if(solve(0, M)) printf("yes\n");
	else printf("no\n");
}
return 0;
}
	


Measured memory_bytes: 2124
/*  -*- coding: utf-8 -*-
 *
 * a.cc: C: 白昼夢 / Daydream
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const string DREAM = "dream";
const string ERASE = "erase";
const string ER = "er";
const string R = "r";

const int DN = 5, EN= 5, ERN = 2, RN = 1;

/* typedef */

/* global variables */

/* subroutines */

bool match(const string &s, int pos, const string &t) {
  int n = t.size();
  for (int i = 0; i < n; i++)
    if (s[pos + i] != t[i]) return false;
  return true;
}

/* main */

int main() {
  string s;
  cin >> s;
  int n = s.size();

  int pos = 0;
  while (pos < n) {
    //printf("s[%d]=", pos); cout << s.substr(pos) << endl;
    if (pos + DN <= n && match(s, pos, DREAM)) {
      pos += DN;
      if (pos + ERN <= n && match(s, pos, ER) &&
	  (pos + ERN == n || s[pos + ERN] != 'a')) pos += ERN;
    }
    else if (pos + EN <= n && match(s, pos, ERASE)) {
      pos += EN;
      if (pos + RN <= n && match(s, pos, R)) pos += RN;
    }
    else break;
  }

  cout << (pos == n ? "YES" : "NO") << endl;
  return 0;
}


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

int  main()
{
    ll n , w , wt , val;
    cin >> n >> w;
    vector<pair<ll,ll>> wt_val;
    wt_val.push_back({0,0});
    for(ll i = 1 ; i <= n ; i++)
    {
        cin >> wt >> val;
        wt_val.push_back({wt , val});
    }
    ll dp[n+1][w+1];
    for(ll i = 0 ; i < n+1 ; i++)
        for(ll j = 0 ; j < w+1 ; j++)
            dp[i][j] = 0;

    for(ll item = 1 ; item <= n ; item++)
        for(ll wt = 1 ; wt <= w ; wt++)
        {
            ll curr_item_wt =  wt_val[item].first ;
            ll curr_item_val = wt_val[item].second ;
            ll not_inc = dp[item-1][wt];
            ll inc = 0;
            if(wt-curr_item_wt >= 0)
                inc = curr_item_val +  dp[item-1][wt-curr_item_wt];
            dp[item][wt] = max(inc , not_inc);
        }

    cout << dp[n][w] << endl;
    
    return 0;
}  

Measured memory_bytes: 82380
#include <cstdio>

using namespace std;

char s[100'009];

int main() {
  int n;
  scanf("%d%s", &n, s);
  int ans = 0;
  for (int i = 1; i < n; ++i) {
    if (s[i] != s[i - 1]) {
      ++ans;
    }
  }
  ++ans;
  printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}

const ll mod = 1000000007;

ll mpow(ll a, ll x){
  ll res = 1;
  while(x > 0){
    if(x & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    x >>= 1;
  }
  return res;
}
int main(){
  int N; cin >> N;
  ll ans = 0;
  ans = mpow(10,N)-mpow(9,N)-mpow(9,N)+mpow(8,N);
  while(ans<0) ans += mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue


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 namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, t; cin >> n >> t;
	VE a(n); rep(i, n)cin >> a[i];
	int ans = t;
	rep(i, n - 1) {
		ans += min(t, a[i + 1] - a[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 99999999999
#define PRINT(var) std::cout<<#var"= "<<var<<std::endl

using namespace std;
typedef long long  int ll;

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

ll n,m;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n;
  ll mod=1000000007;
  ll ans=1;
  FOR(i,1,n+1) ans=ans*i%mod;
  cout <<ans <<endl;
  return 0;
}

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

int main(){
	int m = 0, n, count = 0;
  	string s;
  	cin >> n >> m;
  	vector<int> ccount(n);
	cin >> s;
	for(int i = 1; i < n; i++) {
		if(s[i-1] == 'A' && s[i] == 'C'){
          	ccount[i] = ++count;
	    } else {
        	ccount[i] = count; 
        }
    }
  	int l, r;
  	for(int i = 0; i < m; i++) {
    	cin >> l >> r; 
      	cout << ccount[r-1] - ccount[l-1] << endl;
    }
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=1e5+5;
const int MM=4e5+5;
int n,m,tot;
int to[MM*5],nxt[MM*5],h[MM+MN],cnt;
inline void ins(int s,int t){
	to[++cnt]=t;nxt[cnt]=h[s];h[s]=cnt;
	to[++cnt]=s;nxt[cnt]=h[t];h[t]=cnt;
}
int dis[MN+MM];
map<int,int>mp[MN];
typedef pair<int,int>pii;
priority_queue<pii,vector<pii>,greater<pii> >q;
int main(){
	scanf("%d%d",&n,&m);tot=n;
	for(reg int i=1,s,t,c;i<=m;i++){
		scanf("%d%d%d",&s,&t,&c);
		if(!mp[s][c])mp[s][c]=++tot,ins(mp[s][c],s);
		if(!mp[t][c])mp[t][c]=++tot,ins(mp[t][c],t);
		ins(mp[s][c],mp[t][c]);
	}
	memset(dis,0x3f,sizeof(dis));
	dis[1]=0;q.push(make_pair(0,1));
	while(!q.empty()){
		reg pii v=q.top();q.pop();
		if(v.first!=dis[v.second])continue;
		for(reg int i=h[v.second];i;i=nxt[i])
			if(dis[to[i]]>v.first+((v.second<=n)||(to[i]<=n)))
				dis[to[i]]=v.first+((v.second<=n)||(to[i]<=n)),
				q.push(make_pair(dis[to[i]],to[i]));
	}
	if(dis[n]==0x3f3f3f3f)puts("-1");
	else printf("%d\n",dis[n]/2);
	return 0;
}

Measured memory_bytes: 40824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
 
const int INF = (int)(1e9);
 
void upd(int &x, int y) {
    x = min(x, y);
}
 
int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif
 
 
    int n, m;
    while (cin >> n >> m) {
        vector<vector<int> > e(n, vector<int>(n, 0));
        for (int i = 0; i < m; i++) {
            int u, v, w;
            cin >> u >> v >> w;
            u--; v--;
            e[u][v] = e[v][u] = w;
        }
 
        int ans = INF;
        vector<vector<int> > dp(1 << n, vector<int>(n, INF));
        dp[1][0] = 0;
        for (int mask = 0; mask < (1 << n); mask++) {
            for (int last = 0; last < n; last++) {
                if (!(mask & (1 << last))) continue;

                vector<int> cost(n);
                for (int nw = 0; nw < n; nw++) {
                    for (int i = 0; i < n; i++) if ((mask & (1 << i)) && i != last) cost[nw] += e[nw][i];
                }
                int rmask = ((1 << n) - 1) ^ mask;
                for (int x = rmask; x; x = (x - 1) & rmask) {
                    int cur = 0;
                    for (int i = 0; i < n; i++) if (x & (1 << i)) cur += cost[i];
                    upd(dp[mask | x][last], dp[mask][last] + cur);
                }

                for (int nw = 0; nw < n; nw++) {
                    if (mask & (1 << nw)) continue;
                    if (e[last][nw] == 0) continue;
                    int cost = 0;
                    for (int i = 0; i < n; i++) if ((mask & (1 << i)) && i != last) cost += e[nw][i];
                    upd(dp[mask | (1 << nw)][nw], dp[mask][last] + cost);
                }
            }
        }
        ans = dp[(1 << n) - 1][n - 1];
        cout << ans << endl;
    }
 
 
#ifdef HOME
    cerr << "time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

Measured memory_bytes: 5632
// 課題3_3 AtCoder Beginner Contest 156 B - Digits
// nk777
 
#include <stdio.h>
 
int main(void){
    // 整数NのK進数のn,k、途中計算の値の格納n_cal、結果の格納result
    // 1の位分があるので初期設定はresult = 1(log_k(N)+1の1の部分)
    int n, k, n_cal, result = 1;
 
    // n,kを受け取る
    scanf("%d %d", &n, &k);

    // 最初の値を代入
    n_cal = n;

    while (n_cal >= k)
    {
        result++;
        n_cal = n_cal / k;
    }
    
    printf("%d\n", result);

    return 0;
}

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

int main() {
  string x;
  cin>>x;

  int cnt_t=0,cnt_s;
  for (int i=0; i<x.size(); i++) {
    if (x[i]=='T'&&cnt_s==0) cnt_t++;
    else if (x[i]=='T') cnt_s--;
    else cnt_s++;
  }
  
  cout<<cnt_s+cnt_t<<endl;
  return 0;
}

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

int main()
{
	int S;

	cin >> S;

	int h = (int)(S / 3600);
	int m = (int)((S - h * 3600) / 60);
	int s = S - h * 3600 - m * 60;

    cout << h << ":" << m << ":" << s << endl;

	return 0;
}


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

int main(){
	int n,y,i,j,k;
	cin >> n >>y;
	for(i=0;i<=n;i++){
		for(j=0;j<=n;j++){
				k=n-i-j;
				if(k>=0 && 1000*i+5000*j+10000*k == y){
				printf("%d %d %d\n",k,j,i);
				return 0;
			}
		}
	}
	printf("-1 -1 -1\n");
	return 0;
}


Measured memory_bytes: 888