akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        int[] NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int max = a[0];
        int difgcd = 0;
        for (int i = 1; i < a.Length; i++)
        {
            max = Math.Max(max,a[i]);
            difgcd = Gcd(Math.Abs(a[i] - a[i - 1]), difgcd);
        }
        string res = "POSSIBLE";
        if(difgcd == 0)
        {
            if (NK[1] == max) Console.WriteLine(res);
            else Console.WriteLine("IM" + res);
        }
        else if ((max >= NK[1] && (max - NK[1]) % difgcd == 0))
        {
            Console.WriteLine(res);
        }
        else
        {
            Console.WriteLine("IM" + res);
        }
    }
    public static int Gcd(int a, int b)
    {
        if (a < b)
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }
}

Measured memory_bytes: 19680
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {    
    ll n;
    cin >>n;
    ll d = pow(n,0.5);
    vector<ll>ans(1e4+100,0);
    for(int i=1;i<=d;i++){
        for(int j=1;j<=d;j++){
            for(int k=1;k<=d;k++){
                ll check = i*i+j*j+k*k+i*j+j*k+k*i;
                if(check<=1e4){
                    ans.at(check)++;
                }
            }
        }
    }
    for(int i=1;i<=n;i++){
        cout<<ans.at(i)<<endl;
    }
}
    



Measured memory_bytes: 4016
DBG = !true
n = gets.to_i
sum = 0.0
for i in 0...n
  xx,u = gets.split
  print "#{u}-" if DBG
  x = xx.to_f
  sum += (u == 'JPY' ? 1.0 : 380000.0) * x
end
puts "#{sum}"


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

int main()
{
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int ans=0;
	if(s[0]=='1') ans++;
	if(s[1]=='1') ans++;
	if(s[2]=='1') ans++;
	cout<<ans;
}

Measured memory_bytes: 256
import scala.io.StdIn._
import scala.collection.mutable.LinkedHashSet

object Main extends App {
  val s, t = readLine
  val sSet, tSet = new LinkedHashSet[Char]()
  sSet ++= s
  tSet ++= t
  val table = sSet.zipAll(tSet, ' ', ' ').toMap
  println(if (t == s.map(table)) "Yes" else "No")
}

Measured memory_bytes: 37996
h, w = map(int, input().split())

ans = 10**10

if w >= 3:
    if w % 3 == 0:
        ans = 0
    else:
        ans = min(ans, h)

if h >= 3:
    if h % 3 == 0:
        ans = 0
    else:
        ans = min(ans, w)

