akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.algorithm, std.conv, std.array, std.string;

void main()
{
    int a, b, c;
    readf("%d %d %d", &a, &b, &c);

    auto r = a%b;
    while (r != 0) {
        if (c >= r && c%r == 0) {
            writeln("YES");
            return;
        } else {
            while (r < b) r += a;
            r = r % b;
        }
    }
    writeln(c == 0 ? "YES" : "NO");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();

		if(a > 0 && a <= 100000){
		int min = 0;
		int max = 0;
		long sum = 0;
		for(int i = 0; i < a; i++){
			int b[] = new int[a];
			b[i] = sc.nextInt();
			if(a >= -1000000 && a <= 1000000){
			sum = sum + b[i];
			if(i == 0){
			min = b[i];
			max = b[i];
			}
			if(min > b[i])min = b[i];
			if(max < b[i])max = b[i];
 			}
		}
		System.out.printf("%d %d %d\n", min,max,sum);
		}
	}
}


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

using namespace std;

int main()
{
    int x,n;
    cin >> x >> n;
   
    vector<int> p(101,0);
    for(int i=0;i<n;i++){
        int buf;
        cin >> buf;
        p[buf]++;
    }

    int ans=1e8;
    for(int i=-1;i<=101;i++){
        if(0<=i && i<=100){
            if(p[i]>0) continue;
        }
        if(abs(x-ans)>abs(x-i)) ans=i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
#define printd(x) printf("%.12f\n", ans);
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main(void) {
    int n;
    cin >> n;

    cout << n << ":";
    vector<pll> ans = prime_factorize(n);
    for (auto x : ans) {
        rep (i, x.second) cout << " " << x.first;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3104
from heapq import heappop, heappush
n, q = list(map(int, input().split()))
a = [[] for i in range(n)]
for _ in range(q):
  q = list(map(int, input().split()))
  if q[0]==0:
    heappush(a[q[1]], -1*q[2])
  elif q[0]==1:
    if len(a[q[1]])>0:
      print(-1*a[q[1]][0])
  elif q[0]==2:
    if len(a[q[1]])>0:
      heappop(a[q[1]])


Measured memory_bytes: 13180
#include<iostream>
#include<cmath>
#include<bitset>
using namespace std;

#define N 10

class CMap{
public:
	int m[N+2][N+2];
	int ans[N+2][N+2];

	CMap(){ Reset(); ResetAnswer(); }
	
	void Reset(){
		for(int i = 0; i < N+2; ++i){
			for(int j = 0; j < N+2; ++j){
				m[i][j] = 0;
			}
		}
	}
	void ResetAnswer(){
		for(int i = 0; i < N+2; ++i){
			for(int j = 0; j < N+2; ++j){
				ans[i][j] = 0;
			}
		}
	}
	bool inline static inRange(int t){
		return ( 1 <= t && t < N + 1 );
	}

	bool PassParticle(int i, int j, bool bConsiderEfficiency = false)
	{
		int cnt0 = 0;
		int cnt1 = 0;
		const int di[] = {0,-1,0,1,0};
		const int dj[] = {0,0,1,0,-1};

		if( bConsiderEfficiency ){
			for(int k = 0; k < sizeof(di)/sizeof(*di); ++k)
				if( inRange( i+di[k] ) && inRange( j+dj[k] ) )
					if( m[i+di[k]][j+dj[k]] == 1 ) cnt1++; else cnt0++;
		}

		if( cnt1 < cnt0 )
			return false;

		for(int k = 0; k < sizeof(di)/sizeof(*di); ++k)
			if( inRange( i+di[k]) && inRange( j+dj[k]) )
				m[i+di[k]][j+dj[k]] ^= 1;

		ans[ i ][ j ] = 1;
		return true;
	}
	bool NoLight() const
	{
		for(int i = 1; i < N+1; ++i)
			for(int j = 1; j < N+1; ++j)
				if( m[i][j] == 1 ) return false;
		return true;
	}
	void Print()const{
		for(int i = 1; i < N+1; ++i){
			cout << m[i][1];
			for(int j = 2; j < N+1; ++j)
				cout << ' ' << m[i][j];
			cout << '\n';
		}
	}
	void PrintAnswer() const{
		for(int i = 1; i < N+1; ++i){
			cout << ans[i][1];
			for(int j = 2; j < N+1; ++j)
				cout << ' ' << ans[i][j];
			cout << '\n';
		}
	}
};

bool DetermineShootingPoints(CMap &M){
	for(unsigned int i = 2; i < N+1; ++i){
		for(unsigned int j = 1; j < N+1; ++j){
			if( M.m[i-1][j] == 1 ){
				M.PassParticle( i, j );
			}
		}
	}
	if( M.NoLight() )
		return true;
	else
		return false;
}

int main(void){
	int n;

	cin >> n;
	for( int D = 0; D < n; ++D )
	{
		bool bCont = true;
		CMap M;
		bitset<N> B;

		for(int i = 1; i < N+1; ++i)
			for(int j = 1; j < N+1; ++j)
				cin >> M.m[i][j];

		for(unsigned long L = 0; L < (unsigned long)pow(2.0,(double)N) && bCont; ++L){
			B = L;
			//cout << L << ": " << B.to_string() << endl;
			CMap Tmp = M;
			for(unsigned int bits = 0; bits < B.size() && bCont; ++bits){
				if( B[bits] )
					M.PassParticle(1,N-bits);//break;
			}
			if( DetermineShootingPoints( M ) ){
				bCont = false;
				break;
			}
			M = Tmp;
		}
		//cout << "END.\n";
		//cout << "CURRENT MAP:\n";
		//M.Print();
		//cout << "ANSWER:\n";
		M.PrintAnswer();
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

ll N;
ll A[100010];
std::vector<ll> ma, minus;
ll S;

int main()
{
  scanf( "%lld", &N );

  rep( i, N )
  {
    scanf( "%lld", A+i );

    if( A[i] >= 0 )
      ma.push_back( A[i] );
    
    if( A[i] < 0 )
      minus.push_back( -A[i] );

    S += llabs(A[i]);
  }

  std::sort( all(ma) );
  std::sort( all(minus) );

  ll ans = 0;

  if( minus.size() & 1 )
  {
    if( !minus.empty() ) rep( i, minus.size()-1 )
      ans += minus[i+1];

    if( !ma.empty() && !minus.empty() )
    {
      if( ma[0] < minus[0] )
      {
        ans += minus[0];
        ans -= ma[0];
      }
      else
      {
        ans -= minus[0];
        ans += ma[0];
      }
    }
    else
    {
      if( !ma.empty() )
        ans += ma[0];
      if( !minus.empty() )
        ans -= minus[0];
    }

    if( !ma.empty() ) rep( i, ma.size()-1 )
      ans += ma[i+1];
  }
  else
    ans = S;

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

  return 0;
}

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

int main() 
{
    int N;
    cin >> N;
    vector<int>A;
    for (int i = 0; i < N; i++){
        int a;
        cin >> a;
        a--;
        A.push_back(a);
    }
    
    int ans = 0;
    int sum = 0;
    for (int i = 0; i <= N; i++) {
        if (ans == 1) {
            cout << sum << endl;
            return 0;
        }
        if (sum >= N) {
            cout << -1 << endl;
            return 0;
        }
        sum++;
        ans = A[ans];
    }
}

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

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi std::vector<int>
#define vvi std::vector<std::vector<int> >
#define vpi std::vector<pi >
#define pi std::pair<int,int>
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (int var = (from); var <= ((int)(to)); var++)
#define DOWNTO(var, from, to) for (int var = (from); var >= ((int)(to)); var--)
#define FOR(var, to)		  UPTO(var, 0, (to)-1)
#define DOWN(var, from)	   DOWNTO(var, (from)-1, 0)

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) std::cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) std::cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

static const int MOD = 1000000007;
static const int INF = ((1<<30)-1);
static const s64 LINF = ((1LL << 62)-1);

struct Comb {
	std::vector<std::vector<s64> > a;
	Comb(int n) { // O(n^2)
		a.resize(n+1);
		FOR(i,n+1) {
			a[i].resize(i+1, 1);
			UPTO(j,1,i-1) a[i][j] = a[i-1][j] + a[i-1][j];
		}
	}
	s64 ncr(int n, int r) {
		assert(n >= 0);
		assert(n <= (int)a.size());
		assert(r >= 0);
		assert(r <= n);
		return a[n][r];
	}
};

#define gc(c) (c)=getchar()
int ri() {
	int c,s=0,r=0;
	for(;;){gc(c);if(c=='-'){s=1;break;}if(c>='0'&&c<='9'){r=c-'0';break;}}
	for(;;){gc(c);if(c<'0'||c>'9')break;r*=10;r+=c-'0';}
	if(s)r=-r;
	return r;
}
s64 rs64() {
	s64 r=0;
	int c,s=0;
	for(;;){gc(c);if(c=='-'){s=1;break;}if(c>='0'&&c<='9'){r=c-'0';break;}}
	for(;;){gc(c);if(c<'0'||c>'9')break;r*=10;r+=c-'0';}
	if(s)r=-r;
	return r;
}

int int_less(const void *a, const void *b) {
	return (*(const int*)a - *(const int*)b);
}
int int_greater(const void *a, const void *b) {
	return (*(const int*)b - *(const int*)a);
}
std::string operator*(const std::string &s, int n){ std::string res; FOR(i,n) res += s; return res; }

template<class T> std::ostream& operator<<(std::ostream& os, std::vector<T> a) { for (auto i : a) os << i << " "; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, std::set<T> a) { for (auto i : a) os << i << " "; return os; }
template<class A, class B> std::ostream& operator<<(std::ostream&os, std::pair<A,B> a) { os << a.fi << "," << a.se; return os; }


int main() {
	int n = ri();
	std::string s;
	std::cin >> s;
	int black = 0;
	FOR(i,n) if (s[i] == '#') black++;
	int res = black;
	DOWN(i,n) {
		if (s[i] == '#') black--;
		else black++;
		res = std::min(res, black);
	}
	std::cout << res << std::endl;
	return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for (int i = (int)s.length() - 1; i; i--) if (i % 2 == 0) {
        if (s.substr(0, i / 2) == s.substr(i / 2, i / 2)) {
            cout << i;
            return 0;
        }
    }
}


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

int main(){
   int n,y;
   cin >> n >> y;
   int ans = 0;
   string faild = "-1 -1 -1";
   rep(i,n+1){//x
      rep(j,n+1){//y
         int temp = y/1000 - 10 * i - 5 * j;
         if((temp == n - i - j) && (temp >= 0)){
            ans = n - i - j;
            cout << i << " " << j << " " << ans << endl;
            return 0;
         }
      }
   }
   cout << faild << endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll int n,a,b;
    cin>>n>>a>>b;
    ll int ans ;

    ans = b - a;
    if(!(ans & 1)){
        cout<<ans/2;
    }
    else{
        if(a == 1 || a == n || b == 1 || b == n){
            cout<<(ans+1)/2;
            return 0;
        }
        else{
            ans = (ans + 1)/2;
            if(n - b > (a - 1)){
                cout<<((a-1) + ans );
                return 0;
            }
            else{
                cout<<((n - b) + ans );
                return 0;
            }
        }

    }
    return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  int kaunt = 0;
  
  for (int i = A; i <= B; i++){
    if ((i / 10000 == i % 10 ) && (i % 10000 / 1000 == i % 10000 % 1000 % 100 / 10)){
      kaunt += 1;
      
    }
 }
  
  cout << kaunt << endl;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
MOD = 10**9+7
tos = Array.new(n)
tos[0] = a[0]
for i in 1..(n-1)
  tos[i] = tos[i-1] + a[i]
end
sum = 0
for j in 0..(n-1)
  sum += a[j]*((tos[n-1]-tos[j])%MOD)%MOD
  sum %= MOD
end
puts sum

Measured memory_bytes: 29656
#
# File    : B.rb
# Author  : Kazune Takahashi
# Created : 5/19/2019, 9:03:56 PM
# Powered by Visual Studio Code
#

s = gets.chomp

a = s[0...2].to_i
b = s[2...4].to_i

ax = (1 <= a && a <= 12)
bx = (1 <= b && b <= 12)

if ax && bx
  puts "AMBIGUOUS"
elsif ax
  puts "MMYY"
elsif bx
  puts "YYMM"
else
  puts "NA"
end

Measured memory_bytes: 1788
//   __      __       .__           .____________                   __________        __ ________   __                 
//  /  \    /  \ ____ |_________  __| _\______   \__ __  ____  _____\______   \__ ___/  |\_____  \ |  | ______  ___.__.
//  \   \/\/   _/ __ \|  \_  __ \/ __ | |    |  _|  |  \/ ___\/  ___/|    |  _|  |  \   __/   |   \|  |/ \__  \<   |  |
//   \        /\  ___/|  ||  | \/ /_/ | |    |   |  |  / /_/  \___ \ |    |   |  |  /|  |/    |    |    < / __ \\___  |
//    \__/\  /  \___  |__||__|  \____ | |______  |____/\___  /____  >|______  |____/ |__|\_______  |__|_ (____  / ____|
//         \/       \/               \/        \/     /_____/     \/        \/                   \/     \/    \/\/     

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second

using namespace std;

void solve()
{
    ll a, b;
    cin >> a >> b;
    ll h, m;
    ld pi = 3.14159265358979323846;
    cin >> h >> m;
    ld ang1 = 0.0, ang2 = 0.0;
    ang1 = (h * 30.0 + m / 2.0);
    ang2 = (m * 6.0);
    ang1 *= pi / 180;
    ang2 *= pi / 180;
    ang1 = fabs(ang1 - ang2);
    ang1 = min(ang1, 2 * pi - ang1);
    //cout << ang1 << " " << ang2 << endl;
    ld c2 = 1.0 * a * a + 1.0 * b * b - 2.0 * a * b * cos(ang1);
    cout << setprecision(20) << sqrt(c2) << endl;
}

int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q = 1;
	//cin >> q;
	for(int i = 1; i <= q; i++)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 4112
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

class UnionFind{
  int n;
  vector<int> data;
public:
  UnionFind(int _n):n(_n),data(_n,-1){}
  bool link(int a, int b){ //if new link, then true.
    int ra=find_root(a);
    int rb=find_root(b);
    if(ra!=rb){
      if(data[rb]<data[ra]) swap(ra,rb);
      data[ra]+=data[rb];
      data[rb]=ra;
    }
    return (ra!=rb);
  }
  bool check(int a, int b){ //if same set, then true.
    return (find_root(a)==find_root(b));
  }
  int find_root(int a){
    return ((data[a]<0)?a:(data[a]=find_root(data[a])));
  }
};


int vy[] = {-1,1,0,0};
int vx[] = {0,0,-1,1};

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> S;
  rep(i,H){
    string s;
    cin >> s;
    S.push_back(s);
  }

  UnionFind uf(H*W);
  rep(y,H){
    rep(x,W){
      rep(k,4){
        int ny = y + vy[k];
        int nx = x + vx[k];
        if(0 <= ny && ny < H && 0 <= nx && nx < W){
          if(S[y][x] != S[ny][nx]){
            uf.link(y*W+x, ny*W+nx);
          }
        }
      }
    }
  }

  map<int,ll> cb, cw;
  rep(y,H){
    rep(x,W){
      int root = uf.find_root(y*W+x);
      if(S[y][x] == '#') cb[root]++;
      else cw[root]++;
    }
  }

  ll ret = 0;
  FOR(it,cb){
    ret += cw[it->first] * it->second;
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 18432
#include <stdio.h>

int main(){

	int x[10000], i, temp;

	for(i=0;i<10000;i++){
		scanf("%d", &x[i]);
	}

	for(i=0;i<10000;i++){
		temp = x[i];
		if(temp == 0){
			break;
		}else{
			printf("Case %d: %d\n", i+1, temp);
		}
	}

	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
using namespace std;
typedef long long ll;





int main(){
   int n;
   cin>>n;
   int d[111];
   ll sum=0;
   rep(i,n){
      cin>>d[i];
      rep(j,i){
         sum+=d[j]*d[i];
      }
   }
   cout<<sum<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define ull unsigned long long 
#define ld long double
#define ui unsigned int 
using namespace std;

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	if (x < y && y < z) {
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
}



Measured memory_bytes: 3084
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    ull n,a,b;
    cin>>n>>a>>b;
    ull c=b-a;
    if(c%2==0) cout<<c/2;
    else{
        ull s=a,t=b;
        cout<<(b-a-1)/2+min(a,n-b+1);
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
int main(){
    int x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x),b(y),c(z);
    for(int i=0;i<x;i++)    cin >> a[i];
    for(int i=0;i<y;i++)    cin >> b[i];
    for(int i=0;i<z;i++)    cin >> c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    int pa=x-1,pb=y-1,pc=z-1,ca=1,cb=1,cc=1;
    while(ca*cb*cc < k){
        if(pa>=1&&pb>=1&&pc>=1){
            if(a[pa-1]+b[pb]+c[pc]>=a[pa]+b[pb-1]+c[pc]&&a[pa-1]+b[pb]+c[pc]>=a[pa]+b[pb]+c[pc-1])    pa--,ca++;
            else if(a[pa]+b[pb-1]+c[pc]>=a[pa-1]+b[pb]+c[pc]&&a[pa]+b[pb-1]+c[pc]>=a[pa]+b[pb]+c[pc-1]) pb--,cb++;
            else if(a[pa]+b[pb]+c[pc-1]>=a[pa-1]+b[pb]+c[pc]&&a[pa]+b[pb]+c[pc-1]>=a[pa]+b[pb-1]+c[pc]) pc--,cc++;
        }
        else if(pa>=1&&pb>=1){
            if(a[pa-1]+b[pb]+c[pc]>=a[pa]+b[pb-1]+c[pc]) pa--,ca++;
            else    pb--,cb++;
        }
        else if(pb>=1&&pc>=1){
            if(a[pa]+b[pb-1]+c[pc]>=a[pa]+b[pb]+c[pc-1])    pb--,cb++;
            else pc--,cc++;
        }
        else if(pc>=1&&pa>=1){
            if(a[pa]+b[pb]+c[pc-1]>=a[pa-1]+b[pb]+c[pc])    pc--,cc++;
            else    pa--,ca++;
        }
        else if(pa>=1){
            pa--,ca++;
        }
        else if(pb>=1){
            pb--,cb++;
        }
        else if(pc>=1){
            pc--,cc++;
        }
    }
    ca = min(x,ca+100);
    cb = min(y,cb+100);
    cc = min(z,cc+100);
    vector<ll> sum;
    for(ll i=1;i<=ca;i++){
        for(ll j=1;j<=cb;j++){
            for(ll k=1;k<=cc;k++){
                sum.push_back(a[x-i]+b[y-j]+c[z-k]);
            }
        }
    }
    sort(sum.begin(),sum.end());
    ll cnt=0;
    for(ll i=sum.size()-1;;i--){
        cout << sum[i] << endl;
        cnt++;
        if(cnt==k)  break;
    }
    return 0;
}

Measured memory_bytes: 133344
import sys
sys.setrecursionlimit(1000000)

def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

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

n = int(raw_input())
t = [int(raw_input()) for _ in xrange(n)]
ans = 1
for i in xrange(n):
    ans = lcm(ans, t[i])
print ans


Measured memory_bytes: 2568
#include <stdio.h>
int main(){
    while(1){
    int h,w;
    int i,j;
    scanf("%d %d",&h,&w);
        if(h==0 && w==0) break;
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if(i==0 || i==h-1 || j==0 || j==w-1){
                printf("#");
            }else{
                printf(".");
            }
        }
        printf("\n");
    }
        printf("\n");
    }
    return 0;
}



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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,a,b;cin>>n>>a>>b;
  ll x=abs(a-b);
  res=INF;
  if(x%2==0){
    chmin(res,x/2);
  }
  else{
    chmin(res,x/2+a);
    chmin(res,x/2+n-b+1);
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  private static String day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      String s=sc.next();
      for(int i=0;i<7;i++){
        if(s.equals(day[i]))
          System.out.println(7-i);
      }
      
    }
}


Measured memory_bytes: 21712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
   ll n,d;
   cin>>n>>d;
   ll c=0;
   for(ll i=0;i<n;i++){
   	double a,b;
   	cin>>a>>b;
   	double t=a*a+b*b;
   	double p=sqrt(t);
   	if(p<=d){
   		c++;
	   }
   }
   cout<<c;
    return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
 int a[1000000][4];
int dp[1000000][4];
int solve(int n, int i){
  if(n==0)
    return 0;
  if(dp[n][i]!= -1)
    return dp[n][i];
  
  for(int j=1;j<=3;j++){
    if(i!=j)
    dp[n][i]=max(dp[n][i], solve(n-1,j)+a[n][j]);
  }
  return dp[n][i];
}
int main(){
  int n;
  cin>> n;
  
   // int a[n][3];
  memset(dp,-1,sizeof(dp));
    for(int i=1;i<=n;i++){
      for(int j=1;j<=3;j++)
        cin>> a[i][j];
    }
      cout<<solve(n,0);
      
}


Measured memory_bytes: 26496
#L, R = map(int,input().split())
N,K = map(int,input().split())
H = list(map(int,input().split()))

H.sort()

if K>=N:
  print(0)
else:
  h = H[:N-K]
  ans = 0
  for i in h:
    ans += i
  print(ans)

Measured memory_bytes: 26024
#include<bits/stdc++.h>
using namespace std;
char sz[1024];
int main()
{
	long long n,m,i;
	scanf("%s",sz);
	scanf("%lld",&m);
	for(i=0;i<strlen(sz);i++)
	{
		if(sz[i]!='1'&&sz[i]!='4'&&sz[i]!='5'&&sz[i]!='8'&&sz[i]!='9')
		{
			printf("%c",sz[i]);
			return 0;
		}
		if(i+1==m)
		{
			printf("%c",sz[i]);
			return 0;
		}
	}
	printf("1");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define LEN 100005
#define min(a,b) ((a)<(b)?(a):(b))


typedef struct {
    char name[100];
    int time;
} CPU;

CPU Queue[LEN];
int head,tail,n;

void enqueue(CPU x) {
    Queue[tail]=x;
    tail=(tail+1)%LEN;
}
CPU dequeue() {
    CPU x=Queue[head];
    head=(head+1)%LEN;
    return x;
}
int main() {
    int el=0,c,i,q;
    CPU u;
    scanf("%d %d",&n,&q);
    for (i=1; i<=n; i++) {
        scanf("%s",Queue[i].name);
        scanf("%d",&Queue[i].time);
    }
    head=1; tail=n+1;
    while (head!=tail) {
        u=dequeue();
        c=min(q,u.time);
        u.time-=c;
        el+=c;
        if (u.time>0) {
            enqueue(u);
        } else {
            printf("%s %d\n",u.name,el);
        }
    }
}


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

int main(){
  int N;
  cin >> N;
  vector<int> H(N);
  for(int i=0; i<N; i++) cin >> H.at(i);
  vector<int> L(N-1);
  for(int i=0; i<N-1; i++){
    if(H.at(i)>=H.at(i+1)) L.at(i)=1;
    else L.at(i)=0;
  }

  int ans=0;
  int ant=0;
  for(int i=0; i<N-1; i++){
    if(L.at(i)==1){
      ant++;
      ans=max(ans, ant);
    } 
    else ant=0;;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int main() {
    int n;
    cin >> n;
    int ac = 0, wa = 0, tle = 0, re = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s == string("AC")) {
            ac++;
        } else if (s == string("WA")) {
            wa++;
        } else if (s == string("TLE")) {
            tle++;
        } else if (s == string("RE")) {
            re++;
        }
    }
    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", re);
}


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

int main(){
  int N,count=0;
  cin >> N;
  vector<int> p(N);
  for(int i=0;i<N;i++){
  	cin >> p.at(i);
  }
  for(int i=0;i<N;i++){
  	if(p.at(i)!=i+1)
      count++;
  }
  if(count==0 || count==2)
    cout << "YES";
  else
    cout << "NO";
}

Measured memory_bytes: 256
N, M = map(int, input().split())
 
a = [int(input()) for i in range(M)]
 
 
for i in range(M - 1):
    if a[i] + 1 == a[i+1]:
        print(0)
        exit()
 
dp = [0] * (N + 1)
flag_a = [0] * (N + 1)
 
for i in range(M):
    flag_a[a[i]] = -1
 
 
if N == 1 and M != 1:
    print(1)
    exit()
elif N == 1 and M == 1:
    print(0)
    exit()
 
if 1 in a and 2 in a:
    print(0)
    exit()
 
if 1 in a:
    dp[1] = 0
    dp[2] = 1
elif 2 in a:
    dp[1] = 1
    dp[2] = 0
else:
    dp[1] = 1
    dp[2] = 2
 
for i in range(3,N+1):
    if flag_a[i] == -1:
        dp[i] = 0
    else:
        dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007
 
print(dp[N])

Measured memory_bytes: 8172
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stack>

int top, S[1000];

int pop () {
    if (top == 0) {
        throw "stack is empty.";
    }
    return S[--top];
}

void push (int x) {
    S[top++] = x;
}

int main(){
    int x;
    char s[100];

    top = 0;

    while( scanf("%s", s) != EOF ){
        if ( s[0] == '+' ){
            int a = pop();
            int b = pop();
            push(a+b);
        } else if ( s[0] == '-' ){
            int a = pop();
            int b = pop();
            push(b-a);
        } else if ( s[0] == '*' ){
            int a = pop();
            int b = pop();
            push(a*b);
        } else {
            x = atoi(s);
            push(x);
        }
    }

    printf("%d\n", pop());
    return 0;
}

Measured memory_bytes: 2696
#include <stdio.h>
int main(){
  int a[100],i,j,k;
  scanf("%d",&i);
  for(j=i;j>0;j--){
    scanf("%d",&a[j]);
  }
  for(k=1;k<i+1;k++){
    if(k == i){
    printf("%d\n",a[k]);
    }
    else{
      printf("%d ",a[k]);
    }
  }
  return 0;
}

Measured memory_bytes: 2680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	string s[4]={"Sunny","Cloudy","Rainy","Sunny"},t;
	cin>>t;
	for(int i=0;i<3;i++)
	{
		if(t==s[i])
		{
			cout<<s[i+1]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
    WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
long long MOD;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
 
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

long long A,B;

bool ok(long long key,long long index){
    string S = to_string(index);
    long long nagasa = S.size();
    if(index*A+nagasa*B > key) return true;
    else if(index*A+nagasa*B <= key) return false;
}

long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}



int main() {
    long long N,A,B,C,D,E;cin >> N >> A >> B >> C >> D >> E;
    long long mini = min({A,B,C,D,E});
    if(N % mini != 0) mini = N / mini + 1;
    else mini = N / mini;

    cout << 4+mini << endl;

    // PLEASE GIVE ME THE "ACCEPTED" !
}


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

int main() {
	int a, b;
	while (scanf("%d%d", &a, &b) != EOF) {
		if (a < 6) {
			b = 0;
		} else if (a < 13) {
			b /= 2;
		}
		printf("%d\n", b);
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;
inline void DeleteSpace(string &buf)
{
    size_t pos;
    while((pos = buf.find_first_of(" 　\t")) != string::npos){
        buf.erase(pos, 1);
    }
}
int main(){
  string w;cin >> w;
  int ans = 0;
  while(1){
    string t;cin >> t;
    if(t=="END_OF_TEXT") break;
    for(int i=0;i<t.size();i++){
      if('A'<=t[i]&&t[i]<='Z') t[i]+='a'-'A';
    }
    if(w==t) ans++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3144
#include<iostream>
#include<cstdio>
#include<bitset>
const int N=88,M=12801;
std::bitset<M> dp[N][N];
int n,m,a[N][N],b[N][N];
int main() {
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=m;j++) scanf("%d",a[i]+j);
    }
    for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) {
        scanf("%d",b[i]+j);
        dp[i][j].reset();
        int t=a[i][j]-b[i][j];
        if(i==1&&j==1) dp[i][j][t+6400]=1,dp[i][j][-t+6400]=1;
        else {
            if(t<0) t=-t;
            if(j>1) dp[i][j]|=(dp[i][j-1]<<t)|(dp[i][j-1]>>t);
            if(i>1) dp[i][j]|=(dp[i-1][j]<<t)|(dp[i-1][j]>>t);
        }
    }
    auto &f=dp[n][m];
    int ans=M;
    for(int j=0;j<M;j++) if(f[j]) ans=std::min(ans,std::max(j-6400,6400-j));
    printf("%d",ans);
    return 0;
}


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

int n, p[100009], cnt; bool v[100009];

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> p[i];
		if (p[i] == i) v[i] = true;
	}
	int s = 0;
	for (int i = 1; i <= n + 1; i++) {
		if (v[i] == true) s++;
		else { 
			cnt += (s + 1) / 2;
			s = 0;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) 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(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    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;
    }
    mint choose(int n, int a){
        mint x = 1 ,y = 1;
        for(int i = 0; i < a; ++i){
            x *= n-i;
            y *= i+1;
        }
        return x / y;
    }
    friend istream& operator>>(istream& is, mint& m){
        is >> m.x;
        return is;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

mint fanc[100010];

mint choose2(int n, int a){
  if(n<a)return 0;
  return fanc[n]/(fanc[n-a]*fanc[a]);
}

int main(){
  int n;
  cin>>n;
  int l,r;
  map<int,int>mp;
  for(int i=1; i<=n+1; ++i){
    int a; cin>>a;
    if(mp[a]!=0)l=mp[a],r=i;
    mp[a]=i;
  }

  fanc[0]=1;
  for(int i=1; i<100010; ++i){
    fanc[i]=fanc[i-1]*i;
  }

  for(int i=1; i<=n+1; ++i){
    cout<<choose2(n+1,i)-choose2(l-1+n+1-r,i-1)<<endl;
  }
}

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

int main(){
	int n, x;
	for(int i=0;;i++){
		cin >> n >> x;
		int c=0;
		if(n==0&&x==0){
			break;
		}else{
			for(int j=1;j<=n;j++){
				for(int k=1;k<=n;k++){
					for(int l=1;l<=n;l++){
						if(j+k+l==x){
							c++;
							if(j==k||k==l||l==j){
								c--;
							}
						}
					}
				}
			}
		}
		c=c/6;
		cout << c << endl;
	}
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define ULL unsigned long int
#define MOD (long int)10e9 + 7

int main(){
    long double r;
    cin >> r;

    cout << fixed << setprecision(16) << r * 2 * M_PI << endl;

    return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

ll N,K;
ll p[3];
string T;
vector<ll> t, ans;

signed main() {
  cin >> N >> K >> p[0] >> p[1] >> p[2] >> T;
  t.resize(N);
  ans.resize(N);
  rep(i, N) {
    switch (T[i]) {
      case 'r': t[i] = 0; break;
      case 's': t[i] = 1; break;
      case 'p': t[i] = 2; break;
    }
    if (i-K < 0) {
      // win
      ans[i] = (t[i]+2) % 3;
    } else if (ans[i-K] != (t[i]+2)%3) {
      // win
      ans[i] = (t[i]+2) % 3;
    } else {
      // lose
      ans[i] = -1;
    }
  }

  ll score = 0;
  rep(i, N) {
    if (ans[i] != -1) {
      score += p[ans[i]];
    }
  }
  cout << score << endl;
  return 0;
}


Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();

		long power = 1;

		for(int i = 1; i <= n; i++){
			power *= i;
			power %= 1_000_000_007;
		}

		System.out.println(power);
    }
}

Measured memory_bytes: 23508
def chmin(dp, a, b):
    if dp[a] > b:
        dp[a] = b
        return True
    return False

def chmax(dp, a, b):
    if dp[a] < b:
        dp[a] = b
        return True
    return False

# A 問題 - Frog 1
import sys
input = sys.stdin.readline

def main(step, height):
    inf = float('inf')
    dp = [inf for i in range(step)]
    dp[0] = 0
    for i in range(1, step):
        chmin(dp, i, dp[i-1] + abs(height[i]-height[i-1]))
        if i > 1:
            chmin(dp, i, dp[i-2] + abs(height[i]-height[i-2]))

    print(dp[step-1])


n = int(input())
h = list(map(int, input().split()))
main(n, h)


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

int main(){
    
    int a, b, c, i, count = 0;
    
    cin >> a >> b >> c;
    
    for(i = a; i <= b; i++){
        if((c % i) == 0){
            count++;
        }
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 3132
n = input()
k = int(input())
nl = len(n)#桁数
dp = [[[0] * (k + 1) for i in range(2)] for i in range(nl + 1)]
dp[0][0][0] = 1# 初期条件

# dp[i][j][k] i:桁数 j:smallフラグ 1はsmall確定、0はnと同じ値 k:ゼロ以外の数字を使った回数
for i in range(nl):
    for j in range(2):
        for l in range(k + 1): # lはK+1(つまりk)までの範囲にしても問題なし。下でl<kするから
            c = int(n[i])# 今調べている桁の数
            if j == 1:  # small確定の場合
                dp[i + 1][j][l] += dp[i][j][l]  # kの値が等しいので次の桁で0が来なければいけない
                if l < k:  # まだ0でない数の個数がkより少ない場合   ※比較する変数注意！
                    dp[i + 1][j][l + 1] += dp[i][j][l] * 9  # 次の桁で1~9を使う
            else:  # j==0のとき つまり現在まで調べている桁数の部分がnと一致している。
                if c == 0:
                    # cが0のときは0しか選べなく、small確定できない
                    dp[i + 1][0][l] += dp[i][j][l]
                else:
                    dp[i + 1][1][l] += dp[i][j][l]  # Cより小さい0を使う→small確定
                    if l < k: #※比較する変数注意！
                        dp[i + 1][1][l + 1] += dp[i][j][l] * (c - 1)  # c以外の数字を使う、small確定
                        dp[i + 1][0][l + 1] += dp[i][j][l]  # cを使う、small確定できない
print(dp[nl][1][k]+dp[nl][0][k])

Measured memory_bytes: 3064
n=int(input())
c='Christmas'
e=' Eve'
d=25-n
if d==0:
  print(c)
elif d==1:
  print(''.join([c,e]))
elif d==2:
  print(''.join([c,e,e]))
elif d==3:
  print(''.join([c,e,e,e]))

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


string operate(string num)
{
  int count; //??????????????°
  int i;
  stringstream ss;
  string bef = "";  //??´???????????????????´?
  string buf = "";  //?????¨?????????1??????
  string output = "";
  for (i = 0; i<num.length(); i++) {
    buf = num[i];
    if (i == num.length() - 1) {
      if (buf == bef) {
        ss << count + 1 << buf;
        output += ss.str();
        ss.clear();
      } else {
        ss << count << bef << "1" << buf;
        output += ss.str();
        ss.clear();
      }
    } else if (buf == bef) {
      count++;
    } else {
      if (i != 0) {
        ss << count << bef;
        output += ss.str();
        ss.clear();
        ss.str("");
        bef = buf;
        count = 1;
      } else {
        bef = buf;
        count = 1;
      }
    }
  }
  return output;
}

int main()
{
  int i,m;
  string str;
  while(1) {
    cin >> m;
    if (m == 0) return 0;
    cin >> str;
    for (i = 0 ; i < m ; i++) {
      str = operate(str);
    }
    cout << str << endl;
  }
  return 0;
}

Measured memory_bytes: 1364
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vv = vector<vector<ll>>;
using vvv = vector<vector<vector<ll>>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()
#define PQ priority_queue<ll, vector<ll>, greater<ll>>
#define VVI(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVI(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))

typedef pair<ll, ll> Pair;
bool pairCompare(const Pair &firstElof, const Pair &secondElof) {
  return firstElof.second > secondElof.second;
}

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * POW(n, m - 1)) % MOD;
  }
}

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

vector<ll> X(51, 0);
vvv DP = VVVI(52, 52, 2551, 0);
ll PO[51] = {};

int main() {
  ll N, A;
  ll ans = 0;
  cin >> N >> A;
  REP(i, N) { cin >> X[i]; }
  DP[0][0][0] = 1;
  REP(i, N) {
    REP(j, N) REP(k, N * 50 + 1) {
      DP[i + 1][j + 1][k + X[i]] += DP[i][j][k];
      DP[i + 1][j][k] += DP[i][j][k];
    }
  }
  FOR(i, 1, N + 1) {
    ans += DP[N][i][A * i];
    // cout << DP[N][i][A * i] << endl;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 55296
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int min = Integer.MAX_VALUE;
      int max = Integer.MIN_VALUE;
      int[] arr = new int[n];
      for(int i = 0; i < n; i++) {
        arr[i] = sc.nextInt();
        min = Math.min(min, arr[i]);
        max = Math.max(max, arr[i]);
      }

      while(min <= max) {
        int mid1 = min + (max - min) / 3;
        int mid2 = max - (max - min) / 3;
        int res1 = dist(arr, mid1);
        int res2 = dist(arr, mid2);
        if(res1 >= res2) {
            min = mid1 + 1;
        } else {
            max = mid2 - 1;
        }
      }

      System.out.println(dist(arr, max));
  }
  private static int dist(int[] arr, int num) {
    int res = 0;
    for(int a : arr) {
      res += (num - a) * (num - a);
    }
    return res;
  }

}

Measured memory_bytes: 21844
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M= scan.nextInt();
		int C = scan.nextInt();
		ArrayList<Integer> times = new ArrayList();
		ArrayList<Integer> number = new ArrayList();
		int count = 0;

		for (int i = 0; i < M; i++){
			int B = scan.nextInt();
			times.add(B);
		}

		for (int i = 0; i < N; i++){
			int answer = 0;

			for (int j = 0; j < times.size(); j++){
				int A = scan.nextInt();
				number.add(A);
				answer += times.get(j) * number.get(j);
			}
			answer += C;
			if (answer > 0){
				count++;
			}
			number.clear();
		}
		System.out.println(count);
	}
}

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

int main(){
  int c[3][3];
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin >> c[i][j];
    }
  }
  int b0=c[0][0];
  int b1=c[0][1];
  int b2=c[0][2];
  int a1=c[1][0]-b0;
  int a2=c[2][0]-b0;
  if(a1+b1==c[1][1] && a1+b2==c[1][2] && a2+b1==c[2][1] && a2+b2==c[2][2]){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int N, d[300000], rd[300000];
bool trm(int, bool);

int main(void){
	int i;
	scanf("%d", &N);
	for(i=0; i<N; ++i){
		scanf("%d", d+i);
		d[i]/=10;
		rd[i]=d[i];
	}
	printf("%s\n", (trm(0, true))?"yes":"no");
	return(0);
}

bool trm(int c, bool l){
	int i;
	if((!l)&&(c==0)){return(true);}
	if(c==N-1){l=false;}
	for(i=(c+d[c]>=N)?N-1:c+d[c]; (i>c)&&(l); --i){
		if(trm(i, l)==true){return(true);}
		d[i]=0;
	}
	for(i=(c-rd[c]<0)?0:c-rd[c]; (i<c)&&(!l); ++i){
		if(trm(i, l)==true){return(true);}
		rd[i]=0;
	}
	
	return(false);
}


Measured memory_bytes: 33048
from fractions import gcd
from functools import reduce

n = int(input())
a = [int(x) for x in input().split()]

left = [0] * (n + 1)
right = [0] * (n + 1)
for i in range(n):
   left[i+1] = gcd(left[i], a[i])
   right[n-i-1] = gcd(right[n-i], a[n-1-i])

ans = 0
for i in range(n):
   ans = max(ans, gcd(left[i], right[i+1]))
print(ans)


Measured memory_bytes: 16116
n = int(input())
w = list(map(int, input().split()))
# n = 3
# w = [1, 2, 3]
v = abs(sum(w[:1]) - sum(w[1:]))
for i in range(1, n):
    v = min(v, abs(sum(w[:i]) - sum(w[i:])))
print(v)


Measured memory_bytes: 2940