akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream> 
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;

#define assert_range(x,a,b) assert((a) <= (x) and (x) <= (b))
using ll = long long;
const int INF = 1e9;

const int N = 300;
double dp[N+2][N+2][N+2];
bool visited[N+2][N+2][N+2];

double solve(int n, int a, int b, int c) {
    if (a == 0 and b == 0 and c == 0) return 0;
    if (visited[a][b][c]) return dp[a][b][c];
    double res = 0;
    if (a > 0) {
        res += a/(double)n * (1+solve(n, a-1, b, c));
    }
    if (b > 0) {
        res += b/(double)n * (1+solve(n, a+1, b-1, c));
    }
    if (c > 0) {
        res += c/(double)n * (1+solve(n, a, b+1, c-1));
    }
    res += (n-a-b-c) / (double)n;
    res /= (1 - (n-a-b-c)/(double)n);
    dp[a][b][c] = res;
    visited[a][b][c] = true;
    return res;
}

int main() {
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> cnt(3);
    for (int i = 0; i < n; ++i) {
        int value;
        cin >> value;
        cnt[value-1]++;
    }
    auto res = solve(n, cnt[0], cnt[1], cnt[2]);
    cout.precision(12);
    cout << fixed << res << endl;

    return 0;
}


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

int main () {
  vector<int> a(3);
  for (int i=0;i<3;++i) cin >> a[i];
  
  sort(a.begin(),a.end());

  if (a[0]+a[1]==a[2]) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,s,n;
    cin>>n;

    s=n%10;
    n=n/10;
    d=s;

    s=n%10;
    n=n/10;
    c=s;
    s=n%10;
    n=n/10;
    b=s;

    s=n%10;
    n=n/10;
    a=s;



//    s=a+b+c+d;
    s=a+b+c+d;
if(s==7)
    {
        cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
        return 0;
    }
    s=a-b-c-d;
    if(s==7)
    {
        cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
        return 0;
    }

    s=a-b+c+d;
    if(s==7)
    {
        cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
        return 0;
    }
    s=a+b-c+d;
    if(s==7)
    {
        cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
        return 0;
    }
    s=a+b+c-d;
    if(s==7)
    { cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
        return 0;
    }
    s=a-b-c+d;
    if(s==7)
    {
        cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
        return 0;
    }
    s=a+b-c-d;
    if(s==7)
    {
        cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
        return 0;
    }
    s=a-b+c-d;
    if(s==7)
    {
        cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
        return 0;
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int main() {

	int N;
	cin >> N;

	ll ret = 1;

	rep(i, N){
		ret *= (i+1);
		ret %= 1000000007;
	}

	cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define MOD 1000000007
typedef long long ll;
 
string A,B,C;
 
void reverse(){
    reverse(A.begin(),A.end());
    reverse(B.begin(),B.end());
    reverse(C.begin(),C.end());
}
 
int main(){
    while(cin >> A, A != "0"){
	cin >> B >> C;
	reverse();
	int size = A.size();
	ll dp[51][2];
	memset(dp,0,sizeof(dp));
	dp[0][0] = 1;
	for(int p = 0 ; p < size ; p++){
	    for(int i = 0 ; i < 10 ; i++){
		if(A[p] != '?' && (A[p]-'0') != i){
		    continue;
		}
		if(p == size-1 && i == 0) continue;
		for(int j = 0 ; j < 10 ; j++){
		    if(B[p] != '?' && (B[p]-'0') != j){
			continue;
		    }
		    if(p == size-1 && j == 0) continue;
		    for(int k = 0 ; k < 2 ; k++){
			int l = (i + j + k) % 10;
			int nk = (i + j + k >= 10);
			if(C[p] != '?' && (C[p]-'0') != l){
			    continue;
			}
			dp[p+1][nk] += dp[p][k];
			dp[p+1][nk] %= MOD;
		    }
		}
	    }
	}
	cout << dp[size][0] << endl;
    }
    return 0;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n;
// string s;

int main() {
    cin >> n;

    Vi a(n);
    REP(i, n) cin >> a[i];

    ll res = 1;
    VVi list(n+1, Vi(3, 0));
    REP2(i, 1, n+1) {
        int x = a[i-1];
        int c = 0;
        for (auto y: list[i-1]) {
            c += x == y ? 1 : 0;
        }
        res = res * c % MOD;
        bool f = true;
        REP(j, 3) {
            if (f && list[i-1][j] == x) {
                list[i][j] = x+1;
                f = false;
            }
            else list[i][j] = list[i-1][j];
        }
    }
    std::cout << res << '\n';

    return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
int N,Q,K;
vector<pair<int,int>> G[111111];
long long dist[111111];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>N;N--;
    while(N--){
        int x,y,c;
        cin>>x>>y>>c;
        G[x].push_back({y,c});
        G[y].push_back({x,c});
    }
    cin>>Q>>K;
    queue<int>q;
    q.push(K);
    while(!q.empty()){
        auto qf = q.front();
        for(auto &p:G[qf]){
            if(dist[p.first]==0&&p.first!=K){
                dist[p.first]=dist[qf]+p.second;
                q.push(p.first);
            }
        }
        q.pop();
    }
    while(Q--){
        int x,y;
        cin>>x>>y;
        cout<<dist[x]+dist[y]<<'\n';
    }
    return 0;
}


Measured memory_bytes: 9076
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main(){
    int rad, n;
    while(cin >> rad >> n, rad+n){
        int height[40] = {};
        for(int i = 0; i < n; i++){
            int xl, xr, h;
            cin >> xl >> xr >> h;
            for(int j = xl; j < xr; j++){
                height[20+j] = max(height[20+j], h);
            }
        }
        double l = 0.0, r = 21;
        for(int i = 0; i < 100; i++){
            double mid = (l+r)/2;
            bool safe = true;
            for(int j = -rad; j < rad; j++){
                safe &= height[20+j] >= mid-rad+sqrt(pow(rad,2.0)-pow(min(fabs(j),fabs(j+1)),2.0));
            }
            if(!safe)   r = mid;
            else        l = mid;
        }
        cout << fixed << setprecision(12) << l << endl;
    }
    return 0;
}


Measured memory_bytes: 3180
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-06-08 13:47:03
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , ans;
string s;

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

    cin >> s; n = SZ(s);
    for(int i = 0 ; i < (1 << n - 1) ; i++){
        ll cur = 0;
        for(int j = 0 ; j < n ; j++){
            if(j != 0 && (i & (1 << j - 1))){
                ans += cur; cur = 0;
            }
            cur = cur * 10 + s[j] - 48;
        }
        ans += cur;
    }
    cout << ans << endl;

    return 0;
}
/*

*/


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

using namespace std;
using ll = long long;

struct Intmod {
    int mod;
    ll a;
    Intmod(int mod, ll a = 0): a(((a % mod) + mod) % mod), mod(mod) {}

    Intmod operator-() const {return Intmod(mod, -a);}

    Intmod& operator=(const ll b) {
        a = ((b % mod) + mod) % mod;
        return *this;
    }
    Intmod& operator+=(const Intmod b) {
        if((a += b.a) >= mod) a -= mod;
        return *this;
    }
    Intmod& operator+=(const ll b) {
        if((a += b) >= Intmod(mod, b).a) a -= mod;
        return *this;
    }
    Intmod& operator-=(const Intmod b) {
        if((a -= b.a) < 0) a += mod;
        return *this;
    }
    Intmod& operator-=(const ll b) {
        if((a -= Intmod(mod, b).a) < 0) a += mod;
        return *this;
    }
    Intmod& operator*=(const Intmod b) {
        (a *= b.a) %= mod;
        return *this;
    }
    Intmod& operator*=(const ll b) {
        (a *= Intmod(mod, b).a) %= mod;
        return *this;
    }

    template<typename T> Intmod operator+(const T b) const {return Intmod(*this) += b;}
    template<typename T> Intmod operator-(const T b) const {return Intmod(*this) -= b;}
    template<typename T> Intmod operator*(const T b) const {return Intmod(*this) *= b;}

    // Valid for prime mod. pown() needs to be included.
    // int i = 0;
    // Intmod inv() {
    //     if(a == 0) throw "Inverse of zero does not exist.";
    //     if(!i) i = pown(*this, mod - 2).a;
    //     return Intmod(mod, i);
    // }
    // Intmod& operator/=(const Intmod b) {return *this *= b.inv();}
    // Intmod& operator/=(const ll b) {return *this *= Intmod(mod, b).inv();}
    // template<typename T> Intmod operator/(const T b) const {return Intmod(*this) /= b;}
};
Intmod operator+(const ll b, Intmod a) {return a += b;}
Intmod operator-(const ll b, Intmod a) {return a -= b;}
Intmod operator*(const ll b, Intmod a) {return a *= b;}
// Intmod operator/(const ll b, Intmod a) {return a /= b;} //Valid for prime mod.

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

    int n;
    string x;
    cin >> n >> x;
    vector<bool> xb(n);
    int popcnt = 0;
    for(int i = 0; i < n; ++i)
        if(xb[n - 1 - i] = x[i] - '0') popcnt++;

    int ans, div;

    vector<Intmod> bimodp(n, Intmod(popcnt + 1)), bimodm;
    bimodp[0] = 1;
    for(int i = 0; i < n - 1; ++i) bimodp[i + 1] = bimodp[i] * 2;
    Intmod xp(popcnt + 1), xm(1);
    for(int i = 0; i < n; ++i) xp += bimodp[i] * xb[i];

    if(popcnt >= 2) {
        bimodm = vector<Intmod>(n, Intmod(popcnt - 1));
        bimodm[0] = 1;
        for(int i = 0; i < n - 1; ++i) bimodm[i + 1] = bimodm[i] * 2;
        xm = Intmod(popcnt - 1);
        for(int i = 0; i < n; ++i) xm += bimodm[i] * xb[i];
    }

    for(int i = n - 1; i >= 0; --i) {
        if(popcnt == 1 && xb[i]) {
            printf("0\n");
            continue;
        }
        ans = 1;
        if(xb[i]) div = (xm - bimodm[i]).a;
        else div = (xp + bimodp[i]).a;

        while(div) {
            ans++;
            div %= __builtin_popcount(div);
        }
        printf("%d\n", ans);
    }

    return 0;
}

Measured memory_bytes: 9968
#include<iostream>

int main(){
  int a[4];
  int b[4];
  int i,j,hit,blow;

  while(std::cin >> a[0]){
    std::cin >> a[1] >> a[2] >> a[3]
             >> b[0] >> b[1] >> b[2] >> b[3];
    hit = 0;
    blow = 0;
    for(i=0;i<4;i++){
      if(a[i]==b[i]){
        ++hit;
      }
      for(j=0;j<4;j++){
        if(i!=j){
          if(a[i]==b[j]){
            ++blow;
          }
        }
      }
    }
    std::cout << hit << ' ' << blow << std::endl;
  }
}

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

 int main (){
   int A, B, C, D;
   cin >> A >> B >> C >> D;

   if (A+B > C+D)
     cout << "Left" << endl;
   else if (A+B < C+D)
     cout << "Right" << endl;
   else 
     cout << "Balanced" << endl;
}


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

pair<int, int> field[128][128];
int v[128][128];

int dfs(int x, int y, int now){
    while(v[y][x] == 0){
        v[y][x] = now;
        int nx = field[y][x].first; int ny = field[y][x].second;
        x = nx; y = ny;
    }
    if(v[y][x] == now) return 1;
    return 0;
}

int main(){
    int n;
    while(cin >> n, n){
        memset(v, 0, sizeof(v));
        for(int i=0; i < n; i++){
            for(int j=0; j < n; j++){
                int x, y;
                cin >> x >> y;
                field[i][j].first = x; field[i][j].second = y;
            }
        }

        int ans = 0, now = 1;
        for(int i=0; i < n; i++){
            for(int j=0; j < n; j++){
                if(v[i][j] == 0){
                    ans += dfs(j, i, now);
                    now++;
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1360
#include <stdio.h>

int main()
{
    int R = 0;
    scanf("%d",&R);
    if(R < 1200)
    {
        printf("ABC");
    }else if(R < 2800)
    {
        printf("ARC");
    }else
    {
        printf("AGC");   
    }
    return 0;

}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

const static int LEN=20;
int n,a[LEN];
int q,k;

bool dfs(int i,int sum)
{
    if(i==n) return sum==k;
    if(dfs(i+1,sum)) return true;
    if(dfs(i+1,sum+a[i])) return true;
    return false;
}

int main()
{
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    cin>>q;
    while(q--){
        cin>>k;
        if(dfs(0,0)) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3080
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main()
	{
		int N = GetInt();
		int M = GetInt();
		int[] L = new int[M];
		int[] R = new int[M];
		long[] D = new long[M];
		for(int i = 0; i < M; i++)
		{
			L[i] = GetInt();
			R[i] = GetInt();
			D[i] = GetLong();
		}

		UnionFind uf = new UnionFind(N+1);
		for(int i = 0; i < M; i++)
		{
			if(uf.IsSame(L[i], R[i]))
			{
				long d = uf.Diff(L[i], R[i]);
				if(d != D[i])
				{
					Console.WriteLine("No");
					return;
				}
			}
			else
				uf.Merge(L[i], R[i], D[i]);
		}
		Console.WriteLine("Yes");
	}
}


// https://qiita.com/drken/items/cce6fc5c579051e64fab (2019/05/26)
public class UnionFind
{
	private int[] par = null;
	private int[] rank = null;
	private long[] diffWeight = null;
	
	public UnionFind(int n)
	{
		par = new int[n];
		rank = new int[n];
		diffWeight = new long[n];
		for(int i = 0; i < n; i++)
		{
			par[i] = i;
			rank[i] = 0;
			diffWeight[i] = 0;
		}
	}

	public bool IsSame(int x, int y)
	{
		return (root(x) == root(y));
	}

	private int root(int x)
	{
		if(par[x] == x)
			return x;

		int r = root(par[x]);
		diffWeight[x] += diffWeight[par[x]];
		par[x] = r;
		return r;
	}
	
	public bool Merge(int x, int y, long w)
	{
		long wp = w + weight(x) - weight(y);
		int rx = root(x);
		int ry = root(y);
		if(rx == ry)
			return false;
		
		if(rank[rx] < rank[ry])
		{
			int tmp = rx;
			rx = ry;
			ry = tmp;
			wp = -wp;
		}
		else if(rank[rx] == rank[ry])
			rank[rx]++;

		par[ry] = rx;
		diffWeight[ry] = wp;
		return true;
	}

	public long Diff(int x, int y)
	{
		return weight(y) - weight(x);
	}

	private long weight(int x)
	{
		root(x);
		return diffWeight[x];
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

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

int main(){
	int n;
	scanf("%d", &n);
	vector<int> p(n + 9);
	for(int i = 0; i < n; ++i){
		scanf("%d", &p[i]);
	}

	vector<char> visit(n + 9);
	queue<int> q;
	q.push(0);
	q.push(-1);
	visit[0] = 1;
	int ans = 1;
	while(1){
		if(q.front() == -1){
			q.push(-1);
			++ans;
		}
		else{
			for(int j = 1; j <= 6; ++j){
				int x = q.front() + j;
				while(!visit[x] && p[x] != 0){
					visit[x] = 1;
					x += p[x];
				}
				
				if(x >= n - 1){
					printf("%d\n", ans);
					return 0;
				}
				if(!visit[x]){
					visit[x] = 1;
					q.push(x);
				}
			}
		}
		q.pop();
	}
}

Measured memory_bytes: 1536
import bisect
import sys
sys.setrecursionlimit(10**9)

def main():
    N,K = map(int,input().split())
    MOD = 10**9+7

    def between(n,k,i):
        if i == 1:
            return 1
        return comb(k-1,i-1,MOD)

    def comb(n, r, mod):
        r = min(r, n-r)
        res = 1
        for i in range(r):
            res = res * (n - i) * pow(i+1, mod-2, mod) % mod
        return res

    for i in range(1,K+1):
        if i > K or i > N-K+1:
            print(0)
        else:
            ans = comb(N-K+1,i,MOD) * between(N,K,i)
            ans %= MOD
            print(ans)



if __name__ == "__main__":
  main()

Measured memory_bytes: 43356
import math
n = int(input())
s = 0
if math.sqrt(n) == int(math.sqrt(n)):
  lim = int(math.sqrt(n))
else:
  lim = int(math.sqrt(n))+1
for i in range(1,lim):
  x = n-i
  if x%i == 0 and x//i > i:
    s += x//i
print(s)


Measured memory_bytes: 9124
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
  int alphabet[26]={0};
  string str;
  cin >> str;
  for(int i=0;i<str.length();++i){
    alphabet[str[i]-'a']++;
    if(alphabet[str[i]-'a']>=2){
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{
  string s;
  cin>>s;
  if(s=="Sunny")cout<<"Cloudy"<<endl;
  if(s=="Cloudy")cout<<"Rainy"<<endl;
  if(s=="Rainy")cout<<"Sunny"<<endl;
}

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

using namespace std;

int main() {
	int N, L; cin >> N >> L;
	
	auto S = vector<string>(N);
	for (auto &s: S) {
		cin >> s;
	}

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

	string smallest;
	for (auto &s : S) {
		smallest += s;
	}

	cout << smallest << endl;
}

Measured memory_bytes: 256
N=int(input())
X=[int(i) for i in input().split()]
x=X.copy()
x.sort()
mina=x[N//2-1]
minb=x[N//2]
for i in range(N):
  if mina<X[i]:
    print(mina)
  else :
    print(minb)
  

Measured memory_bytes: 26016
#include<bits/stdc++.h>
using namespace std;
#define int long long

const int mx = 2e5 + 5;

vector<pair<int , int> > adj[mx];
bool vis[mx];
int dis[mx];

void dfs(int src){
vis[src] = 1;
for(auto u : adj[src]){
    if(vis[u.first] == 0){
       dis[u.first] = (dis[src] + u.second);
       dfs(u.first);
    }
}
}

main(){
int n;
cin>>n;
for(int i=1 ; i<n ; i++){
    int u , v , w;
    cin>>u>>v>>w;
    adj[u].push_back({v , w});
    adj[v].push_back({u , w});
}

dfs(1);

for(int i=1 ; i<=n ; i++){
    cout<<dis[i]%2<<endl;
}
}


Measured memory_bytes: 15664
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    string st;
    cin>>st;
    sort(all(st));
    if(st=="abc"){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		int[] p = new int[n];
		for(int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
		}
		int min= Integer.MAX_VALUE;
		for(int i = 0; i < n; i++) {
			if(p[i] < min) {
				count++;
				min = p[i];
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 64412
#include <iostream>
#include <string>
using namespace std;
int board[255][255],dx[] = {-1,0,1,-1,1,-1,0,1},dy[] = {-1,-1,-1,0,0,1,1,1};
int main(){
    int n,tx,ty,cnt,max;
    string str;
    while(cin >> n,n){
        max = 0;
        for(int i = 0;i < n;++i){
            cin >> str;
            for(int j = 0;j < str.size();++j){
                board[i][j] = (int)(str[j] - '0');
            }
        }
        for(int i = 0;i < n;++i){
            for(int j = 0;j < n;++j){
                if(board[i][j] == 1){
                    for(int k = 0;k < 8;++k){
                        cnt = 1;
                        tx = j + dx[k];
                        ty = i + dy[k];
                        while(0 <= tx && 0 <= ty && tx < n && ty < n && board[ty][tx] == 1){
                            ++cnt;
                            tx += dx[k];
                            ty += dy[k];
                        }
                        if(cnt > max) max = cnt;
                    }
                }
            }
        }
        cout << max << endl;
    }
    return 0;
}

Measured memory_bytes: 1456
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int t, x, y, tt, xx, yy, flag = 1, a;
  cin >> t >> x >> y;
  for(int i = 0; i < N; i++) {
    cin >> tt >> xx >> yy;
    a = abs(t - tt) - abs(x - xx) - abs(y - yy);
    if (a % 2 == 1 || a < 0) {
      flag = 0;
      break;
    }
    t = tt;
    x = xx;
    y = yy;
  }
  if (flag == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
N,K,Q = map(int,input().split())
A = []
L = []
for i in range(N):
    A.append(K - Q)
for i in range(Q):
    L.append(int(input()))
for i in range(Q):
    j = L[i]
    A[j - 1] += 1

for i in range(N):
    if A[i] <= 0:
        print('No')
    else:
        print('Yes')

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


bool isPrime(int n) {
	if (n <= 1) {
		return false;
	}

	// Check from 2 to n-1
	for (int i = 2; i < n; i++) {
		if (n % i == 0) {
			return false;
		}
	}

	return true;
}
int main()
{
	// string S, T;
	// cin >> S >> T;
	// cout << T << S << endl;

	// long long A, B, K;
	// cin >> A >> B >> K;

	// for (long long i = 0; i < K; i++) {
	// 	if (A >= 1) {
	// 		A -= 1;
	// 	} else if (B >= 1) {
	// 		B -= 1;
	// 	} else {
	// 		break;
	// 	}
	// }
	// long long ans_A, ans_B;
	// if (A <= K) {
	// 	ans_A = 0;
	// 	if (B <= K - A) {
	// 		ans_B = 0;
	// 	} else {
	// 		ans_B = B - (K - A);
	// 	}
	// } else {
	// 	ans_A = A - K;
	// }
	// cout << ans_A << " " << ans_B << endl;
	int X;
	cin >> X;

	while (true) {
		if (isPrime(X)) {
			break;
		}
		X++;
	}
	cout << X << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define fi first
#define se second
//#define mp make_pair
#define pb push_back
typedef pair<int,int> P;
#define REP(i,x,y) for(int i=x;i<=y;i++)
#define abs(x) ((x)>0?(x):-(x))
const int maxn = 100205, inf = 0x3f3f3f3f;
int a,b;
int main(){
	cin>>a>>b;
	if(a+b==15) puts("+");
	else if(a*b==15) puts("*");
	else puts("x");
	return 0;
}

Measured memory_bytes: 256
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        a: usize,
        b: usize,
    }
    let mut ans = 0;
    if a <= 3 {
        ans += 100_000 * (4 - a);
    }
    if b <= 3 {
        ans += 100_000 * (4 - b);
    }
    if a == b && a == 1 {
        ans += 400_000;
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        
        String s1 = sc.next();
        String s2 = sc.next();
        String s3 = sc.next();
        s1 = s1.toUpperCase();
        s2 = s2.toUpperCase();
        s3 = s3.toUpperCase();
        
        
        System.out.println(("" +s1.charAt(0) + s2.charAt(0) + s3.charAt(0)).toUpperCase());
	}
 
}

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

long long gcd(long long m, long long n)
{
    long long temp;
    while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

long long func(long long C, long long D)
{
    return C * D / gcd(C, D);
}

int main()
{
    long long A, B, C, D;
    cin >> A >> B >> C >> D;

    long long CD = func(C, D);
    long long count_div_C   = ( B / C ) - ( (A - 1) / C );
    long long count_div_D   = ( B / D ) - ( (A - 1) / D );
    long long count_div_CD  = ( B / CD ) - ( (A - 1) / CD );
    long long count_all = B - A + 1;

    long long count = count_all - (count_div_C + count_div_D - count_div_CD);

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 101

void dfs(int);

//グローバル変数の初期値は0
int G[MAX][MAX];
int d[MAX], f[MAX];
int n, time = 0;

int main(){
    int u, k, v;

    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        scanf("%d%d", &u, &k);
        for(int j = 0; j < k;j++){
            scanf("%d", &v);
            //頂点uに隣接する点にチェックを入れる
            G[u][v] = 1;
        }
    }

    for(int i = 1; i <= n; i++){
        //まだ一度も発見されてない時だけ
        if(d[i] == 0)dfs(i);
    }

    for(int i = 1; i <= n; i++){
        printf("%d %d %d\n", i, d[i], f[i]);
    }

    return 0;
}

void dfs(int i){
    d[i] = ++time;

    for(int j = 1; j <= n; j++){
        //終了値が0でない時つまり、これ以上進めない時再帰せずに終了できる
        //頂点Gに点が隣接する時かつその点がまだ未発見の時再帰
        if(G[i][j] != 0 && d[j] == 0)dfs(j);
    }

    //終了前に1増える
    time += 1;
    f[i] = time;
}





Measured memory_bytes: 2112
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
int n,a[100010][3],dp[100010][3];
int main(){
	n=gi();
	for(int i=1;i<=n;i++)
		a[i][0]=gi(),a[i][1]=gi(),a[i][2]=gi();
	dp[1][0]=a[1][0];dp[1][1]=a[1][1];dp[1][2]=a[1][2];
	for(int i=2;i<=n;i++)
		for(int j=0;j<3;j++)
			for(int k=0;k<3;k++)
				if(j!=k)
					dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
	printf("%d\n",max(max(dp[n][0],dp[n][1]),dp[n][2]));
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97 '0'=0x30=48
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef string str;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  int a,b,c,x,ans;
  cin>>a>>b>>c>>x;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        ans+=(x==i*500+j*100+k*50);
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
# D - Five, Five Everywhere

# 条件を満たす5つの素数をランダムにピック→条件を満たす素数を追加して55個揃える、とすると解の1つが見つかる

N = int(input())

a = [
    12959,
    14347,
    15511,
    51749,
    23819,
    26849,
    6089,
    27779,
    23339,
    13859,
    26699,
    18719,
    15149,
    5279,
    27689,
    10079,
    18089,
    15629,
    10139,
    51419,
    46889,
    41579,
    5519,
    29429,
    29879,
    1259,
    3929,
    13799,
    27179,
    3449,
    4409,
    32609,
    21269,
    44729,
    52769,
    10499,
    39209,
    42899,
    269,
    13709,
    509,
    3779,
    22619,
    15749,
    4349,
    51479,
    14879,
    39659,
    48449,
    3299,
    8849,
    40499,
    46829,
    45869,
    8039
]

print(*a[:N])

# import itertools, random, copy

# # n以下の全ての素数のセットを返す関数
# def prime_set(n):
#     primes = set(range(2, n+1))
#     for i in range(2, int(n**0.5) + 1):
#         primes.difference_update(range(i*2, n+1, i))
#     return primes

# p_set = prime_set(55555)
# p2_set = prime_set(55555*5)

# while 1:
#     while 1:
#         tmp = random.sample(p_set, 5)
#         if sum(tmp) not in p2_set:
#             a = tmp
#             break

#     p_new_set = p_set.copy()
#     p_new_set.difference_update(set(a))

#     while len(a) < N:
#         if p_new_set:
#             tmp = random.sample(p_new_set, 1)
#             p_new_set.difference_update(set(tmp))
#             tmp = tmp[0]
#         else:
#             break

#         for four_list in list(itertools.combinations(a, 4)):
#             if sum(four_list) + tmp in p2_set:
#                 break
#         else:
#             a.append(tmp)
#             print(a)

#     if len(a) == N:
#         for five_list in list(itertools.combinations(a, 5)):
#             if sum(five_list) in p2_set:
#                 print("check NG")
#                 break
#         else:
#             print("check OK")
#             for x in a:
#                 print(x, ",", sep="")
#             exit()

Measured memory_bytes: 3064
//32
#include<iostream>
#include<stack>
#include<utility>
#include<algorithm>

using namespace std;

int main(){
  for(int h,w;cin>>h>>w,h|w;){
    char g[500][501];
    for(int y=0;y<h;y++){
      cin>>g[y];
    }
    int m=0;
    int a[501]={};
    for(int y=0;y<h;y++){
      stack<pair<int,int> > s;
      for(int x=0;x<w+1;x++){
	a[x]=(g[y][x]=='.')?a[x]+1:0;
	int l=x;
	while(!s.empty()&&a[x]<s.top().first){
	  m=max(m,s.top().first*(x-s.top().second));
	  l=s.top().second;
	  s.pop();
	}
	s.push(make_pair(a[x],l));
      }
    }
    cout<<m<<endl;
  }
  return 0;
}

Measured memory_bytes: 1448
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
template <class T1, class T2> void print(std::map<T1, T2> &v) {
    for (auto &&i : v) {
        std::cout << i.first << " " << i.second << '\n';
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

// 素因数を数列で返す。ソートされている。
// first が素因数で second が個数
template <class T> map<T, long long> factring(T N) {
    map<T, long long> ans;
    long long i = 2;
    while (i * i <= N) {
        if (N % i == 0) {
            ans[i]++;
            N /= i;
        } else {
            i++;
        }
    }
    if (N != 1)
        ans[N]++;
    return ans;
};

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

    ll A, B;
    scan(A, B);

    auto a = factring(A);
    auto b = factring(B);
    map<ll, ll> v;
    for (auto &&i : a) {
        auto key = i.first;
        if (b.count(key)) {
            v[key] = min(a[key], b[key]);
        }
    }

    print(v.size() + 1);

    return 0;
}

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

using ll = long long;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(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 pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int x; std::cin >> x;
    x -= 400;
    std::cout << 8-(x / 200) << "\n";
}


Measured memory_bytes: 3596
#include<stdio.h>
#include<math.h>

#define PI 3.141592653589793

int main(){
	int d,a,Ax,Ay;
	double x,y,degree;
	x=y=degree=0.0;
	while(scanf("%d,%d",&d,&a)){
		if(d==0&&a==0) break;
		x+=(double)d*sin(degree*PI/180.0);
		y+=(double)d*cos(degree*PI/180.);
		degree+=(double)a;
	}
	Ax=(int)x;
	Ay=(int)y;
	printf("%d\n%d\n",Ax,Ay);
	return 0;
}

Measured memory_bytes: 604
////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / my::gcd(a, b); }
vector<pair<ll, ll>> primeFac(ll n) {
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////

int main() {
  int n;
  cin >> n;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }

  ll kane = 1000;
  ll kabu = 0;
  bool isKai = true;  // true:kai,false:uri
  bool isSaigo = false;
  int now = 0;

  while (!isSaigo) {
    if (isKai) {  // kai
      while (a.at(now) >= a.at(now + 1)) {
        now++;
        if (now == n - 1) {
          isSaigo = true;
          break;
        }
      }
      if (isSaigo) break;
      kabu = kane / a.at(now);
      kane %= a.at(now);
      isKai = false;

    } else {  // uri
      while (a.at(now) <= a.at(now + 1)) {
        now++;
        if (now == n - 1) {
          kane += kabu * a.at(now);
          kabu = 0;
          isSaigo = true;
          break;
        }
      }
      if (isSaigo) break;
      kane += kabu * a.at(now);
      kabu = 0;
      isKai = true;
    }
  }

  cout << kane << endl;
}

Measured memory_bytes: 3588
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc146_a.cpp
 * time   : Sat May  2 18:31:22 2020
 * quest  : A - Can't wait for Holiday
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  if (s == "SUN") cout << "7\n";
  else if (s == "MON") cout << "6\n";
  else if (s == "TUE") cout << "5\n";
  else if (s == "WED") cout << "4\n";
  else if (s == "THU") cout << "3\n";
  else if (s == "FRI") cout << "2\n";
  else cout << "1\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    string s;
    cin >> s;
    int a = 0;
    for (char c : s) a += c == '1';
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=2e5;
const lli INF=1e18;

int main(){
	lli N,T;
	cin>>N>>T;
	lli t[MAX+1];
	rep(i,N) cin>>t[i];
	t[N]=INF;
	
	lli ans=0;
	rep(i,N) ans+=min(t[i+1]-t[i],T);
	cout<<ans;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0); 
	cin.tie(0); 
	cout.tie(0);
	long long n,x,sum=0;
	cin>>n;
	map<long long, long long> b,c;
	for(long long i=0;i<n;i++)	
	{
		cin>>x;
		b.insert(make_pair(x+i,0));
		b.insert(make_pair(i-x,0));
		sum+=b[x+i]+c[i-x];
		b[i-x]++;
		c[x+i]++;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 49144
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    int p = 700;
    for (String ss: s.split("")) {
      if (ss.equals("o")) p += 100;
    }
    System.out.println(p);
  }
}


Measured memory_bytes: 21844
#include <stdio.h>

int main(void){
  int i, j, k;
  int n, b, f, r, v, house[4][3][10];

  /* ????????? */
  for(i = 0; i < 4; i++){
    for(j = 0; j < 3; j++){
      for(k = 0; k < 10; k++){
	house[i][j][k] = 0;
      }
    }
  }
  
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d%d%d%d", &b, &f, &r, &v);
    house[b-1][f-1][r-1] += v;
  }

  for(i = 0; i < 4; i++){
    for(j = 0; j < 3; j++){
      for(k = 0; k < 10; k++){
	printf(" %d", house[i][j][k]);
      }
      printf("\n");
    }
    if(i < 3){
      printf("####################\n");
    }
  }
  return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
int main () {
    int D, N;
    cin >> D >> N;
    for (int i = 1;; i++) {
        int k = 0;
        int ii = i;
        while (ii % 100 == 0) {
            ii /= 100;
            k++;
        }
        if (k == D) {
            N--;
        }
        if (N == 0) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
l,r=map(int, open(0).read().split())
if r-l>=2019:
    print(0)
    exit()
l=l%2019
r=r%2019
a=2018
for i in range(l,r):
    for j in range(i+1,r+1):
        a=min(a,i*j%2019)
print(a)

Measured memory_bytes: 3060
<?php

class Solver
{
    private $elements_of_formula = array();

    public function __construct()
    {
        $lines = array();
        while (1) {
            if (!$line = fgets(STDIN)) {
                break;
            }
            $line = trim($line);
            $lines[] = $line;
        }
        $this->elements_of_formula = explode(' ', $lines[0]);
    }
    
    public function calculateReversePolishNotationFormula()
    {
        $elements_of_stack = array();
        foreach ($this->elements_of_formula as $element) {
            if (ctype_digit($element)) { //オペランドならスタックする
                array_push($elements_of_stack, intval($element));
            } else { //演算子ならスタックされた2つの要素を計算
                // $operand2 [演算子] $operand1 
                $operand1 = array_pop($elements_of_stack);
                $operand2 = array_pop($elements_of_stack);
                $result;
                switch ($element) {
                    case '+':
                        $result = $operand2 + $operand1;
                        break;
                    case '-':
                        $result = $operand2 - $operand1;
                        break;
                    case '*':
                        $result = $operand2 * $operand1;
                        break;
                }
                array_push($elements_of_stack, $result);
            }
        }
        echo $elements_of_stack[0] . PHP_EOL;
    }
}

$solver = new Solver;
$solver->calculateReversePolishNotationFormula();



Measured memory_bytes: 9424
S = input()
T = input()
alp = "abcdefghijklmnopqrstuvwxyz"
A = [0]*26
for i in range(len(S)):
    if A[alp.index(T[i])] == 0:
        A[alp.index(T[i])] = S[i]
    elif A[alp.index(T[i])] != S[i]:
        print("No")
        exit()
A = [0]*26
for i in range(len(S)):
    if A[alp.index(S[i])] == 0:
        A[alp.index(S[i])] = T[i]
    elif A[alp.index(S[i])] != T[i]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
static const int INF = 1e8;
 
int main() {
	int a,b;
	cin >> a >>b;
	if(a>8||b>8) cout<<":("<<endl;
	else cout <<"Yay!" << endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
p = list(map(int,input().split()))
used = [0]*n
c = list(map(int,input().split()))
ans = -float("INF")
def calc(x):
    l = []
    now = x
    score = 0
    while used[now] == 0:
        used[now] = 1
        l.append(c[now])
        now = p[now]-1
    S = sum(l)
    le = len(l)
    if S > 0 and k > le:
        score += (k//le-1)*S
        mod = k%le+le
        now = 0
        for i in range(le):
            cal = 0
            for j in range(mod):
                cal += l[(i+j)%le]
                now = max(now,cal)
        return score+now
    else:
        mod = min(le,k)
        now = -float("INF")
        for i in range(le):
            cal = 0
            for j in range(mod):
                cal += l[(i+j)%le]
                now = max(now,cal)
        return score+now
    
for i in range(n):
    if used[i] == 0:
        ans = max(ans,calc(i))
print(ans)

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

int main()
{
  int n;
  cin >> n;
  int team[n + 5] = {0};
  int m = n * (n - 1) / 2;
  for (int i = 0; i < m; i++){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (c > d) team[a] += 3;
    else if (c < d) team[b] += 3;
    else {
      team[a]++;
      team[b]++;
    }
  }

  for (int i = 1; i <= n; i++){
    int res = 1;
    for (int j = 1; j <= n; j++) if (team[i] < team[j]) res++;
    cout << res << '\n';
  }
}

Measured memory_bytes: 3024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

const int dir[] = {-1, 0};

int main() {
	int a, b, q; cin >> a >> b >> q;
	vector<ll> sh(a);
	rep(i, a) cin >> sh[i];
	vector<ll> te(b);
	rep(i, b) cin >> te[i];

	rep(i, q) {
		ll ans = LLONG_MAX;
		ll x; cin >> x;
		rep(j, 2) {
			if (j==0) { // shから
				rep(k, 2) {
					ll tot = 0;
					int it = lower_bound(all(sh), x)-sh.begin();
					it += dir[k];
					if (it<0 || it>=a) continue;
					tot += abs(x-sh[it]);
					int it2 = lower_bound(all(te), sh[it])-te.begin();
					ll tmp = LLONG_MAX;
					rep(l, 2) {
						if (l==0) it2--;
						else it2++;
						if (it2<0 || it2>=b) continue;
						chmin(tmp, abs(sh[it]-te[it2]));
					}
					chmin(ans, tot+tmp);
					debug(i,j,k,tot,tmp);
				}
			} else {
				rep(k, 2) {
					ll tot = 0;
					int it = lower_bound(all(te), x)-te.begin();
					it += dir[k];
					if (it<0 || it>=b) continue;
					tot += abs(x-te[it]);
					int it2 = lower_bound(all(sh), te[it])-sh.begin();
					ll tmp = LLONG_MAX;
					rep(l, 2) {
						if (l==0) it2--;
						else it2++;
						if (it2<0 || it2>=a) continue;
						chmin(tmp, abs(te[it]-sh[it2]));
					}
					chmin(ans, tot+tmp);
					debug(i,j,k,tot,tmp);
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 2944
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll dp[1005]={0};
double a[1005]={0};
int main()
{  double m,n,sum=0,t,sum1=0,t1;
   int i,n1;
   scanf("%lf%lf",&n,&m);
   n1=n;
   t=1/(m*4);
   for(i=1;i<=n;i++)
     { scanf("%lf",&a[i]);
       sum+=a[i];
   }
   sort(a+1,a+n1+1);
   for(i=n1;i>=1;i--)
   {    t1=a[i]/sum;
        if(t1>=t)
        sum1++;
        else
        break;
        
   } 
    if(sum1>=m)
     printf("Yes\n");
     else
     printf("No\n");
 }

Measured memory_bytes: 256