akhauriyash/Code-Regression huggingface dataset:
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T& v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

const int INF = 20000000;

void dfs(int v, int p, vector<int> &dist, vector<int> G[]) {
  if (dist[v] != INF) return;
  if (p != -1) dist[v] = dist[p] + 1;
  else dist[v] = 0;
  for (auto&u: G[v]) {
    if (u == p) continue;
    dfs(u, v, dist, G);
  }
}

void solve(int n, int s, int t, vector<int> &fromS, vector<int> fromT, vector<int> G[]) {
  vector<bool> done(n, false);
  priority_queue<pair<int, int> > Qs, Qt;
  Qs.push({ fromT[s], s });
  Qt.push({ fromS[t], t });
  while (Qs.size() and Qt.size()) {
    auto qs = Qs.top(); Qs.pop();
    while (done[qs.second] and Qs.size()) {
      qs = Qs.top(); Qs.pop();
    }
    if (done[qs.second]) {
      print("Snuke");
      return;
    }
    done[qs.second] = true;
    
    auto qt = Qt.top(); Qt.pop();
    while (done[qt.second] and Qt.size()) {
      qt = Qt.top(); Qt.pop();
    }
    if (done[qt.second]) {
      print("Fennec");
      return;
    }
    done[qt.second] = true;
    
    // print("Fennec", " ");
    // print(qs.second+1);
    // print("Snuke", " ");
    // print(qt.second+1);
    {
      for (auto &&u: G[qs.second]) {
        if (done[u]) continue;
        Qs.push({ -fromT[u], u }); // Tに近い方から取る.
      }
    }
    {
      for (auto &&u: G[qt.second]) {
        if (done[u]) continue;
        Qt.push({ -fromS[u], u }); // Sに近い方から取る.
      }
    }
  }
  
  if (Qs.size()) print("Fennec");
  else print("Snuke");
}


void solve2(int n, int s, int t, vector<int> &fromS, vector<int> &fromT, vector<int> G[]) {
  int cnt = 0;
  loop(i,0,n) {
    // TよりもSに近いところはFennecが取れる.
    cnt += fromS[i] <= fromT[i];
  }
  int ok = n-cnt;
  if (cnt > ok) print("Fennec");
  else print("Snuke");
}

int main() {
  int n;in(n);
  vector<int> G[n];
  loop(i,0,n-1) {
    int a, b; in(a),in(b);
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int s = 0, t = n-1;
  vector<int> fromS(n, INF), fromT(n, INF);
  dfs(s, -1, fromS, G);
  dfs(t, -1, fromT, G);
  
  solve2(n, s, t, fromS, fromT, G);
  return 0;
}


Measured memory_bytes: 15680
module Main

open System

let ab =
    Console.ReadLine().Split(' ')
        |> Array.map
            (fun x ->
                if int x = 1 then
                    14
                else
                    int x
            )

Console.WriteLine(
    if ab.[0] < ab.[1] then
        "Bob"
    elif ab.[0] > ab.[1] then
        "Alice"
    else
        "Draw"
)


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    int z=a+b;
    if(z&1==1)printf("IMPOSSIBLE");
    else {
            z=(a+b)/2;
            printf("%d",z);
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define MAX 100
#define THOU 1000
#define FIVEMAX 100000
#define NINEMAX 1000000000
#define TWEMAX 1000000000000
#define rep(i,n) for (int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define darep(i,a,n) for(int i=n,i>=a;i--)
 
int main(){
 cin.tie(0);
 ios::sync_with_stdio(false);
 
 //ll a[2*FIVEMAX+1];
 //ll s[2*FIVEMAX+1];
 
 int n;
 
 cin>>n;
 vector<ll>a(n);
 vector<ll>s(n+1,0);
 for(int i=0;i<n;i++)cin>>a[i];
 
 for(int i=0;i<n;i++){
     s[i+1]=s[i]+a[i];
 }
 
ll nine=NINEMAX+7;
ll amari=0;
for(int i=0;i<n;i++){
    ll b = (s[n]-s[i+1])%nine;
    amari+=b*(a[i]%nine)%nine;
    amari=amari%nine;
}

cout<<amari<<endl;
return 0;
}

Measured memory_bytes: 6332
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    vector<int> V(N);rep(i, N) cin >> V[i];
    vector<int> C(N);rep(i, N) cin >> C[i];
    vector<int> add(N);rep(i, N) add[i] = V[i] - C[i];
    int ans = 0;
    rep(i, N) {
        if(add[i] >= 0) {
            ans += add[i];
        }
    }
    cout << ans << endl;

 

    return 0;
}

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

int main(){
  int N;
  cin>>N;
  int x=0;
  for(int i=0;i<N;i++){
    int p,q;
    cin>>p>>q;
    int R=q-p+1;
    x+=R;
  }
  cout<<x<<endl;
}
    


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdint>
using namespace std;

int main() {
    int n; cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        int a; cin >> a;
        if ((i & 1) && (a & 1)) ++ans;
    }

    cout << ans << endl;
}



