akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      Graph graph = new Graph(n);
      int[] ajacent;
      String[] vInfo;
      int id,degree;

      for(int i=0; i<n; i++) {
        vInfo  = br.readLine().split(" ");
        id     = Integer.parseInt(vInfo[0]);
        degree = Integer.parseInt(vInfo[1]);
        ajacent = new int[degree];
        for(int j=0; j<degree; j++) {
          ajacent[j] = graph.convIdToIndex( Integer.parseInt(vInfo[j+2]) );
        }
        graph.setVertex(id, ajacent);
      }

      graph.vertexSearch();

      graph.dispReport();
    }
    catch (IOException e) {
      System.err.println(e);
    }
  }

  class Graph {

    Vertex[] vertices;
    Queue<Vertex> queue;
    int time;

    public Graph(int size ) {
      vertices  = new Vertex[size];
      queue = new ArrayDeque<>(size);
      time = 0;
    }

    public void setVertex(int id) {
      vertices[convIdToIndex(id)] = new Vertex(id);
    }
    public void setVertex(int id, int[] ajacent) {
      setVertex(id);
      setAjacent(id, ajacent);
    }
    public void setAjacent(int id, int[] ajacent) {
      vertices[convIdToIndex(id)].ajacent = ajacent;
    }
    public void vertexSearch() {
      breadthFirstSearch(0);
    }
    public void dispReport() {
      StringBuilder buf = new StringBuilder();

      for (Vertex v : vertices) {
          buf.append(v.id).append(" ")
             .append(v.distance).append("\n");
      }

      System.out.print(buf);
    }
    public int convIdToIndex(int id) {
      return id-1;
    }

    private void breadthFirstSearch(int index) {
      vertices[index].state = Vertex.GRAY;
      vertices[index].distance = 0;
      queue.offer(vertices[index]);

      Vertex v;
      while(queue.peek() != null) {
        v = queue.poll();
        for (int ajcIndex : v.ajacent) {
          if(vertices[ajcIndex].state == Vertex.WHITE) {
            vertices[ajcIndex].state = Vertex.GRAY;
            vertices[ajcIndex].distance = v.distance + 1;
            queue.offer(vertices[ajcIndex]);
          }
        }
        v.state = Vertex.BLACK;
      }
    }

    class Vertex {

      static final int WHITE = 0;
      static final int GRAY  = 1;
      static final int BLACK = 2;
      int id;
      int index;
      int state;
      int[] ajacent;
      int findTime;
      int doneTime;
      int distance;

      public Vertex(int id) {
        this.id = id;
        index = id-1;
        state = WHITE;
        distance = -1;
      }
    }
  }
}


Measured memory_bytes: 24564
#include <bits/stdc++.h>
using namespace std; 
int n;
int a[10010];
int ans;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				if(a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[j]!=a[k]){
					ans++;
				}
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	int N, D; scanf("%d%d", &N, &D);
	printf("%d", (N + (2 * D)) / (2 * D + 1));

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int K = scanner.nextInt();
		String S = scanner.next();
		String[] sArray = S.split("");
		sArray[K - 1] = sArray[K - 1].toLowerCase();
		System.out.println(String.join("", sArray));
		scanner.close();
	}
}

Measured memory_bytes: 23636
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s; cin >> s;
    V<int> accr(n + 1, 0), accb(n + 1, 0), accg(n + 1, 0);
    for (int i = 0; i < n; i++) {
        accr[i + 1] = accr[i];
        accb[i + 1] = accb[i];
        accg[i + 1] = accg[i];
        if (s[i] == 'R') accr[i + 1]++;
        else if (s[i] == 'B') accb[i + 1]++;
        else if (s[i] == 'G') accg[i + 1]++;
    }

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            ans += accb[i] * (accg.back() - accg[i]);
            ans += accg[i] * (accb.back() - accb[i]);
        } else if (s[i] == 'B') {
            ans += accr[i] * (accg.back() - accg[i]);
            ans += accg[i] * (accr.back() - accr[i]);
        } else if (s[i] == 'G') {
            ans += accb[i] * (accr.back() - accr[i]);
            ans += accr[i] * (accb.back() - accb[i]);
        }
    }

    for (int i = 1; i < n - 1; i++) {
        for (int j = 0; j < i; j++) {
            if (s[i] == 'R') {
                if (s[j] == 'B') {
                    if (i + i - j < n && s[i + i - j] == 'G') ans--;
                } else if (s[j] == 'G') {
                    if (i + i - j < n && s[i + i - j] == 'B') ans--;
                }
            } else if (s[i] == 'B') {
                if (s[j] == 'R') {
                    if (i + i - j < n && s[i + i - j] == 'G') ans--;
                } else if (s[j] == 'G') {
                    if (i + i - j < n && s[i + i - j] == 'R') ans--;
                }
            } else if (s[i] == 'G') {
                if (s[j] == 'B') {
                    if (i + i - j < n && s[i + i - j] == 'R') ans--;
                } else if (s[j] == 'R') {
                    if (i + i - j < n && s[i + i - j] == 'B') ans--;
                }
            }
        }
    }

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


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

