akhauriyash/Code-Regression huggingface dataset:
import bisect

n, m, k = map(int, input().split())
INF = 10**18
A = list(map(int, input().split()))
B = list(map(int, input().split()))
cum_a = [0] * (n+1)
cum_b = [0] * (m+1)
for i in range(n):
    cum_a[i+1] = cum_a[i] + A[i]
for i in range(m):
    cum_b[i+1] = cum_b[i] + B[i]
INF = 10**18
ans = -INF
for i in range(n+1):
    mod = k - cum_a[i]
    b = bisect.bisect(cum_b, mod)
    if b == 0:
        ans = max(ans, i)
        break
    ans = max(ans, b+i)
ans -= 1
print(ans)


Measured memory_bytes: 47428
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int N;
    long long M;
    cin >> N >> M;
    long long ans = 0;

    for ( long long a = 1; a*a <= M; a++ ) {
        if ( M%a == 0 ) {
            if ( a >= N ) { ans = max( ans, M/a ); }
            if ( M/a >= N ) { ans = max( ans, a ); }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]){
        int N=sc.nextInt();
        long n=0,p=sc.nextLong(),res=0;
        for(int i=1;i<N;i++){
            n=sc.nextLong();
            if(p>n){
                res+=p-n;
            }
            else{
                p=n;
            }
        }
        System.out.println(res);
    }
}


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

using namespace std;

int main(){

	string s;
  	long long int lp, dg, ans=0;

	cin>> s;

  	reverse(s.begin(), s.end());
  
  	for(int i=0;i<s.size();i++){
      	lp=1<<(s.size()-1);
      	dg=1;
      	for(int j=0;j<i;j++){
          	lp/=2;
          	ans+=(int)(s[i]-'0')*dg*lp;
          	//cout<< (int)(s[i]-'0') << " " << dg << " " << lp <<endl;
          	dg*=10;
        }
        ans+=(int)(s[i]-'0')*dg*lp;
        //cout<< (int)(s[i]-'0') << " " << dg << " " << lp <<endl;
    }
  
  	cout<< ans <<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 998244353;
const int MAX_N = 200100;
signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int n, k;
    cin >> n >> k;
    vector<int> p;
    rep(i, n)
    {
        int t;
        cin >> t;
        p.emplace_back(t + 1);
    }
    vector<int> q;
    int t = 0;
    q.emplace_back(t);
    rep(i, n)
    {
        t += p[i];
        q.emplace_back(t);
    }
    int ans = -INF;
    for (int i = 0; i <= n - k; i++)
    {
        ans = max(ans, q[i + k] - q[i]);
    }
    cout << setprecision(10) << (double)ans / 2.0 << endl;

    return 0;
}

Measured memory_bytes: 4848
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var rcrc = Sarray();
            var r1 = (int)rcrc[0];
            var c1 = (int)rcrc[1];
            var r2 = (int)rcrc[2];
            var c2 = (int)rcrc[3];
            var cmb = new Combination(2000007);
            long square(int x, int y) => cmb.nCk(x + y + 2, x + 1) - 1;
            var ans = square(r2, c2)
                    - square(r2, c1 - 1)
                    - square(r1 - 1, c2)
                    + square(r1 - 1, c1 - 1);
            WriteLine((ans % Mod + Mod) % Mod);
        }
        public class Combination
        {
            readonly long mod;
            readonly long[] fac, finv, inv;
            public Combination(long n, long mod = 1000000007)
            {
                long max = n + 1;
                this.mod = mod;
                fac = new long[max];
                finv = new long[max];
                inv = new long[max];
                fac[0] = fac[1] = 1;
                finv[0] = finv[1] = 1;
                inv[1] = 1;
                for (int i = 2; i < max; ++i)
                {
                    fac[i] = fac[i - 1] * i % mod;
                    inv[i] = mod - inv[mod % i] * (mod / i) % mod;
                    finv[i] = finv[i - 1] * inv[i] % mod;
                }
            }
            public long nCk(int n, int k)
            {
                if (n < k) return 0;
                if (n < 0 | k < 0) return 0;
                return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
            }
        }
    }
}

Measured memory_bytes: 75164
#include "bits/stdc++.h"
using namespace std;

int main(){
	vector<int> a(5);
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
	sort(a.begin(),a.end());
	
	cout<<a[4]<<" "<<a[3]<<" "<<a[2]<<" "<<a[1]<<" "<<a[0]<<endl;
	return 0;
}

Measured memory_bytes: 3124
import sys
import numpy as np

from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m, l = map(int, readline().split())
rest = np.array(read().split(), np.int64)
abc = rest[: m + m + m]
a = abc[::3]
b = abc[1::3]
c = abc[2::3]
st = rest[m + m + m + 1 :]
s = st[::2]
t = st[1::2]


dist_graph = csr_matrix((c, (a, b)), (n + 1, n + 1))
dist_path = floyd_warshall(dist_graph, directed=False)

cost_graph = np.full((n + 1, n + 1), np.inf)
np.fill_diagonal(cost_graph, 0)
cost_graph[dist_path <= l] = 1

cost_path = floyd_warshall(cost_graph, directed=False)

