akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

int main (void){

    int n;
    int sum = 100;
    scanf("%d", &n);

    for(int a = 1; a <= n-1; a++){
        int b = n - a;

        int asum = 0;
        int bsum = 0;

        int tmp = a;
        while( tmp != 0 ){
             asum += tmp%10;
             tmp /= 10;       
        }

        tmp = b;
        while( tmp != 0 ){
             bsum += tmp%10;
             tmp /= 10;
        }

        if( sum > asum + bsum )
          sum = asum + bsum;

    }

    printf("%d", sum);

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
int comp(const void *a,const void *b){
  return *(int*)a - *(int*)b;
}

int main(void){
  int n,v[50]={0};
  double ave ;
  
  scanf("%d",&n);
  for(int i = 0;i<n;i++){
    scanf("%d",&v[i]);
  }
  qsort(v,n,sizeof(int),comp);
  
  ave = v[0];
  for(int i = 1;i<n;i++){
    ave = (ave + v[i]) / 2.0;
  }
  printf("%lf\n",ave);
}

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

int main() 
{
    priority_queue<int> PQ;
    int key;
    char order[10];
    while (true) 
    {
        cin >> order;
        if (order[0] == 'e' && order[1] == 'n') break;
        if (order[0] == 'i') 
        {
            cin >> key;
            PQ.push(key);
        }
        else 
        {
            cout << PQ.top() << endl;
            PQ.pop();
        }
    }
}


Measured memory_bytes: 7000
n=int(input())
#a,b=map(int,input().split())
al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

dic={}

for a in al:
    dic[a]=dic.get(a,0)+1
total=0
for k in dic.keys():
    total+=dic[k]*(dic[k]-1)//2

for k in range(n):
    count=dic[al[k]]
    ans=total-count*(count-1)//2+(count-1)*(count-2)//2
    print(ans)


Measured memory_bytes: 26268
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let H: i32 = read();
    let W: i32 = read();
    let h: i32 = read();
    let w: i32 = read();
    println!("{}", H * W - h * W - w * H + h * w);
}


#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>

int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	bool f = 0;
	for (int i = 1;i <= 100;i++)
	{
		if (i * a % b == c) f = 1;
	}
	if (f) puts("YES");
	else puts("NO");
	return 0;
}

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

const int MOD = 1000000007;
struct modint {
  long long val;
  modint(long long val=0) : val((val % MOD + MOD) % MOD){}
  modint operator-() const { return modint(-val); }
  modint& operator+=(const modint a) { if ((val += a.val)     >= MOD) val -= MOD; return *this; }
  modint& operator-=(const modint a) { if ((val += MOD-a.val) >= MOD) val -= MOD; return *this; }
  modint& operator*=(const modint a) { (val *= a.val) %= MOD; return *this; }
  modint operator+(const modint a) const { return (modint)*this += a; }
  modint operator-(const modint a) const { return (modint)*this -= a; }
  modint operator*(const modint a) const { return (modint)*this *= a; }
  modint pow(long long n) const { modint r(1), m(val); while (n > 0) { if (n & 1) {r *= m;} m *= m; n >>= 1; } return r; }
  modint inv() const { return pow(MOD-2); }
  modint& operator/=(const modint a) { return (*this) *= a.inv(); }
  modint operator/(const modint a) const { return (modint)*this /= a; }
  bool operator==(const modint &p) const { return val == p.val; }
  bool operator!=(const modint &p) const { return val != p.val; }
  friend ostream &operator<<(ostream &os, const modint &p) { return os << p.val; }
  friend istream &operator>>(istream &is, modint &a) { long long t; is >> t; a = modint(t); return (is); }
};

int N, K;
modint g[100000];
modint f[100000];

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

  for(int i=1; i<=K; i++) g[i] = modint(K/i).pow(N);
  for(int i=K; i>=1; i--) {
    f[i] = g[i];
    for(int j=2; i*j<=K; j++) f[i] -= f[i*j];
  }

  modint ans = 0;
  for(int i=1; i<=K; i++) ans += modint(i) * f[i];

  cout << ans << endl;
}


