akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//Dijkstra法
struct edge {
	ll to;
	ll cost;
};
typedef pair<ll, ll> P;

void Dijkstra(int s, vector<vector<edge>>& g, vector<ll>& d) {
	priority_queue<P, vector<P>, greater<P>> q;
	d = vector<ll>(g.size(), INF_LL);
	d[s] = 0;
	q.push(P{ 0,s });

	while (!q.empty()) {
		P p = q.top(); q.pop();
		ll v = p.second;
		if (d[v] < p.first)continue;
		for (int i = 0; i < g[v].size(); i++) {
			edge e = g[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				q.push(P{ d[e.to] , e.to });
			}
		}
	}
}

int main() {
	io_init;
	int N, X, Y;
	cin >> N >> X >> Y;
	vector<vector<edge>> g(N);
	g[X - 1].push_back({ Y - 1,1 });
	g[Y - 1].push_back({ X - 1,1 });
	for (int i = 0; i < N - 1; i++) {
		g[i].push_back({ i + 1,1 });
		g[i + 1].push_back({ i,1 });
	}
	vector<ll> tmp;
	map<int, int> ans;
	for (int i = 0; i < N; i++) {
		Dijkstra(i, g, tmp);
		for (int j = 0; j < N; j++) {
			ans[tmp[j]]++;
		}
	}
	for (int i = 1; i < N; i++) {
		cout << ans[i]/2 << endl;
	}
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

string a,b,c;
int x,y,z;


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

	cin>>a>>b>>c;
	char flg='a';
	while (true) {
		if(flg=='a') {
			if(a.size()==x) {
				cout<<'A'<<endl;
				return 0;
			}
			flg=a[x];
			x++;
		}
		else if(flg=='b') {
			if(b.size()==y) {
				cout<<'B'<<endl;
				return 0;
			}
			flg=b[y];
			y++;
		}
		else {
			if(c.size()==z) {
				cout<<'C'<<endl;
				return 0;
			}
			flg=c[z];
			z++;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
const int MAXN = 2e5+5,MAXM = 2e5+5,MOD = 20130427,INF = 0x3f3f3f3f,N=100050;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const db eps = 1e-9;
#define lson o<<1,l,m
#define rson o<<1|1,m+1,r
#define mid l + ((r-l)>>1)
#define rep(i,a,b) for(register int i=(a);i<=(b);i++)
#define vii vector<pair<int,int>>
#define vi vector<int>
using namespace std;

int n,a,base[55];
multiset<int> st;
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    //freopen("../A.in","r",stdin);
    //freopen("../A.out","w",stdout);
    base[0]=1;
    for(int i=1;i<=30;i++)base[i]=base[i-1]*2;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a,st.insert(a);
    int ans=0;
    while(st.size()>=2){
        int x = *st.rbegin();
        st.erase(st.find(x));
        for(int j=30;base[j]>x;j--){
            auto y = st.find(base[j]-x);
            if(y!=st.end()&&base[j]-x==*y){
                st.erase(y);
                ans++;
                break;
            }
        }
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 9600
/* 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-05-18 22:40:16
**/
#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;

#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 = 1e3 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , A , B , C , D , fact[MAXN] , inv[MAXN][MAXN] , dp[MAXN][MAXN];

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

    for(int i = 0 ; i < MAXN ; i++){
        fact[i] = (i == 0 ? 1LL : fact[i - 1] * i) % MOD;
        inv[i][0] = 1;
        inv[i][1] = poww(fact[i] , MOD - 2 , MOD);
        for(int j = 2 ; j < MAXN ; j++) inv[i][j] = inv[i][j - 1] * inv[i][1] % MOD;
    }

    cin >> n >> A >> B >> C >> D;
    dp[A - 1][0] = 1;
    for(int i = A ; i <= B ; i++){
        for(int j = 0 ; j < MAXN ; j++) dp[i][j] = dp[i - 1][j];
        for(int j = C ; j <= D ; j++){
            if(i * j > n)   break;
            ll cur = fact[i * j] * inv[i][j] % MOD * inv[j][1] % MOD;
            //cout << i << sep << j << sep << cur << endl;
            for(int k = i * j ; k <= n ; k++){
                ll x = fact[n - k + i * j] * inv[i * j][1] % MOD * inv[n - k][1] % MOD;
                dp[i][k] = (dp[i][k] + dp[i - 1][k - i * j] * x % MOD * cur) % MOD;
            }
        }
    }
    cout << dp[B][n] << endl;


    return 0;
}
/*

*/


Measured memory_bytes: 16256
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = 0
for i in range(n):
    for j in range(i):
        for k in range(j):
            if a[k]+a[j] > a[i] and a[i] != a[j] and a[j]!=a[k]:
                ans += 1
print(ans)

Measured memory_bytes: 67876
#include <iostream>
#include <string>
using namespace std;
int main()
{
  int A;
  int B;
  int C;
  int i;
  int tmp;

  
  cin >> A;
  cin >> B;
  cin >> C;
  if(A==B){
    if(B==C){
      cout << "No";
    }else{
      cout << "Yes";
    }
  }else if(B==C||A==C){
    cout << "Yes";
  }else{
    cout <<"No";
  }
}



Measured memory_bytes: 256
#!/usr/bin/env python
from collections import defaultdict
from heapq import heappop, heappush
from math import isinf

V, E, r = map(int, input().split())

e = defaultdict(list)
for i in range(E):
    s, t, length = map(int, input().split())
    e[s].append((length, t))

distance = [float('inf')] * V          # 各頂点への距離の初期値
distance[r] = 0                        # 始点への距離は 0

# ダイクストラ
heap = [(distance[r], r)]
while heap:
    du, u = heappop(heap)
    for length, v in e[u]:
        if distance[v] > distance[u] + length:
            distance[v] = distance[u] + length
            heappush(heap, (distance[v], v))

for d in distance:
    print('INF' if isinf(d) else d)

Measured memory_bytes: 108588
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <unordered_map>

using namespace std;

void solve() {
    int n, d; cin >> n >> d;
    vector<vector<int>> pos(n, vector<int>(d));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            cin >> pos[i][j];
        }
    }

    int count = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            double sqrtsum = 0;
            for(int k = 0; k < d; k++){
                sqrtsum += pow((double)pos[i][k] - (double)pos[j][k], 2);
            }
            double sqrtres = sqrt(sqrtsum);
            if(floor(sqrtres) == sqrtres) count++;
        }
    }
    cout << count << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