int main () {
  int N, M;
  cin >> N;
  int T[N];
  for (int i = 0; i < N; i++) {
    cin >> T[i];
  }
  cin >> M;
  int count, P, X, ans[M];
  for (int i = 0; i < M; i++) {
    cin >> P >> X;
    for (int j = 0; j < N; j++) {
      if (j == P-1) {
        count += X;
      }
      else {
        count += T[j];
      }
    }
    ans[i] = count;
    count = 0;
  }
  for (int i = 0; i < M; i++) {
    cout << ans[i] << endl;
  }
}

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

int main(){
  int k,t;
  vector<int> a;
  cin >> k >> t;
  int tmp, max=0;
  for(int i = 0; i < t; i++){
	cin >> tmp;
	if(max < tmp){max = tmp;}
	a.push_back(tmp);
  }
  max*=2;
  for(int i = 0; i < a.size(); i++){
	max -=a[i];
  }
  if(max < 0)max = 1;

  cout << (max - 1);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define N 200005

using namespace std;

int main()
{   __

    int h,n;
    ll sum = 0;

    cin >> h >> n;

    int a[n];

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

    sort(a,a+n);

    for(int i=0;i<n;i++)
    {
        if(sum>=h) break;

        sum+=a[i];
    }

    if(sum>=h) cout << "Yes\n";

    else cout << "No\n";

    return 0;
}




Measured memory_bytes: 640
#include<cstdio>


int main(){
    int n,u,k,v;
    scanf("%d",&n);
    int G[n+1][n+1];
    for(int i = 0;i <= n;++i){
        for(int j = 0;j <= n;++j){
            G[i][j] = 0;
        }
    }
    for(int i = 0;i < n;++i){
        scanf("%d %d",&u,&k);
        for(int j = 0;j < k;++j){
            scanf("%d",&v);
            G[u][v] = 1;
        }
    }
    for(int i = 1;i <= n;++i){
        for(int j = 1;j <n;++j){
            printf("%d ",G[i][j]);
        }
        printf("%d\n",G[i][n]);
    }
}



Measured memory_bytes: 2752
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

void solve() {
	int n, q; cin >> n >> q;
	Graph graph(n);
	vector<int> cost(n, 0), counter(n, 0);
	vector<bool>seen(n, false);
	queue<int>order; order.push(0);
	for (int i = 0; i < n - 1; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		graph[a].emplace_back(b);
		graph[b].emplace_back(a);
	}
	for (int i = 0; i < q; i++) {
		int a, b; cin >> a >> b;
		a--;
		cost[a] += b;
	}
	counter[0] = cost[0];
	while (!order.empty()) {
		int from = order.front();
		order.pop();
		seen[from] = true;
		for (int to = 0; to < graph[from].size(); to++) {
			if (!seen[graph[from][to]]) {
				order.push(graph[from][to]);
				counter[graph[from][to]] = counter[from] + cost[graph[from][to]];
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << counter[i];
		if (i != n - 1)cout << " ";
	}
	cout << endl;
}

int main() {
	solve();
}

Measured memory_bytes: 16372
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}

   


  int main(){
  lint N,M,ans=0;
  cin >>N>>M;
  priority_queue<int,vector<int>,greater<int>> A;
  pair<lint,lint> x[M];
  rep(i,N){
    int a;
    cin>>a;
    A.push(a);
  }
  rep(i,M){
    int a,b;
    cin>>a>>b;
    x[i]=make_pair(b,a);
  }
  sort(x,x+M,greater<pair<lint,lint>>());
  rep(i,M){
      lint l,m;
      tie(m,l)=x[i];
        rep(j,l){
      if(A.top()<m){
        A.pop();
        A.push(m);
      }else break;
    }
  }
  rep(i,N){
    ans+=A.top();
    A.pop();
  }
  cout <<ans;
 
}

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

int main()
{
    string S;
    string week[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    cin >>  S;
    for(int i=0;i<7;++i){
        if(week[i]==S){
            cout << 7-i;
        }
    }
    return 0;
}

Measured memory_bytes: 256
H,W=map(int,input().split())
S=[input() for _ in range(H)]

arr=[]
for h in range(0,H):
    for w in range(0,W):
        if S[h][w]=='#':
            cnt=0
            if w!=0:
                cnt+=S[h][w-1]=='#'
            if w!=W-1:
                cnt+=S[h][w+1]=='#'
            if h!=0:
                cnt+=S[h-1][w]=='#'
            if h!=H-1:
                cnt+=S[h+1][w]=='#'
            arr.append(cnt>0)
print('Yes' if all(arr) else 'No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define id(x,y) ((x-1)*m+(y-1))
using namespace std;
char t[510][510],s[510][510];int n,m;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
		scanf("%s",s[i]+1);
	memset(t,'.',sizeof(t));
	for(int i=1;i<=n;++i)t[i][1]='#';
	for(int i=1;i<=n;++i)if(i&1)
		for(int j=1;j<m;++j)t[i][j]='#';
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)if(s[i][j]=='#')t[i][j]='#';
	for(int i=1;i<=n;puts(""),i++)t[i][m+1]=0,printf("%s",t[i]+1);
	memset(t,'.',sizeof(t));
	puts("");
	for(int i=1;i<=n;++i)t[i][m]='#';
	for(int i=1;i<=n;++i)if(~i&1)
		for(int j=2;j<=m;++j)t[i][j]='#';
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)if(s[i][j]=='#')t[i][j]='#';
	for(int i=1;i<=n;puts(""),i++)t[i][m+1]=0,printf("%s",t[i]+1);
}

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

int main() {
  int w,h,x,y;
  cin >> w >> h >> x >> y;
  double ans = (double)w*h/2;
  int num = (w==x*2 && h==y*2) ? 1 : 0;
  printf("%f %d\n", ans, num);
  return 0;
  
}



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

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1};
vl dy={1,-1,0,0};

