akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#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 pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 2005;



int main() {
  int n,a,b;
  scanf("%d%d%d",&n,&a,&b);
  vi x(n);
  cin>>x;
  int ans = abs(b-x.back());
  if (n >= 2) {
    int now = abs(x[n-2]-x.back());
    maxs(ans, now);
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 256
a, b = gets.split.map(&:to_i)

if a < 3 || a > 20 || b < 3 || b > 20
  puts "invalid argunment: 3 <= a, b <= 20"
  exit 0
end

res = 0
2.times do
  if a > b
    res += a
    a -= 1
  else
    res += b
    b -= 1
  end
end
puts res


Measured memory_bytes: 3836
package main

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

func main() {
	/*
		N : スイッチの個数
		M : 電球の個数
	*/
	var N, M, ans int
	fmt.Scan(&N, &M)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	a := make([]int, N)
	for i := 0; i < M; i++ {
		sc.Scan()
		k, _ := strconv.Atoi(sc.Text())

		for j := 0; j < k; j++ {
			sc.Scan()
			s, _ := strconv.Atoi(sc.Text())
			a[s-1] |= 1 << uint(i)
		}
	}

	var p int
	for i := 0; i < M; i++ {
		sc.Scan()
		b, _ := strconv.Atoi(sc.Text())
		p |= b << uint(i)
	}

	for sState := 0; sState < (1 << uint(N)); sState++ {
		q := 0
		for i := 0; i < N; i++ {
			if sState>>uint(i)&1 == 1 {
				q ^= a[i]
			}
		}
		if p == q {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
n,m=map(int,input().split())
a=[list(input())for i in range(n)]
b=[list(input())for i in range(m)]
def match(x,y):
    for i in range(m):
        for j in range(m):
            if a[i+x][j+y]!=b[i][j]:
                return False
    return True
flag=False
for i in range(n-m+1):
    for j in range(n-m+1):
        if match(i,j):
            flag=True
if flag:
    print("Yes")
else:
    print("No")

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

    

Measured memory_bytes: 604
/*
 * アルゴリズムとしてはチケットの枚数分のネットワークをレイヤ構造で持ち
 * 各々のレイヤから上位レイヤへはチケットを使った場合に遷移するようにする
 * 上位レイヤから下位レイヤには遷移することができないようにし，
 * 最下位レイヤの始点から終点と同じ点を表すすべてのレイヤの点までの最短経路を求める．
 *
 * (イメージ)
 *      T`T`T`  
 *      |/|/|   S=始点, o=点, T`=終点 |=辺 /=レイヤ下位から上位への有効辺
 *      o o o   
 *      |/|/|   S->T`までの距離で最短のものを求め出力する
 *      S o o   
 *Layer 0 1 2   
 *
 **/

#include <iostream>
#include <map>

#define rep(i,s,t) for(int i=s;i<t;i++)

using namespace std;

//c層目のid値を返す関数
int id2cid(int c,int id){
	return c*1000+id;
}

//dijkstraアルゴリズム
//特に無加工，距離を持った隣接を表すgraphと各点までの距離を保持するdis,始点ssを入力
//計算結果はdisに保持し，返り値は無し
void dijkstra(map<int,map<int,int> > &graph,map<int,int>  &dis,int ss){
	//未確定点を保持する集合multimap，距離をkey,点idをvalueとする
	multimap<int, int> T;
	//注目する点pのid値
	int pid;
	//始点をまず入力する
	T.insert(make_pair(0,ss));
	//未確定点がなくなるまで
	while(!T.empty()){
		//未確定の中で一番距離が小さい要素(mapの先頭)を取得し注目点pを得る
		pid=(*(T.begin())).second;
		//点pを未確定点集合から削除する
		T.erase(T.begin());

		//pに隣接する点について
		for(map<int,int>::iterator it=graph[pid].begin();it!=graph[pid].end();it++){
			//隣接点のid値cidとその点までの距離distを取得
			int cid=(*it).first;
			int dist=(*it).second;
			//隣接点が未確定点集合に含まれない，もしくは暫定の距離より小さい場合
			//未確定点集合の隣接点の距離を始点から注目点までの距離＋注目点からの距離に更新する
			if((dis.find(cid)!=dis.end() &&  dis[cid]>dis[pid]+dist) ||
				dis.find(cid)==dis.end()){
					T.insert(make_pair(dis[pid]+dist,cid));			
					dis[cid]=dis[pid]+dist;
			}
		}
	}
}

int main(void){
	
	int c,n,m,s,d;
	while(cin >> c >> n >> m >> s >> d){
		if(c==0) break;

		//グラフ構造用意
		//mapを用いて辺i,jのコストcで隣接関係を表現
		map<int,map<int,int> > graph;

		//m路線に対して
		rep(i,0,m){
			int a,b,f;
			cin >> a >> b >> f;

			//グラフをc+1個の層構造とする
			rep(j,0,c+1){
				//j層目のグラフでは通常料金の移動コストで辺を張る
				//id2cid(j,id)でj層目の点idを示すid値に変換する
				//点は最大でも500点しかないため，1000桁目以上がn層目とする.
				//ex(0層目の点125は id=125,8層目の点125は8125)となる．
				graph[id2cid(j,a)][id2cid(j,b)]=f;
				graph[id2cid(j,b)][id2cid(j,a)]=f;
				//j層目からj+1層目へは割引料金を用いた移動コストの辺を張る
				//j層目からj-1層目への辺がないため階層が上がるに連れて下がることはできない
				//j層目はすなわちj回チケットを利用した枚数に相当する．
				if(j<c){
					graph[id2cid(j,a)][id2cid(j+1,b)]=f/2;
					graph[id2cid(j,b)][id2cid(j+1,a)]=f/2;
				}
			}
		}
		//各点の最短距離を保持するmap
		map<int,int>  dis;
		//通常のダイクストラで始点sからの各点への最短距離を求め，計算結果を変数disに保持する
		dijkstra(graph,dis,id2cid(0,s));

		//求め終わると終点dと同じ点である点すべての中から最小値を求める
		int mindis=dis[id2cid(0,d)];
		rep(i,0,c){
			mindis=mindis>dis[id2cid(c-i,d)]?dis[id2cid(c-i,d)]:mindis;
		}
		//結果出力
		cout << mindis << endl;
	}

	return 0;
}

Measured memory_bytes: 2040
// https://atcoder.jp/contests/abc114/tasks/abc114_c

#include <algorithm>
#include <cmath>
#include <iostream>
// #include <string>
using namespace std;
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))

int len = 0, cnt = 0, n;

void rege(string s) {
    // 3, 5, 7が含まれている
    if (s.find("3") != std::string::npos && s.find("5") != std::string::npos &&
        s.find("7") != std::string::npos && stoi(s) <= n) {
        cnt++;
    }
    if ((int)s.size() < len) {
        rege(s + "3");
        rege(s + "5");
        rege(s + "7");
    }

    return;
}

int main() {
    string s;
    cin >> n;

    s = to_string(n);
    len = s.size();
    rege("");

    cout << cnt << endl;
    return 0;
}


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

int INF = 1e9;
int n, u, v;
vector<int> edge[100005];
vector<int> d1(100005);
vector<int> d2(100005);

void dfs(int u){
    for(auto v : edge[u]){
        if(d1[v] == INF){
            d1[v] = d1[u]+1;
            dfs(v);
        }
    }
}
void dfs2(int u){
    for(auto v : edge[u]){
        if(d2[v] == INF){
            d2[v] = d2[u]+1;
            dfs2(v);
        }
    }
}

int main(void){
    cin>>n>>u>>v;
    --u;--v;
    rep(i, n-1){
        int a, b;
        cin>>a>>b;
        --a;--b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    rep(i, n){
        d1[i] = INF;
        d2[i] = INF;
    }
    d1[u] = 0;//逃げる方
    d2[v] = 0;//鬼
    dfs(u);
    dfs2(v);
    int ans = 1;
    rep(i, n){
        if(d1[i]<d2[i]){
            ans = max(ans, d2[i]);
        }
    }
    cout<<ans-1<<endl;
    return 0;
}

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

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

    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    long long ans = 1000;
    long long max = 1000;
    long long now = 0;
    int flag = 0;
    for(int i = 0; i < n - 1; i++){
        if(flag == 0){
            if(a[i] < a[i + 1]){
                now = max / a[i];
                max -= now * a[i];
                flag = 1;
            }
        }else{
            if(a[i] > a[i + 1]){
                max += now * a[i];
                if(ans < max){
                    ans = max;
                }else{
                    max = ans;
                }
                now = 0;
                flag = 0;
            }
        }
    }

    if(now != 0){
        max += now * a[n - 1];
        if(ans < max){
            ans = max;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include  <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>

using namespace std;

int n;
int i;
long long a;
long long x;
long long tmp = 0;
long long summ = 0;

int main(){
	scanf("%d%lld",&n,&x);
	for(i=0;i<n;i++){
		scanf("%lld",&a);
		if(a+tmp>x){
			summ+=a+tmp-x;
			tmp = x-tmp;
		}
		else tmp = a;
	}
	printf("%lld\n",summ);
	return 0;
}

Measured memory_bytes: 256
use proconio::input;

// use std::cmp::*;
// use std::collections::*;
// use proconio::marker::Chars;

fn main() {
    input! {
        // s: String
        // n: isize
        c:char
    }
    let vowels = vec!['a', 'e', 'i', 'o', 'u'];
    if vowels.contains(&c) {
        println!("vowel");
    } else {
        println!("consonant");
    }
}


Measured memory_bytes: 2132
n, k = map(int, input().split())
MOD = 10**9+7
d = [0]*(k+1)
for i in range(1, k+1):
    d[i] = pow(k//i, n, MOD)

for i in reversed(range(1, k+1)):
    for j in range(2*i, k+1, i):
        d[i] -= d[j]
        d[i] %= MOD

ans = 0
for i in range(1, k+1):
    ans += i*d[i] % MOD
print(ans % MOD)


Measured memory_bytes: 11172
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		String a = stdIn.next();
		String b = stdIn.next();
		String c = stdIn.next();
		
		System.out.println("A" + b.charAt(0) + "C");
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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

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


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll X; std::cin >> X;

  std::cout << std::ceil( (double) (-1.+std::sqrt( 8.*(double)X + 1 ))/2. ) << std::endl;
  
  return 0;
}


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

public class Main{

	static int [][][][]memo;
	static int MOD=(int)1e9+7,n;
	
	static boolean ok(int x1,int x2,int x3,int x4) {
		if(x1==0 && x2==1 && x3==2)
			return false;
		if(x2==0 && x3==1 && x4==2)
			return false;
		return true;
	}
	static int dp(int idx,int x1,int x2,int x3) {
		if(idx==n)
			return 1;
		if(memo[x1][x2][x3][idx]!=0)
			return memo[x1][x2][x3][idx];
		int ans=0;
		for(int nxt=0;nxt<=3;nxt++) {
			if(!ok(x1,x2,x3,nxt))
				continue;
			if(!ok(x1,x2,nxt,x3))
				continue;
			if(!ok(x1,x3,x2,nxt))
				continue;
			if(!ok(x2,x1,x3,nxt))
				continue;
			ans+=dp(idx+1, x2, x3, nxt);
			ans%=MOD;
		}
		return memo[x1][x2][x3][idx]=ans;
	}
	
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner();
		PrintWriter out=new PrintWriter(System.out);
		n=sc.nextInt();
		memo=new int [5][5][5][n];
		out.println(dp(0, 4, 4,4));
		out.close();

	}
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		Scanner(String fileName) throws FileNotFoundException{
			br=new BufferedReader(new FileReader(fileName));
		}
		String next() throws IOException {
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		String nextLine() throws IOException {
			return br.readLine();
		}
		int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		long nextLong()  throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 22996
#include <stdio.h>
int main(){
	int n;
	int i,a,b,asum,bsum;
	scanf("%d",&n);
	while(n!=0){
		asum=0;
		bsum=0;
		for(i=0;i<n;i++){
			scanf("%d %d",&a,&b);
			if(a>b){
				asum+=a+b;
			}
			else if(a==b){
				asum+=a;
				bsum+=b;
			}
			else{
				bsum+=a+b;
			}
		}
		printf("%d %d\n",asum,bsum);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 600
def main():
    n,k = map(int,input().split())
    ans = 0
    mod = 10**9+7
    tmp = [0] * (n+1)
    for i in range(1,n+1):
        tmp[i] = tmp[i-1] + i
    # print(tmp)
    for i in range(k,n+1):
        ans += (tmp[-1] - tmp[-1-i]) - tmp[i-1] + 1
        ans %= mod
    print(ans+1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 65428
#include <stdio.h>

int main(void)
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	// printf("%d %d %d\n", a, b, c);
	if (a + b >= c)
		printf("%d\n", b + c);
	else if (a + b < c)
		printf("%d\n", a+b+1+b);
	return 0;
}

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

#define FasterIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(v) v.begin(), v.end()
const int MOD = 1e9+7;

bool cmp(const pair<string, pair<int, int> >& a, const pair<string, pair<int, int> >& b){
    if(a.first==b.first)
        return a.second.first>b.second.first;
    return a.first<b.first;
}

int main(){
    FasterIO;

    int n;

    while(cin>>n){
        pair<string, pair<int, int> >p[n];

        for(int i=0; i<n; i++){
            cin>>p[i].first>>p[i].second.first;
            p[i].second.second = i+1;
        }

        sort(p, p+n, cmp);

        for(int i=0; i<n; i++){
            cout<<p[i].second.second<<endl;
        }
    }

    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		std::vector<int> num;
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (; x; x /= 10) {
			num.push_back(x % 10);
		}
		while (!num.empty()) {
			putchar(num.back() ^ '0');
			num.pop_back();
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 105;

int n, m, a[N], sum, cnt;

int main() {
	read(n), read(m);
	for (int i = 1; i <= n; ++i) {
		read(a[i]), sum += a[i];
	}
	sum = (sum - 1) / (4 * m) + 1;
	for (int i = 1; i <= n; ++i) {
		if (a[i] >= sum) {
			++cnt;
		}
	}
	if (cnt >= m) {
		printStr("Yes");
	} else {
		printStr("No");
	}
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
#define F(i,a,n) for(int i=a;i<n;i++)
#define mod 1000000007 
#define pb push_back

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int w=1;
	// cin>>w;
	while(w--){
	int n,ans=0,i=0,x=0;
	cin>>n;
	F(i,1,n){
		if(n%i==0)ans+=n/i-1;
		else ans+=n/i;
		if(i*i<n)x++;
	}
	cout<<ans;
	}

	return 0;
}

Measured memory_bytes: 3636
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s

main :: IO ()
main = do
    -- スペース区切り整数の入力
    [a, b, c] <- map strToInt . words <$> getLine
    -- 出力
    putStrLn . show $ if a == b then c else (if b == c then a else b)


Measured memory_bytes: 508
N = int(input())
A = list(map(int,input().split()))

k = 1000000007

sm = sum(A)

ans = 0
for s in range(len(A)-1):
    #ans += A[s]*sum(A[s+1:])
    sm -= A[s]
    ans += A[s]*sm

if ans>1000000007:
    print(ans%k)
else:
    print(ans)


Measured memory_bytes: 31572
x=list(input())
stack=[]
for i in range(len(x)):
    if x[i]=="S":
        stack.append(x[i])
    elif x[i]=="T" and len(stack)==0:
        stack.append(x[i])
    elif x[i]=="T" and stack[-1]=="T":
        stack.append(x[i])
    elif x[i]=="T" and stack[-1]=="S":
        stack.pop()
print(len(stack))

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

int main(){
  int a;
  cin >> a;
  cout << a + a*a + a*a*a;
  
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using sqvec = vector<vector<int>>;
int main(){
  int n, W;
  cin >> n >> W;
  //sqvec a(vector<int>(n));
  int w[n], v[n];
  for(int i = 0; i < n; i++){
    cin >> w[i] >> v[i];
  }
  long dp[n+1][W+1];
  for(int i = 0; i < W+1; i++){
    dp[0][i] = 0;
  }
  for(int i = 1; i < n+1; i++){
    for(int sum_w = 0; sum_w < W + 1; sum_w ++){
      if(sum_w >= w[i-1]){
        dp[i][sum_w] = max(dp[i-1][sum_w], dp[i-1][sum_w - w[i-1]] + v[i-1]);
      }else{
        dp[i][sum_w] = dp[i-1][sum_w];
      }
    }
  }
  cout << dp[n][W] << endl;
}


Measured memory_bytes: 79104
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int value;
	if (a + b<2 * c) {
		value = a + b;
	}
	else {
		value = 2 * c;
	}
	int ans;
	ans = min(x, y)*value;
	if (x>y) {
		ans += min(a,2*c) * (x - y);
	}
	else {
		ans += min(b,2*c) * (y - x);
	}
	cout << ans << endl;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int T[205];
int V[205];

//! [i*0.5秒後に出せる最大速度]
double M[40005];

int main()
{
    int N;
    cin >> N;
    REP(i, N)
    {
        cin >> T[i];
    }
    int t = 0;
    REP(i, N)
    {
        cin >> V[i];
        M[t * 2] = V[i];
        t += T[i];
    }
    FOR(i, t * 2 + 1, 1)
    {
        if (M[i] == 0)
            M[i] = M[i - 1];
    }
    for (int i = t * 2; i > 0; --i)
    {
        M[i] = std::min(M[i], M[i - 1]);
    }
    M[0] = 0;
    FOR(i, t * 2 + 1, 1)
    {
        M[i] = std::min(M[i], M[i - 1] + 0.5);
    }
    M[t * 2] = 0;
    for (int i = t * 2 - 1; i >= 0; --i)
    {
        M[i] = std::min(M[i], M[i + 1] + 0.5);
    }

    double sum = 0;
    REP(i, t * 2)
    {
        sum += 0.25 * (M[i] + M[i + 1]);
    }
    cout << OF64 << sum << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    int a[100005] = {0}, b[100005] = {0};
    for(int i = 1; i <= n+1; ++i)
        scanf("%d", &a[i]);
    for(int i = 1; i <= n; ++i)
        scanf("%d", &b[i]);
    long long ans = 0;
    for(int i = 1; i <= n+1; ++i)
    {
        int tmp1 = min(a[i], b[i-1]);
        ans += tmp1;
        a[i] -= tmp1;
        b[i-1] -= tmp1;
        int tmp = min(a[i], b[i]);
        ans += tmp;
        b[i] -= tmp;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chadd(x, y) x = (x + y) % mod

ll sum[200005];

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

    int n;
    cin >> n;
    vector<ll> a(n);
    map<ll, int> mp;
    ++mp[0];
    ll res = 0;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        sum[i+1] = sum[i] + a[i];
        if(mp.find(sum[i+1]) == mp.end()){
            mp[sum[i+1]] = 1;
        }
        else{
            res += mp[sum[i+1]];
            ++mp[sum[i+1]];
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 15872
#include<stdio.h>
	int main(){
		int a,b,c;
		while(scanf("%d %d %d",&a,&b,&c)!=EOF){
		if(a>1989)
			printf("heisei %d %d %d\n",a-1989+1,b,c);
		else if(a==1989){
			if(b>1)
				printf("heisei %d %d %d\n",a-1989+1,b,c);
			else if(b==1){
				if(c>=8)
					printf("heisei %d %d %d\n",a-1989+1,b,c);
				else printf("showa %d %d %d\n",a-1926+1,b,c);
			}
		}
		else if(a>1926)
			printf("showa %d %d %d\n",a-1926+1,b,c);
		else if(a==1926){
			if(b==12){
				if(c>=25)
					printf("showa %d %d %d\n",a-1926+1,b,c);
				else printf("taisho %d %d %d\n",a-1912+1,b,c);
			}
			else printf("taisho %d %d %d\n",a-1912+1,b,c);
		}
		else if(a>1912)
			printf("taisho %d %d %d\n",a-1912+1,b,c);
		else if(a==1912){
			if(b>7)
				printf("taisho %d %d %d\n",a-1912+1,b,c);
			else if(b==7){
				if(c>=30)
					printf("taisho %d %d %d\n",a-1912+1,b,c);
				else printf("meiji %d %d %d\n",a-1868+1,b,c);
			}
			else if(b<7)
				printf("meiji %d %d %d\n",a-1868+1,b,c);
		}
		else if(a>1868)
			printf("meiji %d %d %d\n",a-1868+1,b,c);
		else if(a==1868){
			if(b>9)
				printf("meiji %d %d %d\n",a-1868+1,b,c);
			else if(b==9){
				if(8<=c)
					printf("meiji %d %d %d\n",a-1868+1,b,c);
				else printf("pre-meiji\n");
			}
			else printf("pre-meiji\n");
		}
		else printf("pre-meiji\n");
		}
		return 0;
}

Measured memory_bytes: 0
import math
a, b, x = map(int,input().split())
sita = 0
c = 0
if x == a*b*b:
  sita = math.pi/2
elif a*a*b/2 <= x:
  c = a*a*a/2/(a*a*b-x)
  sita = math.atan(c)
else:
  c = 2*x/a/b/b
  sita = math.atan(c)
print('{:.10g}'.format(90-math.degrees(sita)))

Measured memory_bytes: 3064
import math,cmath
def f(m):
  c=1j*math.acos(a/2)
  r=cmath.exp(b+c)+p
  s=cmath.exp(b-c)+p
  u,v=2,2
  for t in A:
    if t in[p,q]:continue
    if abs(t-r)-1<1e-6:u+=1
    if abs(t-s)-1<1e-6:v+=1
  return max(m,u,v)

while 1:
  n=input()
  if n==0:break
  N=range(n)
  A=[]
  for i in N:
    x,y=map(float,input())
    A+=[x+1j*y]
  m=1
  for i in N:
    p=A[i]
    for q in A[i+1:]:
      a,b=cmath.polar(q-p)
      b*=1j
      if a<=2:m=f(m)
  print m

Measured memory_bytes: 4604
#include <iostream>

using namespace std;

int main()
{
    int lub;
    int d;
    long long area;

    while (cin >> d) {
        lub = 600 - d;
        area = 0;
        for (int i = d; i <= lub; i += d) 
            area += ((i * i) * d);
        cout << area << endl;
    }

    return 0;
}

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n, m;
int f[N];
LL s[N];
map<int, int> h;

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i ++ )
	{
		int x;
		scanf("%d", &x);
		s[i] = s[i - 1] + x;
	}
	
	h[0] = 1;
	LL res = 0;
	for (int i = 1; i <= n; i ++ )
	{
		LL r = s[i] % m;
		if (h.count(r)) res += h[r];
		h[r] ++ ;
	}
	
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
//debug
#define vecprint(v) cout << "  vector: ";rep(i,v.size())cout << v[i] << " ";cout << endl;
#define setprint(s) cout << "  set: ";for(auto i=s.begin();i!=s.end();i++)cout << *i << " ";cout << endl;
#define mappairprint(s) cout << "  map: ";for(auto i=s.begin();i!=s.end();i++)cout << i->first << " " << i->second << endl;cout << endl;
//reader
#define r1(a) cin>>(a)
#define r2(a,b) cin>>(a)>>(b)
#define r3(a,b,c) cin>>(a)>>(b)>>(c)
//writer
#define w1(a) cout<<(a)<<" "
#define w2(a,b) cout<<(a)<<" "<<(b)<<" "
#define w3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "
#define wl1(a) cout<<(a)<<endl
#define wl2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wl3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
//variable definition
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
//roop
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define all(c) c.begin(),c.end()
//term
#define elif else if
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
using namespace std;
using ll = long long;
//const
constexpr double PI = 3.141592653589793238462643383279;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};



int main() {
  //input
  ll r;
  cin >> r;
  
  
  cout << 2*r*PI << endl;
}

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

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

struct Node {
  Node *l, *r;
};

void test() {
  for (int i = 0; i < 1000000; ++i) new Node();
}

int main() {
  test();
  int a, b, c;
  cin >> a >> b >> c;
  cout << ((a+b+c) == max({a,b,c})*2 ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 31488
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int n,x,cnt;
    scanf("%d %d",&n,&x);
    for (int a=0;a<10000;a++){
        if (n==0 && x==0){
            break;
        }
    
    
    cnt=0;
    for (int i=3;i<=n;i++){
        for (int j=2;j<i;j++){
            for (int k=1;k<j;k++){
                if (i+j+k==x){
                    cnt+=1;
                }
                if (i+j+k>x){
                    break;
                }
            }
        }
    }
    printf("%d\n",cnt);
    scanf("%d %d",&n,&x);
    }
    return 0;
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
ll factorial(ll a){return a < 2 ? 1 : factorial(a - 1) * a;}
ll summation(ll a){return a < 1 ? 0 : (a * a + a) / 2;}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const string ALPHABETS = "abcdefghijklmnopqrstuvwxyz";
ll dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
//ll dx[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
ll n, m, x, y, z, w, h, k;
string s, t;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n >> m){
        ll ans = 0, tmp = 0, cnt = 0, mx = -INF, mn = INF;
        ll a[m + 1] = {}, b[] = {}, c[] = {};
        vll v;
        cin >> k;
        rep(i, k){
            cin >> x;
            a[x] = 1;
        }
        rep(i, n - 1){
            cin >> k;
            ll flag[m + 1] = {};
            rep(j, k){
                cin >> x;
                flag[x] = 1;
            }
            rep(j, m + 1){
                if(flag[j] == 0){
                    a[j] = 0;
                }
            }
        }
        rep(i, m + 1){
            if(a[i]){
                debug(i);
                ans++;
            }
        }
        print(ans);
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
ll fr[200002];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,t,n,m,k,q; 
    t = 1;
    // cin>>t;
    while(t--)
    {
    	cin>>n;
    	// memset(fr,0,sizeof(fr));
    	for(int i=1;i<=n;i++)
    		fr[i] = 0;
    	ll ar[n];
    	for(int i=0;i<n;i++)
    	{
    		cin>>ar[i];
    		fr[ar[i]]++;
    	}
    	ll sum = 0;
    	for(int i=1;i<=n;i++)
    	{
    		sum += ((fr[i])*(fr[i]-1))/2;
    	}
    	for(int i=0;i<n;i++)
    	{
    		a = sum - (fr[ar[i]]-1);
    		cout<<a<<endl;
    	}
    }
    return 0;
}

Measured memory_bytes: 5760
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        Integer[] num = {a,b,c};
        Arrays.sort(num,Collections.reverseOrder());

        System.out.println(Math.abs(num[1]-num[0]+num[2]-num[1]));
        
        
    }

}


Measured memory_bytes: 22740
#include <stdio.h>
int main(){
    int a,b,c,d,i=0;
     scanf("%d%d%d%d",&a,&b,&c,&d);
     while(a>0&&c>0){
      if(i%2!=0){
        a=a-d;
        i++;
      }
      else{
        c=c-b;
        i++;
      }
     }
      if(a<=0){
        printf("No\n");
      }
     else {
      printf("Yes\n");
     }
    return 0;
}


Measured memory_bytes: 2052
from sys import exit
#import copy
#import numpy as np
#from collections import deque

n, = map(int, input().split())

tmp = n

alpha = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l",
         "m", "n", "o", "p", " q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

ans = []
gun = 0
for l in range(1, 13):
    if gun < tmp <= gun+26 ** l:
        kou = tmp - gun-1
        for k in range(l):
            ans.append(kou % 26)
            kou = kou // 26
        break
    else:
        gun += 26 ** l


s = ""
for i in ans[::-1]:
    s += alpha[i]

print(s)


Measured memory_bytes: 61964
#include <stdio.h>

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

  int H[20];
  scanf("%d", &H[0]);
  int X = 1;
  int M = H[0];
  for(int i = 1; i < N; i++) {
    scanf("%d", &H[i]);
    if(H[i] >= M) {
      X++;
      M = H[i];
    }
  }

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


Measured memory_bytes: 128
import qualified Data.Set as S 

main = do
 getLine
 as <- map read . words <$> getLine
 let likeTo = S.fromDistinctAscList (zip [1..] as)
 let likeFrom = S.fromList (zip as [1..])
 print $ S.size (S.intersection likeTo likeFrom) `div` 2

Measured memory_bytes: 70012
import numpy as np
N,M,C = map(int,input().split())
B = np.array(list(map(int,input().split())))
A = []
for i in range(N):
  A.append(list(map(int,input().split())))
A = np.array(A)
print(sum(x+C>0 for x in sum((B*A).T)))

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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long
#define ld long double

const int INF = 2e9 + 1;
const ll INFLL = 1e18 + 1;
const int mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k, c;
    cin >> n >> k >> c;
    vector<int> ans;
    string s;
    cin >> s;
    vector<int> a;
    for (int i = 0; i < n; i++) if (s[i] == 'o') a.pb(i);
    n = a.size();
    vector<int> dp(n);
    for (int i = n - 1; i >= 0; i--) {
        int ind = upper_bound(all(a), a[i] + c) - a.begin();
        dp[i] = 1 + (ind < n ? dp[ind] : 0);
    }
    if (n > 1 && dp[1] < k) ans.pb(a[0]);
    if (n == 1) ans.pb(a[0]);
    int cur = 1, last = a[0];
    for (int i = 1; i < n; i++) {
        int ind = upper_bound(all(a), last + c) - a.begin();
        ind = max(ind, i + 1);
        if (cur + (ind < n ? dp[ind] : 0) < k) ans.pb(a[i]);
        if (a[i] > last + c) {
            cur++;
            last = a[i];
        }
    }
    for (auto &c : ans) cout << c + 1 << "\n";
    return 0;
}


Measured memory_bytes: 6476
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    string n;
    cin >> N;
 
    n = to_string(N);

    if (n[0] == '7' || n[1] == '7' || n[2] == '7') {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


  	return 0;
}


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

int main() {
    string S;
    cin >> S;

    string former = "";
    former = former + S[0] + S[1];
    string later = "";
    later = later + S[2] + S[3];

    int f = atoi(former.c_str());
    int l = atoi(later.c_str());
    bool yymm = false;
    bool mmyy = false;

    if(f >= 1 && f <= 12){
        mmyy = true;
    }
    if(l >= 1 && l <= 12){
        yymm = true;
    }

    if(mmyy && yymm){
        cout << "AMBIGUOUS" << endl;
    }
    else if(mmyy){
        cout << "MMYY" << endl;
    }
    else if(yymm){
        cout << "YYMM" << endl;
    }
    else{
        cout << "NA" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int x,y;
	while(cin>>x){
		cin>>y;
		if(x==0&&y==0)break;

		if(x < y ){
			cout << x << " " << y << endl;
		}else{
			cout << y << " " << x << endl;
		}
	}
return 0;
}

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

int main()
{
	int n, m;
	cin >> n >> m;
	priority_queue<int> q;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		q.push(a);
	}
	for (int i = 0; i < m; i++)
	{
		int a = q.top();
		q.pop();
		q.push(a/2);
	}
	ll ans = 0;
	for (int i = 0; i < n; i++)
	{
		ans += q.top();
		q.pop();
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>


using namespace std;


long long int gcd(long long int a, long long int b) {

	long long int tmp;

	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r;

	r = a % b;

	while (r != 0) {

		a = b;
		b = r;
		r = a % b;

	}

	return b;
}





int main()
{

	int n;
	cin >> n;

	int wk;
	bool iro[8] = { false };
	int any = 0;
	for (int i = 0; i < n; i++) {
		cin >> wk;

		wk /= 400;

		if (wk >= 8) {
			any++;
			continue;
		}

		iro[wk] = true;

	}

	int wkans = 0;
	int minans = 0;
	int maxans;

	for (int i = 0; i < 8; i++) {
		if (iro[i])wkans++;
	}

	minans = max(1, wkans);
	maxans = wkans + any;

	cout << minans << " " << maxans << endl;

	return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,k;
  cin >> n >> k;
  vector<bool> j(n+1);
  for (int i=0; i<k; i++) {
    int t;
    cin >> t;
    for (int i=0; i<t; i++) {
      int q;
      cin >> q;
      j.at(q) = true;
    }
  }
  int a=0;
  for (int i=1; i<=n; i++) {
    if (j.at(i) == false) {
      a++;
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];
    for(int i = 0; i < n; ++i)  cin >> b[i];
    for(int i = 0; i < n; ++i)  cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    vector<ll> cnt(n+1, 0);
    for(int i = 0; i < n; ++i)  cnt[i+1] = c.end() - upper_bound(c.begin(), c.end(), b[i]);
    for(int i = 0; i < n; ++i)  cnt[i+1] += cnt[i];
    ll res = 0;
    for(int i = 0; i < n; ++i){
        int pos = upper_bound(b.begin(), b.end(), a[i]) - b.begin();
        res += cnt[n] - cnt[pos];
    }
    cout << res << endl;
}

Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cstdio>
#include <bitset>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <functional>
#include <stack>
#include <cmath>
#include <string>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
using ll = long long;

inline bool bit(ll x, int b) { return (x >> b) & 1; }

constexpr int SZ = 100000;
constexpr int prs = 10;
ll pre[1 << prs][SZ + 1];

int main() {
  int N;
  cin >> N;
  vector<int> V(N + 1), W(N + 1);
  REP(i, N) cin >> V[i + 1] >> W[i + 1];
  FOR(i, 1, min(N + 1, 1 << prs)) {
    if (i != 1) copy(pre[i / 2], pre[i / 2] + SZ + 1, pre[i]);
    for (int j = SZ; j >= W[i]; --j)
      pre[i][j] = max(pre[i][j], pre[i][j - W[i]] + V[i]);
    REP(j, SZ) pre[i][j + 1] = max(pre[i][j + 1], pre[i][j]);
  }
  int Q;
  cin >> Q;
  while (Q--) {
    int v, L;
    cin >> v >> L;
    if (v < (1 << prs)) {
      cout << pre[v][L] << "\n";
    } else {
      int bi = 32 - __builtin_clz(v) - prs;
      ll ans = 0;
      REP(b, 1 << bi) {
        int w = 0;
        ll va = 0;
        REP(i, bi) {
          if (bit(b, i)) {
            w += W[v >> i];
            va += V[v >> i];
          }
          if (w > L) break;
        }
        if (w <= L) ans = max(ans, pre[v >> bi][L - w] + va);
      }
      cout << ans << "\n";
    }
  }
  return 0;
}


Measured memory_bytes: 804400
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    if(n==m){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 22996
import sys
from collections import defaultdict as dd
from bisect import bisect_left as bl
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
b = a[: ]
res = 0
for i in range(N): b[i] -= i
d = dd(list)
for i in range(N): d[b[i]].append(i)
for i in range(N):
  x = b[i] + i * 2
  j = bl(d[-x], i)
  res += len(d[-x]) - j
print(res)

Measured memory_bytes: 134988
#include <iostream>
#include <string>
#include <cmath>
#include<iomanip>
#include<algorithm>
#include<list>
using namespace std;

int main()
{
	int tmp, x, y;
	cin >> x >> y;
	while (true){
		if (x < y){
			tmp = x;
			x = y;
			y = tmp;
		}
		if (x % y == 0){
			cout << y << endl;
			break;
		}
		else{
			x = x % y;
		}
	}
	

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(void){
    int N;cin>>N;
    vector<ll>V0(N);vector<ll>V1(N);for(int i=0;i<N;i++){cin>>V0[i];V1[i]=V0[i];}
    //V0は正負V1は負正
    ll count0=0;ll count1=0;ll sum0=0;ll sum1=0;
    for(int i=0;i<N;i++){
        if(i%2==1){
            if(sum0+V0[i]>=0){count0+=V0[i]-(-1-sum0);V0[i]=-1-sum0;}
            if(sum1+V1[i]<=0){count1+=(1-sum1)-V1[i];V1[i]=1-sum1;}
            sum0+=V0[i];sum1+=V1[i];
        }
        if(i%2==0){
            if(sum0+V0[i]<=0){count0+=(1-sum0)-V0[i];V0[i]=1-sum0;}
            if(sum1+V1[i]>=0){count1+=V1[i]-(-1-sum1);V1[i]=-1-sum1;}
            sum0+=V0[i];sum1+=V1[i];
        }
    }
    cout<<min(count0,count1)<<endl;
}

Measured memory_bytes: 1792
/**

author:	©LoneWolfDON
Git: MahinHossainMunna

**/
/*

*/

#include <stdio.h>
#include <string.h>

int main()
{
    char S[1001], T[1001], c[1001];

    gets(S);
    gets(T);

    T[strlen(T)-1] = 0;

    //puts(temp);
    if(strcmp(S,T) == 0)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 1492
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	int x, y;
	cin >> x >> y;
	int sum = 0;
	if (x == 1) {
		sum += 300000;
	}
	if (x == 2) {
		sum += 200000;
	}
	if(x==3){
		sum += 100000;
	}
	if (y == 1) {
		sum += 300000;
	}
	if (y == 2) {
		sum += 200000;
	}
	if (y==3){
		sum += 100000;
	}
	else {
		sum += 0;
	}
	if (x == 1 && y == 1) {
		sum += 400000;
	}

	cout << sum << endl;
	


	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    ll x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x);
    vector<ll> b(y);
    vector<ll> c(z);
    REP(i,x) cin >> a[i];
    REP(i,y) cin >> b[i];
    REP(i,z) cin >> c[i];
    sort(a.begin(), a.end(), greater<>());
    sort(b.begin(), b.end(), greater<>());
    sort(c.begin(), c.end(), greater<>());
    vector<ll> AB;
    REP(i,x) {
        REP(j,y) {
            AB.push_back(a[i]+b[j]);
        }
    }
    sort(AB.begin(), AB.end(), greater<>());
    ll q = min((int)AB.size(), 5000);
    vector<ll> ans;
    REP(i,q) {
        REP(j,z) {
            ans.push_back(AB[i]+c[j]);
        }
    }
    sort(ans.begin(), ans.end(), greater<>());
    REP(i,k) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 76132
#include <cstdio>
#include <set>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>

using namespace std;

#define ll long long
#define ld long double
#define M_PI 3.14159265358979323846264338327950288
const ll N = 1000000007;

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

void fix(ll &a, ll &b) {
    if (a <= 0 && b <= 0) {
        a = -a;
        b = -b;
    }
    if (b < 0 && a > 0) {
        a = -a;
        b = -b;
    }
}

void solve() {
    ll n;
    cin >> n;

    map<pair<ll, ll> , int> pos;
    ll ans = 0, a, b, pr = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a; cin >> b;
        if (a == 0 && b == 0) {
            ++pr;
            continue;
        }
        
        ll d = gcd(abs(a), abs(b));
        a /= d;
        b /= d;
        fix(a, b);

        pair<ll, ll> val = make_pair(a, b);

        if (pos.find(val) == pos.end()) pos[val] = 1;
        else ++pos[val];
    }

    ll step[n + 1];
    ll tec = 1;
    for (int i = 0; i <= n; ++i) {
        step[i] = (tec - 1 + N) % N;
        tec = (tec * 2) % N;
    }

    for (auto& it : pos) {
        auto val = it.first;
        val.first = -it.first.second, val.second = it.first.first;
        fix(val.first, val.second);

        ans = ans * (step[it.second] + step[pos[val]] + 1) % N;
        ans = (ans + step[it.second] + step[pos[val]]) % N;
        pos[val] = 0;
        it.second = 0;
    }


    cout << ans + pr << endl;
}

int main(){
    int t;
    t = 1;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 30056
def solve(N):
    A = list(map(int, input().split()))
    ans = 1e9
    for i in range(N):
        for j in range(N):
            if i != j:
                d = abs(A[i] - A[j])
                if ans > d:
                    ans = d
    print(ans)

while True:
    N = int(input())
    if N > 0:
        solve(N)
    else:
        break

Measured memory_bytes: 7764