akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const ll MOD = 1e9+7;

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

//********************************template END****************************************//

void solve(void){

	int N;
	cin >> N;

	vec xs(N), ys(N), hs(N);
	rep(N, i) cin >> xs[i] >> ys[i] >> hs[i];

	Rep(0, 100, cx) Rep(0, 100, cy)
	{
		vecll Hs;
		rep(N, i)
		{
			ll H = abs(cx-xs[i]) + abs(cy-ys[i]) + hs[i];
			if (H > 0)
			{
				Hs.pb(H);
			}
		}

		if (Hs.size() == 0) continue;

		for (ll H : Hs)
		{
			bool f = 1;

			rep(N, i)
			{
				f &= max(H-abs(cx-xs[i])-abs(cy-ys[i]), 0LL) == hs[i];
			}

			if (f)
			{
				cout << cx << ' ' << cy << ' ' << H << endl;
				return;
			}
		}

	}


}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[101];
int main()
{
int n,i,sum=0;
cin>>n;
for (i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
}
if (sum%10!=0){
    cout<<sum;
    return 0;
}
sort(a,a+n);
for (i=0;i<n;i++)
    if ((sum-a[i])%10!=0)
    {
        cout<<(sum-a[i]);
        return 0;
    }
cout<<0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
k = []
douro = []
for i in range(N):
  douro.append(0)
for i in range(M):
    k.append(list(map(int,input().split())))
for i in range(M):
    douro[(k[i][0]-1)] += 1
    douro[(k[i][1]-1)] += 1
for i in range(N):
  print(douro[i])

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        long n=sc.nextLong();
        long i;
        long ans=0;
        for(i=1;i*i<=n;i++){
            if(n%i==0)ans = i;
        }
        System.out.println(ans+n/ans-2);

    }

}



Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define F first
#define S second
#define ld long double
#define pb push_back
#define sz size
#define sc(a) scanf("%d",&a)
#define scll(a) scanf("%lld",&a)
#define scc(a) scanf(" %c",&a)
#define scs(a) scanf(" %s",a)
#define me(a,b) memset(a,b,sizeof a)
#define all(a) a.begin(),a.end()
#define allr(a,n) a,a+n
#define loop(a,s,e) for(ll a=s;a<=e;a++)
#define read_arr(a,s,n) for(int i=s;i<n+s;i++){sc(a[i]);}
#define read_arr_ll(a,s,n) for(int i=s;i<n+s;i++){scll(a[i]);}
#define err(a,s) cerr<<a<<s;
#define err_arr(a,s,n) for(int i=s;i<n+s;i++){cerr<<a[i]<<" ";}cerr<<endl;
#define prtll(x) printf("%lld",x);
#define prt(x) printf("%d",x);
#define F first
#define S second
#define ld long double
#define ll long long
#define pb push_back
#define sz size
#define INF 0x7f7f7f7f
using namespace std;
const int N =1e5;
ll n ,val[N] , w[N],k ;
ll oo=1e9+10;
ll mem[200][N];
ll dp(int i,int sum){
if(sum<0){return -oo;}
if(sum==0){return 0;}
if(i==n){return 0;}
ll &ret=mem[i][sum];
if(ret!=-1){return ret;}
ret=dp(i+1,sum);
ret=max(ret,val[i]+dp(i+1,sum-w[i]));
return ret;
}

int main(){
memset(mem,-1,sizeof mem);
scll(n);scll(k);
for(int i=0;i<n;i++){scll(w[i]);scll(val[i]);}
printf("%lld\n",dp(0,k));

return 0;
}


Measured memory_bytes: 157952
object Main extends App{
    // Your code here!
    
    var s = io.StdIn.readLine
    var count = 0;
    for (i <- 0 until s.size / 2) {
        if (s(i) != s(s.size - i - 1)) {
            count = count + 1
        }
    }

    println(count)
}

Measured memory_bytes: 54676
#include <iostream>

using namespace std;

