akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

namespace FFT{
  using dbl = double;
  
  struct num{
    dbl x,y;
    num(){x=y=0;}
    num(dbl x,dbl y):x(x),y(y){}
  };
  
  inline num operator+(num a,num b){
    return num(a.x+b.x,a.y+b.y);
  }
  inline num operator-(num a,num b){
    return num(a.x-b.x,a.y-b.y);
  }
  inline num operator*(num a,num b){
    return num(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x);
  }
  inline num conj(num a){
    return num(a.x,-a.y);
  }
 
  int base=1;
  vector<num> rts={{0,0},{1,0}};
  vector<int> rev={0,1};
 
  const dbl PI=acosl(-1.0);
 
  void ensure_base(int nbase){
    if(nbase<=base) return;
 
    rev.resize(1<<nbase);
    for(int i=0;i<(1<<nbase);i++)
      rev[i]=(rev[i>>1]>>1)+((i&1)<<(nbase-1));
 
    rts.resize(1<<nbase);
    while(base<nbase){
      dbl angle=2*PI/(1<<(base+1));
      for(int i=1<<(base-1);i<(1<<base);i++){
	rts[i<<1]=rts[i];
	dbl angle_i=angle*(2*i+1-(1<<base));
	rts[(i<<1)+1]=num(cos(angle_i),sin(angle_i));
      }
      base++;
    }
  }
 
  void fft(vector<num> &a,int n=-1){
    if(n==-1) n=a.size();
    assert((n&(n-1))==0);
 
    int zeros=__builtin_ctz(n);
    ensure_base(zeros);
    int shift=base-zeros;
    for(int i=0;i<n;i++)
      if(i<(rev[i]>>shift))
	swap(a[i],a[rev[i]>>shift]);
 
    for(int k=1;k<n;k<<=1){
      for(int i=0;i<n;i+=2*k){
	for(int j=0;j<k;j++){
	  num z=a[i+j+k]*rts[j+k];
	  a[i+j+k]=a[i+j]-z;
	  a[i+j]=a[i+j]+z;
	}
      }
    }
  }
 
  vector<num> fa;
 
  vector<Int> multiply(vector<int> &a,vector<int> &b){
    int need=a.size()+b.size()-1;
    int nbase=0;
    while((1<<nbase)<need) nbase++;
    ensure_base(nbase);
 
    int sz=1<<nbase;
    if(sz>(int)fa.size()) fa.resize(sz);
    for(int i=0;i<sz;i++){
      int x=(i<(int)a.size()?a[i]:0);
      int y=(i<(int)b.size()?b[i]:0);
      fa[i]=num(x,y);
    }
    fft(fa,sz);
 
    num r(0,-0.25/sz);
    for(int i=0;i<=(sz>>1);i++){
      int j=(sz-i)&(sz-1);
      num z=(fa[j]*fa[j]-conj(fa[i]*fa[i]))*r;
      if(i!=j)
	fa[j]=(fa[i]*fa[i]-conj(fa[j]*fa[j]))*r;
      fa[i]=z;
    }
    fft(fa,sz);
 
    vector<Int> res(need);
    for(int i=0;i<need;i++)
      res[i]=fa[i].x+0.5;
    
    return res;
  }
  
};

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n,m,q;
  cin>>n>>m>>q;
  vector<int> a(n),b(m),c(q);
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<m;i++) cin>>b[i];
  for(int i=0;i<q;i++) cin>>c[i];

  vector<int> sa(n+1,0),sb(m+1,0);
  for(int i=0;i<n;i++) sa[i+1]=sa[i]+a[i];
  for(int i=0;i<m;i++) sb[i+1]=sb[i]+b[i];

  const int SZ=200200;
  vector<int> A(SZ),B(SZ);
  for(int i=0;i<n;i++)
    for(int j=i+1;j<=n;j++)
      A[sa[j]-sa[i]]++;
  
  for(int i=0;i<m;i++)
    for(int j=i+1;j<=m;j++)
      B[sb[j]-sb[i]]++;
  
  reverse(B.begin(),B.end());
  auto C=FFT::multiply(A,B);

  for(int i=0;i<q;i++)
    if(c[i]) cout<<C[SZ-1-c[i]]+C[SZ-1+c[i]]<<endl;
    else cout<<C[SZ-1]<<endl;
  return 0;
}

Measured memory_bytes: 27232
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

int main(){

 long long x,N;
 cin>>N;
 vector<int>B(N);
  B[N-1] = 100000;

 for(int i=0;i<N-1;i++){
        cin>>x;
   B[i] = x;
 }

 long long ans = B[0];

 for(int i=1;i<N;i++){

 // cout<<B[i]<<"?"<<endl;
   int a = min(B[i],B[i-1]);

   ans += a;
 }

 cout<<ans<<endl;

 return 0;
}


