akhauriyash/Code-Regression huggingface dataset:
s = input()
s_cnt =0
t_cnt =0
cnt = 0

for i in range(len(s)):
    if s[i] == 'S':
        s_cnt += 1
    if s[i] == 'T':
        t_cnt += 1
        if s_cnt >0:
            t_cnt -= 1
            s_cnt -= 1
print(t_cnt + s_cnt)


Measured memory_bytes: 9092
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=5005,M=1e9+7;
int n,dp[N][N],k;
char s[N];
signed main(){
	scanf("%lld",&n);
	scanf("%s",s+1);
	int k=strlen(s+1);
	dp[0][0]=1; 
	for (int i=1;i<=n;i++)
		for (int j=0;j<=i;j++){
			if (!j)dp[i][j]=(dp[i-1][0]+dp[i-1][1])%M;
			else dp[i][j]=(2*dp[i-1][j-1]+dp[i-1][j+1])%M;
		}
	for (int i=1;i<=k;i++)(dp[n][k]*=(M/2+1))%=M;
	printf("%lld\n",dp[n][k]);
}

Measured memory_bytes: 194048
#include <stdio.h>
int asc(const void *a, const void *b)
{
    return *((int *)a + 2) - *((int *)b + 2);
}
int main()
{
    int n, m;
    int edge[400010][2] = {}; //[0]:辺の行き先，[1]：同じ頂点から出る次の辺の枠
    int node[100010] = {};    //各ノードから出る辺の最初の枠
    int a, b;
    int ans[100010];
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= m; i++)
    {
        scanf("%d %d", &a, &b);
        edge[i][0] = b;
        edge[i][1] = node[a];
        node[a] = i;
        edge[i + m][0] = a;
        edge[i + m][1] = node[b];
        node[b] = i + m;
    }
    int queue[100010] = {};
    int done[100010] = {};
    int start, end;
    int now, next, t;
    start = 0;
    end = 0;
    queue[0] = 1;
    done[1] = 1;
    while (start <= end)
    {
        now = queue[start]; //今いる部屋
        t = node[now];      //今いる部屋から出る辺の枠
        while (t != 0)
        {
            next = edge[t][0]; //nowから行ける部屋
            if (done[next] == 0)
            {
                //edge[t] 今いる部屋から出る辺
                queue[++end] = edge[t][0];
                ans[edge[t][0]] = now;
                done[next] = 1; //queueに追加済みかどうか
            }
            t = edge[t][1];
        }
        start++;
    }
    printf("Yes\n");
    for (int i = 2; i <= n; i++)
    {
        printf("%d\n", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 6392
#include <stdio.h>
#include <utility>
#include <vector>
#include <queue>
#include <bitset>
using namespace std;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
const int N=3e3+10;
const int INF=1e9+10;
int max(int a,int b){return a>b?a:b;}
int main(){
    int n,m,dis[N][N],top=0,l,r,d;
    bool f;
    bitset<N> used,went;
    priority_queue<pi,vector<pi>,greater<pi>>pq;
    pi now;
    vector<int> ans;
    vector<pi> graph[N],v;
    scanf("%d%d",&n,&m);
    while(m--){
        scanf("%d%d%d",&l,&r,&d);
        graph[l].PB({r,d});
        graph[r].PB({l,d});
    }
    used.reset();
    for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)dis[i][j]=INF;
    for(int i=1;i<=n;i++){
        went.reset();
        pq.push({0,i});
        dis[i][i]=0;
        while(!pq.empty()){
            now=pq.top();
            pq.pop();
            if(!went[now.S]){
                went[now.S]=true;
                for(pi j:graph[now.S])if(j.S+now.F<dis[i][j.F]){
                    dis[i][j.F]=j.S+now.F;
                    pq.push({dis[i][j.F],j.F});
                }
            }
        }
    }
    for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(dis[i][j]==top)v.PB({i,j});
    else if(dis[i][j]>top){
        top=dis[i][j];
        v.clear();
        v.PB({i,j});
    }
    for(int i=1;i<=n;i++)for(pi j:graph[i])if(!(used[i]&&used[j.F])){
        f=false;
        for(pi u:v)if(dis[u.F][i]+j.S+dis[j.F][u.S]==top||dis[u.F][j.F]+j.S+dis[i][u.S]==top){
            f=true;
            break;
        }
        if(f)used[i]=used[j.F]=true;
    }
    for(int i=1;i<=n;i++)if(!used[i])ans.PB(i);
    printf("%ld\n",ans.size());
    for(int i:ans)printf("%d\n",i);
}


Measured memory_bytes: 50284
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n+1);
  vector<int> ans(n+1);
  for(int i=1; i < n+1; i++) cin >> a[i];
  for(int i=n; i>=1; i--){
    int check=0;
    int multi = n/i;
    if(multi==1){
      ans[i] = a[i];
    }
    else{
      check=a[i];
      for(int j=1; j<multi;j++){
        if(ans[i*(j+1)]==1) check +=1;
      }
      ans[i] = check%2;
    }
  }
  int m=0;
  rep(i,n+1){
    if(ans[i]==1) m+=1;
  }
  cout << m << endl;
  rep(i,n+1){
    if(ans[i]==1) printf("%d ", i);
  } 
  
}