using System;
    using System.Collections.Generic;
    using System.Linq;
     
    class program{
    	static void Main(string[] args){
        	string[] input = Console.ReadLine().Split(' ');
          List<int> list  = new List<int>();	
          for(int i = 0;i < input.Length;i ++){
            if(!list.Exists(j => j == int.Parse(input[i])))
              list.Add(int.Parse(input[i]));
            }
          
          Console.WriteLine(list.Count);
        }
    }

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

int prime[247000];
bool is_prime[247001];

int sieve(int n){
    int p = 0;
    for(int i = 0;i <= n;i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for(int i = 2;i <= n;i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j = 2*i;j <= n;j+=i) is_prime[j] = false;
        }
    }
    return p;
}

int main(void){
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;
        cout << sieve(2*n)-sieve(n) << endl;
    }
    return 0;
}



Measured memory_bytes: 3364
#include<iostream>
#include<map>
#include<string>
#define MAX_N 101
using namespace std;

string s[MAX_N];

int main() {
    int N;
    cin >> N;
    map<string, int> MP;
    for (int i = 0; i < N; i++) {
        cin >> s[i];
        MP[s[i]]++;
    }
    if (MP[s[0]] != 1) {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 1; i < N; i++) {
        if (MP[s[i]] != 1) {
            cout << "No" << endl;
            return 0;
        }
        if (s[i - 1][s[i - 1].length() - 1] != s[i][0]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

typedef pair<int, int> pint;
typedef long long ll;

signed main()
{
    int N, M;
    cin >> N >> M;
    if (abs(N - M) > 1)
    {
        cout << 0 << endl;
        return 0;
    }

    int ans = 1;
    for (int i = 1; i <= N; i++)
    {
        ans *= i;
        ans %= INF;
    }
    for (int i = 1; i <= M; i++)
    {
        ans *= i;
        ans %= INF;
    }
    if ((N + M) % 2 == 0)
    {
        cout << (ans * 2) % INF << endl;
    }
    else
    {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int i;
		char cha = 0;
		String str;
		try (Scanner sc = new Scanner(System.in)) {
			str = sc.nextLine();
			for(i = 0; i < str.length(); i++) {
				cha = str.charAt(i); //strの文字列を一文字づつchaに入れる
				if(Character.isUpperCase(cha)){
					System.out.print(Character.toLowerCase(cha)); //chaが大文字の時小文字にする
				}else {
					System.out.print(Character.toUpperCase(cha)); //chaが小文字の時大文字にし、それ以外はそのまま出力
				}
			}
			System.out.println();
		}
	}
}



Measured memory_bytes: 26600
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<int>())S
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int a,b;
    cin >> a >> b;
    pr(a-b+1);
}

Measured memory_bytes: 256
import numpy as np

N,M=(int(x) for x in input().split())
c=np.zeros(50)
for i in range(M):
    a,b=(int(x) for x in input().split())
    c[a-1]=c[a-1]+1
    c[b-1]=c[b-1]+1
for i in range(N):
    print(int(c[i]))

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

int main() {
  int H, W, dol;
  string S1, S2 = "";
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    cin >> S1;
    S2 += S1;
  }
  for (int i = 0; i < H * W; i++) {
    if (S2.at(i) == '.') {
      dol = 0;
      if (W * H != 1) {
        if (W != 1) {
          if (i >= W) {
            if (i % W == 0) {
              for (int k = 0; k < 2; k++) {
                if (S2.at(i - W + k) == '#')
                  dol++;
              }
            }
            else if ((i + 1) % W == 0) {
              for (int k = 0; k < 2; k++) {
                if (S2.at(i - W - k) == '#')
                  dol++;
              }
            }
            else {
              for (int k = -1; k <= 1; k++) {
                if (S2.at(i - W + k) == '#') 
                  dol++;
              }
            }
          }
          if (i <= H * W  - 1 - W) {
            if (i % W == 0) {
              for (int k = 0; k < 2; k++) {
                if (S2.at(i + W + k) == '#')
                  dol++;
              }
            }
            else if ((i + 1) % W == 0) {
              for (int k = 0; k < 2; k++) {
                if (S2.at(i + W - k) == '#')
                  dol++;
              }
            }
            else {
              for (int k = -1; k <= 1; k++) {
                if (S2.at(i + W + k) == '#') 
                  dol++;
              }
            }
          }
          if (i % W == 0) {
            if (S2.at(i + 1) == '#')
              dol++;
          }
          else if ((i + 1) % W == 0) {
            if (S2.at(i - 1) == '#')
              dol++;
          }
          else {
            for (int k = -1; k <= 1; k += 2) {
              if (S2.at(i + k) == '#')
                dol++;
            }
          }
        }
        else {
          if (i == 0) {
            if (S2.at(i + 1) == '#')
              dol++;
          }
          else if (i == H - 1) {
            if (S2.at(i - 1) == '#')
              dol++;
          }
          else {
            for (int k = -1; k <= 1; k++) {
              if (S2.at(i + k) == '#')
                dol++;
            }
          }
        }
      }
      cout << dol;
    }
    else 
      cout << "#";
    if ((i + 1) % W == 0)
      cout << endl;
  }
}

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