Measured memory_bytes: 3632
import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.IArray             as IA
import qualified Data.Array.IO                 as AI
import qualified Data.Array.MArray             as MA
import qualified Data.Array.ST                 as STA
import qualified Data.Array.Unboxed            as AU
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Graph                    as G
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.IntSet                   as IS
import           Data.List
import qualified Data.Map.Strict               as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence                 as SQ
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Tree                     as T
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO Int
readInt = fst . fromJust . BS.readInt <$> BS.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readIntLists :: Int -> IO [[Int]]
readIntLists n = replicateM n readInts

readInteger :: IO Integer
readInteger = fst . fromJust . BS.readInteger <$> BS.getLine

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegerLists :: Int -> IO [[Integer]]
readIntegerLists n = replicateM n readIntegers

readStrings :: IO [String]
readStrings = map BS.unpack . BS.words <$> BS.getLine

readStringLists :: Int -> IO [[String]]
readStringLists n = replicateM n <$> readStrings

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putList :: Show a => [a] -> IO ()
putList [n     ] = print n
putList (n : ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n     ] = putStrLn n
putStrList (n : ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b | b         = putStrLn "YES"
             | otherwise = putStrLn "NO"

yesNo b | b         = putStrLn "Yes"
        | otherwise = putStrLn "No"

divCeiling x n | b == 0    = a
               | otherwise = a + 1
  where (a, b) = x `divMod` n

main = do
  n <- readInt
  print $ solve n

solve n = f 0 n

f s n
  | s > n     = 0
  | otherwise = ret + sum [f (s * 10 + 3) n, f (s * 10 + 5) n, f (s * 10 + 7) n]
  where ret = if l s then 1 else 0

l s = all (\c -> c `elem` ss) "357" where ss = show s



Measured memory_bytes: 892
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N; cin >> N;
    if(N == 3){
        cout << "2 5 63";
        return 0;
    }

    mat a(6, vec(0));
    FOR(i, 1, 30001) a[i % 6].push_back(i);

    cout << "2 3 4 9 ";
    N -= 4;

    int n = min(4999LL, N / 2);
    REP(i, n){
        cout << a[2][i + 1] << " " << a[4][i + 1] << " ";
    }
    N -= n * 2;

    n = min(2499LL, N / 2);
    REP(i, n){
        cout << a[3][2 * i + 2] << " " << a[3][2 * i + 3] << " ";
    }
    N -= n * 2;

    REP(i, N){
        cout << a[0][i] << " ";
    }
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

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

int main() {
	int a[4];
	for (int b = 0; b < 4; b++) {
		scanf("%d", &a[b]);
	}
	sort(a, a + 4);
	int sum = a[1] + a[2] + a[3];
	int p, q;
	cin >> p >> q;
	sum += max(p, q);
	cout << sum << endl;
}

Measured memory_bytes: 3212
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nk = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var have = new bool[nk[0]];
            for (var i = 0; i < nk[1]; i++)
            {
                var d = int.Parse(Console.ReadLine());
                var ai = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                for (var j = 0; j < ai.Length; j++)
                {
                    have[ai[j] - 1] = true;
                }
            }
            Console.WriteLine(have.Where(x => !x).Count());
        }
    }
}


Measured memory_bytes: 28520
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,ans=0;
pii a[200010];