Measured memory_bytes: 2432
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    H, W = map(int, input().split())
    A = [list(input()) for _ in range(H)]

    res = []
    for h in range(H):
        for w in range(W):
            if A[h][w] == "#":
                res.append(A[h])
                break

    res2 = [[] for _ in range(len(res))]
    for w in range(W):
        for h in range(len(res)):
            if res[h][w] == "#":
                for k in range(len(res)):
                    res2[k].append(res[k][w])
                break

    for i in res2:
        print("".join(i))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3188
N = int(input())
dic = {}
plis = [2]
for i in range(3,150):
    s =True
    for p in plis:
        if i%p==0:
            s = False
    if s:
        plis.append(i)
for i in range(N):
    foo = 1
    for j in input():
        j = ord(j) - ord("a")
        foo *= plis[j]
    try:
        dic[foo] += 1
    except:
        dic[foo] = 1
ans = 0
for n in dic.values():
    ans += n*(n-1)//2
print(ans)

Measured memory_bytes: 15824
#include <stdio.h>
#include <stdlib.h>

int Sibling(int);
int degree(int);
int Depth(int);
int height(int);

void inorder(int);
void preorder(int);
void postorder(int);

typedef struct{
  int id;
  int parent;
  int left;
  int right;
}tree;

tree *TREE;

int N;

#define fr -1

int main(){
  int id,i,j,de,depth,ro,l,r;

  scanf("%d",&N);
  TREE = (tree *)malloc(sizeof(tree)*N);

  for(i=0;i<N;i++){
    //TREE[i].id = fr;
    TREE[i].parent = fr;
    //TREE[i].left = fr;
    //TREE[i].right = fr;
  }


  for(i=0;i<N;i++){
     scanf("%d %d %d",&j,&l,&r);
     TREE[j].id=j;
     TREE[j].left = l;
     TREE[j].right = r;
     if(TREE[j].left!=fr){
       TREE[TREE[j].left].parent = TREE[j].id;
     }

     if(TREE[j].right!=fr){
       TREE[TREE[j].right].parent = TREE[j].id;

     }
   }

  for(i=0;i<N;i++){
    if(TREE[i].parent == fr)ro = i;
  }


  printf("Preorder\n");
  preorder(ro);

  printf("\nInorder\n");
  inorder(ro);

  printf("\nPostorder\n");
  postorder(ro);


  printf("\n");

  return 0;
}

//Sibling Function!<f>
int Sibling(int id){
  int i;
  for(i=0;i<N;i++){
    if(TREE[id].parent == TREE[i].parent && id != i){
      return i;
    }
  }
  return -1;
}

//degree Function!<f>
int degree(int id){
  int i;
  if(TREE[id].left != -1 && TREE[id].right != -1){
    return 2;
  }
  else if(TREE[id].left != -1 || TREE[id].right != -1){
    return 1;
  }
  else return 0;
}

//depth Function!<f>
int Depth(int id){
  int i = TREE[id].parent;
  int depth = 0;
  while(i!=fr){
    i = TREE[i].parent;
    depth++;
  }
  return depth;
}

//height Function
int height(int id){
  int lheight=0,rheight=0;
  if(TREE[id].left != fr){
    lheight = height(TREE[id].left) + 1;
  }
  if(TREE[id].right != fr){
    rheight = height(TREE[id].right) + 1;
  }
  if(lheight > rheight){
    return lheight;
  }
  else{
    return rheight;
  }
}

void preorder(int x){
  if(x==fr){
    return;
  }
  printf(" %d",x);
  if(TREE[x].left!=-1){
    preorder(TREE[x].left);
  }
  if(TREE[x].right!=-1){
    preorder(TREE[x].right);
  }
}

void inorder(int x){
  if(x==fr){
    return;
  }
  if(TREE[x].left != -1)
  {
    inorder(TREE[x].left);
  }
  printf(" %d",x);
  if(TREE[x].right != -1){
    inorder(TREE[x].right);
  }
}

void postorder(int x){
  if(x==fr){
    return;
  }
  if(TREE[x].left != -1) {
    postorder(TREE[x].left);
  }
  if(TREE[x].right != -1) {
    postorder(TREE[x].right);
  }
  printf(" %d",x);
}

Measured memory_bytes: 616
#include <iostream>
#include <iostream>

using namespace std;
using ll = long long int;

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

    if(a < b)
        return gcd(b, a);
    else 
        return gcd(b, a%b);
}


int main()
{
    ll a, b;
    while(cin >> a >> b)
    {
        ll tmp = gcd(a, b);
        cout << tmp << " ";
        cout << a / tmp * b << endl;
    }
}


Measured memory_bytes: 3048
#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector> 

using namespace std;

int main() {
	char s[100];
	cin >> s;
	int n = strlen(s);
	cout << s[0] << n - 2 << s[n - 1] << endl;
	return 0;
}

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

bool prime(int x){
  bool flg = false;
  for(int i = 2; i*i <= x; i++){
    if(x % i == 0) flg = true;
  }
  return flg;
}


