akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long X;
  cin >> X;
  long long F = 100;
  long long year = 0;
  while (F < X){
    year++;
    F = F * 1.01 / 1;
  }
  cout << year;
}


Measured memory_bytes: 3604
import std.conv,
			 std.stdio,
			 std.string,
			 std.algorithm;

int xs[];
int get_numberof_primenumbers (int n) {
	if (n <= 1) return 0;

	int cnt = 0;

	xs = new int[n+1];
	fill(xs, true);

	foreach (int i; 2..n+1) {
		if (xs[i]) {
			++cnt;
			int j = i;
			while (n >= j) {
				xs[j] = false;
				j += i;
			}
		}
	}

	return cnt;
}

void main() {
	while (true) {
		string s = readln;
		if (stdin.eof()) break;
	int n = s.chomp.to!int;
	writefln("%d", get_numberof_primenumbers(n));
	}
	return;
}

Measured memory_bytes: 11076
#include<bits/stdc++.h>
using namespace std;
int main(){
  	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int x,t,c; cin>>x; t=x; c=0;
    c=250; 
    for(int i=c;i>=-c;i--){
        for(int j=c;j>=-c;j--){
            int u=pow(i,5)-pow(j,5); 
            if(u==x) {cout<<i<<" "<<j; return 0;}
        }
    }
    return 0;
}


Measured memory_bytes: 3984
N = int(input())
A = [list(map(int,input().split())) for _ in range(N)]

flag = [[0] * N for _ in range(N)]
dist = [line[:] for line in A]

for k in range(N):
    for i in range(N):
        for j in range(N):
            if i == j or j == k or k == i:
                continue
            if dist[i][j] > dist[i][k] + dist[k][j]:
                dist[i][j] = dist[i][k] + dist[k][j]
            elif dist[i][j] < dist[i][k] + dist[k][j]:
                flag[i][j] += 1

if A != dist:
    print(-1)
    exit()

ans = 0
for i in range(N):
    for j in range(N):
        if flag[i][j] == N-2:
            ans += A[i][j]

ans //= 2
print(ans)

Measured memory_bytes: 46816
#include <iostream>
#include <string>
#include <sstream>
#include <vector>

using namespace std;

struct Info {
  string word;
  int length;
  int hist;
};

vector<Info> words;
vector<Info>::iterator it;

void init(string s) {
  string word;
  stringstream ss;

  for (ss << s; !ss.eof();) {
    ss >> word;
    bool flag = false;
    for (it = words.begin(); it != words.end(); it++) {
      if (it->word == word) {
        flag = true;
        it->hist += 1;
      }
    }
    if (!flag) {
      Info info = { word, word.length(), 1 };
      words.push_back(info);
    }
  }
}

string find() {
  string mode = "", max = "";
  int m1 = 0, m2 = 0;
  
  for (it = words.begin(); it != words.end(); it++) {
    if (m1 < it->hist) m1 = it->hist;
    if (m2 < it->length) m2 = it->length;
  }
  
  for (it = words.begin(); it != words.end(); it++) {
    if (m1 == it->hist) mode = it->word;
    if (m2 == it->length) max = it->word;
  }

  return mode + " " + max;
}

int main() {
  string line, r;

  getline(cin, line);
  init(line);
  r = find();

  cout << r << endl;

  return 0;
}

Measured memory_bytes: 0
using System;

namespace ALDS1_2_B
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());

			int[] a = new int[n];
			string[] vs = Console.ReadLine().Split(' ');

			for(int i = 0; i < n; i++) {
				a[i] = int.Parse(vs[i]);
			}

			int swap = 0;
			for(int i = 0; i < n; i++) {
				int minj = i;
				for(int j = i; j < n; j++) {
					if(a[j] < a[minj]) {
						minj = j;
					}
				}

				if(a[minj] != a[i]) {
					int tmp = a[i];
					a[i] = a[minj];
					a[minj] = tmp;
					swap++;
				}
			}

			Output(a, n);
			Console.WriteLine(swap);
		}

		static void Output(int[] vs, int n)
		{
			string text = string.Empty;

			for(int i = 0; i < n; i++) {
				text += i == 0 ? $"{vs[i]}" : $" {vs[i]}";
			}

			Console.WriteLine(text);
		}
	}
}



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