cost_path[cost_path == np.inf] = 0
cost_path = (cost_path).astype(int)

x = cost_path[s, t] - 1

print("\n".join(x.astype(str)))


Measured memory_bytes: 37892
#include <stdio.h>
#include <math.h>

int main(){ 
	int n,d,i,j;
	scanf("%d %d",&n,&d);
	int s[n][d];
	for(i = 0;i < n;i++){
		for(j = 0; j < d;j++){
			scanf("%d",&s[i][j]);
		}
	}
	float f;
	int h = 1,sum = 0;
	for(i = 0;i < n;i++){
		for(h = 1;h + i < n;h++){
			f = 0;
			for(j = 0; j < d;j++){
				f += pow((s[i][j]-s[i+h][j]),2.0);
			}
			if(sqrt(f)-(int)sqrt(f)==0) sum++;
		}
	}
	printf("%d",sum);
	return 0;
}

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


int main(int argc, char const *argv[])
{
    int X,A,B;
    cin>>X>>A>>B;

    
    if (B<=X) {
        cout<<"delicious";
    }else 
    if (B<=A+X) {
        cout<<"safe";
    }
    else
    {
        cout<<"dangerous";
    }
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n, m; cin >> n >> m;
	VI a(m); REP(i,m) cin >> a[i];
	ll sum=0;
	REP(i,m) sum+=a[i];
	cout << max((ll)-1,n-sum) << endl;
	return 0;
}


Measured memory_bytes: 3676
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#ifndef LOCAL
#define endl '\n'
#endif

const int mod = 1e9 + 7;