Measured memory_bytes: 3632
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        System.Diagnostics.Debug.WriteLine("-----TextFile1");
        System.Diagnostics.Debug.WriteLine(process("../TextFile1.txt"));
        System.Diagnostics.Debug.WriteLine("-----TextFile2");
        System.Diagnostics.Debug.WriteLine(process("../TextFile2.txt"));
        System.Diagnostics.Debug.WriteLine("-----TextFile3");
        System.Diagnostics.Debug.WriteLine(process("../TextFile3.txt"));
#endif

#if !DEBUG
        String ret = process(new System.IO.StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static string process(string filePath) {
        using (var input = new System.IO.StreamReader(filePath)) {
            if(input.EndOfStream) return "NO PROC";
            return process(input);
        }
    }

    static string process(System.IO.TextReader input) {
        int n     = int.Parse(input.ReadLine());
        
        long r = 1;
        for(int i=1; i<=n; i++) {
            r *= (long)i;
            if (r >= 1000000007L) r %= 1000000007L;
        }

        r = r % 1000000007L;
        return r + "";
    }
    
}

Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound 
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define vi vector<int> 
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
    
	const int N =1e6;
    
     int mod= 1e9+7;
     
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};
   
   
   
    int sum;
     void solve(){
          
          
          int n;
          cin>>n;
          
          vi b(n-1,0),a(n,0);
          
          rep(i,0,n-1)
            cin>>b[i];
          
          rep(i,0,n-1){
			  if(i==0){
				  a[i]=b[i];
				  a[i+1]=b[i];				  
			  }
			  
			  else
			     a[i+1]=b[i];
		  }
		  
		  rep(i,0,n-1){
			  
			  if(b[i]==max(a[i],a[i+1]))
			     continue;
			  else{
				 if(a[i]>b[i])
				  a[i]=a[i+1];
				 else
				  a[i+1]=a[i];			  
			  }		     
		  }
		  
		  rep(i,0,n){
		    //~ cout<<a[i]<<" ";
		    sum+=a[i];
		}  
          cout<<sum<<endl;
            
      
     }
   
   
   
   
      int32_t main() {
	    cool;
	    int t=1;
        //cin>>t;
	    while(t--)
	       solve();
	       
	       
	       return 0;	   
	   }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e6;
int main() {
  int H, W;
  cin >> H >> W;
  vector<string> s(H);
  REP(i, H) { cin >> s[i]; }
  vector<vector<int>> dis(H, vector<int>(W, -INF));
  queue<P> que;
  que.push(P(0, 0));
  dis[0][0] = 1;
  while (!que.empty()) {
    P p = que.front();
    que.pop();
    int y = p.first, x = p.second;
    if (0 < x) {
      int nx = x - 1, ny = y;
      if (s[ny][nx] == '.') {
        if (dis[ny][nx] == -INF) {
          dis[ny][nx] = dis[y][x] + 1;
          que.push(P(ny, nx));
        }
      }
    }
    if (x < W - 1) {
      int nx = x + 1, ny = y;
      if (s[ny][nx] == '.') {
        if (dis[ny][nx] == -INF) {
          dis[ny][nx] = dis[y][x] + 1;
          que.push(P(ny, nx));
        }
      }
    }
    if (0 < y) {
      int nx = x, ny = y - 1;
      if (s[ny][nx] == '.') {
        if (dis[ny][nx] == -INF) {
          dis[ny][nx] = dis[y][x] + 1;
          que.push(P(ny, nx));
        }
      }
    }
    if (y < H - 1) {
      int nx = x, ny = y + 1;
      if (s[ny][nx] == '.') {
        if (dis[ny][nx] == -INF) {
          dis[ny][nx] = dis[y][x] + 1;
          que.push(P(ny, nx));
        }
      }
    }
  }
  if (dis[H - 1][W - 1] == -INF) {
    cout << -1 << endl;
    return 0;
  }
  ll tmp = 0;
  REP(i, H) REP(j, W) {
    if (s[i][j] == '.') tmp++;
  }
  cout << tmp - dis[H - 1][W - 1] << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(void){
    int n,x,i,j,k,cnt;
    while(1){
        cnt=0;
        scanf("%d %d",&n,&x);
        if(n==0 && x==0) break;
        for(i=1;i<=n;i++){
            for(j=1;j<=n;j++){
                for(k=1;k<=n;k++){
                    if(i==j || i==k || j==k) continue;
                    if((i+j+k)==x) cnt += 1; 
                }
            }
        }
        printf("%d\n",cnt/6);
    }
    return 0;
}


Measured memory_bytes: 2076
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
// istream& operator>>(istream& is, mint& a) { return is >> a.x;}
// ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    mint ans = 0;
    mint s = 0, t = 0;;
    rep(i, n){
        s += a[i];
        t += a[i]*a[i];
    }
    ans = (s*s-t)/2;
    cout << ans.x << endl;
    
}