int main(){
    vector<int> a;
    int ans=0;
    for(int i=0;i<3;i++){
        int b;cin>>b;
        a.push_back(b);
    }
    sort(a.begin(),a.end());
    int g=a[2]-a[0],h=a[2]-a[1];
    if(g%2==1&&h%2==1){
        a[0]++;a[1]++;ans++;
    }else
    if(g%2==0&&h%2==1){
        a[0]++;a[2]++;ans++;
    }else
    if(g%2==1&&h%2==0){
        a[2]++;a[1]++;ans++;
    }
    for(int i=0;i<2;i++){
        while(a[i]<a[2]){
            a[i]+=2;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,x;
	scanf("%d %d %d",&a,&b,&c);
	x=a+b+c;
	if(x==17){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

const int INF = 1 << 29;

int main() {
    int n;
    cin >> n;
    cout << (n + 1) * n / 2 << endl;
}


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

using namespace std;
using ll = long long;

int main() {
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	string s;
	cin >> s;
	A--;
	B--;
	C--;
	D--;

	bool okA = false;
	deque<int> que;
	que.push_back(A);
	while (!que.empty()) {
		int now = que.front();
		que.pop_front();
		if (now + 1 < N && s[now + 1] == '.') {
			que.push_back(now + 1);
			if (now + 1 == C) { okA = true; }
		}
		if (now + 2 < N && s[now + 2] == '.') {
			que.push_back(now + 2);
			if (now + 2 == C) { okA = true; }
		}
	}

	bool okB = false;
	while (!que.empty()) { que.pop_front(); }
	que.push_back(B);
	while (!que.empty()) {
		int now = que.front();
		que.pop_front();
		if (now + 1 < N && s[now + 1] == '.') {
			que.push_back(now + 1);
			if (now + 1 == D) { okB = true; }
		}
		if (now + 2 < N && s[now + 2] == '.') {
			que.push_back(now + 2);
			if (now + 2 == D) { okB = true; }
		}
	}

	if (D < C) {
		bool ok = false;
		for (int i = B; i <= D; ++i) {
			if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
				ok = true;
			}
		}
		if (ok && okA && okB) { cout << "Yes" << endl; }
		else { cout << "No" << endl; }
		return 0;
	}

	if (okA && okB) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir [] = {
	{ 1,0 },{ 0,1 }
};


signed main() {
	ll n, a, b;

	scnaf("%lld %lld %lld", &n, &a, &b);
	vector<ll> town(n);
	ll ans = 0;
	REP(i, n) {
		scanf("%lld", &town[i]);
	}

	REP(i, n - 1) {
		if ((town[i + 1] - town[i])*a > b)
			ans += (ll) b;
		else
			ans += (ll) (town[i + 1] - town[i])*a;
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}
  

Measured memory_bytes: 256
N, M = list(map(int,input().split()))
A = []
for i in range(M):
    in1, in2 = input().split()
    A.append([int(in1) - 1, in2])
    
ac = [0 for _ in range(N)]
wa = [0 for _ in range(N)]

for i in range(M):
    if A[i][1] == "AC":
        ac[A[i][0]] = 1
    else:
        if ac[A[i][0]] == 0:
            wa[A[i][0]] += 1
            
ac_sum = sum(ac)

wa_sum = 0
for i in range(N):
    if ac[i] == 1:
        wa_sum += wa[i]

print(ac_sum, wa_sum)

Measured memory_bytes: 72792
a=65280; b=61680; c=52428; d=43690; e=65535
QS = [[] for i in range(17)]
QS[1] = [a, b, c, d]
L = {a: 1, b: 1, c: 1, d: 1, e: 1, e: 1, 0: 1}
H = []
get = L.get
push = H.append
for l in range(1, 16):
    Q = QS[l]
    QN = QS[l+1]
    while Q:
        p = Q.pop()
        if L[p] < l: continue
        if l+1 < get(p ^ e, 17):
            L[p ^ e] = l+1
            l < 15 and QN.append(p ^ e)
        if l < 13:
            li = 13-l; l3 = 3+l
            for q, r in H:
                if r < li:
                    k = p & q
                    if r < get(k, 17)-l3: L[k] = l3+r; QS[l3+r].append(k)
                    k = p ^ q
                    if r < get(k, 17)-l3: L[k] = l3+r; QS[l3+r].append(k)
                elif r == li:
                    if p & q not in L: L[p & q] = 16
                    if p ^ q not in L: L[p ^ q] = 16
                else: break
        if l < 7: push((p, l))
print(*map(L.__getitem__, eval("e&"+",e&".join(open(0).read().replace(*"-~").replace(*"*&").replace(*"1e").split()[:-1]))),sep='\n')

Measured memory_bytes: 8308
#include<complex>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<vector>
#include<map>
#include<sstream>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<deque>
#include<queue>
#include<climits>
#include<list>
#include<stack>
#include<ctime>
#define all(n) n.begin(),n.end()
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define INF (1<<27)
#define EPS 1e-10
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define LIM 10000010
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef unsigned long long ull;
typedef long long ll;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
bool isprime[LIM];
vector<int> Quadruplet;

void sieve(){
  for(int i=0;i<=LIM;i++)isprime[i] = true;
  isprime[0] = isprime[1] = false;
  int Size = 0;
  for(int i=2;i<LIM;i++){
    if(isprime[i]){
      //prime.pb(i);
      Size++;
      for(int j=2*i;j<LIM;j+=i)isprime[j] = false;
    }
  }
 
  for(int i=0;i<LIM;i++){
    if(i+8 <= LIM && isprime[i] && isprime[i+2] && isprime[i+6] && isprime[i+8]){
      Quadruplet.pb(i+8);
    }
    
  }

}

int main(){
  clock_t start,end;
  //start = clock();

  sieve();
 
  //end = clock();

  //cout << setiosflags(ios::fixed) << setprecision(10) << (double)(end-start)/CLOCKS_PER_SEC << endl;

  int n;
  while(cin >> n && n){
    cout << (upper_bound(all(Quadruplet),n)[-1]) << endl;
  }
  return 0;
}

Measured memory_bytes: 10988
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define RREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll sum(ll n){
  return (1 + n) * (n) / 2;
}
int solve(){
  int n,k;
  cin >> n >> k;
  vector<int>v(n);
  rep(i,n)cin >> v[i];
  ll c = 0;
  ll s = 0;
  vector<ll>rui(n + 1);
  rep(i,n)rui[i + 1] = rui[i] + v[i];
  rep(i,n-k+1){
    ll tmp = rui[i + k] - rui[i];
    if(c <= tmp){
      c = tmp;
      s = i;
    }
  }
  long double tmp = 0;
  REP(i,s,s + k){
    tmp += (long double)sum(v[i]) / (long double)v[i];
  }
  cout << tmp << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  int com1=0,com2=0;
  string s,t;
  string str;

  cin>>n;
  cin>>s>>t;

  for(int i=1;i<=n*2;i++){
    if(i%2==1){ str+=s[com1]; com1++; }
    else{ str+=t[com2]; com2++; }
  }

  cout<<str<<endl;
  return 0;
}


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

using namespace std;

const int N = 2e5 + 5;
const long long MOD = 1e9 + 7;
int n;
long long arr[N];

long long binpow(long long a, long long b){
    if(b == 0){
        return 1;
    } else {
        long long x = binpow(a, b / 2);
        long long res = (x * x) % MOD;
        if(b & 1){
            res = (res * a) % MOD;
        }
        return res;
    }
}

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

    cin >> n;
    long long sum = 0;
    long long pows = 0;
    for(int i = 1; i <= n; i++){
        cin >> arr[i];

        sum = (sum + arr[i]) % MOD;
        long long k = (arr[i] * arr[i]) % MOD;
        pows = (pows + k) % MOD;
    }

    long long res = (sum * sum) % MOD;
    res = (res - pows) % MOD;
    if(res < 0){
        res += MOD;
        res = res % MOD;
    }


    res = (res * binpow(2, MOD - 2)) % MOD;

    cout << res << '\n';




    return 0;
}

Measured memory_bytes: 5212
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        if B[i] > A[i]:
            ans += A[i]
            B[i] -= A[i]

            if B[i] > A[i+1]:
                ans += A[i+1]
                A[i + 1] = 0

            else:
                ans += B[i]
                A[i+1] -= B[i]
        else:
            ans += B[i]
    print(ans)


if __name__ == "__main__":
    main()


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

int main (){
  vector<int> vec;
  int N;
  cin >> N;
  int P[N], Q[N];
  for (int i = 0; i < N; ++i) {
    vec.push_back(i + 1);
  }
  for (int i = 0; i < N; ++i) {
    cin >> P[i];
  }
  for (int i = 0; i < N; ++i) {
    cin >> Q[i];
  }

  int cnt_p = -1;
  int cnt_q = -1;
  int cnt = 0;
  do {
    if (cnt_p == -1) {
      bool f = true;
      for (int i = 0; i < N; ++i) {
        if (P[i] != vec[i]){
          f = false;
          break;
        }
      }
      if (f) {
        cnt_p = cnt;
      }
    }

    if (cnt_q == -1) {
      bool f = true;
      for (int i = 0; i < N; ++i) {
        if (Q[i] != vec[i]){
          f = false;
          break;
        }
      }
      if (f) {
        cnt_q = cnt;
      }
    }
    ++cnt;
  } while (std::next_permutation(vec.begin(), vec.end()));

  cout << abs(cnt_p - cnt_q) << endl;
  return 0;
}


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

int n, p;
string s;

long long sol() {
  long long cnt = 0;

  if (p == 2 || p == 5) {
    for (int i=n-1; i>=0; i--) {
      if ((int)(s[i] - '0') % p == 0) cnt += i+1;
    }
  }
  else {
    vector<int> pref(n+2);
    pref[n+1] = 0;
    long long b = 1;
    for (int i=n; i>=1; i--) {
      pref[i] = ((int)(s[i-1]-'0') * b + pref[i+1]) % p;
      b = b * 10 % p;
    }

    int rec[10002];
    memset(rec, 0, sizeof(rec));
    rec[0] = 1;
    for (int i=n; i>=1; i--) {
      cnt += rec[pref[i]];
      rec[pref[i]]++;
    }
  }
  return cnt;
}

int main() {
  cin >> n >> p >> s;
  cout << sol() << endl;
  return 0;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
#define int long long
#define pii pair<int, int>
  
using namespace std;
const int inf = 1e9 + 7;




signed main() {
	//freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++) cin >> a[i];
    sort(a.begin(), a.end());
	int res = inf;
	 for(int i = 0;i < n;i++) {
		int prev = a[(i - 1 + n) % n];
		int next = a[(i + 1) % n];
		int new_res = min((prev - a[i] + k) % k, (a[i] - next + k) % k);

		res = min(res, new_res);
	}

	cout << res;
}

Measured memory_bytes: 1792
import sys
L=list()
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,i=map(int,input().split())
N=int(input())
R=[a,b,c,d,e,f,g,h,i]
for k in range(N):
  A=int(input())
  if A in R:
    L.append(A)
  if a in L and b in L and c in L:
    print("Yes")
    sys.exit()
  if d in L and e in L and f in L:
    print("Yes")
    sys.exit()
  if g in L and h in L and i in L:
    print("Yes")
    sys.exit()
  if a in L and d in L and g in L:
    print("Yes")
    sys.exit()
  if e in L and b in L and h in L:
    print("Yes")
    sys.exit()
  if f in L and i in L and c in L:
    print("Yes")
    sys.exit()
  if a in L and e in L and i in L:
    print("Yes")
    sys.exit()
  if e in L and g in L and c in L:
    print("Yes")
    sys.exit()
print("No")

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

Measured memory_bytes: 1012
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;



int main()
{
   
    int d, t, s;
    cin >> d >> t >> s;
   
    int a = d / t;
    if (d % t)a++;
    cout << a * s << endl;
    
   
    return 0;

}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int h, w, k;
int a[310][310];
int num;
int cnt[310];
char c[310][310];

void solve(int cl, int cr) {
    vector<int> p;
    for (int i = cl; i <= cr; ++i) {
        for (int j = 1; j <= w; ++j) {
            if (c[i][j] == '#') p.push_back(j); //横方向でいちごのある位置
        }
    }

    sort(p.begin(), p.end());

    for (int i = 0; i < p.size(); ++i) {
        int v1 = 1, v2 = w;
        if (i >= 1) v1 = p[i-1] + 1;
        if (i < (int)p.size() - 1) v2 = p[i]; ////このif文は最後はwまで見たいので入れている

        num++;
        for (int j = cl; j <= cr; ++j) {
            for (int k = v1; k <= v2; ++k) {
                a[j][k] = num;
            }
        }
    }
}

int main() {

    cin >> h >> w >> k;

    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            cin >> c[i][j];
            if (c[i][j] == '#') cnt[i]++;
        }
    }

    vector<int> vec;
    for (int i = 1; i <= h; ++i) {
        if (cnt[i] >= 1) vec.push_back(i);
    }

    for (int i = 0; i < vec.size(); ++i) {
        int v1 = 1, v2 = h;
        if (i >= 1) v1 = vec[i-1] + 1; //前に#があった行の次の行から
        if (i < (int)vec.size() - 1) v2 = vec[i]; //このif文は最後はhまで見たいので入れている

        solve(v1, v2);
    }

    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            if (j >= 2) cout << " "; cout << a[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>

typedef std::pair<std::string,int> pa;
std::vector<pa>index;

int main(){
	std::string str;
	int page;
	while(std::cin>>str>>page){
		pa a;
		a.first=str,a.second=page;
		index.push_back(a);
	}
	std::sort(index.begin(),index.end());

	std::string d=index[0].first;
	std::cout<<d<<std::endl;
	std::cout<<index[0].second;

	for(int i=1;i<index.size();i++){
		if(index[i].first==d)std::cout<<" "<<index[i].second;
		else{
			std::cout<<std::endl;
			d=index[i].first;
			std::cout<<d<<std::endl;
			std::cout<<index[i].second;
		}
	}
	std::cout<<std::endl;
	return 0;
}

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

#define INF 1000000007
#define mem(dp,a) memset(dp,a,sizeof dp)
#define flash ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define f(i,n) for (ll i=0;i<n;i++)
#define sieve(j,mp) for(ll j=2*i ; j<=mp ; j+=i)
#define pb(x) push_back(x)
#define mp(x,y) push_back(make_pair(x,y))
#define tr(c,it) for(((c).begin())it=(c).begin();it!=(c).end();it++)
#define test ll t=1; while(t--)
#define F first
#define S second
main()
{
    flash
    clock_t launch=clock();
    test
    {
        string s1,s2;
        cin>>s1>>s2;
        ll l1=s1.length(),l2=s2.length();
        vector<char> ans;
        ll dp[l1+1][l2+1],x=l1,y=l2;
        mem(dp,0);
        rep(i,1,l1+1)
        rep(j,1,l2+1)
        if(s1[i-1]==s2[j-1])
        dp[i][j]=dp[i-1][j-1]+1;
        else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        while(x!=0&&y!=0)
        if(s1[x-1]==s2[y-1])ans.pb(s2[y-1]),x--,y--;
        else if(dp[x-1][y]>dp[x][y-1]) x--;
        else y--;
        reverse(ans.begin(),ans.end());
        for(auto i:ans)cout<<i;
        cout<<endl;
    }
    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
    return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int N, M;
    cin >> N >> M;
    ll h[N];
    int A[M], B[M];
    rep(i, N) cin >> h[i];
    rep(i, M) cin >> A[i] >> B[i];
    bool high[N];
    rep(i, N) high[i] = true;
    rep(i, M){
        if(h[A[i]-1] > h[B[i]-1]){
            high[B[i]-1] = false;
        }else if(h[A[i]-1] < h[B[i]-1]){
            high[A[i]-1] = false;
        }else{
            high[A[i]-1] = high[B[i]-1] = false;
        }
    }
    int cnt = 0;
    rep(i, N){
        if(high[i]){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 5280
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

int main() 
{ 
 

  
      ll n,k;
      lscf(n),lscf(k);

      ll v=max({n+k,n-k,n*k});

      lprin(v);



  



}

Measured memory_bytes: 3768
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  int N; cin>>N;
  int b4 = 0, b2 = 0, b1 = 0;
  for(int i=0; i<N; i++) {
    int a; cin>>a;
    if(a % 4 == 0) b4++;
    else if(a % 2 == 0) b2++;
    else b1++;
  }

  string ans = "No";
  if(b2 == 0) {
    if(b4 + 1 >= b1) {
      ans = "Yes";
    }
  } else {
    if(b4 >= b1) {
      ans = "Yes";
    }
  }
  cout << ans << endl;
}


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

int n, m;

int main()
{
	cin >> n;

	m = n % 10;

	if(m == 3)
		cout << "bon" << endl;
	else if (m == 0 || m == 1 || m == 6 || m == 8)
		cout << "pon" << endl;
	else
		cout << "hon" << endl;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

int read()
{
	int a = 0,x = 1;
	char ch = getchar();
	while(ch > '9' || ch < '0'){
		if(ch == '-') x = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9'){
		a = a*10 + ch-'0';
		ch = getchar();
	}
	return a*x;
}

int main()
{
	int  k = read();
	for(int i =1; i<= k;i ++) printf("ACL");
}

Measured memory_bytes: 1592
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
using namespace std;

#define int long long
#define INF 1e18

signed main() {
    double n, t, a; cin >> n >> t >> a;
    double deg = INF;
    int ans = 1;
    for(int i = 0; i < n; i++) {
        double h; cin >> h;
        double tmp = abs(t - h * 0.006 - a);
        if(tmp < deg) {
            deg = tmp;
            ans = i + 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define mem(a,h)          memset(a, (h), sizeof(a))
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<double, ii>  iii;
typedef pair<double, double>  iidb;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9+7;
const double PI = acos(-1);
#define initseg ll new_nodo=(pnodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 3600
#define offset 3000
#define ptr nodo*
const ll MOD=1e9+7;

using namespace std;
ll K;
ll vals[300];
ll sub=0;
void capturar(ll x,ll px)
{
	
	for(ll bit=30;bit>=0;bit--)
	{
		//cout<<bit<<": ";
		//cout<<((1<<bit)&x)<<' '<<((1<<bit)&K)<<' ';
		if ((1<<bit)&x)
		{
			if (!((1<<bit)&K))break;
		}
		if ((((1<<bit)&K) && !(((1<<bit)&x)))|| bit==0){
			vals[bit]+=px;
			//cout<<"add ";
		}
		//cout<<endl;
	}
}
int main()
{	
	ios::sync_with_stdio(false);cin.tie(0);
	ll n;
	cin>>n>>K;
	forr(i,0,n)
	{
		ll valor,peso;
		cin>>valor>>peso;
		capturar(valor,peso);
	}
	ll maxx=0;
	forr(i,0,31)
	{
		maxx=max(maxx,vals[i]);
	}
	cout<<maxx<<endl;
}			

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

int main(){
  while(true){
    int n;
    cin >> n;

    if(n==0)
      break;

    int a[1000];
    for(int i=0; i<n; i++){
      cin >> a[i];
    }

    int dif = 1000001;

    for(int i=0; i<n-1; i++){
      for(int j=i+1; j<n; j++){
        int d = abs(a[i]-a[j]);

        if(d<dif){
          dif = d;
        }
      }
    }
    cout << dif << endl;
  }
  return 0;
}



Measured memory_bytes: 3012
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		BigInteger bin = BigInteger.valueOf(n-2);		
		BigInteger bim = BigInteger.valueOf(m-2);		
		
		BigInteger ret = bin.multiply(bim).abs();
		
		
		System.out.println(ret.toString());
	}
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
    string o,e;
    cin>>o>>e;
    for(int i=2;i<=o.size()+e.size()+1;i++){
        if(i%2==0){
            cout<<o[i/2-1];
        }
        else{
            cout<<e[i/2-1];
        }
    }
    cout<<endl;
    return(0);
}

Measured memory_bytes: 3580
S = input()
lS = len(S)
l = []
c = -1
for i in range(lS):
    if (c == -1):
        l.append(S[i])
        c += 1
    elif (S[i] == "S"):
        l.append(S[i])
        c += 1
    elif (S[i] == "T"):
        if (l[c] == "S"):
            l.pop()
            c -= 1
        else:
            l.append(S[i])
            c += 1
            
print(c+1)


Measured memory_bytes: 5096
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  vector<int> par{0, 1, 2, 1, 4, 1, 4, 1, 1, 4, 1, 4, 1};
  int x, y;
  cin >> x >> y;
  if (par[x] == par[y]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,a,b) for(int i = a;i < b;i++)
#define _rep(i,a,b) for(int i = a;i <= b;i++)
typedef long long ll;

const int maxn = 110;
pair<int,int> bk[maxn];
pair<int,int> edge[210];

int main() {
	int n;
	scanf("%d",&n);
	if(n == 3) {
		printf("2\n1 3\n2 3\n");
		return 0;
	}
	else if(n == 4) {
		printf("4\n1 2\n2 4\n3 4\n1 3\n");
		return 0;
	}
	int cnt = 0;
	if(n%2 == 1) {
		bk[cnt].first = bk[cnt].second = n;
		n--;
		cnt++;
	}
	for(int i = 1;i <= n/2;i++) {
		bk[cnt].first = i;
		bk[cnt].second = n-i+1;
		cnt++;
	}

	int tot = 0;
	for(int i = 0;i < cnt;i++) {
		pair<int,int> cur = bk[i];
		pair<int,int> nxt = bk[(i+1)%cnt];
		if(cur.first == cur.second) {
			edge[tot++] = pair<int,int>(cur.first,nxt.first);
			edge[tot++] = pair<int,int>(cur.first,nxt.second);
		}
		else if(nxt.first == nxt.second) {
			edge[tot++] = pair<int,int>(cur.first,nxt.first);
			edge[tot++] = pair<int,int>(cur.second,nxt.first);
		}
		else {
			edge[tot++] = pair<int,int>(cur.first,nxt.first);
			edge[tot++] = pair<int,int>(cur.first,nxt.second);
			edge[tot++] = pair<int,int>(cur.second,nxt.first);
			edge[tot++] = pair<int,int>(cur.second,nxt.second);
		}
	}
	printf("%d\n",tot);
	for(int i = 0;i < tot;i++) printf("%d %d\n",edge[i].first,edge[i].second);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(){
    int n;
    std::cin >> n;
    for (int i = 0; i < 3; ++i)
    {
        if (n % 10 == 7)
        {
            std::cout << "Yes" << std::endl;
            return 0;
        }
        n /= 10;
    }
    std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>

using namespace std;
int main (){
	int i,o;
	while ( cin >> i >> o){
		if ( i < o ){
			cout << "a < b" << endl;
		}
		else if ( i > o ){
			cout << "a > b" << endl;
		}
		else{
			cout << "a == b" << endl;
		}
	}
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mp(a,b) make_pair(a,b)
#define vi vector<int>
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define vp vector<pair<int,int> >
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define F first
#define S second
#define endl "\n"
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define dom 998244353
#define pi 3.14159265
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define pii pair<int,int> 
#define mini 2000000000000000000
#define time_taken 1.0 * clock() / CLOCKS_PER_SEC
//mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
void shikhar7s(int cas)
{
    int n,i;
    cin>>n;
    int l=0,a,ans=0;
    fr(i,n)
    {
        cin>>a;
        if(a<l)
        {
            ans+=(l-a);
            a=l;
        }
        l=a;
    }
    cout<<ans;
}
signed main()
{
    fast;
    int t=1;
    //cin>>t;
    int cas=1;
    while(cas<=t)
    {
    shikhar7s(cas);
    cas++;
    }
    return 0;
}

Measured memory_bytes: 3648
n,l = map(int,input().split())

temp1 = [10**9] + [abs(l + i - 1) for i in range(1,n+1)]
temp2 = [10**9] + [l + i - 1 for i in range(1,n+1)]

ans = temp1.index(min(temp1))
print(sum(temp2[1:]) - temp2[ans])

Measured memory_bytes: 3060
n, m = map(int, input().split())
A = [[0 for _ in range(m)] for _ in range(n)]
B = [0 for _ in range(m)]
for y in range(n):
    column = list(map(int, input().split()))
    for x in range(m):
        A[y][x] = column[x]

for x in range(m):
    B[x] = int(input())

for a in A:
    c = 0
    for i in range(m):
        c += a[i]*B[i]
    print(c)



Measured memory_bytes: 5788
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 1e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int>switches[m];
	int p[m];
	for(int i = 0; i < m; i++)
	{
		int k; cin >> k;
		for(int j = 0; j < k; j++)
		{
			int a; cin >> a;
			switches[i].pb(a);
		}
	}
	for(int i = 0; i < m; i++)
		cin >> p[i];
	int ans = 0;
	for(int msk = 0; msk < 1 << n; msk++)
	{
		bool chk = true;
		for(int i = 0; i < m; i++)
		{
			int cnt = 0;
			for(int bulb : switches[i])
			{
				if(msk >> (bulb - 1) & 1)
					++cnt;
			}
			if(cnt % 2 != p[i])
			{
				chk = false;
				break;
			}
		}
		if(chk)
			++ans;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(void){
    ll n,h; cin>>h;cin>>n;
    vector<ll> a(n),b(n);
    for(int i=0;i<n;++i){
        cin>>a[i];cin>>b[i];
    }
    vector<vector<ll> > dp(n,vector<ll>(h+1,0));
    for(int i=0;i<n;++i){
        for(int j=1;j<=h;++j){
            if(i==0) dp[i][j] = dp[i][max(0LL,j-a[i])]+b[i];
            else{
                ll t1 = dp[i-1][j];
                ll t2 = dp[i-1][max(0LL,j-a[i])]+b[i];
                ll t3 = dp[i][max(0LL,j-a[i])]+b[i];
                //cout<<t1<<" "<<t2<<" "<<t3<<endl;
                dp[i][j] = min({t1,t2,t3});
            }
        }
    }

    cout<<dp[n-1][h]<<endl;
}


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

#define space cout<<" ";
#define line cout<<"\n";

using namespace std;


int main()
{
    string str;

    cin>>str;

    if(str[2]==str[3]&&str[4]==str[5])
    {
        cout<<"Yes";
    }
    else
        cout<<"No";

}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N,X,Y;
  cin>>N>>X>>Y;
  X--,Y--;
  vector<int>ans(N);
  for(int i=0;i<N;i++){
    vector<ll>dp(N,INT_MAX);
    dp[i]=0;
    for(int j=1;j<N;j++){
      if(j==Y)dp[Y]=min({dp[Y],dp[X]+1,dp[j-1]+1});
      else dp[j]=min(dp[j],dp[j-1]+1);
    }
    for(int j=N-2;j>=0;j--){
      if(j==X)dp[X]=min({dp[X],dp[Y]+1,dp[j+1]+1});
      dp[j]=min(dp[j],dp[j+1]+1);
    }
    for(int j=1;j<N;j++){
      if(j==Y)dp[Y]=min({dp[Y],dp[X]+1,dp[j-1]+1});
      else dp[j]=min(dp[j],dp[j-1]+1);
    }
    for(int j=N-2;j>=0;j--){
      if(j==X)dp[X]=min({dp[X],dp[Y]+1,dp[j+1]+1});
      dp[j]=min(dp[j],dp[j+1]+1);
    }
    for(int i=0;i<N;i++)ans[dp[i]]++;
  }
  for(int i=1;i<N;i++)cout<<ans[i]/2<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
 
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n, W; cin >> n >> W;
  vector<long long> dp(1<<17, 0);
  fill(dp.begin() + 1, dp.end(), -(1ll<<60));
  dp[0] = 0;
  for (int i = 1; i <= n; ++i) {
    int w, v; cin >> w >> v;
    for (int j = W; j >= w; --j) {
      dp[j] = max(dp[j], dp[j - w] + v);
    }
  }
  cout << *max_element(dp.begin(), dp.begin() + W + 1) << '\n';
}



Measured memory_bytes: 1280
import java.util.*

fun main(args:Array<String>){
    solve()
}

fun solve(){
    val s = read()
    var g = 0
    var p = 0
    var ans = 0
    for(i in 0 until s.length){
        if(s[i] == 'g'){
            if(p < g){
                ans++
                p++
            }
            else{
                g++
            }
        }
        else{
            if(p < g) p++
            else{
                g++
                ans--
            }
        }
    }
    println(ans)
}

fun read() = readLine()!!
fun reads() = readLine()!!.split(" ")
fun readint() = readLine()!!.toInt()
fun readints() = readLine()!!.split(" ").map{it.toInt()}
fun readlong() = readLine()!!.toLong()
fun readlongs() = readLine()!!.split(" ").map{it.toLong()}

Measured memory_bytes: 36932
#include <stdio.h>
 
int main(void){
 
  int n,m,l;
  int a[100][100] = {0};
  int b[100][100] = {0};
  long int c[100][100] = {0};
  register int i,j,s;
 
  scanf("%d %d %d",&n,&m,&l);
  for(i = 0;i < n;i++){
    for(j = 0;j < m;j++){
      scanf("%d",&a[i][j]);
    }
  }
  for(i = 0;i < m;i++){
    for(j = 0;j < l;j++){
      scanf("%d",&b[i][j]);
    }
  }
  for(i = 0;i < n;i++){
    for(j = 0;j < l;j++){
      for(s = 0;s < m;s++){
        c[i][j] += a[i][s] * b[s][j];
      }
    }
  }
  for(i = 0;i < n;i++){
    for(j = 0;j < l;j++){
      if(j == (l - 1)){
        printf("%ld\n",c[i][j]);
      }else{
        printf("%ld ",c[i][j]);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 764
A = int(input()) #500
B = int(input()) #100
C = int(input()) #50
X = int(input())

counter = 0
for a in range(A+1):
  if 500*a + 100*B + 50*C < X:
    continue
  for b in range(B+1):
    if 500*a + 100*b + 50*C < X:
   		continue
    for c in range(C+1):
      if 500*a + 100*b + 50*c == X:
        counter += 1
        
print(counter)

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

using namespace std;
#define ll long long
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
const ll mod = 1e9 + 7;

int main (){
   int n;
   cin >> n;
   ll ans = 1;
   REPS(i,n){
     
       ans *= i;
     ans %= mod;
   }
   cout << ans << endl;






    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <unordered_set>

using namespace std;

bool road[52][52][4];
int mov[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
const string dirs = "NESW";

vector<tuple<int, int, int, int>> dists[51][51][4][11];

int main(void) {
	int n, x0, y0, t;
	scanf("%d %d %d %d", &n, &x0, &y0, &t);
	for(int i = 0; i < n; i++) {
		int x[2], y[2];
		scanf("%d %d %d %d", x, y, x + 1, y + 1);
		if(x[0] > x[1]) swap(x[0], x[1]);
		if(y[0] > y[1]) swap(y[0], y[1]);
		if(y[0] == y[1]) {
			for(int i = x[0]; i <= x[1]; i++) {
				if(i > x[0]) road[i][y[0]][3] = true;
				if(i < x[1]) road[i][y[0]][1] = true;
			}
		} else {
			for(int i = y[0]; i <= y[1]; i++) {
				if(i > y[0]) road[x[0]][i][2] = true;
				if(i < y[1]) road[x[0]][i][0] = true;
			}
		}
	}

	for(int i = 0; i <= 50; i++)
		for(int j = 0; j <= 50; j++)
			for(int k = 0; k < 4; k++) {
				if(!road[i][j][k]) continue;

				queue<tuple<int, int, int>> curq;
				curq.push(make_tuple(i, j, k));

				for(int lv = 0; lv < 10; lv++) {
					set<tuple<int, int, int, int>> nexts;
					while(!curq.empty()) {
						int x, y, dir;
						tie(x, y, dir) = curq.front();
						curq.pop();

						if(!road[x][y][dir]) continue;

						int nx = x + mov[dir][0], ny = y + mov[dir][1];
						if(nx >= 0 and ny >= 0) {
							for(int d = -1; d <= 1; d++) {
								int ndir = (dir + d + 4) % 4;
								nexts.insert(make_tuple(nx, ny, ndir, d != 0));
							}
						}
					}
					for(auto &e: nexts) {
						int x, y, dir, turned;
						tie(x, y, dir, turned) = e;
						curq.push(make_tuple(x, y, dir));
						dists[i][j][k][lv + 1].push_back(e);
					}
				}
			}

	queue<tuple<int, int, int>> q;
	for(int i = 0; i < 4; i++)
		if(road[x0][y0][i])
			q.push(make_tuple(x0, y0, i));

	for(int i = 0; i < t; i++) {
		int step;
		char type[2];
		scanf("%d %s", &step, type);

		set<tuple<int, int, int>> nextStart;

		while(!q.empty()) {
			int x, y, dir;
			tie(x, y, dir) = q.front();
			q.pop();

			for(auto &next: dists[x][y][dir][step]) {
				int x, y, ndir, turned;
				tie(x, y, ndir, turned) = next;
				if(turned) {
					if(dirs[ndir] == type[0]) nextStart.insert(make_tuple(x, y, ndir));
				} else {
					if(dirs[ndir] == type[0])
						for(int d = -1; d <= 1; d++) {
							int curDir = (ndir + d + 4) % 4;
							nextStart.insert(make_tuple(x, y, curDir));
						}
				}
			}
		}

		for(auto &e: nextStart) q.push(e);
	}

	set<tuple<int, int>> ans;
	while(!q.empty()) {
		int x, y, dir;
		tie(x, y, dir) = q.front();
		q.pop();
		if(road[x][y][dir]) ans.insert(make_tuple(x, y));
	}

	for(auto &e: ans) printf("%d %d\n", get<0>(e), get<1>(e));

	return 0;
}

Measured memory_bytes: 111200
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string a,b;
    cin>>a;
    cin>>b;
   // int j;
    int n1=a.length(),n2=b.length();
    int ans=n2;
    for(int i=0;(i+n2-1)<n1;i++)
    {
        int count=0;
        for(int j=0,k=i;j<n2;j++,k++)
        {
            if(a[k]!=b[j])
            {
                count++;
            }
        }
       // cout<<"hai";
        ans=min(ans,count);
    }
    cout<<ans<<endl;




    return 0;
}

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

using namespace std;

const int N = 3005;

int n;
int p[2][N], sz[2];
int nxt[N * 2];
bool vis[N * 2];
string s;

struct Data {
	string s; int l, r;

	bool operator < (const Data& rhs) const {
		return make_pair(s, -l) < make_pair(rhs.s, -rhs.l);
	}
};

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> s;
	for (int i = 0; i < n * 2; ++i) {
		int x = s[i] - 'a'; p[x][sz[x]++] = i;
	}
	for (int i = 0; i < n; ++i) {
		nxt[p[0][i]] = p[1][i], nxt[p[1][i]] = p[0][i];
	}
	vector<Data> vec;
	for (int i = 0; i < n * 2; ++i) {
		if (s[i] != 'b' || i > nxt[i]) continue;
		string tmp;
		int lim = i;
		for (int j = i; j <= lim; ++j) {
			if (j < nxt[j] && s[j] == 'b') vis[j] = vis[nxt[j]] = 1, lim = nxt[j];
		}
		for (int j = i; j <= lim; ++j) {
			if (vis[j]) tmp += s[j], vis[j] = 0;
		}
		vec.push_back({tmp, i, lim});
	}
	sort(vec.begin(), vec.end());
	reverse(vec.begin(), vec.end());
	int cur = 0;
	string res;
	for (auto i : vec) {
		if (i.l < cur) continue;
		cur = i.r, res += i.s;
	}
	for (int i = cur; i < n * 2; ++i) {
		if (i < nxt[i]) vis[i] = vis[nxt[i]] = 1, i = nxt[i]; 
	}
	for (int i = cur; i < n * 2; ++i) {
		if (vis[i]) res += s[i];
	}
	cout << res;
}

Measured memory_bytes: 16256
s = list(input())

q = int(input())

before = []

after = []

cnt = 0

for i in range(q):
    t = list(input().split())
    
    if t[0] == "1":
        cnt += 1
    else:
        f = t[1]
        c = t[2]
        if f == "1":
            if cnt%2 == 0:
                before.append(c)                      
            else:
                after.append(c)
        else:
            if cnt%2 == 0:
                after.append(c)
            else:
                before.append(c)
                
if cnt%2 == 1:
    s.reverse()
    after.reverse()
    #before.reverse()
    for i in after:
        print(i,end = "")
    for i in s:
        print(i,end = "")
    for i in before:
        print(i,end = "")
else:
    before.reverse()
    before.extend(s)
    before.extend(after)
            
    for i in before:
        print(i,end = "")

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

ll H, W;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> H >> W;
  ll ans = 1LL << 40;
  for (int i = 1; i < H; i++) {
    ll A = i * W, B, C;
    B = ((H - i) / 2) * W;
    C = (H - i) * W - B;
    ans = min(ans, max({A, B, C}) - min({A, B, C}));
    B = (H - i) * (W / 2);
    C = (H - i) * W - B;
    ans = min(ans, max({A, B, C}) - min({A, B, C}));
  }
  for (int i = 1; i < W; i++) {
    ll A = i * H, B, C;
    B = ((W - i) / 2) * H;
    C = (W - i) * H - B;
    ans = min(ans, max({A, B, C}) - min({A, B, C}));
    B = (W - i) * (H / 2);
    C = (W - i) * H - B;
    ans = min(ans, max({A, B, C}) - min({A, B, C}));
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, L;
  cin>>N>>L;
  int ans = 0;
  if(L*(L+N-1)<=0) {
    for(int i=L;i<=L+N-1;++i) {
      ans += i;
    }
  }
  else if(L+N-1<0) {
    for(int i=L;i<L+N-1;++i) ans += i;
  }
  else {
    for(int i=L+1;i<=L+N-1;++i) ans += i;
  }
  cout<<ans<<endl;
}



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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;
int N,M,K;
int A[111111];

int dp[111111];

int nex[111111];
signed main(){
    cin>>N>>M>>K;
    rep(i,N)cin>>A[i];
    for(int i=0;i<N;i++)dp[i]=A[i];
    rep(i,K-1){
        deque<int>d;
        for(int j=0;j<N;j++){
            while(d.size()&&j-d.front()>M)d.pop_front();
            if(d.size())nex[j]=(i+2)*A[j]+dp[d.front()];
            else nex[j]=-INF;
            while(d.size()&&dp[d.back()]<=dp[j])d.pop_back();
            d.pb(j);
        }
        rep(j,N)dp[j]=nex[j];
    }

    cout<<*max_element(dp,dp+N)<<endl;
    return 0;
}


Measured memory_bytes: 2688
#define _GLIBCXX_DEBUG
#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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;
  a--; b--; c--; d--;
  string s; cin >> s;
  bool f=0;
  rep(i,n){
    if(a<i&&i+1<c&&s[i]=='#'&&s[i+1]=='#'){
      cout << "No" << endl;
      return 0;
    }
    if(b<i&&i+1<d&&s[i]=='#'&&s[i+1]=='#'){
      cout << "No" << endl;
      return 0;
    }
    if(i+2<n&&b-1<=i&&i<d&&s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.'){
      f=1;
    }
  }
  if(c>d&&f==0){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 640