int pwr(int a,int b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

const int N = 1e5 + 5;
int cnt[N];

void solve() {
	int n, k;
	cin >> n >> k;
	ll ans = 0;
	for(int g = k; g >= 1; g--) {
		cnt[g] = pwr(k / g, n);
		for(int i = 2 * g; i <= k; i += g) {
			cnt[g] += mod - cnt[i];
			cnt[g] %= mod;
		}
		ans = (ans + g * 1LL * cnt[g]) % mod;
	}
	cout << ans;
}

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	// cin >> t;
	t = 1;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 4036
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long lint;
typedef pair<int, int> P;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

const int MAX_N = 600000;

int prime[MAX_N];
bool is_prime[MAX_N + 1];

void sieve(int n) {
  int p = 0;
  for (int t = 0; t <= n; t++)
    is_prime[t] = true;
  is_prime[0] = is_prime[1] = false;
  for (int t = 2; t <= n; t++) {
    if (is_prime[t] == true) {
      prime[p++] = t;
      for (int i = 2 * t; i <= n; i += t)
        is_prime[i] = false;
    }
  }
}

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

  sieve(560000);

  vector<int> ans;

  int cont = 0;
  for (int i = 3; i <= 55555; i++) {
    if (is_prime[i] && ((i - 1) / 2) % 5 == 0) {
      cont++;
      ans.push_back(i);
    }

    if (cont == N)
      break;
  }

  for (int i = 0; i < ans.size(); i++) {
    if (i != 0)
      cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);

void solve(){
    ll n, m; cin >> n >> m;
    cout << pow(2, m)*(1900*m + 100*(n - m)) << endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define mod 1000000007

typedef long long ll;

using namespace std;

int main(){
    int a,b;cin >> a >> b;
    string s;cin >> s;
    
    if(s[a]!='-'){
        cout << "No" << endl;
        return 0;
    }
    else{
        for(int i=0;i<a;i++){
            if(!(s[i]>='0' && s[i]<='9')){
                cout << "No" << endl;
                return 0;
            }
        }
        for(int i=a+1;i<a+b;i++){
            if(!(s[i]>='0' && s[i]<='9')){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 764
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int maxi = 0, ans;
	for (int i = 0; i < n; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		if (maxi < za)
		{
			maxi = za;
			ans = za + zb;
		}
	}
	printf("%d\n", ans);
}

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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define pf push_front
#define pii pair <int ,int>
#define all(s) s.begin (), s.end ()

using namespace std;

int main()
{
    long long n, m, m1, n1;

    cin >> n >> m;

    m1 = abs(m);
    n1 = abs(n);

    if( (n == 0 && m > 0) )
    {
        cout << m;
        return 0;
    }
    if( n == 0 && m < 0 )
    {
        cout << m1 + 1;
        return 0;
    }
    if(  m == 0 && n > 0  )
    {
        cout << n + 1;
        return 0;
    }
    if( m == 0 && n < 0 )
    {
        cout << n1;
        return 0;
    }

    if( m1 == n || n1 == m )
    {
        cout << 1;
        return 0;
    }


    if( n > 0 && m > 0 && m > n )
    {
        cout << m - n;
        return 0;
    }
    if( n > 0 && m > 0 && n > m )
    {
        cout << n - m + 2;
        return 0;
    }


    if( n < 0 && m < 0 && m1 > n1 )
    {
        cout << m1 - n1 + 2;
        return 0;
    }
    if( n < 0 && m < 0 && m1 < n1 )
    {
        cout << n1 - m1;
        return 0;
    }


    if( n < 0 && m > 0 && m > n1 )
    {
        cout << m1 - n1 + 1;
        return 0;
    }
    if( n1 > m1 && n < 0 && m > 0 )
    {
        cout << n1 - m1  + 1;
        return 0;
    }


    if( n > 0 && m < 0 && n1 > m1 )
    {
        cout << n - m1 + 1;
        return 0;
    }
    if( n > 0 && m < 0 && n1 < m1 )
    {
        cout << m1 - n + 1;
        return 0;
    }

}
///5 10 100
///100 10 1


Measured memory_bytes: 256
import std.stdio, std.conv, std.math, std.string, std.range, std.array,
       std.algorithm;

long s(long n)
{
    long s;
    while(n > 0)
    {
        s += n % 10;
        n /= 10;
    }
    return s;
}

void main(){
    auto K = readln().strip().to!int();

    long step = 1;

    long befoki = 0;
    long i = 1;
    for (long c = 0; c < K;) {
        auto nwev = i.to!double() / s(i);
        auto nxev = (i+step).to!double() / s(i+step);

        //write(nwev, "\t", nxev, "\t");
        //writeln(i);
        if(nwev <= nxev) {
            writeln(i);
            c++;
            if(step != i-befoki) {
                step = i - befoki;
            }
            befoki = i;
        }
        nwev = nxev;

        i += step;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
using namespace std;
long long f(vector<vector<long long>> cake,vector<int> pos)
{
	long long sum = 0;
	for(int i=0; i<3; i++)
	{
		sum+=cake[i][pos[i]];
	}
	return sum;
}
int getflag(vector<vector<vector<int>>> flag ,vector<int> pos)
{
	return flag[pos[0]][pos[1]][pos[2]];
}
void setflag(vector<vector<vector<int>>>& flag ,vector<int> pos,int value)
{
	flag[pos[0]][pos[1]][pos[2]]=value;
}
bool fflag(set<long long> flag,vector<int> pos)
{
	if(flag.find(pos[0]*1000000+pos[1]*1000+pos[2]) == flag.end())
	{
		return false;
	}
	return true;
}
int main()
{
	vector<int> size(3);
	for(int i=0; i<3; i++)
	{
		cin>>size[i];
	}

	set<long long> flag;
	

	int K;
	cin>>K;
	vector<vector<long long>> cake;
	cake.resize(3);
	for(int i=0; i<3; i++)
	{
		cake[i].resize(size[i]);
		for(int j=0; j<size[i]; j++)
		{
			cin>>cake[i][j];
		}
	}
	for(int i=0; i<3; i++)
	{
		sort(cake[i].begin(),cake[i].end(),greater<long long>());
	}
	priority_queue<pair<long long,vector<int>>> q;
	vector<int> initial{0,0,0};
	q.push(make_pair(f(cake,initial),initial));
	flag.insert(0);
	for(int k=0; k<K; k++)
	{
		
		cout<<q.top().first<<endl;
		vector<int> list = q.top().second;
		
		q.pop();
		if(k==K-1)
		{
			break;
		}
		
		vector<vector<int>> next(3);
		next[0] = {list[0]+1,list[1],list[2]};
		next[1] = {list[0],list[1]+1,list[2]};
		next[2] = {list[0],list[1],list[2]+1};

		for(int i=0; i<3; i++)
		{
			if(list[i]+1>=size[i] || fflag(flag,next[i]))
			{
				continue;
			}
			q.push(make_pair(f(cake,next[i]),next[i]));
			flag.insert(next[i][0]*1000000+next[i][1]*1000+next[i][2]);
		}
	}
	return 0;
}

Measured memory_bytes: 1408
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include <vector>
#include <list>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <climits>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <set>
#include <random>
using namespace std;


int main() {
	string s;
	cin >> s;
	int f = 0;
	int l = s.size() - 1;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'A') { f = i; break; }
	}
	for (int i = s.size()-1; i >= 0; i--)
	{
		if (s[i] == 'Z') { l = i+1; break; }
	}

	cout << l - f << endl;

	return 0;
}

Measured memory_bytes: 640
/// __Macro's__
// #pragma GCC optimize("-O2")
#include <bits/stdc++.h>
using namespace std;
#define ll                   long long
#define II                   pair<int,int>
#define III                  pair<int, II>
#define VL                   vector<ll>
#define VI                   vector<int>
#define VII                  vector<II>
#define VIII                 vector<III>
#define VVI                  vector<vector<int>>
#define VVII                 vector<vector<II>>
#define fr                   first
#define sc                   second
#define mkpr                 make_pair
#define PQ                   priority_queue
#define pb                   push_back
#define eb                   emplace_back
#define all(v)               v.begin(), v.end()
#define LINE                 putc('\n', stdout)
#define SPACE                putc(' ' , stdout)
#define TAB                  putc('\t', stdout)
#define fillarr(arr, val)    fill((int*)arr, (int*)arr+(sizeof(arr)/sizeof(int)), val)
#define Log2(x)              (31^__builtin_clz(x))
#define inf                  2000000007 
#define MOD                  1000000007 
#define getint ReadInt()
const char IO_MODE = 3; // in-->00<--out (MSB-->LSB) | 0: Norm, 1: Fast 
inline ll ReadInt(){ll x=0,s=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')s=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';
c=getchar();}return s*x;}inline void WriteInt(ll x){char c[20];if(!x){putchar('0');return;}if(x<0)putchar('-'),x=-x;int i=0;while(x>0)
c[++i]=x%10,x/=10;while(i)putchar(c[i--]+48);}template <typename T>inline void out(T x){if(IO_MODE&1)WriteInt(x);else if(typeid(x)==typeid(int))
printf("%i", x);else printf("%lld", (ll)x);}template<typename T, typename... Args>inline void out(T x,Args...args){out(x);SPACE;out(args...);}
template <typename T>inline void in(T &x){if(IO_MODE&2) x=ReadInt();else if(typeid(x)==typeid(int))scanf("%i",&x);else if(typeid(x)==typeid(ll))
scanf("%lld",&x);}template<typename T, typename... Args>inline void in(T &x,Args&...args){in(x);in(args...);}
int aa,bb,cc,dd,ee,ff,gg,hh,ii,jj,kk,mm,nn,oo,pp,qq,rr,ss,tt,uu,vv,ww,xx,yy,zz;
int tc;
///

#define nax 100100

int n;
int A[nax], B[nax];
int main()
{
  in(n);
  for(int i=1 ; i<=n ; i++)  in(A[i]);
  A[0]=-1;
  for(int i=1 ; i<=n ; i++)
  {
    if(A[i]<=A[i-1]) B[i] = B[i-1]+1;
    else B[i]=0;
  }
  cout << *max_element(B+1, B+n+1) << endl;

}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>

int main() {
  int i;
  int a,b;
  while(scanf("%d %d",&a, &b) != EOF) {
    int c = a+b;
    for(i = 1; i < 9; i++) {
      if(c/(int)pow(10,i) == 0) {
	printf("%d\n",i);
	break;
      }
    }
  }

  return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
vector<l_l> ans;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    if(N % 2 == 0) {
        for(int i = 1; i <= N; i++) {
            for(int j = i + 1; j <= N; j++) {
                if(i + j == N + 1) continue;
                ans.push_back({i, j});
            }
        }
    } else {
        for(int i = 1; i <= N; i++) {
            for(int j = i + 1; j <= N; j++) {
                if(i + j == N) continue;
                ans.push_back({i, j});
            }
        }
    }
    cout << ans.size() << endl;
    for(int i = 0; i < ans.size(); i++) {
        cout << ans[i].first << " "<< ans[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 512
N = int(input())
A = []
for _ in range(N):
    A += [int(input())]

right = [0] * (N + 1)
left = [0] * (N + 1)
for i in range(1, N + 1):
    right[i] = max(right[i-1], A[i-1])
    left[N - i] = max(left[N + 1 -i], A[N - i])

# print (right)
# print (left)

for i in range(N):
    print (max(right[i], left[i + 1]))


Measured memory_bytes: 15712
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <limits>
#include <map>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define IREP(i,j,n) for(int (i)=(j);(i)<(n);(i)++)
#define INF numeric_limits<double>::infinity()
using namespace std;

int a,b,c;

int main()
{
    cin >> a >> b >> c;
    if (a+b>=c){
        cout << "Yes" << endl;
    }
    if(a+b<c){
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int H, W;
  while(1){
  cin >> H >> W;
  if (H == 0 && W == 0)
   return 0;
    for(int j=0; j<H; j++){
    for(int i=0; i<W; i++){
        cout << '#';
    }
    cout << endl;
  }
  cout << endl;
}
return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false) , cin.tie(0) ;
#define w(x) cout << (#x) << " is " << x << "\n" ;

int main()
{
    //fast ;
//#ifndef ONLINE_JUDGE
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
//#endif
    int n,k,s=0,i;
    cin >> n >> k ;
    vector<int>v(n);
    for(auto &c:v)
        cin >> c;
    sort(v.begin(),v.end());
    for(i=0 ; i<k; i++)
        s+=v[i];
    cout << s << "\n";
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
//#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
main(){
    fastio;
    int n;
    cin >> n;
    vector<int> b(n-1);
    for(int &x : b) cin >> x;
    vector<int> a(n);
    a[0] = a[1] = b[0];
    for(int i=1;i<n-1;i++){
        a[i+1] = b[i];
        if(a[i] > a[i+1]){
            a[i] = a[i+1];
        }
    }
    cout << accumulate(td(a),0) << endl;
}   

Measured memory_bytes: 256
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
//これは、頭が悪く競プロが世界で一番できないHIR180が
//IOI2014日本代表になるまでのN日間の記録である。
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define f first
#define s second
#define rep(i,x) for(int i=0;i<x;i++)
P za[3005];
int main()
{
	srand((unsigned int)time(NULL));
	while(1)
	{
		int n;
		scanf("%d",&n); if(!n) return 0;
		static bool in[5005][5005]={};
		for(int i=1;i<=n;i++)
		{
			scanf("%d %d",&za[i].f,&za[i].s);
			in[za[i].f][za[i].s]=true;
		}
		int ret=0;
		for(int i=1;i<=n;i++)
		{
			for(int j=i+1;j<=n;j++)
			{
				int xa=za[i].f;
				int xb=za[j].f;
				int ya=za[i].s;
				int yb=za[j].s;
				if(xa+xb-yb+ya<0||ya+yb+xb-xa<0||xa+xb+yb-ya<0||ya+yb-xb+xa<0) continue;
				if(xa+xb-yb+ya>10000||ya+yb+xb-xa>10000||xa+xb+yb-ya>10000||ya+yb-xb+xa>10000) continue;
				if(in[(xa+xb-yb+ya)/2][(ya+yb+xb-xa)/2] && in[(xa+xb+yb-ya)/2][(ya+yb-xb+xa)/2]) ret=max(ret,(xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
			}
		}
		printf("%d\n",ret/2);
	}
}

Measured memory_bytes: 25068
import sys
def input():
    return sys.stdin.readline()[:-1]
H,W=map(int,input().split())
t=0
n=0
a=[]
for i in range(H//2):
    s=tuple(map(int,input().split()))
    for j in range(W-1):
        if (s[j]+t)%2==1:
            t=1
            a.append((2*i+1,j+1,2*i+1,j+2))
            n+=1
        else:
            t=0
    if (s[-1]+t)%2==1:
        t=1
        a.append((2*i+1,W,2*i+2,W))
        n+=1
    else:
        t=0
    s=tuple(map(int,input().split()))
    for j in range(W-1,0,-1):
        if (s[j]+t)%2==1:
            t=1
            a.append((2*i+2,j+1,2*i+2,j))
            n+=1
        else:
            t=0
    if (s[0]+t)%2==1:
        if i!=H/2-1:
            t=1
            a.append((2*i+2,1,2*i+3,1))
            n+=1
    else:
        t=0
if H%2==1:
    s=tuple(map(int,input().split()))
    for j in range(W-1):
        if (s[j]+t)%2==1:
            t=1
            a.append((H,j+1,H,j+2))
            n+=1
        else:
            t=0
print(n)
for i in a:
    print(*i)

Measured memory_bytes: 24416
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    A = list(map(int,input().split()))
    A.sort()
    max_A = max(A)
    dp = [True] * (max_A+1) # iより小さいiの約数がAに存在しない
    multi = [0] * (max_A+1) #重複個数
    for a in A:
        multi[a] += 1
        if multi[a] > 1: continue
        x = a
        while x + a <= max_A:
            x += a
            dp[x] = False
    ans = 0
    for a in A:
        if dp[a] and multi[a]==1:
            ans += 1
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 109228
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int a, b, c; cin>>a>>b>>c;
    if(c<=a-b) cout<<0<<endl;
    else cout<<c-(a-b)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%lld",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define ll long long
#define mod 1000000007
#define bitcount    __builtin_popcountll
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pi pair<ll,ll>
vector<ll> q[100005];
ll a[100005];
ll ans=0;
ll dfs(ll cur,ll par)
{
	vector<ll> v;
	ll j=0;
	for(ll i=0;i<q[cur].size();i++)
	{
		if(q[cur][i]==par)
			continue;
		j++;
		v.pb(dfs(q[cur][i],cur));
	}
	if(j==0)
		return a[cur];
	sort(v.begin(),v.end());
	ll x,y,z;
	j=0;
	for(ll i=0;i<v.size();i++)
		j+=v[i];
	ll k=j-v[v.size()-1];
	if(j>2*k)
	{
		y=j-2*k;
		j-=y;
	}
	else
		y=0;
	x=2*a[cur]-2*y-j;
	if(x<0||x>j)
	{
		ans=-1;
		return 0;
	}
	else
		return x+y;
}
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ll n,i,j,k;
    sd(n);
    for(i=1;i<=n;i++)
    	sd(a[i]);
    for(i=1;i<n;i++)
    {
    	sd(j);
    	sd(k);
    	q[j].pb(k);
    	q[k].pb(j);
    }
    if(n==2)
    {
    	if(a[1]==a[2])
    		printf("YES\n");
    	else
    		printf("NO\n");
    	return 0;
    }
    for(i=1;i<=n;i++)
    {
    	if(q[i].size()>=2)
    	{
    		j=dfs(i,0);
    		break;
    	}
    }
    if(j==0&&ans==0)
    	printf("YES\n");
    else
    	printf("NO\n");
    return 0;
}

Measured memory_bytes: 15872
import math;

def swap(a,b):
    return (b,a)

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

def main():
    l,r = map(int,input().split())
    mod = 2019
    r = min(r,l+mod*2)
    ans = 2018
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            x = i * j % mod
            ans = min(ans,x)
    print(ans)
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 40176
#include <bits/stdc++.h>
using namespace std;
double sum=0;
int main()
{
	int n;
	cin>>n;
	double a[n];
	for (int i=0;i<n;i++)
	{
		string s;
		cin>>a[i]>>s;
		if (s=="JPY")
			sum+=a[i];
		else
			sum+=380000*a[i];
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int k,n;
	cin >> k >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
	}
	int mx=a[0]+(k-a[n-1]);
	for(int i=1;i<n;i++)
	{
		int tmp=a[i]-a[i-1];
		if(tmp>mx)
			mx=tmp;
	}
	cout << k-mx << endl;




}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define FLOOR(x) ((int)floor(((double)x)))
#define CEIL(x) ((int)ceil(((double)x)))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


string S, T;


bool solve(){
	if(S == T) return true;
	string s;
	rep(i, 0, SIZE(S)){
		s.pb(S[SIZE(S)-1]);
		rep(j, 0, SIZE(S)-1) s.pb(S[j]);
		S = s;
		s = "";
		if(S == T) return true;
	}
	return false;
}


signed main(){
	cin >> S >> T;

	if(solve()) Yes;
	else No;

	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a = [i for i in map(int,input().split())]
bc = [[i for i in map(int,input().split())] for j in range(m)]

a.sort(reverse=True)
bc.sort(key=lambda x: x[1], reverse=True)
arr = []
j = 0
for i in range(n):
  arr.append(bc[j][1])
  bc[j][0]-=1
  if bc[j][0]==0:
    j += 1
  if j >= m:
    break

while len(arr) < n:
  arr.append(a.pop(0))
arr.sort()

for i in range(len(arr)):
  if arr[i] < a[0]:
    arr[i] = a.pop(0)
  
print(sum(arr))


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



Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
int MOD = 1000000007;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;
	cin >> a >> b;
	const double tax_8 = 0.08;
	const double tax_10 = 0.10;

	int r_a = 0;
	int r_b = 0;

	double a_1 = a / tax_8;
	if(a%2!=0) r_a = 1;
	double a_2 = (a+1.0) / tax_8;
	double b_1 = b / tax_10;
	double b_2 = (b+1.0) / tax_10;
	//cout << a_1 << "," << a_2 << "," <<  b_1 << "," << b_2 << endl;
	
	if(b_1 <= a_1 && a_1 < b_2) cout << (int)a_1+r_a << endl;
	else if(a_1 <= b_1 && b_1 < a_2) cout << (int)b_1 << endl;
	else cout << -1 << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;

#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

ll n, k, m, M = 1e9 + 7;

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

    cin >> n;

    if(n % 2 == 1) return cout << 0 << endl, 0;

    ll prd = 2, sum = 0;
    while(prd <= n) {
        prd *= 5;
        sum += n / prd;
    }

    cout << sum << endl;
}

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

int main() {
	string s;
	cin >> s;
	if (s == "Sunny")cout << "Cloudy" << endl;
	if (s == "Cloudy")cout << "Rainy" << endl;
	if (s == "Rainy")cout << "Sunny" << endl;
		return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.awt.geom.*;
import java.io.*;

public class Main{
	int p,q,r;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			String s = sc.next() + "#";
			if(s.equals(".#")) break;
			 p = 0;
			 q = 0;
			 r = 0;
			 int count = 0;
			 
			 for(p = 0; p < 3; p++){
				 for(q = 0; q < 3; q++){
					 for(r = 0; r < 3; r++){
						 int res = new Parse(s + "", 0).exp();
						 if(res == 2){
							 count++;
						 }
					 }
				 }
			 }
			 System.out.println(count);
		}
		
	}
	
	class Parse{
		String str;
		int pos;
		
		public Parse(String str, int pos) {
			this.str = str;
			this.pos = pos;
		}


		private int exp() {
			int res = fact();
			while(true){
				char op = str.charAt(pos);
				if((op == '+') || (op == '*')){
					int old = res;
					pos++;
					res = fact();
					switch(op){
					case '+':
						res = Math.max(old, res);
						break;
					case '*':
						res = Math.min(old, res);
						break;
					}
				}
				else{
					break;
				}
			}
			return res;
		}


		private int fact() {
			if(Character.isDigit(str.charAt(pos))){
				int t = str.charAt(pos) - '0';
				pos++;
				return t;
			}
			else if(str.charAt(pos) == '('){
				pos++;
				int res = exp();
				pos++;
				return res;
			}
			else if(str.charAt(pos) == '-'){
				pos++;
				int res = fact();
				if(res == 0){
					res = 2;
				}
				else if(res == 1){
					res  = 1;
				}
				else{
					res = 0;
				}
				return res;
			}
			else if(str.charAt(pos) == 'P'){
				pos++;
				return p;
			}
			else if(str.charAt(pos) == 'Q'){
				pos++;
				return q;
			}
			else if(str.charAt(pos) == 'R'){
				pos++;
				return r;
			}
			//dead code
			return 0;
		}
	}
	
	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

Measured memory_bytes: 27424
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int n;
	cin >> n;
	int a[n], s[n+1];
	for( int i= 0; i< n; ++i ){
		cin >> a[i];
		if( i > 0 )
			s[i] = s[i-1] + abs(a[i]-a[i-1]);
		else
			s[i] = abs(a[i]);
	}
	s[n] = s[n-1] + abs(a[n-1]);
	//cout << s[n] << endl;
	for( int i = 0; i < n; ++i ){
		if( i == 0 )
			cout << s[n] - s[i+1] + abs(a[i+1]) << endl;
		else if( i == n-1 )
			cout << s[i-1] + abs(a[i-1]) << endl;
		else
			cout << s[n] - (s[i+1] - s[i-1]) + abs(a[i-1] - a[i+1]) << endl;
	}
	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;



int main(){
  ll n;
  cin >>n;
  ll a[n];
  rep(i,n)cin>>a[i];
  ll ans=0;
  rep(i,n)if(a[i]%2==1)ans=1;
  if(ans%2==1){cout << "first" << endl;}else{cout << "second" << endl;}
}

Measured memory_bytes: 4388
#include<bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define mp make_pair
#define ff first
#define se second
#define MAX 1000001
#define MAXN 200001
#define mod 1000000007 
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double x,y,p;
    cin>>x>>y;
    p=x/y;
    cout<<fixed<<setprecision(10)<<p;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n = 3;
	int five = 0, seven = 0;

	while(n--) {
		int x;
		scanf("%d", &x);
		if (x == 5)
			five++;
		else if (x == 7)
			seven++;
		else
			break;
	}
	puts(five == 2 && seven == 1 ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	while(1) 
	{
		bool f=false;
		for(int i = a; i < b+1; ++i)
		{
			if(i%400==0) 
			{
				cout<<i<<endl;
				f=true;
			}
			else if(i%100!=0)
			{
				if(i%4==0)
				{
					cout<<i<<endl;
					f=true;
				}
			}
		}
		if(!f) cout<<"NA"<<endl;
		cin>>a>>b;
		if(a==0&&b==0) break;
		else cout<<endl;
	}
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
int n;
cin>>n;
vector<int>a(n);
for(int i=0;i<n;i++)cin>>a[i];
int j=0;
int cnt=0;
for(int i=0;i<n;i++){
  if(a[i]==j+1)j++;
  else cnt++;
}
if(!j)cout<<-1;
else cout<<cnt;
}

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

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

    vector<int> ans(n, 1);
    rep(i, n) {
        if (s.substr(i, 2) == "RR") {
            ans[i + 2] += ans[i];
            ans[i] = 0;
        }
    }

    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == 'L' && s[i - 1] == 'L') {
            ans[i - 2] += ans[i];
            ans[i] = 0;
        }
    }

    rep(i, n - 1) cout << ans[i] << ' ';
    cout << ans[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 3864
import java.util.*;
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int wk=0;
		int ans=0;
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		for(int i=2;i<=N;i++){
			wk=sc.nextInt();
			if (map.containsKey(wk)){
			map.put(wk, map.get(wk)+1);
			}
			else{
			map.put(wk, 1);
			}
		}
		// mapキーでソートする
		Object[] mapkey = map.keySet().toArray();
		Arrays.sort(mapkey);
		for(int i=1;i<=N;i++){
			if (map.containsKey(i)){
			System.out.println(map.get(i));
			}
			else{
			System.out.println(ans);
			}
			}
    }
}

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

bool isATGC(char c){
    return c == 'A' || c == 'T' || c == 'G' || c == 'C';
}

int main(){
    string str = "";
    cin >> str;
    int atgc = 0;
    int head = 0;
    int tail = 0;
    for(int head = 0; head < str.size(); head++){
        tail = head;
        int atgc_tmp = 0;
        while(tail < str.size()){
            if(isATGC(str.at(tail))){
                atgc_tmp++;
                if(tail == str.size()-1){
                    atgc = max(atgc, atgc_tmp);
                    break;
                }
            } else {
                atgc = max(atgc, atgc_tmp);
                break;
            }
            tail++;
        }
    }
    cout << atgc << endl;
}

Measured memory_bytes: 256
def main():
  H, W = list(map(int, input().split()))

  count = 0

  for i in range(H):
    row = input()
    for j in range(W):
      if(row[j] == '#'):
        count += 1

  print("Possible" if W + H - 1 == count else "Impossible")

if __name__ == "__main__":
  main()


Measured memory_bytes: 2940
import math

N, K = map(int, input().split())

def blue(b):
    if K-1<0 or K-b<0 or b-1<0:
        return 0
    else:
        return math.factorial(K-1)//(math.factorial(b-1)*math.factorial(K-b))
def red(r):
    if N-K+1<0 or N-K-r+1<0 or r<0:
        return 0
    else:
        return math.factorial(N-K+1)//(math.factorial(N-K-r+1)*math.factorial(r))

for i in range(1,K+1):
    ans = blue(i)*red(i)
    print(ans%(10**9+7))



Measured memory_bytes: 3316
#include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

int main() {
  int year[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
  string day[7] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
  int first = 3;

  int m, d;
  while (true) {
    cin >> m >> d;
    if (!(m|d)) break;
    int n = first;
    for (int i = 0; i < m-1; i++) {
      n += year[i];
    }
    n += d-1;

    n %= 7;
    cout << day[n] << endl;
  }
}

Measured memory_bytes: 1192
from functools import reduce

#def gcd(a, b):
#    while b:
#        a, b = b, a % b
#    return a

def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

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

N = int(input())
Ts = []
c = 1
for i in range(N):
    c = lcm(c, int(input()))

print(int(c))


Measured memory_bytes: 3572
// Itp1_5_d.java
import java.io.*;
import java.lang.Integer;
public class Main
{
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			call( Integer.parseInt(br.readLine()));
		} catch ( IOException e ) {
			System.out.println("??¨??????????????????????????????");
		}
	}
	public static void call(int n) {
		int i = 1;
		do {
			int x = i;
			if ( x%3 == 0) {
				System.out.print(" " + i);
				continue;
			}
			while( x != 0 ) {
				if ( x%10 == 3) {
					System.out.print( " " + i);
					break;
				}
				x /= 10;
			}
		} while( ++i <= n);
		System.out.println("");
	}
}

Measured memory_bytes: 26476
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
int main(void){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        
    }
    //cout<<gcd(5,0)<<endl;
    vector<int>left(n+1,0),right(n+1,0);
    for(int i=0;i<n;i++){
        left[i+1]=gcd(left[i],a[i]);
    }
    for(int i=n-1;i>=0;i--){
        right[i]=gcd(right[i+1],a[i]);
    }
    int res=0;
    for(int i=0;i<n;i++){
        int l,r;
        l=left[i];
        r=right[i+1];
        res=max(res,gcd(l,r));
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

int main(){
    lint n, k;
    scanf("%lld%lld", &n, &k);
    int a[n];
    vector<int> v(n);
    rep(i, n){
        scanf("%d", &a[i]);
        v[i] = a[i];
    }
    sort(v.begin(), v.end());
    lint ans = 0;
    const lint mod = 1e9 + 7;
    rep(i, n){
        lint s = lower_bound(v.begin(), v.end(), a[i]) - v.begin();
        lint t = 0;
        For(j, i+1, n)if(a[i] > a[j]) ++t;
        ans += t*k % mod + k*(k-1)/2 % mod * (lint)s % mod;
        ans %= mod;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 256
use std::cmp::*;

#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (n, weight) = get!(usize, usize);
    let mut w_vec = Vec::with_capacity(n);
    let mut v_vec = Vec::with_capacity(n);
    for _ in 0..n {
        let (w, v) = get!(usize, usize);
        w_vec.push(w);
        v_vec.push(v);
    }
    let mut dp = vec![vec![1 << 60; 100005]; n + 1];
    dp[0][0] = 0;
    dp[1][30] = 3;
    for i in 0..n {
        for v in 0..100004 {
            if v_vec[i] <= v {
                dp[i + 1][v] = min(dp[i][v], dp[i][v - v_vec[i]] + w_vec[i]);
            } else {
                dp[i + 1][v] = dp[i][v];
            }
        }
    }
    let mut ans = 0;
    for i in 0..dp[n].len() {
        if 0 < dp[n][i] && dp[n][i] <= weight {
            ans = max(ans, i);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 106748
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<string>
//#include<windows.h>


using namespace std;



#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9 + 7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 1e6+3;


int main() {
	int n;
	cin >> n;
	int a[200003];
	for (int i = 1; i < n + 1; i++) {
		cin >> a[i];
	}
	long long int b[200003];
	int c[200003] = {};
	int cnt = 0;
	for (int i = n + 1; i > 0; i--) {
		if (i * 2 > n) {
			if (a[i] == 1) {
				b[cnt] = i;
				c[i] = 1;
				cnt++;
			}
		}
		else {
			int i3 = i;
			int cnter = 0;
			for (int i2 = 2; i * i2 <= n; i2++) {
				i3 = i * i2;
				if (c[i3] == 1) {
					cnter++;
				}
			}/*
			if (i == 2) {
				cout << i3 << " " << i << " " << a[i] << " " << cnter << endl;
			}*/
			if (cnter % 2 != a[i]) {
				b[cnt] = i;
				c[i] = 1;
				cnt++;
			}
		}
	}
	cout << cnt << endl;
	if (cnt != 0) {
		for (int i = 0; i < cnt; i++) {
			cout << b[i] << " ";
		}
	}
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    int n;
    cin>>n;
    int a[n];
    int g=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        g=__gcd(g,a[i]);
    }
    int d[1010101]={};
    for(int i=2;i<1010101;i++){
        if(d[i])continue;
        for(int j=i;j<1010101;j+=i)d[j]=i;
    }
    map<int,int> mp;
    for(int i=0;i<n;i++){
        int t=a[i];
        set<int> st;
        while(t>1){
            st.insert(d[t]);
            t/=d[t];
        }
        for(auto x:st)mp[x]++;
    }
    bool flag=true;
    for(auto x:mp){
        if(x.second>1)flag=false;
    }
    if(flag)cout<<"pairwise coprime"<<endl;
    else if(g==1)cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;
}

Measured memory_bytes: 15040
n=int(input())
a=[int(input())for _ in range(n)]
if n==2:print(abs(a[0]-a[1]));exit()
f=[-1]
for i in range(1,n-1-(n%2==0)):
  if i%2:f.append(2)
  else:f.append(-2)
if n%2:f+=[-1]
else:f+=[-2,1]
b=[]
c=[]
for i in f:
  b.append(i)
  c.append(-i)
b.sort()
c.sort()
sb=sc=0
a.sort()
for i in range(n):
  sb+=a[i]*b[i]
  sc+=a[i]*c[i]
print(max(sb,sc))

Measured memory_bytes: 9912