int main(){
    int H,W;
    cin >> H >> W;

    char grid[H][W];

    for(int i = 0; i < H; i++){
        for(int n = 0; n < W; n++){
            cin >> grid[i][n];
        }
    }

    bool check = false;

    do{
        check = false;
        
        //横のチェック
        for(int i = 0; i < H; i++){
            bool hCheck = false;
            for(int n = 0; n < W; n++){
                if(grid[i][n] == '#'){
                    hCheck = true;
                    break;
                }
            }
            if(!hCheck){
                for(int x = i; x < H-1; x++){
                    for(int n = 0; n < W; n++){
                        grid[x][n] = grid[x+1][n];
                    }
                }
                H--;
                check = true;
                break;
            }
        }
        if(check) continue;
        
        //縦のチェック
        for(int i = 0; i < W; i++){
            bool wCheck = false;
            for(int n = 0; n < H; n++){
                if(grid[n][i] == '#'){
                    wCheck = true;
                    break;
                }
            }
            if(!wCheck){
                for(int x = i; x < W-1; x++){
                    for(int n = 0; n < H; n++){
                        grid[n][x] = grid[n][x+1];
                    }
                }
                W--;
                check = true;
                break;
            }
        }
        
    }while(check);

    for(int i = 0; i < H; i++){
        for(int n = 0; n < W; n++){
            cout << grid[i][n];
        }
        cout << endl;
    }

    return 0;
}

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

int main(){
  long long N,Max=0,Num;
  cin >> N;
  vector<long long> A(N),B(N);
  for(long long i=0;i<N;i++){
    cin >> A[i];
    B[i] = A[i];
    if(A[i]>=Max){
      Max = A[i];
      Num = i;
    }
  }
  sort(B.begin(),B.end());
  for(long long i=0;i<N;i++){
    if(i==Num){
      cout << B[N-2] << endl;
    }else{
      cout << B[N-1] << endl;
    }
  }
  return 0;
}
  

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