//素因数分解O(√n)
map<ll,ll>prime_factor(ll n){
  map<ll,ll>res;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}

const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
//finvが階乗の逆元

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n, ll mod) {
  
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}



int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  
  ll n;cin>>n;
  vl a(n);
  rep(i,n)cin>>a[i];
  ll cnt=0;
  rep(i,n){
    if(i%2==0&&a[i]%2==1){
      cnt++;
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cstring>
#define rep(i,s,t) for (int i = s ; i < t ; ++ i)

using namespace std;

int main()
{
    int a,b,c;
    cin>> a >> b >> c;
    if (a == 5 && b ==7 && c == 5)
        cout<< "YES" <<endl;
    else if (a == 7 && b ==5 && c == 5)
        cout<< "YES" <<endl;
    else if (a == 5 && b ==5 && c == 7)
        cout<< "YES" <<endl;
    else
        cout<< "NO" <<endl;
    return 0;
}


Measured memory_bytes: 256
N, M, X = map(int, input().split())
P = [[int(x) for x in input().split()] for _ in range(N)]

flg = False
ans = 10**12
for i in range(2**N):
    A = []
    for j in range(N):
        if ((i>>j) & 1):
            A.append(P[j])
#     print('####', A)
    value = 0
    algo = [0]*M
    for a in A:
        value += a[0]
        for i in range(1, M+1):
            algo[i-1] += a[i]
#     print(value, algo)
    cnt=0
    for al in algo:
        if al>=X:
            cnt+=1
    if cnt==M:
#         print('!!!!!!!!!!!!!')
        flg=True
        ans = min(ans, value)
if flg:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 9152
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;


int main()
{
    int N;
    cin >> N;
    int x;
    vector <int> v;
    for (int i = 0; i<N; i++){
        cin>>x;
        v.push_back(x);
    }
    
    int c = 0;
    x = 1e9;
    
    for (int i = 0; i<v.size(); i++)
    {
        if (v[i]<x) {
            x = v[i];
            c++;
        }
        
    }
    cout <<c <<endl;
    
    
    
    
    return 0;
}


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

using namespace std;

typedef long long ll;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

int main() {
  int n; read(n);
  map <string, int> cnt;
  int mx = 0;
  for(int i = 0; i < n; i++) {
    string s; cin >> s;
    cnt[s]++;
    mx = max(mx, cnt[s]);
  }
  vector <string> v;
  for(auto x : cnt) {
    if(mx == x.second) v.push_back(x.first);
  }
  sort(v.begin(), v.end());
  for(auto x : v) cout << x << '\n';
}

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

int N, M, K;
void solve() {
	bool flg = false;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= M; j++) {
			if (i * M + j * N - i * j * 2== K) {
				flg = true;
				break;
			}
		}
		if (flg) break;
	}
	if (flg) cout << "Yes" << endl;
	else cout << "No" << endl;
}

int main() {
	cin >> N >> M >> K;
	solve();
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
	BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	String str;
	while((str=input.readLine())!=null)
	    {
		float w=Float.parseFloat(str);
		if(w<=48.00)System.out.println("light fly");
		else if(48.00<w && w<=51.00)System.out.println("fly");
		else if(51.00<w && w<=54.00)System.out.println("bantam");
		else if(54.00<w && w<=57.00)System.out.println("feather");
		else if(57.00<w && w<=60.00)System.out.println("light");	
		else if(60.00<w && w<=64.00)System.out.println("light welter");
		else if(64.00<w && w<=69.00)System.out.println("welter");
		else if(69.00<w && w<=75.00)System.out.println("light middle");
		else if(75.00<w && w<=81.00)System.out.println("middle");
		else if(81.00<w && w<=91.00)System.out.println("light heavy");
		else if(91.00<w)System.out.println("heavy");

	    }
    }
}

