akhauriyash/Code-Regression huggingface dataset:
function main(){
  var i = 0;
  while(true){
    var fieldInfo = input[i].split(' ');
    var width = fieldInfo[0] - 0;
    var height = fieldInfo[1] - 0;
          
    if(!width && !height){
      break;
    }
          
    var start;
    var goal;
    var elem = [[],[],[],[],[]];
    var c;
    for(var y = height; y--;){
      i++;
      var ni = input[i];
      for(var x = 0; x < width; x++){
        c = ni[x];
        
        if(c === '.'){
        }else if(c === '1' || c === '2' || c === '3' || c === '4' || c === '5'){
          var e = elem[c - 1];
          e[e.length] = pos(x, y);
        }else if(c === 'S'){
          start = pos(x, y);
        }else{
          goal = pos(x, y);
        }
          
      }
    }
          
    var INF = 1 << 30;
    var bestElement = -1;
    var distance = INF;
    
    for (var startElem = 0; startElem < 5; startElem++) {
      
      var dp = [[],[],[],[],[]];
      for(var h = 0; h < 5; h++){
        var hLength = elem[h].length;
        var initdph = dp[h];
        initdph.length = hLength;
        for(var hidx = 0; hidx < hLength; hidx++){
          initdph[hidx] = INF;
        }
      }
      
      var first = (startElem + 1) % 5;
      var firstLength = elem[first].length;
      var dpf = dp[first];
      var elemf = elem[first];
      for (var j = 0; j < firstLength; j++) {
        dpf[j] = dist(start, elemf[j]);
      }
      
      for (var e = 0; e < 3; e++) {
        var now = (first + e) % 5;
        var next = (now + 1) % 5;
        var dpnw = dp[now];
        var dpnx = dp[next];
        var elnw = elem[now];
        var elnx = elem[next];
        var nowLength = elnw.length;
        var nextLength = elnx.length;
        for (var j = 0; j < nowLength; j++) {
          var dpnwj = dpnw[j];
          var elnwj = elnw[j];
          for (var k = 0; k < nextLength; k++) {
            dpnx[k] = min(
              dpnx[k],
              dpnwj + 
                  dist(elnwj, elnx[k]));
          }
        }
      }

      var last = (first + 3) % 5;
      var lastLength = elem[last].length;
      var dpl = dp[last];
      var ell = elem[last];
      for (var j = 0; j < lastLength; j++) {
        var d = dpl[j] + dist(ell[j], goal);
        if (d < distance) {
          distance = d;
          bestElement = startElem + 1;
        }
                  
      }
                
    }
              
    if (distance == INF) {
      console.log("NA");
    } else {
      console.log(bestElement + " " + distance);
    }
          
    i++;
  }
            
          
}
          
function dist(from, to){
  return abs((from >> 11) - (to >> 11)) + abs((from & 2047) - (to & 2047));
}
          
function min(a, b){
  var t = a - b;
 return b + (t & (t >> 31));
}
          
function pos(a, b){
  return (a << 11) + b;
}
         
function abs(a){
 var mask = a >> 31;
 return (a ^ mask) - mask;
}
          
var
input = '';
          
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 51444
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const double INF = 1e9;

struct edge{int to,cost;};
typedef pair<int,int> P;//firstは最短距離,secondは頂点番号

#define MAX_V 21
int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s){
	priority_queue<P,vector<P>,greater<P> > que;
	fill(d,d+V,INF);
	d[s]=0;
	que.push(P(0,s));
	
	while(!que.empty()){
		P p=que.top();que.pop();//仮の最短距離が短い順に取り出す
		int v=p.second;
		if(d[v]<p.first)continue;
		REP(i,G[v].size()){
			edge e=G[v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				que.push(P(d[e.to],e.to));//仮の最短距離と頂点の組を更新が行われる度に追加していく
			}
		}
	}
}

int main(){
	cin>>V;
	int m;
	cin>>m;
	char c;
	REP(i,m){
		edge e1,e2;
		int a,b;
		cin>>a>>c>>b>>c>>e1.cost>>c>>e2.cost;
		a--;b--;
		e1.to=b;e2.to=a;
		G[a].PB(e1);
		G[b].PB(e2);
	}
	int x1,x2,y1,y2;
	cin>>x1>>c>>x2>>c>>y1>>c>>y2;
	x1--;x2--;
	dijkstra(x1);
	int sum=d[x2];
	dijkstra(x2);
	sum+=d[x1];
	cout<<y1-sum-y2<<endl;
	return 0;
}