void solve(const vector<vecll>& dp, ll k, ll i, ll j) {
  if (i == -1) return;
  ll s = max(0l, j-1);
  ll t = min(9l, j+1);
  FOR(a,s,t+1) {
    if (dp[i][a] >= k) {
      cout<<a;
      solve(dp, k, i-1, a);
      return;
    } else {
      k -= dp[i][a];
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll k;
  cin>>k;
  vector<vecll> dp(10, vecll(10, 0));
  REP(i,10) dp[0][i] = 1;
  REP(i,9) {
    REP(j,10) {
      dp[i+1][j] += dp[i][j];
      if (j) dp[i+1][j] += dp[i][j-1];
      if (j < 9) dp[i+1][j] += dp[i][j+1];
    }
  }
  REP(i,10) {
    FOR(j,1,10) {
      if (dp[i][j] >= k) {
        cout<<j;
        solve(dp, k, i-1, j);
        cout<<endl;
        return 0;
      } else {
        k -= dp[i][j];
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
s = input()
cnt = 0
if s[0] == "A" and s[2:-1].count("C") == 1:
    for i in range(len(s)):
        if ord(s[i])<=90:
            cnt += 1
    if cnt != 2:
        print("WA")
    else:
        print("AC")
else:
    print("WA")


Measured memory_bytes: 2940
using System;

class Program
{
    static void Main(string[] args)
    {
        String str1, str2, str3;
        int a, b;
        int sum = 0;
        char op;

        while (true)
        {

            string[] str = Console.ReadLine().Split(' ');
            str1 = str[0];
            str2 = str[1];
            str3 = str[2];

            a = int.Parse(str1);
            b = int.Parse(str3);
            op = char.Parse(str2);

            if (op == '+')
            {
                sum = a + b;
            }else if (op == '-')
            {
                sum = a - b;
            }else if (op == '*')
            {
                sum = a * b;
            }else if (op == '/')
            {
                sum = a / b;
            }else
            {
                break;
            }
        Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 9136
#include <iostream>
using namespace std;
int main() {
    int r;
    cin >> r;
    if (r < 1200) {
        cout << "ABC" << endl;
    } else if (r < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
}

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

int calc(int a,int b){
    if(a%b==0){
        return b;
    }
    return calc(b,a%b);
}

int main(){
	// おまじない
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int N,M;
	// 出入力
	cin>>N>>M;

    // vector<int> A(N);
    set<int> A;
    int a;
    for(int i=0;i<N;i++){
        cin>>a;
        A.insert(a/2); 
    }
    ll k=1;
    ll tmp_n;
    for(int a:A){
        tmp_n = calc(k,a);
        k = a*k/tmp_n;
    }
    for(int a:A){
        if((k/a)%2==0){
            cout<<0<<"\n";
            return 0;
        }
    }
    ll ans = 0;
    ans = M/k;

    if ((M/k)%2!=0){
        ++ans;
    }
    ans=ans/2;
    
    cout<<ans<<"\n";

	return 0;
}

Measured memory_bytes: 4992
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  int n;
  cin >> n;
  int mx = 0, mn = MOD;
  rep(i, n){
    int m; cin >> m;
    chmax(mx, m);
    chmin(mn, m);
  }
  cout << mx - mn << ln;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

template <class T>
struct Union_find {
    /*
  T: integer(int, long longなど)
  n個の整数に対してunion find森を生成
  par: 親の配列 ex)par[x]はxの親
  rank: ランクの配列で、root以外は意味はない
  size_of: サイズの配列で、root以外は意味がない
  root(x): xの根を返す
  same(x, y): boolでxとyが連結かを返す
  size(x): xが含まれる木の要素数を返す
  unite(x, y): xが含まれる木とyが含まれる木を連結させる
  */
    vector<int> par;
    vector<int> rank;
    vector<int> size_of;

    Union_find(T n) : par(n), rank(n), size_of(n) {
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
            size_of[i] = 1;
        }
    }

    int root(T x) {
        return par[x] == x ? x : par[x] = root(par[x]);
    }

    bool same(T x, T y) {
        return root(x) == root(y);
    }

    int size(T x) {
        return size_of[root(x)];
    }

    void unite(T x, T y) {
        x = root(x);
        y = root(y);
        if (x == y) {
            return;
        }
        if (rank[x] < rank[y]) {
            size_of[y] += size_of[x];
            par[x] = y;
        }
        else {
            size_of[x] += size_of[y];
            par[y] = x;
            if (rank[x] == rank[y])
                rank[x]++;
        }
        return;
    }
};

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<set<int>> cannot_make_friends_with(n);
    int a, b;
    Union_find<int> uf(n);
    rep(i, m) {
        cin >> a >> b;
        a--;
        b--;
        uf.unite(a, b);
        cannot_make_friends_with[a].insert(b);
        cannot_make_friends_with[b].insert(a);
    }
    int c, d;
    rep(i, k) {
        cin >> c >> d;
        c--;
        d--;
        if (uf.same(c, d)) {
            cannot_make_friends_with[c].insert(d);
            cannot_make_friends_with[d].insert(c);
        }
    }
    rep(i, n) {
        cout << uf.size(i) - cannot_make_friends_with[i].size() - 1;
        if (i != n - 1)
            cout << " ";
        else
            cout << endl;
    }
    return 0;
}

Measured memory_bytes: 25472
#![allow(non_snake_case, unused_mut)]
use std::collections::HashMap;
fn main() {
    proconio::input! {
        n:usize,
        A:[usize;n]
    }
    let mut B = HashMap::new();
    //B.reserve(n);
    for i in 0..n {
        let entry = B.entry(A[i]).or_insert(0);
        *entry += 1;
    }
    let mut sum = 0;
    for (_, &v) in B.iter() {
        sum += combination(v);
    }
    //println!("sum={}", sum);
    for i in 0..n {
        let val = B.get(&A[i]).unwrap();
        let ans = sum - combination(*val) + combination(*val - 1);
        println!("{}", ans);
    }
}

fn combination(v: usize) -> usize {
    if v <= 1 {
        0
    } else {
        v * (v - 1) / 2
    }
}


Measured memory_bytes: 11504
#include "bits/stdc++.h"

#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

template<typename T1,typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 & a, T2 b) { if (a < b) a = b; }

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;
const long long kMod = 1000000007;

const long kMAX = 1000000000;

using namespace std;
using ll = long long;

inline int readInt() {
  char c = getchar();
  while(!isdigit(c) && c != '-') c = getchar();
  int sigma = 1;
  if (c == '-') {
    sigma = -1;
    c = getchar();
  }
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * sigma;
}

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

  ll ans;

  int n, m;
  vector<ll> a, b;

  string s, t;
  cin >> s >> t;
  rep(i, 0, 2) { if (s[i] == t[i]) ++ans; }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  //宣言
  int N,ch;
  //入力
  scanf("%d",&N);
  //計算
  ch = N%1000;
  if(ch != 0)
  {
    ch = 1000 - ch;
  }
  //出力
  printf("%d",ch);

  return 0;
}

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

#define N 101

int a[N][N], b[N], c[N], t=0, n;

void DFS(int p);

int main(void){
  int i, j;
  int u, k, v;
  
  scanf("%d",&n);
  if(n<1 || n>N) exit(1);

  for(i=1;i<=n;i++){
    b[i]=0;
    c[i]=0;
  }
  
  for(i=1; i<=n; i++)
    for(j=1;j<=n;j++) a[i][j]=0;
  
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      a[u][v]=1;
    }
  }
  
  for(i=1; i<=n; i++){
    DFS(i);
  }
  for(i=1; i<=n; i++) printf("%d %d %d\n",i,b[i],c[i]);
  
  return 0;
}


void DFS(int r){
  int i;
  
  if(b[r]==0){
    t++;
    b[r]=t;
    for(i=1; i<=n; i++){
      if(a[r][i]==1) DFS(i);
    }
    t++;
    c[r]=t;
  }

  return ;
}
  



Measured memory_bytes: 2108
#include<iostream>
#include<vector>
#define mod 1000000007
#define ll long long
using namespace std;
int solve(int n,int k,vector<int> &v)
{
    ll dp[n+1][k+1];
    for(int i=0;i<=k;i++)
    {
        dp[1][i]=(i>v[1])?0:1;
    }
    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<=k;j++)
        {
            if(j==0) dp[i][j]=dp[i-1][j];
            else 
            {
                dp[i][j]=(mod+dp[i][j-1]+dp[i-1][j]-((j-v[i]-1)>=0?dp[i-1][j-v[i]-1]:0))%mod;
            }
        }
    }
    return dp[n][k]%mod;
}
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> v(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    cout<<solve(n,k,v);
    return 0;
}

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

int main(){
    string s;
    cin>>s;
    int num;
    cin>>num;
    int l2r=s[0]-'0';
    for(int i=1;i<s.size();i+=2){
        if(s[i]=='*'){
            l2r*=s[i+1]-'0';
        }else{
            l2r+=s[i+1]-'0';
        }
    }
    stack<int> S;
    S.push(s[0]-'0');
    for(int i=1;i<s.size();i+=2){
        if(s[i]=='*'){
            S.top()*=s[i+1]-'0';
        }else{
            S.push(s[i+1]-'0');
        }
    }
    int mf = 0;
    while(!S.empty()){
        mf+=S.top();
        S.pop();
    }
    bool L = num==l2r;
    bool M = num==mf;
    char ans;
    if(L&&M){
        ans = 'U';
    }else if(L){
        ans = 'L';
    }else if(M){
        ans = 'M';
    }else{
        ans = 'I';
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3228
/*Author : Yuvraj Singh
 * Patience is Power
 * 
 * */
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
const long long mod = 1e9 + 7;
#define ar array

ll power(ll x,ll y) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2); 
    if (y%2 == 0) 
        return ((temp%mod)*(temp%mod))%mod; 
    else
        return (((x%mod)*(temp%mod))%mod*(temp%mod))%mod; 
}

int gcd(int x,int y){
	return y==0?x:gcd(y,x%y);
}

bool cmp(pair<int,int>a,pair<int,int>b){
	return a.second<b.second;
}

void solve(){
	ll n; cin>>n;
	ll x1 = power(10,n);
	ll x2 = power(9,n);
	ll x3 = power(8,n);
	ll res = (x1%mod-2*x2%mod+x3%mod)%mod;
	if(res<0) res+=mod;
	cout<<res<<"\n";
	//cout<<(1e3 + 2);
	//ll a = 1e9 +7;
	//cout<<a;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	//int t; cin>>t;
	//while(t--)
		solve();
		
    return 0;
}



Measured memory_bytes: 3616
import java.util.ArrayList;
import java.util.Scanner;

class Main{

	static int N;
	static int M;
	static 		ArrayList<ArrayList<Integer>> map;
	static boolean[] used;
	static int f = 0;
	static int s = 0;

	static long mod = 1000000007;
	static ArrayList<Integer> saitan;




	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);			//文字の入力
		int a = sc.nextInt();
		int b = sc.nextInt();

		int aa = 0;
		int bb = 0;

		switch (a) {
		case 1:
			aa =1;
			break;
		case 3:
			aa =1;
			break;
		case 5:
			aa =1;
			break;
		case 7:
			aa =1;
			break;
		case 8:
			aa =1;
			break;
		case 10:
			aa =1;
			break;
		case 12:
			aa =1;
			break;
		case 2:
			aa =3;
			break;


		default:
			aa = 2;
			break;
		}
		switch (b) {
		case 1:
			bb =1;
			break;
		case 3:
			bb =1;
			break;
		case 5:
			bb =1;
			break;
		case 7:
			bb =1;
			break;
		case 8:
			bb =1;
			break;
		case 10:
			bb =1;
			break;
		case 12:
			bb =1;
			break;
		case 2:
			bb =3;
			break;


		default:
			bb = 2;
			break;
		}

		if(aa == bb){
			System.out.println("Yes");
		}else{
			System.out.println("No");

		}





	}


}