Measured memory_bytes: 17096
#include<iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define P_B push_back
#define E_B emplace_back
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
  ll N, ans=1;

  cin >> N;

  vector<string> S(N), T;

  rep(i, N){
    cin >> S[i];
  }

  sort(S.begin(), S.end());

  rep(i, N-1){
    if(S[i] == S[i+1]) continue;
    else ans++;
  }

  cout << ans << endl;



  return 0;
}


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

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

    vector<vector<int>> sum(n + 1);
    rep(i, n + 1) sum[i].assign(3, 0);

    sum[0][0] = sum[0][1] = sum[0][2] = 0;

    for (int i = 0; i < n; ++i)
    {
        rep(j, 3) sum[i + 1][j] = sum[i][j];
        if (s[i] == 'R')
            ++sum[i + 1][0];
        else if (s[i] == 'G')
            ++sum[i + 1][1];
        else
            ++sum[i + 1][2];
    }

    ll ans = 0;
    for (int i = 0; i < n; ++i)
    {
        char t = s[i];
        if (t == 'R')
            ans += (sum[n][1] - sum[i][1]) * (sum[n][2] - sum[i][2]);
        else if (t == 'G')
            ans += (sum[n][0] - sum[i][0]) * (sum[n][2] - sum[i][2]);
        else
            ans += (sum[n][1] - sum[i][1]) * (sum[n][0] - sum[i][0]);
        const int g = n - i;

        for (int j = 1; 2 * j < g; ++j)
        {
            if (s[i + j] != t && s[i + 2 * j] != t && s[i + j] != s[i + 2 * j])
                --ans;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
struct node
{
    string c;
    int s;
    int id;
    bool operator <(const node &b)const
    {
        if(c!=b.c)
        return c<b.c;

            return s>b.s;
    }
}a[110];
string c[110];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        cin>>a[i].c>>a[i].s;
        a[i].id=i;
    }
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++)printf("%d\n",a[i].id);
    return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")
#include"stdio.h"
#include"stdlib.h"
#include"assert.h"
#include"ctype.h"
#include"string.h"
#include"math.h"
#include"string"
#include"deque"
#include"iostream"
#include"set"
#include"map"
#include"vector"
#include"algorithm"
#include"bitset"
#include"stack"
#include"queue"
#include"sstream"
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int long long
#define ends ' '
#define endl '\n'
#define pb emplace_back
#define x first
#define y second
#define pii pair<int, int>
#define sz(x) (int)(x).size()

const int maxn = 1e5+10;

vector<int> g[3*maxn];

int dist[3*maxn];

int32_t main()
{
	// #ifndef ONLINE_JUDGE
		// freopen("input.txt", "r", stdin);
		// freopen("output.txt", "w", stdout);
	// #endif
	IOS;

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

	for(int i = 1; i <= m; ++i)
	{
		int u, v;
		cin >> u >> v;
		g[u].pb(v+n);
		g[u+n].pb(v+2*n);
		g[u+2*n].pb(v);
	}

	int s, t;
	cin >> s >> t;

	dist[s] = 0;

	queue<pii> q;

	q.push({s, 0});

	while(!q.empty())
	{
		int node = q.front().x;
		int d = q.front().y;
		if(node == t)
		{
			cout << d/3;
			return 0;
		}
		q.pop();
		for(int i : g[node])
		{
			if(!dist[i])
			{
				q.push({i, d+1});
				dist[i] = d+1;
			}
		}
	}

	cout << -1;

	return 0;
}

Measured memory_bytes: 19072
#include<iostream>
using namespace std;
int main(){
int n,c=0,c1=0;
cin>>n;
    for(int i=1;i<=n;i=i+2)
{
    for(int j=1;j<=n;j++){
        if(i%j==0){
            c++;
            }
            if(c==8){
                c1++;
                c=0;
                break;
                }
    }
    c=0;
}
    cout<<c1<<endl;

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int long long int
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
 
using namespace std;
 
int inf = 1e18;
const int N = 4e5+5;
int mod = 1e9+7-998244353+998244353;
/*void dfs(int u,int par,int maxx)
{
 
 
    for(int v:adj[u])
    {
        if(v==par)
            continue;
        dfs(v,u,maxx);
    }
}
 
 
int ncr(int n , int r ){
	r = min(r,n-r);
	int res = 1 ;
	for(int i = 1 ; i <= r ; i++ ){
		( res *= n-i+1 )%= mod;
		res /= i ;
	}
	return res ;
}
*/
int arr[N];
 int sumXOR(int n)
{
     int sum = 0;
    for (int i = 0; i < 65; i++)
    {
 
        int zc = 0, oc = 0;
 
         int idsum = 0;
        for (int j = 0; j < n; j++)
        {
            if (arr[j] % 2 == 0)
                zc++;
            else
                oc++;
            arr[j] /= 2;
        }
 
        idsum = ( ( ((oc)%mod) * ((zc)%mod))%mod * ((1LL<< i)%mod))%mod;
 
        sum = (sum+idsum)%mod;
    }
    return sum%mod;
}
int32_t main()
{
    io
    int tt=1;
    //cin>>tt;
    while(tt--)
    {
        int n;
        cin>>n;
 
        rep(i,0,n)
        cin>>arr[i];
        int ans = sumXOR(n);
        cout<<ans%mod<<el;
 
    }
 
 
 
    return 0;
}

Measured memory_bytes: 2560
N=int(input())
List=list(map(int,input().split()))
List.sort(key=lambda x:x)
n=0
Alice=0
Bob=0
while n<=N-1:
  if n%2==0:
    Alice+=List[N-1-n]
  else     :
    Bob+=List[N-1-n]
  n+=1
print(Alice-Bob)

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

long long X[100005];

int main()

{
	int N,A,B;
	cin>>N>>A>>B;
	
	int i;
	
	for (i=1;i<=N;i++)
	cin>>X[i];
	
	long long ans=0;
	
	for (i=1;i<N;i++)
	{
		long long dist=X[i+1]-X[i];
		
		if(dist*A<B)
		ans+=dist*A;
		
		else ans+=B;
	}
	
	cout<<ans;
}

Measured memory_bytes: 1024
N=int(input())
A=list(map(int,input().split()))
money=1000;kabu=0
i=0
while(i<N):
    j=i
    money,kabu=money-(money//A[i])*A[i],kabu+(money//A[i])
    while(j<N-1 and A[j]<=A[j+1]):
        j+=1
    money=money+kabu*A[j]
    kabu=0
    i=j+1
print(money)

Measured memory_bytes: 61756
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;

VLL a, b;

int main()
{
    ll n;
    cin>>n;
    a.resize(n); b.resize(n);
    REP(i,n) {
        cin>>a[i]>>b[i];
    }
    SORT(a); SORT(b);

    if (n % 2 == 1) {
        cout<<b[n/2] - a[n/2] + 1<<endl;
    } else {
        cout<<(b[n/2-1] + b[n/2]) - (a[n/2-1] + a[n/2]) + 1<<endl;
    }

    return 0;
}


Measured memory_bytes: 6416
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		sc.close();

		long s = a + b;
		long x = n / s;
		System.out.println(a * x + Math.min(a, n % s));
	}
}