// スマホコーディング@バンコク

// 偶数回の移動による極限分布
int main() {
	string S;
	cin >> S;
	vector<int> v; // 変化の座標
	v.push_back(-1);
	for(int i=0; i < S.size() - 1; ++i) {
		if(S[i] != S[i+1]){
			v.push_back(i);
		}
	}
	v.push_back(S.size() - 1);
	vector<int>ans(S.size());
	
	// v.size() は3以上の奇数であることが保証される
	// vの座標は 0-indexed なので注意
	for(int i=1; i < v.size() - 1; ++i){
		if(i % 2 == 1){ // RL
			ans[v[i]] = ans[v[i]] + (v[i] - v[i-1] + 1) / 2;
			ans[v[i]+1] = ans[v[i]+1]+ (v[i] - v[i-1]) / 2;
			ans[v[i]] = ans[v[i]] + (v[i+1] - v[i]) / 2;
			ans[v[i]+1] = ans[v[i]+1]+ (v[i+1] - v[i] + 1) / 2;
		}
		// LRの時は何もする必要なし
	}
	
	for(int i=0; i < S.size(); ++i) {
		cout << ans[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 1528
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int size;
    int tmp;
    cin >> size;

    vector<int> v;

    for (int i = 0; i < size; i++) {
        cin >> tmp;
        v.push_back(tmp);
    }

    sort(v.begin(), v.end());
    for (int i = 0; i < size - 1; i++) {
        if (v[i] == v[i + 1]) {
            cout << "NO" << endl;;
            return (0);
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,sum=0;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int temp;
        cin>>temp;
        sum=sum+temp;
    }
    if(sum<=n)
    cout<<n-sum;
    else{
        cout<<-1;
    }
    return 0;
}

Measured memory_bytes: 3620
# -*- coding: utf-8 -*-

import re

A, B = map(int, input().split())
S = str(input())

text = '[0-9]{' + str(A) + '}-[0-9]{' + str(B) + '}'
pattern = re.compile(text)
matchobj = pattern.match(S)

if matchobj:    
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9920
n=int(input())
a = list(map(int,input().split()))
b = [0]*n
for i in range(n-1,-1,-1):
  if a[i]!=sum(b[i::i+1])%2:
    b[i]=1
ans=[i for i, x in enumerate(b) if x == 1] #-1
print(len(ans))
for i in ans:
  print(i+1,end=" ")

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


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

    int cnt = 0;
    if (s == "SUN") cnt = 7;
    else if (s == "MON") cnt = 6;
    else if (s == "TUE") cnt = 5;
    else if (s == "WED") cnt = 4;
    else if (s == "THU") cnt = 3;
    else if (s == "FRI") cnt = 2;
    else if (s == "SAT") cnt = 1;

    cout << cnt << endl;
}


Measured memory_bytes: 256
#import<stdio.h>
#import<queue>
int main(){std::queue<int>q;int w,h,f[484],i,j,a,b,t,x,z;char p[15];for(;scanf("%d%d ",&h,&w),h;){for(j=0;j<w+2;j++)f[j]=f[j-~h*22]=-1;for(i=1;i<=h;i++){for(j=1;j<=w;j++)f[x=i*22+j]=-2,z=getchar(),z-35?z>65?b=x:z>64?a=x:1:--f[x];f[i*22]=f[i*22-~w]=-1;getchar();}f[a]=t=0;q.push(0);for(q.push(a);a=q.front(),q.size()>1;q.pop())if(!a)++t,q.push(0);else for(i=4;i--;)if(f[x=a+" 57L"[i]-54]==-2)f[x]=t,q.push(x);q.pop();scanf("%s",p);for(a=t=0;!a;){x=b;z=0;for(i=0;!a&&p[i];f[b]>=0&&++z)++t,~f[j=b-54+"L65676 "[p[i++]-50]]?b=j:0,f[b]>=0&t>=f[b]?a=b:0;!z&!a&!p[i]&b==x&f[b]<0&&--a;}printf(~a?"%d %d %d\n":"impossible\n",t,a/22-1,a%22-1);}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    rep(i,3){
        if(n%10==7){
            cout<<"Yes"<<endl;
            return 0;
        }
        n/=10;
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 3624
/// Kazuki Hoshino


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define endl '\n'
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

ll n;
string s[555];
map<string, int> mp;
bool ans = true;

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

cin >> n;

cin >> s[1];
mp[s[1]]++;
int k = s[1].size()-1;
rep(i, 2, n){
cin >> s[i];
mp[s[i]]++;
if(mp[s[i]]>1 || s[i][0]!=s[i-1][k] )ans=false;
k = s[i].size()-1;
}

if(ans){
    cout << "Yes" << endl;
}
else {
    cout << "No" << endl;
}











return 0;}
///....


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>
#include <fstream>
using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const int BINF = 100000000000000001;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
const double pi = 3.14159265359;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())

//ABC151 ２マス間の最短距離　深さ幅どっちか
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<vector<bool>> S(H + 2, vector<bool>(W + 2, false));
    for (int i = 1; i < H + 1; ++i) {
        string input;
        cin >> input;
        for (int j = 1; j < W + 1; ++j) {
            if (input[j - 1] == '.')S[i][j] = true;
        }
    }
    int ans = 0;
    vector<vector<bool>> canGo(H + 2, vector<bool>(W + 2, false));
    
    for (int i = 1; i < H + 1; ++i) {
        for (int j = 1; j < W + 1; ++j) {
            copy(S.begin(), S.end(), canGo.begin());
            if (canGo[i][j] != false) {
                std::queue<std::pair<int, std::pair<int, int>>> wait;
                wait.push(std::make_pair(0, std::make_pair(i, j)));
                canGo[i][j] = false;
                while (!wait.empty()) {
                    int nowcost = wait.front().first;
                    int nowY = wait.front().second.first;
                    int nowX = wait.front().second.second;
                    wait.pop();

                    /*if (gy == nowY && gx == nowX) {
                        ans = nowcost;
                        break;
                    }*/
                    ans = max(nowcost, ans);
                    for (int k = 0; k < 4; k++) {
                        int nextY = nowY + dy[k];
                        int nextX = nowX + dx[k];
                        if (canGo[nextY][nextX]) {
                            wait.push(std::make_pair(nowcost + 1, std::make_pair(nextY, nextX)));
                            canGo[nextY][nextX] = false;
                        }
                    }

                }
                
            }
        }
    }
    /*for (int i = 0; i <= H; ++i) {
        for (int j = 0; j <= W; ++j) {
            if (S[i][j] == true)cout << ".";
            else cout << "#";
        }
        cout << endl;
    }*/
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	int N, A;
	cin >> N >> A;
	int x[51];
	rep(i, N) {
		cin >> x[i];
	}

	ll dp[51][51][2501] = {};
	dp[0][0][0] = 1;

	rep(i, N) {
		rep(ii, 50) {
			rep(iii, 2500) {
				dp[i + 1][ii + 1][iii + x[i]] += dp[i][ii][iii];
				dp[i + 1][ii][iii] += dp[i][ii][iii];
			}
		}
	}

	ll kotae = 0;
	rep1(i, 50) {
		kotae += dp[N][i][A * i];
	}
	co(kotae);

	Would you please return 0;
}

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

using namespace std;

int n;
const int MAX_A = 1e6 + 5;
int cnt[MAX_A] = {};

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

        if (cnt[a[i]] >= 1) {
            cnt[a[i]] = 2;
            continue;
        }
        for (int j = a[i]; j < MAX_A; j += a[i]) {
            cnt[j]++;
        }
    }
    int ans = 0;
    for (auto x : a) {
        if (cnt[x] == 1) ans++;
    }
    printf("%d\n", ans);

    return 0;
}


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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int res=max({a,b,c});
	res = res*10 + a+b+c-res;
	cout << res << endl;
	return 0;
}



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