int main()
{
	cin>>n;
	rep(i,n) cin>>a[i].fi;
	sort(a,a+n);
	for(int i=n-1;i>=0;i--)
	{
		if(a[i].se==-1) continue;
		LL pw=1;
		while(pw<=a[i].fi) pw*=2;
		int pos=lower_bound(a,a+i,mpr(pw-a[i].fi,0LL))-a;
		//cout<<i<<' '<<a[i].fi<<' '<<pw<<' '<<pos<<endl;
		//cout<<i<<' '<<pos<<" "<<a[i].fi<<' '<<a[pos-1].fi<<endl;
		if(pos<i&&a[i].fi+a[pos].fi==pw)
		{
			ans++;
			a[pos].se=-1;
		}
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define mem0(a) memset(a,0,sizeof(a))
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
const int mod=1e9+7;
const int N=1e5+5;
int a[N],b[N];
int main()
{
 int n;
 cin>>n;
 rep(i,0,n+1)
 {cin>>a[i];
 
 }
 ll ans=0;
 repb(i,1,n)
 {cin>>b[i];
   if(b[i]>=a[i-1]&&b[i]>=0&&a[i-1]>=0)
   {ans+=(a[i-1]);
  
   	b[i]-=a[i-1];
   	 a[i-1]=0;
   }
   else if(b[i]<a[i-1]&&b[i]>=0&&a[i-1]>=0)
   {
    ans+=b[i];
   
    a[i-1]-=b[i];
     b[i]=0;
   }
  //  ans+=min(b[i],a[i]);
   if(a[i]>=b[i]&&b[i]>=0&&a[i-1]>=0)
   {
   	ans+=b[i];
   	
   	a[i]-=b[i];
   	b[i]=0;
   }
   else if(a[i]<b[i]&&b[i]>=0&&a[i-1]>=0)
   {
   	 ans+=a[i];
   	 b[i]-=a[i];
   	 a[i]=0;
   }
  
 }
 cout<<ans;

}


Measured memory_bytes: 1024
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
    SELECT SYSIN ASSIGN TO KEYBOARD ORGANIZATION LINE SEQUENTIAL.

DATA DIVISION.
FILE SECTION.
FD SYSIN.
01 INP PIC X(2000000).
WORKING-STORAGE SECTION.
01 INF        PIC 9(19) VALUE 1000000000000000000.
01 maxlen     PIC 9(10) VALUE 100 COMP.
01 cur        PIC 9(10) VALUE 1 COMP.
01 i          PIC 9(10) VALUE 1 COMP.
01 j          PIC 9(10) COMP.
01 len        PIC 9(10) COMP.
01 ans        PIC 9(36) VALUE 1.
01 zs         PIC Z(35)9.
01 N          PIC 9(10).
01 flg        PIC 9(1) VALUE ZERO.
01 A1.
   03 A11 OCCURS 100000 DEPENDING ON N DESCENDING KEY A INDEXED BY K.
      05 A    PIC 9(19).

PROCEDURE DIVISION.
  ACCEPT N.
  OPEN INPUT SYSIN.
  READ SYSIN.
  CLOSE SYSIN.
  MOVE N TO maxlen.
  PERFORM maxlen TIMES
    PERFORM VARYING j FROM cur BY 1 UNTIL INP(j:1) = SPACE
    END-PERFORM
    COMPUTE len = j - cur
    MOVE INP(cur:len) TO A(i)
    IF ZERO = A(i)
      MOVE 1 TO flg
      EXIT PERFORM
    END-IF
    COMPUTE cur = j + 1
    ADD 1 TO i
  END-PERFORM.

  IF 1 = flg
    DISPLAY ZERO
  ELSE
    PERFORM VARYING i FROM 1 BY 1 UNTIL maxlen < i
      IF INF < A(i)
        MOVE 1 TO flg
        EXIT PERFORM
      END-IF
      IF INF < ans * A(i)
        MOVE 1 TO flg
        EXIT PERFORM
      ELSE
        MULTIPLY ans BY A(i) GIVING ans
      END-IF
    END-PERFORM
    IF 1 = flg
      DISPLAY -1
    ELSE
      MOVE ans TO zs
      DISPLAY FUNCTION TRIM(zs)
    END-IF
  END-IF.
  STOP RUN.


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

int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
// #ifndef ONLINE_JUDGE 
//     freopen("input.txt", "r", stdin); 
//     freopen("output.txt", "w", stdout); 
// #endif
    cout << setprecision(10) << fixed;
   int n;
   cin>> n;
   vector <double> dp(n+1);
   dp[0]=1;
   //probability that there are i heads so far
   for (int i=0;i<n;i++){
   		double current ;
   		cin>> current;
   		// for (int j=0;j<i-1;j++){
   		// 	dp[j+1]=dp[j]*(current)+(1-current)*dp[j+1];
   		// }
   		for (int j = i+1;j>=0;j--){
   			 
   			// continue;
   			dp[j]=(j==0 ? 0 :current*dp[j-1])+(1-current)*dp[j];
   		}
   		// for (int i=0;i<=n;i++){
   		// cout<< dp[i]<<" ";
   	

   }
   double ans=0;
   for (int i=0;i<=n;i++){
   		//cout<< dp[i]<<"\n";
   	if (i>n-i){
   		//cout<<i<<"\n";
   		ans+=dp[i];
   	}
   }
   	cout<< ans;
	return 0;

}


Measured memory_bytes: 384
import re

stack = []
_l = input().split(' ')

for c in _l:
    if re.match(r"(\+|\-|\/|\*)", c):
        f = stack.pop()
        z = stack.pop()
        stack.append(eval("{}{}{}".format(z, c, f)))
    else:
        stack += [c]

print(stack[0])

Measured memory_bytes: 7676
#include <iostream>
#include <iomanip>
 int main() {
  int a, b;
  std::cin >> a >> b; 
  std::cout << a/b <<std::endl;
  std::cout << a%b <<std::endl;
  double f;
  f = 1.00000 * a/b;
  std::cout << std::fixed << f <<std::endl;




 return 0;


}


Measured memory_bytes: 3252
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

using namespace std;
int main(){

    
    ll n;
    while(cin>>n){
        ll ans=0;
        ll j=1;
        for(int i=n*j;n*j<=600-n;i=n*j){
            ans+=pow(j*n,2)*n;
            j++;
        }
        
        cout<<ans<<endl;
        
        
    }
    
    
    
    
    
    return 0;
}



Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define pb push_back;
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<char, char> c_c;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
const int INF = 1e9;
const ll LLINF = 1e16;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    ll m;
    cin >> n >> m;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    set<int> s;
    vector<ll> b(n);
    b = a;
    for(int i=0; i<n; i++){
        int cnt = 0;
        while(a[i]%2 == 0){
            a[i] /= 2;
            cnt++;
        }
        s.insert(cnt);
        //b[i] = a[i];
    }
    ll sum = a[0];
    if (s.size() != 1){
        cout << 0 << endl;
        return 0;
    }
    else{
        //cout << LC << endl;
        for(int i=1; i<n; i++){
            sum = (sum*a[i])/(__gcd(sum, a[i]));
            if(sum>m){
                cout << 0 << endl;
                return 0;
            }
        }

        for(int i=0; i<*begin(s)-1; i++){
            sum *= 2;
            if(sum>m){
                cout << 0 << endl;
                return 0;
            }
        }
            //LCM求め終わり
    }
    
    int ans = 0;
    //cout << sum << endl;
    ll tot = sum;
    while(tot <= m){
        ans++;
        tot += sum*2;
    }
    cout << ans << endl;
}

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

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    vector<int> count(N, 0);
    int max = sqrt(N);
    for(int x = 1; x <= max; x++){
        for(int y = 1; y <= max; y++){
            for(int z = 1; z <= max; z++){
                int t = x*x + y*y + z*z + x*y + y*z + z*x;
                if(t-1 < N) count[t-1]++;
            }
        }
    }
    for(int ct : count){
        cout << ct << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3576
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve(sc *scanner, wr *bufio.Writer) {
	x := sc.getInt()

	ans := 1
	for i := 2; i*i <= x; i++ {
		j := i
		for j*i <= x {
			j *= i
		}
		ans = max(ans, j)
	}
	fmt.Fprintln(wr, ans)
}

func main() {
	sc := newScanner()
	wr := bufio.NewWriter(os.Stdout)
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)

	solve(sc, wr)
	wr.Flush()
}

