akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  lint A[N],B[N];
  REP(i,N)cin>>A[i]>>B[i];
  map<lint,vector<lint> > m;
  REP(i,N){
    m[-A[i]-B[i]].push_back(A[i]);
  }
  lint ans=0;
  int t=0;
  for(auto& e:m){
    sort(ALL(e.second),greater<lint>());
    REP(i,e.second.size()){
      if(t==0){
        ans+=e.second[i/2];
        t=1;
      }else{
        ans-=-e.first-e.second[e.second.size()-1-i/2];
        t=0;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 12800
s = input()

if s == "SAT":
    print(1)
elif s == "SUN":
    print(7)
elif s == "MON":
    print(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)



Measured memory_bytes: 2940
using System;
using System.Collections.Generic;

//namespace _5_B

class Program
{
    static void Main(string[] args)
    {
        while (true)
        {
            //???????????????3????????????????????????????????????
            string readData = Console.ReadLine();

            //???????????¨??????????????????????????????H,W???????????????????????????
            string[] readDataValues = readData.Split(' ');
            int H = int.Parse(readDataValues[0]);
            int W = int.Parse(readDataValues[1]);

            //3??\?????????300??\????????´?????????
            if (3 > H || W > 300)
            {
                break;
            }

            for (int num = 1; num <= H; num++)
            {

                for (int digital = 1; digital <= W; digital++)
                {

                    //1???????????¨???
                    if (num == 1)
                    {
                        Console.Write("#");
                    }
                    //1??????????????¨???                
                    else if (digital == 1)
                    {
                        Console.Write("#");
                    }
                    //1?????????????????¨???
                    else if (digital == W)
                    {
                        Console.Write("#");
                    }
                    //1?????????????????¨???
                    else if (num == H)
                    {
                        Console.Write("#");
                    }
                    //????????\????????¨???
                    else
                    {
                        Console.Write(".");
                    }


                }
                //1???????????£??????????????????
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 8792
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;

constexpr int INF = 1e9;
constexpr ll BIGINF = 1e18;
constexpr double EPS = 1e-16;
constexpr int MOD = 1e9 + 7;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

int x;

void input() {
  cin >> x;
}

void solve() {
  map<int, int> a;

  a[3] = a[5] = a[7] = 1;

  string ans = "NO";

  if (a[x])
    ans = "YES";

  cout << ans << '\n';
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  preambule();
  input();
  solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000001

using namespace std;
#define ll long long
#define dbg if(0)

//0~1000の1001個。0~1000を1~1001にして0をつける

int main(){
    int n;
    cin>>n;
    ll ans=0;
    ll tile[1002][1002];
    int mx=0,my=0;
    for(int y=0;y<1002;y++){
        for(int x=0;x<1002;x++){
            tile[x][y]=0;
        }
    }
    for(int i=0;i<n;i++){
        int ax,ay,bx,by;
        cin >>ax>>ay>>bx>>by;
        ax++,ay++,bx++,by++;
        dbg mx=max(mx,bx);
        dbg my=max(my,by);
        tile[ax][ay]+=1;
        tile[ax][by]-=1;
        tile[bx][ay]-=1;
        tile[bx][by]+=1;
    }
    for(int y=0;y<1002;y++){
        for(int x=1;x<1002;x++){
            tile[x][y]=tile[x][y]+tile[x-1][y];
        }
    }
    for(int x=0;x<1002;x++){
        for(int y=1;y<1002;y++){
            tile[x][y]=tile[x][y]+tile[x][y-1];
            dbg cout<<tile[x][y]<<" ";
            ans=max(tile[x][y],ans);
            dbg if(y>my)break;
        }
        dbg cout << endl;
        dbg if(x>mx)break;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 10940
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    def dist_x(cx):
        b=0
        t=1000
        for _ in range(roop):
            cb=(t+2*b)/3
            ct=(2*t+b)/3
            if dist_xy(cx,cb)>dist_xy(cx,ct):
                b=cb
            else:
                t=ct
        return dist_xy(cx,b)

    def dist_xy(cx,cy):
        mx=0
        for x,y in xy:
            d=(x-cx)**2+(y-cy)**2
            if d>mx:mx=d
        return mx

    n = II()
    xy = [LI() for _ in range(n)]
    l=0
    r=1000
    roop=100
    for _ in range(roop):
        cl=(2*l+r)/3
        cr=(l+2*r)/3
        if dist_x(cl)>dist_x(cr):
            l=cl
        else:
            r=cr
    print(dist_x(l)**0.5)

main()


Measured memory_bytes: 3064
#include <algorithm>
#include <cstring>
#include <cctype>
#include <cstdio>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 2e6+5;
int n, ans, d = 1, q[N], l, r;
char s[N], t[N];
int main()
{  
    n = read(); scanf("%s%s", s+1, t+1);
    for(int i = n, p = n, l = 1, r = 0; i; --i)
    {
        d &= (s[i] == t[i]);
        if(t[i] == t[i-1]) continue;
        p = min(p, i);
        while(p&&s[p] != t[i]) --p;
        if(!p) return puts("-1"), 0;
        while(l <= r&&q[l]-(r-l+1)+1 > i) ++l; 
        q[++r] = p, ans = max(ans, (i != p)*(r-l+1));
    }
    printf("%d\n", ans+(d == 0));
    return 0;
}
/* 
4
bcad
*/

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

int main() {

	int n;
	cin >> n;
	for (int i = 3; i <= n; i++) {
		if (i % 3 == 0) cout << " " << i;
		else {
			int x = i;
			while (x > 1) {
				if (x % 10 == 3) {
					cout << " " << i; 
					break;
				}
				else {
					x /= 10;
				}
			}
		}
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3100
#!/usr/bin/env python3
import sys
import math

MOD = 1000000007  # type: int
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def solve(N: int, K: int):
    for i in range(1,K+1):
        split_pattern = combinations_count(K-1,i-1)
        if N-K >= i-1:
            print((split_pattern*combinations_count(N-K+1,i))%MOD)
        else:
            print(0)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		String a = sc.next();
		String b = sc.next();
		
		int[][] dp = new int[3100][3100];
		
		for(int i = 0; i < a.length(); i++) {
			for(int j = 0; j < b.length(); j++) {
				if(a.charAt(i) == b.charAt(j)) dp[i+1][j+1] = Math.max(dp[i][j] +1, dp[i+1][j+1]);
				
				dp[i+1][j+1] = Math.max(dp[i+1][j+1],  dp[i+1][j]);
				dp[i+1][j+1] = Math.max(dp[i+1][j+1], dp[i][j+1]);
			}
		}
		
		String res = "";
		
		int i = a.length();
		int j = b.length();
		
	    while (i > 0 && j > 0){
	        if (dp[i][j] == dp[i-1][j]) {
	        	i--;
	        }else if (dp[i][j] == dp[i][j-1]) {
	        	j--;
	        }else {
	            res = a.charAt(i-1) + res;
	            i--;
	            j--;
	        }
	    }
		
		out.println(res);
		
		out.flush();
	}
	
	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 86660
N,X,M = map(int,input().split())

l = [X]
a = X
k = 0
for i in range(M):
    if a**2%M not in l:
        l.append(a**2%M)
        a = a**2%M
    else:
        k = l.index(a**2%M)
        break
sum = 0
for i in range(k,len(l)):
    sum += l[i]

ans = 0

ans += ((N-k)//(len(l)-k))*sum

for i in range(min(k,N)):
    ans += l[i]

for i in range(1,(N-k)%(len(l)-k)+1):
    ans += l[k+i-1]

print(ans)


Measured memory_bytes: 70312
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  vector<ll> vec(5);
  rep(i,5){
    cin >>vec[i];
    if(vec[i]==0){
      cout <<i+1<<endl;
    return 0;
    }
  }
}

Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
#define INF 0x3f3f3f3f
using namespace std;
typedef unsigned long long LL;
const int maxn=1e5+7;
const int mod=1e9+7;
int read(){        
    int s = 0, f = 1;        
    char ch = getchar();        
    while(!isdigit(ch)) {        
        if(ch == '-') f = -1;        
        ch = getchar();        
    }        
    while(isdigit(ch)) {        
        s = s * 10 + ch - '0';        
        ch = getchar();        
    }        
    return s * f;        
}   
bool check(string str){
	int l=0,r=str.length()-1;
	while(l<=r){
		if(str[l]!=str[r])
		   return false;
		l++;
		r--;
	}
	return true;
}     
int main(){
	string s;
	cin>>s;
	int len=s.length();
	if(check(s)&&check(s.substr(0,(len-1)/2))&&check(s.substr((len-1)/2+1,(len-1)/2)))
	    cout<<"Yes"<<endl;
	else
	    cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue

# fact(int)
def fact(n):
  if(n == 1):
    return 1
  else:
    return (n * fact(n - 1))

# gcd(int,int)
def gcd(a,b):
  if a == 0:
    return b
  elif b == 0:
    return a
  else:
    return gcd(b,a % b)

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

# qsort(array[])
def qsort(seq):
  if len(seq) < 2:
    return seq
  else:
    beg, end = 0, len(seq) - 1
    mid = (beg + end) // 2
    smaller = [c for c in seq if seq[mid] > c]
    equal = [c for c in seq if seq[mid] == c]
    larger = [c for c in seq if seq[mid] < c]
    return (qsort(smaller) + equal + qsort(larger)) 

# = map(int, input().split())
# = int(input())
# = raw_input().split()
# = list(int(i) for i in input().split())

n,m = map(int, input().split())
if n == m:
  print('Yes')
else:
  print('No')


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

int main() {
	int n; cin >> n;
	vector<int> b(n - 1); rep(i, 0, n - 1) cin >> b[i];

	ll ans = b[0] + b[n - 2];
	rep(i, 0, n - 2) {
		ans += min(b[i], b[i + 1]);
	}

	cout << ans << endl;

	return 0;
}

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

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}

bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

int n,k;
char ch;
int x[100000], y[100000], c[100000];
int ma[2010][2010];
int solve(int x1, int y1, int x2, int y2){
    return ma[x2][y2] - ma[x2][y1] - ma[x1][y2] + ma[x1][y1];
}
int main(){
    cin >> n >> k;

    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i] >> ch;
        if(ch == 'W'){
            y[i] += k;
        }
    }


    for(int i = 0; i < n; i++){
        ma[y[i] % (2*k)+1][x[i]%(2*k)+1]++;
    }

    for(int i = 1; i <= 2 * k; i++){
        for(int j = 1; j <= 2*k; j++){
            ma[i][j] += ma[i][j-1];
        }
    }

    for(int i = 1; i <= 2 * k; i++){
        for(int j = 1; j <= 2*k; j++){
            ma[i][j] += ma[i-1][j];
        }
    }

    int ans = 0,sum;
    for(int i = 0; i <= k; i++){
        for(int j = 0; j <= k; j++){
            sum = ma[i][j]
                + ma[2*k][j] - ma[i+k][j]
                + ma[i+k][j+k] + ma[i][j] - ma[i][j+k] - ma[i+k][j]
                + ma[i][2*k] - ma[i][k+j]
                + ma[2*k][2*k] + ma[k+i][k+j] - ma[k+i][2*k] - ma[2*k][k+j];
            ans = max(ans, max(sum, n-sum));
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 17152
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  vector<int> heights(10);
  for (int i = 0; i < 10; i++) {
    cin >> heights[i];
  }

  sort(heights.begin(), heights.end(), greater<int>());
  
  for (int i = 0; i < 3; i++) {
    cout << heights[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 1212
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */
 
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>
 
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 1000000007
 
const long double PI = 3.141592653589793236L;
 
typedef long long int ll;
typedef long double ld;
 
using namespace std;
 
void solve()
{
    ll n, d;
    cin >> n >> d;

    int ans = 0;

    for(int i = 0; i < n; i++)
    {
        ll x, y;
        cin >> x >> y;

        if(x*x + y*y <= d*d)
        {
            ans++;
        }
    }

    cout << ans << "\n";
   
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    int T = 1;
    //cin >> T;
 
    while (T--)
    {
        solve();
    }
    
    return 0;
}
 


Measured memory_bytes: 3648
public class Main 
{
	public static void main(String[] args) 
	{
		for(int i = 1; i < 10; ++i)
		{
			for(int j = 1; j < 10; ++j)
			{
				System.out.println(i + "x" + j + "=" + i * j);
			}
		}
	}
}

Measured memory_bytes: 16852
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<functional>

using namespace std;

int main(){
    int n;
    long long ans = (long long)-1e18;
    cin >> n;
    vector<long long> a(3 * n);
    for(int i = 0; i < 3 * n; i++){
        cin >> a[i];
    }
    int k = 0;
    priority_queue<long long, vector<long long>, greater<long long>> q1;
    priority_queue<long long> q2;
    vector<long long> s1(n + 1), s2(n + 1);
    long long x = 0, y = 0;
    for(int i = 0; i < n; i++){
        x += a[i];
        q1.push(a[i]);
        y += a[3 * n - i - 1];
        q2.push(a[3 * n - i - 1]);
    }
    s1[0] = x; s2[n] = y;
    for(int i = 0; i < n; i++){
        if(q1.top() < a[n + i]){
            x += a[n + i] - q1.top();
            q1.pop();
            q1.push(a[n + i]);
        }
        s1[i + 1] = x;
        if(q2.top() > a[2 * n - i - 1]){
            y += a[2 * n - i - 1] - q2.top();
            q2.pop();
            q2.push(a[2 * n - i - 1]);
        }
        s2[n - i - 1] = y;
    }
    for(int i = 0; i <= n; i++){
        ans = max(ans, s1[i] - s2[i]);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int m=2;
  int count[101];
  for(int i=1;i<=100;i++)
    count[i]=0;

  vector<int> list[101];

  int a,b;
  while(cin >> a >> b){
    if(a>0 && b>0){
      count[a]++; count[b]++;
      m=max(m,max(a,b));

      list[a].push_back(b);
      list[b].push_back(a);
    }else{
      bool f[101];
      for(int i=1;i<=m;i++) f[i]=false;

      stack<int> cur;
      cur.push(1);
      f[1]=true;
      while(!cur.empty()){
        bool flg=false;
        for(vector<int>::iterator it=list[cur.top()].begin();it!=list[cur.top()].end();it++){
          if(!f[*it]){
            f[*it]=true;
            cur.push(*it);
            flg=true;
            break;
          }
        }
        if(flg) continue;
        cur.pop();
      }

      bool flg=true;
      for(int i=1;i<=m;i++) flg=(flg && f[i]);

      flg=(flg && (count[1]%2==1) && (count[2]%2==1));
      for(int i=3;i<=m;i++) flg=(flg && (count[i]%2==0));

      if(flg) cout << "OK" << endl;
      else cout << "NG" << endl;

      for(int i=1;i<=100;i++){
        count[i]=0;
        list[i].clear();
      }
      m=2;
    }
  }

  return 0;  
}

Measured memory_bytes: 3132
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int A,B,C,D,E,F;
  cin >> A >> B >> C >> D >> E >> F;

  vector<int> avaw;
  bool dp[31];
  fill(dp,dp+31,false);
  dp[0] = true;
  for(int i=0;i<31;i++){
    if(dp[i]){
      if(i + A <= 30){
        dp[i+A] = true;
      }
      if(i + B <= 30){
        dp[i+B] = true;
      }
      avaw.push_back(i*100);
    }
  }

  /*for(int i=0;i<avaw.size();i++){
    cout << avaw[i] << endl;
  }
  cout << endl;*/

  vector<int> avas;
  bool dp2[F];
  fill(dp2,dp2+F,false);
  dp2[0] = true;
  for(int i=0;i<F;i++){
    if(dp2[i]){
      if(i + C < F){
        dp2[i+C] = true;
      }
      if(i + D < F){
        dp2[i+D] = true;
      }
      avas.push_back(i);
    }
  }

  /*for(int i=0;i<avas.size();i++){
    cout << avas[i] << endl;
  }
  cout << endl;*/


  double std = (double)E / (double)(100 + E);
  double ans = 0;
  int ans1 = 0,ans2 = 0;
  for(int i=0;i<(int)avaw.size();i++){
    for(int j=0;j<(int)avas.size();j++){
      if(avaw[i]==0 && avas[j]==0) continue;
      double tmp;
      tmp = (double)avas[j]/(double)(avaw[i]+avas[j]);
      if(tmp <= std && ans <= tmp && avaw[i]+avas[j]<=F){
        ans = tmp;
        ans1 = avaw[i] + avas[j];
        ans2 = avas[j];
      }
    }
  }

  cout << ans1 << " " << ans2 << endl;
  return 0;
}


Measured memory_bytes: 256
n,k = (int(i) for i in input().split())
ans = ''
for i,a in enumerate(input()):
    if i == k-1:
        if a is 'A':
            a = 'a'
        elif a is 'B':
            a = 'b'
        else:
            a = 'c'
    ans += a
print(ans)


Measured memory_bytes: 2940
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,a[4];
	bool first=false;
	while(true){
	cin>>n;
	if(n==0)
		break;
	if(first==true)
		cout<<endl;
	first=true;
	int best=100;
	int abest[4];
	int nsum=0;
	for(int i=0;i<4;i++){
		cin>>a[i];
		nsum+=a[i];
	}
	for(int w500=0;w500<=a[3];w500++){
		for(int w100=0;w100<=a[2];w100++){
			for(int w50=0;w50<=a[1];w50++){
				for(int w10=0;w10<=a[0];w10++){
					int count=nsum-(w500+w100+w50+w10);
					int msum=w500*500+w100*100+w50*50+w10*10-n;
					if(msum>=0){
					while(true){
						if(msum<500)
							break;
						count++;
						msum-=500;
					}
					while(true){
						if(msum<100)
							break;
						count++;
						msum-=100;
					}
					while(true){
						if(msum<50)
							break;
						count++;
						msum-=50;
					}
					while(true){
						if(msum<10)
							break;
						count++;
						msum-=10;
					}
					if(best>count){
						best=count;
						abest[0]=w10;
						abest[1]=w50;
						abest[2]=w100;
						abest[3]=w500;
					}
					}
	            }
	        }
	    }
	}
	if(abest[0]!=0)
		cout<<"10 "<<abest[0]<<endl;
	if(abest[1]!=0)
		cout<<"50 "<<abest[1]<<endl;
	if(abest[2]!=0)
		cout<<"100 "<<abest[2]<<endl;
	if(abest[3]!=0)
		cout<<"500 "<<abest[3]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<iomanip>

using namespace std;

int main(){
    double inv, temp, ans;
    int n;
    inv = ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> temp;
        inv += 1 / temp;
    }
    ans = 1 / inv;
    cout <<fixed<< setprecision(10)<<ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	string str;
	cin >> str;
	if (str == "Sunny")
	{
		cout << "Cloudy" << endl;
	}
	else if (str == "Cloudy")
	{
		cout << "Rainy" << endl;
	}
	else
	{
		cout << "Sunny" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const auto INF = (ll)1e9;
using v = vector<int>;
using m = map<ll,int>;
using vv = vector<v>;
int main(){
    int n;
    cin >> n;
    auto a = m();

  	for (int i = 0; i < n; i++)
    {
        ll t = 0;
        cin >> t;
        if(a.find(t)!=a.end()){
            a[t]++;
        }else{
            a[t]=1;
        }
    }

    ll sum = 0;
    for (auto i:a)
    {
        if(i.second%2) sum++;
    }
    
    cout << sum;
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
 
using namespace std;
 
int main() 
{
  long long n, d;
  cin >> n >> d;
  long long ans = 0;
  long long x, y;
  for (int i = 0; i < n; i++)
  {
    cin >> x >> y;
    if (d * d >= x * x + y * y) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;

int dis[105][105];
int n,m;
pair< pair<int,int> , int> ed[1005];

int main()
{
	cin >> n >> m;
	memset(dis,'?',sizeof dis);
	for(int i=0;i<m;i++)
	{
		cin >> ed[i].F.F >> ed[i].F.S >> ed[i].S;
		dis[ed[i].F.F][ed[i].F.S]=ed[i].S;
		dis[ed[i].F.S][ed[i].F.F]=ed[i].S;
	}
	for(int i=1;i<=n;i++) dis[i][i]=0;
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[j][k]);
			int ans=0;
			for(int i=0;i<m;i++)
				ans+=dis[ed[i].F.F][ed[i].F.S]<ed[i].S;
			cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env perl

use strict;
use warnings;

my $nums = <STDIN>;
chomp($nums);

my ($A, $B, $C, $D) = split qr/\s+/, $nums;

my $AC = $A * $C;
my $AD = $A * $D;
my $BC = $B * $C;
my $BD = $B * $D;

print [sort { $b <=> $a } ( $AC, $AD, $BC, $BD )]->[0];

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

typedef vector<int> veci;
typedef pair<int,int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9+7)
#define fi first
#define se second

int main()
{
    ios::sync_with_stdio(false);
#ifdef LOCAL_TEST    
    int tcs;
    cin >> tcs;
    while (tcs-->0)
#endif        
{
    string s;
    cin >> s;

    bool res = false;
    while (!s.empty()) {
        s.pop_back();
        if (s.size()%2)
            continue;

        res = true;
        int half = int(s.size())/2;
        for (int i=0; i<half; ++i) {
            if (s[i]!=s[half+i]) {
                res = false;
                break;
            }
        }

        if (res)
            break;
    }

    cout << int(s.size()) << endl;
}}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s)                                                               \
    do {                                                                       \
    } while (0)
#define dump(x)                                                                \
    do {                                                                       \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

void solve() {
    string s, t;
    cin >> s >> t;
    int slen = s.size(), tlen = t.size();
    string ans;
    REP(i, 0, slen + 1) ans += 'z';
    string organs = ans;
    REP(i, 0, slen) {
        string u = s;
        bool b = true;
        REP(j, 0, tlen) {
            if (u[i + j] == '?')
                u[i + j] = t[j];
            else if (t[j] != u[i + j]) {
                b = false;
                break;
            }
        }
        if (!b)
            continue;
        REP(j, 0, slen) if (u[j] == '?') u[j] = 'a';
        ans = min(ans, u);
    }
    if (ans == organs)
        cout << "UNRESTORABLE" << endl;
    else
        cout << ans << endl;
}

int main() {
    solve();

    return 0;
}

Measured memory_bytes: 256
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>
#include <functional>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define loop(i, n) for (ll i = 0; i < n; ++i)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T LCM(T a, T b){
  return a*b/GCM(a,b);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();

void solution();
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

void solution(){
    ld s;
    cin >> s;
    ld maxvalue = 0; 
    ld length = s / 3.000000000000; 
  
    s -= length; 
  
    // finding breadth 
    ld breadth = s / 2.000000000000; 
  
    // finding height 
    ld height = s - breadth; 
  
    maxvalue = length * breadth * height *1.000000000000; 
  
    cout.precision(12);
    cout << maxvalue << endl;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, a[100000], i;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    for(i=0;i<n;i++){
        if(a[i]%2==0){
            if(a[i]%3!=0 && a[i]%5!=0){
                cout << "DENIED" <<endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" <<endl;
    return 0;
}

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

int xx[1000] , yy[1000];
int wf[1000][1000];
int main(){
	int n,X,Y;
	cin >> n;
	while(cin >> n >> X >> Y && n){
		memset(wf,0,sizeof(wf));
		int sx , sy = 0;
		cin >> sx >> sy;
		for(int i = 0 ; i < n ; i++){
			int x,y; cin >> x >> y;
			xx[i] = x , yy[i] = y;
		}
		for(int i = 0 ; i < n ; i++)
			for(int j = 0 ; j < n ; j++)
				if( i != j && (xx[i]-xx[j])*(xx[i]-xx[j])+(yy[i]-yy[j])*(yy[i]-yy[j]) <= 2500 ) wf[i][j] = 1;
		int p[1000];
		int q[1000];
		for(int i = 0 ; i < 1000 ; i++)
			p[i] = -1 , q[i] = -1;
		for(int i = 0 ; i < n ; i++){
			if((sx-xx[i])*(sx-xx[i])+(sy-yy[i])*(sy-yy[i]) <= 100){
				p[i] = X;
			}
		}
		bool flag; int cnt = 0;
		while(cnt != 100000){
			flag = false;/*
			for(int j = 0 ; j < n ; j++) 
				cout << p[j] << " " << q[j] << endl;
			cout << endl;*/
			for(int i = 0 ; i < n ; i++){
				if(p[i] > 0){
					flag = true;
				}
				p[i]--;
				q[i]--;
			}
			for(int i = 0 ; i < n ; i++){
				if(p[i] == 0){
					q[i] = Y;
				}
			}
			for(int i = 0 ; i < n ; i++){
				if(p[i] == 0){
					for(int j = 0 ; j < n ; j++){
						if(wf[i][j] && q[j] < 0){
							p[j] = X;
							flag = true;
						}
					}
				}
			}
			if(!flag) break;
			cnt++;
		}
		if(cnt == 100000) cout << "You're always welcome!" << endl;
		else cout << cnt << endl;
	}	
}
/*
11011

*/

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

#define rev(v) reverse(v.begin(), v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end()); 
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));

//ffs = lsb, clz = l0's, ctz = r0's, popcount = 1's 
 //++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
 //++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int maxdiv(int n){
    int ans = 0;
    while(n % 2 == 0){
        n /= 2;
        ++ans;
    }
    return ans;
}
int main(){
    fastio();
    int n; cin >> n;
    vector<int> v(n);
    int tot = 0;
    for(int i = 0;  i < n ; ++i){
        cin >> v[i];
        while(v[i] % 2 == 0){
            tot++;
            v[i]/=2;
        }
        //tot += maxdiv(v[i]);
    }
    cout << tot << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    char a,b;
    cin >> a >> b;
    if(a > b){
        cout << ">" << endl;
    }else if(a == b){
        cout << "=" << endl;
    }else{
        cout << "<" << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>

using namespace std;

typedef long long int ll;
typedef long int li;


int main(void){
    double ans=0;
    double t,x;
    cin >> t >> x;
    ans = t / x;
    cout << ans << endl;
    return 0;
}

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

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

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        int a, b;
        string[] arys;
        string result;
        
        //入力情報取得
        arys = Console.ReadLine().Split(' ');
        a = int.Parse(arys[0]);
        b = int.Parse(arys[1]);
        
        //両方 0 の場合は処理を抜ける
        while (a != 0 || b != 0) 
        {
            result = "";
            
            if (a > b) 
            {
                //左が大きい場合は結果を入替える
                result = string.Format("{0} {1}", b, a);
            }
            else
            {
                result = string.Format("{0} {1}", a, b);
            }
            
            //結果表示
            Console.WriteLine(result);
            
            //次の入力情報を取得
            arys = Console.ReadLine().Split(' ');
            a = int.Parse(arys[0]);
            b = int.Parse(arys[1]);
        }
    }
}


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

int main(){
	int n, k;

	cin >> n >> k;


	if ((n-1) % (k-1) == 0) {
		cout << (n - 1) / (k - 1) << endl;
	}
	else {
		cout << ((n - 1) / (k - 1)) + 1 << endl;
	}

    return 0;
}

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

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  
  for (int i = 0; i < 2000; ++i) {
    if (floor(i*0.08) == A && floor(i*0.10) == B) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin>>N;
	vector<int> t(N);
	vector<int> x(N);
	vector<int> y(N);
	for(int i=0; i<N; i++){
		cin>>t[i]>>x[i]>>y[i];
	}
	//入力終わり
	int sub=0;
	if(t[0]>=x[0]+y[0]){
		if((t[0])%2==(x[0]+y[0])%2){
			sub++;
		}
	}
	for(int i=0; i<N-1; i++){
		int sum=0;
		if(((abs(x[i+1]-x[i]))+(abs(y[i+1]-y[i])))%2==(abs(t[i+1]-t[i]))%2){
			sum++;
		}
		if(((abs(x[i+1]-x[i]))+(abs(y[i+1]-y[i])))<=(abs(t[i+1]-t[i]))){
			sum++;
		}
		if(sum==2){
			sub++;
		}
	}
	if(sub==N){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 
struct edge{int to,name;};
vector <edge> E[200010];

int main()
{ 
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;
        edge e;
        cin>>a>>b;
        e.to=b;
        e.name=i;
        E[a].push_back(e);
        e.to=a;
        E[b].push_back(e);
    }
    int t[n+1];
    for(int i=0;i<=n;i++){
        t[i]=i;
    }
    int C[n+1];//iの親方向の色
    int max=0;
    int s;
    for(int i=1;i<=n;i++){
        if(E[i].size()>max){max=E[i].size();s=i;}
    }
    cout<<max<<endl;
    C[s]=0;
    //木を上から下に
    int ans[n-1];
    queue <int> q;
    q.push(s);
    while(!q.empty()){
        int from;
        from=q.front();
        q.pop();
        int c=1;
        while(!E[from].empty()){
            edge e;
            e=E[from].back();
            E[from].pop_back();
            if(e.to!=t[from]){
                t[e.to]=from;
                q.push(e.to);
                //coloring
                if(c==C[from]){c++;}
                ans[e.name]=c;
                C[e.to]=c;
                c++;
            }
        }
    }
    for(int i=0;i<n-1;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 10112
#include <iostream>

using namespace std;
using lint = long long;
constexpr int mod=1e9+7;

template<int Modulo = mod>
struct Mint {
 
	lint val;
	constexpr Mint(lint v = 0) noexcept : val(v% Modulo) { if (val < 0) val += Modulo; }
 
	constexpr Mint& operator+=(const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator-=(const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator*=(const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator/=(const Mint& r) noexcept {
		lint a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			lint t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
 
	constexpr Mint operator+(const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator-(const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator*(const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator/(const Mint& r) const noexcept { return Mint(*this) /= r; }
 
	constexpr Mint operator-() const noexcept { return val ? Modulo - val : 0; }
 
	constexpr bool operator==(const Mint& r) const noexcept { return val == r.val; }
	constexpr bool operator!=(const Mint& r) const noexcept { return !((*this) == r); }
	constexpr bool operator< (const Mint& r) const noexcept { return val < r.val; }
 
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept { return os << x.val; }
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		lint tmp; is >> tmp;
		x = Mint(tmp);
		return is;
	}
 
	constexpr Mint pow(lint n) const noexcept {
		Mint res = 1, tmp = val;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};
 
using mint = Mint<>;

int main(){
  mint N,K;
  cin>>N>>K;
  cout<<(K-N-2)*(K*K*2-K*(N+2)-N*N-N-6)/6;
}


Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

signed main(){
	string S,T;
	cin>>S>>T;
	int ans=0;
	REP(i,3){
		if(S[i]==T[i]){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int main() {
	int a[1001] = {};
	for (int i = 1; i <= 1000; i++)
		a[i] = a[i - 1] + i;

	for (int N; cin >> N&&N;) {
		int cnt = 0;
		for (int i = 0; i <= 1000; i++)
			for (int j = i + 2; j <= 1000; j++)
				if (a[j] - a[i] == N)
					cnt++;

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

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG

 // 深さ優先探索
vector<bool> seen;
int dfs(const Graph &G, ll v) {
    seen[v] = true; // v を訪問済にする
    int score = 0; 

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー

        // 負荷さ優先探索中の処理



        dfs(G, next_v); // 再帰的に探索, 毎回mat渡してええの？
    }
    return score;
} 

/*
//桁数の計算
ll keta(ll num){
  ll ans= 0 ;
  ll rem;

  for (ll i = 4; i >= 0 ; i--){
    rem = pow(10,i);
    ans += (num / rem); 
    num = num % rem;
  }
  return ans;
}
*/


int main() {
  ll N, tmp;
  cin >> N;

  tmp = 1;

  for (ll i = 1; i<=N; i++){
    tmp = tmp * i % (1000000007);
  }

    cout << tmp <<endl; 

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
struct fastio { fastio () { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } _io;
template<class T, class U> bool chmax(T& a, const U &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> bool chmin(T& a, const U &b) { if (a > b) { a = b; return 1; } return 0; }

constexpr unsigned int D = 365;
constexpr unsigned int type = 26;
constexpr int INF = (1 << 30);
constexpr int X = 500;

using Data = pair<int, pair<array<int, type>, vector<int>>>;

array<int, type> c;
array<array<int, type>, D> s;

void input () {
	int buff;
	cin >> buff;
	for (int &i : c) cin >> i;
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < type; j++) {
			cin >> s[i][j];
		}
	}
}

vector<pair<int, int>> calc (int day, const array<int, type> &last) {
	array<int, type + 1> l, r; l[0] = r[type] = 0;
	vector<pair<int, int>> score;
	for (int i = 0; i < type; i++) l[i + 1] = l[i] + c[i] * (day - last[i]);
	for (int i = type; i > 0; i--) r[i - 1] = r[i] + c[i - 1] * (day - last[i - 1]);
	for (int i = 0; i < type; i++) {
		int val = s[day - 1][i] - (l[i] + r[i + 1]);
		score.emplace_back(val, i);
	}
	auto comp = [&](const pair<int, int> &r, const pair<int, int> &l) {
		if (r.first == l.first) {
			if (day == D) return r.second < l.second;
			return (s[day][r.second] > s[day][l.second]);
		}
		return (r.first > l.first);
	};
	sort(score.begin(), score.end(), comp);
	return score;
}


int main() {
	input();
	vector<Data> dat;
	{
		array<int, type> a;
		vector<int> b(0);
		fill(a.begin(), a.end(), 0);
		dat.emplace_back(0, pair(a, b));
	}
	
	auto comp = [](const Data &lhs, const Data &rhs) {
		return (lhs.first > rhs.first);
	};

	for (int day = 0; day < D; day++) {
		vector<Data> buff;
		for (size_t i = 0; i < dat.size(); i++) {
			vector<pair<int, int>> cd = calc(day + 1, dat[i].second.first);
			for (auto [v, id] : cd) {
				int val = dat[i].first + v;
				array<int, type> nxt;
				vector<int> con;
				tie(nxt, con) = dat[i].second;
				nxt[id] = day + 1;
				con.push_back(id);
				buff.emplace_back(val, pair(nxt, con));
			}
		}
		sort(buff.begin(), buff.end(), comp);
		buff.resize(X);
		dat.swap(buff);
	}

	for (int a : dat[0].second.second) cout << a+1 << '\n';
	
	return 0;
}


Measured memory_bytes: 31012
#include"bits/stdc++.h"
using namespace std;
struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0);cout<<fixed<<setprecision(10); } } ___;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}

#define pii pair<int,int>
#define ff first
#define ss second
#define endll '\n'
#define rep(i,n) for(int i=0;i++<n;)
#define scl(i) scanf("%lld",&i);

using ll = long long int;
using intt = long long int;

int main()
{
    ll x;cin>>x;
    ll a = 100;
    ll sum=0;
    while(a<x)
    {
        a += (a/100);
        sum++;
    }

    cout<<sum<<endl;
}


Measured memory_bytes: 3652
n=int(input())
S=input()

ans=0
import itertools
itr=itertools.product(list("1234567890"),repeat=3)

for it in itr:
    cnt=0
    for i in range(n):
        if S[i]==it[cnt]:
            cnt+=1
        if cnt==3:
            ans+=1
            break

print(ans)

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

int main() {
  int N;
  cin >> N;

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  bool increasing = false;
  bool decreasing = false;
  int ans = 1;
  for (int i = 1; i < N; i++) {
    if (A.at(i - 1) < A.at(i)) {
      increasing = true;
    }
    if (A.at(i - 1) > A.at(i)) {
      decreasing = true;
    }

    // 「増加のあとに減少」あるいは「減少のあとに増加」を確認したタイミングで
    // 数式の分割が発生する
    if (increasing && decreasing) {
      ans++;
      increasing = false;
      decreasing = false;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
int power(int x,int y,int p)
{
	int res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%p;
		
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
int modInverse(int n,int p)
{
	return power(n,p-2,p);
}
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 int x,n;
	 cin>>x>>n;
	 set<int> st;
	 for(int i=0;i<n;i++)
	 {
		 int val;
		 cin>>val;
		 st.insert(val);
	 }
	 int ans=-1;
	 int min_diff=INT_MAX;
	 for(int i=0;i<=200;i++)
	 {
		 if(!st.count(i))
		 {
			 int d=abs(x-i);
			 if(d<min_diff)
			 {
				 min_diff=d;
				 ans=i;
			 }
		 }
	 }
	 cout<<ans;
	 
	 return 0;
}


Measured memory_bytes: 3608
def main():
    N, M = map(int, input().split())
    ans = [-1] * N
    for _ in range(M):
        s, c = map(int, input().split())
        if ans[s-1] != -1 and ans[s-1] != c:
            print(-1)
            return
        ans[s-1] = c
    if N == 1 and ans[0] in (0, -1):
        print(0)
        return
    if ans[0] == 0:
        print(-1)
        return
    elif ans[0] == -1:
        ans[0] = 1
    for i in range(1, N):
        if ans[i] == -1:
            ans[i] = 0
    print("".join(map(str, ans)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a*a+b*b==c*c)
	 cout<<a*b/2<<endl;
	if(a*a+c*c==b*b)
	 cout<<a*c/2<<endl;
	if(b*b+c*c==a*a)
	 cout<<b*c/2<<endl;
	return 0;
}

Measured memory_bytes: 256