Measured memory_bytes: 23764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        long a = s.nextLong(),b=s.nextLong(),x=s.nextLong();
        long start=a;
        if(start%x!=0)start = a+(x-(a%x));
        long end = b - (b%x);
        System.out.println((end-start)/x + 1);

    }


}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25404
local s = io.read()
if s:sub(1,1)==s:sub(2,2) and s:sub(1,1)==s:sub(3,3) then
  print("Yes")
elseif s:sub(4,4)==s:sub(2,2) and s:sub(4,4)==s:sub(3,3) then
  print("Yes")
else
  print("No")
end


Measured memory_bytes: 760
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  //入力
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++) cin >> A[i];

  //処理
  sort(A.begin(), A.end(), greater<>());
  ll ans = 0;
  if (N < 3) ans += A[0];
  else ans += A[0] + A[1];
  for (int i=3; i<N; i++) {
    ans += A[i/2];
  }

  //出力
  cout << ans << endl;
}

Measured memory_bytes: 4104
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, a[100005] = {}, b[100005] = {}, c, y = 0, z = 0;
    string s;
    cin >> n >> m;
    while (m--) {
        cin >> c >> s;
        if (s == "AC") {
            if (!a[c]) y++;
            a[c] = 1;
        } else {
            if (!a[c]) b[c]++;
        }
    }
    for (int i = 1; i <= n; i++) if (a[i]) z += b[i];
    cout << y << ' ' << z;
}


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

int main() {
	string s;
	cin >> s;
	string k = "yes";
	sort(s.begin(),s.end());
	for(int i = 0;i < s.size()-1;i++)
	{
		if(s.at(i) == s.at(i+1))
		{
			k = "no";
		}
	}
    cout << k << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <list>
#include <numeric>
#include <math.h>
#include <cstdlib>
#include <queue>
#include <iterator>
#include <limits>
#include <string>
#include <sstream>
#include <iomanip>
#include <bitset>
#include <mutex>
#include <condition_variable>
#include <atomic>
#include <stack>
#include <memory>
#include <deque>
#include <string_view>
#include <random>
#include <chrono>
#include <cstring>

using namespace std;

static int my_speed_up = []() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); return 0; }();
using ll = long long; using ull = unsigned long long;
template<class T> using v = vector<T>;
template<class T> using vv = vector<vector<T>>;
template<class T> using vvv = vector<vector<vector<T>>>;
template<class T> using vvvv = vector<vector<vector<vector<T>>>>;
#define for_b(i, b) for (int i = 0; i < (b); ++i)
#define for_ab(i, a, b) for (int i = a; i < (b); ++i)
#define what_is(x) cout << #x << " = " << x << endl;
#define what_are(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl;
#define pad(x) for_b(i, x) cout << "  ";
#define show_1d(___x) cout << #___x << " = "; for (auto& ___num : ___x) cout << ___num << ", "; cout << endl;
#define show_2d(___x) cout << #___x << endl; for (auto& ___row : ___x) { for (auto ___num : ___row) cout << ___num << ", "; cout << endl; }
#define show_3d(___x) cout << #___x << endl; for (auto& ___row : ___x) { for (auto& ___row2 : ___row) { for (auto ___num : ___row2) cout << ___num << ", "; cout << endl; }cout << endl; }

vv<int> d4 = {{1,0},{-1,0},{0,1},{0,-1}};
vv<int> d8 = {{1,0},{-1,0},{0,1},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};
bool is_valid_pos(const vv<int>& tb, int x, int y) {
    return x >= 0 && x < tb.size() && y >= 0 && y < tb[0].size();
}