int main(){
    int n, i, l, r, xr = 0, sum = 0;
    cin >> n;
    long long res = 0, c = 0, a[n];
    for(i=0; i<n; i++){
        cin >> a[i];
    }
    r = 0;
    for(l=0; l<n; l++){
        while(sum == xr && r<n){
            sum += a[r];
            xr ^= a[r];
            r++;
            c++;
        }
        if(sum == xr && r == n) res++;
        res += c-1;
        sum -= a[l];
        xr ^= a[l];
        c--;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <cmath>

using namespace std;

long long max(vector<long long> A){
    long long ret=0;
    for(int i=0; i<A.size(); i++){
        if(A[i]>ret){
            ret= A[i];
        }
    }
    return ret;
}

int main(){
    long long N,K;
    cin >> N >> K;
    vector<long long> A(N,0);

    for(int i=0; i<N; i++){
        cin >> A[i];
    }

    long long num=0;
    for(int i=39; i>=0; i--){
        long long sum_0=0;
        long long sum_1=0;
        long long tmp=num+(long long) pow(2,i);
        if(tmp>K)continue;

        for(int j=0; j<N; j++){
            sum_0+=A[j]^num;
            sum_1+=A[j]^tmp;
        }
        if(sum_0<sum_1){
            num=tmp;
        }
    }
    long long ans=0;
    for(int i=0; i<N; i++){
        ans+=A[i]^num;
    }
    cout << ans << endl;
}


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

int main() {
  int N, T;
  cin >> N >> T;
  int ans = T, prev = 0;
  for (int i = 0; i < N; i++) {
    int t;
    cin >> t;
    if (i == 0) continue;
    ans += min(t - prev, T);
    prev = t;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
  int n;
  cin >> n;
  ll cnt = 0;
  map<ll,ll> mp;
  mp[0] = 1;
  ll sum = 0;
  for(int i = 0;i < n;i++) {
    ll a;
    cin >> a;
    sum += a;
    cnt += mp[sum];
    mp[sum]++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 15960
//Author : Siriuslight
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0),cout<<setprecision(10)<<fixed;
#define int long long
#define F first
#define S second

using namespace std;
using namespace __gnu_pbds;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const ll inf = 1e9+100, N = 1e2+5, M = 1e5+5;
const ll INF = 1e18+100, MOD = 1e9+7;

ll powmod(ll a,ll b,ll m=MOD){ll r=1;while(b>0){if(b&1)r=r*a%m;a=a*a%m;b>>=1;}return r;}
ll power(ll a,ll b){ll r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
ll gcd(ll a,ll b){if(!b)return a;return gcd(b,a%b);}
ll inv(ll a, ll m = MOD){return powmod(a,m-2,m);}
ll lcm(ll a,ll b){return(a*b)/gcd(a,b);}

//ordered_set X;
//X.insert(3);
//X.order_of_key(3) no of elements less than 3
//*X.find_by_order(n) nth greatest element(0-indexed)

int n, cap, we[N], val[N], dp[N][M];

int solve(int id, int rem){
    if(id <= 0) return 0;
    int &res = dp[id][rem];
    if(res != -1) return res;
    res = 0;
    if(rem - we[id] >= 0)
    res = max(res, val[id] + solve(id - 1, rem - we[id]));
    res = max(res, solve(id - 1, rem));
    return res;
}
int32_t main(){
    FIO;
    cin >> n >> cap;
    for(int i = 1; i <= n; ++i){
        cin >> we[i] >> val[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << solve(n, cap);

}


Measured memory_bytes: 82304
#include<stdio.h>

int main(void){

    int n;

    scanf("%d",&n);

    int s = 0,t = 0,u = 0,w,ans;
    int f = s*s + t*t + u*u + s*t + t*u + u*s;

    for(w = 1; w <= n; w++){
        ans = 0;
        for(s = 1 ;s*s +s<= w; s++){
            for(t = 1 ;t*t + t<= w; t++){
                for(u = 1 ;s*s + t*t + u*u + s*t + t*u + u*s <= w; u++){
                    if(s*s + t*t + u*u + s*t + t*u + u*s == w){
                        ans++;
                    }
                }
            }
        }
        printf("%d\n",ans);
    }

}

Measured memory_bytes: 1632
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
  int n;
  cin>>n;
  V<ll> a(n);
  multiset<ll> s;
  for(int i=0;i<n;i++){
      cin>>a[i];
      s.insert(a[i]);
  }
  V<ll> two(60);
  for(int i=0;i<60;i++)two[i]=(1ll<<i);
  int ans=0;
  sort(all(a),greater<ll>());
  for(int i=0;i<n;i++){
      if(s.find(a[i])==s.end())continue;
      s.erase(s.find(a[i]));
      for(int j=59;j>=0;j--){
          if(two[j]<a[i])break;
          if(s.find(two[j]-a[i])!=s.end()){
              ans++;
              s.erase(s.find(two[j]-a[i]));
              break;
          }
      }
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 11264
/* Filename: ABC044A.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main{

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

		while (input.hasNext()) {
			int N = input.nextInt();
			int K = input.nextInt();
			int X = input.nextInt();
			int Y = input.nextInt();
			
			if(N <= K){
				System.out.println(N * X);
			} else {
				System.out.println(K * X + (N - K) * Y);
			}
		}
	}

}


Measured memory_bytes: 8788
#include<stdio.h>
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void){
	int n,j,i,k;
	int su[10000],max;
	long long int dp[1000][100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&su[i]);
	}
	for(i=0;i<n;i++){
		for(j=0;j<=20;j++){
			dp[i][j]=0;
		}
	}
	dp[0][su[0]]=1;
	for(i=1;i<n-1;i++){
		for(j=0;j<=20;j++){
			dp[i][j-su[i]]+=dp[i-1][j];
			dp[i][j+su[i]]+=dp[i-1][j];
		}
	}
	/*for(i=0;i<n-1;i++){
		for(j=0;j<=20;j++){
			printf("%lld ",dp[i][j]);
		}
		printf("\n");
		printf("%d",su[i]);
		printf("\n");
		printf("%d\n",i);
		//printf("\n");
	}*/
	printf("%lld\n",dp[n-2][su[n-1]]);
	return 0;
}

Measured memory_bytes: 1116
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
ll f(ll h)
{
	if(h==1)
	return 1;
	return 1+2*f(h/2);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,m,k,ans,n,a,b,g,h;
    	cin>>h;
    	ans=0;
    	cout<<f(h);
    	
    	
    } 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main(){
    int N, W; cin >> N >> W;
    vector<vector<ll>> dp(N+1, vector<ll>(110000, 1LL<<60));
    vector<int> c(N), v(N);
    for(int i=0; i<N; i++){
        cin >> c[i] >> v[i];
    }
    
    dp[0][0] = 0;
    for(int i=0; i<N; i++){
        for(int j=0; j<=100000; j++){
            dp[i+1][j+v[i]] = min(dp[i][j+v[i]], dp[i][j] + c[i]);
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        }
    }
    
    for(int i=100000; i>=0; i--){
        if(dp[N][i]<=W){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}





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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int a, n;

int main() {
	cin >> n >> a;
	
	cout << (n % 500 <= a ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a, b, ans;
    char op;

    while (1) {
        scanf("%d %c %d", &a, &op, &b);
        if (op != '?') {
            if (op == '+') {
                ans = a + b;
            }

            if (op == '-') {
                ans = a - b;
            }

            if (op == '*') {
                ans = a * b;
            }

            if (op == '/') {
                ans = a / b;
            }
            printf("%d\n", ans);
        } else {
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 2056
n = int(input())

times = n
table = []
for _ in range(times):
    a = int(input())
    temp = []
    for _ in range(a):
        x , y = map(int,input().split())
        temp.append([x-1,y])
    table.append(temp)  

    
def check(i,n):#iはbitでn人それぞれが正直者か嘘つきかのどちらかを表している。
    flg = True
    for j in range(n):
        if i>>j & 1:#右にシフト演算したものの一桁目が1であるとき。iのうち１である桁j=正直者jの意見に関しては吟味する。
            for x,y in table[j]:#ある正直者jの、xに対する評価y
                if (i>>x)&1 != y:#iにおけるxの評価(実際のxの評価)　！＝　jのxに対する評価y
                    flg = False
                    # print(flg)
                    return flg
    # print(flg)
    return flg

# print(table)
ans = 0
for i in range(2**n):   #bit全探索
    if check(i,n):
        ans = max(bin(i).count("1"),ans)

print(ans)


Measured memory_bytes: 3064
import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in = new Scanner(System.in);
		String s=in.next();
		int ans=0;
		for(int i=0;i<s.length();i++)
		{
			if(i==s.length()-2) {
				if(s.charAt(i)==s.charAt(i+1)) {
					i++;
				}
			}else if(i!=s.length()-1){
				if(s.charAt(i)==s.charAt(i+1)) {
					i++;
					ans++;
					i++;
				}
			}
			ans++;
		}

		System.out.println(ans);
			
	}
}
	

Measured memory_bytes: 26936
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
typedef double D;
typedef complex<D> P;
typedef vector<P>VP;
const D EPS = 1e-9;
#define X real()
#define Y imag()
#define EQ(n,m) (abs(n-m)<EPS)
D dot(P a,P b){return (conj(a)*b).X;}
D cross(P a,P b){return (conj(a)*b).Y;}
int ccw(P a,P b,P c){
  b-=a;c-=a;
  if(cross(b,c)>EPS)return 1;
  if(cross(b,c)< -EPS)return -1;
  if(dot(b,c)< -EPS)return 2;
  if(norm(b)<norm(c))return -2;
}
VP crosspointCC(P a, D ar, P b, D br) {
  VP ps;
  P ab=b-a;
  D d=abs(ab);
  D crL=(norm(ab)+ar*ar-br*br)/(2*d);
  if(EQ(d,0)||ar<abs(crL))return ps;
  P abN=ab*P(0,sqrt(ar*ar-crL*crL)/d);
  P cp=a+crL/d*ab;
  ps.push_back(cp + abN);
  if(!EQ(norm(abN),0)) ps.push_back(cp-abN);
  return ps;
}
namespace std {
  bool operator<(const P a,const P b) {
    return a.X!=b.X?a.X<b.X:a.Y<b.Y;
  }
}
VP convexHull(VP ps){
  int n=ps.size(),k=0;
  sort(ps.begin(),ps.end());
  VP ch(2*n);
  for(int i=0;i<n;ch[k++]=ps[i++])
    while(k>=2&&ccw(ch[k-2],ch[k-1],ps[i])<=0)--k;
  for(int i=n-2,t=k+1;i>=0;ch[k++]=ps[i--])
    while(k>=t&&ccw(ch[k-2],ch[k-1],ps[i])<=0)--k;
  ch.resize(k-1);
  return ch;
}

P rot(P p, double a,double x,double y){
  a=a*M_PI/180.0;
  P p1=P(x,y);
  p-=p1;
  return P(p.X*cos(a)+p.Y*(-sin(a))+x,p.X*sin(a)+p.Y*cos(a)+y);
}

int n,q;
D r;

int main(){
  //cout<<acos(cos(M_PI))/M_PI*180<<endl;
  while(cin>>n>>r>>q,n){
  VP v;
  r(i,n){
    double x,y;
    cin>>x>>y;
    v.push_back(P(x,y));
  }
  v=convexHull(v);
  int p;
  double t=1e9;
  double y,x;
  r(i,v.size()){
    if(v[i].Y<t){
      x=v[i].X;
      y=v[i].Y;
      t=v[i].Y;
      p=i;
    }
  }
  //for(int i=p,c=0;c<4;i=(i+1)%4,c++){
  //cout<<v[i].X<<' '<<v[i].Y<<endl;
  //}
  r(i,q){//cout<<p<<endl;
    int ppp=p;
    for(;;p=(p-1+v.size())%v.size()){//cout<<p<<endl;
      VP p1=crosspointCC( P(0,0) ,r , P(x,y) , abs(v[ppp]-v[(p-1+v.size())%v.size()]) );
      P pt;
      if(ccw(p1[0],P(x,y),P(0,0))==1)pt=p1[0];
      else pt=p1[1];
      // r(k,2){
      //cout<<pt.X<<' '<<pt.Y<<endl;
      //cout<<v[(p-1+v.size())%v.size()].X<<' '<<v[(p-1+v.size())%v.size()].Y<<endl;
      //}//cou
      D a=abs(v[ppp]-v[(p-1+v.size())%v.size()]);
      // D b=abs(v[p]-v[(p+1)%v.size()]);
      D c=abs(v[(p-1+v.size())%v.size()]-pt)*abs(v[(p-1+v.size())%v.size()]-pt);

      //cout<<sqrt(c)<<endl;
      //return 0;
      
      double radi=acos((a*a+a*a-c)/(2*a*a));

      // cout<<a<<endl;
      
      radi=radi/M_PI*180;
      //cout<<radi<<endl;
      
      VP vt=v;

      r(k,vt.size()){
	vt[k]=rot(vt[k],radi,x,y);
      }
      
      int flag=0;
      r(k,vt.size()){
	if(abs(vt[k]-P(0,0))-EPS>r)flag++;
      }
      if(flag)continue;
      v=vt;
      y=v[(p-1+v.size())%v.size()].Y;
      x=v[(p-1+v.size())%v.size()].X;
      printf("%.12f %.12f\n",x,y);
      p=(p-1+v.size())%v.size();
      break;
    }
  }
}
}

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

int main(){
int n;cin >>n;
string s ; cin >>s;
int ans=0;
for(int i=1;i<n;i++){
if(s[i]=='E'){ans++;}}
int dp[n];
dp[0]=ans;
for(int i=1;i<n;i++){
if(s[i-1]=='W'){
if(s[i]=='W'){
dp[i]=dp[i-1]+1;}
else dp[i]=dp[i-1];}
else{if(s[i]=='E'){dp[i]=dp[i-1]-1;}
else{dp[i]=dp[i-1];}}}
int x=dp[0];
for(int i=1;i<n;i++){x=min(x,dp[i]);}
cout << x << endl;}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 100005;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
int N;
vector<vector<int>> G(MAX, vector<int>());
/* function */
vector<int> bfs(int st) {
    vector<int> dist(N, NIL);
    queue<int> q;
    q.push(st);
    dist[st] = 0;
    while (q.size()) {
        int from = q.front();
        q.pop();
        for (int to :G[from]) {
            if (dist[to] != NIL) continue;
            dist[to] = dist[from] + 1;
            q.push(to);
        }
    }
    return dist;
}
/* main */
int main(){
    int u, v;
    cin >> N >> u >> v;
    u--, v--;
    for (int i = 0; i < N-1; i++) {
        int s, t; cin >> s >> t;
        s--, t--;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    vector<int> distTk = bfs(u);
    vector<int> distAO = bfs(v);
    int mx = 0;
    for (int i = 0; i < N; i++) {
        if (distTk[i] < distAO[i]) {
            if (mx < distAO[i]) {
                mx = distAO[i];
            }
        }
    }
    int ans = mx - 1;
    cout << ans << '\n';
}


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

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

//     int max;
//     for (int i = 1; i<=n; i++) {
//         ll now = a*i/b - a*(i/b);
//         if (now > max) max = now;
//     }

//     cout << max << endl; 
// }

int main () {
    ll a,b,n;
    cin >> a >> b >> n;
    ll x = min(b-1,n);
    ll ans = a*x/b - a*(x/b);
    cout << ans << endl;
}

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

a = [0] * M
b = [0] * M

ans = [0] * N

for i in range(M):
    a[i], b[i] = map(int, input().split())

for i in range(N):
    k = 0
    l = 0
    for ii in range(M):
        if a[ii]==i+1:
            k += 1
        elif b[ii]==i+1:
            l += 1
    ans[i] = k + l

for i in range(N):
    print(ans[i])




Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=1e5+10;
int dp[maxn][105],cnt[maxn];
ll upb,lwb;
int ID=0;
map<int,int> id;
int rid[maxn],reid[maxn];
int N,K;
inline void add(int &a,int b)
{
	a=(a+b)%MOD;
}
int main()
{
	scanf("%lld%d",&upb,&K);
	lwb=40000;
	while((upb/lwb)<lwb)lwb--;
	for(int i=1;i<=(int)lwb;i++)
	{
		rid[ID]=i;
		id[i]=ID++;
	}
	for(int i=lwb;i>=1;i--)
	{
		if(!id.count((int)(upb)/i))
		{
			rid[ID]=(int)(upb/i);
			id[(int)(upb/i)]=ID++;
		}
	}
	N=ID;
//	for(int i=0;i<N;i++)
//		cout<<rid[i]<<" ";
//	cout<<endl;
	for(int i=0;i<N;i++)
		dp[i][1]=rid[i];
	for(int i=0;i<N-1;i++)
		cnt[i]=rid[N-i-1]-rid[N-i-2];
	cnt[N-1]=1;
//	cout<<K<<endl;
	for(int i=0;i<N;i++)
		reid[i]=id[(int)upb/rid[i]];
	for(int len=1;len<K;len++)
	{
	//	cout<<len<<endl;
		for(int j=0;j<N;j++)
		{
			if(j)dp[j][len+1]=dp[j-1][len+1];
			add(dp[j][len+1],dp[reid[j]][len]*1ll*cnt[reid[j]]%MOD);
	//		cout<<dp[j][len+1]<<" "<<j<<" "<<len+1<<endl;
		}
	}
	printf("%d\n",dp[N-1][K]);
	return 0;
}

Measured memory_bytes: 31488
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int p = in.nextInt();
        int q = in.nextInt();
        int r = in.nextInt();

        System.out.println(Integer.min(p+q, Integer.min(q+r, p+r)));
    }
}

Measured memory_bytes: 23892
line2 = []
line = gets.chomp.split(" ")
(0..2).each do |i|
line2.push(line[i].to_i)
end

if line2.include?(5) && line2.include?(7)
    if line2.count(5) == 2
        puts "YES"
    else
        puts "NO"
    end
else
    puts "NO"
end

Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var ab = ReadSplitInt();
            Println(ab[0] * ab[1] % 2 == 0 ? "Even" : "Odd");
        }


        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 13268