Measured memory_bytes: 21588
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
/*namespace*/
using namespace std;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(x) (x).begin(),(x).end()

int main(){
    int A,B;
    cin>>A>>B;
    if(B%A==0){
        cout<<A+B<<endl;
    }else{
        cout<<B-A<<endl;
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

"""
[考察]
　高橋君が最も遠くに逃げる場合
　:= (高橋君が先に行ける頂点)Λ(青木君から最も遠い頂点)

⇒高橋君が先に行ける頂点
　高橋君からの各頂点の距離(高橋君を根としたときの木の深さ),
　青木君からの各頂点の距離(青木君を根としたときの木の深さ)を求めて、
　高橋君からの距離と青木君からの距離を比較
⇒青木君から最も遠い頂点
　青木君からの各頂点の距離の最大値
"""
n,V,U = LI()
V -= 1
U -= 1

edges = [[] for _ in range(n)]

for _ in range(n-1):
    a,b = LI()
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

if n == 2:
    print(0)
else:
    depth_v = [None]*n
    depth_v[V] = 0
    que = deque()
    que.append(V)
    while que:
        v = que.popleft()
        for u in edges[v]:
            if depth_v[u] == None:
                depth_v[u] = depth_v[v]+1
                que.append(u)
    
    depth_u = [None]*n
    depth_u[U] = 0
    que = deque()
    que.append(U)
    while que:
        u = que.popleft()
        for v in edges[u]:
            if depth_u[v] == None:
                depth_u[v] = depth_u[u] + 1
                que.append(v)
    
    ans = 0
    for v in range(n):
        if depth_v[v] < depth_u[v]:
            ans = max(ans,depth_u[v]-1)
    print(ans)

Measured memory_bytes: 65312
from sys import stdin
##  input functions for me
def ria(sep = ''):
    if sep == '' :
        return list(map(int, input().split())) 
    else: return list(map(int, input().split(sep)))
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##

## main ##

A, B, T = map(int, input().split())
print((T // A )* B)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define fr(i, n) for (i = 0; i < n; i++)
#define rep(i, n) for (i = 1; i <= n; i++)
#define lcm(x, y) ((x) * (y) / __gcd((x), (y)))
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define part cout << "----------------------------------\n";
#include <iostream>

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}; // trick to explore an implicit 2D grid
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; // S,SE,E,NE,N,NW,W,SW neighbors  //GO FOR EVEN FOR 4 moves

#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

LL POW(LL x, LL y)
{
    LL ans = 1;
    LL base = x;
    while (y)
    {
        if (y & 1)
        {
            ans *= base;
        }
        base = base * base;
        y = y >> 1;
    }
    return ans;
}

int main()
{
    fastinput;
    LL n, i, j, k, t, temp, tc;
    cin >> k;
    // LL hcf=__gcd(10LL,k);
    // if(3%hcf!=0)
    // {
    //     cout<<-1<<endl;
    //     return 0;
    // }
    // LL found=-1;
    // for(i=1;;i++)
    // {
    //     if((i*k)%10==3)
    //     {
    //         cout<<i<<endl;
    //         return 0;
    //     }
    // }
    LL now = 1;
    if (k % 7 == 0)
    {
        k /= 7;
    }
    k *= 9;
    for (i = 1; i <= k; i++)
    {
        now *= 10;
        now%=k;
        if(now%k==1)
        {
            cout<<i<<endl;
            return 0;
        }
        
        
    }
    cout << -1 << endl;
    ;

    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define double long double
using namespace std;
typedef vector<double> vec;
typedef vector<vec> mat;
const double EPS=1E-6;

vec gauss_jordan(const mat& A,const vec& b){
  int n=A.size();
  mat B(n,vec(n+1));
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)B[i][j]=A[i][j];
  for(int i=0;i<n;i++)B[i][n]=b[i];
  for(int i=0;i<n;i++){
    int pivot=i;
    for(int j=i;j<n;j++)
      if(abs(B[j][i])>abs(B[pivot][i]))pivot=j;
    swap(B[i],B[pivot]);

    if(abs(B[i][i])<EPS)return vec();

    for(int j=i+1;j<=n;j++)B[i][j]/=B[i][i];
    for(int j=0;j<n;j++){
      if(i!=j)
	for(int k=i+1;k<=n;k++)B[j][k]-=B[j][i]*B[i][k];
    }
  }
  vec x(n);
  for(int i=0;i<n;i++)x[i]=B[i][n];
  return x;
}

int D;
vec calc(int d){
  vec res(D+1);
  for(int i=D,n=1;i>=0;i--,n*=d)res[i]=n;
  return res;
}

double calc(vector<double> A,int d){
  double res=0;
  for(int i=0,n=1;i<(int)A.size();i++,n*=d)res+=A[A.size()-1-i]*n;
  return res;
}


int main(){
  while(cin>>D,D){

    vec f(D+3);
    for(int i=0;i<=D+2;i++)cin>>f[i];
  
    mat A(D+3);
    vector<int> ord(D+3);
    for(int i=0;i<=D+2;i++)A[i] = calc(i),ord[i] = i;

    mat X;    
    vec Y;
    int idx=-1;
    for(int i=0;i<=D+2&&idx==-1;i++){
      for(int j=0;j<=D+2&&idx==-1;j++){
	if(i==j)continue;
	X.clear(),Y.clear();
	for(int k=0;k<=D+2;k++)
	  if(k!=i&&k!=j)X.push_back(A[k]),Y.push_back(f[k]);

	vec ans=gauss_jordan(X,Y);
	if(ans.size()==0)continue;
	int cnt=0;
	for(int k=0;k<=D+2;k++)if(abs(calc(ans,k)-f[k])>1e-5)idx = k,cnt++;
	if(cnt!=1)idx=-1;
      }
    }
    cout<<idx<<endl;
  }
  return 0;
}

Measured memory_bytes: 3204
#include<cstdio>
#define F3(i) for(int i=0;i<3;i++)
const int mod=1000000007;
int N,M;
struct mat{
	int a[3][3];
	mat operator*(const mat&b)const{
		mat c;
		F3(i)F3(j)c.a[i][j]=0;
		F3(i)F3(j)F3(k)c.a[i][k]=(c.a[i][k]+1ll*a[i][j]*b.a[j][k])%mod;
		return c;
	}
}A[33],R;
int b[3],b2[3];
void mul(mat&m){
	F3(i)b2[i]=b[i],b[i]=0;
	F3(i)F3(j)b[i]=(b[i]+1ll*m.a[i][j]*b2[j])%mod;
}
int main(){
	scanf("%d%d",&N,&M);
	*A=(mat){{{1,0,1},{1,1,1},{1,2,2}}};
	R=(mat){{{0,mod-2,mod-1},{1,1,1},{1,2,2}}};
	for(int i=0;i<30;i++)A[i+1]=A[i]*A[i];
	b[0]=1;
	int x=0,y;
	while(M--){
		scanf("%d",&y);
		for(int i=30;i>=0;i--)if(y-x-1>>i&1)mul(A[i]);
		mul(R);
		x=y;
	}
	for(int i=30;i>=0;i--)if(N-x>>i&1)mul(A[i]);
	printf("%d\n",b[2]);
}

Measured memory_bytes: 128
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;

ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
	}
	
	mod& operator=(const ll & tx) {
		x = tx;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return (x + m2.x) % MOD;
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return (x - m2.x + MOD) % MOD;
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return (x * m2.x) % MOD;
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return mod(((*this).x * (*this).inv().x) % MOD);
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}

/* TEMPLATE ENDS HERE */

#define MAXN (1 << 20)

int a[MAXN];

int main() {
	cout << fixed << setprecision(12);	
	int n, k, q;
	cin >> n >> k >> q;	
	for (int i = 0, t; i < q; i++) {
		cin >> t;
		a[t]++;
	}
	for (int i = 1; i <= n; i++) {
		if (k + a[i] - q > 0) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4016
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define	pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigboi        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 


void solve(){
	int n, cnt=0;
	cin>>n;
	int arr[n];
	map<int, int> mp;
	FOR(i, 0, n) cin>>arr[i], mp[arr[i]]++;
	FOR(i, 1, n+1){	
		cnt+=(mp[i]*(mp[i]-1)/2);
	}
	FOR(i, 0, n){
		int k = mp[arr[i]];
		int temp = cnt-(k*(k-1)/2);
		k--;
		k = k*(k-1)/2;
		cout<<temp+k<<endl;
	}
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0); 	
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
	//	cout<<"Case #"<<i<<":"<<endl;
		solve();
	}
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
 
}

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

L = []

for i in range(M):
    LR = list(map(int, input().split()))
    L.append(LR)

res = [L[0][0], L[0][1]]

for i in range(M):
    res = [max(res[0], L[i][0]), min(res[1], L[i][1])]

if res[1] < res[0]:
    print(0)
else: 
    print(res[1] - res[0] + 1)

Measured memory_bytes: 27244
#include "bits/stdc++.h" 
using namespace std; 
 
 
#define ll long long 
#define MAXN   10000005 
  
// stores smallest prime factor for every number 
int spf[MAXN]; 
  

void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
  
// A O(log n) function returning primefactorization 
// by dividing by smallest prime factor at every step 
vector<int> getFactorization(int x) 
{ 
    vector<int> ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 
  

int main(int argc, char const *argv[]) 
{ 
    // precalculating Smallest Prime Factor 
    sieve(); 
    int n;
    cin >> n;
   	ll ans = 0;
    for(int i=1;i<=n;i++)
    {
    	vector<int> p = getFactorization(i); 
    	ll temp = 1;
    	int f = i;
    	for(int x: p)
    	{
    		int cnt = 0;
			while(f%x==0)
    		{
    			f = f/x;
    			cnt++;
			}
			temp = temp*(ll)(cnt+1);
		}
		ans += (ll)i*temp;
	}
	cout << ans;
  
    return 0; 
} 

Measured memory_bytes: 42692
#include <iostream>
#include <algorithm>
#define MAX 1000000
using namespace std;

int N;


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

    int digit = 1;
    N /= K;
    while(N > 0){
      N /= K;
      digit++;
    }

    cout << digit << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX/2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  int N,M;
  cin>>N>>M;
  vector<vector<char> > src(N,vector<char>(N));
  vector<vector<char> > tmp(M,vector<char>(M));

  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      cin>>src[i][j];
    }
    
  }
  
  for (int i = 0; i < M; i++)
  {
    for (int j = 0; j < M; j++)
    {
      cin>>tmp[i][j];
    }
    
  }
  bool ANS = false;
  for (int i = 0; i < N - M + 1; i++)
  {
    for (int j = 0; j < N - M + 1; j++)
    {
      bool match = 1;
      for (int k = 0; k < M; k++)
      {
        for (int l = 0; l < M; l++)
        {
          if(src[i+k][j+l] != tmp[k][l]) match = false;
        }
      }
      if(match == true) ANS = true;
      
    }
    
  }
  
  
  cout<<(ANS?"Yes":"No")<<endl;
  return; 
}


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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