Measured memory_bytes: 4788
#include <bits/stdc++.h>
using namespace std;
static const int MAX = 100000;
static const int INFTY = (1<<30);

class Edge {
public:
  int t, w;
  Edge(){}
  Edge(int t, int w): t(t), w(w) {}
};

vector<Edge> G[MAX];
int n, d[MAX];

bool vis[MAX];
int cnt;

void bfs(int s){
	for (int i = 0; i < n; i++) d[i] =INFTY;
	queue<int> Q;
	Q.push(s);
	d[s] = 0;
	int u;
	while( !Q.empty()) {
		u = Q.front(); Q.pop();
		for(int i =0; i < G[u].size(); i++) {
			Edge e = G[u][i];
			if (d[e.t] == INFTY) {
				d[e.t] = d[u] + e.w;
				Q.push(e.t);
			}
		}
	}
}

void solve(){
	bfs(0);
	int maxv = 0;
	int tgt = 0;
	for (int i = 0; i < n; i++) {
		if (d[i] == INFTY) continue;
		if(maxv < d[i]) {
			maxv = d[i];
			tgt = i;
		}
	}

	bfs(tgt);
	maxv = 0;
	for (int i =0; i < n; i++) {
		if ( d[i] == INFTY) continue;
		maxv = max(maxv, d[i]);
	}
	cout << maxv << endl;
}

int main() {
	int s, t, w;
	cin >> n;

	for (int i = 0; i< n-1; i++) {
		cin >> s >> t >> w;
		G[s].push_back(Edge(t, w));
		G[t].push_back(Edge(s, w));
	}
	solve();
}



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

using namespace std;

int main() {
    cin.tie(NULL);
    ios::sync_with_stdio(false);
	#if LOCAL
	freopen("c.in", "r", stdin);
	#endif
	int N,M;
	cin>>N>>M;
    vector<pair<int,int>> vp;
    for(int i=0;i<N;i++) {
        int price,amount;
        cin>>price>>amount;
        vp.emplace_back(price,amount);
    }
    sort(vp.begin(),vp.end());
    long long m=0,sum=0,am;
    for(int i=0;i<N && m<M;i++) {
        am = min(M-m,(long long)vp[i].second);
        //cout<<"am "<<am<<endl;
        m+=am;
        sum+=am*vp[i].first;
    }
    cout<<sum<<endl;

	return 0;
}



Measured memory_bytes: 1400
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

class UnionFindTree {
public:
    this(size_t n) {
        parent = iota(n).array();
        rank = new size_t[](n);
    }
    size_t find(size_t n) {
        if(n == parent[n]) {
            return n;
        } else {
            parent[n] = find(parent[n]);
            return parent[n];
        }
    }
    void unite(size_t n, size_t m) {
        auto p1 = find(n);
        auto p2 = find(m);
        if(n == m) {
            return;
        }
        if(rank[p1] < rank[p2]) {
            swap(p1, p2);
        }
        if(rank[p1] == rank[p2]) {
            ++rank[p1];
        }
        parent[p2] = p1;
    }
private:
    size_t[] parent;
    size_t[] rank;
}
unittest {
    auto uft = new UnionFindTree(10);
    foreach(i; iota(10)) {
        assert(uft.find(i) == i);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0).drop(1)) {
        uft.unite(i, i-3);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0)) {
        assert(uft.find(0) == uft.find(i));
    }
    foreach(i; iota(10).filter!(a => a%3 != 0)) {
        assert(uft.find(0) != uft.find(i));
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    auto s = readln.chomp();
    long[long] dp;
    dp[0] = 0;
    long m;
    foreach(i; iota(s.length)) {
        m ^= 1 << (s[i] - 'a');
        long tmp = i+1;
        foreach(j; iota(27)) {
            auto x = (1 << j) & ((1 << 26)-1);
            if((m ^ x) in dp) {
                tmp = min(tmp, dp[m^x] + 1);
            }
        }
        if(i < s.length - 1 && m in dp) {
            dp[m] = min(tmp, dp[m]);
        } else {
            dp[m] = tmp;
        }
    }
    writeln(dp[m]);
}