int main()
{
    ll N;
    cin >> N;
    v<ll> tb (N);
    
    for_b(i,N)
        cin >> tb[i];
        
    ll cur_max = tb[0];
    ll res = 0;
    for_ab(i,1,tb.size())
    {
        if (tb[i] < cur_max)
            res += cur_max - tb[i];
        else
            cur_max = tb[i];
    }
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 4752
// b

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ru(a,b) (((a)+((b)-1)) / (b))   //切り上げ(a/b)
#define dump(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    // 単発入力
    int N;
    cin >> N;

    vector<int> A(N);
    rep(i,N) cin >> A[i];


    vector<bool> B(1000000010);

    for (int i = 0; i < N; ++i)
    {
        if (B[A[i]] == true)
        {
            cout << "NO" << endl;
            return 0;
        }
        B[A[i]] = true;
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 123136
n,m,q = map(int,input().split())
u = []
for i in range(q):
    u.append(list(map(int,input().split())))
"""
a = [i[0] for i in u]
b = [i[1] for i in u]
c = [i[2] for i in u]
d = [i[3] for i in u]
"""
z = []
import itertools
a = itertools.combinations_with_replacement([i for i in range(1,m+1)],n)
for e in a:
    sum = 0
    for i in range(q):
        if e[u[i][1]-1]-e[u[i][0]-1] == u[i][2]:
            sum += u[i][3]
    z.append(sum)

print(max(z))

Measured memory_bytes: 12800
#include "bits/stdc++.h"
using namespace std;
 
int main(void) {
	string s;
	cin >> s;

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

	bool check = true;

	for(int i=0;i<s.size()-1;i++) {
		if(s.at(i) == s.at(i+1)) check = false;
	}

	if(check) cout << "yes" << endl;
	else cout << "no" << endl;
}


Measured memory_bytes: 256
import sys

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

overlap_l = 1
overlap_r = n
for i in range(m):
    l, r = list(map(int,input().split()))
    if overlap_r < l or r < overlap_l:
        print(0)
        sys.exit()
    else:
        overlap_l = max(l, overlap_l)
        overlap_r = min(r, overlap_r)

print(overlap_r - overlap_l + 1)

Measured memory_bytes: 44776
#include<iostream>
#include<cstdio>
#include<string>00
using namespace std;

int main(){
	char ch, ch2;
	
	while(1){
		scanf("%c", &ch);
		
		if(islower(ch)){
			ch2 = toupper(ch);
			cout << ch2;
		}else{
			ch2 = tolower(ch);
			cout << ch2;
		}
		
		if(ch == '\n'){
			break;
		}
	}
		
	return 0;
}

Measured memory_bytes: 3112
from math import sqrt, ceil
from itertools import accumulate
N = 120000
temp = [True]*(N+1)
temp[0] = temp[1] = False
for i in range(2, ceil(sqrt(N+1))):
    if temp[i]:
        temp[i+i::i] = [False]*(len(temp[i+i::i]))

cumsum = [i for i in range(N) if temp[i]]
cumsum = list(accumulate(cumsum))
while True:
    n = int(input())
    if not n: break
    print(cumsum[n-1])


Measured memory_bytes: 7928
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pp pair<ll,ll>
#define vi vector<pair<pp,pp> >
#define pq_min priority_queue<ll,vector<ll>,greater<ll>>
#define pq_max priority_queue<ll>
#define f(i,a,b) for(ll i=a;i<b;i++)
#define r(i,a,b) for(ll i=b-1;i>=a;i--)
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define ld long double
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef pair<pp,pp> ppll;
const ll mod=1e9 +7;
const ll N = 1e12 + 5 ;
ll ans=0;

ll power(ll a,ll b)
{
    ll res=1;
    a%=mod;
    while(b>0)
    {
        if(b%2==1)
        {
            res = (res * a)%mod;
        }
        b/=2;
        a = (a*a)%mod;
    }
    return res;
}



int main()
{
    fast;
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        if(i%3!=0 && i%5!=0)
        {
           ans += i;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 3640
#include <string>
#include <iostream>
#include <list>

using namespace std;

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

void solve(){
    string t;
    getline(cin,t);
    list<char> s(t.begin(), t.end());

    auto it = s.begin();
    int n; cin>>n; cin.get();
    while(n--){
        string cmd; getline(cin,cmd);

        if(cmd=="forward char"){
            if(it!=s.end()) ++it;
        } else if(cmd=="forward word"){
            while(it!=s.end() && *it==' ') ++it;
            while(it!=s.end() && *it!=' ') ++it;
        } else if(cmd=="backward char"){
            if(it!=s.begin()) --it;
        } else if(cmd=="backward word"){
            while(it!=s.begin() && *--it==' ') continue;
            while(it!=s.begin()){
                --it;
                if(*it==' '){
                    ++it;
                    break;
                }
            }
        } else if(cmd.substr(0,6)=="insert"){
            int i = cmd.find('"') + 1;
            int j = cmd.find('"',i);
            s.insert(it,cmd.begin()+i,cmd.begin()+j);
        } else if(cmd=="delete char"){
            if(it!=s.end()) it = s.erase(it);
        } else if(cmd=="delete word"){
            auto it2 = it;
            while(it2!=s.end() && *it2==' ') ++it2;
            if(it2==s.end()) continue;
            while(it2!=s.end() && *it2!=' ') ++it2;
            it=s.erase(it,it2);
        }
    }

    for(auto i=s.begin();;++i){
        if(i==it)
            cout<<'^';
        if(i==s.end())
            break;
        cout<<*i;
    }
    cout<<endl;
}

int main(){
    int t; cin>>t;
    cin.get();
    rep(i,t) solve();
}

Measured memory_bytes: 1248
A,B,C,D=input().split()
num = 0
while(int(A)>=0 and int(C)>=0):
    if int(A)<= 100 and 0 <= int(B)<= 100 and int(C)<= 100 and 0 <= int(D)<= 100:
        if num %2 == 0:
            C = int(C)-int(B)
            if int(C)<=0:
                print("Yes")
                break
            num += 1
        elif num %2 !=0:
            A = int(A)-int(D)
            if int(A)<=0:
                print("No")
                break
            num += 1
    else:
        break


Measured memory_bytes: 8908
n=int(input())
ss=set()
d=dict()
for ii in range(n):
  s=input()
  if s in ss:
    d[s]+=1
  else:
    ss.add(s)
    d[s]=1
ss=list(ss)
ss.sort()
mx=max(d.values())
for ii in ss:
  if d[ii]==mx:
    print(ii)

Measured memory_bytes: 40360
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdbool.h>




int main() {
	char s[10011][11];
	int n,cnt=0,cnta=0,cntb=0,m[10011],flag=0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", s[i]);
		for (int j = 0; s[i][j] != '\0'; j++) {
			if (s[i][j] == 'A' && s[i][j + 1] == 'B') {
				cnt++;
				s[i][j] = 'C';
				s[i][j + 1] = 'C';
			}
			if (s[i][j + 1] == '\0')m[i] = j;
			
		}
	}
	for (int i = 0; i < n; i++) {
		
		
		if (s[i][0] == 'B' && s[i][m[i]] == 'A')flag++;
		else if (s[i][0] == 'B')cntb++;
		else if (s[i][m[i]] == 'A')cnta++;
	}
	if (flag != 0 ) {
		if (cnta != 0 && cntb != 0) {
			cnt += flag + 1;
			cnta--; cntb--;
		}
		else if (cntb != 0 || cnta != 0)cnt += flag;
		else cnt += flag - 1;
		
	}
	if (cnta > cntb)printf("%d", cnt + cntb);
	else printf("%d", cnt + cnta);
	return 0;
}

Measured memory_bytes: 256
integer(8) a,b,d,e,f,g,check
integer(8),dimension(3,3):: c
 
check=0
do i=1,3
  read*,c(i,:)
end do

a=c(1,1)-c(1,2)
b=c(1,2)-c(1,3)
d=c(1,3)-c(1,1)
e=c(1,1)-c(2,1)
f=c(2,1)-c(3,1)
g=c(3,1)-c(1,1)
 
do i=1,3
  if (c(i,1)-c(i,2)==a .and. c(i,2)-c(i,3)==b .and. c(i,3)-c(i,1)==d) then
    if (c(1,i)-c(2,i)==e .and. c(2,i)-c(3,i)==f .and. c(3,i)-c(1,i)==g) then
          
    else
      check=1
    endif
  else
    check=1
  endif
enddo
 
if (check==0)then
  print"(A)","Yes"
else
  print"(A)","No"
endif
end

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

# import functools
# import operator
# prod = functools.partial(functools.reduce, operator.mul)

# i=K+1の時、直近K回の期末テストの点数
# p_K = prod(A[:K])
p_K = 1

for i in range(K, N):
    t = A[i] / A[i-K]
    p_Kp1 = p_K * t
    if p_K < p_Kp1:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 31748
#include <cstdio>
#include <cmath>

int main(){
    long long n;
    scanf("%lld",&n);

    //x^2 + x - 2*n = 0
    int resp = ceil((-1.0 +  sqrt(1.0 + 8.0*n))/2.0);
    while(n >= resp && resp >= 0 && n >= 0){
        if(resp!=0)printf("%d\n",resp);
        n -= resp;
        resp--;
    }
    if(n!=0)printf("%d\n",n);

}


Measured memory_bytes: 128
N = int(input())
H = list(map(int, input().split()))

dp = [0] * N

dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    dp[i] = min([
        dp[i-1] + abs(H[i] - H[i-1]),
        dp[i-2] + abs(H[i] - H[i-2]),
    ])
    
print(dp[-1])

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back

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

ll modpow(ll a, ll n, ll m)
{
    if(n == 0) return 1;
    ll t = modpow(a, n >> 1, m);
    t = t * t % m;
    if(n & 1) t = t * a % m;
    return t; 
}

int main()
{
    ll N;
    cin >> N;
    map<pair<ll,ll>,ll> R, S;
    ll c = 0;
    REP(i,0,N) {
        ll a, b;
        cin >> a >> b;
        if(b == 0) {
            if(a == 0) {
                ++c;
                continue;
            }
            else if(a < 0) a = -a;
        }
        else if(b < 0) {
            a = -a;
            b = -b;
        };
        ll g = gcd(abs(a), abs(b));
        ++R[{a/g, b/g}];
    }

    ll sum = 1;
    FORR(r,R) {
        pair<ll,ll> p = r.first, s;
        ll ci = r.second, cj;
        R[p] = 0;
        if(p.first > 0) s = {-p.second, p.first};
        else s = {p.second, -p.first};
        if(R.count(s) > 0) {
            cj = R[s];
            R[s] = 0;
        }
        else cj = 0;
        ll t = (modpow(2, ci, MOD) + modpow(2, cj, MOD) - 1 + MOD) % MOD;
        sum = (sum * t) % MOD;
    }
    PR((sum+c-1+MOD)%MOD);

    return 0;
}

/*



*/

Measured memory_bytes: 16000
#include<stdio.h>


int main(){
	int loop,c=0;
	int angka[30];
	scanf("%d", &loop);
	
	for(int i=0; i<loop; i++){
		scanf("%d", &angka[i]);
	}
	for(int i=1; i<loop-1; i++){
		if(angka[i]>angka[i-1]&&angka[i]<angka[i+1]||angka[i]<angka[i-1]&&angka[i]>angka[i+1])
		c++;
	}
	
	printf("%d\n", c);
	return 0;
}

Measured memory_bytes: 128
n = int(input())
s = [c == 'o' for c in input()]
def next_s(s, flag):
  d = {'S' : 'W', 'W' : 'S'}
  if flag:
    return s
  else:
    return d[s]

def sim(s0):
  ans = ['.' for _ in range(n+1)]
  ans[0] = s0[0]
  ans[1] = s0[1]
  for i in range(2, n+1):
    if ans[i-1] == 'S':
      ans[i] = next_s(ans[i-2], s[i-1])
    else:
      ans[i] = next_s(ans[i-2], not s[i-1])
  res = ans[1] == ans[-2]
  if s0[0] == 'S':
    if res == s[0] and ans[-1] == ans[0]:
      return ans[:-1]
  else:
    if res != s[0] and ans[-1] == ans[0]:
      return ans[:-1]
  return False

def solve():
  for item in ["SS", "SW", "WS", "WW"]:
    ans = sim(item)
    if ans:
      return print(''.join(ans))
  return print(-1)

solve()


Measured memory_bytes: 5516
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
using namespace std;

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

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

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

  if (bsum > asum) {
    puts("-1");
    return 0;
  }

  vector<int> g;
  vector<int> l;
  for (int i = 0; i < n; ++i) {
    int diff = a[i] - b[i];
    if (diff < 0) l.push_back(diff);
    else g.push_back(diff);
  }

  if (g.size() == n) {
    puts("0");
    return 0;
  }

  sort(g.begin(), g.end(), greater<int>());
  int cur = 0;
  for (int i = 0; i < (int)l.size(); ++i) {
    while (l[i] < 0) {
      if (abs(l[i]) > g[cur]) {
	l[i] += g[cur];
	cur++;
      } else {
	g[cur] += l[i];
	l[i] = 0;
      }
    }
  }
  int ans = (int)l.size() + cur + 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1660
#include <math.h>
#include <bits/stdc++.h>
#define ll long long
#define l long double
#define pi 3.14159265358979323846
#define mod 1000000007
#define val 1000000000000000000
using namespace std;
int main()
{
    int n;
    l ss = 1;ll f = 0;
    ll a = 1000000000000000000;
    cin >> n;
    ll s[n];
    for (ll i = 0; i < n; i++)
    {
        cin >> s[i];
        if (s[i] == 0)
        {
            f = 1;
            break;
        }
    }
    if (f == 1)
        cout << "0" << endl;
    else
    {
        for (ll i = 0; i < n; i++)
        {
            ss = ss * s[i];
            if (ss > 1000000000000000000 || ss < 0)
            {
                ss = -1;
                break;
            }
        }
        cout << (ll)ss << endl;
    }
}

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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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;
}

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

ll N;

struct Comp1 {
	bool operator()(const l_l &a, const l_l &b) {
		if (a.first != b.first) {
			return a.first < b.first;
		}
		return a.second > b.second;
	}
};

struct Comp2 {
	bool operator()(const l_l &a, const l_l &b) {
		if (a.first != b.first) {
			return a.first > b.first;
		}
		return a.second > b.second;
	}
};

void solve() {
    cin >> N;
    vector<string> a(N);
    vector<l_l> adds, subs;
    
	int tlc = 0, trc = 0;

    for (int i = 0; i < N; i++) {
		int lc = 0, rc = 0;
		cin >> a[i];
		for (auto& c : a[i]) {
			if (c == '(') {
				lc++;
			} else {
				if (lc) lc--;
				else rc++;
			}
		}
		if (lc && !rc) tlc += lc;
		else if (!lc && rc) trc += rc;
		else if (lc && rc) {
			if (lc >= rc) adds.push_back({rc, lc});
			else subs.push_back({rc, lc});
		}
	}
    sort(adds.begin(), adds.end(), Comp1());
    sort(subs.begin(), subs.end(), Comp2());
    
    bool pos = true;
    for (auto& i : adds) {
		if (i.first > tlc) {
			pos = false;
			break;
		} else {
			tlc -= i.first;
			tlc += i.second;
		}
	}
	
	for (auto& i : subs) {
		if (i.first > tlc) {
			pos = false;
			break;
		} else {
			tlc -= i.first;
			tlc += i.second;
		}
	}
    
    if (pos && tlc == trc) cout << "Yes";
    else cout << "No";
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 34336