int main() {
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  map<int,int>k;
  for(int i=0;i<N;i++){
    k[a[i]+1]++;
    k[a[i]]++;
    k[a[i]-1]++;
  }
  int MAX=0;
  for(auto c:k){
    if(c.second>MAX){MAX=c.second;}
  }
  cout<<MAX<<endl;
  return 0;  
}

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

using ll = long long;

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

    int n; cin >> n;
    string s; cin >> s;

    int red[n+1] = {}, white[n+1] = {};
    for (int i = 1; i <= n; i++) {
        red[i] = red[i-1] + (s[i-1] == 'R');
        white[i] = white[i-1] + (s[i-1] == 'W');
    }

    char c = s[0];
    int x = 1;
    for (int i = 1; i < n; i++) {
        if (s[i] != c) {
            x = 0;
            break;
        }
    }

    if (x) {
        printf("0\n");
        return 0;
    }

    int ans = INT_MAX;
    for (int i = 1; i < n; i++) {
        int temp = max(white[i], red[n] - red[i]);
        ans = min(ans, temp);
    }
    printf("%d\n", ans);
}


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

int main() {
  int N, sum, n, w;
  sum = 0;
  w = 10000000;
  cin >> N;
  n = N;
  for (; w>=1; w/=10){
    sum += n/w;
    n -= (n/w *w); 
  }
  if (N%sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}



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

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;
const char ENDL = '\n';

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

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int a,b,h;
    cin >> a >> b >>h;
    cout << (a+b)*h/2 << ENDL ;
    
    return 0;
}

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