Measured memory_bytes: 1220
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    static int abs(int a) {
        return Math.abs(a);
    }
    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String line[] = bf.readLine().split("\\s");
        int n = Integer.parseInt(line[0]);
        int k = Integer.parseInt(line[1]);
        int ar [] =  new int[n];
        line = bf.readLine().split("\\s");
        for(int i=0;i<n;++i) {
            ar[i] = Integer.parseInt(line[i]);
        }
        int[]dp = new int[n];
        dp[0] = 0;
        dp[1] = abs(ar[1]-ar[0]);
        for(int i=2;i<n;i++) {
            int mini = Integer.MAX_VALUE;;
            int j = Math.max(0, i-k);
            for(;j<i;j++)
            {
                int ab1 = abs(ar[i] - ar[j]);
                mini = Math.min(mini, dp[j] + ab1);
            }
            dp[i] = mini;
        }
        System.out.println(dp[n-1]);
    }
}

Measured memory_bytes: 36072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using piii = pair<pair<int, int>, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

struct Binomial {
    int siz;
    vector<ll> inv, fac, finv;
    Binomial(int N) : siz(N + 2), inv(siz), fac(siz), finv(siz) {
        inv[1] = 1;
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        for (int i = 2; i < siz; ++i) {
            inv[i] = MOD - (MOD / i * inv[MOD % i]) % MOD;
            fac[i] = fac[i - 1] * i % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

    ll calc(int a, int b) {
        return (fac[a] * finv[b] % MOD) * finv[a - b] % MOD;
    }
};

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

    int H, W, A, B;
    cin >> H >> W >> A >> B;

    Binomial bin(H + W);

    ll ans = 0;
    for (int i = B + 1; i <= W; ++i) {
        ans += bin.calc(H - A + i - 2, i - 1) * bin.calc(A + W - i - 1, A - 1) % MOD;
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    vint a(3);
    int k;
    cin >> a[0] >> a[1] >> a[2] >> k;
    sort(ALL(a));

    rep(i, k)
    {
        a[2] *= 2;
    }
    cout << accumulate(ALL(a), 0) << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
// Problem : C - H and V
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_c
// Memory Limit : 1024 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef unordered_map<ll,ll> umll;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define tc ll tests;cin>>tests;while(tests--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007
#define INF LLONG_MAX/2

using namespace std;
 
#define endl '\n'
 
int h,w,k;
vector <string> grid;
bool check(int r,int c){
  int cnt = 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(r & (1 << i) || c & (1 << j))
          continue;
        if(grid[i][j] == '#')
          cnt++;
      }
    }
    return cnt == k;
}
 
int main(){
 
  ios_base :: sync_with_stdio(false);
  cin.tie(NULL);
 
  cin >> h >> w >> k;
 
  grid.resize(h);
 
  for(int i=0;i<h;i++)
    cin >> grid[i];
 
  int ans  =0;
  for(int r=0;r<(1<<h);r++){
    for(int c=0;c<(1<<w);c++){
      if(check(r,c))
        ans++;
    }
  }
 
  cout << ans << endl;
 
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    if(N%10==3){
    cout<<"bon"<<endl;}
    else if(N%10==0||N%10==1||N%10==6||N%10==8)
    cout<<"pon"<<endl;
    else
    cout<<"hon"<<endl;
  return 0;
    }


Measured memory_bytes: 3636
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int T = sc.nextInt();

		long sum = 0;
		for (int i = A; i < T + 0.5; i += A) {
			sum += B;
		}