for i in range(1, h):
    s1 = i*w
    s2 = (h-i)*(w//2)
    s3 = (h-i)*(w - w//2)
    smax = max(max(s1, s2), s3)
    smin = min(min(s1, s2), s3)

    ans = min(ans, smax - smin)

for i in range(1, w):
    s1 = i*h
    s2 = (w-i)*(h//2)
    s3 = (w-i)*(h - h//2)
    smax = max(max(s1, s2), s3)
    smin = min(min(s1, s2), s3)

    ans = min(ans, smax - smin)

print(ans)

Measured memory_bytes: 3064
n = int(input())
i_l=[]
k_l=[]
for a in range(n):
    i = input().split()
    if i[1]=='BTC':
        i_l.append(float(i[0]))
    else:
        k_l.append(int(i[0]))

q=sum(k_l)
print(sum(i_l)*380000+q)


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

int main() {
  int64_t N, W, ans;
  cin >> N >> W;
  int64_t INF=1LL <<60;
  int64_t V=100000;
  
  vector<vector<int64_t>> dp(N+1, vector<int64_t>(100001, INF));
  vector<int64_t> weight(N);
  vector<int64_t> value(N);
  
  //重さおよび価値入力
  for (int i=0; i<N; i++) {
    cin >> weight.at(i) >> value.at(i);
  }
  
  dp.at(0).at(0)=0;
  
  //品物一つにつき一巡（i）。dp.at(i+1)行目にvalue.at(i)を足した価値→N行目にAns。
  for (int i=0; i<N; i++) {
    for (int v=0; v<=V; v++) {//1からでも回る。w=0列は重さ無し
      if (v<value.at(i)) {//i行目の価値候補が指定の価値:vより大きいと、i行目の品物は選ばれない。
        dp.at(i+1).at(v)=dp.at(i).at(v);//価値最大の中での最小重さ
      }
      else {/*i行目の価値候補がv以下ならば、1.選ばない 2.v-valeu.at(i)列目の価値（v-value.at(i)の重さ価値)
      +i行目の重さ　のうち最小の方*/
        dp.at(i+1).at(v)=min(dp.at(i).at(v), dp.at(i).at(v-value.at(i))+weight.at(i));
      }
    }
  }
  
  //重さW以下の最大価値探し
  for (int v=0; v<=V; v++) {
    if (dp.at(N).at(v)<=W) {
      ans=v;
    }
  }
    cout << ans << endl;
}

Measured memory_bytes: 80256
A=[input().split() for _ in range(3)]
N=int(input())
B=[input() for _ in range(N)]

for i in range(3):
  for j in range(3):
    if A[i][j] in B:
      A[i][j]=0

if A[0][0]==A[1][1]==A[2][2] or A[0][2]==A[1][1]==A[2][0]:
  print("Yes")
  exit()

for n in range(3):
  if A[0][n]==A[1][n]==A[2][n] or A[n][0]==A[n][1]==A[n][2]:
    print('Yes')
    exit()

print('No')

Measured memory_bytes: 9216
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
    static Scanner cin = new Scanner();
    static void Main() {
        string S = Console.ReadLine();
        string T = Console.ReadLine();

        var s_arr = new int[26];
        var t_arr = new int[26];
        foreach (var x in S) {
            s_arr[x - 'a']++;
        }
        foreach (var x in T) {
            t_arr[x - 'a']++;
        }

        Array.Sort(s_arr);
        Array.Sort(t_arr);
        bool flag = true;
        for (int i = 0; i < 26; i++) {
            if (s_arr[i] != t_arr[i]) flag = false;
        }
        Console.WriteLine(flag ? "Yes" : "No");
        Console.ReadLine();
    }
}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13208
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *left;
  struct node *right;
  struct node *parent;
  int key;
};
 
typedef struct node * Node;
 
Node root;
 
void Preorder(Node t){
  printf(" %d",t->key);
  if(t!=NULL){
    if(t->left!=NULL){
      Preorder(t->left);
    }
    if(t->right!=NULL){
      Preorder(t->right);
    }
  }
}
 
void Inorder(Node t){
   
  if(t!=NULL){
    if(t->left!=NULL){
      Inorder(t->left);
    }
    printf(" %d",t->key);
     
    if(t->right!=NULL){
      Inorder(t->right);
    }
  }
}
 
void Insert(int k){
  Node y=NULL;
  Node x=root;
  Node z;
 
  z=malloc(sizeof(struct node));
  z->key=k;
  z->left=NULL;
  z->right=NULL;
   
  while(x!=NULL){
    y=x;
 
    if(z->key<x->key){
      x=x->left;
    }
    else x=x->right;
  }
  z->parent=y;
   
  if(y==NULL){
    root=z;
  }
  else if(z->key<y->key){
    y->left=z;
  }
  else y->right=z;
}
 
Node Search(Node t,int k){
  if(t==NULL || k==t->key){
    return t;
  }
  if(k<t->key){
    return Search(t->left,k);
  }
  else return Search(t->right,k);
}
 
main(){
  int n, i, a;
  char str[10];
   
  scanf("%d",&n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s",str);
 
    if (str[0]=='i'){
      scanf("%d",&a);
      Insert(a);
    } 
    else if (str[0]=='p'){
      Inorder(root);
      printf("\n");
       
      Preorder(root);
      printf("\n");
    }
    else if(str[0]=='f'){
      scanf("%d",&a);
      Node s=Search(root,a);
      if (s!= NULL ) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}

Measured memory_bytes: 19364
#include<cstdio>
int n,ans;
char a[305][305];
bool book[305][305],flag;
bool check(int A,int B){
	for(int i=0;i<n;++i)
		for(int j=i+1;j<n;++j)
			if(a[i+A>=n?i+A-n:i+A][j+B>=n?j+B-n:j+B]!=a[j+A>=n?j+A-n:j+A][i+B>=n?i+B-n:i+B]) return 0;
	return 1;
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i) scanf("%s",a[i]);
	for(int A=0;A<n;++A)
		for(int B=0;B<n;++B){
			if(book[A][B]) continue;
			flag=0;
			if(check(A,B)) ans++,book[A][B]=1,flag=1;
			for(int l=1;l<=n;++l)
				if(A+l>=n||B+l>=n) break;
				else{
					book[A+l][B+l]=1;
					if(flag) ans++;
				}
		}
	printf("%d\n",ans);
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

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

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

template<uint32_t mod>
struct ModInt{
	uint32_t a;
	ModInt& s(uint32_t vv){
		a=vv<mod?vv:vv-mod;
		return *this;
	}

	ModInt(int64_t x=0){s(x%mod+mod);}

	ModInt& operator+=(const ModInt &x){return s(a+x.a);}
	ModInt& operator-=(const ModInt &x){return s(a+mod-x.a);}
	ModInt& operator*=(const ModInt &x){
		a=uint64_t(a)*x.a%mod;
		return *this;
	}
	ModInt& operator/=(const ModInt &x){
		*this*=x.inv();
		return *this;
	}

	ModInt operator+(const ModInt &x)const{return ModInt(*this)+=x;}
	ModInt operator-(const ModInt &x)const{return ModInt(*this)-=x;}
	ModInt operator*(const ModInt &x)const{return ModInt(*this)*=x;}
	ModInt operator/(const ModInt &x)const{return ModInt(*this)/=x;}
	bool operator==(const ModInt &x)const{return a==x.a;}
	bool operator!=(const ModInt &x)const{return a!=x.a;}
	bool operator<(const ModInt &x)const{return a<x.a;}

	ModInt operator-()const{return ModInt()-*this;}
	ModInt pow(int64_t n)const{
		ModInt res(1),x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}

	ModInt inv()const{return pow(mod-2);}
};

template<uint32_t mod>
istream& operator>>(istream& in,ModInt<mod>& a){
	return (in>>a.a);
}
template<uint32_t mod>
ostream& operator<<(ostream& out,const ModInt<mod>& a){
	return (out<<a.a);
}
using mint=ModInt<1000003>;

const int mod=1000003;
mint fact[mod];
void solve(){
	mint x,d;
	int n;
	cin>>x>>d>>n;

	if(d==0){
		cout<<x.pow(n)<<endl;
		return;
	}

	x/=d;
	mint ans=d.pow(n);

	int l=x.a;
	if(l==0||l+n-1>=mod){
		cout<<0<<endl;
		return;
	}
	ans*=fact[l+n-1];
	ans/=fact[l-1];
	cout<<ans<<endl;
}

signed main(){
	fact[0]=1;
	for(int i=1;i<mod;i++)fact[i]=fact[i-1]*i;
	int Q;
	cin>>Q;
	while(Q--)solve();
	return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <math.h>

using namespace std;

int main()
{
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if ((e - a) > k) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int l;
int main(){
  string s;cin>>s;
  l a=0,k=1<<(s.size()-1),t=k;
  for(l i=s.size()-1;i>=0;i--) a+=(s[i]-'0')*k,k=k*5+t/2;
  cout<<a<<endl;
}

Measured memory_bytes: 256
import scala.io.StdIn.readLine

object Main{
  def main(args : Array[String]): Unit ={
    val n : Int = readLine().toInt
    val Hs : Array[Int] = readLine().split(' ').map(_.toInt)
    val solve = new Solve(n, Hs)
    solve.doSolve()
  }
}

class Solve(private val n : Int, private val Hs : Array[Int]){
  def getMin(hd : Int, tl : Int): (Int, Int) = {
    var res : Int = Int.MaxValue
    var position : Int = -1
    for(i <- hd to tl if Hs(i) < res){
      res = Hs(i)
      position = i
    }
    (res, position)
  }
  def conq(hd : Int, tl : Int): Int ={
    if(hd > tl) 0
    else if(hd == tl) Hs(hd)
    else{
      val (here_min, position) = getMin(hd, tl)
      for(i <- hd to tl) Hs(i) -= here_min
      here_min + conq(hd, position - 1) + conq(position + 1, tl)
    }
  }
  def doSolve(): Unit ={
    println(conq(0, n - 1))
  }
}

Measured memory_bytes: 27228
program polygon
  implicit none
  integer              :: n
  integer, allocatable :: l(:)
  read(*,*) n
  allocate(l(n))
  read(*,*) l(:)
  if (sum(l)-2*maxval(l) .gt. 0) then
     write(*,'(a)') 'Yes'
  else
     write(*,'(a)') 'No'
  end if
end program polygon

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>

constexpr long MAX = 20000000000;

int main()
{
  int n;
  std::cin >> n;
  long maxv = -MAX;
  long minv = MAX;

  for (int i = 0; i < n; ++i)
  {
    long v;
    std::cin >> v;
    maxv = std::max(maxv, v - minv);
    minv = std::min(minv, v);
  }

  std::cout << maxv << std::endl;

  return 0;

}

Measured memory_bytes: 1164
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
template<typename T>
inline void read(T& s)
{
    s=0;int f=1;char c=getchar();
    while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0' && c<='9'){s=s*10+c-'0';c=getchar();}
    s*=f;
}
int n;
int s[200005];
multiset<int>ss;
int main()
{
	read(n);
	for(int i=0;i<n;i++)
		read(s[i]);
	sort(s,s+n);
	int ans=0;
	for(int i=n-1;i>=0;i--)
	{
		bool fg=0;
		for(int gg=30;gg>=0;gg--)
		{
			int ned=(1<<(gg+1))-s[i];
			if(ned<=0)	break;
			auto ga=ss.find(ned);
			if(ga!=ss.end())
			{
				ss.erase(ga);
				ans++;
				fg=1;
				break;
			}
		}
		if(fg==0)	ss.insert(s[i]);
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define ld long double

using namespace std;

const ld eps = 1e-9;

bool equal(ld a, ld b)
{
    return abs(a - b) < eps;
}

struct Point
{
    ld x;
    ld y;
};

struct Circle : Point
{
    Circle(ld x, ld y, ld r) : Point{x, y}, r(r) {}
    ld r;
};

ld dist(Point &p1, Point &p2)
{
    return sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
}

vector<Point> intersection(Circle c1, Circle c2)
{
    ld d = dist(c1, c2);
    if (d > c1.r + c2.r || d < abs(c1.r - c2.r))
        return {};
    ld a = (d * d + c1.r * c1.r - c2.r * c2.r) / (2 * d);
    ld h = sqrt(c1.r * c1.r - a * a);
    ld xm = c1.x + a * (c2.x - c1.x) / d;
    ld ym = c1.y + a * (c2.y - c1.y) / d;
    return {{xm - h / d * (c2.y - c1.y), ym + h / d * (c2.x - c1.x)},
            {xm + h / d * (c2.y - c1.y), ym - h / d * (c2.x - c1.x)}};
}

bool inCircle(Circle c, Point p)
{
    return dist(c, p) <= c.r + eps;
}

int n, k;
vector<Circle> cs;

int cooked(ld t)
{
    int mx1 = 0;
    for (int i = 0; i < cs.size() - 1; i++)
    {
        for (int j = i + 1; j < cs.size(); j++)
        {
            auto ps = intersection({cs[i].x, cs[i].y, cs[i].r * t}, {cs[j].x, cs[j].y, cs[j].r * t});
            for (auto &p : ps)
            {
                int count = 0;
                for (int ci = 0; ci < cs.size(); ci++)
                {
                    if (inCircle({cs[ci].x, cs[ci].y, cs[ci].r * t}, p))
                    {
                        count++;
                    }
                }
                mx1 = max(mx1, count);
            }
        }
    }
    int mx2 = 0;
    for (int i = 0; i < cs.size(); i++)
    {
        int count = 0;
        for (int j = 0; j < cs.size(); j++)
        {
            if (inCircle({cs[j].x, cs[j].y, cs[j].r * t}, cs[i]))
                count++;
        }
        mx2 = max(mx2, count);
    }
    return max(mx1, mx2);
}

ld bin_search(ld tl, ld th)
{
    ld mid = (tl + th) / 2;
    if (th - tl < 1e-6)
        return mid;
    if (cooked(mid) >= k)
        return bin_search(tl, mid);
    else
        return bin_search(mid, th);
}

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        ld x, y, c;
        cin >> x >> y >> c;
        Circle ci{x, y, 1 / c};
        cs.push_back(ci);
    }

    cout << fixed << bin_search(0, 1e6) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
  ll n;
  cin>>n;
  vector<ll> v;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
  }
  ll d[3] = {-1,-1,-1};
  ll ans = 1;
  rep(i,0,v.sz){
    ll a = v[i];
    ll c = 0;
    rep(j,0,3){
      if(a==d[j]+1)c++;
    }
    if(c>0){
      ans *= c;
      ans %= MOD;
      rep(j,0,3){
        if(a==d[j]+1){
          d[j] = a;
          break;
        }
      }
    }
    else{
      ans *= 0;
    }
  }
  cout << ans%MOD << endl;
  return 0;
}

Measured memory_bytes: 1400
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    x,y,z = map(int,input().split())
    print(z,x,y)
if __name__ =='__main__':
    main()  

Measured memory_bytes: 3316
n = int(input())
ans = []
num = 0

for i in range(1, n+1):
    if i % 3 == 0 and i % 5 == 0:
        ans.append('FizzBuzz')
    elif i % 3 == 0:
        ans.append('Fizz')
    elif i % 5 == 0:
        ans.append('Buzz')
    else:
        num += i
print(num)

Measured memory_bytes: 12628
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;

    if (a == b)
        cout << "Draw";
     else if ( a == 1)
            cout << "Alice";

    else if (b == 1)
        cout << "Bob";

    else if (a > b )
        cout << "Alice";

    else if (b > a )
        cout << "Bob";

    return 0;
}


Measured memory_bytes: 256
// Problem : A - Nickname
// Contest : AtCoder - Tokio Marine & Nichido Fire Insurance Programming Contest 2020
// URL : https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

string s;


int main() {
    ios::sync_with_stdio(false);cin.tie(0);
	cin>>s;
	 for(int i=0;i<3;++i){
	 	cout<<s[i];
	 }



    return 0;
}


Measured memory_bytes: 3652
using System;

namespace AGC014_B___Unplanned_Queries
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Solve() ? "YES" : "NO");
        }
        static bool Solve()
        {
            var NM = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NM[0]; var M = NM[1];
            var count = new int[N + 1];
            for (int i = 0; i < M; i++)
            {
                var ab = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                count[ab[0]]++;
                count[ab[1]]++;
            }
            for (int i = 1; i < N + 1; i++)
            {
                if (count[i] % 2 == 1) return false;
            }
            return true;
        }
    }
}