# 奇数 + 奇数 = 偶数
# 偶数 + 偶数 = 偶数

# 偶数列は最終的に一つになるまで操作可能
# 奇数1余るか余らないかで決まる

evens = list(filter(lambda x: x % 2 == 1, numbers))
evens_mod = len(evens) % 2

if evens_mod == 1:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 14108
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int countOdd = 0;
        for (int i = 1; i <= n; i++) {
            if (i%2 != 0) {
                countOdd++;
            }
        }

        System.out.println((float)countOdd / n);
    }
}

Measured memory_bytes: 23764
X = int(input())
L = list()
i = 0
while True:
    if i ** 5 > 10 ** 11:
        break
    L.append(i ** 5)
    i += 1
flag = False
ret = ''
for i in range(len(L)):
    if flag:
        break
    for j in range(i+1, len(L)):
        if L[j] - L[i] == X :
            ret ='{} {}'.format(j,i)
            flag = True
            break
        if L[j] + L[i] == X :
            ret ='{} {}'.format(j,-i)
            flag = True
            break
print(ret)

Measured memory_bytes: 9208
N = int(input())
H = [int(a) for a in input().split(" ")]
ans=0
while any([h!=0 for h in H]):
    i=0
    while i<N and H[i]==0:
        i+=1
    j=i
    minh=H[i]
    while j<N and H[j]!=0:
        minh = min(H[j], minh)
        j+=1
    for k in range(i,j):
        H[k]-=minh
    ans+=minh