		System.out.println(sum);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Pair {
		private int A;
		private int B;

		public Pair(int a, int b) {
			super();
			A = a;
			B = b;
		}

		public int getA() {
			return A;
		}

		public int getB() {
			return B;
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 21716
using System;
using System.Collections.Generic;
class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int n, q;
        n = int.Parse(s[0]);
        q = int.Parse(s[1]);
        Queue<string> name = new Queue<string>();
        Queue<int> time = new Queue<int>();
        for (int i = 0; i < n; i++)
        {
            s = Console.ReadLine().Split(' ');
            name.Enqueue(s[0]);
            time.Enqueue(int.Parse(s[1]));
        }
        int t = 0;
        while (name.Count != 0)
        {
            if (time.Peek() <= q)
            {
                t += time.Dequeue();
                Console.WriteLine("{0} {1}", name.Dequeue(), t);
            }
            else
            {
                t += q;
                time.Enqueue(time.Dequeue() - q);
                name.Enqueue(name.Dequeue());
            }
        }
    }
}


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    int N; ll M; cin >> N >> M;
    ll A[N+1]; rep(i, N) cin >> A[i+1];
    A[0] = 0;
    //区間l,rを選択した時にM人に均等に配れる <=> A[l]からA[r]までの和(S[r]-S[l-1])がMの倍数
    //累積和の配列をSとする. 二項関係~をx~y when x modM = y modM と定義するとx~yはZ上の同値関係
    //S[r]-S[l-1] ~ 0 <=> S[r] ~ S[l-1]
    //累積和配列SをmodMとりながら作ってソートして、同じ数字がk個続いたらkC2 = (k-1)k/2加算
    ll ruiseki[N+1]; ruiseki[0] = A[0] % M;
    for(int i = 1; i <= N; i++){
        ruiseki[i] = (ruiseki[i-1] + A[i]) % M;
    }
    sort(ruiseki, ruiseki+(N+1));
    ll row = 1;
    ll ans = 0;
    for(int i = 1; i <= N; i++){
        if(ruiseki[i] == ruiseki[i-1]) row++;
        else{
            ans += row*(row-1)/2;
            row = 1;
        }
    }
    ans += row*(row-1)/2;
    cout << ans  << endl;
    return 0;
}

void solve(){}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll dp[100005][3];

void Main() {
    int N;
    cin >> N;
    vector<vector<int>> items;
    rep(i, N) {
        int a, b, c;
        cin >> a >> b >> c;
        items.push_back(vector<int> {a, b, c});
    }

    rep(i, N) {
        rep(j, 3) {
            rep(k, 3) {
                if (j == k) continue;
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + items[i][k]);
            }
        }
    }
    cout << max({dp[N][0], dp[N][1], dp[N][2]}) << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 8752
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#include <atcoder/all>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

int bmap[101][101] = {};

