akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using std::cin;
using std::cout;
int N,M,C;
int B[25];
int a;

int main(){
  cin >>N>>M>>C;
  for(int i = 0;i<M;++i){
   cin>>B[i]; 
  }
  
  for(int i = 0;i<N;++i){
    int tmpans = 0;
    for(int j = 0;j<M;++j){
      int tmp;
     cin>>tmp; 
      tmpans += tmp * B[j];
    }
    if(tmpans + C > 0)a++;
  }
  cout << a <<'\n';
 return 0; 
}

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

int main(){
	int n,m;
	cin >> n;
	m = n*100/108;
	for (int i=0;i<10;i++){
	if (floor((double)m*108/100) == n ){
		cout << m;
		return 0;
	}
	m=m+1;
}
cout << ":(" << endl;
}


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

int main(){
    
    int a, b, c, d;
 
    while(1){
        
        cin >> a >> b;
        
        if(a == 0 && b == 0)break;
        
        c = a - 1;
        
        d = b - 1;

        for ( int i = 0; i < a; i++ ){
            for ( int j = 0; j < b; j++ ){
                if(i != 0 && j != 0 && i != c && j != d){
                    cout << ".";
                } else {
                    cout << "#";
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  int ac=0;
  int wa=0;
  int tle=0;
  int re=0;
  string s;
  for(int i=0;i<n;i++){
    cin >> s;
    if(s=="AC"){
      ac++;
    }else if(s=="WA"){
      wa++;
    }else if(s=="TLE"){
      tle++;
    }else if(s=="RE"){
      re++;
    }
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;

}

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES_
#include <bits/stdc++.h>

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
typedef long long ll;
typedef vector<ll> vec;

string A,B;
const ll MOD=998244353,MAX_A_LEN=1e4,MAX_M2=1<<14;
ll fact[MAX_A_LEN+2],omg[MAX_M2<<1];

ll mpw(ll n,ll m){
	ll ret=1;
	while(m>0){
		if (m&1){
			ret*=n;
			ret%=MOD;
		}
		n*=n;
		n%=MOD;
		m>>=1;
	}
	return ret;
}
ll minv(ll n){
	return mpw(n,MOD-2);
}
ll M,E,m2;

vec fft(const vec &p,ll n,ll u=0,ll s=1){
	vec ret(n);
	if (n==1){
		ret[0]=p[u];
	}else{
		vec a=fft(p,n>>1,u,s<<1),b=fft(p,n>>1,u+s,s<<1);
		ll c=(MAX_M2<<1)/n;
		REP(i,n>>1){
			ll w1=omg[i*c],w2=omg[i*c+MAX_M2];
			ret[i]=(a[i]+w1*b[i]%MOD)%MOD;
			ret[i+(n>>1)]=(a[i]+w2*b[i]%MOD)%MOD;
		}
	}
	return ret;
}

vec ifft(const vec &p,ll n,ll u=0,ll s=1){
	vec ret(n);
	if (n==1){
		ret[0]=p[u];
	}else{
		vec a=ifft(p,n>>1,u,s<<1),b=ifft(p,n>>1,u+s,s<<1);
		ll c=(MAX_M2<<1)/n;
		REP(i,n>>1){
			ll w1=omg[((MAX_M2<<1)-i*c)%(MAX_M2<<1)],w2=omg[MAX_M2-i*c];
			ret[i]=(a[i]+w1*b[i]%MOD)%MOD;
			ret[i+(n>>1)]=(a[i]+w2*b[i]%MOD)%MOD;
		}
	}
	if (u==0 && s==1){
		REP(i,n){
			ret[i]*=minv(n);
			ret[i]%=MOD;
		}
	}
	return ret;
}

vec mul(vec p, vec q){
	p.resize(m2<<1);
	q.resize(m2<<1);
	vec u=fft(p,m2<<1),v=fft(q,m2<<1),w(m2<<1);
	REP(i,m2<<1){
		w[i]=u[i]*v[i]%MOD;
	}
	vec ret=ifft(w,m2<<1);
	ret.resize(m2);
	return ret;
}

vec ppw(vec p,ll m){
	vec ret(m2);
	ret[0]=1;
	while(m>0){
		if (m&1){
			ret=mul(ret,p);
		}
		p=mul(p,p);
		m>>=1;
	}
	return ret;
}
		
int main(){
	cin>>A>>B;
	REP(i,(ll)A.size()){
		if (A[i]=='1' && B[i]=='1'){
			M++;
		}else if (A[i]=='1' && B[i]=='0'){
			E++;
		}
	}
	omg[0]=1;
	REP(i,(MAX_M2<<1)-1){
		omg[i+1]=omg[i]*968855178%MOD;
	}
	m2=1;
	while(m2<=M){
		m2<<=1;
	}
	fact[0]=1;
	REP(i,(ll)A.size()+1){
		fact[i+1]=fact[i]*(i+1)%MOD;
	}
	vec p(m2);
	REP(i,M+1){
		p[i]=minv(fact[i+1]);
	}
	vec q=ppw(p,E);
	ll ans=0;
	REP(i,M+1){
		ans+=q[i];
		ans%=MOD;
	}
	ans=(ans*fact[E]%MOD*fact[M]%MOD*fact[E+M]%MOD);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3356
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

ll dp[2][100010][3];

int main(){
    int N; cin >> N;
    string S1,S2;
    cin >> S1 >> S2;
    ll ans = 1;
    rep(i,N){
        if(S1[i] == S2[i]){
            int d = 3;
            if(i >= 1){
                if(S1[i-1] == S2[i-1]){
                    d -= 1;
                }
                else d -= 2;
            }
            ans *= d;
            ans %= MOD;
        }
        else{
            if(i >= 1){
                if(S1[i-1] == S2[i-1]){
                    ans *= 2;
                    ans %= MOD;
                }
                else{
                    ans *= 3;
                    ans %= MOD;
                }
            }
            else{
                ans *= 6;
            }
            i++;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 384
# input
n = int(input())
graph = [[] for i in range(n+1)]
for i in range(n-1):
  a, b, c = map(int, input().split())
  graph[a].append([b, c])
  graph[b].append([a, c])
color = [-1 for i in range(n+1)]

# main
que = [1]
color[1] = 0
while len(que) != 0:
  nowv = que.pop(0)
  nowc = color[nowv]
  
  for nx in graph[nowv]:
    if color[nx[0]] != -1:
      continue
    que.append(nx[0])
    if nx[1] % 2 == 1:
      color[nx[0]] = 1 - nowc
    else:
      color[nx[0]] = nowc

# output
for i in range(1, n+1):
  print(color[i])
      

Measured memory_bytes: 45044
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>

using namespace std;

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

    if (s == "AAA" or s == "BBB") {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Manjyu{
	Manjyu(int arg_price){
		price = arg_price;
	}
	bool operator<(const struct Manjyu &arg) const{
		return price < arg.price;
	};
	int price;
};

int main(){

	int M,N;
	scanf("%d %d",&M,&N);
	int table[M+1];

	priority_queue<Manjyu> M_Q;
	int tmp;
	for(int i = 0; i < M; i++){
		scanf("%d",&tmp);
		M_Q.push(Manjyu(tmp));
	}

	table[0] = 0;
	table[1] = M_Q.top().price;
	M_Q.pop();
	for(int i = 2; i <= M; i++){
		table[i] = M_Q.top().price;
		table[i] += table[i-1];
		M_Q.pop();
	}

	int dp[M+1];
	dp[0] = 0;
	for(int i = 1; i <= M; i++)dp[i] = BIG_NUM;

	int num,price;

	for(int loop = 0; loop < N; loop++){
		scanf("%d %d",&num,&price);

		if(num > M){
			dp[M] = min(dp[M],price);
		}else{
			for(int i = M; i-num >= 0; i--){
				if(dp[i-num] != BIG_NUM){
					dp[i] = min(dp[i],dp[i-num]+price);
				}
			}
		}
		for(int i = M-1; i >= 0; i--){
			dp[i] = min(dp[i],dp[i+1]);
		}
	}

	int maximum = 0;
	for(int i = 1; i <= M; i++){
		maximum = max(maximum,table[i]-dp[i]);
	}

	printf("%d\n",maximum);

	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a, b;
  while(cin >> a >> b){
    cout << a + b << endl;
  }
  return 0;
}

Measured memory_bytes: 3112
def main():
    n= int(input())
    ls = [int(x) for x in input().split()]
    bunsi = 1
    for i in range(n):
        bunsi *= ls[i]
    bunbo = 0

    for i in range(n):
        bunbo += bunsi/ls[i]
    print(bunsi/bunbo)

if __name__ =="__main__":
    main()

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

int main()
{
  // int a, b, c;
  // cin >> a >> b >> c;
  // cout << a + b + c << endl;
  // 入力は文字列として与えられているので上記は利用不可

  // string s;
  // int cnr;
  // cin >> s;

  // if (s[1] == '1')
  //   cnr++;
  // if (s[2] == '1')
  //   cnr++;
  // if (s[3] == '1')
  //   cnr++;

  // cout << cnr << endl;
  // 初期化不足と、配列間違い

  string s;
  int cnr;
  cin >> s;

  if (s[0] == '1')
    cnr++;
  if (s[1] == '1')
    cnr++;
  if (s[2] == '1')
    cnr++;

  cout << cnr << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

inline int topbit(unsigned long long x){
	return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
	return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){//popcount%2
	return __builtin_parity(x);
}



template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF=1e15;

const ll mod=1e9+7;

int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> u(m),v(m);
    vector<vector<ll>> to(n);
    rep(i,m){
        cin >> u[i] >> v[i];
        u[i]--;
        v[i]--;
        to[u[i]].push_back(v[i]);
    }
    ll s,t;
    cin >> s >> t;
    s--; t--;
    vector<vector<ll>> d(n,vector<ll>(3,INF));
    vector<ll> ans(n,-1);
    queue<pll> que;
    que.push({s,0});
    d[s][0]=0;
    while(!que.empty()){
        pll x=que.front();
        que.pop();
        for(auto v:to[x.fi]){
            ll r=(d[x.fi][x.se]+1)%3;
            if(d[v][r]!=INF){
                continue;
            }
            d[v][r]=d[x.fi][x.se]+1;
            que.push({v,r});
        }
    }
    
    if(d[t][0]!=INF){
        cout << d[t][0]/3 << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;
}

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

int main () {
    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC";
    else cout << "ABC";
}

Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>

using namespace std;
#define ll          long long
#define endl        "\n"
#define inf         10000000002
#define pb          push_back
#define pf          push_front
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(a)      a.begin(),a.end()
#define mp          make_pair
#define MAX         100
#define yes         cout<<"YES"<<endl
#define no          cout<<"NO"<<endl
#define bye         return 0

ll gcd(ll a, ll b)
{
      if(!b) return a;
      return gcd(b,a%b);
}

int main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      cout.tie(NULL);
      //freopen("inputNew.txt", "r", stdin);

      ll tt;
      cin>>tt;

      ll ac=0;
      ll wa=0;
      ll tle=0;
      ll re=0;
      while(tt--){
            string str;
            cin>>str;
            if(str=="AC") ac++;
            else if(str=="WA") wa++;
            else if(str=="TLE") tle++;
            else re++;
      }

      cout<<"AC x "<<ac<<endl;
      cout<<"WA x "<<wa<<endl;
      cout<<"TLE x "<<tle<<endl;
      cout<<"RE x "<<re<<endl;


      bye;
}


Measured memory_bytes: 3640
#include <stdio.h>

int main(void){
    int n,a[101],i,j,key,k;
    scanf("%d",&n);
    for (i=0; i<n; i++)
        scanf("%d",&a[i]);
    for (k=0; k<n; k++){
        printf("%d",a[k]);
        if(k==n-1)
            break;
        printf(" ");
    }
    printf("\n");
    for (i=1; i<n; i++) {
        key=a[i];
        j=i-1;
        while(j>=0&&a[j]>key){
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=key;
        for (k=0; k<n; k++){
            printf("%d",a[k]);
            if(k==n-1)
                break;
            printf(" ");
        }
        printf("\n");
    }
    


return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = (a), i_len = (b); i < b; ++i)

int main()
{
    int N; ll A, B;
    scanf("%d %lld %lld", &N, &A, &B);
    int X[N+3];
    REP(i, 0, N) scanf("%d", &X[i]);

    ll res = 0;
    REP(i, 1, N) {
        ll dis = X[i] - X[i-1];
        res += min(dis*A, B);
    }
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 640
N = int(input())
A = [int(x) for x in input().split()]
B = [int(y) for y in input().split()]
sum = 0
for i in range(N):
    sum += min(A[i],B[i])
    sum += min(max(B[i]-A[i],0),A[i+1])
    A[i+1] += max(min(A[i]-B[i],0),-A[i+1])
print(sum)


Measured memory_bytes: 25336
#include<iostream>
#include<vector>
#include<list>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
int main() {
	int n, r;
	while (cin >> n >> r&&n != 0 && r != 0) {
		list<int>a[2];
		for (int i = n; i >= 1; i--) {
			a[0].push_back(i);
		}
		int p, c;
		list<int>::iterator it = a[0].begin(),it2;
		for (int z = 0; z < r; z++) {
			cin >> p >> c;
			it = a[0].begin();
			a[1].clear();
			for (int i = 1; i < p; i++) it++;
			for (int i = 0; i < c; i++) {
				a[1].push_back(*it);
				it2 = it;
				it2++;
				a[0].erase(it);
				it = it2;
			}
			a[0].insert(a[0].begin(), a[1].begin(), a[1].end());
		}
		it = a[0].begin();
		cout << (*it) << endl;
	}
} 

Measured memory_bytes: 3084
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if ((b-a)==(c-b)){
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		}
	}	
}


Measured memory_bytes: 23636
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
int a[25][25];
 
 
 
int main(){
  int h,w;
  long long int ans=100000000;
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
    }
  }
  for(int ii=0;ii<h;ii++){
    for(int jj=0;jj<w;jj++){
      long long int k=0;
      for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
          int u=a[i][j]*min(abs(ii-i),abs(jj-j));
k+=u;
        }
      }
        ans=min(ans,k);
    }
  }
    cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3128
a,b = map(int, input().split())
def c(x,r):
    return int(-(-x//r))
a1,a2 = c(a,.08), c(a+1,.08)-1
b1,b2 = c(b,.1), c(b+1,.1)-1
if a1 > b2 or b1 > a2:
    print(-1)
else:
    print(max(a1,b1))

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

#define gc( ) std::getchar( )
#define pc( i ) std::putchar( i )
#define enter '\n'
#define RE cout << "Passing [" << __FUNCTION__ << "] on " << __LINE__ << enter
#define DEBUG(...) for( auto &i: __VA_ARGS__ ) cout << i << " "; cout << enter
using std::make_pair;

template < typename T >
inline T read( )
{
 T x = 0;
 char ch = gc( );
 bool f = 0;
 while( !std::isdigit( ch ) )
 {
  f = ( ch == '-' );
  ch = gc( );
 }
 while( std::isdigit( ch ) )
 {
  x = x * 10 + ( ch - '0' );
  ch = gc( );
 }
 return f ? -x : x;
}

template < typename T >
void print( T x )
{
 if( x < 0 )
 {
  x = -x;
  pc( '-' );
 }
 if( x < 10 )
 {
  pc( x + 48 );
  return;
 }
 print < T > ( x / 10 );
 pc( x % 10 + 48 );
 return ;
}

namespace Solution
{
#define IOS std::ios::sync_with_stdio( false ), std::cin.tie( 0 ), std::cout.tie( 0 )
#define Rep( i, j, k ) for( int i = j; i >= k; --i )
#define rdi( ) read < int > ( )
#define rdl( ) read < long long > ( )
#define pti( i ) print < int > ( i ), putchar( space )
#define ptl( i ) print < long long > ( i ), putchar( space )
#define For( i, j, k ) for( int i = j; i <= k; ++i )
 using std::cin;
 using std::cout;
 using std::endl;
 using std::vector;
 using std::map;
 using std::queue;
 using std::deque;
 using std::set;
 using std::pair;
 const int N = 204001, mod = 1e9 + 7;
 long long ans = 0;
 int n, a[ N ];
 void Fakemain( )
 {
  IOS;
  cin >> n;
  For( i, 1, n )
   cin >> a[ i ];
  int mx = a[ 1 ];
  For( i, 2, n )
  {
   if( a[ i ] > mx )
    mx = a[ i ];
   else
    ans += mx - a[ i ]; 
  }
  cout << ans;
  return;
 }

} // namespace Solution

int main( int argc, char* argv[] )
{
 Solution::Fakemain( );
 return 0;
}

Measured memory_bytes: 4424
//$g++ main.cpp - compile
//$./a.out - run
#include <iostream>
#include <string>
#include <cctype>
#include <stdio.h>
#include <string.h>
using namespace std;

int main(){
    int l = 0, size = 1000, tmp = 0;
    string number;
    int ans[size];
    for(int i = 0; i < size; i++){
        ans[i] = 0;
    }
    do{
        cin >> number;
        for(int i = 0; i < number.length(); i++){
            tmp = number[i] - '0';
            ans[l] += tmp;
        }
        l++;
    }while(number != "0");
    for(int i = 0; i < l - 1; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;
int a[101][2];
int main()
{
    int i,n;
    scanf("%d",&n);
    for(i=1; i<=n; i++)
        scanf("%d%d",&a[i][0],&a[i][1]);
    for(i=3; i<=n; i++)
        if(a[i][1]==a[i][0] && a[i-1][1]==a[i-1][0] && a[i-2][1]==a[i-2][0])
        {
            printf("Yes\n");
            return 0;
        }
    printf("No\n");

    return 0;
}


Measured memory_bytes: 3756
import java.util.Scanner;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Arrays;
class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		HashMap<Integer, Integer> first = new HashMap<Integer, Integer>();
		HashMap<Integer, Integer> second = new HashMap<Integer, Integer>();
		HashMap<Integer, Integer> current = first;
		HashSet<Integer> customers = new HashSet<Integer>();
		int index = 0;
		while (sc.hasNext())
		{
			String str = sc.nextLine();
			if (str.equals(""))
			{
				current = second;
			}
			else
			{
				Scanner setScan = new Scanner(str).useDelimiter("[,\n]");
				int id = setScan.nextInt();
				customers.add(id);
				int date = setScan.nextInt();
				Integer count = current.get(id);
				if (count == null)
				{
					count = 1;
				}
				else
				{
					count += 1;
				}
				current.put(id, count);
			}
		}
		Integer cus[] = customers.toArray(new Integer[0]);
		Arrays.sort(cus);
		for (int i = 0; i < cus.length; i++)
		{
			Integer f = first.get(cus[i]);
			Integer s = second.get(cus[i]);
			if (f != null && s != null)
			{
				System.out.printf("%d %d\n", cus[i], f + s);
			}
		}
	}
}

Measured memory_bytes: 13000
N = gets.to_i
count = 0
k = 1

loop{
    k += 1
    break if k ** 2 > N
    #warn "k:%d" % k
    case N % k
    when 0
        n = N
        n /= k while n % k == 0
        n %= k
        #warn "n:%d" % n
        if n == 1
            count += 1
        end
    when 1
        m = (N - 1) / k
        #warn "->%d" % m
        if m == k
            count += 1
        else
            count += 2
        end
    else
    end
}
if N == 2
    puts count + 1
else
    puts count + 2
end


Measured memory_bytes: 1788
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
	
	public static void main(String input[]){
		int a = 0, b = 0, c=0;
		BufferedReader buffRead = new BufferedReader(new InputStreamReader(System.in));
		String fileline;
		try{
			while ((fileline = buffRead.readLine()) != null){
				int height = Integer.parseInt(fileline);
				if (height > a){
					c = b;
					b = a;
					a = height;		
				}else if (height > b){
					c = b;
					b = height;
				}else if (height > c){
					c = height;
				}else{
					
				}
			}
		} catch (Exception e){
			System.out.println("Failure");
		}
		System.out.println(a);
		System.out.println(b);
		System.out.println(c);
	}	
}

Measured memory_bytes: 16928
n,h = map(int, input().split())
p = 0
q = []
for i in range(n):
    a,b = map(int, input().split())
    p = max(p,a)
    q.append(b)
ans = 0
q.sort(reverse=True)
i = 0
for b in q:
    if b>p:
        ans +=1
        h -= b
        if h<=0:
            break
    else:
        break

if h<=0:
    pass
else:
    ans += -((-h)//p) 
print(ans)

Measured memory_bytes: 7512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define FTEST int testcase;fin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
FO
ull max_d(ull a){
    ull maxx=0;
    while(a){
        maxx=max(maxx,a%10);
        a/=10;
    }
    return(maxx);
}
ull min_d(ull a){
    ull minn=9;
    while(a){
        minn=min(minn,a%10);
        a/=10;
    }
    return(minn);
}
void solve(){

    ll n,d;
    cin>>n>>d;
    int cnt=0;
    while(n--){
        ll x,y;
        cin>>x>>y;
        if(x*x+y*y<=d*d) cnt++;
    }
    cout<<cnt;
    return;
}
int main(){
    IO
   // TEST
    solve();
    return(0);
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
int main(void)
{
  for(;;){
    int n,d;
    cin >> n >> d;
    if(!n&&!d) return 0;
    vector<vector<int> > mis;
    mis.resize(n);
    REP(i,n){
      int m;
      cin >> m;
      mis[i].assign(m+1,0);
      REP(j,m) cin >> mis[i][j+1];
      REP(j,m) mis[i][j+1]+=mis[i][j];
    }
    vector<int> disposed;
    disposed.assign(n,0);
    int mi=0;
    bool flag;
    REP(inf,10000){
      REP(i,n) while(disposed[i]<mis[i].size()-1){
	int tmpmi=INT_MAX;
	flag=true;
	REP(j,n) if(i-j&&mis[i][disposed[i]+1]>mis[j][disposed[j]]+d){
	  flag=false;
	  break;
	}
	if(flag) disposed[i]++;
	else break;
      }
    }
    flag=true;
    REP(i,n) if(disposed[i]!=mis[i].size()-1) flag=false;
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

      int a, b;
    cin >> a >> b;
    cout << max(0, a-2*b);


    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define sz() size()
#define fr first
#define sc second
#define int long long
#define mp make_pair
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
using namespace std;

int n,a[200005],sum;

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    srand(chrono::steady_clock::now().time_since_epoch().count());
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    sort(a+1,a+n+1);
    int cnt = n-2;
    sum = a[n];
    int curr = n-1;
    while(cnt > 0){
        if(cnt >= 2){
            sum += a[curr];
            sum += a[curr];
        }
        else{
            sum += a[curr];
        }
        --curr;
        --cnt;
        --cnt;
    }
    cout << sum << '\n';
}


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

int main(){

    int K, N = 0;
    cin >> K >> N;
    vector<int> A(N);

    int dist_max = 0;
    int dist_N = K;
    rep (i, N) cin >> A[i];
    rep (i, N) {
        int dist_i = 0;
        if (i != 0) dist_i = A[i] - A[i-1];
        dist_N -= dist_i;
        dist_max = max(dist_max, dist_i);
    }
    dist_max = max(dist_max, dist_N);

    cout << K - dist_max << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
using ll=long long;
using namespace std;

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

    ll ans=0;
    for(int i=1;i<N;i++){
        if(A[i-1]>A[i]){
            ans+=A[i-1]-A[i];
            A[i]=A[i-1];
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 4044
#include <iostream>

using namespace std;

void solve(int a, int b, int c) {
	int sum = a + b;
	float prob = 0.0f;
	for (int n = 1; n <= 10; n++) {
		if (n == a || n == b || n == c) continue;
		if (sum + n <= 20) prob += 1.0f / 7.0f;
	}
	if (prob >= 0.5f)
		cout << "YES" << endl;
	else 
		cout << "NO" << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c;
	while (cin >> a >> b >> c)
		solve(a, b, c);
}

Measured memory_bytes: 1184
#include <iostream>

int main(void) {
	std::string S;
	std::cin >> S;
	if (S == "Sunny") {
		std::cout << "Cloudy";
	}
	else if (S == "Cloudy") {
		std::cout << "Rainy";
	}
	else {
		std::cout << "Sunny";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
using namespace std;

#define M 2019
ll mpow(ll x, ll n) {
	for (int i = 0; i < n; i++) {
		x *= n;
		x %= M;
	}

	return M;
}

int ctoi(char c) {
	return c - '0';
}
int main() {
	string S; cin >> S;
	vi temp(2019), curr(2019);
	int x = ctoi(S[0]);
	temp[x]++;
	ll ans = 0;
	for (int i = 1; i < S.size(); i++) {
		vi curr(2019);
		int u = ctoi(S[i]);
		for (int j = 0; j < 2019; j++) {
			int v = (10 * j + u) % M;
			curr[v] = temp[j];
		}
		curr[u]++;
		
		ans += curr[0];

		temp = curr;
	}

	cout << ans << endl;
}

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

int main(){
  int cnt = 0;
  int n;
  string s;
  cin >> n >> s;
  for(int i = 0; i < s.size()-1; i++){
    if(s[i]!=s[i+1])
      	cnt++;
  }
  
  cout << cnt+1;
  return 0;
}


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

using usize = ::std::size_t;
//using u64 = ::std::int_least64_t;
using u64 = int;
static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;

struct edge
{
    int v, weight;
    edge (int v = 0, int weight = 0): v(v), weight(weight) {}
    bool operator<(const edge &e) const { return weight > e.weight; }
};
const int MAXV = 10010;
vector<vector<edge>> edges;
u64 distToTree[MAXV];
int n, E, parent[MAXV], intree[MAXV];

u64 prim(int u)
{
    u64 minSumOfWeight = 0;

    for (int i = 0; i < n; i++)
        parent[i] = -1, intree[i] = 0, distToTree[i] = Inf;

    priority_queue<edge> q;
    q.push(edge(u, 0));

    while (!q.empty()) {
        edge e1 = q.top();
        q.pop();
        if (intree[e1.v]) continue;
        intree[e1.v] = 1, minSumOfWeight += e1.weight;
        for (auto e2 : edges[e1.v])
            if (!intree[e2.v] && distToTree[e2.v] > e2.weight) {
                distToTree[e2.v] = e2.weight;
                parent[e2.v] = e1.v;
                q.push(edge(e2.v, e2.weight));
            }
    }

    return minSumOfWeight;
}
int main(int argc, char *argv[])
{
    
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n >> E;
    edges.resize(n);
    for (int i = 0; i < E; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        edges[u].push_back(edge{v, w});
        edges[v].push_back(edge{u, w});
    }
    
    cout << prim(0) << endl;
    
    return 0;
}



Measured memory_bytes: 6204
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) for(ll i=1;i<=(n);i++)
#define MOD 1000000007
#define int long long
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1e9;



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

    string ans = "";
    REP(i,s.length()) {
        if (i % 2 == 0) ans += s[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 512
n, h = gets.split.map(&:to_i)
ks = n.times.map { gets.split.map(&:to_i) }

max_slash = ks.map { |k| k[0] }.max
ks = ks.select { |k| k[1] >= max_slash }
throws = ks.map { |k| k[1] }.sort.reverse

def throw_times(throws, h)
  d = 0
  i = 0
  until d >= h
    d += throws[i]
    i += 1
  end
  i
end

if throws.reduce(&:+) >= h
  puts throw_times(throws, h)
else
  slash_damage = (h - throws.reduce(&:+))
  puts (slash_damage.to_f / max_slash).ceil + throws.size
end

Measured memory_bytes: 13448
#include <iostream>
#include <bits/stdc++.h>
#define pb push_back
#define ob pop_back
#define xx first
#define yy second
#define dob double
#define int long long int
#define ss size()
using namespace std;
const int M=1e9+7,maxn=100011;
std::vector<int> adj[maxn];
std::vector<int> v1;
int ans,n,k,m,x,y,q,par[maxn],h[maxn],mach[maxn],sk[maxn],dp[101][maxn];
bool mark[maxn];

int32_t main(){
    cin>>n>>m;
    int a[n+1],b[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i]>>b[i];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            dp[i][j]=dp[i-1][j];
            if(j-a[i]>=0)
                dp[i][j]=max(dp[i][j],dp[i-1][j-a[i]]+b[i]);
        }
    cout<<dp[n][m];
    return 0;
}


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


def main():
    a, b, c = map(int, input().split())
    maximum = max(a, b, c)
    summed = sum([a, b, c])

    while True:
        diff = maximum * 3 - summed

        if diff % 2 == 0:
            print(diff // 2)
            exit()
        else:
            maximum += 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>

using namespace std;

int main(){
    map<int,pair<int,int>> mp;
    for (int i=1;i<=3;i++){
        for (int j=1;j<4;j++){
            int a;
            cin >> a;
            mp[a]=make_pair(i,j);
        }
        
    }
    int k[4][4];
    for (int i=1;i<4;i++){
        for (int j=1;j<4;j++) k[i][j]=0;
    }
    int n;
    cin >> n;
    int b[n];
    for (int i=0;i<n;i++) {
        cin >> b[i];
        for(auto itr=mp.begin();itr!=mp.end();itr++){
            if(itr->first==b[i]){
                k[itr->second.first][itr->second.second]=1;
            }
        }
    }
    
    int ans=0;
    //yoko
    for(int i=1;i<4;i++){
        if(k[i][1]==1 && k[i][2]==1 && k[i][3]==1) ans=1;
    }
    //tate
    for(int i=1;i<4;i++){
        if(k[1][i]==1 && k[2][i]==1 && k[3][i]==1) ans=1;
    }
    //naname
    if(k[1][1]==1 && k[2][2]==1 && k[3][3]==1) ans=1;
    if(k[1][3]==1 && k[2][2]==1 && k[3][1]==1) ans=1;
    
    if(ans) cout <<"Yes" << endl;
    else cout << "No" << endl;
    
}



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

using namespace std;

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

    vector<int> x(m);
    for (int i = 0; i < m; ++i)
        cin >> x[i];

    if (n >= m) {
        cout << 0 << '\n';
        return 0;
    }

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

    vector<int> distance(m - 1);
    for (int i = 0; i < m - 1; ++i)
        distance[i] = x[i + 1] - x[i];
    sort(distance.begin(), distance.end(), greater<int>());

    int ans = x[m - 1] - x[0];
    for (int i = 0; i < n - 1; ++i)
        ans -= distance[i];
    cout << ans << '\n';
}


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

int main() {

	int h, w; cin >> h >> w;
	vector<vector<char>> c(h + 2, vector<char>(w + 2, 'e'));
	for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++) cin >> c[i][j];

	vector<vector<int>> L(h + 2, vector<int>(w + 2, 0));
	vector<vector<int>> R(h + 2, vector<int>(w + 2, 0));
	vector<vector<int>> U(h + 2, vector<int>(w + 2, 0));
	vector<vector<int>> D(h + 2, vector<int>(w + 2, 0));

	for (int i = 1; i <= h; i++) {
		int now_x = 0;
		for (int j = 1; j <= w; j++) {						
			if (c[i][j] == '#') now_x = 0;			
			else now_x++;
			L[i][j] = now_x;
		}
	}
	for (int i = 1; i <= h; i++) {
		int now_x = 0;
		for (int j = w; j >= 0; j--) {
			if (c[i][j] == '#') now_x = 0;
			else now_x++;
			R[i][j] = now_x;
		}
	}

	for (int j = 1; j <= w; j++) {
		int now_y = 0;
		for (int i = 1; i <= h; i++) {
			if (c[i][j] == '#') now_y = 0;
			else now_y++;
			D[i][j] = now_y;
		}
	}
	for (int j = 1; j <= w; j++) {
		int now_y = 0;
		for (int i = h; i >= 0; i--) {
			if (c[i][j] == '#') now_y = 0;
			else now_y++;
			U[i][j] = now_y;
		}
	}

	int  ans = 0;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (c[i][j] == '#') continue;
			int tmpAns = max(1, L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3);
			ans = max(ans, tmpAns);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 69972
#include<bits/stdc++.h>
using namespace std;
int main(){
    string N;
    int cnt = 0;
    cin >> N;
    if(N.at(0)=='7'){
        cnt++;
    }
    if(N.at(1)=='7'){
        cnt++;
    }
    if(N.at(2)=='7'){
        cnt++;
    }
    if(cnt >= 1){
    cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;

int main(){

string P;
//for(int i=0;i<3;i++){
while(1){
cin>>P;if(P[0]=='0')break;
int a=0,b=0;
for(int j=0;j<P.size();j++){
if(j>0&&P[j]=='A')a++;
else if(j>0&&P[j]=='B'){b++;}
}

if(a>b)a++;
else if(b>a)b++;

cout<<a<<" "<<b<<endl;
}
return 0;
}

Measured memory_bytes: 1180
#define ll long long
#define vv(t) vector<vector<t>>
#define v(t) vector<t>
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for(int i=0; i<n; ++i)
#define FOR(i, m, n) for(int i=m; i<n; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#include <iostream>
#include <algorithm>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
//cin.tie(0);
//sync_with_stdio(false);
template <class T = int>    T in(){ T x;  cin >> x;   return (x); }

int main(int argc, const char * argv[]) {
    ll mini = 1000000000000001;
    ll peaple;          cin >> peaple;
    rep(i, 5){
        ll tmp;     cin >> tmp;
        mini = min(mini, tmp);
    }
    ll cnt = --peaple / mini;
    cout << cnt + 5 << endl;
    
    return 0;
}


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

using namespace std;
typedef long long ll;

bool solve(vector<pair<int, int>> &v, int N) {
  ll t = 0;
  for (int i = 0; i < N; i++) {
    t += v[i].second;
    if (t > v[i].first) {
      return false;
    }
  }
  return true;
}

int main() {
  int N;
  scanf("%d", &N);
  vector<pair<int, int>> v(N);
  for (int i = 0; i < N; i++) {
    int A, B;
    scanf("%d%d", &A, &B);
    v[i] = make_pair(B, A);
  }
  sort(v.begin(), v.end());
  printf("%s\n", solve(v, N) ? "Yes" : "No");
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 値を取得
		int n = sc.nextInt();
		long ans = 0;

		for (int i = 0; i < n; i++) {
			ans += i;
		}

		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 23764
from scipy.sparse.csgraph import dijkstra
n, m = map(int, input().split())
edges = [[0]*n for i in range(n)]
query = []
ans = 0
for i in range(m):
    a,b,c = map(int, input().split())
    edges[a-1][b-1] = c
    edges[b-1][a-1] = c
    query.append([a-1, b-1, c])
for a,b,c in query:
    edges[a][b] = 0
    edges[b][a] = 0
    dist_ = dijkstra(edges, directed=False, indices=a)[b]
    if dist_ < c:
        ans += 1
    edges[a][b] = c
    edges[b][a] = c
print(ans)

Measured memory_bytes: 18720
#include <bits/stdc++.h>
using namespace std;
const double Rad_to_deg=45.0/atan(1.0);
int main() 
{
    double a,b,h,m;cin>>a>>b>>h>>m;
    double x=abs(6*m-30*h-m/2)/Rad_to_deg;
    double ans=sqrt(a*a+b*b-2*a*b*cos(x));
   // 4.56425719433005567605
    printf("%.20f",ans);
}




Measured memory_bytes: 4224
int_n, int_x = map(int, input().split())

int_m_ar = []
for m in range(int_n):
    int_m_ar.append(int(input()))

int_m_ar.sort()

count = 0
zan = int_x
for m in int_m_ar:
    count += 1
    zan -= m

for m in int_m_ar:
    count = count + int(zan / m)
    zan = zan - (m * int(zan / m))

print(count)



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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    string S, T;
    cin >> S >> T;

    ll SL = S.length();
    ll TL = T.length();

    if(SL < TL){
        cout << "UNRESTORABLE" << endl;
        return 0; 
    }
    ll minid = -1;
    ll minl = INF;
    REP(i, SL-TL+1){
        bool flag = true;
        ll temp = 0;
        REP(j, TL){
            if(S[i+j] == '?'){
                temp++;
                continue;
            }
            if(S[i+j] != '?' && S[i+j] != T[j]){
                flag = false;
                break;
            }
        }
        if(flag){
            // if(temp <= minl){
            //     minl = temp;
            //     minid = i;
            // }
            minid = i;
            minl = temp;
        }
    }
    if(minl == INF){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    for(ll i=0; i<minid; i++){
        if(S[i] == '?'){
            cout << 'a';
        }
        else{
            cout << S[i];
        }
    }
    
    cout << T;
    
    for(ll i=minid+TL; i<SL; i++){
        if(S[i] == '?'){
            cout << 'a';
        }
        else{
            cout << S[i];
        }
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 3608
from collections import defaultdict
n = int(input())
v = list(map(int, input().split()))
o = defaultdict(int)
e = defaultdict(int)
odd_num = 0
even_num = 0
for i, v_one in enumerate(v):
  if i % 2 == 1:
    o[v_one] += 1
    odd_num += 1
  else:
    e[v_one] += 1
    even_num += 1
sorted_o = sorted(o.items(), key=lambda x:-x[1])
sorted_e = sorted(e.items(), key=lambda x:-x[1])
if sorted_o[0][0] != sorted_e[0][0]:
  ans = odd_num - sorted_o[0][1] + even_num - sorted_e[0][1]
elif len(sorted_o) >= 2 and len(sorted_e) >= 2:
  ans1 = odd_num - sorted_o[1][1] + even_num - sorted_e[0][1]
  ans2 = odd_num - sorted_o[0][1] + even_num - sorted_e[1][1]
  ans = min(ans1, ans2)
elif len(sorted_o) >= 2:
  ans = sorted_o[0][1]
elif len(sorted_e) >=2:
  ans = sorted_e[0][1]
else:
  ans = odd_num
print(ans)

Measured memory_bytes: 102520
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var r = cin.nextInt();
            
            Console.WriteLine(r < 1200? "ABC": r < 2800? "ARC":"AGC");
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1e9+7
#define hell2 1e9+9
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cout << (#x) << " is " << (x) << endl
#define INF 1e9
#define LL_MAX 1e18
// memset(array, -1, sizeof(array[0][0]) * row * count)
using namespace std;
 
ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;
}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 
bool isPerfectSquare(long double x) {long double sr = sqrt(x); return ((sr - floor(sr)) == 0); }
 
// max({a, b, c, d})

int main()
{
	int n, k, q;
	cin >> n >> k >> q;

	int a[n+1] = {0};

	for(int i=0;i<q;i++)
	{
		int x;
		cin >> x;

		a[x]++;
	}

	int sum = 0;
	for(int i=1;i<=n;i++)
		sum += a[i];

	int b[n+1] = {0};
	for(int i=1;i<=n;i++)
	{
		b[i] = k - (sum - a[i]);
		// see(b[i]);
	}

	for(int i=1;i<=n;i++)
	{
		if(b[i] > 0) cout << "Yes\n";
		else cout << "No\n";
	}


}

Measured memory_bytes: 1408
S = list(input())

if S[0] == 'A':
    if 1 == S[2:-1].count('C'):
        for s in S:
            if s == 'A' or s == 'C':
                continue
            if s.isupper():
               break
        else:
            print('AC')
            exit()
print('WA')


Measured memory_bytes: 2940