print(ans)

Measured memory_bytes: 39408
#pragma GCC target("avx2")
#pragma GCC optimize("O3")

# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e3 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
int pref[N];
int a[N];



int main () {
   SpeedForce;
	cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		//cout << "pff :" << ans << '\n';
		for (int j = 1; j < i; j ++) {
			int r = a[i] + a[j] - 1;
			if (r > 1e3) r = 1e3;
			int l = abs(a[i] - a[j]) + 1;
			if (l > r) continue;
			ans += pref[r] - pref[l - 1];
			if (a[j] >= l) ans--;
		}
		//cout << "wooo : " << ans << '\n';

		cnt[a[i]] ++;
		for (int j = 1; j <= 1e3; j ++)
			pref[j] = pref[j - 1] + cnt[j];

	}
	cout << ans / 2 << '\n';
   return Accepted;
}

// B...a

Measured memory_bytes: 256
N=int(input())
S=str(input())

l_S=list(S)

count=0
for i in range(0,1000):
    i_1=int(i/100)
    i_2=int(i/10)-i_1*10
    i_3=i%10
    if str(i_1) in l_S[:-2]:
        idx_1=l_S[:-2].index(str(i_1))
        if str(i_2) in l_S[idx_1+1:-1]:
            idx_2=l_S[idx_1+1:-1].index(str(i_2))+idx_1+1
            if str(i_3) in l_S[idx_2+1:]:
                count+=1