Measured memory_bytes: 17320
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int64_t N, A, B;

  cin >> N >> A >> B;
  
  if ( A == 0 ) {
    cout << 0 << endl;
  }
  
  else if (B == 0) {
    cout << N << endl;
  }
  
  else if ( N <= (A+B) ) {
    if ( N <= A ) {
      cout << N << endl;
    }
    
    else {
      cout << A << endl;
    }
  }
  
  else if (N%(A+B) == 0 ) {
    cout <<  ( N / (A+B) ) * A  << endl;
  }
  
  else if (N%(A+B) <= A) {
    cout << ( ( N / (A+B) ) * A ) + ( N % (A+B) )  << endl;
  }
  
  else {
    cout << ( ( N / (A+B) ) * A ) + A  << endl;
  }

 }


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		ContestScanner scan = new ContestScanner();

		int n = scan.nextInt();

		int[] R = new int[n];

		for(int i=0; i < n; i++)
		{
			R[i] = scan.nextInt();
		}

		(new Solve(n, R)).solve();
	}
}
class Solve {
	private final int n;
	private final int[] R;

	public Solve(final int n, final int[] R)
	{
		this.n = n;
		this.R = R;
	}

	public void solve()
	{
		int max = R[1] - R[0];
		int left = R[0];

		for(int i=1; i < n; i++)
		{
			max = Math.max(max, R[i] - left);
			left = Math.min(left, R[i]);
		}

		System.out.println(max);
	}
}
class ContestScanner {
	BufferedReader reader;
	String[] line;
	int index;
	public ContestScanner() {
		reader = new BufferedReader(new InputStreamReader(System.in));
	}