Measured memory_bytes: 18360
#include<bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define mp make_pair
#define REP(i,a,b) for(ll i=a;i<b;i++)
typedef long long ll;
using namespace std;

void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}


int main(){

FAST();


string s,t; cin>>s>>t;

cerr<<s<<endl<<t;

ll count=0;


for(int i=0;i<s.length();i++){

	if(s[i]!=t[i])
		  count++;
		
}

cout<<count<<endl;
return 0;
}

Measured memory_bytes: 3880
from sys import stdin
input = stdin.readline
def BFS(K,edges,N):
  dist=[-1]*N
  stack=[]
  stack.append(K)
  dist[K]=0
  while stack:
    label=stack.pop(-1)
    for i,c in edges[label]:
      if dist[i]==-1:
        dist[i]=dist[label]+c
        stack+=[i]
  return dist
 
N=int(input())
edges=[ [] for i in range(N)]
for i in range(N-1):
  a,b,c=map(int,input().split())
  edges[a-1]+=[(b-1,c)]
  edges[b-1]+=[(a-1,c)]
Q,K=map(int,input().split())
xy=[list(map(int,input().split())) for i in range(Q)]
distance=BFS(K-1,edges,N)
for i in range(Q):
  print(distance[xy[i][0]-1]+distance[xy[i][1]-1])

Measured memory_bytes: 67744
N,M = map(int,input().split())
a=[0]*M
b=[0]*M
c=set() #最初の候補地

for i in range(M):
  a[i],b[i]=map(int,input().split())
  if a[i]==1:
    if b[i] not in c:
      c.add(b[i])
    
for j in range(M):
  if a[j]!=1:
    if a[j] in c:
      if b[j]==N:
        print("POSSIBLE")
        break
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 20588
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  int n;
  string a,b,c;
  cin>>n>>a>>b>>c;

  int ans = 0;
  rep(i,n){
    set<char> s;
    s.insert(a[i]);
    s.insert(b[i]);
    s.insert(c[i]);
    ans += s.size() - 1;
  }

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


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int a[1000000]={0};
int main(){
	
	a[0]=1;
	a[1]=1;
	for(int i=2;i<=(int)sqrt(1000000);i++){
		if(a[i]==0){
		for(int j=2*i;j<1000000;j+=i){
			a[j]=1;
		}
	}
}
	int n;
	cin>>n;
	int i=n;
	while(a[i]!=0){
		i++;
		}
		cout<<i;
}