print(count)

Measured memory_bytes: 3600
import numpy as np
from math import ceil,log2
N = int(input())
a = np.array(list(map(int,input().split())),dtype=np.int64)
ans = 0
count = 1
if max(a) == 0:
    x = 1
else:
    x = ceil(log2(max(a)))

for i in range(x):
    b = a%2
    s = np.count_nonzero(b==1)*np.count_nonzero(b==0)*count
    ans +=s
    count *= 2
    a = a//2
    ans %= 10**9+7
print(ans)


Measured memory_bytes: 49948
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};
const int mod = 1000000007;
#define Yes(ifeq) cout<<(( ifeq )? "Yes":"No")<<endl;

void Main(){
  ll k,n;
  cin>>k>>n;
  vl a(n);
  cin>>a;

  vl b(n);
  rep(i,n-1){
    b[i] = a[i+1]-a[i];
  }
  b[n-1] = a[0] + (k-a[n-1]);

  ll ans = k- *max_element( rng(b) );
  cout<<ans<<endl;
} signed main(int argc,char** argv)
{fastio; myio; myloopset Main();}


Measured memory_bytes: 3456
import math
import functools
n, k = map(int, input().split())
a = list(map(int, input().split()))
a_max = max(a)
G = functools.reduce(math.gcd, a)
ok = True
if k > a_max:
    ok = False
else:
    if k%G == 0:
        pass
    else:
        ok = False

if ok:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


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

using namespace std;

int main() {
  int M, D;
  cin >> M >> D;
  int cnt = 0;
  for (int m = 1; m <= M; ++m) {
    for (int d = 1; d <= D; ++d) {
      int d1 = d % 10;
      int d2 = d / 10;
      if (d1 >= 2 && d2 >= 2 && d1 * d2 == m) ++cnt;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int l,r,d;cin>>l>>r>>d;
  int res=0;
  for(int i=l;i<=r;++i){
    if(i%d==0)++res;
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int A,B;
    cin >> A >> B;

    for(int i=0;i<max(A,B);i++){
        if(abs(A-i)==abs(B-i)){
            cout << i << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 256
local MOD=998244353
local function add(a,b)return (a+b)%MOD end
local function sub(a,b)return a>b and a-b or a-b+MOD end
local function mul(a,b)local a1,b1=a%31596,b%31596 local a2,b2=(a-a1)/31596,(b-b1)/31596 return (62863*a2*b2+31596*(a1*b2+a2*b1)+a1*b1)%MOD end
local function pow(a,b)local ret=1 while(b>0)do if(b%2==1)then ret=mul(ret,a)b=b-1 end a=mul(a,a)b=b*.5 end return ret end
local function inv(x)local a,b,u,v=x,MOD,1,0 repeat local t=math.floor(a/b)a,b=b,a-t*b u,v=v,u-t*v until(b==0)return u%MOD end
local function div(a,b)return mul(a,inv(b))end

N=io.read"*n"
M=io.read"*n"
K=io.read"*n"

ret=0
c=1
for i=0,K do
	ret=add(ret, mul(c, mul(M, pow(M-1, N-i-1))))
	c=div(mul(c,N-i-1),i+1)
end
print(ret)

Measured memory_bytes: 2772