// input ------------------------
type scanner struct {
	*bufio.Scanner
}

func newScanner() *scanner {
	sc := bufio.NewScanner(os.Stdin)
	return &scanner{sc}
}
func (sc *scanner) getInt() int {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getInt2() (int, int) {
	return sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt3() (int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt4() (int, int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInts(n int) []int {
	ret := make([]int, n)
	for i := range ret {
		ret[i] = sc.getInt()
	}
	return ret
}
func (sc *scanner) getString() string {
	sc.Scan()
	return sc.Text()
}
func (sc *scanner) getRunes() []rune {
	return []rune(sc.getString())
}
func (sc *scanner) getFloat() float64 {
	sc.Scan()
	ret, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := range ret {
		ret[i] = sc.getFloat()
	}
	return ret
}

// math ----------------------------
func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

func pow(a, b int) int {
	ret := 1
	for b > 0 {
		if b&1 > 0 {
			ret = ret * a
		}
		a = a * a
		b >>= 1
	}
	return ret
}


Measured memory_bytes: 1776
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto nm = readints;
    int n = nm[0], m = nm[1];
    long[][] a;
    for (int i = 0; i < n; i++) {
        a ~= reads!long;
    }

    a.sort!((a, b) => a[0] < b[0]);
    long ans = 0;
    long cnt = 0;
    foreach (e; a) {
        auto req = min(m - cnt, e[1]);

        ans += e[0] * req;
        cnt += req;
        if (cnt >= m) break;
    }
    writeln(ans);
}


Measured memory_bytes: 20476
#include<bits/stdc++.h>
using namespace std;
#define pi=cos
int main()
{
    int a,b;
    cin>>a>>b;
    if((a==1||a==2)&&(b==2||b==1))
        cout<<"3"<<endl;
    else if((a==2||a==3)&&(b==3||b==2))
        cout<<"1"<<endl;

    else
        cout<<"2"<<endl;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
use std::cmp::{max,min};
const MOD:i64 = 1000000007;
fn main(){
    input!{
        n:usize,
        m:usize,
        an:[usize;m],
    }
    let mut field = vec![true;n+1];
    for &a in &an {
        field[a] = false; 
    }
    let mut dp = vec![0i64;n+1];
    dp[0] = 1;
    for j in 0..n+1 {
        for k in (j+1)..j+3{
            if k >= n+1 {
                continue;
            }
            if field[k] {
                dp[k] += dp[j];
                dp[k] %= MOD;
            }
        }
    }
    println!("{}",dp[n]);
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main(){
	int n,k,q;
	cin >> n >> k >> q;
	vi ac(n,0);
	rep(i,q){
		int a;
		cin >> a;
		ac[a-1]++;
	}

	for(int i = 0; i < n; i++){
		cout << (k-q+ac[i] > 0 ? "Yes" : "No") << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
def main():
    import sys
    input=sys.stdin.readline
    n,q=map(int,input().split())
    from collections import deque,defaultdict
    dic=defaultdict(list)
    for i in range(n-1):
        x,y=map(int,input().split())
        dic[x-1].append(y-1)
        dic[y-1].append(x-1)
    cnt=[0]*n
    for i in range(q):
        x,y=map(int,input().split())
        cnt[x-1]+=y
    
    d=deque()
    d.append(0)
    completed=[False]*n
    while d:
        now=d.popleft()
        completed[now]=True
        for x in dic[now]:
            if completed[x]==False:
                cnt[x]+=cnt[now]
                d.append(x)
    print(*cnt)

if __name__=="__main__":
    main()

Measured memory_bytes: 73212
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


def main():
    k, s = map(int, input().split())

    c = 0
    for i in range(k+1):
        if i > s:
            break
        for j in range(k+1):
            if i + j > s:
                break
            if s-i-j <= k:
                c += 1

    print(c)


if __name__ == '__main__':
    main()


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

int main(){
    long long n;
    cin >> n;
    long long sum = 0;
    for(long long i=1;i<=n;i++){
        if(!((i % 3 == 0) || (i % 5 ==0))){
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3632
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define repi(i,a) for(auto i = a.begin(); i!= a.end() ;++i) 
#define repdi(i,a) for(auto i = a.rbegin(); i!=a.rend();++i) 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define INF 1e18
#define sz(a) (int)a.size() 
#define all(a) a.begin(),a.end()
#define mod 998244353
#define limit 1000
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;  

typedef vector<ll> vll;
typedef pair<ll,ll> pii;
typedef vector<pii> vpi;
typedef vector<vector<ll> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
ll dp[100005],a[100005],n;

ll ans(int i) {
	if(i==n-2) return dp[i] = abs(a[i]-a[i+1]);
	if(i==n-3) return dp[i] = min(abs(a[i]-a[i+1])+ans(i+1),abs(a[i]-a[i+2]));
	if(dp[i]!=-1) return dp[i];
	return dp[i] = min(abs(a[i]-a[i+1])+ans(i+1),abs(a[i]-a[i+2])+ans(i+2));
}

void solve() {
	cin >> n ;
	rep(i,0,n) cin >> a[i] ;
	fl(dp,-1);
	cout << ans(0) ;
}

int32_t main() {
  
    fast; 
	int t=1;
	// cin>>t;
	rep(i,0,t) {
		solve() ;
	}

	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define mem(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 7;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

int main() {
	ll n;
	cin>>n;
	ll ans = 0;
	for(ll i=1;i<=n;i++){
		ll t = n/i;
		int b1 = i,b2 = i*t;
		ll sum = (b1+b2)*t/2;
		ans+=sum;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3632
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
	LL n, k;
	cin >> n >> k;
	LL ans = n;
	if (ans > 0) {
		if (k * 10 < n) {
			LL c = max(0LL, (n - k) / k - 2);
			n -= c * k;
		}
		for (int i = 0; i < 10000; ++i) {
			n = abs(n - k);
			ans = min(ans, n);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from pprint import pprint
from collections import defaultdict
import itertools

N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(int, input().split())) for _ in range(N)]

mod3_dict_tbl = [defaultdict(int) for _ in range(3)]
for i in range(N):
    for j in range(N):
        mod3_dict_tbl[(i+1+j+1) % 3][c[i][j]-1] += 1

ans = []

colors = [i for i in range(C)]

for to_colors in itertools.permutations(colors, 3):
    tmp_diff = 0
    for i,to_color in enumerate(to_colors):
        for k,v in mod3_dict_tbl[i].items():
            tmp_diff += D[k][to_color]*v
    ans.append(tmp_diff)

print(min(ans))


Measured memory_bytes: 47068
/*input
3 10
2 3 4 5 5 7
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int a[maxn];

int main()
{
	// IOS;
	int n,p;
	cin>>n>>p;
	REP(i,2*n) cin>>a[i];
	sort(a,a+n+n,greater<int>());

	int bst=INF;
	int len;
	for(len=0;len<2*n;len+=2){
		int pt=upper_bound(a,a+n+n,p-a[len/2],greater<int>())-a;
		--pt;
		if(len/2%2==pt%2) pt--;
		// cout<<len/2<<' '<<pt<<'\n';
		if(pt<0) break;
		bst=min(bst,len/2+pt+1);
		if(bst<len+2) break;
	}
	// cout<<len<<'\n';
	int ans=0;
	REP(i,len/2){
		ans=max(ans,a[i]+a[len-1-i]-p);
		assert(a[i]+a[len-1-i]>=p);
	}
	REP(i,n-len/2){
		ans=max(ans,a[len+i]+a[n+n-1-i]);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	static long ans = Integer.MAX_VALUE;
	static int[] u;
	static int[][] d;
	static int n, m, r;
	static boolean[] used = new boolean[9];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		m = sc.nextInt();
		r = sc.nextInt();
		u = new int[9];
		for(int i = 0; i < r; i++) u[i] = sc.nextInt() - 1;
		d = new int[201][201];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				if(i != j) d[i][j] = Integer.MAX_VALUE / 10;
			}
		}
		for(int i = 0; i < m; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			int c = sc.nextInt();
			d[a][b] = d[b][a] = c;
		}
		for(int k = 0; k < n; k++) {
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < n; j++) {
					d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
		dfs(0, -1, 0);
		System.out.println(ans);
	}

	static void dfs(int x, int last, int sum) {
		if(x == r) {
			ans = Math.min(sum, ans);
			return;
		}
		// 訪れたい場所を全列挙
		for(int i = 0; i < r; i++) {
			if(!used[i]) {
				used[i] = true;
				if(last == -1) dfs(x + 1, i, 0);
				else dfs(x + 1, i, sum + d[u[last]][u[i]]);
				used[i] = false;
			}
		}
	}

}

Measured memory_bytes: 45276
#include<stdio.h>
#include<math.h>
int prime[1000000];
int main(void){

    int i,j,sq_n,count;
    double n;

    while(scanf("%lf",&n)!=EOF){
        count=0;
        sq_n=sqrt(n);
        for(i=0;i<n;i++)
            prime[i]=1;
        prime[0]=0;

        for(i=1;i<sq_n;i++){
            if(prime[i]==1){
                for(j=(i+1);(i+1)*j<=n;j++) {
                    prime[(i+1)*j-1]=0;
                }
            }
        }
        for(i=0;i<n;i++){
            if(prime[i]==1){
                count++;
            }
        }
        printf("%d\n",count);
    }


    return 0;
}

Measured memory_bytes: 4528
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a < 9 && b <9) {
			System.out.print("Yay!");

		} else {
			System.out.print(":(");
		}
	}
}

Measured memory_bytes: 23764
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	int pn = 1;
	if (*ci == '-') {
		pn = -1;
		ci++;
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	return pn * tmp;
}

void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	ll tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint();
	ll A[200001];
	A[0] = 0;
	rep1(i, N) {
		A[i] = getint() + A[i - 1];
	}

	pakuri_sort(N + 1, A);

	ll kotae = 0;
	int kazu = 1;
	rep(i, N) {
		if (A[i + 1] != A[i]) kazu = 1;
		else kotae += kazu++;
	}

	printf("%lld\n", kotae);

	Would you please return 0;
}

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

int main() {
	// 0-ind
	int N, M; cin >> N >> M;
	vector<vector<int>> g(N, vector<int>(0));
	for (int i = 0; i < M; i++) {
		int A, B; cin >> A >> B;
		A--; B--;
		g[A].push_back(B);
		g[B].push_back(A);
	}
	int ans = 0;
	vector<bool> r(N, false);
	queue<int> q;

	for (int s = 0; s < N; s++) {
		if (r[s]) continue;
		r[s] = true;
		q.push(s);
		int temp = 1;
		while (!q.empty()) {
			int u = q.front(); q.pop();
			for (int v : g[u]) {
				if (r[v]) continue;
				r[v] = true;
				q.push(v);
				temp++;
			}
		}
		if (temp > ans) ans = temp;
	}
	cout << ans << endl;
}

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

struct StNode
{
  StNode* m_poParnt;
  StNode* m_poLeft;
  StNode* m_poRigt;
  int m_nKey;

  StNode(int nNo) :
    m_poParnt(nullptr), m_poLeft(nullptr), m_poRigt(nullptr), m_nKey(nNo)
  { }
};

void fnPreOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  cout << " " << poNode->m_nKey;
  fnPreOrder(poNode->m_poLeft);
  fnPreOrder(poNode->m_poRigt);
}

void fnInOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnInOrder(poNode->m_poLeft);
  cout << " " << poNode->m_nKey;
  fnInOrder(poNode->m_poRigt);
}

void fnInsert(StNode*& rpoRoot, StNode* poNewNod)
{
  StNode* poParnt = nullptr;
  StNode* poNode = rpoRoot;

  while (poNode != nullptr)
  {
    poParnt = poNode;
    if (poNewNod->m_nKey < poNode->m_nKey)
      poNode = poNode->m_poLeft;
    else
      poNode = poNode->m_poRigt;
  }

  poNewNod->m_poParnt = poParnt;
  if (poParnt == nullptr)
    rpoRoot = poNewNod;
  else if (poNewNod->m_nKey < poParnt->m_nKey)
    poParnt->m_poLeft = poNewNod;
  else
    poParnt->m_poRigt = poNewNod;
}

void fnBinSchTree(StNode*& rpoRoot)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  for (int i = 0; i < nMaxSiz; ++i)
  {
    string sCmd;
    cin >> sCmd;
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      StNode* poNewNod = new StNode(nNo);
      fnInsert(rpoRoot, poNewNod);
    }
    if (sCmd[0] == 'p')
    {
      fnInOrder(rpoRoot);
      cout << endl;
      fnPreOrder(rpoRoot);
      cout << endl;
    }
  }
}

void fnPstOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnPstOrder(poNode->m_poLeft);
  fnPstOrder(poNode->m_poRigt);
  delete poNode;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  StNode* poRoot = nullptr;

  fnBinSchTree(poRoot);
//fnPstOrder(poRoot);
}

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

#define pb push_back
#define ss second
#define ff first
#define N 100005
#define inf 1000000009
#define ll long long
#define all(a) a.begin(),a.end()
#define mid(a,b) (a+b)/2
#define pii pair<int,int>

using namespace std;

int x,y,a,b,c,p[N],q[N],r[N],nw;
ll sum;
vector <int> v;

int main()
{
	scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
	for(int i = 1;i <= a;i++) scanf("%d",&p[i]);
	for(int i = 1;i <= b;i++) scanf("%d",&q[i]);
	for(int i = 1;i <= c;i++) scanf("%d",&r[i]);
	sort(p + 1,p + a + 1);
	sort(q + 1,q + b + 1);
	sort(r + 1,r + c + 1);
	for(int i = a - x + 1;i <= a;i++) v.pb(p[i]);
	for(int i = b - y + 1;i <= b;i++) v.pb(q[i]);
	sort(all(v));
	nw = c;
	for(auto i : v){
		if(nw >= 1 and r[nw] > i)
			sum += r[nw--];
		else sum += i;
	}
	cout << sum;
}

Measured memory_bytes: 2552
#include<bits/stdc++.h>
#define ll long long
#define inf 1e18
#define mod 1000000007
#define setbits(x) __builtin_popcount(x)
using namespace std;

vector<vector<double>>dp;
int n;

double func(double *p, int i, int heads, int tails) {
	if (i >= n) {
		if (heads > tails) {
			return 1.0;
		}
		return 0.0;
	}
	if (dp[heads][tails] != -1) {
		return dp[heads][tails];
	}

	// head
	double ans1 = 0, ans2 = 0;
	ans1 = p[i] * func(p, i + 1, heads + 1, tails);

	//tail
	ans2 = (1.0 - p[i]) * func(p, i + 1, heads, tails + 1);

	return dp[heads][tails] = ans1 + ans2;
}

int main() {
	cin >> n;
	double p[n];
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	dp.resize(n + 1, vector<double>(n + 1, -1));
	cout << fixed << setprecision(10) << func(p, 0, 0, 0);
	return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  ll x = 1;
  for(ll i = 1; i <= n; i++) {
    x = (x*i) % (1000000000 + 7);
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 3648
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] SS = br.readLine().split("") ;
		int LEN = SS.length/2;
		
		int ans = 0;
		for(int i=LEN-1; i>0; i--) {
			boolean LequalR = true;
			for(int j=0; j<i; j++) {
				if(!SS[j].contentEquals(SS[j+i])) {
					LequalR = false;
				}
			}
			if(LequalR) {
				ans = i*2;
				break;
			}
		}
			
		System.out.println(ans);	
	}
}

Measured memory_bytes: 33012
#include <stdio.h>
#define MAX 10000
#define nil -1

struct node{
	int parent,left,right;
};

struct node T[MAX];
int n;
int D[MAX],H[MAX];


void setdepth(int u,int d){
	if(u==nil){
		return;
	}
	D[u]=d;
	setdepth(T[u].left,d+1);
	setdepth(T[u].right,d+1);
}

int setheight(int u){
	int h1,h2;
	h1=h2=0;
	if(T[u].left!=nil){
		h1=setheight(T[u].left)+1;
	}
	if(T[u].right!=nil){
		h2=setheight(T[u].right)+1;
	}
	return H[u]=(h1>h2? h1:h2);
}

int getsibling(int u){
	if(T[u].parent==nil){
		return nil;
	}
	if(T[T[u].parent].left!=u && T[T[u].parent].left!=nil){
		return T[T[u].parent].left;
	}
	if(T[T[u].parent].right!=u && T[T[u].parent].right!=nil){
		return T[T[u].parent].right;
	}
	return nil;
}

void print(int u){
	printf("node %d: ",u);
	printf("parent = %d, ",T[u].parent);
	printf("sibling = %d, ",getsibling(u));
	int deg=0;
	if(T[u].left!=nil){
		deg++;
	}
	if(T[u].right!=nil){
		deg++;
	}
	printf("degree = %d, ",deg);
	printf("depth = %d, ",D[u]);
	printf("height = %d, ",H[u]);
	
	if(T[u].parent==nil){
		printf("root\n");
	}
	else if(T[u].left==nil && T[u].right==nil){
		printf("leaf\n");
	}
	else{
		printf("internal node\n");
	}
}

int main(void){
	int v,l,r,root=0;
	scanf("%d",&n);
	
	for(int i=0;i<n;i++){
		T[i].parent=nil;
	}
	for(int i=0;i<n;i++){
		scanf("%d %d %d",&v,&l,&r);
		T[v].left=l;
		T[v].right=r;
		if(l!=nil){
			T[l].parent=v;
		}
		if(r!=nil){
			T[r].parent=v;
		}
	}
	
	for(int i=0;i<n;i++){
		if(T[i].parent==nil){
			root=i;
		}
	}
	
	setdepth(root,0);
	setheight(root);
	
	
	for(int i=0;i<n;i++){
		print(i);
	}
	
	return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
const double PI  =3.141592653589793238463;
using namespace std;
using ll = long long;
const ll INF = +10010010000;
typedef pair<int,int> P;
const int mod = 1e9+7;

struct mint{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a){
        (x+=a.x)%=mod;
        return *this;
    }
    mint& operator-=(const mint a){
        (x-=mod-a.x)%=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x)%= mod;
        return *this;
    }
    mint operator+(const mint a)const{
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a)const{
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a)const{
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
      if(!t)return 1;
      mint a = pow(t>>1);
      a*=a;
      if(t%1)a*=*this;
      return a;
    }

    // for prime mod
    mint inv() const {
      return pow(mod-2);
    }
    mint& operator/=(const mint a){
      return (*this) *= a.inv();
    }
    mint operator/(const mint a)const{
      mint res(*this);
      return res/=a;
    }
};

struct combination{
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i<n;++i)fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i>=1;--i) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k){
    if(k<0 || k>n)return 0;
    return fact[n] * ifact[k] + ifact[n-k]; 
  }
};

int main(){
    ll n;
    cin >> n;
    vector<pair<int,int>> fn;
    for(int i = 2; (ll)i*i<n;i++){   
        int x =0;
        while(n%i==0){
            n/=i;
            ++x;
        }
        fn.emplace_back(i,x);
    }
    if(n!=1)fn.emplace_back(n,1);
    int ans =0;
    rep(i,fn.size()){
        int prime = fn[i].first;
        int cnt = fn[i].second;
        int x = 1;
        while(cnt-x>=0){
            cnt-=x;
            x++;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11620
@D=map[glob<>],@@=0..$'-<>=~$";
map{
	$j=0;
	for$x(glob){
		$k=($i+$j++)%3;
		$_[$k][$_]+=$D[$x-1][$_]for@@;
	}
	++$i
}<>;
$\=1e15;
for$i(@@){
	for$j(@@){
		for(@@){
			$\-=$-=$i-$j&&$i-$_&&$j-$_&&$\-$_[0][$i]-$_[1][$j]-$_[2][$_]
		}
	}
}
print


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
int A,B,C;
cin>>A>>B;
  if(0<=A,B<=23)
  {
  	C=A+B;
  	if(C>=24){
  		C%=24;
	  }
	  cout<<C;
  }

return 0;



}

Measured memory_bytes: 256
s = gets.chomp.strip

if s[0] == "A" && s[2..-2].chars.count{|l| l == "C"} == 1
  x_idx = s[2..-2].index("C") + 2
  s[0] = "a"
  s[x_idx] = "c"
  if s.scan(/[A-Z]*/).reject(&:empty?).any?
    puts "WA"
  else
    puts "AC"
  end
else
  puts "WA"
end


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


def solve(A: int, B: int):
    print(max(A+B, A-B, A*B))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


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

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll A, B, M;
    cin >> A >> B >> M;
    vl aa(A), bb(B);
    rep(i, A) cin >> aa[i];
    rep(i, B) cin >> bb[i];
    ll ma = *min_element(all(aa)), mb = *min_element(all(bb));
    ll ans = ma + mb;

    rep(i,M){
        ll x, y, c;
        cin >> x >> y >> c;
        x--, y--;
        chmin(ans, aa[x] + bb[y] - c);
    }
    cout << ans << endl;
}

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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}
// SegmentTree<int> seg(n, 0x7FFFFFFF, [](int a, int b){return min(a, b);});
template <class T>
class SegmentTree {
    using func_t = function<T(T, T)>;
    const int sz, n;
    const T id;
    func_t merge;
    vector<T> data;
    int expand(int n) const { return n == 1 ? n : expand((n + 1) / 2) * 2; }
public:
    SegmentTree(const vector<T> &init, T id, func_t merge) :
        sz(init.size()), n(expand(sz)), id(id), data(n * 2, id), merge(merge) {
        copy(begin(init), end(init), begin(data)+n);
        RREP(i, n) {
            data[i] = merge(data[i * 2 + 0], data[i * 2 + 1]);
        }
    }
    int size() const { return sz; }
    void update(int p, T val) {
        assert (0 <= p && p < sz);
        data[p += n] = val;
        while (p /= 2) data[p] = merge(data[p * 2], data[p * 2 + 1]);
    }
    T find(int l, int r) const {
        assert (0 <= l && l <= r && r <= sz);
        l += n; r += n;
        T res1 = id, res2 = id;
        while (l != r) {
            if (l % 2) res1 = merge(res1, data[l++]);
            if (r % 2) res2 = merge(data[--r], res2);
            l /= 2; r /= 2;
        }
        return merge(res1, res2);
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, A, B; cin >> n >> A >> B;
    SegmentTree<P> seg(vector<P>(n+1, P(linf, -linf)), P(linf, -linf), [](P a, P b) {
        return P(min(a.first, b.first), max(a.second, b.second));
    });
    vector<ll> a(n+1);
    a[0] = B;
    rep(i, n) cin >> a[i+1];
    ++n;
    rrep(i, n-1) {
        ll v = abs(a[i] - a[n-1]);
        P p = seg.find(i+1, n);
        P pp(max(p.second, v), min(p.first, v));
        seg.update(i, pp);
        // cout << i << " " << a[i] << " " << a[n-1] << " " << v << " " << pp.first << " " << pp.second << endl;
    }
    ll ans = abs(B - a[n-1]);
    ans = seg.find(0, 1).first;
    cout << ans << endl;
}


Measured memory_bytes: 384