Measured memory_bytes: 5212
#include<iostream>
#include<cstdio>
using namespace std;
long long p[100005],N,Q,A;
int main() {
    cin>>N>>Q;
    for (int i=0;i<N;i++)scanf("%lld",&p[i]);
    for (int i=0;i<Q;i++){
        long long sum=0,R=0;cin>>A;
        long long cnt=0;
        for(int i=0;i<N;i++){
            while (R<N) {
                if (sum+p[R]>A)break;
                sum+=p[R];R++;
            }
            if(sum>0){sum-=p[i];}
            cnt+=R-i;
            if(R<i+1)R=i+1;
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3896
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(n);
// string p=s.substr(0,len);
// string q=s.insert(0,str);
// sort(arr, arr+n, greater<int>());
// cout<<fixed<<setprecision(9)<<pi<<endl
// const  double pi = acos(-1.0);
// sort(v.rbegin(),v.rend());
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


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

	int a[n];

	for(int i=0;i<n;i++) cin>>a[i];

	sort(a,a+n);
		
	// sum of 2 sides must ber greater than third side.
	// since the array is sorted the sum of 2 minimum sides must be larger than the third side.

	int cnt=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			for(int k=j+1;k<n;k++)
			{
				if(a[i]+a[j]>a[k] && a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k])
				{
					cnt++;
				}
			}
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 3656
k = gets.chomp.to_i

if k % 5 == 0 || k % 2 == 0
  puts '-1'
else
  m = k % 7 == 0 ? k / 7 * 9 : k * 9

  s = 0
  1.upto(m - 1) do |i|
    s = (s * 10 + 7) % k
    if s == 0
      puts i
      break
    end
  end
end


Measured memory_bytes: 14380
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
inline ll lin() { ll x; scanf("%lld",&x); return x;}
inline char chin() { char x; scanf("%c",&x); return x;}
inline string stin() { string x; cin >> x; return x;}
inline double din() { double x; scanf("%lf",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  ll a;
  double b;
  cin >> a >> b;
  int ib = (int)(b*100+0.5);
  cout << a*ib/100 << endl;
  return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
template <class T, class C> void chmax(T &a, C b) { a > b ?: a = b; }
template <class T, class C> void chmin(T &a, C b) { a < b ?: a = b; }

int main() {
  int N;
  cin >> N;
  set<string> A;
  for (int i = 0; i < N; ++i) {
    string b;
    cin >> b;
    A.insert(b);
  }
  cout << A.size() << endl;
  return 0;
}


Measured memory_bytes: 19120
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    ABC042DIrohaandaGrid solver = new ABC042DIrohaandaGrid();
    solver.solve(1, in, out);
    out.close();
  }

  static class ABC042DIrohaandaGrid {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int h = in.nextInt();
      int w = in.nextInt();
      int a = in.nextInt();
      int b = in.nextInt();
      ModComb mc = new ModComb(200005);
      mc.makeFac();
      ModInt res = new ModInt(0);
      for (int i = 0; i < h - a; i++) {
        res = res.add(mc.combFac(b - 1 + i, i).mul(mc.combFac(w - b - 1 + h - 1 - i, h - 1 - i)));
      }
      out.println(res.toString());
    }

  }

  static class ModInt {

    private static int MOD = 1000000007;
    long x;

    ModInt(long l) {
      this.x = l % MOD;
    }

    ModInt add(ModInt mi) {
      return new ModInt(this.x + mi.x);
    }

    ModInt mul(long i) {
      return new ModInt(this.x * i);
    }

    ModInt mul(ModInt mi) {
      return new ModInt(this.x * mi.x);
    }

    ModInt pow(int p) {
      ModInt res = new ModInt(1);
      ModInt tmp = this;
      while (p > 0) {
        if ((p & 1) == 1) {
          res = res.mul(tmp);
        }
        tmp = tmp.mul(tmp);
        p /= 2;
      }
      return res;
    }

    ModInt inv() {
      return this.pow(MOD - 2);
    }

    public String toString() {
      return Integer.toString((int) this.x);
    }

  }

  static class ModComb {

    int size;
    ModInt[] fac;
    ModInt[] inv;

    ModComb(int n) {
      size = n;
      fac = new ModInt[n + 1];
      inv = new ModInt[n + 1];
    }

    void makeFac() {
      for (int i = 0; i <= size; i++) {
        if (i == 0) {
          fac[i] = new ModInt(1);
        } else {
          fac[i] = fac[i - 1].mul(i);
        }
        inv[i] = fac[i].inv();
      }


    }

    ModInt combFac(int n, int k) {
      if (n < k) {
        return new ModInt(0);
      }
      return fac[n].mul(inv[k]).mul(inv[n - k]);
    }

  }
}



Measured memory_bytes: 102100
// use std::ops::{Index, IndexMut};
// use std::cmp::{Ordering, min, max};
// use std::collections::{BinaryHeap, BTreeMap};
// use std::collections::btree_map::Entry::{Occupied, Vacant};
// use std::clone::Clone;

fn getline() -> String{
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*) 
        }
    };
}

macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

macro_rules! mvec {
    ($v: expr, $s: expr) => {
        vec![$v; $s]
    };
    ($v: expr, $s: expr, $($t: expr),*) => {
        vec![mvec!($v, $($t),*); $s]
    };
}

macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator, 
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display {
    for (i,e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}

fn main() {
    let n = readl!(usize);
    let a = readlvec!(i32);
    let c4 = a.iter().cloned().filter(|x| x%4 == 0).count();
    let c1 = a.iter().cloned().filter(|x| x%2 == 1).count();
    let c2 = n-c1-c4;
    if c4 >= c1 {
        println!("Yes");
    } else if c4+1 == c1 && c2 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}



Measured memory_bytes: 4352
class UnionFindVerSize():
    def __init__(self, N):
        """ N個のノードのUnion-Find木を作成する """
        # 親の番号を格納する。自分が親だった場合は、自分の番号になり、それがそのグループの番号になる
        self._parent = [n for n in range(0, N)]
        # グループのサイズ（個数）
        self._size = [1] * N

    def find_root(self, x):
        """ xの木の根(xがどのグループか)を求める """
        if self._parent[x] == x: return x
        self._parent[x] = self.find_root(self._parent[x]) # 縮約
        return self._parent[x]

    def unite(self, x, y):
        """ xとyの属するグループを併合する """
        gx = self.find_root(x)
        gy = self.find_root(y)
        if gx == gy: return

        # 小さい方を大きい方に併合させる（木の偏りが減るので）
        if self._size[gx] < self._size[gy]:
            self._parent[gx] = gy
            self._size[gy] += self._size[gx]
        else:
            self._parent[gy] = gx
            self._size[gx] += self._size[gy]

    def get_size(self, x):
        """ xが属するグループのサイズ（個数）を返す """
        return self._size[self.find_root(x)]

    def is_same_group(self, x, y):
        """ xとyが同じ集合に属するか否か """
        return self.find_root(x) == self.find_root(y)

    def calc_group_num(self):
        """ グループ数を計算して返す """
        N = len(self._parent)
        ans = 0
        for i in range(N):
            if self.find_root(i) == i:
                ans += 1
        return ans

N,M=map(int,input().split())
p=list(map(int,input().split()))
x=[0 for i in range(0,M)]
y=[0 for i in range(0,M)]
for i in range(0,M):
    x[i],y[i]=map(int,input().split())

uf=UnionFindVerSize(N)
for i in range(0,M):
    uf.unite(x[i]-1,y[i]-1)

root=set([])
for i in range(0,N):
    root.add(uf.find_root(i))
root=list(root)
index=[-1 for i in range(0,N)]
for i in range(0,len(root)):
    index[root[i]]=i

tree1=[[] for i in range(len(root))]
tree2=[[] for i in range(len(root))]
for i in range(0,N):
    tree1[index[uf.find_root(i)]].append(i)
    tree2[index[uf.find_root(i)]].append(p[i]-1)

ans=0
for i in range(len(root)):
    set1=set(tree1[i])
    set2=set(tree2[i])
    ans+=len(set1 & set2)

print(ans)

Measured memory_bytes: 114668
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var ans = 0;
            var index = 0;
            var max = a.Max();
            var through = false;
            for (var j = 1; j <= max || index < N; j++)
            {
                var bef = index;
                for (var i = index; i < N; i++)
                {
                    if (a[i] != j) ans++;
                    else
                    {
                        index = i + 1;
                        break;
                    }

                    if (i == N - 1) through = true;
                }

                if (index == 0 && bef == index)
                {
                    Console.WriteLine(-1);
                    return;
                }

                if (through) break;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 35676
#include<stdio.h>
int a[200][200]={};//(0,0)=100,100
int n,t;
void dfs(int x,int y,int i){
  a[x][y]=i;
  i++;
  if(t>=i-1){
    if(a[x-1][y-1]==0 || a[x-1][y-1]>i) dfs(x-1,y-1,i);
    if(a[x-1][y]==0 || a[x-1][y]>i) dfs(x-1,y,i);
    if(a[x][y-1]==0 || a[x][y-1]>i) dfs(x,y-1,i);
    if(a[x+1][y+1]==0 || a[x+1][y+1]>i) dfs(x+1,y+1,i);
    if(a[x+1][y]==0 || a[x+1][y]>i) dfs(x+1,y,i);
    if(a[x][y+1]==0 || a[x][y+1]>i) dfs(x,y+1,i);
  }
  else return;
}


int main(){
  int i,j,c,co;
  int x,y,cx,cy;
  while(1){
    //syoki
    for(i=0;i<200;i++){
      for(j=0;j<200;j++){
	a[i][j]=0;
      }
    }
    co=0;
    scanf("%d%d",&t,&n);
    if(t==0&&n==0)break;
    //printf("point 1\n");///
    for(i=0;i<n;i++){
      scanf("%d%d",&x,&y);
      // printf("\n");
      a[x+100][y+100]=-1;
    }
    //printf("point 2\n");///
    scanf("%d%d",&cx,&cy);
    cx+=100;
    cy+=100;
    dfs(cx,cy,1);
    //printf("point 3\n");///
    for(i=0;i<200;i++){
      for(j=0;j<200;j++){
	if(a[i][j]>0)co++;
      }
    }
    printf("%d\n",co);    
  }
  return 0;
}

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

int main()
{
    deque<int> d;
    int t, s, x, q;
    cin >> t;
    while (t--)
    {
        cin >> q;
        if (q == 0)
        {
            cin >> s >> x;
            if (s == 0)
            {
                d.push_front(x);
            }
            else if (s == 1)
            {
                d.push_back(x);
            }
        }
        if (q == 1)
        {
            cin >> s;
            cout << d[s] << endl;
        }
        if (q == 2)
        {
            cin >> s;
            if (s == 0)
            {
                d.pop_front();
            }
            else if (s == 1)
            {
                d.pop_back();
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4636
#include <stdio.h>

int main(void) {
	int i, a, b, k;
	
	scanf("%d %d %d", &a, &b, &k);
	
	for (i = a; i <= b; i++)
		if (i < a+k || i > b-k)
			printf("%d\n", i);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N, K;
    cin >> N >> K;
    ll a=0, b=0, c=0;
    ll count=0;

    for(ll i=1;i<=N; i++)
    {
        if(i % K == 0) a++;
        if(i % K == K / 2 && K % 2 == 0) b++;
    }
    cout << a*a*a + b*b*b << endl;

   /*
   ll max_multi = 2 * N / K;
    for(size_t i=1;i<=max_multi; i++)
    {
        ll elem = i * K;
        a = elem / 2;
        if(elem != 2 * a) continue;
        for(size_t j=1;j<=i; j++)
        {
            b = j*K - a;
            if(b <= 0) continue;
            for(size_t k=1;k<=j; k++)
            {
                c = k*K - b;
                if(c <= 0 || b < c) continue;
                //cerr << elem << ":" << a << "," << b << "," << c << endl;
                if(a != b && b != c && c != a) count+=6;
                else if(a != b || b != c || c != a) count+=3;
                else count++;
            }
        }
    }

    cout << count << endl;
    */
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

Measured memory_bytes: 572
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<cassert>

#define f first
#define s second
#define mp make_pair

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

using namespace std;

typedef unsigned int uint;
typedef long long ll;

template<int m>
class Prime{
  std::vector<bool> p;
  std::vector<int> ps;
public:
  Prime(){
    p = std::vector<bool>(m,true);
    assert(m>1);
    p[0]=p[1]=false;
    for(int i=4;i<m;i+=2)
      p[i]=false;
    ps.push_back(2);
    for(int i=3;i<m;i+=2){
      if(p[i]){
        ps.push_back(i);
        for(int j=i+i;j<m;j+=i)
          p[j]=false;
      }
    }
  }

  bool isPrime(int n){
    assert(m>n);
    return p[n];
  }

  int operator [] (int n){
    if(n<ps.size()) return ps[n];
    else return 0;
  }

  int size(){
    return ps.size();
  }
};

int main(){
  Prime<10000000+100> p;
  int n;
  while(cin>>n, n){
    int ans = 0;
    for(int i=0; p[i] + p[i] <= n; i++){
      if(p.isPrime(n - p[i]))
        ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
    ll tn;
    while(true){
        cin>>tn;
        if(tn==0)break;
        ll ans=0;
        ll ansn=0;
        for(ll i=1;i<=sqrt(2*tn);i++){
            ll u=-1,t=tn+1;
            while(t-u>1){
                ll mid=(t+u)/2;
                ll sum=i*(mid*2+i-1)/2;
                if(sum==tn){
                    if(ans<i){ans=i;
                    ansn=mid;}
                    break;
                }else if(sum<tn){
                    u=mid;
                }else{
                    t=mid;
                }

            }
        }
        cout<<ansn<<" "<<ans<<endl;
    }




    return 0;
}



Measured memory_bytes: 3004
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;
template<typename T> void Out(T x) { cout << x << endl; }

const int maxh = 1e4 + 10;
const int maxn = 1e3 + 10;
int dp[maxh];
int a[maxn], b[maxn];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int h, n;
  cin >> h >> n;
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
  memset(dp, 0x3f3f3f3f, sizeof(dp));
  dp[0] = 0;
  for (int i = 0; i < n ; i++) {
    for (int j = 0; j <= h; j++) {
      int hh = min(j + a[i], h);
      dp[hh] = min(dp[hh], dp[j] + b[i]);
    }
  }
  Out(dp[h]);

}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i, begin_i, end_i) for (int i = (int)begin_i; i < (int)end_i; i++)

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
int n,k,x,y;
int main(){
    cin>>n>>k>>x>>y;
    int i=0;
    long long sum=0;
    for(i;i<n;i++){
    if(i<k)
        sum+=x;
    else
        sum+=y;
    }
    cout<<sum<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main ()
{
	int n, k, r, s, p, pas=0, i=0, j=0;
	cin>>n>>k>>r>>s>>p;
	string t, b="";
	cin>>t;
	for(i=0; i<k; i++){
		b="";
		for(j=i; j<t.size(); j+=k){
			b+=t[j];
		}
		b+='a';
		for(j=1; j<b.size(); j++){
			if(b[j-1]==b[j]){
			if(b[j-1]=='r')
			pas+=p;
			if(b[j-1]=='s')
			pas+=r;
			if(b[j-1]=='p')
			pas+=s;
			b[j]='a';
			continue;
			}
			if(b[j-1]=='r')
			pas+=p;
			if(b[j-1]=='s')
			pas+=r;
			if(b[j-1]=='p')
			pas+=s;
		}
	}
	cout<<pas;
}

Measured memory_bytes: 512
import numpy as np
n, c = map(int, input().split())
channels = np.zeros((30, 10**5), dtype=np.int64)
for _ in range(n):
  s, t, c = map(int, input().split())
  s -= 1
  t -= 1
  c -= 1
  channels[c, s:t+1] += 1
newchannels = np.where(channels>1, 1, channels)
sums = newchannels.sum(axis=0)
print(sums.max())

Measured memory_bytes: 88696
#include <string>
#include <iostream>

using namespace std;
long long int dp[200005];
int main(){
  string s;
  cin >> s;
  int ct[256];
  for(int i=0;i<256;i++) ct[i] = 0;
  dp[0] = 1;
  ct[s[0]]++;
  for(int i=1;i<s.length();i++){
    dp[i] = (i - ct[s[i]]) + dp[i-1];
    ct[s[i]]++;
  }
  cout << dp[s.length()-1] << endl;
  return 0;
}

Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100010
#define INF 10000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
    int n;
    cin>>n;
    vector<P>a(n);
    REP(i,n){
        int x,y;
        cin>>x>>y;
        a[i]={y,x};
    }
    sort(ALL(a));
    bool f=true;
    ll sum=0;
    REP(i,n){
        sum+=a[i].second;
        if(sum>a[i].first){
            f=false;
            break;
        }
    }
    if(f)OUT("Yes");
    else OUT("No");
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<map>
#define DD 1000000007
using namespace std;

int main()
{
    long long n;
    string s;
    cin >> n;
    cin >> s;
    string st="abcdefghijklmnopqrstuvwxyz";
    
    map<string,long long> mp;
    
    for(int i = 0;i<26;i++)
    {
        string t(1,st[i]);
        mp[t] = 1;
    }
    
    for(long long i = 0;i<n;i++)
    {
        string t(1,s[i]);
        mp[t]++;
    }

    long long c=1;
    for(int i = 0;i<26;i++)
    {
        string t(1,st[i]);
        c *= mp[t];
        c %= DD;
    }
    
    cout << c-1 << endl;
   
    return 0;    
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <set>
#include <stack>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
string convertInt(int number)
{
    if (number == 0)
        return "0";
    string temp = "";
    string returnvalue = "";
    while (number > 0)
    {
        temp += number % 10 + 48;
        number /= 10;
    }
    for (int i = 0; i < temp.length(); i++)
        returnvalue += temp[temp.length() - i - 1];
    return returnvalue;
}
const int eps = 1e-7;


int main() {

    fast
        map<string, int>mp;
        int n;
    cin >> n;
    vector<pair<int,string>>v;
    for (int i = 0; i < n; i++) {
        string x;
        cin >> x;
        mp[x]++;
    }
    for (auto t : mp) { v.push_back({ t.second,t.first }); }
    

    sort(v.begin(), v.end());
    
    for (int i = 0; i < v.size(); i++) {
        if (v[i].first == v[v.size()-1].first)cout << v[i].second << endl;
    }
}

Measured memory_bytes: 27760
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll power(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)

//your code here!

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート 1,2,....9
}

int main(void){
    ll N, score[1001], ans=0;
    scanf("%lld", &N);
    rep(i, N) {
        scanf("%lld", score+i);
        ans += score[i];
    }
    if(ans%10) printf("%lld\n", ans);
    else {
        ll is_score_0=1;
        qsort(score, N, sizeof(ll), cmp);
        rep(i, N) {
            if(score[i]%10) {
                is_score_0 = 0;
                ans -= score[i];
                break;
            }
        }
        if(is_score_0) puts("0");
        else printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import bisect
#N, Q = map(int,input().split())
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
B.sort()
C.sort()
B_num = [0] * N
ans = 0
for i in range(N):
    b = B[i]
    B_num[i] += N - 1 - bisect.bisect_right(C,b) + 1

for i in range(N-1):
    B_num[i+1] += B_num[i]
#print(B_num)
B_num = [0] + B_num

for i in range(N):
    a = A[i]
    idx = min(bisect.bisect_right(B, a), N)
    ans += B_num[N] - B_num[idx]
    #print(B_num[idx], ans)
    #print(ans)

print(ans)

Measured memory_bytes: 23360
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
typedef long long ll;
#define mp make_pair
int n,q;
ll sum;
ll cnt[100005];
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		ll tmp;
		cin>>tmp;
		sum+=tmp;
		cnt[tmp]++;
	}
	cin>>q;
	while(q--){
		int a,b;
		cin>>a>>b;
		sum+=cnt[a]*(b-a);
		cnt[b]+=cnt[a];
		cnt[a]=0;
		cout<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 4340
a,b,k=map(int,input().split())
for i in range(k):
    if i%2:
        if b%2:b-=1
        a,b=a+b//2,b//2
    else:
        if a%2:a-=1
        a,b=a//2,b+a//2

print(a,b,sep=' ')

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

int main(){
  int x;
  cin>>x;
  int sum=0;
  int tmp;
    if(x>=500){
      tmp=x/500;
      sum+=tmp*1000;
      x-=tmp*500;
    }
    if(x>=5){
      tmp=x/5;
      sum+=tmp*5;
    }
    cout<<sum<<endl;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;

ll f(string s)
{
    int N = s.size();
    ll sum = 0;
    for (ll i = 0, j = 0; i < N; i = j) {
        // 同じ数が連続する回数
        while (j < N && s[i] == s[j]) {
            j++;
        }
        sum += (j - i) / 2;
    }
    return sum;
}

int main(int argc, char const* argv[])
{
    string S;
    cin >> S;
    ll N = S.size(), K;
    cin >> K;

    // もし全ての文字が同じなら
    bool same = true;
    for (int i = 0; i < N; ++i) {
        if (S[0] != S[i]) {
            same = false;
        }
    }
    if (same) {
        cout << N * K / 2 << endl;
        return 0;
    }

    ll d1 = f(S), d2 = f(S + S);
    ll a = d1, d = d2 - d1;

    // 文字列同士が連続するのはK-1箇所なので,その分を足す
    cout << a + (K - 1) * d << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  int tk = a, ao = b;
  for (int i = 0; i < k; ++i) {
    if (i % 2 == 0) {
      if (tk & 1) {
        tk--;
      }
      ao += tk / 2;
      tk /= 2;
    } else {
      if (ao & 1) {
        ao--;
      }
      tk += ao / 2;
      ao /= 2;
    }
  }
  cout << tk << " " << ao << endl;
  return 0;
}

Measured memory_bytes: 3636
from math import gcd
def main(): #startline-------------------------------------------
    k = int(input())
    ans = 0
    for i in range(1,k+1):
        for j in range(1,k+1):
            for l in range(1,k+1):
                ans += gcd(gcd(i,j),l)

    print(ans)
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 9184
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x

int selectionSort(int* A, int N){ // N 個の要素を含む 0-オリジンの配列 A
  int count = 0;
  int i, j;
  int minj;

  for( i = 0; i <= N-1; i++){
    minj = i;
    for( j = i; j <= N-1; j++ ){
      if( A[j] < A[minj] ){
        minj = j;
      }
    }
    if( i != minj ){
      swap( A[i], A[minj] );
      count++;
    }
  }

  return count;
}

int main() {

  int N, A[200];
  int count;

  cin >> N;

  REP(i, N){
    cin >> A[i];    
  }

  count = selectionSort( A, N );

  REP(i, N){
    cout << A[i];
    if( i != N-1 ){
      cout << " ";
    }    
  }
  cout << endl;
  cout << count << endl;

}

/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 3116
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    
const int N = 405;
const ll INF = 1e18L + 5;
ll dp[N][N];

//dp[i][j] = min cost to combine [i....j] segment into one


int main(){
   IOS

   int n; cin>>n;

   vector<ll> a(n);

   for(auto & i : a)cin>>i;

   for(int i = 0; i < n; i++)dp[i][i] = 0;

    auto sum = [&](int l, int r){
        ll res = 0;
        for(int i = l ; i <= r; i++)
            res += a[i];
        return res;
    };

    for(int i = 0; i < n; i++)dp[i][i] = 0;

   for(int l = 2; l <= n; l++){
       for(int i = 0; i < n-l+1; i++){
           int j = i + l- 1;
           ll s= sum(i,j);
           dp[i][j] = INF;
            for(int k = i; k < j; k++){
               dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + s);
           }
       }
   }

   cout<<dp[0][n-1];



   

    







}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



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

using ll =long long;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b == 0){
       return(b);
   }else{
       return(gcd(b, a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a * b / gcd(a, b);
}

//文字列→数列
//string S;int A=atoi(S.c_str());
//数列→文字列
//int A;string S=to_string(A);
//数字判定　isdigit(a)
//pair宣言　pair<int,int> p(5,7);
//

 double f(double T){
   double ans;
   ans=(T+1)/2;
   return ans;
 }

int main(){
cout<<fixed<<setprecision(10);
  
  
ll N,K;
  cin>>N>>K;
  vector<double> vec(N); 
  double sum=0;
  double M=0;
  vector<double> Y(N);
  for(int i=0;i<N;i++){
    double a;
    cin>>a;
    vec[i]=f(a);
  //  cout<<vec[i]<<endl;
    sum+=vec[i];
   Y[i]=sum;
  }
vector<double> ans(N);
  for(int i=0;i<N-K+1;i++){
    ans[i]=Y[i+K-1]-Y[i-1];
  }
  sort(ans.begin(),ans.end());
  reverse(ans.begin(),ans.end());
cout<<ans[0];


  



}


Measured memory_bytes: 4992
while 1!=0:
    n, m = map(int,input().split())
    if n==0 and m==0:
        break
    lista= [int (i) for i in input().split()]
    ans = 0
    for i in range(n):
        for j in range(n):
            if i == j:
                continue
            if (lista[i]+lista[j])<=m and (lista[i]+lista[j])>ans:
                ans = lista[i] + lista[j]
                
    if ans == 0:
        print('NONE')
    else:
        print(ans)



Measured memory_bytes: 5636
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)(x).size())
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	vector<int> v(n),l(n),r(n);
	for(auto &i:v) cin>>i;
	l[1]=v[0];
	For(i,2,n-1) l[i]=gcd(l[i-1],v[i-1]);
	r[n-2]=v[n-1];
	for(int i=n-3;i>=0;i--) r[i]=gcd(r[i+1],v[i+1]);
	int mx=0;
	For(i,0,n-1) mx=max(mx,gcd(l[i],r[i]));
	cout<<mx<<"\n";
	//for(auto i:l) cout<<i<<" "; cout<<"\n";
	//for(auto i:r) cout<<i<<" "; cout<<'\n';
	return 0;
}












Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 28;
int dp[maxn], dpu[maxn];
int main(){
	int n, t;
	string s;
	cin >> n >> t >> s;
	for(int i = 1, j = n - 2; i < n; i ++, j --){
		dp[i] = dp[i - 1];
		if(s[i - 1] == 'A' && s[i] == 'C')
			dp[i] ++;
		dpu[j] = dpu[j + 1];
		if(s[j] == 'A' && s[j + 1] == 'C')
			dpu[j] ++;
	//	cout << dp[i] << "  ** " << i << "\n";
	//	cout << dpu[j] << " && " << j << " \n";
	}
	while(t--){
		int l, r;
		cin >> l >> r;
		l --, r --;
		if(s[r] == 'A' && s[r + 1] == 'C')
			cout << dpu[l] - dpu[r + 1] - 1 << "\n";
		else
			cout << dpu[l] - dpu[r + 1] << "\n";
	}
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define ALL(a) (a).begin(), (a).end()
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#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 cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
#define INF 1e18
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
  return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

int main()
{
  int n,a[101]={};
  cin >> n;
  rep(i,n)
  {
    cin >> a[i];
  }
  sort(a,a+n);
  cout << a[n-1] - a[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int n;
    cin >> n;
    if (n == 0){
      break;
    }
    vector<string> group(n);
    vector<vector<string>> member(n);
    for (int i = 0; i < n; i++){
      string S;
      cin >> S;
      int m = S.size();
      string T;
      for (int j = 0; j < m; j++){
        if (isalpha(S[j])){
          T += S[j];
        }
        if (S[j] == ':'){
          group[i] = T;
          T = "";
        }
        if (S[j] == ',' || S[j] == '.'){
          member[i].push_back(T);
          T = "";
        }
      }
    }
    map<string, int> mp;
    for (int i = 0; i < n; i++){
      mp[group[i]] = i;
    }
    vector<vector<int>> E(n);
    for (int i = 0; i < n; i++){
      int sz = member[i].size();
      for (int j = 0; j < sz; j++){
        if (mp.count(member[i][j])){
          E[mp[member[i][j]]].push_back(i);
        }
      }
    }
    vector<int> deg(n, 0);
    for (int i = 0; i < n; i++){
      for (int j : E[i]){
        deg[j]++;
      }
    }
    queue<int> Q;
    for (int i = 0; i < n; i++){
      if (deg[i] == 0){
        Q.push(i);
      }
    }
    vector<set<string>> ans(n);
    while (!Q.empty()){
      int v = Q.front();
      Q.pop();
      int sz = member[v].size();
      for (int i = 0; i < sz; i++){
        if (!mp.count(member[v][i])){
          ans[v].insert(member[v][i]);
        } else {
          for (string s : ans[mp[member[v][i]]]){
            ans[v].insert(s);
          }
        }
      }
      for (int w : E[v]){
        deg[w]--;
        if (deg[w] == 0){
          Q.push(w);
        }
      }
    }
    cout << ans[0].size() << endl;
  }
}


Measured memory_bytes: 3312
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define MAXN 100000
using namespace std;
typedef long long LL;
vector<int> turns[MAXN+5];
LL k;
int n,m,tcnt=0,chs[MAXN+5],id[MAXN+5],id2[MAXN+5];
LL x[MAXN+5],a[MAXN+5];
LL a2[MAXN+5],x2[MAXN+5];
bool vis[MAXN+5];
int main()
{
//	freopen("rabbit.in","r",stdin);
//	freopen("rabbit.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&x[i]),id[i]=i;
	for(int i=1;i<=n;i++)
		a[i]=x[i]-x[i-1];
	scanf("%d %lld",&m,&k);
	for(int i=1;i<=m;i++)
		scanf("%d",&chs[i]),swap(id[chs[i]],id[chs[i]+1]);
	for(int i=1;i<=n;i++)
	{
		int p=i;
		if(vis[p]==true)
			continue;
		tcnt++;
		while(vis[p]==false)
		{
			vis[p]=true;
			turns[tcnt].push_back(p);
			p=id[p];
		}
	}
	for(int i=1;i<=tcnt;i++)
	{
		int T=(int)turns[i].size();
		int pos=k%T;
		for(int j=0,p=pos;j<(int)turns[i].size();j++,p=(p+1)%T)
			id2[turns[i][j]]=turns[i][p];
	}
	for(int i=1;i<=n;i++)
		a2[i]=a[id2[i]];
	for(int i=1;i<=n;i++)
		x2[i]=x2[i-1]+a2[i];
	for(int i=1;i<=n;i++)
		printf("%lld.0\n",x2[i]);
	return 0;
}

Measured memory_bytes: 11264
import java.util.*;

public class Main {
public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int total = 0;
  
  if (N < 4) {
    System.out.println("No");
    return;
  }

    for (int i = 0; total <= N; i++) {
      for (int j = 0; total <= N; j++) {
          total = 4 * i + 7 * j;
          if (total == N) {
            System.out.println("Yes");
            return;
          }
      }
      total = 4 * i;
    }

    System.out.println("No");
  }
}


Measured memory_bytes: 23636
// ref: https://web.archive.org/web/20200525161650/https://webcache.googleusercontent.com/search?q=cache:02O8gvmgmdkJ:https://dalekspritner.hatenablog.com/entry/2018/09/14/050526+&cd=1&hl=ja&ct=clnk&gl=jp
// ref: https://atcoder.jp/contests/abc087/submissions/3187335

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

struct edge{
    int to;
    int cost;
};

bool DFS(vector<int>& vDist, const vector<vector<edge>>& vGraph, int u, int d){
    // u: from
    // v: to
    
    if( vDist[u]!=INT_MAX && d!=vDist[u]){ return false; }
    if( vDist[u]!=INT_MAX && d==vDist[u]){ return true; }
    
    vDist[u] = d;
    for(uint v=0; v<vGraph[u].size(); ++v){
        if(! DFS(vDist, vGraph, vGraph[u][v].to, d + vGraph[u][v].cost) ){ return false; }
    }
    
    return true;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N, M; cin >> N >> M;
    vector<vector<edge>> vGraph(N);
    for(int i=0; i<M; ++i){
        int L, R, D; cin >> L >> R >> D;  --L, --R;
        vGraph[ L ].push_back( edge{R, D} );
        vGraph[ R ].push_back( edge{L,-D} );
    }
    
    vector<int> vDist(N, INT_MAX);
    for(int i=0; i<N; ++i){
        if(vDist[i]!=INT_MAX){ continue; }
        if(!DFS(vDist, vGraph, i, 0)){ cout << "No" << endl; return 0; }
    }
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 12032
#include<iostream>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

int dp[101][3][3];
int can[100][3];

int main() {
  int n, k;
  cin >> n >> k;
  rep (i, k) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    can[a][(b + 1) % 3] = -1;
    can[a][(b + 2) % 3] = -1;
  }
  rep (i, 3) if (can[0][i] != -1) dp[0][i][i] = 1;
  rep (i, 3) if (can[1][i] != -1) rep (j, 3) dp[1][i][j] = dp[0][j][j];
  rep (i, n - 2) {
    rep (j, 3) rep (k, 3) {
      if (can[i + 2][j] != -1) {
	rep (l, 3) {
	  if (j == k && j == l) continue;
	  dp[i + 2][j][k] += dp[i + 1][k][l];
	  dp[i + 2][j][k] %= 10000;
	}
      }
    }
  }
  int res = 0;
  rep (i, 3) rep (j, 3) res += dp[n - 1][i][j];
  cout << res % 10000 << endl;
  return 0;
}

Measured memory_bytes: 1164
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X, Y;
    cin >> X >> Y;
    if (abs(X - Y) <= 1) cout << "Brown" << endl;
    else cout << "Alice" << endl;

    return 0;
}


Measured memory_bytes: 256