akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
#ifdef VC
#define scanf scanf_s
#endif
#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const ll mod = 998244353;
int n;

int main() {
	int z, w;
	int a[2010];
	cin >> n >> z >> w;
	forn(i)cin >> a[i];
	int ans;
	ans = abs(w - a[n - 1]);
	if (n > 1) {
		ans = max(ans, abs(a[n - 1] - a[n - 2]));
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int n, m, a[501][501], b[501][501], used[501];

int main () {
	
	cin >> n >> m;
	for (int i = 1; i <= m; i ++) a[1][i] = a[n][i] = 1;
	for (int i = 1; i <= n; i ++) a[i][1] = a[i][m] = 1;
	for (int i = 1; i <= n; i ++)
		for (int j = 1; j <= m; j ++) {
			char c;
			cin >> c;
			if (c == '#') used[i] = a[i][j] = b[i][j] = 1;
		}
	bool ok = 0;
	for (int i = 2; i < n; i ++) {
		if (ok & used[i]) {
			ok ^= 1;
			for (int j = 2; j < m; j ++) a[i][j] = 1;
		}
		else {
			ok ^= 1;
			for (int j = 2; j < m; j ++) b[i][j] = 1;
		}
	}
	for (int i = 1; i <= n; i ++, cout << endl)
		for (int j = 1; j <= m; j ++)
			cout << (a[i][j] ? '#' : '.');
	for (int i = 1; i <= n; i ++, cout << endl)
		for (int j = 1; j <= m; j ++)
			cout << (b[i][j] ? '#' : '.');		

}

Measured memory_bytes: 2816
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int M, T, P, R;
    while(cin >> M >> T >> P >> R, M || T || P || R) {
        int m, t, p, j;

        // board[team][problem] := judge
        int board[60][15] = {};
        int probnum[60] = {};
        int acctime[60] = {};

        rep(i,0,R) {
            cin >> m >> t >> p >> j;
            t--;
            if(j != 0) {
                board[t][p]++;
            }
            else {
                acctime[t] -= m + 20 * board[t][p];
                probnum[t]++;
            }
        }

        vector< pair< pii, int > > pp;
        rep(i,0,T) pp.pb(make_pair( make_pair(probnum[i], acctime[i]), i+1) );
        pii prev = pii(-1, -1);
        sort(pp.begin(), pp.end());
        reverse(pp.begin(), pp.end());


        rep(i,0,T) {
            if(prev == pii(-1, -1)) {
                prev = pp[i].fr;
                printf("%lld", pp[i].sc);
            }
            else if(prev == pp[i].fr) {
                printf("=%lld", pp[i].sc);
            }
            else if(prev != pp[i].fr) {
                printf(",%lld", pp[i].sc);
                prev = pp[i].fr;
            }
        }
        cout << endl;
    }
    return 0;
}

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

int main(){
  vector<int>a{0,1,2,3,4,5,6,7,8,9};
  int K;
  int n;
  cin >> K >> n;
  vector<int>b(n);
  for(int i=0;i<n;i++){
    cin >> b.at(i);
  }
  for(int i=0;i<n;i++){
    a.erase(a.begin()-i+b.at(i));
  }
  int c=a.size();
  int e=0;
  vector<int>g(1);
  for(int w=0;w<c;w++){
    e+=a.at(w);
    g.push_back(e);
    for(int x=0;x<c;x++){
      e+=a.at(x)*pow(10,1);
      g.push_back(e);
      for(int y=0;y<c;y++){
        e+=a.at(y)*pow(10,2);
        g.push_back(e);
        for(int z=0;z<c;z++){
          e+=a.at(z)*pow(10,3);
          g.push_back(e);
          for(int v=0;v<c;v++){
            e+=a.at(v)*pow(10,4);
            g.push_back(e);
            e-=a.at(v)*pow(10,4);
          }
          e-=a.at(z)*pow(10,3);
        }
        e-=a.at(y)*pow(10,2);
      }
      e-=a.at(x)*pow(10,1);
    }
    e-=a.at(w)*pow(10,0);
  }
  sort(g.begin(),g.end());
  for(int i=0;i<g.size();i++){
    if(g.at(i)>=K){
      cout << g.at(i) << endl;
      break;
    }
  }
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin >> n;
    vector<ll> a(n),b(n);
    for(ll i = 0; i < n; i++) cin >> a[i];
    for(ll i = 0; i < n; i++) cin >> b[i];

    ll m = 0;

    for(ll i = 0; i < n; i++){
        if(b[i] > a[i]){
            m += (b[i]-a[i]+1)/2;
            a[i] += 2*((b[i]-a[i]+1)/2);
        }
    }

    for(ll i = 0; i < n; i++){
        if(a[i] > b[i]){
            m -= a[i]-b[i];
            b[i] = a[i];
        }
        if(m < 0){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3736
n = gets.strip.to_i
arr = gets.strip.split(' ').map(&:to_i)
sum = 0
arr.each do |elem|
  sum += elem
end
points = [(sum / n) - 1, (sum / n), (sum / n) + 1]
answers = []
def check(arr, point)
  s = 0
  arr.each do |elem|
    s += (elem - point).abs ** 2
  end
  s
end
points.each do |point|
  answers.push check(arr, point)
end
puts answers.min


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using pint=pair<int,int>;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int H,W;
string fi[110];
int dist[110][110];
 
int main()
{   
    cin>>H>>W;
    int wnum=0;
    for(int i=0;i<H;i++){
        cin>>fi[i];
        for(int j=0;j<W;j++){
            if(fi[i][j]=='.') wnum++;
        }
    }
    
    memset(dist,-1,sizeof(dist));
    dist[0][0]=1;
    queue<pint> que;
    que.push(pint(0,0));
    while(!que.empty()){
        pint cur=que.front();
        que.pop();
        int x=cur.first;
        int y=cur.second;
        for(int dir=0;dir<4;dir++){
            int nx=x+dx[dir];
            int ny=y+dy[dir];
            if(nx<0 || nx>=H || ny<0 || ny>=W) continue;
            if(fi[nx][ny]=='#') continue;
            if(dist[nx][ny]==-1){
                dist[nx][ny]=dist[x][y]+1;
                que.push(pint(nx,ny));
            }
        }
    }
    if(dist[H-1][W-1]==-1) cout<<-1<<endl;
    else cout<<wnum-dist[H-1][W-1]<<endl;
}

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

using namespace std;

int main() {
    int c;
    cin >> c;
    for(int dataCount = 0; dataCount < c; dataCount++) {
        int n, k;
        cin >> n >> k;
        int x[n];
        for (int i = 0; i<n; i++) {
            cin >> x[i];
        }
        if(n <= k){
            cout << 0 << endl;
            continue;
        }
        int distance[n-1];
        for (int i = 0; i<n-1; i++) {
            distance [i] = x[i+1] - x[i];
        }
        bool done[n-1];
        fill(done, done + (n-1), false);
        int sum = 0;
        sort(distance, distance + (n-1), greater<>());
        for(int i = 0; i < k-1; i++) {
            sum += distance[i];
        }
        cout << x[n-1] - x[0] - sum << endl;
    }
    return 0;
}


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

const ll infll=9223372036854775806;
const int inf=2147483646;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll a,b,i,j,k,t=1,s=0,ans=0,d[42]={1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912,1073741824,2147483648,4294967296,8589934592,17179869184,34359738368,68719476736,137438953472,274877906944,549755813888,1099511627776,2199023255552};
	cin>>a>>b;
	vector<ll> g;
	g.push_back((((b+1)/2)%2)^((a/2)%2));
	for (i=2;d[i]<=2*b;i++){
		ll tb,ta;
		tb=b%d[i];
		tb++;
		if (2*tb>d[i]){
			tb%=2;
		}
		else {
			tb=0;
		}
		ta=a%d[i];
		if (2*ta>d[i]){
			ta%=2;
		}
		else {
			ta=0;
		}
		g.push_back((ta^tb));
	}
	for (i=0;i<g.size();i++){
		ans+=g[i]*d[i];
	}
	cout<<ans;
	return 0;
}

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

int main()
{
  string s;
  cin >> s;
  int ans1 = 0, ans2 = 0;
  for(int i = 0; i < s.size(); ++i)
  {
    if(i % 2 == 0)
    {
      if(s[i] != '1') ++ans1;
    }
    else
    {
      if(s[i] != '0') ++ans1;
    }
  }
  for(int i = 0; i < s.size(); ++i)
  {
    if(i % 2 == 0)
    {
      if(s[i] != '0') ++ans2;
    }
    else
    {
      if(s[i] != '1') ++ans2;
    }
  }
  cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 512
#include <iostream>
#define ll long long
using namespace std;

int main(){
  int a,b,k,r; cin >> a >> b;
  
  k = (b-1)/(a-1);
  r = (b-1)%(a-1);
  
  if(r!=0){k++;}
  
  cout << k;
  
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
p = list(map(int, input().split()))
g = [[] for _ in range(N)]

for xy in range(M):
    x, y = map(int, input().split())
    g[x - 1].append(y - 1)
    g[y - 1].append(x - 1)

lst = []
visited = [0]*N
for i in range(N):
    if visited[i] == 1:continue
    temp = [i]
    grp = [i]
    visited[i] = 1
    while temp:
        q = temp.pop()
        for gq in g[q]:
            if visited[gq] == 0:
                temp.append(gq)
                visited[gq] = 1
                grp.append(gq)
    lst.append(grp)

ans = 0
for l in lst:
    temp = set([p[i]-1 for i in l])
    ans += len(temp & set(l))
print(ans)

Measured memory_bytes: 49404
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <iomanip>
using namespace std;
typedef long long unsigned int llui_t;
typedef long long int lli_t;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


/* inputs */
llui_t N;
vector<llui_t> X;

int main() {
  cin >> N;
  llui_t ans = 0;
  uint is7, is5, is3, no753;

  for(llui_t i=1; i<N+1; i+=2) {
    llui_t n = i;
    is7 = 0;
    is5 = 0;
    is3 = 0;
    no753 = 0;

    while(n>0) {
       uint j = n % 10;
       if (j!=7 && j!=5 && j!=3) {
         no753 = 1;
         break;
       }
       if (j==7) {
         is7 += 1;
       }
       if (j==5) {
         is5 += 1;
       }
       if (j==3) {
         is3 += 1;
       }
       n = n / 10;
    }
    //cout << i << "/" << is7 << "," << is5 << "," << is3 << "," << no753 << endl;
    if (is7>0 && is5>0 && is3>0 && no753==0) {
      ans += 1;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
    #include <vector>
    #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;
     
    #define pb push_back
    #define eb emplace_back
    #define fi first
    #define se second
    #define bg begin()
    #define ed end()
    #define all(x) x.bg, x.ed
    #ifdef LOCAL
    #define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl
    #else
    #define dmp(x) void(0)
    #endif
     
    template <class t, class u>
    void chmax(t &a, u b)
    {
      if (a < b)
        a = b;
    }
    template <class t, class u>
    void chmin(t &a, u b)
    {
      if (b < a)
        a = b;
    }
    const int mod = 1000000007;
    struct mint
    {
      ll x; // typedef long long ll;
      mint(ll x = 0) : x((x % mod + mod) % mod) {}
      mint &operator+=(const mint a)
      {
        if ((x += a.x) >= mod)
          x -= mod;
        return *this;
      }
      mint &operator-=(const mint a)
      {
        if ((x += mod - a.x) >= mod)
          x -= mod;
        return *this;
      }
      mint &operator*=(const mint a)
      {
        (x *= a.x) %= mod;
        return *this;
      }
      mint operator+(const mint a) const
      {
        mint res(*this);
        return res += a;
      }
      mint operator-(const mint a) const
      {
        mint res(*this);
        return res -= a;
      }
      mint operator*(const mint a) const
      {
        mint res(*this);
        return res *= a;
      }
      mint pow(ll t) const
      {
        if (!t)
          return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
          a *= *this;
        return a;
      }
     
      // for prime mod
      mint inv() const
      {
        return pow(mod - 2);
      }
      mint &operator/=(const mint a)
      {
        return (*this) *= a.inv();
      }
      mint operator/(const mint a) const
      {
        mint res(*this);
        return res /= a;
      }
    };
    struct combination
    {
      vector<mint> fact, ifact;
      combination(int n) : fact(n + 1), ifact(n + 1)
      {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
          fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
          ifact[i - 1] = ifact[i] * i;
      }
      mint operator()(int n, int k)
      {
        if (k < 0 || k > n)
          return 0;
        return fact[n] * ifact[k] * ifact[n - k];
      }
    };
     
    template <class t>
    using vc = vector<t>;
    template <class t>
    using vvc = vc<vc<t>>;
     
    using vi = vc<int>;
    int gcd(int a, int b)
    {
      if (b == 0)
        return a;
      return gcd(b, a % b);
    }
    int lcm(int a, int b)
    {
      return (a * b) / gcd(a, b);
    }
    int fact(int n)
    {
      if (n == 0)
        return 1;
      return n * fact(n - 1);
    }
     
    int main()
    {
      int a,b,c;
      cin >> a >> b >>c;
      if(b-a==c-b){
      cout<<"YES"<<endl;
      }else{
      cout<<"NO"<<endl;
      }
    }

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

using namespace std;

#define ll long long
#define PI 3.14159265358979323846264338327950L

int k,a,b;

void solve(){

    cin >> k >> a >> b;

    for (int i = a; i <= b; i++)
    {
        if(i%k == 0){
            cout << "OK" << endl;
            return;
        }
    }
    cout << "NG" << endl;
}





int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();

}

Measured memory_bytes: 3600
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void solve() throws Exception {
		int n = scanInt();
		int ans = 0;
		int prev = -1;
		for (int i = 0; i < n; i++) {
			int a = scanInt();
			if (a == prev) {
				++ans;
				a = -1;
			}
			prev = a;
		}
		out.print(ans);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 23124
a, b, c = map(int, input().split())

tmp_list = []
i = 1
while True:
    tmp = a * i % b
    if tmp == c:
        print("YES")
        exit()
    else:
        if tmp in tmp_list:
            print("NO")
            exit()
        tmp_list.append(tmp)
        i += 1


Measured memory_bytes: 9160
def powmod(b,r,mod)
  a = 1
  while r > 0
    if r%2 == 1
      a = a * b % mod
    end
    b = b * b % mod
    r /= 2
  end
  a
end

def invmod(f, mod)
  powmod(f, mod-2, mod)
end

N,M,K = gets.split.map &:to_i
Mod = 998244353

if M == 1
  puts K == N-1 ? 1 : 0; exit
end

n = N - 1
m = M - 1
m_pow_n = powmod(m, n, Mod)
m_inv = invmod(m, Mod)

ans = 0
comb = m_pow_n
(0..K).each{ |k|
  ans = (ans + comb) % Mod
  comb = comb * m_inv * (n-k) * invmod(k+1, Mod) % Mod
}
puts ans * M % Mod


Measured memory_bytes: 14420
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
ll k;
string s;
int i,x;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>s>>k;
	for(i=0;i<s.size();i++)
	{
		x=(int)s[i];
		if(s[i]!='a' && 123-x<=k)s[i]='a',k-=(123-x);
	}
	k-=26*(k/26),i--;
	s[i]=(char)(s[i]+k);
	cout<<s<<endl;
	return 0;
}

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

  long long int K = N / (A + B);
  long long int blue = A * K;
  long long int red = B * K;
  
  long long int shortage = N - (blue + red);
  
  if (blue + red + A <= N) { //青をA個足してもNに達しない
    blue += A;
    cout << blue;
  } else { //足すとNに達してしまう
    cout << blue + shortage;
  } 
}

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

namespace AtCoder_Beginner_Contest_126
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var mae = int.Parse(S.Substring(0, 2));
            var ato = int.Parse(S.Substring(2, 2));

            var maemm = false;
            var maeyy = false;
            var atomm = false;
            var atoyy = false;
            //月
            if (1 <= mae && mae <= 12) maemm = true;
            if (1 <= ato && ato <= 12) atomm = true;
            //年
            if (0 <= mae && mae <= 99) maeyy = true;
            if (0 <= ato && ato <= 99) atoyy = true;

            if (maemm & maeyy & atomm & atoyy)
                Console.WriteLine("AMBIGUOUS");
            else if (maemm & (!maeyy | !atomm) & atoyy)
                Console.WriteLine("MMYY");
            else if (maeyy & (!maemm | !atoyy) & atomm)
                Console.WriteLine("YYMM");
            else
                Console.WriteLine("NA");
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
using namespace std;


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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

	int N, x;
	cin >> N >> x;

	vector<int> V(N);
	for(auto &i : V)  cin >> i;

	ll ans = 0;

	for(int i = 1; i < N; i++){
		int need = V[i] + V[i-1] - x;
		if(need <= 0) continue;

		ans += need;

		int to = min(need,V[i]);
		V[i] -= to;
		need -= to;

	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3704
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
using namespace std;

struct NODE{
	int x,y,c,num;
	NODE(int x,int y,int c) : x(x) , y(y) , c(c) {}
	NODE(int x,int y,int c,int num) : x(x) , y(y) , c(c) , num(num) {}
};
int W,H;

int doit(vector<NODE> v){
	queue<NODE> Q;
	for(int i = 0 ; i < v.size() ; i++){
		Q.push(NODE(v[i].x,v[i].y,0,i));
	}
	int cnt[100][100]={};
	int ans[100][100];
	for(int i = 0 ; i < 100 ; i++)
		for(int j = 0 ; j < 100 ; j++)
			ans[i][j] = 1e9;
	
	// kore Shindoinen!!!!!!!!!!!!!
	// kore Shindoinen!!!!!!!!!!!!!
	// kore Shindoinen!!!!!!!!!!!!!
	int dx[2][6] = { {-1, 0, 1,-1,-1,0 } , {-1,0,0,1,1,1} };
	int dy[2][6] = { { 0, 1, 0, 1,-1,-1} , {0,1,-1,0,1,-1} };
	// kore Shindoinen!!!!!!!!!!!!!
	// kore Shindoinen!!!!!!!!!!!!!
	// kore Shindoinen!!!!!!!!!!!!!
	while(Q.size()){
		NODE q = Q.front(); Q.pop();
		if( q.x < 0 || q.y < 0 || q.x >= W || q.y >= H ) continue;
		if( ans[q.y][q.x] < q.c ) continue;
		if( ans[q.y][q.x] > 10000) {
			ans[q.y][q.x] = q.c;
			cnt[q.y][q.x] = (1<<q.num);
		}else if( ans[q.y][q.x] == q.c ){
			cnt[q.y][q.x] |= (1<<q.num);
			continue;
		}
		for(int i = 0 ; i < 6 ; i++){
			Q.push(NODE(q.x+dx[q.y%2][i],q.y+dy[q.y%2][i],q.c+1,q.num));
		}
	}
	
	int cntt = 0;
	for(int i = 0 ; i < H ; i++){
		for(int j = 0 ; j < W ; j++){
			//printf("%3d",cnt[i][j]);
			if( cnt[i][j] == (1<<(v.size()-1)) ){
				cntt++;
			}
		}
		//puts("");
	}
	return cntt;
	
}
int main(){

	while(cin >> W >> H && W){
		int s,N;
		cin >> s;
		vector<NODE> alr;
		for(int i = 0 ; i < s ; i++){
			int x,y;
			cin >> x >> y;
			x--,y--;
			alr.push_back(NODE(x,y,0));
		}
		cin >> N;
		int ans = 0;
		for(int i = 0 ; i < N ; i++){
			int x,y;
			cin >> x >> y;
			x--,y--;
			alr.push_back(NODE(x,y,0));
			ans = max( ans , doit(alr) );
			alr.pop_back();
		}
		
		cout << ans << endl;
		
		
	}
}

Measured memory_bytes: 1316
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[] T = new long[100];
    for (int i = 0; i < N; i++) {
      T[i] = sc.nextLong();
    }
    long ans = 1;
    for (int i = 0; i < N; i++) {
      ans = lcm(ans, T[i]);
    }
    System.out.println(ans);
  }

  public static long gcd(long a, long b) {
    if (b == 0) {
      return a;
    }
    return gcd(b, a % b);
  }

  public static long lcm(long a, long b) {
    return (a / gcd(a, b)) * b;
  }
}


Measured memory_bytes: 22868
/* ****GT_18**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll n,a[100][2],i,j,k,l,m;
        cin>>n;
        for(i=0;i<n;i++)
        {
            cin>>a[i][0]>>a[i][1];
        }
        map<pair<ll,ll>,ll> ma;
        for(i=0;i<n;i++)
        {
            for(j=0;j<n;j++)
            {
                if(i==j)
                    continue;
                ma[{a[i][0]-a[j][0],a[i][1]-a[j][1]}]++;
            }
        }
        k=0;
        for(auto i:ma)
            k=max(k,i.S);
        cout<<n-k;
    }
    return 0;
}

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

int main() {
  
  int n;
  cin >> n;
  int total = 0;
  for(int i = 1; i <= n; i++){
    if(i % 2 == 0){
      total++;
    }
  }
  double p, q;
  p = total;
  q = n;
  double r = p / q;
  double e = 1 - r;
  cout << fixed << setprecision(10) << e << endl;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;

const int N=200005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x+=y;if(x>=mod) x-=mod;}

int n,x,y,c[N],w[N],mn[N],mn1,mn2,fa[N];
int fac[N],ifac[N];
vi g[N];
map<int,int> s;

int exp(int x,int y){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}
int C(int x,int y){
	return (ll)fac[x]*ifac[y]%mod*ifac[x-y]%mod;
}
void pre(){
	int n=200000;
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=(ll)fac[i-1]*i%mod;
	ifac[n]=exp(fac[n],mod-2);
	for(int i=n-1;~i;i--) ifac[i]=(ll)ifac[i+1]*(i+1)%mod;
}
int find(int x){if(fa[x]!=x) fa[x]=find(fa[x]);return fa[x];}
void merge(int x,int y){
	fa[find(x)]=find(y);
}

int main(){
	pre();
	scanf("%d%d%d",&n,&x,&y);
	w[0]=inf;
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&c[i],&w[i]);
		if(w[i]<w[mn[c[i]]]) mn[c[i]]=i;
	}
	for(int i=1;i<=n;i++){
		int j=mn[i];
		if(w[j]<w[mn1]) mn2=mn1,mn1=j; 
		else if(w[j]<w[mn2]) mn2=j;
	}
	for(int i=1;i<=n;i++)
		if(w[i]+w[mn[c[i]]]<=x) merge(i,mn[c[i]]);
	for(int i=1;i<=n;i++){
		int k=mn1;
		if(mn[c[i]]==mn1) k=mn2;
		if(w[k]+w[i]<=y) merge(i,k);
	}
	for(int i=1;i<=n;i++)
		g[find(i)].pb(i);
	int ans=1;
//	debug(C(1,1));
	for(int i=1;i<=n;i++){
		if(!g[i].size()) continue;
		int m=g[i].size();
		s.clear();
		for(int j:g[i])
			s[c[j]]++;
//		for(int j:g[i]) printf("%d ",j);puts("");
		for(auto j:s)
			ans=(ll)ans*C(m,j.SS)%mod,m-=j.SS;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 17016
N,M = map(int, input().split())
es = [tuple(map(int, input().split())) for _ in range(M)]
es.reverse()

ans = []
cnt = N*(N-1) // 2
ans.append(cnt)

"""
辺を削除していくつ通行不能の組ができたかを毎度調べるのは厳しいので、最後に落とす橋から逆に繋いでいく。
初期状態では繋がってない島の組の数は N*(N-1) // 2
ある島A,Bを橋でつなぐと、Aに元から繋がっていた島とBにもとから繋がっていた島間で行き来できるようになるから、
union(A)の構成要素数 x union(B)の構成要素数 を、行き来できない組数からのぞくとよいか

"""


class UnionFind:
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N # 最初はそれぞれのノードが誰ともUnionをつくってないから木の深さが０
        self.count = 0 # unite回数
        self.size = [1] * N
    
    # 根を返す
    def root(self, a):
        if self.parent[a] == a:
            return a
        else:
            # 親を見に行く
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    
    # 同じUnionに属するかどうか
    def is_same(self, a, b):
        return self.root(a) == self.root(b)
    
    # 同じUnionにする
    def unite(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb:
            return 
        if self.rank[ra] < self.rank[rb]:
            self.size[rb] += self.size[ra]
            self.parent[ra] = rb
        else:
            self.size[ra] += self.size[rb]
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]:
                self.rank[ra] += 1
        self.count += 1
    # Unionの構成要素数を返す
    def get_size(self, a):
        return self.size[self.root(a)]


uf = UnionFind(N)

for i in range(M-1):
    a,b = es[i]
    a,b = a-1, b-1
    if not uf.is_same(a,b):
        cnt -= uf.get_size(uf.root(a)) * uf.get_size(uf.root(b))
        uf.unite(a,b)
    ans.append(cnt)


ans.reverse()

print(*ans, sep="\n")

Measured memory_bytes: 124888
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    long long N,K;
    cin >> N >> K;
    long long all;
    all = 0;
    for (long long i = K; i < N+2; i++)
    {
        long long po;
        po = N*i-(i-1)*i;
        all = (all + po + 1) %1000000007;
    }
    cout << all;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
using ll = long long;
int MOD = 1e9 + 7;
using namespace std;
struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int main()
{
    int n, m;
    cin >> n >> m;
    UnionFind tree(n + m);
    for (int i = 0; i < n;i++){
        int k;
        cin >> k;
        for (int j = 0; j < k;j++){
            int x;
            cin >> x;
            tree.unite(i,x+n-1);
        }
    }
    set<int> s;
    for (int i = 0; i < n;i++){
        s.insert(tree.root(i));
    }
    if(s.size()==1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 1152
n = int(input())
t = [int(x) for x in input().split()]
a = list(reversed([int(x) for x in input().split()]))

t2 = [(p != q, p) for p, q in zip(t, [None] + t)]
a2 = reversed([(p != q, p) for p, q in zip(a, [None] + a)])

ans = 1
for (tf, tv), (af, av) in zip(t2, a2):
    if tf:
        if af:
            if tv != av:
                ans = 0
                break
        else:
            if tv > av:
                ans = 0
                break
    elif af:
        if tv < av:
            ans = 0
            break
    else:
        ans = (ans * min(tv, av)) % 1000000007

print(ans)


Measured memory_bytes: 26432
N = int(input())
a = [0] * N
b = [0] * N
c = [0] * N

for i in range(N):
  a[i], b[i], c[i] = map(int, input().split())

dp = [ [0, 0, 0] for i in range(N)]

dp[0][0] = a[0]
dp[0][1] = b[0]
dp[0][2] = c[0]

for i in range(1, N):
  dp[i][0] = max(dp[i - 1][1] + a[i],
    dp[i - 1][2] + a[i])
  dp[i][1] = max(dp[i - 1][0] + b[i],
    dp[i - 1][2] + b[i])
  dp[i][2] = max(dp[i - 1][0] + c[i],
    dp[i - 1][1] + c[i])
  
print(max(dp[i][0], dp[i][1], dp[i][2]))


Measured memory_bytes: 34636
#include <bits/stdc++.h>
using namespace std;
int main(){
	int r,g,b;

	cin>>r>>g>>b;
	if((10*g+b)%4==0)
	{
		cout<<"YES"<<"\n";
	} else {
		cout<<"NO"<<"\n";
	}
return 0;
}

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

ls = [[a, b] for a, b in zip(lsa, lsb)]
ls.sort(key=lambda x: x[1])
lsa = [l[0] for l in ls]
lsb = [l[1] for l in ls]

lsasort = sorted(lsa)
for i in range(n):
    if lsasort[i]>lsb[i]:
        flag = False
        break
else:
    flag = True

if flag:
    lscycle = [[p, q] for p, q in zip(range(n), lsa)]
    lscycle.sort(key=lambda x: x[1])

    count=0
    idx=0
    while True:
        idx=lscycle[idx][0]
        count+=1
        if idx == 0:
            break

    if count != n:
        flag = True
    else:
        for i in range(n-1):
            if lsasort[i+1] <= lsb[i]:
                flag = True
                break
        else:
            flag = False

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 102800
#include <iostream>
#include <cmath>

using namespace std;
int main(){
  long  n;
  cin >> n;

  long min_dist = n;
  for(long i = 1L; i <= sqrt(n); i++) {
    if(n%i == 0) {
      min_dist = min(min_dist, i+(n/i)-2L);
    }
  }
  cout << min_dist << endl;
  return 0;
} 


Measured memory_bytes: 3676
#include<bits/stdc++.h>
#include <vector>
#include <algorithm>
#define ll long long
#define mod 1000000007
#define test int t; cin>>t; while(t--)
#define f for(int i=0;i<n;i++)
#define f1 for(int i=1;i<n-1;i++)
#define read(x) ll x; cin>>x;
#define TIME  cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";

using namespace std;
/*ll gcd(ll a , ll b){return b==0?a:gcd(b,a%b);}
int combi(int n, int k)
{
    int C[k+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (int i = 1; i <= n; i++)
    {
        for (int j = min(i, k); j > 0; j--)
            C[j] = C[j] + C[j-1];
    }
    return C[k];
}
int factorial(int n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll power(ll x,ll n)
{
    if(n==0) return 1;
    if(n&1) return x*power(x,n/2)*power(x,n/2);
    else
        return power(x,n/2)*power(x,n/2);
}*/
/*int gcd(int a, int b){
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int lcm(int a, int b)
{
    return (a*b)/gcd(a, b);
}*/
int main() {

   ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
   // static const auto _ = []() { ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); return 0; }();
   
   double d,t,s; cin>>d>>t>>s;
  double  tt=(d/s);
  if(tt<=t)
  {
      cout<<"Yes"<<endl;
  } else{
      cout<<"No"<<endl;
  }
//TIME
}

Measured memory_bytes: 3716
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.E
{
    public class Program
    {
        public static long N { get; private set; }
        public static long K { get; private set; }
        public static List<long> A { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            (N, K) = Read2Longs();
            A = ReadLongs();

            var l = 0L;
            var r = A.Max();
            while (r - l != 1)
            {
                var mid = (l + r) / 2;
                if (CanCutLogsUnder(mid))
                {
                    r = mid;
                }
                else
                {
                    l = mid;
                }
            }

            return r;
        }

        private static bool CanCutLogsUnder(long maxLength)
        {
            var cutCount = 0L;
            foreach (var a in A)
            {
                // カット不要
                if (a < maxLength) continue;

                // 5等分なら4回カットすればよい だから-1する
                cutCount += (long)Math.Ceiling((double)a / maxLength) - 1;
                if (cutCount > K)
                {
                    return false;
                }
            }

            return true;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 45688
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e;
int main(){
	cin>>a;
	if(a<1200){
		cout<<"ABC";
	}else{
		if(a<2800){
			cout<<"ARC";
		}else{
			cout<<"AGC";
		}
	}
	return 0;
}

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

typedef long long ll;

ll gcds(ll a, ll b){
    if(a<b){
        swap(a,b);
    }
    ll r=0;
    while(a%b>0){
        r=a%b;
        a=b;
        b=r;
    }
    return b;
}

ll lcms(ll a,ll b){
    ll c=0;
    c=gcds(a,b);
    ll d=0;
    d=a*b/c;
    return d;
}


int main(){
    ll N;
    cin>>N;
    vector<ll> x(N);
    for(ll i=0;i<N;i++){
        cin>>x.at(i);
    }
    for(ll i=1;i<N;i++){
        x.at(i)=gcds(x.at(i-1),x.at(i));
    }
    cout<<x.at(N-1)<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cstdlib>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
    int n;
    cin >> n;
    vector<int> a(n, 0);
    for (int i = 1; i < n; i++) {
        int m;
        cin >> m;
        a[m-1]++;
    }
    rep(i, n) {
        cout << a[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 4052
K=int(input())
l=[0,1,2,3,4,5,6,7,8,9]
cnt=0
def dfs(s, depth):
    if depth>8:
        return
    S=str(s)
    ls=int(S[-1])
    for i in range(max(0,ls-1),min(10,ls+2)):
        n=int(S+str(i))
        l.append(n)
        dfs(n, depth+1)
for i in range(1, 10):
    dfs(i, 0)
l.sort()
print(l[K])

Measured memory_bytes: 75484
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
#define vll vector<ll>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

template<typename T>
void vecin(vector<T>& v, int n = 0){
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
}
template <typename T>
void vecout(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n-1; ++i)
    {
        cout << v[i] << " ";
    }
    cout << v[n - 1] << endl;
}
void print(string s){
    cout << s << endl;
}

int main()
{
    ciosup;
    int n;
    cin >> n;
    ll ans = 0;
    REP(i,n){
        ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
C = []
S = []
F = []
for _ in range(n-1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)

def f(n, s, f):
    if n <= s:
        return s
    if n % f == 0:
        return n
    else:
        return n // f * f + f

for i in range(n-1):
    now = S[i] + C[i]
    for j in range(i+1, n-1):
        now = f(now, S[j], F[j]) + C[j]
    print(now)
print(0)

Measured memory_bytes: 9244
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) < *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

int main(void) {
	char S[11];

	scanf("%s", S);

	size_t maxLength = 0;
	size_t len = 0;
	for (size_t i = 0; i < strlen(S); i++) {
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
			len++;
		}
		else {
			if (maxLength < len) {
				maxLength = len;
			}

			len = 0;
		}
	}

	if (maxLength < len) {
		maxLength = len;
	}

	printf("%zu\n", maxLength);

	return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N;
    vector<ll> D;
    cin >> N;
    for (int i = 0; i < N; i++) {
        ll d; cin >> d;
        D.pb(d);
    }
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            ans += D[i]*D[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3572
import java.util.Scanner;

public class  Main
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n>0)
		{
			double ax=sc.nextDouble();
			double ay=sc.nextDouble();
			double bx=sc.nextDouble();
			double by=sc.nextDouble();
			double cx=sc.nextDouble();
			double cy=sc.nextDouble();
			double dx=sc.nextDouble();
			double dy=sc.nextDouble();

			if((ay-by)/(ax-bx) == (cy-dy)/(cx-dx))
				System.out.println("YES");
			else
				System.out.println("NO");
			n--;
		}

	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    bool is_four = false;
    for (int i = 0; i < n; i++){
        string s;
        cin >> s;
        if (s == "Y") is_four = true;
    }
    if (is_four)
 	    cout << "Four" << endl;
    else
        cout << "Three" << endl;
	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    ll N,K; cin >> N >> K;
    VI A(N); REP(i,N) cin >> A[i];
    VVI pos(202020); REP(i,N) pos[A[i]].push_back(i);
    VI nxt(N,-1);
    REP(i,202020){
        if(pos[i].empty()) continue;
        REP(j,pos[i].size()-1) nxt[pos[i][j]] = pos[i][j+1];
        nxt[pos[i].back()] = pos[i][0];
    }

    ll idx = -1, T = 1;
    while(idx != N-1){
        idx++;
        if(nxt[idx] <= idx) T++;
        idx = nxt[idx];
    }
    K %= T;
    idx = -1;
    while(K > 0){
        idx++;
        if(K == 1 && nxt[idx] <= idx) break;
        if(nxt[idx] <= idx) K--;
        idx = nxt[idx];
    }

    if(idx < 0) idx = N;
    deque<int> deq;
    vector<bool> exist(202020,false);
    FOR(i,idx,N){
        if(exist[A[i]]){
            while(exist[A[i]]){
                exist[deq.back()] = false;
                deq.pop_back();
            }
        }
        else{
            deq.push_back(A[i]);
            exist[A[i]] = true;
        }
    }

    while(!deq.empty()){
        cout << deq.front() << " ";
        deq.pop_front();
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 14848
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner input = new Scanner(System.in);
		long n = input.nextLong();
		long m = input.nextLong();
		
		long ans = (n*(n-1))/2 + (m*(m-1))/2;
		System.out.println(ans);
	}
}


Measured memory_bytes: 23124
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let code: String = sc.read();
    let mut lc = 'n';
    for c in code.chars(){
        if lc == c {
            println!("Bad");
            return;
        }
        lc = c;
    }
    println!("Good");
}

Measured memory_bytes: 4352
h,w,k = map(int,input().split())
inc = 0
def p():
    global inc
    inc += 1
    return inc
S = [[0 if s=='.' else p() for s in input()] for i in range(h)]
for i in range(1,h):
    for j in range(w):
        if S[i][j]!=0:
            continue
        S[i][j] = S[i-1][j]
for i in range(h-2,-1,-1):
    for j in range(w):
        if S[i][j]!=0:
            continue
        S[i][j] = S[i+1][j]
for i in range(h):
    for j in range(1,w):
        if S[i][j]!=0:
            continue
        S[i][j] = S[i][j-1]
for i in range(h):
    for j in range(w-2,-1,-1):
        if S[i][j]!=0:
            continue
        S[i][j] = S[i][j+1]
for i in range(h):
    print(*S[i])

Measured memory_bytes: 7504
#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#include <bitset>
#include <iomanip>
#include <map>
#include <queue>
#include <numeric>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    ll N;
    cin >> N;
    for (int i = (int)std::sqrt(N); i > 0; i--) {
        if (N % i == 0) {
            cout << std::max((int)std::log10(i) + 1, (int)std::log10(N / i) + 1) << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 512
#include<cstdio>
#include<cmath>
long long n,cnt,ans=0,t;
int main()
{
    scanf("%lld",&n);
    for(t=sqrt(n);t>0;t--)
    {
        if(!(n%t))
		{
            cnt=n/t;
            break;
        }
    }
    while(cnt)
	{
        ans++,cnt/=10;
    }
    printf("%lld",ans);
}

Measured memory_bytes: 128