int main(){
  int x;
  cin >> x;
  while(prime(x)){
    x++;
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

bridges = []
for i in range(M):
	bridges.append(list(map(int, input().split())))

intervals = sorted(bridges, key=lambda x: x[1])

#print(bridges)
count=1
done=[intervals[0]]

for interval in intervals:
	#print(interval)
    # we cut the last bridage of last processed interval
	if not interval[0] < done[-1][1]:
		count += 1
		done.append(interval)	
#print(done)
print(count) 

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

#define REP(i, n) for (ll i = 0; i < (n); i++)

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  vector<ll> cnt(50);

  REP(i, N) {
    REP(j, 50) {
      if (A[i] >> j & 1) cnt[j]++;
    }
  }
  ll x = 0;
  for (ll i = 49; i >= 0; i--) {
    if (x + (1LL << i) > K) continue;
    if (cnt[i] * 2 < N) x += (1LL << i);
  }
  ll ans = 0;
  REP(i, N) { ans += x ^ A[i]; }
  cout << ans << endl;
}


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

int main(){
  int K,sum;
  sum=0;
  cin>>K;
  for(int i=1;i<K+1;i++){
    for(int j=1;j<K+1;j++){
      for(int k=1;k<K+1;k++){
        int N,M,L;
        N=gcd(i,j);
        M=gcd(j,k);
        L=gcd(N,M);
        sum+=L;
      }
    }
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	string s, t, r;
	cin >> s >> t >> r;
	cout << s[0] << t[0] << r[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

ll a[501][501] = {};
ll y_1[2000000];
ll x_1[2000000];
ll y_2[2000000];
ll x_2[2000000];

int main() {
	ll h, w; cin >> h >> w;
	repe(i, 1, h)repe(j, 1, w) {
		ll A; cin >> A;
		a[i][j] = A % 2;
	}

	ll cnt = 0;
	repe(i, 1, h) {
		repe(j, 1, w - 1) {
			if (a[i][j] & 1) {
				a[i][j]--;
				a[i][j + 1]++;
				y_1[cnt] = i;
				x_1[cnt] = j;
				y_2[cnt] = i;
				x_2[cnt] = j + 1;
				cnt++;
			}
		}
	}

	repe(i, 1, h - 1) {
		if (a[i][w] & 1) {
			a[i][w]--;
			a[i + 1][w]++;
			y_1[cnt] = i;
			x_1[cnt] = w;
			y_2[cnt] = i + 1;
			x_2[cnt] = w;
			cnt++;
		}
	}
	cout << cnt << endl;
	rep(i, 0, cnt) {
		cout << y_1[i] << " " << x_1[i] << " " << y_2[i] << " " << x_2[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 16384
[H,W] = list(map(int,input().split()))
canvas = []
for h in range(H):
    canvas.append([x for x in input()]) 

ans = True
for h,line in enumerate(canvas):
    for w,dot in enumerate(line):
        if dot == '#':
            ans0 = False
            if h-1 >=0 and canvas[h-1][w] == "#": ans0 =True #OK
            if h+1 < H and canvas[h+1][w] == "#": ans0 =True #OK
            if w-1 >=0 and canvas[h][w-1] == "#": ans0 =True #OK
            if w+1 < W and canvas[h][w+1] == "#": ans0 =True #OK
            if ans0 == False :
                ans = False
                break

if ans == True:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
n,m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]

for i in range(1000):
    s = str(i)
    if len(s) != n: continue
    if all(s[a - 1] == str(b) for a, b in sc):
        print(i)
        exit()

print(-1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  map<string, int> S;
  string s;
  for (int i = 0; i < N; i++) {
    cin >> s;
    S[s]++;
  }
  int m = 0;
  for (auto p : S) {
    m = max(m, p.second);
  }
  for (auto p : S) {
    if (p.second == m) {
      cout << p.first << endl;
    }
  }
  return 0;
}

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

char G[1000][1000];
int H, W;

int solve(){
  int mi = 1000000000;
  int ma = 0;
  for ( int i = 0; i < H; i++ ){
    for ( int j = 0; j < W; j++ ){
      if ( G[i][j] == '.' ) continue;
      mi = min(mi, i+j);
      ma = max(ma, i+j);
    }
  }
  return ma - mi;
}

void rev(){
  char t[1000];
  for ( int i = 0; i < H; i++ ){
    for ( int j = 0; j < W; j++ ) t[j] = G[i][j];
    for ( int j = 0; j < W; j++ ) G[i][j] = t[W-j-1];
  }
}

int main(){
  cin >> H >> W;
  pair<int, int> s, t, o;
  for ( int i = 0; i < H; i++ ){
    for ( int j = 0; j < W; j++ ){
      cin >> G[i][j];
    }
  }
  int ans = solve();
  rev();
  ans = max(ans, solve());
  cout << ans << endl;

}












Measured memory_bytes: 3132
//
// Created by yamunaku on 2020/01/18.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

struct edge{
    int to;
    int id;
};

int main(){
    // CFS;
    int n, m;
    cin >> n >> m;
    vl d(n);
    map<int, vector<int>> mp;
    rep(i, n){
        cin >> d[i];
        mp[d[i]].push_back(i);
    }
    vector<vector<edge>> e(n);
    int u, v;
    rep(i, m){
        cin >> u >> v;
        u--, v--;
        e[u].push_back({v, i});
        e[v].push_back({u, i});
    }
    string c(n, '.');
    vi ans(m, IINF + 1);
    vi can(n, false);
    vi ok(n, false);
    for(auto &p:mp){
        int val = p.first;
        vi &vx = p.second;
        for(auto &x:vx){
            can[x] = true;
        }
        for(auto &x:vx){
            if(ok[x]) continue;
            for(auto &nx:e[x]){
                if(can[nx.to]){
                    ok[x] = true;
                    ok[nx.to] = true;
                    ans[nx.id] = val;
                    break;
                }
            }
        }
        for(auto &x:vx){
            if(!ok[x]){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    rep(i, n){
        if(c[i] == '.'){
            c[i] = 'W';
            queue<int> q;
            q.push(i);
            while(!q.empty()){
                int now = q.front();
                q.pop();
                for(auto &nx:e[now]){
                    if(ans[nx.id] == IINF + 1) continue;
                    if(c[nx.to] != '.') continue;
                    if(c[now] == 'W') c[nx.to] = 'B';
                    else c[nx.to] = 'W';
                    q.push(nx.to);
                }
            }
        }
    }
    cout << c << endl;
    rep(i, m){
        if(ans[i] == IINF + 1) cout << IINF << endl;
        else cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 22912
fun main(args: Array<String>) {
    val arr = Array(3) {
        IntArray(3) { 0 }
    }
    repeat(3) { y ->
        arr[y] = readLine()!!.split(" ").map { it.toInt() }.toIntArray()
    }
    val n = readLine()!!.toInt()
    val nums = Array(n) {
        readLine()!!.toInt()
    }
    for (y in 0 until 3) {
        var bingo = true
        for (x in 0 until 3) {
            if (arr[y][x] !in nums) {
                bingo = false
            }
        }
        if (bingo) {
            System.err.println("yoko")
            println("Yes")
            return
        }
    }
    for (x in 0 until 3) {
        var bingo = true
        for (y in 0 until 3) {
            if (arr[y][x] !in nums) {
                bingo = false
            }
        }
        if (bingo) {
            System.err.println("tate")
            println("Yes")
            return
        }
    }
    var bingo = true
    for (xy in 0 until 3) {
        if (arr[xy][xy] !in nums) {
            bingo = false
        }
    }
    if (bingo) {
        System.err.println("naname")
        println("Yes")
        return
    }
    bingo = true
    for (xy2 in 0 until 3) {
        if (arr[xy2][2 - xy2] !in nums) {
            bingo = false
        }
    }
    if (bingo) {
        System.err.println("naname2")
        println("Yes")
        return
    }

    println("No")
}

Measured memory_bytes: 37944
#include <iostream>
#include <climits>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(void){
    int A1, A2, A3;
    int ans = INT_MAX;
    int cost;
    int sub;
    vector <int> a;
    
    for(int i = 0; i < 3; i++){
        cin >> sub;
        a.push_back(sub);
    }
    
    for(int i = 0; i < 3; i++){
        
        for(int j = 0; j < 3; j++){
            if(j != i){
                for(int k = 0; k < 3; k++){
                    cost = abs(a[j] - a[i]);
                    if(k != i && k != j){
                        cost += abs(a[k] - a[j]);
                        ans = min(ans, cost);
                    }
                }
            }
        }
    }
    
    cout << ans << endl;
}

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

int main(int argc, char const *argv[])
{
	string s, t;
	cin >> s >> t;

	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());

	// cout << s << " " << t << endl;
	for (int i = 0; i < s.size() && i < t.size(); ++i)
	{
		if (t[i] > s[i]) {
			cout << "Yes" << endl;
			return 0;
		}
		else if (t[i] < s[i]) {
			cout << "No" << endl;
			return 0;
		}
	}

	if (t.size() > s.size())
		cout << "Yes";
	else
		cout << "No";
	cout << endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int l = 0, r = 0;
  rep(i,n) {
    if (s[i] == '.') r++;
  }
  int ans = l+r;
  rep(i,n) {
    if(s[i] == '#') {
      l++;
    } else {
      r--;
    }
    ans = min(ans, l+r);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
N = int(input())

xn = []
yn = []
hn = []

for i in range(N):
    xi, yi, hi = map(int, input().split())
    xn.append(xi)
    yn.append(yi)
    hn.append(hi)

for Cx in range(101):
    for Cy in range(101):

        flg = True

        for i in range(N):
            if 0 == hn[i]:
                continue

            h = abs(xn[i] - Cx) + abs(yn[i] - Cy) + hn[i]

            if flg:
                H = h
                flg = False
            else:
                if (H != h):
                    flg = True
                    break

        if flg:
            continue

        for i in range(N):
            if 0 == hn[i]:
                h = abs(xn[i] - Cx) + abs(yn[i] - Cy)
                if h < H:
                    flg = True
                    break

        if flg:
            continue

        print(Cx, Cy, H)
        break

    if not flg:
        break


Measured memory_bytes: 3064
use std::cmp::*;
use std::collections::*;
use std::fmt::Debug;
use std::io::{stdin, Read};
use std::str::FromStr;

//mod lib;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    return token.parse().ok().expect("failed to parse token");
}

static MOD: i64 = 1_000_000_007;

fn read_vec1<T: FromStr>(n: usize) -> Vec<T> {
    return (0..n).map(|_| read()).collect();
}

fn read_vec2<T: FromStr>(n: usize, m: usize) -> Vec<Vec<T>> {
    return (0..n).map(|_| read_vec1(m)).collect();
}

#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

fn add_by_mod(a: &i64, b: &i64) -> i64 {
    return (a % MOD + b % MOD) % MOD;
}

fn solve(n: usize, m: usize) -> i64 {
    let mut h: Vec<i64> = read_vec1(n);
    let mut w: Vec<i64> = read_vec1(m);
    let mut hash_x = HashMap::new();
    let mut hash_y = HashMap::new();

    for i in 0..n {
        let mut sum = 0;
        for j in i..n {
            sum += h[j];
            let count = hash_y.entry(sum).or_insert(0i64);
            *count += 1;
        }
    }


    for i in 0..m {
        let mut sum = 0;
        for j in i..m {
            sum += w[j];
            let count = hash_x.entry(sum).or_insert(0);
            *count += 1;
        }
    }

    let mut ans = 0;

    for (k, v) in hash_x.iter() {
        let count = hash_y.get(k);
        match count {
            Some(c) => ans += c * *v,
            None => (),
        }
    }

    return ans;
}

fn main() {
    let mut n: usize = read();
    let mut m: usize = read();

    while n != 0 && m != 0 {
        println!("{}", solve(n, m));
        n = read();
        m = read();
    }
}



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

int nxt[100005], vis[100005];
pair<int, int> a[100005], b[100005];
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i ++) cin >> a[i].first, a[i].second = i;
	sort(a, a + n);
	
	for(int i = 0; i < n; i ++) cin >> b[i].first, b[i].second = i;
	sort(b, b + n);
	
	bool f = 0;
	for(int i = 0; i < n; i ++) nxt[a[i].second] = b[i].second;
	int cnt = 0;
	for(int i = 0; i < n; i ++){
		if(vis[i]) continue;
		int cur = i;
		vis[cur] = 1;
		while(1){
			cur = nxt[cur];
			if(vis[cur]) break;
			vis[cur] = 1;
		}
		cnt ++;
	}
//	cout << cnt << '\n';
	if(cnt > 1) f = 1;
	
	bool flag = 1;
	for(int i = 0; i < n; i ++){
		if(b[i].first < a[i].first) flag = 0;
	}
	if(!flag){ cout << "No" << '\n'; return 0;}
	if(f && flag) { cout << "Yes" << '\n'; return 0;}
	for(int i = 0; i < n - 1; i ++){
		if(b[i].first >= a[i + 1].first){
			cout << "Yes" << '\n';
			return 0;
		}
	}
	cout << "No" << '\n';
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef pair<int, int> pii;
// #define INF __INT32_MAX__
#define INF 1e9
#define LINF __LONG_LONG_MAX__

int main() {
    int D, N; cin >> D >> N;

    int ans = pow(100, D) * N;
    if (N == 100) ans += pow(100, D);
    cout << ans << endl;
}


Measured memory_bytes: 3736
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;

int main()
{
	int i = 0, j = 0;
//	char c;
	int a[100][50];
	int b[100][50];
	memset(a, 0, sizeof(a));
	memset(b, 0, sizeof(b));
	
	while (cin >> a[i][j]) {
		while (cin.get() != '\n') {
			j++;
			cin >> a[i][j];
		}
		i++;
		j = 0;
	}

	b[0][0] = a[0][0];

	for (int k = 1; k <= i / 2; k++) {
		b[k][0] = b[k - 1][0] + a[k][0];
		b[k][k] = b[k - 1][k - 1] + a[k][k];
		for (int s = 1; s < k; s++)
			b[k][s] = max(b[k - 1][s - 1], b[k - 1][s]) + a[k][s];
	}

	for(int k = i / 2 + 1; k <= i; k++)
		for (int s = 0; s < i - k + 1; s++)
			b[k][s] = max(b[k - 1][s], b[k - 1][s + 1]) + a[k][s];

			cout << b[i][0] << endl;
		
	return 0;
}



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

 using namespace std;
 int main() {
   string C1, C2;
   cin >> C1 >> C2;
   if (C1.at(0) == C2.at(2) && C1.at(1) == C2.at(1) && C1.at(2) == C2.at(0)) cout << "YES" << endl;
   else cout << "NO" << endl;
 }


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

using namespace std;

int kazu[200005];

int main() {

	int n;

	cin >> n;


	int k;
	vector<int> a;
	for (int i = 0; i < n; i++) {

		cin >> k;
		a.push_back(k);
		kazu[k]++;
	}
	long long sum=0;
	for (int i = 1; i <= n; i++) {
		sum += (long long)kazu[i] * (kazu[i] - 1) / 2;
	}

	for (int i = 0; i < n; i++) {
		//int cnt = 0;
		long long sabun = kazu[a[i]] * (kazu[a[i]] - 1) / 2 - (kazu[a[i] ]- 1) * (kazu[a[i]] - 2) / 2;
		

		cout << sum-sabun << endl;
	}




	return 0;
}

Measured memory_bytes: 5000
#include<cstdio>
#include<algorithm>

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

using namespace std;

int n,a[200];

int dp[200][200];
int dfs(int l,int r){
	if(dp[l][r]!=-1) return dp[l][r];

	int res=0;
	for(int i=l+1;i<r;i++) res=max(res,dfs(l,i)+dfs(i,r)+abs(a[i]-a[l]));
	return dp[l][r]=res;
}

int main(){
	int T; scanf("%d",&T);
	while(T--){
		scanf("%d",&n);
		rep(i,n) scanf("%d",a+i), a[n+i]=a[i];

		rep(i,2*n) rep(j,2*n) dp[i][j]=-1;

		int ans=0;
		rep(i,n) ans=max(ans,dfs(i,n+i)); // 最後に a[i] を残すときの最適解
		printf("%d\n",ans);
	}

	return 0;
}

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

int main() {
  
  int N, M;
  cin >> N >> M;

  if (N == 1 && M == 1) {
    cout << 1 << endl;
  } else if (N == 1) {
    cout << M - 2 << endl;
  } else if (M == 1) {
    cout << N - 2 << endl;
  } else {
    cout <<(long) (N - 2) * (M - 2) << endl;
  }

}

Measured memory_bytes: 256
#include<stdio.h>
int a[1010][1010];

int main()
{
    int ans = 0;
    int n,h,w;
    scanf("%d%d%d",&n,&h,&w);
    for(int i = 0; i < n; i++)
        for(int j = 0; j < 2; j++)
            scanf("%d",&a[i][j]);
    for(int i = 0;i < n;i++)
    {
        if(a[i][0] >=  h && a[i][1] >= w)
            ans++;
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 4096
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
std::map<int,int> a,b;
const int maxn=1e5+10;
int n,v[maxn];
bool cmp(const std::pair<int,int> &a,const std::pair<int,int> &b)
{
    return a.second>b.second;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&v[i]);
        if(i%2==1) a[v[i]]++;
        if(i%2==0) b[v[i]]++;
    }
    std::vector<std::pair<int,int> > A(a.begin(),a.end());
    std::vector<std::pair<int,int> > B(b.begin(),b.end());
    std::sort(A.begin(),A.end(),cmp);
    std::sort(B.begin(),B.end(),cmp);
    int min=0x7fffffff;
    if(A[0].first!=B[0].first)
    {
        min=std::min(min,n-A[0].second-B[0].second);
    } else
    {
        if(A.size()>1)
        {
            min=std::min(min,n-A[1].second-B[0].second);
        }
        if(B.size()>1)
        {
            min=std::min(min,n-A[0].second-B[1].second);
        }
    }
    if(min==0x7fffffff) min=n/2;
    printf("%d\n",min);
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define inf 1e9
using namespace std;

struct data {
  int t, p;
};
bool operator<(const data &dl, const data &dr) {
  if(dl.t != dr.t) return dl.t > dr.t;
  return dl.p < dr.p;
};

int n, m, l, k, a, h, ans = inf;
vector<int> town;
vector<int> dis;
int memo[105][105] = {0};
priority_queue<data> pq;

void setmemo();
void solve();
void wf();

int main() {
  while(1) {
    setmemo();
    cin >> n >> m >> l >> k >> a >> h;
    if(n + m + l + k + a + h == 0) break;
    town.resize(l);
    for(int i = 0; i < l; ++i) cin >> town[i];
    town.push_back(a);
    town.push_back(h);
    for(int i = 0; i < k; ++i) {
      int x, y, t;
      cin >> x >> y >> t;
      memo[x][y] = memo[y][x] = t;
    }
    solve();
    if(ans == inf)
      cout << "Help!" << endl;
    else
      cout << ans << endl;
  }
  return 0;
}

void setmemo() {
  ans = inf;
  for(int i = 0; i < 100; ++i)
    for(int j = 0; j < 100; ++j) memo[i][j] = inf;
}

void wf() {
  for(int o = 0; o < n; ++o)
    for(int i = 0; i < n; ++i)
      for(int j = 0; j < n; ++j)
        memo[i][j] =
            min(memo[i][j], memo[i][o] + memo[o][j]);
}

void solve() {
  wf();
  dis.assign(l + 2, inf);
  pq.push({0, l + 1});
  while(!pq.empty()) {
    data now = pq.top();
    pq.pop();
    if(now.t >= dis[now.p]) continue;
    dis[now.p] = now.t;
    for(int i = 0; i < l + 1; ++i)
      if(now.p != i) {
        data nextp = now;
        if(memo[town[i]][town[now.p]] > m) continue;
        nextp.t += memo[town[i]][town[now.p]];
        nextp.p = i;
        pq.push(nextp);
      }
  }
  if(dis[l] != inf) ans = dis[l] + max(0, dis[l] - m);
}


Measured memory_bytes: 3284
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

string s;
int n;

int main(){
	cin>>n>>s;
	for(int i=0;i<=s.size()-1;i++){
		toupper(s[i]);
		putchar(((s[i]-'A'+n)%26)+'A');
	}
	return 0;
}

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

using namespace std;

long long int A[100005];
int N, Q, B[100005], C[100005];

long long int c[100005];
long long int tot = 0;
int main(void) {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		c[A[i]]++;
		tot += A[i];
	}



	cin >> Q;
	for (int i = 1; i <= Q; i++) {
		cin >> B[i] >> C[i];
	}

	for (int i = 1; i <= Q; i++) {
		tot += c[B[i]] * (C[i] - B[i]);
		cout << tot << endl;
		c[C[i]] += c[B[i]];
		c[B[i]] = 0;
	}


	return 0;
}

Measured memory_bytes: 5908
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    char b;
    cin >> b;

    if (b=='A') cout << 'T' << endl;
    if (b=='T') cout << 'A' << endl;
    if (b=='C') cout << 'G' << endl;
    if (b=='G') cout << 'C' << endl; 

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 100100100100100100;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    int r,g; cin >>r>>g;

    int x = 2*g - r;

    cout << x << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int main(){
    int N; cin >> N;
    int L[N]; for(int i = 0; i < N; i++){ cin >> L[i]; }
    int max = 0;
    int sum = 0;
    for(int i = 0; i < N; i++){
        if( max < L[i]){
            max = L[i];
        }
        sum += L[i];
    }
    sum -= max;
    if(max < sum){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

#define ll long long
#define pq priority_queue
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

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

   if (a < b) {
      while (1) {
         // alice
         if (a+1 == b) {
            a--;
         } else {
            a++;
         }
         // bolice
         if (b-1 == a) {
            b++;
         } else {
            b--;
         }
         // printf("(%d, %d)\n", a, b);
         if (a == 0) {
            puts("Borys");
            return 0;
         }
         if (b == n+1) {
            puts("Alice");
            return 0;
         }
      }
   } else {
      while (1) {
         // alice
         if (a-1 == b) {
            a++;
         } else {
            a--;
         }
         // bolice
         if (b+1 == a) {
            b--;
         } else {
            b++;
         }
         if (b == 0) {
            puts("Alice");
            return 0;
         }
         if (a == n+1) {
            puts("Borys");
            return 0;
         }
      }
   }

   return 0;
}

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

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

	int cnt=0;
	rep(i,3) {
		if(d[i] == 'R') cnt++;
	}

	int ans = 0;
	if (cnt == 3) {
		ans = 3;
	} else if (cnt == 0) {
		ans = 0;
	} else if ((cnt == 2) && (d[1] == 'R')) {
		ans = 2;
	} else {
		ans = 1;
	}

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


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

int main() {
	string S, T;
	cin >> S >> T;
	int ss[26], tt[26];
	for(int i=0; i<26; ++i){
	    ss[i]=-1;
	    tt[i]=-1;
	}
	bool f=true;
	int j;
	for(int i=0; i<S.size(); ++i)
	{
	    if(ss[S[i]-'a']!=tt[T[i]-'a']){
	        f=false;
	        break;
	    }
	    else{
	        ss[S[i]-'a']=i;
	        tt[T[i]-'a']=i;
	    }
	}
	if(f) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

int main(void) {
	int X;
	int fiveHandred,five,remainder,ans;
	cin >> X;
	fiveHandred = X / 500;
	remainder = X % 500;
	five = remainder / 5;
	ans = fiveHandred * 1000 + five * 5;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;

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

int main() {
  char b;
  cin >> b;

  char ans;
  if (b == 'A') ans = 'T';
  if (b == 'T') ans = 'A';
  if (b == 'G') ans = 'C';
  if (b == 'C') ans = 'G';

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,k,x[100]={0},i,ans=0;
  scanf("%d %d",&n,&k);
  for(i=0;i<n;i++){
    scanf("%d",&x[i]);
    if(x[i]<k){
      if(x[i]<k-x[i]){
	ans=ans+x[i];
      }else{
	ans=ans+k-x[i];
      }
    }else{
      if(x[i]<x[i]-k){
	ans=ans+x[i];
      }else{
	ans=ans+x[i]-k;
      }
    }
  }
  printf("%d\n",ans*2);
  return(0);
}


Measured memory_bytes: 128
import sys
readline = sys.stdin.buffer.readline

n = int(readline())
a = list(map(int,readline().split()))

cnt = [0] * 1000005
for x in a:
    if cnt[x] != 0: 
        cnt[x] = 2
    else: 
        for i in range(x,1000005,x):
            cnt[i] += 1

ans = 0
for x in a:
    if cnt[x] == 1:
        ans += 1

print(ans)


Measured memory_bytes: 30740
A,B,K =map(int,input().split())

if A>=1 and K>0:
    tmp=A
    A=A-K
    K=K-tmp
if A<0:
    A=0

if A==0 and B>=1 and K>0:
    B=B-K

if B<0:
    B=0

print(A,B)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

typedef tuple<string, int, int> T;

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

    int n, k; cin >> n >> k;
    vector<ll> v(n);
    for(int i=0; i<n; ++i) cin >> v[i];

    ll ans = 0;

    for(int left=0; left<=k; ++left){
        for(int right=0; right<=k; ++right){
            if(left+right > n || left+right > k) continue;
            ll tmp = 0;
            int cnt = k-left-right;
            priority_queue<ll, vector<ll>, greater<ll>> pq;

            for(int i=0; i<left; ++i){
                tmp += v[i];
                if(v[i] < 0) pq.push(v[i]);
            }
            for(int i=0; i<right; ++i){
                tmp += v[n-1-i];
                if(v[n-1-i] < 0) pq.push(v[n-1-i]);
            }

            while(cnt>0 && !pq.empty()){
                --cnt;
                ll aa = pq.top(); pq.pop();
                tmp -= aa;
            }

            chmax(ans, tmp);

        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>

using namespace std;

int main()
{
	int n;
	cin >> n;
	if(n == 1)
	{
		cout << "Hello World" << endl;
	}else{
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
	return 0;
}


Measured memory_bytes: 256
/*
 * AOJCardGame.cxx
 * 
 * Copyright 2016 Tom Tanaka <torumu@Tom-no-MacBook-Pro.local>
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 * 
 * 
 */


#include <iostream>

int main(int argc, char **argv)
{
	int a, b;
	int n;
	int acards,bcards;
	while(true){
		a = 0;
		b = 0;
		std::cin >> n;
		if(n == 0){
			break;
		}
		for(int i = 0; i < n; i++){
			std::cin >> acards >> bcards;
			if(acards < bcards){
				b += bcards + acards;
			}
			if(acards > bcards){
				a += bcards + acards;
			}
			if(acards == bcards){
				a += acards;
				b += bcards;
			}
		}
		std::cout << a << " " << b << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,r[4010],g[4010],b[4010];
string s;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>s;
    rep(i,n){
        if(i==0){
            if(s[i]=='R')r[i]++;
            if(s[i]=='G')g[i]++;
            if(s[i]=='B')b[i]++;
        }
        else{
            r[i]=r[i-1];
            g[i]=g[i-1];
            b[i]=b[i-1];
            if(s[i]=='R')r[i]++;
            if(s[i]=='G')g[i]++;
            if(s[i]=='B')b[i]++;
        }
    }
    int ans=0;
    for(int j=1;j<n-1;j++){
        if(s[j]=='R'){
            ans+=g[j-1]*(b[n-1]-b[j]);
            ans+=b[j-1]*(g[n-1]-g[j]);
        }
        if(s[j]=='G'){
            ans+=r[j-1]*(b[n-1]-b[j]);
            ans+=b[j-1]*(r[n-1]-r[j]);
        }
        if(s[j]=='B'){
            ans+=r[j-1]*(g[n-1]-g[j]);
            ans+=g[j-1]*(r[n-1]-r[j]);
        }
    }
    for(int j=1;j<n;j++){
        for(int d=1;;d++){
            int i=j-d,k=j+d;
            if(0<=i&&k<n){
                if(s[i]!=s[j]&&s[i]!=s[k]&&s[j]!=s[k])ans--;
            }
            else break;
        }
    }
    cout<<ans<<endl;
	return 0;
}


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

int main() {
  long long x, k, d, m;
  cin >> x >> k >> d;
  if(x == 0) {
    if((k % 2) == 0) m = 0;
    else m = d;
  }
  else {
    x = abs(x);
    long long a, b, p, t;
    a = abs(x % d);
    b = abs((x % d) - d);
    p = min(a, b);
    if(a <= b) t = x / d;
    else t = (x / d) + 1;
    if(t > k) {
      m = x - (k * d); }
    else {
      if((k - t) % 2 == 0) {
        m = p; }
      else {
        m = abs(p - d); }
    }
  }
  cout << m << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

signed main(void) {
  int i,j;
  int n,a,b;
  cin>>n>>a>>b;
  vi x(n);
  vi y(n,0);
  rep(i,n)cin>>x[i];
  int ans=0;
  rep(i,n-1)
    if((x[i+1]-x[i])*a<b){
      ans+=(x[i+1]-x[i])*a;
      y[i+1]++;
    }
  loop(i,1,n)if(y[i]==0)ans+=b;
  cout<<ans<<endl;
}


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

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

    int N, Q;
    cin >> N >> Q;

    string S;
    cin >> S;

    vector<int> a(N);
    for (int i = 1; i < N; i++) {
        if (S[i-1] == 'A' && S[i] == 'C') {
            a[i] = a[i-1] + 1;
        } else {
            a[i] = a[i-1];
        }
    }

    int l, r;
    rep(i,Q) {
        cin >> l >> r;
        cout << a[r-1] - a[l-1] << endl;
    }

    return 0;
}


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

using namespace std;

int main(int argc, char *argv[]) {
    map<int, int> m;
    int n1, n2, n3, n4;
    cin >> n1 >> n2 >> n3 >> n4;
    m[n1] += 1;
    m[n2] += 1;
    m[n3] += 1;
    m[n4] += 1;

    if (m.count(1) == 1 && m.count(9) == 1 && m.count(7) == 1 && m.count(4) == 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    int n;
    cin>>n;
    int c0=0,c1=0,c2=0,c3=0;
    
    for(int i=0;i<n;i++){
        string str;
        cin>>str;
        if("AC"==str){
            c0++;
        }else if("WA"==str){
            c1++;
        }else if("TLE"==str){
            c2++;
        }else if("RE"==str){
            c3++;
        }
    }
    
    cout<<"AC"<<" x "<<c0<<endl;
    cout<<"WA"<<" x "<<c1<<endl;
    cout<<"TLE"<<" x "<<c2<<endl;
    cout<<"RE"<<" x "<<c3<<endl;
    return 0;
}

Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	N,M = inputMap()

	if N == M:
		print("Yes")
	else:
		print("No")



if __name__ == "__main__":
	main()


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

int main() {
  int N, f;
  f = 0;
  cin >> N;

  int X = N; //入れ物を用意
  for(int i=0;; i++){
    if(X > 0){
      f += X%10;
      X /= 10;
    }
    else{
      break;
    }
  }

  if(N%f == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
x = a[0]
total = sum(a)
y = total - x
ans = abs(x - y)
for i in range(1, N-1):
    x += a[i]
    y -= a[i]
    m = abs(x-y)
    if ans > m:
        ans = m
print(ans)

Measured memory_bytes: 24832
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author EDGE
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskAtcoderHitachiA solver = new TaskAtcoderHitachiA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskAtcoderHitachiA {
        public void solve(int testNumber, FastReader in, PrintWriter out) {

            String s = in.nextLine();
            s = s.replaceAll("hi", "");
            //out.println(s+" "+s.length());
            if (s.length() == 0)
                out.println("Yes");
            else
                out.println("No");
        }

    }

    static class FastReader {
        BufferedReader br;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}



Measured memory_bytes: 23764