Measured memory_bytes: 7520
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,k,l,sum=0,r=0,g=0,b=0;
    cin>>n;
    string s;
    cin>>s;
    for(i = 0 ;i<n ;i++)
    {
        if(s[i]=='R')
            r++;
        else if(s[i]=='G')
            g++;
        else if(s[i]=='B')
            b++;
    }
    sum=r*g*b;
    for(i = 0 ;i<n-2 ;i++)
    {
        for(j=i ,l=i ;l<n;j++,l+=2)
        {
            if(s[i]!=s[j]&& s[j]!=s[l] &&s[i]!=s[l])
                sum--;
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3640
def main():
    n = int(input())
    a = list(map(int, input().split()))

    t = 0
    for i in range(n):
        d = a[i]
        while d % 2 == 0:
            d //= 2
            t += 1

    print(t)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4148
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define exp pow(10,-9)
#define F first
#define S second
#define PB push_back 
#define MP make_pair
#define daman ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define lowercase(str) transform(str.begin(), str.end(), str.begin(), ::tolower);
#define uppercase(str) transform(str.begin(), str.end(), str.begin(), ::toupper);
main()
{
	string str;
	cin>>str;
	
	if(str.length() == 6 && str[2] == str[3] && str[4] == str[5])
		cout<<"Yes\n";
	else
		cout<<"No\n";
}

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

int main() {
    long int N, x;
    cin >> N >> x;
    long int temp;
    vector<long int> child;
    for (int i = 0; i < N; ++i) {
        cin >> temp;
        child.push_back(temp);
    }
    sort(child.begin(), child.end());
    int ans = 0;
    for (int j = 0; x > 0; ++j) {
        if(x >= child[j]) {
            if(j == N - 1 && x > child[j]) {
                break;
            }
            ++ans;
            x -= child[j];
        } else {
            break;
        }
    }
    cout << ans << endl;
}

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

int main(){
    int A,B,C,D; cin >> A >> B >> C >> D;
    int cnt = 0;
    while(A > 0 && C > 0){
        if(cnt % 2 == 0) {
            C -= B;
            cnt++;
        }else{
            A -= D;
            cnt++;
        } 
    }

    if(A <= 0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
using namespace std;

#define WAY(s) (s=='W' ? 0 : 1)

int main() {
  int N;
  char S[3*100000 + 100];
  cin >> N >> &S[1];
  int A[2][3*100000 + 100];

  A[0][0] = A[0][1] = 0;
  A[WAY(S[1])][1] = 1;

  for (int i = 2; i <= N; ++i) {
    A[WAY(S[i])][i] = A[WAY(S[i])][i-1]+1;
    A[WAY(S[i])^1][i] = A[WAY(S[i])^1][i-1];
  }

  unsigned ans = 1 << 30;
  for (int i = 1; i <= N; ++i) {
    unsigned tmp = A[0][i-1] + A[1][N] - A[1][i];
    ans = min(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2944
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; ++i){
            a[i] = in.nextInt();
        }
        Arrays.sort(a);

        int max = a[1];
//        System.out.println("max: " + max);
    
        for (int i = max; i >= 1 ; i--){
//            System.out.println("i: " + i);
            int count = 0;
            for (int j = 0; j < n; ++j){
                if (a[j]%i != 0){
                    count++;
                }
            }
//            System.out.println("count: " + count);
            if (count == 1 || count == 0){
                System.out.println(i);
                break;
            }
        }
    }
}


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

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

    int ans = 0;
    for(int i = 0; i < n; i+=2) {
        if(a[i] % 2 != 0) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>

using namespace std;


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

    vector<long long> score(n);
    for(int i=0; i<n; ++i){
        cin >> score[i];
    }

    long long cumsum = 0;
    for(int i=0; i<k; ++i){
        cumsum += score[i];
    }

    long long current_score = cumsum;
    for(int i=k; i<n; ++i){
        cumsum -= score[i - k];
        cumsum += score[i];

        if(current_score < cumsum){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
        current_score = cumsum;
    }
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
const int nmax=3005;
ll a[nmax],dp[nmax][nmax];
bool mem[nmax][nmax];
int n;
ll f(int l,int r){
    if(mem[l][r]){
        return dp[l][r];
    }
    if(l==r){
        mem[l][r]=true;
        return dp[l][r]=0;
    }
    if((l+n-r)%2==0){
        mem[l][r]=true;
        return dp[l][r]=max(a[l]+f(l+1,r),a[r-1]+f(l,r-1));
    }
    else{
        mem[l][r]=true;
        return dp[l][r]=min(-a[l]+f(l+1,r),-a[r-1]+f(l,r-1));
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    REP(i,n){
        cin >> a[i];
    }
    cout << f(0,n) << endl;
}

Measured memory_bytes: 58800
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	mi := int(1e15 + 1)
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			mi = min(mi, i+n/i)
		}
	}
	fmt.Println(mi - 2)
}

func min(a, b int)int{
	if a > b{
		return b
	}
	return a
}

Measured memory_bytes: 1788
import bisect

n = int(input())
a_li = list(map(int, input().split()))
b_li = list(map(int, input().split()))
c_li = list(map(int, input().split()))

a_li.sort()
b_li.sort()
c_li.sort()

ans = 0

for i in b_li:
    s = bisect.bisect_right(c_li, i)
    s_num = n-s
    
    t = bisect.bisect_left(a_li, i)
    t_num = t
    
    ans += s_num * t_num

print(ans)

Measured memory_bytes: 29508
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll r,d,x_2000;
  cin>>r>>d>>x_2000;
  for(ll i=0;i<10;i++){
    x_2000=r*x_2000-d;
    cout<<x_2000<<endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

double dp[3010][3010];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll n;
  cin >> n;
  vector<double> p(n);
  REP(i, n) cin >> p[i];

  dp[0][0] = 1-p[0], dp[0][1] = p[0];
  FOR(i, 1, n) REP(j, i+2) {
    dp[i][j] = dp[i-1][j-1] * p[i] + dp[i-1][j] * (1-p[i]);
  }

  double ans = 0;
  FOR(i, n/2+1, n+1) ans += dp[n-1][i];
  cout << fixed << setprecision(15) << ans << endl;

  return 0;
}


Measured memory_bytes: 69120
/*
           Nothing is absolute.
     This is the only absolute truth.
*/

#include<bits/stdc++.h>

using namespace std;

using ull = unsigned long long;
using ll = long long;

#define READ freopen("in.txt", "r", stdin)
#define ROUT freopen("out.txt", "w", stdout)
#define pb push_back
#define endl '\n'

#define REP(i,a,b) for(int i=a; i<=b; i++)
#define arrL(i,a,b) for(int i=a; i<b; i++)

void fasterIO()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

void fileIO()
{
    READ;
    ROUT;
}

void solve()
{
    int n, k;

    cin>>n>>k;

    if(n==1 || k==1)
        cout<<0<<endl;
    else
        cout<<n-k<<endl;
}

int main()

{
    ///fileIO();
    fasterIO();

    solve();

    return 0;
}


Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    N, M, X = [int(item) for item in input().split()]
    As = [int(item) for item in input().split()]

    low = [item for item in As if item < X]
    high = [item for item in As if item > X]

    print(min(len(low), len(high)))


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9072
#include <bits/stdc++.h>
#define ll long long
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;

int main() {
  INIT;
  
  int a,b;
  cin >> a >>  b;// >> c >> d;

  if (a == 1) a=14;
  if (b == 1) b=14;
  if(a>b){
    cout << "Alice" << endl;
  }
  else if(a<b){
    cout << "Bob" << endl;
  }
  else{
    cout << "Draw" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#2
#-879 981
#-866 890
def f():
    N = int(input())
    a = []
    for i in range(N):
        aa = list(map(int, input().split(" ")))
        a.append(aa)
    
    s = [False]*N
    ta = []
    dm = {}
    ad = []
    dfs(a, s, ta, dm, ad)
    r = sum(ad)/len(ad)
    print(r)
    
def dfs(a, s, ta, dm, ad):
    if len(ta) == len(s):
        pr = ta[0]
        dd = 0
        for p in ta:
            pp = str(pr) + str(p)
            if pp in dm:
                dd += dm[pp]
            else:
                dp = ((p[0] - pr[0])**2 + (p[1] - pr[1])**2)**0.5 
                dm[pp] = dp
                dm[str(p) + str(pr)] = dp
                dd += dp
            pr = p
        ad.append(dd)
            
    for i in range(len(a)):
        if s[i] == False:
            s[i] = True
            ta.append(a[i])
            dfs(a,s, ta,dm, ad)
            ta.pop()
            s[i] = False

f()

    

Measured memory_bytes: 4680
// 23
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) \
  M(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep4(_, x, n, s) \
  for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define rep1(n) rep2(i, n)
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
#ifdef DEBUG
// 3
ostream &operator<<(ostream &o, pair<auto, auto> p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 4
ostream &operator<<(ostream &o, vector<auto> v) {
  rep(i, len(v)) o << setw(7) << right << v[i];
  return o << endc << endl << coutc;
}
// 4
ostream &operator<<(ostream &o, map<auto, auto> m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
void debug(const auto &e, const auto &... r) {
  cerr << coutc << e;
  ((cerr << " " << r), ..., (cerr << endc << endl));
}
#else
#define debug(...)
#endif
// 3
const ld pi = acos(-1);
void _main(int tc) {
  ld a, b, h, m;
  cin >> a >> b >> h >> m;
  ld angm = (m * pi) / 30.0;
  h = h + m / 60;
  ld angh = (h * pi) / 6.0;
  
  ld anglebetween = abs(angh - angm);
  debug((angh * 180) / pi, (angm * 180) / pi, (anglebetween * 180) / pi);
  // c^2 = a^2 + b^2 - 2ab * cos()
  ld c = sqrt(a * a + b * b - 2 * a * b * cos(anglebetween));
  cout << fixed << setprecision(10) << c << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 4180
#include <bits/stdc++.h>
using namespace std;
long long fs=0,n;
string s;
map<string,long long> mp;
vector<string> ans;
int main(){
	long long i;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>s;
		sort(s.begin(),s.end());
		mp[s]++;
		if(mp[s]==1)
		{
			ans.push_back(s);
		}
	}
	for(i=0;i<ans.size();i++)
	{
		if(mp[ans[i]]>1)
		{
			fs+=mp[ans[i]]*(mp[ans[i]]-1)/2;
		}
	}
	cout<<fs<<endl;
	return 0;
}

Measured memory_bytes: 16628
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B

solve :: B.ByteString -> Char -> Int
solve bs wb
    | B.null bs || B.all (==wb') bs = 0
    | otherwise = 1 + solve (B.dropWhile (/=wb) bs) wb'
    where
        wb' = if wb == 'W' then 'B' else 'W'

main = do
    bs <- B.getLine
    print $ min (solve bs 'W') (solve bs 'B')

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

int  main(){
string x;
cin>>x;
if(x[0]!='A')
{cout<<"WA";return 0;}
int sum=0;
for(int i=0;i<x.size();i++)
{
    if(x[i]-'A'<26&&x[i]!='A'&&x[i]!='C')
    {
        cout<<"WA";
        return 0;
    }
}
for(int i=2;i<x.size()-1;i++)
{
    if(x[i]=='C')
        sum++;
}
if(sum==1)
    cout<<"AC";
else
    cout<<"WA";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100000],b[100000];
ll dp[1000][100001];
ll knapsack(ll n,ll w)
{
    	if(dp[n][w]!=-1)
            return dp[n][w];
        if(w-a[n-1]<0)
        	return dp[n][w] = knapsack(n-1,w);
        else
        return dp[n][w] = max(knapsack(n-1,w-a[n-1])+b[n-1] , knapsack(n-1,w));

}
int main() {
	ll n,w;
	cin>>n>>w;
	for(ll i=0;i<n+1;i++)
	{
		for(ll j=0;j<=w;j++)
		{
			dp[i][j]=-1;
		}
	}
	for(ll i=0;i<w+1;i++)
	{
		dp[0][i]=0;
	}
	for(ll i=0;i<n+1;i++)
	{
		dp[i][0]=0;
	}
	for(ll i=0;i<n;i++)
	{
	    cin>>a[i]>>b[i];
	}
	cout<<knapsack(n,w);
	return 0;
}

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

using namespace std;

int main()
{
    while(1)
    {
        string number;
        cin >> number;
        
        if(number == "0")
        { break; }
        
        int ans = 0;
        
        for(size_t i = 0; i < number.size(); ++i)
        { ans += number[i] - '0'; }
    
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3204
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    int A, B, C;
    cin >> A >> B >> C;

    int ans = 0;
    if (A + B >= C) {
        cout << B + C << endl;
    }
    else {
        ans += (A + B) + 1;
        ans += B;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define debug(a) cout << #a ": " << a << endl
using namespace std;
typedef long long ll;
const double eps = 1e-9;
ll a, b, n;
inline ll calc(ll x){
    return a*x/b - a*(x/b);
}
int main(void){
    IOS;
    cin >> a >> b >> n;
    if (n <= b){
        cout << calc(min(n, b-1)) << endl; return 0;
    }
    ll l = b+1, r = n, ans = b;
    while (l < r-10){
        ll m1 = (l+r) >> 1;
        ll m2 = (m1+r) >> 1;
        if (calc(m1) > calc(m2)){
            ans = m1;
            r = m2-1;
        }else{
            l = m1+1;
        }
    }
    for (ll i = l; i <= r; ++i){
        if (calc(i) > calc(ans)) ans = i;
    }
    cout << max(calc(ans), calc(b-1)) << endl;
    return 0;
}

Measured memory_bytes: 3452
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define rg register
#define ll long long
#define CL(a,b) memset(a,b,sizeof a)
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a>c&&c>b||a<c&&c<b) cout<<"Yes";
    else cout<<"No";
    return 0;
}



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

int main(){
    long long N, A, B, ans = 0, tmp;
    cin >> N >> A >> B;

    tmp = A + B;
    ans += A * (N / tmp);

    ans += min(A, N % (A + B));
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n;i>s;i--)
#define rep_re(i,s,n)for(int i = n;i>=s;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 999;// 1e25;
static const ll MAX_N = 100001;

ll dp[51][510][510];
ll A[41];
ll B[41];
ll C[41];
void chmin(long long &a, long long b) { if (a > b) a = b; }

int  main() {
	ll n, ma, mb; cin >> n >> ma >> mb;
	ll M = 510;
	//repe(i, 1, n) cin >> A[i] >> B[i] >> C[i];
	rep(i, 0, n) cin >> A[i] >> B[i] >> C[i];

	rep(i, 0, 51)rep(j, 0, M)rep(k, 0, M) dp[i][j][k] = INF;

	dp[0][0][0] = 0;

	rep(i, 0, n) {//
		repe(a, 0, 500) {
			repe(b, 0, 500)
			{
				if (dp[i][a][b] < INF) {
					// 使わない
					chmin(dp[i + 1][a][b], dp[i][a][b]);

					// 使う
					chmin(dp[i + 1][a + A[i]][b + B[i]], dp[i][a][b] + C[i]);
					//dp[i + 1][a][b] = dp[i][a][b];
					//dp[i + 1][a + A[i]][b + B[i]] = min(dp[i + 1][a + A[i]][b + B[i]], dp[i][a][b] + C[i]);
				}
			}
		}
	}
	//repe(i, 1, n) {//
	//	repe(a, 0, M) {
	//		repe(b, 0, M)
	//		{
	//			if (dp[i - 1][a][b] != INF) {
	//				dp[i][a + A[i]][b + B[i]] = min(dp[i][a + A[i]][b + B[i]], dp[i - 1][a][b] + C[i]);
	//				dp[i][a][b] = dp[i - 1][a][b];
	//			}
	//		}
	//	}
	//}

	ll ans = INF;
	rep(aa, 1, 500) {
		rep(bb, 1, 500) {
			//if (dp[n][aa][bb] == INF) continue;
			if (aa * mb != bb * ma) continue;
			chmin(ans, dp[n][aa][bb]);
			//ans = min(ans, dp[n][aa][bb]);
		}
	}
	if (ans < INF) cout << ans << endl;
	else cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 103936
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<string>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#define UP(i,l,h) for(int i=l;i<h;i++)
#define DOWN(i,h,l) for(int i=h-1;i>=l;i--)
#define W(a) while(a)
#define MEM(a,b) memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f3f3f3f3f
#define LL long long
#define MAXN 100010
#define SIZE 95
#define EPS 1e-10
#define MOD 1000000007

using namespace std;

int main() {
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d\n",(a-1)*(b-1));
}


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

using namespace std;

int main(void){
	int N;
	string S;
	cin >> N;
	cin >> S;
	int x,ans;
	ans = x = 0;
	for(int i=0;i<N;i++){
		if(S[i] =='I')x++;
		else if(S[i]=='D')x--;
		ans = std::max(x,ans);
	}
	cout << ans;
	return 0;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

map<string, int> mp;
int N;
string S[110000];
signed main() {
    cin >> N;
    rep(i, N) {
        cin >> S[i];
        mp[S[i]]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}

Measured memory_bytes: 7040
const long long MOD = 1e9 + 7;
const int N = 203010;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <bitset>
#include <deque>

using namespace std;

#define int long long

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(N);
    __ufact.resize(N);
    __rev.resize(N);
    __rev[1] = 1;
    for (int i = 2; i < N; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < N; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int n;
string s[700];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int i = n; i < 2 * n; i++) s[i] = s[i - n];
    int ans = 0;
    for (int d = 0; d < n; d++)
    {
        vector<string> a(n, string(n, ' '));
        for (int i = d; i < d + n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                a[i - d][j] = s[i][j];
            }
        }
        int t = 1;
        for (int i = 0; i < n; i++)
        {
            for (int j = i; j < n; j++)
            {
                if (a[i][j] != a[j][i]) t = 0;
            }
        }
        ans += t;
    }
    cout << ans * n;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


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

using namespace std;
#define pii pair <int , int>
#define F first
#define S second
const int N = 100, H = N/2;
bool A[N+10][N+10];

int main()
{
    int W, B; cin >> W >> B;
    // -------------------------------------------------------------------------
    for (int i = 2; i <= N; i += 2) for (int j = 1; j <= H; j++) A[i][j] = 1;
    for (int j = 2; j <= H; j+=2) for (int i = 1; i <= N; i++) A[i][j] = 1;

    for (int i = 1; i <= N; i++) for (int j = H+1; j <= N; j++) A[i][j] = 1;

    for (int i = 2; i <= N; i += 2) for (int j = 1; j <= H; j++) A[i][H+j] = 0;
    for (int j = 1; j <= H; j+=2) for (int i = 1; i <= N; i++) A[i][H+j] = 0;
    // --------------------------------------------------------------------------
    vector <pii> vec;
    for (int i = 1; i <= N; i++) for (int j = 1; j <= H; j++) if (A[i][j] == 0) vec.push_back({i, j});
    while (vec.size() > B - 1) {
        pii p = vec.back();
        A[p.F][p.S] = 1;
        vec.pop_back();
    }
    vec.clear();
    for (int i = 1; i <= N; i++) for (int j = H+1; j <= N; j++) if (A[i][j] == 1) vec.push_back({i, j});
    while (vec.size() > W - 1) {
        pii p = vec.back();
        A[p.F][p.S] = 0;
        vec.pop_back();
    }
    // -------------------------------------------------------------------------
    cout << N << " " << N << "\n";
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            if (A[i][j]) cout << '.';
            else cout << '#';
        }
        cout << "\n";
    }


    return 0;
}


Measured memory_bytes: 256
use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    // (j > i)
    // j - i = ai + aj
    // ai + i = j - aj
    let mut map: HashMap<i64, i64> = HashMap::new();
    let mut ret: i64 = 0;
    for i in 0..n {
        let v = i as i64 - a[i];
        ret += *map.get(&v).unwrap_or(&0);
        *map.entry(a[i] + i as i64).or_insert(0) += 1;
    }
    println!("{}", ret);
}


Measured memory_bytes: 11796
#include <bits/stdc++.h>
using namespace std;
map<string,int> mp;
int main()
{
    int n;
    cin >> n;
    string s;
    for(int i  = 0;i<n;++i)
    {
        cin >> s;
        if(mp.find(s)==mp.end())
            mp[s] = 0;
        ++mp[s];
    }
    int ma = 0;
    for(auto it = mp.begin();it!=mp.end();++it)
    {
        ma = max(ma,it->second);
    }
    for(auto it =mp.begin();it!=mp.end();++it)
    {
        if(it->second==ma)
            cout << it->first << endl;
    }
    return 0;
}


Measured memory_bytes: 25216