	public ContestScanner(String filename) throws FileNotFoundException {
		reader = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
	}

	public String nextToken() throws IOException {
		if(line == null || index >= line.length)
		{
			line = reader.readLine().trim().split(" ");
			index = 0;
		}

		return line[index++];
	}

	public String next() throws IOException {
		return nextToken();
	}

	public String readLine() throws IOException {
		line = null;
		index = 0;

		return reader.readLine();
	}

	public int nextInt() throws IOException, NumberFormatException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException, NumberFormatException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException, NumberFormatException {
		return Double.parseDouble(nextToken());
	}

	public int[] nextIntArray(int N) throws IOException, NumberFormatException {
		int[] result = new int[N];

		for(int i=0; i < N; i++) result[i] = nextInt();

		return result;
	}

	public long[] nextLongArray(int N) throws IOException, NumberFormatException {
		long[] result = new long[N];

		for(int i=0; i < N; i++) result[i] = nextLong();

		return result;
	}

	public double[] nexDoubleArray(int N) throws IOException, NumberFormatException {
		double[] result = new double[N];

		for(int i=0; i < N; i++) result[i] = nextDouble();

		return result;
	}
}

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

int main(int argc,char* argv[]){
    int n,m;
    int ans=0;
    scanf("%d %d",&n,&m);
    ans=(m*1900+(n-m)*100)*pow(2,m);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int first = stoi(s.substr(0,2));
    int second =  stoi(s.substr(2,2));
    if (first > 12 || first == 0) {
        if (second > 12 || second == 0) {
            cout << "NA" << endl;
        }
        else {
            cout << "YYMM" << endl;
        }
    }
    else {
        if (second > 12 || second == 0) {
            cout << "MMYY" << endl;
        }
        else {
            cout << "AMBIGUOUS" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#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.at(i);
  }
  
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  long long int ans = 0;
  for(int i=1;i<n;i++){
    ans += a.at(i/2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4032
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <cstdlib>

int main()
{
	std::string buf;
	while (std::getline(std::cin, buf)) {
		std::vector<std::string> vec;
		
		int offset = std::string::size_type(0);
		while (true) {
			int sp_pos = buf.find(" ", offset);
			if (sp_pos == std::string::npos) {
				//std::cout << "npos" << std::endl;
				vec.push_back( buf.substr(offset) );
				break;
			} else {
				//std::cout << "not npos" << std::endl;
				vec.push_back( buf.substr(offset, sp_pos - offset) );
				offset = sp_pos + std::string::size_type(1);
			}
		}
		
		//std::cout << "vec : ";
		//for (std::vector<std::string>::iterator it = vec.begin(); it != vec.end(); ++it) std::cout << (*it) << " ";
		//std::cout << std::endl;
		
		std::stack<std::string> st;
		
		for ( std::vector<std::string>::iterator it = vec.begin(); it != vec.end(); ++it) {
			std::string item = (*it);
			if (item.length() == 1) { // item is either an operator or a number
				if (item[0] == '+') {
					double x = std::stod(st.top()); st.pop();
					double y = std::stod(st.top()); st.pop();
					st.push( std::to_string(y+x) );
				} else if (item[0] == '-') {
					double x = std::stod(st.top()); st.pop();
					double y = std::stod(st.top()); st.pop();
					st.push( std::to_string(y-x) );
				} else if (item[0] == '*') {
					double x = std::stod(st.top()); st.pop();
					double y = std::stod(st.top()); st.pop();
					st.push( std::to_string(y*x) );
				} else if (item[0] == '/') {
					double x = std::stod(st.top()); st.pop();
					double y = std::stod(st.top()); st.pop();
					st.push( std::to_string(y/x) );
				} else { // number
					st.push(item);
				}
			} else { // item is a number
				st.push(item);
			}
		}
		
		std::cout << std::fixed << std::stod( st.top() ) << std::endl;
	}
	
	return 0;
}
			



Measured memory_bytes: 3132
s=input()
a=[]
for i in range(len(s)):
    if s[i]=="B":
        if a==[]:
            continue
        else:
            del a[-1]
    elif s[i]=="0":
        a.append("0")
    elif s[i]=="1":
        a.append("1")
print("".join(a))

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

int main() {
  string s,t;
  cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
//
//  main.cpp
//  Digits_Sum
//
//  Created by Uttam Datta on 03/06/19.
//  Copyright © 2019 Uttam Datta. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int N;

int sum(pair<int, int> k){
    int res = 0;
    while(k.first > 0){
        res += k.first%10;
        k.first /= 10;
    }
    while(k.second > 0){
        res += k.second%10;
        k.second /= 10;

    }
    return res;
}

int ans(){
    int i = 1, j = N-1;
    if(N/10 == 0){
        return N;
    }
    vector <pair<int,int> > A;
    while(j - i != 1 && j != i){
        A.push_back(make_pair(i, j));
        i++;
        j--;
    }
    vector <int> ans;
    for(int k = 0; k < A.size(); k++){
        ans.push_back(sum(A[k]));
    }
    sort(ans.begin(), ans.end());
    return ans[0];
}

int main(){
    cin >> N;
    cout << ans() << endl;
}


Measured memory_bytes: 1144
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {

    while (1) {
        int n;
        scan(n);

        if (!n) return;

        int ans = 10^^7;

        for (int z; z^^3 <= n; z++) {
            for (int y; y^^2 <= n - z^^3; y++) {
                int x = n - z^^3 - y^^2;
                ans = min(ans, x + y + z);
            }
        }

        writeln(ans);
    }
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 2360
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test=""):
    try:
        n = int(input())

        if n == 1:
            print(0)
        else:
            print(1)


    except IndexError as err:
        print("インデックスエラー:", err.args[0])


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """1"""
        output = """0"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """0"""
        output = """1"""
        self.assertIO(test_input, output)

    # 自作テストパターン
    def test_original(self):
        pass


# youk_debug_library
def list_to_tsv(target: [], limit_row: int = 0, limit_column: int = 0) -> str:
    # 行列を制限の範囲内に絞り込む
    if limit_row is not 0:
        target = target[:limit_row]
    if limit_column is not 0:
        target = [i[:limit_column] for i in target]

    # 行番号、列番号を追加
    target = [[cnt] + i for cnt, i in enumerate(target)]  # 行番号
    target.insert(0, [i for i in range(len(target[0]))])  # 列番号
    # tsv形式で出力
    result = ""
    for a in target:
        result += '\t'.join(map(str, a)) + '\r\n'
    return result


# 実装orテストの呼び出し処理
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main(verbosity=2)


Measured memory_bytes: 70732
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define pb push_back
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; }

int gcd(int X, int Y) {
	if (X < Y) gcd(Y, X);
	int r;
    if(Y == 0) return X;
	while (r = X % Y) {
		X = Y;
		Y = r;
	}
	return Y;
}

int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N,X;
    cin >> N >> X;
    int x[N];
    REP(i,N) cin >> x[i];
    int ans = abs(x[0] - X);

    REP(i,N){
        ans = gcd(abs(x[i]-X),ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = Console.ReadLine().Split(' ');
            var N = int.Parse((K[0]));
            var M = int.Parse((K[1]));

            List<int> lresult = new List<int>();
            List<int> rresult = new List<int>();

            for (int i = 0; i < M; i++)
            {
                var tmp = Console.ReadLine().Split(' ');
                lresult.Add(int.Parse((tmp[0])));
                rresult.Add(int.Parse((tmp[1])));
            }

            var ret = rresult.Min() - lresult.Max() + 1;
            Console.WriteLine(ret<0 ? 0 : ret);

        }

    }

    //var N = int.Parse(Console.ReadLine());
    //var S = Console.ReadLine();
    //var K = Console.ReadLine().Split(' ');
}


Measured memory_bytes: 19276
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln endl
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define dbg2(x,y) cerr<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it<<ln;} cerr<<endl
#define dbgstlp32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cerr<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inp freopen("input.txt", "r", stdin)
#define outp freopen("output.txt", "w", stdout)
#define dbgm(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
typedef long long int  ll;
typedef long double  ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
typedef vector<bool> vb;
const int LIM = 2e5+5, MOD = 1e9+7, EPS = 1e-9;
int t,n,m,k,x,y;

	v32 adj[100001];
	vb visited;
 	v32 ans;

void dfs(int v){
	visited[v] = true;
	forstl(u,adj[v]){
		if(!visited[u]){
			dfs(u);
		}
	}
	ans.pb(v);
}

void t_sort(){
	visited.assign(n+1,0);
	ans.clear();
	for(int i=1;i<=n;i++){
		
		if(!visited[i]){
			dfs(i);
		//	cout<<i<<" ";
		} 
	}
	reverse(ans.begin(),ans.end());
}

int main(){
	fastio;
	cin>>n;
	cin>>m;
	forn(i,m){
		int x,y;
		cin>>x>>y;
		adj[x].pb(y);
	}
	t_sort();
	ll dp[n+1] = {0};
//	forstl(r,ans) cout<<r<<" ";

	forstl(i,ans){
	//	cout<<i<<" ";
		forstl(r,adj[i]){
			dp[r] = max(dp[r],1+dp[i]);
		}
	}
	ll an=0;
//	cout<<ln;
	forn(i,n+1) an = max(an,dp[i]);
	cout<<an<<ln;
	return 0;
}

Measured memory_bytes: 8444
mod = 1000000007

# aのp乗を求めるアルゴリズム
# p=62のとき、pの変化は、62->31->30->15->14->7->6->3->2->1->0
# と、半分半分になっていく
# よって、計算量はO(logp)になる
def modpow(a, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        # pが偶数のとき
        halfP = p // 2
        half = modpow(a, halfP)

        # a^(p/2) をhalfとして、half*halfを計算
        return half * half % mod
    else:
        # pが奇数のときは、
        # pを偶数にするために1減らす
        return a * modpow(a, p - 1) % mod


# (10*9*8) / (3*2*1)
# 10*9*8 -> ansMul
# 3*2*1 -> ansDiv
def calcComb(a, b):
    if b > a - b:
        return calcComb(a, a - b)
    ansMul = 1
    ansDiv = 1
    for i in range(b):
        ansMul *= (a - i)
        ansDiv *= (i + 1)
        ansMul %= mod
        ansDiv %= mod
    # ansMul / ansDivをやりたい
    # ansDivの逆元を使って求める
    ans = ansMul * modpow(ansDiv, mod - 2) % mod
    return ans


n, m = map(int, input().split())
MNkori = m
ans = 1
i = 2
while i * i <= MNkori:
    cnt = 0
    while MNkori % i == 0:
        cnt += 1
        MNkori //= i
    # cntが2^Xとか3^XのXの部分
    ans *= calcComb(n + cnt - 1, n - 1) # N-1はcntと同じ
    ans %= mod
    i += 1
if MNkori != 1:
    # 最後に素数が残ってる分を処理する
    ans *= calcComb(n, n - 1)  # N-1はcntと同じ
    ans %= mod
print(ans)

Measured memory_bytes: 3064
#include "stdio.h"
#include "stdlib.h"
#include "iostream"
#include "math.h"
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include "algorithm"


using namespace std;
#define fori0(G) for(int i=0;i<G;i++)
#define fori1(G) for(int i=1;i<=G;i++)
#define forj0(G) for(int j=0;j<G;j++)
#define forj1(G) for(int j=1;j<=G;j++)
#define fork0(G) for(int k=0;k<G;k++)
#define fork1(G) for(int k=1;k<=G;k++)
int dx[] = { -1,0,1,0 ,0 }, dy[] = { 0,1,0,-1,0 };
#define nxnycon (0<=nx&&nx<h&&0<=ny&&ny<w) 
#define lo long long int

int n,a[200001],m,h,data_cnt,b;
lo t = 0;

int int_sort(const void * a, const void * b) {
	/* 引数はvoid*型と規定されているのでint型にcastする */
	if (*(int *)a < *(int *)b) {
		return -1;
	}
	else
		if (*(int *)a == *(int *)b) {
			return 0;
		}
	return 1;
}


int main() {
	cin >> n;
	fori0(n) { cin >> h;
		a[i] = h-i-1 ;
	}
	data_cnt = sizeof(a) / sizeof(a[0]);
	qsort((void *)a, n, sizeof(a[0]), int_sort);
	b= a[(n - 1) / 2];
	fori0(n) {
		//cout << a[i];
		t += abs(a[i] - b);
	}
	 cout<<t;
	
	//system("pause");
	return 0;

}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
int up(ll a){
  if(a<=9){return a;}
  else{
    a/=10;
    return up(a);
  }
}
int main(){
  ll N,ans=0;
  cin>>N;
  vector<vector<int>> vec(9,vector<int>(10));
  for(ll i=1;i<=N;i++){
    vec.at((int)up(i)-1).at((int)i%10)++;
  }
    for(ll i=0;i<9;i++){
    for(ll j=i+1;j<10;j++){
      if(j==0){continue;}
      if(j==i+1){ans+=vec.at(i).at(j)*vec.at(i).at(j);}
      else{ans+=2*vec.at(i).at(j)*vec.at(j-1).at(i+1);}
      //cout<<ans<<" "<<i+1<<" "<<j<<endl;
    }
  }
  cout<<ans<<endl;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ if(a>b) a=b;}
ll INF = 1LL<<55;

int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int h, n;

	cin >>h >>n;
	vector<pii> a(n);
	rep(i, n) cin >>a[i].first >>a[i].second;
	//sort(all(a));
	
	
	VL dp(h+5, INF);
	dp[0] =0;
	rep(i, n) rep(j, h+5) {
		int w = j + a[i].first;
		if(w > h) w =h;
			dp[w] = min(dp[w], dp[j]+a[i].second);
		
	}
	
	cout << dp[h] <<"\n";
	//for(auto x :dp) cerr<<x<<" "; cerr<<"\n";
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong() - 1;
    long b = sc.nextLong();
    int c = sc.nextInt();
    int d = sc.nextInt();
    long x = a - (a/c) - (a/d) +(a / lcm(c,d));
    long y = b - (b/c) - (b/d) + (b/lcm(c,d));
    System.out.println(y - x);
  }
  public static long lcm(int a, int b){
    return (long)a * b / gcd(a , b);
  }
  public static int gcd(int a, int b){
   if(a % b == 0){
     return b;
   }
    return gcd(b , a % b);
  }
}

Measured memory_bytes: 22228
lines=readlines(open("/dev/fd/0"))
function input()
  shift!(lines)
end
int(s::SubString{String})=parse(Int,s)
int(s::Array{SubString{String},1})=map(int,s)
function main()
  x,a=input() |> split |> int
  println(ifelse(x<a,0,10))
end
main()

Measured memory_bytes: 112024
#include <bits/stdc++.h>
using namespace std;
#define arep(i, x, n) for (int i = int(x); i < (int)(n); i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9 + 7
using ll = long long;

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

    vector<ll> a(n);
    vector<bool> history(n);
    rep(i, n) {
        cin >> a[i];
        history[i] = false;
    }

    ll curpt = 1;
    ll cnt = 0;

    // vector<ll> history;
    // history.push_back(curpt);
    bool isDone = false;

    while (isDone == false) {
        cnt++;
        curpt = a[curpt - 1];

        if (curpt == 2) {
            isDone = true;
        } else {
            if(history[curpt - 1]){
                isDone = true;
                cnt = -1;
            }
        }

        history[curpt - 1] = true;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 4012
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define repr2(i,s,n) for (int i = (n-1); i>=(int)(s);i--)
#define repr3(i,n) for(int i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Grid = vector<vector<int>>;
const ll INF = 10011032323450010;
const ld PI = 3.14159265358979323846;



int main() {
    int A,B,K;
    cin>>A>>B>>K;
    rep(i,K){
        if(i%2==0){
            if(A%2==1){
                A--;
            }
            A/=2;
            B+=A;
        }
        else{
            if(B%2==1){
                B--;
            }
            B/=2;
            A+=B;

        }
    }
    cout<<A<<" "<<B<<endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
    
int main(){
    int n=0, even=0, odd=0;
    cin >> n;
    for(int i=0; i<n; i++){
        int x;
        cin >> x;
        if(x%2==0)
        {
            even++;
        }
        else
        {
            odd++;
        }
    }
    if(odd%2==0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
from itertools import groupby

s = input()
k = int(input())
a, b = [], []
count1, count2 = 0, 0

for key, group in groupby(s):
  a.append(list(group))

if len(a) == 1:
  if len(s)%2==1 and k%2==1:
    print(len(s)//2 + len(s)*(k-1)//2 )
  else:
    print(len(s)*k//2)
else:
  for key, group in groupby(s*2):
    b.append(list(group))  

  for i in a:
    count1 += len(i) // 2

  for i in b:
    count2 += len(i) // 2

  c = count2 - count1

  print(count1 + c*(k-1))

Measured memory_bytes: 3064
H, W = map(int, input().split())
G = [list(input()) for _ in range(H)]

ans = 'Yes'
for i in range(H):
    for j in range(W):
        if G[i][j] == '#':
            if i == 0:
                if j == 0:
                    if G[i+1][j] == '#' or G[i][j+1] == '#':
                        continue
                    else:
                        ans = 'No'
                        break
                elif j == W-1:
                    if G[i+1][j] == '#' or G[i][j-1] == '#':
                        continue
                    else:
                        ans = 'No'
                        break
                else:
                    if G[i+1][j] == '#' or G[i-1][j] == '#' or G[i][j-1] == '#' or G[i][j+1] == '#':
                        continue
                    else:
                        ans = 'No'
                        break
            elif i == H-1:
                if j == 0:
                    if G[i-1][j] == '#' or G[i][j+1] == '#':
                        continue
                    else:
                        ans = 'No'
                        break
                elif j == W-1:
                    if G[i][j-1] == '#' or G[i-1][j]:
                        continue
                    else:
                        ans = 'No'
                        break
                else:
                    if G[i-1][j] == '#' or G[i][j-1] == '#' or G[i][j+1] == '#':
                        continue
                    else:
                        ans = 'No'
                        break
            else:
                if j == 0:
                    if G[i+1][j] == '#' or G[i][j+1] == '#' or G[i-1][j]:
                                continue
                    else:
                        ans = 'No'
                        break
                elif j == W-1:
                    if G[i+1][j] == '#' or G[i][j-1] == '#' or G[i-1][j]:
                        continue
                    else:
                        ans = 'No'
                        break
                else:
                    if G[i+1][j] == '#' or G[i-1][j] == '#' or G[i][j-1] == '#' or G[i][j+1] == '#':
                        continue
                    else:
                        ans = 'No'
                        break
    if ans == 'No':
        break

print(ans)

Measured memory_bytes: 3192
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
	long long int A;
	string B;
 
	cin >> A >> B;
 
	long long int IntB;
	long long int DecB;

	IntB = B[0] - '0';
	DecB = (B[2] - '0')*10 + (B[3] - '0');

	long long int res;

	res = IntB*A + DecB*A/100;

	cout << res;
		
	return 0;
}

Measured memory_bytes: 3624
#!/usr/bin/env python3
(n, ), *q = [[*map(int, i.split())] for i in open(0)]
ans = [0] * n
for i, p in enumerate(q):
    c, s, f = p
    for j in range(i):
        ans[j] = c + max(s, -(-ans[j] // f) * f)
    ans[i] = c + s
print(*ans, sep="\n")


Measured memory_bytes: 9004