int idx(int i, int j, int n, int m)
{
	(void)m;
	return j * n + i;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n, m; cin >> n >> m;

	atcoder::mf_graph<int> mfg(n * m + 2);
	FOR_LT(i, 0, n) {
		string s; cin >> s;
		FOR_LT(j, 0, m) {
			if (s[j] == '#') bmap[i][j] = 1;
		}
	}

	FOR_LT(i, 0, n) {
		FOR_LT(j, 0, m) {
			if (bmap[i][j] == 1) continue;
			if (i != n - 1 && bmap[i + 1][j] != 1) {
				int idx1 = idx(i, j, n, m);
				int idx2 = idx(i + 1, j, n, m);
				if ((i + j) & 1) {
					mfg.add_edge(idx1, idx2, 1);
				}
				else {
					mfg.add_edge(idx2, idx1, 1);
				}
			}
			if (j != m - 1 && bmap[i][j + 1] != 1) {
				int idx1 = idx(i, j, n, m);
				int idx2 = idx(i, j + 1, n, m);
				if ((i + j) & 1) {
					mfg.add_edge(idx1, idx2, 1);
				}
				else {
					mfg.add_edge(idx2, idx1, 1);
				}
			}
		}
	}

	FOR_LT(i, 0, n) {
		FOR_LT(j, 0, m) {
			if ((i + j) & 1) mfg.add_edge(n * m, idx(i, j, n, m), 1);
			else mfg.add_edge(idx(i, j, n, m), n * m + 1, 1);
		}
	}
	int ans = mfg.flow(n*m, n*m + 1);
	cout << ans << endl;

	auto edges = mfg.edges();
	for (auto& edge : edges) {
		int idx1 = edge.from;
		int idx2 = edge.to;
		if (edge.flow == 0) continue;
		if (idx1 > idx2) swap(idx1, idx2);
		if (idx2 == n * m) continue;
		if (idx2 == n * m + 1) continue;

		int i1 = idx1 % n;
		int j1 = idx1 / n;
		int i2 = idx2 % n;
		int j2 = idx2 / n;
		assert(i1 == i2 || j1 == j2);
		assert(!(i1 == i2 && j1 == j2));
		if (i1 != i2) {
			bmap[i1][j1] = 2;
			bmap[i2][j2] = 3;
		}
		if (j1 != j2) {
			bmap[i1][j1] = 4;
			bmap[i2][j2] = 5;
		}
	}
	FOR_LT(i, 0, n) {
		FOR_LT(j, 0, m) {
			switch (bmap[i][j]) {
			case 0:
				cout << "."; break;
			case 1:
				cout << "#"; break;
			case 2:
				cout << "v"; break;
			case 3:
				cout << "^"; break;
			case 4:
				cout << ">"; break;
			case 5:
				cout << "<"; break;
			}
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 5584
n, m, c = list(map(int, input().split()))
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for i in range(n):
    s = c
    for j, k in zip(a[i], b):
        s += j * k
    if s > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3064
import math

n = int(input())
ans = [0] * 10001
for x in range(1, int(math.sqrt(n+1))):
    for y in range(1, int(math.sqrt(n+1))):
        for z in range(1, int(math.sqrt(n+1))):
            t = x**2+y**2+z**2+x*y+y*z+z*x
            if t <= n:
                ans[t] += 1
for i in range(1, n+1):
    print(ans[i])

Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N,D,X;
    cin>>N>>D>>X;
    vector<int> A(N);
    rep(n,0,N) cin>>A.at(n);

    uint64_t choco=X;
    for(auto a:A){
        uint64_t d=1;
        while(d<=D){
            choco++;
            d+=a;
        }
    }

    cout<<choco<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
using namespace std;
int main(){
  long long n;
  cin >> n;
  string s;
  cin >> s;
  vector <int> r(n);
  vector <int> g(n);
  vector <int> b(n);
  int R = 0;
  int G = 0;
  int B = 0;
  for (int i = n-1; i > -1; i--){
    r.at(i) = R; g.at(i) = G; b.at(i) = B;
    if (s.at(i) == 'R'){R++;}
    if (s.at(i) == 'G'){G++;}
    if (s.at(i) == 'B'){B++;}
  }
  long long ans = 0;
  for (int i = 0; i < n-2; i++){
    for (int j = i+1 ;j < n-1; j++){
      if ((s.at(i) == 'R' && s.at(j) == 'G') || (s.at(i) == 'G' && s.at(j)=='R')){
        ans += b.at(j);
        if (2*j - i < n){if (s.at(2*j-i) == 'B'){ans -= 1;}}
      }
      if ((s.at(i) == 'G' && s.at(j) == 'B') || (s.at(i) == 'B' && s.at(j) =='G')){
        ans += r.at(j);
        if (2*j - i < n){if (s.at(2*j-i) == 'R'){ans -= 1;}}
      }
      if ((s.at(i) == 'B' && s.at(j) == 'R') || (s.at(i) == 'R' && s.at(j) =='B')){
        ans += g.at(j);
        if (2*j -i < n){if (s.at(2*j-i) == 'G'){ans -= 1;}}
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3584
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())
u = UnionFind(n)
for _ in range(m):
    a, b = map(int, input().split())
    u.union(a - 1, b - 1)
print(max(u.size(i) for i in range(n)))


Measured memory_bytes: 14436
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,n,x;
    cin>>h>>n;
    if((h%n)>0)
    {
        x=(h/n)+1;
        cout<<x<<endl;
    }
     else
        cout<<h/n<<endl;
     return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

from collections import Counter

c = Counter(a)

if c[0] > 0:
    if len(c) == 1:
        bl = True
    else:
        if len(c) > 2:
            bl = False
        else:
            bl = (n == 3 * c[0])
else:
    se = set(c.keys())
    if len(se) != 3:
        bl = False
    else:
        bl = True
        xor = 0
        for key in se:
            xor ^= key
            if c[key] * 3 != n:
                bl = False
        if xor != 0:
            bl = False

print('Yes') if bl else print('No')

Measured memory_bytes: 60784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
 

int main(){
  	char c;
	cin>>c;
  	if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o')cout<<"vowel"<<endl;
  	else cout<<"consonant"<<endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<ll, ll>> stu(N);
  vector<pair<ll, ll>> cp(M);
  for (int i = 0; i < N; i++) {
    ll a, b;
    cin >> a >> b;
    stu[i] = make_pair(a, b);
  }
  for (int i = 0; i < M; i++) {
    ll c, d;
    cin >> c >> d;
    cp[i] = make_pair(c, d);
  }
  for (int i = 0; i < N; i++) {
    vector<pair<ll, ll>> ans;
    ll sx = stu[i].first;
    ll sy = stu[i].second;
    for (int j = 0; j < M; j++) {
      ll cx = cp[j].first;
      ll cy = cp[j].second;
      ans.push_back(make_pair(abs(cx-sx) + abs(cy-sy), j+1));
    }
    sort(ans.begin(), ans.end());
    cout << ans[0].second << endl;
  }
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
mae=a[0]-1
ans=b[mae]#満足度
for i in range(1,n):
    if a[i]-mae==2:
        ans+=c[mae]
    mae=a[i]-1
    ans+=b[mae]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x;
    cin>>x;
    if(x==0)
        cout<<1<<endl;
    else
        cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
bool isPrime (long long int);


void solve(){
   
   long long int number, i;
    cin>>number; 
    for (i=number; !isPrime(i);i++);
    cout<<i;
   
   
   }


int main() {
    solve();
    return 0;
}

bool isPrime (long long int a)
{
    int counter=0;
    for (int i=2; i<=a/2; i++)
    if (a%i==0)
    counter++;
    
    if (counter==0)
    return true;
    else
    return false;
}


Measured memory_bytes: 256
from math import sqrt

def dist(x1, x2):
    l = 0
    for i in range(len(x1)):
        l += (x1[i]- x2[i])**2
    return sqrt(l)

N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N):
    for j in range(i+1, N):
        d = dist(X[i], X[j])
        if int(d) == d:
            ans += 1
print(ans)

Measured memory_bytes: 3064
def merge(A, left, mid, right):
    global cnt
    inf = 10 ** 9
    L = A[left:mid] + [inf]
    R = A[mid:right] + [inf]

    i = 0
    j = 0
    for k in range(left, right):
        cnt += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1


def mergeSort(A, left, right):
    if left+1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)


n = int(input())
A = list(map(int, input().split()))
cnt = 0
mergeSort(A, 0, n)

print(' '.join(str(a) for a in A))
print(cnt)



Measured memory_bytes: 66776
/*---------------------------------

 @Author:   Dicer
 @DateTime: 2019-05-12 10:58:30

---------------------------------*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;

int c[MAXN], v[MAXN];
int main(int argc, char const *argv[])
{
	int sum = 0;
	int n;
	cin >> n;
	for(int i = 1; i <= n; ++i)	cin >> v[i];
	for(int i = 1; i <= n; ++i){
		cin >> c[i];
		sum += max(0, v[i]-c[i]);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main( void )
{
	int middle, term_end, retry, total_score;
	const int absence = -1;
	const int record_A = 80;
	const int record_B = 65;
	const int record_C = 50;
	const int record_D = 30;
	
	while(1)
	{
		middle = 0;
		term_end = 0;
		retry = 0;
		total_score = 0;
		
		scanf( "%d %d %d", &middle, &term_end, &retry );
		if( middle == -1 && term_end == -1 && retry == -1 )
		{
			break;
		}else
		{
			total_score = middle + term_end;
			
			if( middle == absence || term_end == absence || total_score < record_D )
			{
				printf( "F\n" );
			}else
			if( total_score >= record_A )
			{
				printf( "A\n" );
			}else
			if( total_score >= record_B && total_score < record_A )
			{
				printf( "B\n" );
			}else
			if( total_score >= record_C && total_score < record_B )
			{
				printf( "C\n" );
			}else
			if( total_score >= record_D && total_score < record_C )
			{
				if( retry >= record_C )
				{
					printf( "C\n" );
				}else
				{
					printf( "D\n" );
				}
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
using namespace std;
int main(void){
    int W,H,x,y,r;    
    cin>>W>>H>>x>>y>>r;    
    if(x-r < 0 || y-r < 0 || W < x+r || H < y+r){       
        cout<<"No"<<endl;   
        }   
        else{       
            cout<<"Yes"<<endl;   
        }   
        return 0;
    
}



Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

//-------------------------------------------------------------------
struct segtree{
  ll M=1, INF = 1000000000000000000, INIT;
  vector<vll> dat;
  segtree(ll N, ll num){
    INIT = num;
    while(M<N) M*=2;
    dat.resize(M*2-1, vll{num, -1});
  }
  void update(ll x, ll k, ll l=0, ll r=-1){
    if(r==-1) r = M;
    k+=M-1;
    dat[k] = vll{x, k-(M-1)};
    while(k>0) {
      k = (k-1)/2;
      dat[k] = min(dat[k*2+1], dat[k*2+2]);
    }
  }
  vll query(ll a, ll b=-1, ll k=0, ll l=0, ll r=-1){
    if(r==-1) r = M;
    if(b==-1) b = M;
    if(r<=a || b<=l) return vll{INIT, -INIT};
    if(a<=l && r<=b) return dat[k];
    vll A = query(a, b, k*2+1, l, (l+r)/2);
    vll B = query(a, b, k*2+2, (l+r)/2, r);
    return min(A, B);
  }
};
//-------------------------------------------------------------------

vll pre(100002, -1);
int main(int argc, char const *argv[]) {
  ll n, m, INF=10000000000;std::cin >> n >> m;
  string s;std::cin >> s;
  segtree seg(n+1, INF);
  seg.update(0, n);
  for(int i=n-1;i>=0;i--){
    vll q = seg.query(i+1, min(n+1, i+m+1));
    if(q[0]==INF||s[i]=='1') continue;
    seg.update(q[0]+1, i);
    pre[i] = q[1];
  }
  ll ans = seg.query(0, 1)[0];
  if(ans==INF){
    std::cout << -1 << '\n';
    return 0;
  }
  ll now = 0, p = -1;
  vll a;
  while(now!=-1){
    p = now;
    now = pre[now];
    if(now!=-1) a.push_back(now - p);
  }
  re(i, a.size()) std::cout << a[i] << (i==a.size()-1?"\n":" ");
  return 0;
}


Measured memory_bytes: 16572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
#define vecmin(A) *min_element(A.begin(),A.end())
#define vecmax(A) *max_element(A.begin(),A.end())
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<int> a(n),b(n),c(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n) cin >> c[i];
  sort(a);
  sort(b);
  sort(c);
  ll ans = 0;
  rep(i,n){
    int apart = lower_bound(a.begin(),a.end(),b[i])-a.begin();
    int cpart = c.end() - upper_bound(c.begin(),c.end(),b[i]);
    ans += (ll)apart*cpart;
  }
 cout << ans << endl; 
}


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

#define int ll

#define pb push_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

const int MAX = 1E3;

int32_t main() {
	int x;
	cin >> x;
	for(int i = -MAX; i <= MAX; i++) {
		for(int j = -MAX; j <= MAX; j++) {
			if(pow(i, 5) - pow(j, 5) == x) {
				cout << i << ' ' << j << '\n';
				cerr << get_time();
				return 0;
			}
		}
	}
	assert(false);
}


Measured memory_bytes: 4236
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
i = 1
s = 0
for i in range(N + 1):
    if not (i % 3 == 0 or i % 5 == 0):
        s += i

print(s)


Measured memory_bytes: 27156
#include<stdio.h>

int main(){
    int N;
    double k = 0;
    double a = 0;
    scanf("%d",&N);

    for(int i = 0; i < N; i++){
        if((i % 2) == 0)k += 1;
    }
    a = (double)k/N;
    printf("%lf",a);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

i64 gcd(i64 A, i64 B) {
  if(B > A) swap(A, B);
  i64 r = A % B;
  if(r == 0) {
    return B;
  }
  return gcd(B, r);
}

int main(int argc, char *argv[]) {

  i64 A, B;
  cin >> A >> B;
  cout << A * B / gcd(A,B) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main(int argc, char const *argv[])
{
    int a,b;

    std::cin >> a >> b;
    if(b > a){
        int tmp = a;
        a = b;
        b = tmp;
    }


    while(1){
        if(b != 0){
            int tmp = b;
            b = a % b;
            a = tmp;
        }
        else break;
    }

    std::cout << a << std::endl;

    return 0;
}



Measured memory_bytes: 3100
#include <stdio.h>


int main(void)
{
    int x[6],i;
    for (i = 1; i <= 5; i++)
    {
        scanf("%d", &x[i]);
    }
    for (i = 1; i <= 5; i++)
    {
        if (x[i] == 0)
        {
            printf("%d\n", i);
            return 0;
        }
    }
    
    
    return 0;
}
	





Measured memory_bytes: 1732
#!/usr/bin/env python3
import sys
from collections import Counter
INF = float("inf")

MOD = 1000000007  # type: int


class Combination(object):
    def __init__(self, N, mod):
        self.N = N
        self.MOD = mod
        self.fac = [0] * (N+1)
        self.finv = [0] * (N+1)
        self.inv = [0] * (N+1)
        self.cmb_init()

    def cmb_init(self):
        self.fac[0] = 1
        self.fac[1] = 1
        self.finv[0] = 1
        self.finv[1] = 1
        self.inv[1] = 1
        for i in range(2, self.N+1):
            self.fac[i] = self.fac[i-1]*i % self.MOD
            self.inv[i] = -self.inv[self.MOD % i]*(self.MOD//i) % self.MOD
            self.finv[i] = self.finv[i-1]*self.inv[i] % self.MOD

    def __call__(self, n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return self.fac[n] * (self.finv[k]*self.finv[n-k] % self.MOD) % self.MOD


def solve(n: int, a: "List[int]"):
    (m, _), = Counter(a).most_common(1)
    left = a.index(m)
    right = a.index(m, left+1)
    cmb = Combination(n+1, MOD)
    for i in range(1, n+2):
        print((cmb(n+1, i)-cmb(n-right+left, i-1)) % MOD)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(n+1)]  # type: "List[int]"
    solve(n, a)


if __name__ == '__main__':
    main()


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

typedef long long ll;
#define nl "\n"
#define ff first
#define ss second
#define mod 1e9+7
#define lb lower_bound
#define ub upper_bound
#define eb emplace_back
#define pp pop_back
#define bs binary_search
#define all(x) x.begin(),x.end()
#define loop(i,s,n) for(ll i=s;i<n;i++)
#define test ll t ; cin>>t; while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);

int main() {
	fast_io;
	
	ll a,b,n,ans;
	cin>>a>>b>>n;
	if(n>=b-1)      ans=floor((a*(b-1))/b)-a*floor((b-1)/b);
	else    ans=floor((a*n)/b)-a*floor(n/b);   
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3648
#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 all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll rec = *max_element(a.begin(), a.end());
	ll t = linf;
	ll rec2;
	rep(i, n) {
		ll tmp = min(rec - a[i], a[i]);
		if (t >= rec / 2 - tmp) {
			t = rec / 2 - tmp;
			rec2 = a[i];
		}
	}
	cout << rec << ' ' << rec2 << endl;
	return 0;
}


Measured memory_bytes: 3980
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;

fn f(v1: &Vec<Vec<char>>, v2: &Vec<Vec<char>>, ox: usize, oy: usize) -> bool {
    for x in 0..v2.len() {
        for y in 0..v2.len() {
            if v1[x + ox][y + oy] != v2[x][y] {
                return false;
            }
        }
    }
    true
}

fn main() {
    let (n, m): (usize, usize);
    input!(n, m);
    let mut v1 = Vec::new();
    let mut v2 = Vec::new();
    for _ in 0..n {
        v1.push(str2vec(&input_line_str()));
    }
    for _ in 0..m {
        v2.push(str2vec(&input_line_str()));
    }

    for x in 0..n - m + 1 {
        for y in 0..n - m + 1 {
            if f(&v1, &v2, x, y) {
                p("Yes");
                return;
            }
        }
    }
    p("No");
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n), d(n);
  rep(i, n) cin >> h[i];

  sort(h.begin(), h.end());
  int ans = 1e9;
  for (int i = 0; i < n - k + 1; ++i) {
    d[i] = h[i + k - 1] - h[i];
    ans = min(ans, d[i]);
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using ull = unsigned long long;
constexpr ll kMod = 1000000007ll;

/* Eratosthenes Lib */
class Eratosthenes {
 public:
  Eratosthenes(int n) : isprime_(n + 1, true) {
    isprime_[0] = false;  isprime_[1] = false;
    for (int i = 2; i <= n; ++i) if (isprime_[i]) {
      primes_.push_back(i);
      for (int j = 2; i * j <= n; ++j) isprime_[i * j] = false;
    }
  }

  bool isprime(int x) const { return isprime_[x]; }
  auto primes(int x) const {
    vi prime_list;
    auto last = upper_bound(primes_.begin(), primes_.end(), x);
    for (auto it = primes_.begin(); it != last; ++it)
      prime_list.push_back(*it);
    return prime_list;
  }
  auto factor(int x) const {
    map<int, int> factor_map;
    int search_max = (int)sqrt(x);
    for ( auto p : primes(search_max) ) {
      while (x % p == 0) {
        x /= p;
        factor_map[p]++;
      }
    }
    if (x != 1) factor_map[x]++;
    return factor_map;
  }

 private:
  vector<bool> isprime_;
  vector<int>  primes_;
};
/* /Eratosthenes Lib */

int main(int argc, char* argv[]) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  /* */
  int n;
  cin >> n;
  Eratosthenes et(n);
  map<int, int> primes;
  for (int i = 2; i <= n; ++i) {
    auto primes_i = et.factor(i);
    for (auto kv : primes_i) {
      primes[kv.first] += kv.second;
    }
  }

  ll ans = 1;
  for (auto kv : primes) {
    ans = (ans * (kv.second + 1)) % kMod;
  }
  cout << ans << endl;
  /* */

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  cin >> N;
  vector<long> data(N), co(N + 1);
  long a;
  for(int i = 0; i < N; i++){
    cin >> data.at(i);
    co.at(data.at(i))++;
  }
  long ans = 0;
  for(int i = 1; i <= N; i++){
    ans += (co.at(i) - 1) * co.at(i) / 2;
  }
  for(int i = 0; i < N; i++){
    cout << ans - (co.at(data.at(i)) - 1) * co.at(data.at(i)) / 2 + (co.at(data.at(i)) - 1) * (co.at(data.at(i)) - 2) / 2 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
typedef long long ll;

using namespace std;

struct xyz {
    int a;
    int b;
};

struct abc {
    int p;
    int x;
};

int main() {
    int n, q;
    cin >> n >> q;
    
    vector<xyz> v(n - 1);
    vector<vector<int>> save = vector<vector<int>>(n, vector<int>(0));
    for(int i = 0; i < n - 1; i++) {
        cin >> v[i].a >> v[i].b;
        save[v[i].a - 1].push_back(v[i].b);
    }
    
    vector<abc> que(q);
    for(int i = 0; i < q; i++) {
        cin >> que[i].p >> que[i].x;
    }
    
    vector<ll> ans(n, 0);
    for(int i = 0; i < q; i++) {
        ans[que[i].p - 1] += que[i].x;
    }
    
    for(int i = 0; i < n; i++) {
        if(i == n - 1) {
            cout << ans[i] << endl;
            break;
        }
        
        cout << ans[i] << " ";
        
        for(int j = 0; j < save[i].size(); j++) {
            ans[save[i][j] - 1] += ans[i];
        }
    }
    
     /*
    cout << endl;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < save[i].size(); j++) {
            cout << i << " " << save[i][j] << endl;
        }
    }
    */
    
    return 0;
}



Measured memory_bytes: 18048
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	ll T[2],A[2],B[2];
	rep(i,2) scan(T[i]);
	rep(i,2) scan(A[i]);
	rep(i,2) scan(B[i]);
	ll Akyori=T[0]*A[0]+T[1]*A[1],Bkyori=T[0]*B[0]+T[1]*B[1];
	if(T[0]*A[0]+T[1]*A[1]==T[0]*B[0]+T[1]*B[1]){
		prin("infinity");
	}
	else{
		ll lead[100001];
		ll nowA=0,nowB=0;
		ll ans=0;
		ll MAX=100;
		rep(j,MAX){
			nowA+=T[j%2]*A[j%2];
			nowB+=T[j%2]*B[j%2];
			lead[j]=(nowA-nowB);
			if(j>0){
				if((lead[j]<0&&lead[j-1]>0)||(lead[j]>0&&lead[j-1]<0)) ans++;
				else if(lead[j]==0) ans++;
			}
		}
		if((lead[MAX-1]<0&&lead[MAX-2]>0)||(lead[MAX-1]>0&&lead[MAX-2]<0)){
			if(Akyori<Bkyori){
				ll sa=lead[MAX-4]-lead[MAX-2];
				ll kaisu;
				if(lead[MAX-2]%sa==0) kaisu=lead[MAX-2]/sa*2-1;
				else kaisu=lead[MAX-2]/sa*2;
				prin(ans+kaisu);
			}
			else{
				ll sa=-lead[MAX-4]+lead[MAX-2];
				ll kaisu;
				if((-lead[MAX-2])%sa==0) kaisu=(-lead[MAX-2])/sa*2-1;
				else kaisu=(-lead[MAX-2])/sa*2;
				prin(ans+kaisu);
			}
		}
		else prin(ans);
	}
	return 0;
}


Measured memory_bytes: 256