akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <map>
#include <cmath>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <vector>
#include <stdlib.h>
#include <string>
#include <string.h>

using namespace std;

#define ll long long
#define sl(n) scanf("%lld", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)

ll s1, t1, s2, t2, gcd;
bool flag;

ll ex_eucl(ll x, ll y)
{
    if (x%y == 0)
    {
        gcd = y;
        return s1;
    }

    ll q, r, temp;

    q = x/y;
    r = x%y;

    temp = s2 - q*s1;
    s2 = s1;
    s1 = temp;

    temp = t2 - q*t1;
    t2 = t1;
    t1 = temp;

    ex_eucl(y, r);
}

int main ()
{
    ll cs, t, i, j, k, n, x, y, ans, ansb, q, p, e, d, gc;

    while(scanf("%lld %lld", &x, &y) != EOF)
    {
        s2 = t1 = 1;
        s1 = t2 = 0;

        ans = ex_eucl(x, y);

        ansb = (gcd-ans*x)/y;

        printf("%lld %lld\n", ans, ansb);
    }

    return 0;
}

Measured memory_bytes: 1188
//
// Created by 伊東麻沙美 on 2019/10/22.
//

#include<iostream>
#include<algorithm>
#include<stdlib.h>
using namespace std;


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

    int max = A;
    if(max<B){
        max = B;
    }else if(max<C){
        max = C;
    }
    if(max == A){
        cout<<max*10+B+C;
    }else if(max == B){
        cout<<max*10+A+C;
    }else{
        cout<<max*10+A+B;
    }
     return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int n,k,ans=0,l[50];
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&l[i]);
    }
    sort(l,l+n);
    for(int i=0;i<k;i++){
        ans+=l[n-1-i];
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int H, W, A, B;
void print_ans(int a, int b)
{
  vector<vector<int>> ans;
  rep(i, H)
  {
    int zero_number;
    if (i < a)
      zero_number = A;
    else
      zero_number = W - A;
    vector<int> v;
    rep(j, zero_number)
    {
      v.push_back(0);
    }
    rep(j, W - zero_number)
    {
      v.push_back(1);
    }
    ans.push_back(v);
  }

  for (int i = 0; i < W; i++)
  {
    int max_count;
    if (i < b)
      max_count = B;
    else
      max_count = H - B;

    int count = 0;
    rep(j, H)
    {
      if (ans[j][i] == 0)
        count++;
    }

    rep(j, H)
    {
      if (count == max_count)
        break;

      if (ans[j][i] == 1 && count < max_count)
      {
        for (int ni = i + 1; ni < W; ni++)
        {
          if (ans[j][ni] == 0)
          {
            swap(ans[j][i], ans[j][ni]);
            count++;
            break;
          }
        }
      }
      else if (ans[j][i] == 0 && count > max_count)
      {
        for (int ni = i + 1; ni < W; ni++)
        {
          if (ans[j][ni] == 1)
          {
            swap(ans[j][i], ans[j][ni]);
            count--;
            break;
          }
        }
      }
    }
  }

  rep(i, H)
  {
    rep(j, W)
    {
      cout << ans[i][j];
    }
    cout << endl;
  }
}

int main()
{
  cin >> H >> W >> A >> B;
  rep(a, H + 1)
  {
    int denominator = 2 * B - H;
    int numerator = (2 * A - W) * a - (A * H) + (B * W);
    if (numerator % denominator != 0)
      continue;
    int b = numerator / denominator;
    if (b < 0 || b > W)
      continue;
    print_ans(a, b);
    return 0;
  }

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

Measured memory_bytes: 5248
N  = int(input())
A = list(map(int,input().split()))
B  = list(map(int,input().split()))
C  = list(map(int,input().split()))
ans = 0
tmp = -1
for i in range(N):
    num = A[i]
    ans += B[num - 1]
    if num == tmp + 1:
        ans += C[tmp - 1]
    tmp = num
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(int argc, const char * argv[]) {
    char a[100],b[100],c[100];
    int an=0,bn=0,cn=0;
    char player = 'a',winner = 'a';
    printf("");
    scanf("%s",&a);
    scanf("%s",&b);
    scanf("%s",&c);
    while(player=='a'||player=='b'||player=='c'){
        winner = player;
        if(player=='a'){
            player=a[an];
            an++;
        }
        else if(player=='b'){
            player=b[bn];
            bn++;
        }
        else if(player=='c'){
            player=c[cn];
            cn++;
        }
        //printf("%c\n",winner);
    }
    if(winner=='a'){
        printf("A\n");
    }
    if(winner=='b'){
        printf("B\n");
    }
    if(winner=='c'){
        printf("C\n");
    }
    return 0;
}

Measured memory_bytes: 128
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {

//    	File file = new File("src/in.txt");
//    	Scanner sc = new Scanner(file);

    	Scanner sc = new Scanner(System.in);

    	int r = sc.nextInt();
    	System.out.println(r*r);
    }
}

Measured memory_bytes: 21844
s = input()
size = len(s)

def poe(b):
  res = 0
  for i in range(size):
    if b:
      a = '1' if i % 2 == 0 else '0'
    else:
      a = '0' if i % 2 == 0 else '1'
 
    if a != s[i]:
      res+=1

  return res

print(min(poe(True), poe(False)))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int A,B;
  cin >> A >> B;
  if(A < 10 && B < 10) {
    cout << A * B << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc156/tasks/abc156_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  VL xs(N);
  rep(i, N) cin >> xs[i];

  ll res = 1e18;

  rep1(x, 100) {
    ll sum = 0;

    rep(i, N) sum += pow(xs[i] - x, 2);

    chmin(res, sum);
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> pos,neg;
  pos.push_back(0);
  for (int i=0;i<N;i++){
    int x;
    cin >> x;
    if (x<0){
      neg.push_back(-x);
    }
    else {
      pos.push_back(x);
    }
  }
  neg.push_back(0);
  int nm=neg.size(),pm=pos.size();
  int ans=1000000007;
  for (int p=1;p<pm;p++){
    if (K-p+1<=nm){
      ans=min(min(ans,2*pos[p]+neg[nm-1-max(0,K-p)]),2*neg[nm-1-max(0,K-p)]+pos[p]);
    }
  }
  for (int n=1;n<nm;n++){
    if (K-n+1<=pm){
      ans=min(min(ans,2*neg[nm-1-n]+pos[max(0,K-n)]),2*pos[max(0,K-n)]+neg[nm-1-n]);
    }
  }
  cout << ans << endl;
}

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

using LL = long long int;
using uLL = unsigned long long int;
using uint = unsigned int;
using ld = long double;

inline int dist(int a, int b, int k){
    if(b < a){
        return k-a+b;
    }
    return b-a;
}

int main(){
	cin.tie(NULL);
	ios_base::sync_with_stdio(0);
    int n, k;
    cin >> k >> n;
    vector <int> A(n);
    int ans = 1000000000;
    for(auto &x: A) cin >> x;
    for(int i = 0; i < n; i++){
        int j = i+1;
        if(j >= n) j -= n;
        ans = min(ans, k-dist(A[i], A[j], k));
        //cout << dist(A[i], A[j], k) << '\n';
    }
    cout << ans << '\n';
    

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <map>
#include <algorithm>
#include <sstream>

using namespace std;

int main()
{
   int n, p;
   cin>>n>>p;
   string s;
   cin>>s;
   map<int, long long> mod;
   int res=1;
   int tmp=0;
   long long ans=0;
   mod[n+1]=0;

   if(10%p==0){
      for(int i=n-1; i>-1; i--){
         if((s[i]-'0')%p==0){ans+=i+1;}
      }
      cout<<ans<<endl;
   }

   else{
      for(int i=n-1; i>-1; i--){
      int num = s[i]-'0';
      tmp=(tmp+(num*res))%p;
      res=(res*10)%p;
      mod[tmp]++;
      }
      for(int i=0; i<p; i++){
      ans+=((mod[i]*(mod[i]-1))/2);
      }
      ans+=mod[0];
      cout<<ans<<endl;
   }
}


Measured memory_bytes: 1028
from fractions import gcd

N, X = map(int, input().split())
x = list(map(int, input().split()))

x.append(X)
x.sort()

dist = []

for i in range(len(x) - 1):
    dist.append(x[i + 1] - x[i])

ans = 0

for d in dist:
    ans = gcd(ans, d)

print(ans)


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

using namespace std;

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

    for (int i = 0; i < N - 1; i++) {
        sort(A.begin(), A.end());
        A.push_back((A[0] + A[1]) / 2);
        A[0] = INT_MAX;
        A[1] = INT_MAX;
    }

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

    cout << A[0] << endl;
}

Measured memory_bytes: 256
import queue
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
AB = []
for _ in range(N):
    ab = list(map(int, input().split()))
    a,b = ab[0], ab[1]
    AB.append((a,b))
AB.sort()

q = queue.PriorityQueue()
idx = 0
ans = 0
for i in range(1, M+1):
    while True:
        if idx >= N or AB[idx][0] > i:
            break
        b = AB[idx][1]
        q.put((-b, b))
        idx += 1
    if not q.empty():
        ans += q.get()[1]
print(ans)


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

int A[200010];

main() {
    int N;
    cin>>N;
    for (int i=0;i<N;++i) cin>>A[i];
    long long ans=0;
    for (int i=1;i<N;++i) {
        int add=max(0,A[i-1]-A[i]);
        ans+=add;
        A[i]+=add;
    }
    cout<<ans<<endl;
}

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

#define int long long
#define ll long long

int f(string s,int a){
  if(a==0)return -1;
  int res=0,t=1;
  reverse(s.begin(),s.end());
  for(int i=0;i<s.size();i++){
    (res+=t*(s[i]=='1'))%=a;
    (t*=2)%=a;
  }
  return res;
}
int p(int a){
  int res=0;
  while(a){
    if(a&1)res++;
    a>>=1;
  }
  return res;
}
int F(int a){
  int res=0;
  while(a){
    res++;
    a%=p(a);
  }
  return res;
}

ll getPower(ll value,ll shisu,ll mod){
    ll ans = 1;
    ll cnt = shisu;
    while(cnt>0){
        if(cnt%2==1){
            ans = ans * value % mod;
        }
        value = value * value % mod;
        cnt = cnt/2;
    }
    return ans;
}


signed main(){
  int n;cin>>n;
  string s;cin>>s;
  int sum=0;
  for(char p:s)sum+=p=='1';
  int A=f(s,sum+1);
  int B=f(s,sum-1);
  for(int i=0;i<n;i++){
    if(sum==1&&s[i]=='1'){
      cout<<0<<endl;
      continue;
    }
    if(s[i]=='0'){
      int res=A;
      res+=getPower(2,n-i-1,sum+1);res%=sum+1;
      cout<<F(res)+1<<endl;
    }
    else{
      int res=B;
      res-=getPower(2,n-i-1,sum-1);
      res+=sum-1;res%=sum-1;
      cout<<F(res)+1<<endl;
    }
  }
}


Measured memory_bytes: 3868
<?php
  	fscanf(STDIN,"%d %d %d",$a,$b,$k);

	
$r = array();
if(($b-$a+1)<=$k){
  for($i=$a;$i<=$b;$i++){
    $r[]=$i;
  }
}else{

//重なりも考慮しなきゃね
$cc=0;
for($i=$a;$cc<$k;$i++){
  $r[]=$i;
  $cc++;
}

$c=0;
for($i=$b;$c<$k;$i--){
  $r[]=$i;
  $c++;
}
}

$r = array_unique($r);

sort($r);

foreach($r as $a){
  echo $a."\n";
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "cycle"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 924844033;

const int MAXN = 2e3 + 5;

ll f[MAXN];

int dp[2 * MAXN][MAXN][2];

int nxt[2 * MAXN], used[MAXN];

void solve(){
	int n, k;
	scanf("%d%d", &n, &k);
	f[0] = 1;
	REPN(i, 1, n){
		f[i] = (f[i - 1] * i) % MOD;
	}
	int top = 0;
	nxt[top++] = 0;
	REPN(i, 1, n){
		if (!used[i]){
			for(int j = i; j <= n; j += k){
				used[j] = 1;
				nxt[top++] = 1;
			}
			nxt[top - 1] = 0;
			for(int j = i; j <= n; j += k){
				nxt[top++] = 1;
			}
			nxt[top - 1] = 0;
		}
	}
	dp[0][0][0] = 1;
	REP(i, 0, 2 * n){
		REP(j, 0, n){
			if (nxt[i]){
				dp[i + 1][j + 1][1] = (dp[i + 1][j + 1][1] + dp[i][j][0]) % MOD;
			}
		}
		REPN(j, 0, n){
			dp[i + 1][j][0] = (dp[i + 1][j][0] + dp[i][j][0]) % MOD;
			dp[i + 1][j][0] = (dp[i + 1][j][0] + dp[i][j][1]) % MOD;
		}
	}
	
	/*REPN(i, 0, 2 * n){
		printf("%d %d\n", i, nxt[i]);
		REPN(j, 0, n){
			printf("%d ", dp[i][j][0] + dp[i][j][1]);
		}
		putchar('\n');
	}*/
	
	ll ans = 0ll;
	REPN(i, 0, n){
		ll add = ((ll)(dp[2 * n][i][0] + dp[2 * n][i][1]) * f[n - i]) % MOD;
		//printf("%d %lld\n", i, add);
		if (i % 2 == 1){
			ans = (ans + MOD - add) % MOD;
		} else {
			ans = (ans + add) % MOD;
		}
	}
	printf("%lld\n", ans);
}	

int main(){

	//freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();	
	}
}

Measured memory_bytes: 62976
a=int(input())
b=int(input())
c=int(input())

x=int(input())


def only_hun_fif(b,c,m):
    count=0
    for i in range(b+1):
        if m-(i*100)<=50*c and m-(i*100)>=0:
            count+=1

            
    return count
        
count=0

for i in range(a+1):
    if x-i*500<0:
        break
    else:
        count+=only_hun_fif(b,c,x-i*500)
    
print(count)


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	string S;
	cin >> S;

	for (int i = 0; i < S.size() - 1; i++)
	{
		if (S[i] == S[i + 1])
		{
			cout << i + 1 << " " << i + 2;
			return 0;
		}
	}

	for (int i = 0; i < S.size() - 2; i++)
	{
		if (S[i] == S[i + 2])
		{
			cout << i + 1 << " " << i + 3;
			return 0;
		}
	}

	cout << -1 << " " << -1;
	
	return 0;
}

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



#ifndef DEBUG 
#define fprintf (void)
#endif 

double absval(double x);

int main(void){
	int dice[7];
	int cdice[7];
	int i,j;
	char roll;
	char trash;
	
	for(i=1;i<7;i++){
		scanf("%d",&dice[i]);
		cdice[i]=dice[i];
	}
	
	scanf("%c",&trash);
	
	while(scanf("%c",&roll)!=EOF){
		if(roll=='N'){
			dice[1]=cdice[2];
			dice[2]=cdice[6];
			dice[6]=cdice[5];
			dice[5]=cdice[1];
			for(i=1;i<7;i++){
				cdice[i]=dice[i];
			}
		}else if(roll=='E'){
			dice[1]=cdice[4];
			dice[3]=cdice[1];
			dice[6]=cdice[3];
			dice[4]=cdice[6];
			for(i=1;i<7;i++){
				cdice[i]=dice[i];
			}
		}else if(roll=='W'){
			dice[1]=cdice[3];
			dice[3]=cdice[6];
			dice[6]=cdice[4];
			dice[4]=cdice[1];
			for(i=1;i<7;i++){
				cdice[i]=dice[i];
			}
		}else if(roll=='S'){
			dice[1]=cdice[5];
			dice[2]=cdice[1];
			dice[6]=cdice[2];
			dice[5]=cdice[6];
			for(i=1;i<7;i++){
				cdice[i]=dice[i];
			}
		}else if(roll=='\n'){
			break;
		}
		for(i=1;i<7;i++){
			fprintf(stdout,"%d-",dice[i]);
		}
		fprintf(stdout,"\n");
	}
	
	printf("%d\n",dice[1]);
	
	return 0;
}

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

int main() {
	int n, cnt = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int d1, d2;
        cin >> d1 >> d2;
        if(d1 == d2) cnt++;
        else cnt = 0;
        if(cnt == 3) {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

struct Sieve {
    int n;
    vector<int> f, primes;
    Sieve(int n=1):n(n), f(n+1) {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; ++i) {
            if (f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = i*i; j <= n; j += i) {
                if (!f[j]) f[j] = i;
            }
        }
    }
    bool isPrime(int x) { return f[x] == x;}
    vector<int> factorList(int x) {
        vector<int> res;
        while (x != 1) {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<P> factor(int x) {
        vector<int> fl = factorList(x);
        if (fl.size() == 0) return {};
        vector<P> res(1, P(fl[0], 0));
        for (int p : fl) {
            if (res.back().first == p) {
                res.back().second++;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
};

int main(){
    int n;cin >>n;
    ll ans=0;
    auto sieve=Sieve(n);
    for (int i = 1; i <=n; ++i) {
        ll now=i;
        for(auto p:sieve.factor(i)){
            now*=(p.second+1);
        }
        ans+=now;
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 46524
#include<iostream>
#include <bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;


int main(){
/*    long long tmp;
 __int128 A;
    double B;
    cin >> tmp >> B;
    A = tmp;
    __int128 Bint = (__int128 )(B*100.0);
    __int128 ans1 = A*(Bint/100);
    __int128 ans2 = A*(Bint%100-Bint%10)/10; 
    __int128 ans3 = A*(Bint%10);   

    long long ans = ans1+(ans1%10+ans2)/10+(ans1%100+ans2%10)/100;
    */
   long double A,B;
   cin >> A >> B;
   long long ans = (long long)A*B;


    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3792
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

vi a(5);

int f(){
    int t = a[0];
    rep(i,1,5){
        //t++;
        while(t%10 != 0)t++;
        t += a[i];
    }

    ret t;
}

int main(){
    inrep(5,a);

    int ans = inf;
    do{
       // rep(i,0,5)PS(a[i]);
       // cout << endl;
		ans = min(ans,f());
		 	
	}while(next_permutation(a.begin(),a.end()));

	P(ans);
	return  0;
}

Measured memory_bytes: 256
from collections import deque
n = int(input())
a = list(map(int, input().split()))
a.sort()
a = deque(a)

left = a.popleft()
right = a.pop()

ans = []
for i in a:
    if i > 0:
        ans.append((left, i))
        left -= i
    else:
        ans.append((right, i))
        right -= i
else:
    ans.append((right, left))

print(right-left)
for x, y in ans:
    print(x, y)


Measured memory_bytes: 19524
import java.util.Scanner;

public class Main {
  private static String DELIMITER = " ";

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String rowLine = scanner.nextLine();
    String rowLineToFill = scanner.nextLine();
    String[] rowLineArray = rowLine.split(DELIMITER);
    String[] rowLineToFillArray = rowLineToFill.split(DELIMITER);
    int rowNum = Integer.valueOf(rowLineArray[0]);
    int lineNum = Integer.valueOf(rowLineArray[1]);
    int rowToFillNum = Integer.valueOf(rowLineToFillArray[0]);
    int lineToFillNum = Integer.valueOf(rowLineToFillArray[1]);
    int notFilled = (rowNum - rowToFillNum) * (lineNum - lineToFillNum);
    System.out.println(notFilled);
  }
}

Measured memory_bytes: 23124
#include<stdio.h>

#define MAX 2000000

int H,A[MAX+1];

void maxHeapify(int i){
  int l,r,largest,C;
  l=2*i;
  r=2*i+1;

  if(l<=H&&A[l]>A[i])largest=l;
  else largest = i;
  if(r<=H&&A[r]>A[largest])largest=r;

  if(largest!=i){
    C=A[i];
    A[i]=A[largest];
    A[largest]=C;
    maxHeapify(largest);
  }
}

int main(){
  int i;

  scanf("%d",&H);

  for(i=1;i<=H;i++)scanf("%d",&A[i]);
  for(i=H/2;i>=1;i--)maxHeapify(i);
  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }

  printf("\n");
  
  return 0;
}




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

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


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

    // 1 <= k <= N where kの先頭の桁がiに等しく、末尾の桁がjに等しいものの数
    vector<vector<int>> c(10, vector<int>(10));
    FOR(i, 1, N+1){
        string s = to_string(i);
        ++c[s.front()-'0'][s.back()-'0'];
    }
    int ans = 0;
    REP(i, 10){
        REP(j, 10) ans += c[i][j]*c[j][i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		
		if(a.charAt(a.length() - 1) == b.charAt(0) && b.charAt(b.length() - 1) == c.charAt(0)) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 21972
a_price, b_price, ab_price, a_want, b_want = list(map(int, input().split()))
ab_price = ab_price * 2
anb = a_price + b_price
ans = 0

def return_small_num(a, b):
	return min(a, b)


def remaining_amount_list(a, b, a_price, b_price):
	if a > b:
		return [a - b, a_price]
	else:
		return [b - a, b_price]


which = remaining_amount_list(a_want, b_want, a_price, b_price)

small_num = return_small_num(a_want, b_want)

# 絶対的な条件として、abの値段よりも単体の値段の方が小さいのであれば単体で全て賄うべきである
if anb <= ab_price:
	ans = a_want * a_price + b_want * b_price
# abで揃えたほうが、単体で購入するよりも安いのであれば必要最低限の数まではabで購入する
elif anb > ab_price:
	ans = ab_price * small_num
	# ここから更に条件分岐をする
	# 小さい方の数まで。つまり最低限の購入枚数を揃えたなら、その先は、単体で購入したほうがやすいかもしれない
	# その為、remaining_amount_list()を利用して条件分岐を行おう
	# whichの配列の1番目には値段がある。この値段がabより小さいならば、whichの０番目の個数分購入する
	# そうでないならwhichの０番目分をabで購入する
	remaining = which[0]
	amount = which[1]
	if amount <= ab_price:
		ans = ans + remaining * amount
	else:
		ans = ans + remaining * ab_price

print(ans)

Measured memory_bytes: 3064
/*
f[i] = 1 + \frac 1{deg_i} \sum_{i \rightarrow j} f[j]

设 $f_1 = a_if_i + b_i$。这里 $b_i$ 为 $i + 1 \leq j \leq n$ 的贡献。 

$O(NM)$ 枚举解 $a_i, b_i$，暴力枚举断边随便算一下即可。

时间复杂度：$O(NM)$。 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>

const int MAXN = 600 + 10;

int to[MAXN][MAXN], deg[MAXN];
double f[MAXN];
double fa[MAXN], fb[MAXN];
double pa[MAXN], pb[MAXN];

int main() {
	int i, j;
	int n, m;
	int u, v, t;
	double fx;
	double ans;
	
	scanf("%d %d", &n, &m);
	for(i=1; i<=m; i++) {
		scanf("%d %d", &u, &v);
		deg[u]++;
		to[u][deg[u]] = v;
	}
	
	for(u=n - 1; u; u--) {
		for(i=1; i<=deg[u]; i++) 
			f[u] += f[to[u][i]];
		f[u] = 1 + f[u] / deg[u];
	}
	
	ans = f[1];
	for(t=1; t<n; t++) {
		memset(pa, 0, sizeof(pa));
		memset(pb, 0, sizeof(pb));
		for(u=n-1; u; u--) {
			if(u == t) {
				pa[u] = 1;
				pb[u] = 0;
				continue;
			}
			pa[u] = 0;
			pb[u] = 1;
			for(i=1; i<=deg[u]; i++) {
				if(to[u][i] > t) 
					pb[u] += f[to[u][i]] / deg[u];
				else {
					pa[u] += pa[to[u][i]] / deg[u];
					pb[u] += pb[to[u][i]] / deg[u];
				}
			}
		}
		fa[t] = pa[1];
		fb[t] = pb[1];
	}
	
//	printf("f = ");
//	for(u=1; u<=n; u++)
//		printf("%lf ", f[u]);
//	putchar('\n');
	
//	for(u=1; u<n; u++)
//		printf("# %d %lf %lf\n", u, fa[u], fb[u]);
	
	for(u=1; u<n; u++){
		if(deg[u] > 1) {
			for(i=1; i<=deg[u]; i++) {
				fx = 0;
				for(j=1; j<=deg[u]; j++) 
					if(i^j) 
						fx += f[to[u][j]];
				fx = 1 + fx / (deg[u] - 1);
//				printf("# %d->%d %lf\n", u, to[u][i], fx);
				ans = std::min(ans, fa[u] * fx + fb[u]);
			}
		}
	}
	printf("%.12lf\n", ans);
	return 0;
} 

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, k, a[200500];

bool check(ll x) {
	ll cnt = 0;
	for (int i = 0; i < n; i++) {
		cnt += a[i] / x - (a[i] % x == 0);
	}
	return cnt <= k;
}

void solve() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll l = 0, r = 1e9;
	while (r - l > 1) {
		ll mid = l + (r - l) / 2;
		if (check(mid)) r = mid;
		else l = mid;
	}
	cout << r;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++) {
		solve();
	}
}

Measured memory_bytes: 5108
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printVerdict(verdict) cout << (verdict ? "YES": "NO") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)
 
const int mod = 1e9 + 7; 
 
template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) { cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n'; }
template <class T1, class T2>
void printPair(pair<T1, T2> p) { cout << p.first << " " << p.second  << '\n'; }
template <class T>
void printArray(vector<T> arr) { for (int i = 0; i<size(arr); i++) {cout << arr[i] << " ";} cout << '\n'; }

ll evaluate(int curr, int mask, vector<vector<ll>> &dp, vector<vector<int>> &grid) {
	if (curr >= size(grid)) return 1;
	if (dp[curr][mask] != -1) return dp[curr][mask];
	ll ret = 0;
	for (int i =0; i<size(grid); i++) {
		if (!(mask&(1<<i)) && grid[curr][i]) {
			ret += evaluate(curr+1, mask|(1<<i), dp, grid);
			ret %= mod;
		}
	}
	dp[curr][mask] = ret;
	return ret;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	vector<vector<int>> grid(n, vector<int>(n));
	for (int i = 0; i<n; i++) {
		for (int j = 0; j<n; j++) cin >> grid[i][j];
	}
	vector<vector<ll>> dp(n, vector<ll>(1<<n, -1));
	ll ret = evaluate(0, 0, dp, grid);
	cout << ret << '\n';
}


Measured memory_bytes: 363796
import scala.io.StdIn.readLine

object Main {

  def main(args: Array[String]) = {
    var n = readLine.split(" ").map(_.toInt)

    while( n(0) != 0 || n(1) != 0) {
      for(i <- 0 to n(0)-1) {
        val str =  "#."*n(1)
        if(i%2==0)
          println(str.take(n(1)))
        else
          println(str.drop(1).take(n(1)))
      }
      println()
      n = readLine.split(" ").map(_.toInt)
    }
  }
}

Measured memory_bytes: 45488
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;

#define rep(i,n) for(int i=0;i<(n);++i)
#define MAXN 1010
#define linf 8223372036854775808

//d,edge,g
lint d[MAXN];
struct edge{ int to;lint cost; };
vector<edge> g[MAXN];

bool bellmanford(int n,int s){
	d[s]=0;
	rep(i,n){
		rep(v,n){
			for(edge &e:g[v])if(d[v]!=linf&&d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				if(i==n-1&&e.to==n-1)return 1;
            	//なぜ条件(e.to==n-1)が必要かというと、
            	//負の閉路が存在したとしても
            	//負の閉路を通った後ゴールの頂点にたどり着けるとは限らないから。
            	//逆にこれを付けるとなぜACかというと、
            	//負の閉路を通ったルート?がゴールの頂点にたどり着けるなら
             	//その負の閉路からゴールまでのすべての頂点は更新し続けられるから。
			}
		}
	}return 0;
}

int main(){
	int n,m;cin>>n>>m;
	int a,b;lint c;
	fill(d,d+n,linf);
	rep(i,m){
		cin>>a>>b>>c;--a;--b;
		g[a].push_back({b,-c});
	}
	if(bellmanford(n,0))cout<<"inf";
	else cout<<-d[n-1];
	return 0;
}

Measured memory_bytes: 384
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 10 ** 20
for i in range(2 ** n):
    total = 0
    data = a.copy()
    highest = a[0] - 1
    cnt = 0
    for j in range(n):
        if i >> j & 1:
            cnt += 1

    if cnt == k:
        for j in range(n):
            if i >> j & 1:
                if highest >= data[j]:
                    total += highest - data[j] + 1
                    data[j] = max(highest + 1, data[j])
            highest = max(highest, data[j])
        ans = min(ans, total)
        #print(data)
    
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int x;
  cin >> x;
  if(x >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;
return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    sort(all(vec));
    bool ans = true;
    rep(i,N - 1){
        if (vec[i] == vec[i + 1]) ans = false;
    }
    if (ans) cout << "YES" << endl;
    else cout << "NO" << endl;
}



Measured memory_bytes: 3972
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;
#define input(N) cin >> N ;


signed main() {
	int N, ans = 0;

	cin >> N;
	vector<ll> L(N);
	REP(i, N) {
		cin >> L[i];
	}
	vector<ll> S(3);
	for (int i = 0; i<N; i++) {
		for (int j = i; j<N; j++) {
			for (int k = j; k<N; k++) {
				if (i != j&&j != k&&k != i && L[i] != L[j] && L[j] != L[k] && L[k] != L[i]) {
					S[0] = L[i];
					S[1] = L[j];
					S[2] = L[k];
					sort(S.begin(), S.end());
					if (S[0] + S[1]>S[2]) {
						ans += 1;
					}
				}
			}
		}
	}

	answer(ans);
	system("pause");
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main()
{
  int n;cin>>n;
  vector<int> c(n);
  int i,j;
  for(i=0;i<n;i++)cin>>c.at(i);
  sort(c.begin(),c.end());
  reverse(c.begin(),c.end());
  long long ans=0;
  long long ks=2;
  for(i=0;i<n;i++)
  {
    ans=(ans+(c.at(i)*ks)%MOD)%MOD;
    ks++;
  }  
  for(i=0;i<n-1;i++)ans=ans*4%MOD;
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define MAX_V 300000
//lower_bound使え
 
 //[len,position]

struct edge{int to, rev;};
vector<edge> G[MAX_V];
int GA[MAX_V];
int GB[MAX_V];
bool isA[MAX_V];

void add_edge(int from, int to){
	G[from].push_back((edge){to,(int)G[to].size()});
	if(isA[to]){
		GA[from]++;
	}else{
		GB[from]++;
	}
	G[to].push_back((edge){from,(int)G[from].size() - 1});
	if(isA[from]){
		GA[to]++;
	}else{
		GB[to]++;
	}
}

bool delete_edge(int from, edge e){
	GA[from] = 0;
	GB[from] = 0;
	if(from == e.to){
		return false;
	}
	/*cout<<"a"<<endl;
	*G[e.to].erase(G[e.to].begin() + e.rev);
	cout<<"b"<<endl;*/
	G[e.to][e.rev].to = e.to;
	if(isA[from]){
		GA[e.to]--;
		if(GA[e.to] == 0){
			return true;
		}
	}else{
		GB[e.to]--;
		if(GB[e.to] == 0){
			return true;
		}
	}
	return false;
}

int main(void){
	int n,m;
	int a,b;
	string s;
	cin>>n>>m;
	cin>>s;
	rep(i,n){
		isA[i+1] = s[i] == 'A';
		GA[i+1] = 0;
		GB[i+1] = 0;
	}
	rep(i,m){
		cin>>a>>b;
		add_edge(a,b);
	}

	queue<int> que;
	reps(i,n){
		if(GA[i] == 0 || GB[i] == 0){
			que.push(i);
		}
	}
	while(que.size() > 0){
		//cout<<endl;
		/*reps(i,n){
			cout<<i<<" "<<GA[i]<<" "<<GB[i]<<endl;
		}*/

			//cout<<11<<" ";
			/*rep(j,G[11].size()){
				cout<<G[11][j].to << " ";
			}
			cout<<endl;
		
		cout<<endl;*/
		int node = que.front();
		que.pop();
		rep(i,(int)G[node].size()){
			/*if(node == 11){
				cout<<G[node][i].to<<" ";
				rep(j,G[12].size()){
					cout<<G[12][j].to << " ";
				}
				cout<<endl;
			}*/
			bool add = delete_edge(node, G[node][i]);
			if(add){
				que.push(G[node][i].to);
			}
		}
		//cout<<node<<endl;
		
	}
	reps(i,n){
		//cout<<i<<" "<<GA[i]<<" "<<GB[i]<<endl;
		if(GA[i] > 0 && GB[i] > 0){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 16644
#include <bits/stdc++.h>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define def(i,x,y)for(int i=x;i>=y;--i)
#define pb push_back
#define fi first
#define se second
#define SZ(x) (int)x.size()
typedef vector<int> vint;
const int N=410;
const int mod=998244353;
int n,h[N],C[N][N],mi2[N];
void inc(int&a,int b){a+=b;if(a>=mod)a-=mod;}
int mul(int a,int b){return 1LL*a*b%mod;}
pair<vint,vint> dfs(int x,int y,int d){
	if(x>y){
		vint s;s.pb(1);
		return make_pair(s,s);
	}
	int id=0;
	ref(i,x,y)if(id==0||h[i]<h[id])id=i;
	if(h[id]==d){
		int la=x,tot=-1;
		vint s2,s1,stmp;
		ref(i,x,y+1)if(i>y||h[i]==h[id]){
			pair<vint,vint> ss=dfs(la,i-1,d+1);
			if(la==x){
				s1=ss.fi;s1.resize(y-x+2);
				s2=ss.se;s2.resize(y-x+2);
			}else{
				stmp.clear();stmp.resize(y-x+2);
				ref(j,0,y-x+1)if(s1[j])ref(k,0,i-la)if(ss.fi[k])
					inc(stmp[j+k],mul(s1[j],ss.fi[k]));
				s1=stmp;
				stmp.clear();stmp.resize(y-x+2);
				ref(j,0,y-x+1)if(s2[j])ref(k,0,i-la)if(ss.se[k])
					inc(stmp[j+k],mul(s2[j],ss.se[k]));
				s2=stmp;
			}
			la=i+1;tot++;
		}
		vint sa=s2;
		def(i,y-x+1,tot)s1[i]=s1[i-tot];
		def(i,tot-1,0)s1[i]=0;
		ref(i,0,y-x+1)if(s1[i])ref(j,0,y-x+1-i){
			int w=mi2[i]-(j==0);
			inc(sa[i+j],mul(s1[i],mul(w,C[y-x+1-i][j])));
		}
		vint sb=s2;
		ref(i,0,y-x+1)if(s2[i])ref(j,0,y-x+1-i){
			int w=mi2[i]-(j==0);
			inc(sb[i+j],mul(s2[i],mul(w,C[y-x+1-i][j])));
		}
		return make_pair(sa,sb);
	}else{
		pair<vint,vint> ss=dfs(x,y,d+1);
		vint sa=ss.se,sb=ss.se;
		ref(i,0,y-x+1)ref(j,0,y-x+1-i){
			int w=mi2[i]-(j==0);
			inc(sa[i+j],mul(ss.fi[i],mul(w,C[y-x+1-i][j])));
			inc(sb[i+j],mul(ss.se[i],mul(w,C[y-x+1-i][j])));
		}
		return make_pair(sa,sb);
	}
}
int main(){
	cin>>n;
	ref(i,1,n)cin>>h[i];
	mi2[0]=1;
	ref(i,1,n)mi2[i]=mi2[i-1]*2%mod;
	ref(i,0,n)C[i][0]=1;
	ref(i,1,n)ref(j,1,n)C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	pair<vint,vint> ans=dfs(1,n,1);
	cout<<ans.fi[n]<<endl;
}

Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int main()
{
    int n,cnt=0,max=0;
    long long int h,g=0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> h;
        if(g>=h) cnt++;
        else if(g!=0){
            if(max<cnt)max=cnt;
            cnt=0;
        }
        g=h;
    }
    if(max<cnt)max=cnt;
    cout << max;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int a,b,c,count_five=0,count_seven=0;
    scanf("%d%d%d",&a,&b,&c);
     if(a==5)
       count_five++;
     if(b==5)
       count_five++;
     if(c==5)
       count_five++;
     if(a==7)
       count_seven++;
     if(b==7)
       count_seven++;
     if(c==7)
       count_seven++;
     if(count_five==2&&count_seven==1)
       printf("YES");
     else printf("NO");
       
    return 0;
}


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

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

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

    bool evan = true;
    int c = 0;
    while(evan) {
        // 偶数かどうかチェック
        for(int i = 0; i < N; i++) {
            if(A[i] % 2 != 0) {
                evan = false;
                break;
            }
        }

        if(!evan) {
            break;
        }
      
        for(int i = 0; i < N; i++) {
            A[i] = A[i] / 2;
        }

        c++;
    }

    cout << c << endl;
}


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

using namespace std;

// O(log(small10)N)
int countDigits(int64_t num) {
    int count = 0;
    while (num > 0) {
        num /= 10;
        count++;
    }
    return count;
}

int main() {
    int64_t N;  // 1 <= N <= 10^10
    cin >> N;

    vector<int64_t> divisors;  // 約数の配列

    // 考え方メモ
    // A * B == N -> B == N / A
    // 約数を見つける際に、どこまで数を調べればよいか？
    // 交換法則が成り立つから、約数を求める場合、A <= Bと置くことができる。
    // A <= B の時、A * B = N -> A^2 <= N -> A <= sqrt(N)

    // O(N) -> 10^10 -> ボトルネック
    // O(sqrt(N)) -> 10^5 < 10^8 -> ボトルネック解消
    for (int64_t i = 1; i <= sqrt(N); i++) {  // 約数を求める
        bool canDvide = !(N % i);
        if (canDvide) divisors.push_back(i);
    }

    int64_t minAbsDiff = N;
    int64_t minA = N;
    int64_t minB = N;

    // O(N) よりは少ない
    for (int64_t i = 0; i < divisors.size(); i++) {  // 絶対値の差最小の(A, B)を見つける
        if (minAbsDiff > abs(divisors.at(i) - (N / divisors.at(i)))) {
            minAbsDiff = abs(divisors.at(i) - (N / divisors.at(i)));
            minA = divisors.at(i);
            minB = N / divisors.at(i);
        }
    }

    int res = max(countDigits(minA), countDigits(minB));

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  int a,b;
  cin>>a>>b;
  cout<<a*b;
}

Measured memory_bytes: 3628
#include <iostream>
#include <queue>
#include <algorithm>
#include <set>

using namespace std;

const int H = 5, W = 4;

inline int countZero(const string &str) {
  int ret = 0;
  for(int i=0; i<H*W; i++) {
    ret += str[i] == '0';
  }
  
  return ret;
}

void rearrange(string &str) {
  int pos = 0;
  for(int i=0; i<H*W; i++) {
    if(str[i] == '0') continue;
    char ch = str[i];
    str[i] = '0';
    str[pos++] = ch;
  }
}

int main() {
  
  int Tc;
  cin >> Tc;
  
  while(Tc--) {
    
    string initial;
    for(int i=0; i<H; i++) {
      for(int j=0; j<W; j++) {
        char ch; cin >> ch;
        initial += ch;
      }
    }
    
    int ans = 0;
    
    set<string> used;
    queue<string> Q;
    Q.push(initial);
    while(!Q.empty()) {
      const string now = Q.front(); Q.pop();
      ans = max(ans, countZero(now));
      for(int pos=0; pos<H*W; pos++) {
        if(now[pos] == '0') continue;
        int x = pos%W, y = pos/W;
        for(int k=0; k<=1; k++) {
          for(int l=-1; l<=1; l++) {
            if(k == 0 && l == 0) continue;
            const int ny = y+k, nx = x+l;
            if(nx<0 || W<=nx || ny<0 || H<=ny) continue;
            const int npos = ny*W+nx;
            if(now[pos] != now[npos]) continue;
            string next;
            /*
            for(int i=0; i<H*W; i++) {
              if(i == pos || i == npos) continue;
              next += now[i];
            }
            next += "00";
            */
            
            next = now; next[pos] = next[npos] = '0'; rearrange(next);
            
            if(used.count(next)) continue;
            used.insert(next);
            Q.push(next);
          }
        }
      }
    }
    cout << 20-ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1332
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr<<"x ="<<x<<endl
int n;
int main() {
  ios::sync_with_stdio(false);
  cin>>n;LL ret=0;
  for(int i=1;i<=n;i++){
    ret+=1ll*(n-i+2)*(n-i+1)/2;
  }
 // debug(ret);
  for(int i=1;i<n;i++){
    int s,t;
    cin>>s>>t;
    if(s>t)swap(s,t);
    ret-=1ll*s*(n-t+1);
  }
  cout<<ret<<'\n';
  return 0;
}

Measured memory_bytes: 3576
#include <stdio.h>
#define MAX 2000

int check(int, int);

int n, q, A[MAX];

int main(){
    int i, m[MAX];

    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &A[i]);
    }

    scanf("%d", &q);
    for(i = 0; i < q; i++){
        scanf("%d", &m[i]);
    }

    for(i = 0; i < q; i++){
        if(check(0, m[i]) == 0){
            printf("yes\n");
        }
        else if(check(0, m[i]) == 1){
            printf("no\n");
        }
    }
return 0;
}

int check(int i, int m){
    if(m == 0)return 0;

    if(i >= n)return 1; 

    if(check(i+1, m) == 0)return 0;

    return check(i+1, m - A[i]);
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  string s;
  cin >> n >> s;
  int red=0, blue=0;
  for(int i=0;i<n;i++){
    if(s[i]=='R')
      red++;
    else
      blue++;
  }
  if(red>blue)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

ll N, T, Q;
ll A[100100], D[100100];
ll B[100100];

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

    std::cin >> N >> T >> Q;

    for(int i=1;i<=N;++i){
        std::cin >> A[i] >> D[i];
    }

    int i = 1;
    while(i <= N && D[i] == 2){
        B[i] = A[i] - T;
        ++i;
    }

    for(int j=i;i<=N;){
        while(j <= N && D[j] == 1){
            ++j;
        }

        if(j <= N){
            ll x = (A[j-1] + A[j]) / 2;
            while(i < j){
                B[i] = min(A[i] + T, x);
                ++i;
            }

            while(j <= N && D[j] == 2){
                B[j] = max(A[j] - T, x);
                ++j;
            }

            i = j;
        }else{
            while(i <= N){
                B[i] = A[i] + T;
                ++i;
            }
        }
    }

    for(int i=0;i<Q;++i){
        int X;
        std::cin >> X;

        std::cout << B[X] << std::endl;
    }
}



Measured memory_bytes: 5436