akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cassert>
#include<iostream>
#include<algorithm>

using namespace std;

#define Whats(x) cout<<#x<<" is "<<(x)<<endl
#define Divhim() cout<<">>>>>>>>>>>>>>>"<<endl
#define Divher() cout<<"<<<<<<<<<<<<<<<"<<endl
#define Oops() cout<<"!!!!!!!!!!!!!!!"<<endl

template<typename T> bool GetMin(T &a,T b)
{
	return ((a<=b)?false:(a=b,true));
}

template<typename T> bool GetMax(T &a,T b)
{
	return ((a>=b)?false:(a=b,true));
}

/*
	 -<Unlimited Blade Works>-
 */

#define Pir pair<int,int>
const int N=233;

int n;

int main()
{
	scanf("%d",&n);
	if(n==3){puts("2\n1 3\n2 3");return 0;}
	if(n==4){puts("4\n1 2\n1 3\n4 2\n4 3");return 0;}
	if(n&1)
	{
		printf("%d\n",n*2-2);
		for(int i=1;i+i<n-1;++i)
		{
			printf("%d %d\n%d %d\n",i,i+1,i,n-i-1);
			printf("%d %d\n%d %d\n",n-i,i+1,n-i,n-i-1);
		}
		printf("%d %d\n",n/2,n);
		printf("%d %d\n",n/2+1,n);
		printf("%d %d\n%d %d\n",n,1,n,n-1);
	}
	else
	{
		printf("%d\n",n*2);
		for(int i=1;i+i<n;++i)
		{
			printf("%d %d\n%d %d\n",i,i+1,i,n-i);
			printf("%d %d\n%d %d\n",n-i+1,i+1,n-i+1,n-i);
		}
		printf("%d %d\n%d %d\n",n/2,1,n/2,n);
		printf("%d %d\n%d %d\n",n/2+1,1,n/2+1,n);
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
using namespace std;
void read(int &x){
    char ch;bool ok;
    for(ok=0,ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')ok=1;
    for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());if(ok)x=-x;
}
#define rg register
const int maxn=1e7+10,mod=998244353;
int n,fac[maxn],inv[maxn],g[maxn],ans;
int mul(int x,int y){return 1ll*x*y-1ll*x*y/mod*mod;}
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int del(int x,int y){return x-y<0?x-y+mod:x-y;}
int mi(int a,int b){int ans=1;while(b){if(b&1)ans=mul(ans,a);b>>=1,a=mul(a,a);}return ans;}
int C(int n,int m){return mul(fac[n],mul(inv[m],inv[n-m]));}
int main(){
    read(n);fac[0]=inv[0]=g[0]=1;
    for(rg int i=1;i<=n;i++)fac[i]=mul(fac[i-1],i),g[i]=mul(g[i-1],2);
    inv[n]=mi(fac[n],mod-2);
    for(rg int i=n-1;i;i--)inv[i]=mul(inv[i+1],i+1);
    for(rg int i=n/2+1;i<=n;i++)
	ans=add(ans,mul(C(n,i),g[n-i]));
    printf("%d\n",del(mi(3,n),mul(ans,2)));
}


Measured memory_bytes: 117376
/* it was worth becoming a chemist */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long unll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<int> vi;
typedef vector<long long> vll;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define NAME "puts"
#define F first
#define S second

const ll INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const db EPS = (db) 1e-9;
const db pi = acos(-1.0);
const int MAXN = 1e5 + 5;

string s;
int ct, res = inf;
bool used[35];

bool check(int n) {
	for (int i = 0; i < n - 1; i++) {
		if (s[i] != s[i + 1]) return 0;
	}
	return 1;
}

void f(char x) {
	int n = sz(s);
	while (n) {
		//~ for (int i = 0; i < n; i++) {
			//~ cout << s[i];
		//~ }
		//~ cout << ' ';
		if (check(n)) break;
		for (int i = 0; i < n - 1; i++) {
			if (s[i + 1] == x) {
				s[i] = x;
			}
		}
		n--;
		ct++;
	}
}

int main() {	
 
	cin >> s;
	
	for (auto i : s) {
		used[i - 'a'] = 1;
	}
	
	for (char i = 'a'; i <= 'z'; i++) {
		if (used[i - 'a'] == 0) continue;
		//~ cout << i << ": ";
		string t = s;
		f(i);
		//~ cout << '\n';
		res = min(res, ct);
		ct = 0;
		s = t;
	}
	
	cout << res;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int K, X;

	cin >> K >> X;

	if (500 * K >= X) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


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


using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(n) n.begin(),n.end()
#define eb emplace_back
#define endl "\n"

const ll maxn=3e5+50;

const ll maxx=1e13;
const ll mod=1000000007;
const ll mod1=998244353;
vector<ll> adj[maxn];

ll a[maxn];
ll b[maxn];
ll c[maxn];
ll d[maxn];
ll e[maxn];
ll n, m, q;
ll mx=0;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("test.txt","r",stdin);
    //freopen("FRAC.INP", "r", stdin);
    // freopen("WALKING.OUT", "w", stdout);
    ll a, b, n;
     cin>>a>>b>>n;
  n=min(n,b-1); 
     cout<<(a*n)/b-a*(n/b);

}


Measured memory_bytes: 10656
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
ll mod=1000000007;
//ll mod=67280421310721;
//ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		int n,k;
		cin>>n>>k;
		int p[n];
		FOR(i,0,n)
		cin>>p[i];
		sort(p,p+n);
		ll a=0;
		FOR(i,0,k)
		a+=p[i];
		cout<<a;
		
	}
	return 0;
}

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

int main(int argc, const char * argv[]) {
    
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

    int cntOfQ;
    cin >> cntOfQ;

    vector<int> timeList = {};
    int totalTime = 0;
    for (int i=0; i<cntOfQ; i++) {
        int time;
        cin >> time;
        timeList.push_back(time);
        totalTime += time;
    }

    int cntOfDrinks;
    cin >> cntOfDrinks;



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

        int original = timeList[p-1];
        int diff = x - original;

        int totalTimeWithDiff = totalTime + diff;
        cout << totalTimeWithDiff << endl;
    }

    return 0;
}


Measured memory_bytes: 888
#include<iostream>
using namespace std;
int main(){
    int n;
    int ppans;
    int pans;
    cin >> n;
    ppans = n/111;
    pans = ppans + 1;
    if(n % 111 == 0) pans = pans - 1;
    cout << pans * 111 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

long long comb(long long n, long long r) {
    long long r_buf = (r <= n/2) ? r : n-r;
    if (r_buf == 0) return 1;
    else return (n-r_buf+1) * comb(n, r_buf-1) / r_buf;
}

int main() {
    int n = 0;
    cin >> n;
    int ans = 0;
    int now = 1;
    bool flag = true;
    while (now <= n) {
        if (flag) ans++;
        now++;
        if (now == 10 || now == 1000 || now == 100000) flag = false;
        if (now == 100 || now == 10000 || now == 1000000) flag = true;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int n,m;
  
  cin >> n >> m ;
  
  bool flag = true;

  vector<int> a(m);
  
  for(int i =0; i<a.size(); i++){
    cin >> a.at(i);
  }
  
  for(int i =0; i<a.size(); i++){
    n-=a.at(i);
    if(n<0){
      flag = false;
      break;
    }
  }
  
  if(flag)
    cout << n;
  else
    cout << "-1";
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner in =new Scanner(System.in);
        char[] S=in.next().toCharArray();
        int result=0;
        for(int i=0;i<S.length;i++){
            if(S[i]=='x'){
                result++;
            }
        }
        if(result<8){
            System.out.println("YES");

        }else{
            System.out.println("NO");

        }
    }
}


Measured memory_bytes: 23764
#include<iostream>
#include<string>

using namespace std;

int main() {
	long int ans;
	int x,y;
	int a,b;
	cin >> a >> b;
	for (int i = a*12;; i++) {
		x = i * 0.08;
		y = i * 0.1;
		if (x == a && y == b) {
			ans = i;
			break;
		}
		if (y>b) {
			ans = -1;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int sosuu(int x)
{
   int i;

   if ( x < 2 ) return 0;
   else if ( x == 2 ) return 1;
   if ( x % 2 == 0 ) return 0;

   for ( i = 3; i*i <=x; i+=2 ) {
      if ( x % i == 0 ) return 0;
   }
   return 1;
}

int main(void)
{
   int n, x, i;
   int wa = 0;

   scanf("%d", &n);

   for ( i = 0; i < n; i++) {
      scanf("%d", &x);
      if ( sosuu(x) ) wa = wa+1;
   }
   printf("%d\n", wa);

   return 0;
}

Measured memory_bytes: 1804
import bisect
from collections import defaultdict
class SqrtSet:
    def __init__(self, block_limit=201):
        self.key = []
        self.child = [[]]
        self.block_limit = block_limit
 
    def search_lower(self, key):
        if key is None:
            return None
        ret = None
        i = bisect.bisect_left(self.key, key)
        if i != 0:
            ret = self.key[i - 1]
        block = self.child[i]
        i = bisect.bisect_left(block, key)
        if i != 0:
            ret = block[i - 1]
        return ret
        
    def search_higher(self, key):
        if key is None:
            return None
        ret = None
        i = bisect.bisect_right(self.key, key)
        if i != len(self.key):
            ret = self.key[i]
        block = self.child[i]
        i = bisect.bisect_right(block, key)
        if i != len(block):
            ret = block[i]
        return ret
 
    def insert(self, key):
        i = bisect.bisect(self.key, key)
        block = self.child[i]
        bisect.insort(block, key)
        if len(block) == self.block_limit:
            sep = self.block_limit // 2
            self.key.insert(i, block[sep])
            self.child.insert(i + 1, block[sep + 1:])
            self.child[i] = block[:sep]

def main():
    N = int(input())
    A = [int(i) for i in input().split()]

    # IDX[n] <-> A.index(n)
    IDX = defaultdict(int)
    for idx,a in enumerate(A):
        IDX[a] = idx

    SS = SqrtSet()
    SS.insert(-1)
    SS.insert(N)

    ans = 0
    for n in range(1, N + 1):
        H = SS.search_higher(IDX[n])
        L = SS.search_lower(IDX[n])
        ans += (IDX[n] - L) * (H - IDX[n]) *  n
        SS.insert(IDX[n])

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 36756
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

using ull = unsigned long long;
int main(void) {
  int N;
  cin >> N;
  ull ans = 1;
  for (int i = 0; i < N; i++) {
    ull temp;
    cin >> temp;
    ans = temp * (ans / __gcd(temp, ans));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var S = Console.ReadLine();
        var min = int.MaxValue;
        for (int i = 0; i < S.Length - 2; i++)
        {
            var sub = S.Substring(i, 3);
            var target = int.Parse(sub);
            var diff = Math.Abs(target - 753);
            min = Math.Min(min, diff);
        }

        Console.WriteLine(min);
    }

}



Measured memory_bytes: 11220
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<string> vecs;
template<class T,class U> using Hash=unordered_map<T,U>;

#define REP(i, a, n) for(ll i = a; i < (ll)n; i++)
#define RREP(i, a, n) for(ll i = n-1; i >= a; i--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, 0, n)
#define MD 1000000007

template<class T> T read(){T a;cin >> a;return a;}
template<class T> void read(T& a){cin >> a;}
template<class T> void rarr(T a, int n){for(int i = 0; i < n; i++) {cin >> a[i];}}
template<class T> void write(T a){cout << a << endl;}
template<class T> void writes(vector<T> a, const char* c = " "){cout << a[0];for(int i = 1; i < (int)a.size(); i++)cout << c << a[i];cout << endl;;}
void write(double a){cout << fixed << setprecision(12) << a << endl;}
void write(long double a){cout << fixed << setprecision(12) << a << endl;}
template<class T> void warr(T a, int n, const char* c = " "){cout << a[0];for(int i = 1; i < n; i++)cout << c << a[i];cout << endl;}
void split(string s, string delim, veci& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(atoi(s.substr(pos).data()));break;}else {result.push_back(atoi(s.substr(pos, p - pos).data()));}pos = p + delim.size();}}
void split(string s, string delim, vecs& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(s.substr(pos));break;}else {result.push_back(s.substr(pos, p - pos));}pos = p + delim.size();}}
ll gcd(ll a, ll b){while(true){ll k = a % b;if(k == 0)return b;a = b;b = k;}}
ll comb(ll n, ll m){ll p=1;m=min(m,n-m);for(ll i=1;i<=m;i++){p*=n-i+1;p/=i;}return p;}

ull power( const ull& a, ull k, const ull& n )
{
  if ( a == 0 || n == 0 ) return( 0 );
  if ( k == 0 ) return( 1 % n );

  ull currentMod = a % n;
  ull currentValue = ( ( k & 1 ) > 0 ) ? currentMod : 1;

  for ( k >>= 1 ; k > 0 ; k >>= 1 ) {
    currentMod = ( currentMod * currentMod ) % n;
    if ( ( k & 1 ) > 0 )
      currentValue = ( currentValue * currentMod ) % n;
  }

  return( currentValue );
}

ll frac[200001]={1};
ll mfrac_mod[200001]={1};

ll comb_mod(ll n, ll m,ll md){
    ll p=1;
    p=(p*frac[n])%md;
    p=(p*mfrac_mod[n-m])%md;
    p=(p*mfrac_mod[m])%md;
    return p;
}

int main(void)
{
	REP(i,1,200001){
        frac[i]=(i*frac[i-1])%MD;
        mfrac_mod[i]=(power(i,MD-2,MD)*mfrac_mod[i-1])%MD;
    }
    ll h,w,a,b;
    cin>>h>>w>>a>>b;
    h--;w--;a--;b--;
    ll rh=h-a;
    ll rw=w-b;
    ll res=0;
    REP(i,0,rw){
        ll c1=comb_mod(rh+b+i,b+i+1,MD);
        ll c2=comb_mod(a+rw-i-1,rw-i-1,MD);
        res=(res+(c1*c2)%MD)%MD;
    }
    write(res);
    return 0;
}

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

int main() {
    ll h, w;
    cin >> h >> w;
    ll ans = h * w;
    for (int i = 0; i < 2; i++) {
        for (int a = 1; a < h; a++) {
            ll b = h - a;
            ll c = b / 2;
            ll s1 = a * w;
            ll s2 = (b - c) * w;
            ll s3 = c * w;
            if (s1 >= s2) ans = min(ans, s1 - s3);
            if (s2 > s1 && s1 > s3) ans = min(ans, s2 - s3);
            if (s3 >= s1) ans = min(ans, s2 - s1);
            ll d = w / 2;
            ll s4 = b * (w - d);
            ll s5 = b * d;
            if (s1 >= s4) ans = min(ans, s1 - s5);
            if (s4 > s1 && s1 > s5) ans = min(ans, s4 - s5);
            if (s5 >= s1) ans = min(ans, s4 - s1);
        }
        swap(h, w);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n, m; cin >> n >> m;
  priority_queue<ll> pq;
  for(int i=0;i<n;++i) {
    ll tmp; cin >> tmp;
    pq.push(tmp);
  }
  while(m > 0) {
    ll now = pq.top(); pq.pop();
    now /= 2;
    pq.push(now);
    m--;
  }
  ll su = 0;
  while(!pq.empty()) {
    su += pq.top();
    pq.pop();
  }
  cout << su << endl;
}


Measured memory_bytes: 1400
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        List<Integer> lengthList = new ArrayList<>(n);

        for (int i=0; i<n; i++){
            lengthList.add(sc.nextInt());
        }

        int boundCount = 1;
        int zahyou = 0;

        for (int i=0; i<n; i++){
            zahyou += lengthList.get(i);

            if (zahyou <= x){
                boundCount++;
            }else {
                break;
            }
        }

        System.out.println(boundCount);

    }
}

Measured memory_bytes: 24276
#include<iostream>
using namespace std;
int main()
{
    char che;
    while(cin>>che)
    {
        int cnt=0;
        for(char i='A';i<='Z';i++)
        {
            if(che==i)
            {
                cnt=1;
                break;
            }

        }
        if(cnt==1)
            cout<<"A"<<endl;
        else
            cout<<"a"<<endl;
    }
}


Measured memory_bytes: 3584
#include <stdio.h>
int main(void){
  int n,i;
  char s[128];
  scanf("%d",&n);
  scanf("%s",s);
  if( n%2 == 1 ){
    printf("No");
	return 0;
  }
  else{
    for(i=0;i<=n/2-1;i++){
	  if(s[i] == s[i+n/2]){}
	  else{
	    printf("No");
		return 0;
	  }
	}
  }
  printf("Yes");
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
	int d, n, i, S;
	int c;
	while (scanf("%d", &d)!=EOF)
	{
		n=600/d;
		S=0;
		for (i=1; i<=n-1; i++)
		{
			S+=d*(i*d)*(i*d);
		}
		printf("%d\n", S);
	}
	
	return 0;
}

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

using namespace std;

int main()
{
    int N;  cin >> N;
    int max1, max2, cnt;
    vector<int> A(N), v(200000,0);
    cnt = 0;
    max2 = 0;
    for(int i=0; i<N; i++)  cin >> A[i];
    for(int i=0; i<N; i++)  v[A[i]-1]++;
    for(int i=199999; i>=0; i--){
        if(v[i] > 1 and cnt == 0){
            max1 = i+1;
            break;
        }else if(v[i] == 1 and cnt == 0){
            max1 = i+1;
            cnt++;
        }else if(v[i] > 0 and cnt == 1){
            max2 = i+1;
            break;
        }
    }
    if(max2 == 0){
        for(int i=0; i<N; i++)  cout << max1 << '\n';
    }else{
        for(int i=0; i<N; i++){
            if(A[i] == max1)    cout << max2 << '\n';
            else    cout << max1 << '\n';
        }
    }
}

Measured memory_bytes: 4824
#include <stdio.h>
#include <string.h>

int memo[32][32];
int map[32][32];
int w, h;

int dfs(int x, int y, int px){
	int ny = y + 1;

	if (x < 0 || x >= w) return (0);
	if (y >= h) return (1);
	if (memo[y][x] != -1) return (memo[y][x]);

	if (y == h - 1 && map[y][x] == 0) return (memo[y][x] = 1);

	switch (map[y][x]){
	  case 0: return (memo[y][x] = dfs(x, ny, x) + dfs(x + 1, ny, x) + dfs(x - 1, ny, x));
	  case 1: return (memo[y][x] = 0);
	  case 2: return (x == px ? dfs(x, ny + 1, x) : 0);
	  default:fprintf(stderr, "%d is invalid value\n", map[y][x]);
	}
}

int main(void)
{
	while (scanf("%d %d", &w, &h), w){
		int ans = 0;
		int i, j;

		for (i = 0; i < h; i++){
			for (j = 0; j < w; j++){
				scanf("%d", map[i] + j);
			}
		}

		memset(memo, -1, sizeof(memo));
		for (i = 0; i < w; i++){
			ans += dfs(i, 0, i);
		}

		printf("%d\n", ans);
	}

	return (0);
}

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

long long gcd(long long a, long long b){
  if(a < b) swap(a, b); 
  if(a % b == 0) return b;
  else return gcd( a - b, b);
}

int main(){
  long long a,b,c;
  cin >> a >> b >> c;
  
  if(c%gcd(a,b)==0)cout << "YES"<<endl;
  else cout << "NO"<<endl;
  
}

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

int main(void) {
  vector<string> days{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string day;
  cin >> day;
  cout << 7 - distance(days.begin(), find(days.begin(), days.end(), day)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

#define MOD 1000000007

using namespace std;

typedef long long ll;

ll mod_pow(ll x, ll n, ll p) {
    if (n == 1)
        return x % p;
    if (n % 2 == 0) {
        ll t = mod_pow(x, n/2, p);
        return t * t % p;
    }
    else {
        ll t = mod_pow(x, n-1, p);
        return x * t % p;
    }
}

ll mod_inv(ll a, ll p) {
    return mod_pow(a, p-2, p);
}

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

    ll ans = mod_pow(2, n, MOD) - 1;

    ll c_a = 1, c_b = 1;

    for (ll i = 1; i <= a; i++) {
        c_a = (c_a * (n - (i-1))) % MOD * mod_inv(i, MOD) % MOD;
    }

    for (ll i = 1; i <= b; i++) {
        c_b = (c_b * (n - (i-1))) % MOD * mod_inv(i, MOD) % MOD;
    }

    ans -= (c_a + c_b) % MOD;

    if (ans < 0)
        ans += MOD;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n, i;
	cin>>n;
	ll p[n], a[n], x, y;
	for(i=1; i<=n; i++){
		cin>>p[i];
		a[i]=p[i];
	}
	sort(a+1, a+1+n); ll q=0;
	for(i=1; i<=n; i++){
		if(a[i]!=p[i]){
			q++;
		}
	}
	if(q<=2){
		cout<<"YES";return 0;
	}
	else cout<<"NO";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		System.out.println(a*b);
		
		
	}

}


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

#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) (x & -x)
using namespace std;
typedef long long ll;
const int MAX = 0x7ffffff;
int t;

void slove()
{
	int n , yen = 0;
	cin >> n;
	while(yen < n)
	{
		yen += 1000;
	}
	cout << yen - n << endl;
}
int main()
{
	SIS;
	slove();
}

Measured memory_bytes: 3620
s = input()
t = input()

n = len(t)

i = 0
j = 0

a = 10000

for i in range(len(s)-n+1):
    u = s[i:i+n]
    b = 0
    for j in range(n):
        if t[j] != u[j]:
            b += 1
    a = min(a, b)

print(a)

Measured memory_bytes: 9076
#include <iostream>
using namespace std;
int main()
{
  int N;
  string S, T;

  cin >> N;
  cin >> S >> T;

  string answer = "";

  for (int i=0; i<N;i++)
    {
      answer += S[i];
      answer += T[i];
    }
  cout << answer << "\n";

  return 0;
}

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

int main() {
  int x, y;
  cin >> x >> y;
  for(int i=0; i<=x; i++) {
    int n = 2*i + 4*(x-i);
    if(n == y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}
  

Measured memory_bytes: 3640
#include<stdio.h>
int a[200001],b[200001],c[200001];
int main(void)
{
	int n,m,i,f;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++) c[i]=0;
	for(i=0;i<m;i++) scanf("%d %d",&a[i],&b[i]);
	for(i=0;i<m;i++){
		if(a[i]==1) c[b[i]]=1;
	}	
	f=0;
	for(i=0;i<m;i++){
		if(c[a[i]]==1&&b[i]==n){
			f=1; break;
		}
	}	
	if(f==1) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	return 0;
}	

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

using namespace std;

int ot[10][10];

int check4(int a, int b, int c, int d)
{
    int t1,t2,t3;
    t1=ot[0][a];
    t2=ot[t1][b];
    t3=ot[t2][c];
    return ot[t3][d];
}
int check5(int a, int b, int c ,int d ,int e)
{
    int t1,t2,t3,t4;
    t1=ot[0][a];
    t2=ot[t1][b];
    t3=ot[t2][c];
    t4=ot[t3][d];
    return ot[t4][e];
}

int check(int a, int b, int c ,int d , int e)
{
    for(int i=0;i<10;i++)
    {
        if(i==a) continue;
        if(check5(i,b,c,d,e)==0)
            return -1;
    }
    for(int i=0;i<10;i++)
    {
        if(i==b) continue;
        if(check5(a,i,c,d,e)==0)
            return -1;
    }
    for(int i=0;i<10;i++)
    {
        if(i==c) continue;
        if(check5(a,b,i,d,e)==0)
            return -1;
    }
    for(int i=0;i<10;i++)
    {
        if(i==d) continue;
        if(check5(a,b,c,i,e)==0)
            return -1;
    }
    for(int i=0;i<10;i++)
    {
        if(i==e) continue;
        if(check5(a,b,c,d,i)==0)
            return -1;
    }
    if(check5(b,a,c,d,e)==0&&(a!=b)) return -1;
    if(check5(a,c,b,d,e)==0&&(b!=c)) return -1;
    if(check5(a,b,d,c,e)==0&&(c!=d)) return -1;
    if(check5(a,b,c,e,d)==0&&(d!=e)) return -1;
    return 1;
}

int main()
{
    int ctt=0;
    for(int i=0;i<10;i++)
    {
        for(int j=0;j<10;j++)
        {
            cin >> ot[i][j];
        }
    }
    int a,b,c,d;
    for(int i=0;i<10;i++)
    {
        for(int j=0;j<10;j++)
        {
            for(int k=0;k<10;k++)
            {
                for(int L=0;L<10;L++)
                {
                    int e=check4(i,j,k,L);
                    if(check(i,j,k,L,e)==-1)
                        ctt++;
                }
            }
        }
    }
    cout << ctt << endl;

}

Measured memory_bytes: 3096
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
#include <bits/stdc++.h>
#include <fstream>
#include<string.h>
#include <algorithm>
#include<math.h>
#include<vector>
#include <queue>
#include <deque> 
#define ll long long
#define M 1000000007 
#define MM 998244353
#define INF (1LL<<60)-1
using namespace std;
 
bool isBig(ll x,ll n)
{
    ll trm=1;
    for(ll i=0;i<n-1;i++)
    {
        trm*=x;
        if(trm>1e18)return true;
    }
    return false;
}
 
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*ll t,tcitr;
    cin>>t;
    tcitr=0;
    while(tcitr<t)
    {*/
        //cout<<"Case #"<<tcitr+1<<": ";
        ll n,i,j,k;
        cin>>n;
        ll a[n];
        for(i=0;i<n;i++)cin>>a[i];
        ll pre[n];
        pre[0]=a[0];
        for(i=1;i<n;i++)pre[i]=pre[i-1]+a[i];
        ll ans=0;
        for(i=0;i<n;i++)
        {
            ans=(ans+(a[i]*((pre[n-1]-pre[i])%M))%M)%M;
        }
        cout<<ans<<"\n";
        /*tcitr++;
    }*/
    return 0;
}

Measured memory_bytes: 6712
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
A_count = Counter(A)
x = [0, 0]
for a in A_count:
  if A_count[a] > 1:
    x.append(a)
  if A_count[a] > 3:
    x.append(a)
x.sort()
print(x[-1]*x[-2])

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  sort(L.begin(), L.end());
  int res = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      res += lower_bound(L.begin(), L.end(), L[i] + L[j]) - L.begin() - j - 1;
    }
  }
  cout << res << '\n';
  return 0;
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

class modint {
  private:
    ll m_val;
    ll m_mod;
  public:
    constexpr modint() : m_val(0), m_mod() { m_mod = MOD; }
    constexpr modint(const ll x) : m_val(0), m_mod(0) { m_mod = MOD; m_val = x % m_mod; }
    constexpr modint(const ll x, const ll mod) : m_val(0), m_mod(0) { m_mod = mod; m_val = x % m_mod; }
    constexpr ll val() const { return m_val; }
    constexpr modint operator+(const modint &rhs) const { return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const { return modint(*this) /= rhs; }
    constexpr modint &operator+=(const modint &rhs) {
      m_val += rhs.m_val;
      if (m_val >= m_mod) m_val -= m_mod;
      return *this;
    }
    constexpr modint &operator-=(const modint &rhs) {
      if (m_val < rhs.m_val) m_val += m_mod;
      m_val -= rhs.m_val;
      return *this;
    }
    constexpr modint &operator*=(const modint &rhs) {
      m_val = m_val * rhs.m_val % m_mod;
      return *this;
    }
    constexpr modint &operator/=(const modint &rhs) {
      *this *= rhs.pow(m_mod - 2);
      return *this;
    }
    constexpr modint pow(ll n) const {
      if (n == 0) return 1;
      modint o = pow(n >> 1);
      o *= o;
      if (n & 1) o *= *this;
      return o;
    }
    friend ostream& operator<<(ostream& os, const modint &a) { os << a.val(); return os; }
};

int main() {
  ll n;
  cin >> n;

  vector<ll> a(n);
  for (ll i = 0; i < n; ++i) {
    cin >> a[i];
  }
  
  vector<ll> seen(n);
  for (ll i = 0; i < n; ++i) {
    seen[a[i]]++;
  }

  modint ans(1);
  if (n%2 == 0) {
    for (ll i = 1; i <= n-1; i+=2) {
      if (seen[i] != 2) {
        cout << 0 << endl;
        return 0;
      } else {
        ans *= seen[i];
      }
    }
  } else {
    for (ll i = 0; i <= n-1; i+=2) {
      if (i == 0 && seen[i] != 1) {
        cout << 0 << endl;
        return 0;
      } else if ( i > 0 && seen[i] != 2) {
        cout << 0 << endl;
        return 0;
      } else {
        ans *= seen[i];
      }
    }
  }

  cout << ans.val() << endl;

  return 0;
}


Measured memory_bytes: 1792
N = int(input())
Red = [list(map(int,input().split())) for i in range(N)]
Blue = [list(map(int,input().split())) for i in range(N)]
Red.sort(reverse=True)
Blue.sort(key=lambda x: x[1])
count = 0
for red in Red:
    for blue in Blue:
        if red[0]<blue[0] and red[1]<blue[1]:
            count += 1
            Blue.pop(Blue.index(blue))
            break
print(count)


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

int main() {
  int n, o = 0;
  cin >> n;
  vector<char> c(n);
  for(int i = 0; i < n; i++) {
    cin >> c.at(i);
    if(i > 1) {
      if(c[i - 2] == 'A' && c[i - 1] == 'B' && c[i] == 'C')
        o++;
    }
  }
  cout << o << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iostream>
using namespace std;
const int inf=0x3f3f3f3f;
const int maxn=1e5+10;

struct edge{
    int u,v,w;
    edge(int _u=0,int _v=0,int _w=0):u(_u),v(_v),w(_w){
    }
    bool operator<(const edge & a)const{
        return w<a.w;
    }
}es[2*maxn];

struct point{
    int x,y,id;
    point(int _x=0,int _y=0,int _id=0):x(_x),y(_y),id(_id){}
} ps[maxn];

int n,cnt,f[maxn];

bool cmpx(point a,point b){
    return a.x<b.x;
}

bool cmpy(point a,point b){
    return a.y<b.y;
}

int findf(int a){
    return ((f[a]==-1)?a:f[a]=findf(f[a]));
}

int kruskal(){
    int i,ans=0,cc=0;
    memset(f,0xff,sizeof(f));
    sort(es,es+cnt);
    for(i=0;i<cnt;i++){
        int u=es[i].u,v=es[i].v,w=es[i].w;
        int fu=findf(u),fv=findf(v);
        if(fu!=fv){
            ans+=w,++cc;
            f[fu]=fv;
        }
        if(cc==n-1)break;
    }
    if(cc<n-1)return -1;
    return ans;
}
int main(){
    int i,j,k,c,un,vn;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d%d",&ps[i].x,&ps[i].y);
        ps[i].id=i;
    }
    sort(ps+1,ps+n+1,cmpx);
    for(i=1;i<=n-1;i++){
        es[cnt++]=edge(ps[i].id,ps[i+1].id,(ps[i+1].x-ps[i].x));
    }
    sort(ps+1,ps+n+1,cmpy);
    for(i=1;i<=n-1;i++){
        es[cnt++]=edge(ps[i].id,ps[i+1].id,(ps[i+1].y-ps[i].y));
    }
    printf("%d\n",kruskal());
    return 0;
}


Measured memory_bytes: 4224
n = gets.to_i
s = gets.chomp.chars.map do |x|
  if x == "E"
    1
  else
    0
  end
end
right_one_num = s.sum
left_zero_num = 0
min = n + 1
s.each do |x|
  if x == 1#必要なら右側の1のカウントを減らす。
    right_one_num -= 1
  end
  if min > right_one_num + left_zero_num
    min = right_one_num + left_zero_num
  end
  if x == 0#次からはこの0もカウントに入れる。
    left_zero_num += 1
  end
end
puts min


Measured memory_bytes: 40536
package main

import (
	"fmt"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	p := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&p[i])
	}
	a := make([]float64, N)
	for i := 0; i < N; i++ {
		for j := 1; j <= p[i]; j++ {
			a[i] += float64(j)
		}
		a[i] /= float64(p[i])
	}
	var w, r float64
	for i := 0; i < K-1; i++ {
		w += a[i]
	}
	r = w
	for i := 0; i < N-K+1; i++ {
		w += a[i+K-1]
		if r < w {
			r = w
		}
		w -= a[i]
	}
	fmt.Println(r)

}


Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int N;
    cin >> N;
    vector<int> A(N);
    string ans = "APPROVED";
    
    for(int i = 0;i < N;i++){
         cin >> A[i];
        if(A[i]%2 == 0){
            if((A[i])%3 != 0 && (A[i])%5 != 0){
                ans = "DENIED";
                break;
            }
            else{
                ans = "APPROVED";
            }
        }
        else{
            continue;
        }
    }
    cout << ans << endl;
        
}

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

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

int main() {
    int n;
    cin >> n;
    int t[n], a[n];
    for (int i = 0; i < n; i++) {
        cin >> t[i] >> a[i];
    }
    
    ll totalT = t[0];
    ll totalA = a[0];
    
    for (int i = 1; i < n; i++) {
        if (t[i] > a[i]) {
            while (totalA % a[i] != 0) {
                totalA++;
            }
            if (totalT > totalA / a[i] * t[i]) {
                while (totalT % t[i] != 0) {
                    totalT++;
                }
                totalA = totalT / t[i] * a[i];
            } else {
                totalT = totalA / a[i] * t[i];
            }
        } else if (t[i] < a[i]) {
            while (totalT % t[i] != 0) {
                totalT++;
            }
            if (totalA > totalT / t[i] * a[i]) {
                while (totalA % a[i] != 0) {
                    totalA++;
                }
                totalT = totalA / a[i] * t[i];
            } else {
                totalA = totalT / t[i] * a[i];
            }
        } else {
            ll mx = max(totalA, totalT);
            totalA = mx;
            totalT = mx;
        }
    }
    
    cout << (ll)(totalA + totalT) << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

int prime[1000000],n;
bool isprime[1000001];

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

int main(){
	sieve(1000000);
	while(cin>>n){
		if(n==0)return 0;
		int ans=0;
		for(int i=0;prime[i]<=n/2;i++)if(isprime[n-prime[i]])ans++;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 2152
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
const int N=800+10,M=1500,INF=0x3f3f3f3f;
int main()
{
    int n,ans1,a,ans2;
    while(~scanf("%d",&n)){
        ans1=1,ans2=1;
        for(int i=1;i<=n;i++){
            scanf("%d",&a);
            if(a%2==0){
                ans2*=2;
            }
            ans1*=3;
        }
        printf("%d\n",ans1-ans2);
    }
    return 0;
 }


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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp=0, ct=0;
vector<ll> A, S;

signed main(){
    cin >> N;
    if(N==1) {
        cout << "YES" << endl;
        return 0;
    }
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        A.push_back(a);
        tmp += a;
    }
    ct = N*(N+1)/2;
    if(tmp%ct==0) ct = tmp/ct;
    else {
        cout << "NO" << endl;
        return 0;
    }
    for(int i=0;i<N-1;i++) {
        S.push_back(ct-(A[i+1]-A[i]));
    }
    S.push_back(ct-(A[0]-A[N-1]));
    for(int i=0;i<N;i++) {
        //cout << S[i] << endl;
        if(S[i]%N!=0) {
            cout << "NO" << endl;
            return 0;
        }
        else {
            if(S[i]<0||S[i]>ct*N) {
                cout << "NO" << endl;
                return 0;
            }
            ans += S[i]/N;
        }
    }
    if(ans==ct) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

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++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVC vector<vector<char>>
typedef long long ll;



int main() {
	double n, m, d;
	cin >> n >> m >> d;
	if (d == 0) {
		cout << fixed << setprecision(15) << 1 / n * (m - 1) << endl;
	}
	else {
		cout << fixed << setprecision(15) << 2 * (n - d) / (n*n)*(m - 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>

using namespace std;

typedef long long LL;

const int N = 100010, M = 200010;
const LL MOD = 1E9 + 7, INF = 0x3f3f3f3f3f3f3f3f;

inline void Inc(LL &a, LL b) {
    a = (a + b) % MOD;
    return;
}
inline LL Sqr(LL a) {
    return a * a % MOD;
}

int n, m, s, t;
int tot = -1, head[N];
struct Edge {
    int p, nxt, w;
    Edge(int p = 0, int nxt = 0, int w = 0) : p(p), nxt(nxt), w(w) {}
} edge[M << 1];
inline void Add(int u, int v, int w) {
    edge[++tot] = Edge(v, head[u], w);
    head[u] = tot;
    return;
}

bool exist[N];
int id[N];
queue<int> que;

void Init(int s, LL *dist, LL *cnt) {
    fill(dist + 1, dist + n + 1, INF);
    fill(cnt + 1, cnt + n + 1, 0);
    dist[s] = 0;
    que.push(s);
    exist[s] = 1;
    while (!que.empty()) {
        int u = que.front();
        que.pop();
        exist[u] = 0;
        for (int i = head[u]; ~i; i = edge[i].nxt) {
            int v = edge[i].p, w = edge[i].w;
            if (dist[v] > dist[u] + w) {
                dist[v] = dist[u] + w;
                if (!exist[v]) {
                    que.push(v);
                    exist[v] = 1;
                }
            }
        }
    }
    memset(id, 0, sizeof(id));
    for (int u = 1; u <= n; ++u)
        for (int i = head[u]; ~i; i = edge[i].nxt) {
            int v = edge[i].p, w = edge[i].w;
            if (dist[u] + w == dist[v]) ++id[v];
        }
    cnt[s] = 1;
    que.push(s);
    while (!que.empty()) {
        int u = que.front();
        que.pop();
        for (int i = head[u]; ~i; i = edge[i].nxt) {
            int v = edge[i].p, w = edge[i].w;
            if (dist[u] + w == dist[v]) {
                Inc(cnt[v], cnt[u]);
                if (!--id[v]) que.push(v);
            }
        }
    }
    return;
}

LL d1[N], d2[N], c1[N], c2[N];

int main() {
    scanf("%d%d%d%d", &n, &m, &s, &t);
    memset(head, -1, sizeof(head));
    for (int i = 1; i <= m; ++i) {
        int u, v, w;
        scanf("%d%d%d", &u, &v, &w);
        Add(u, v, w);
        Add(v, u, w);
    }
    Init(s, d1, c1);
    Init(t, d2, c2);
    LL res = 0, l = d1[t];
    for (int u = 1; u <= n; ++u) {
        if (d1[u] == d2[u] && d1[u] * 2 == l) Inc(res, Sqr(c1[u]) * Sqr(c2[u]));
        for (int i = head[u]; ~i; i = edge[i].nxt) {
            int v = edge[i].p, w = edge[i].w;
            if (d1[u] + w + d2[v] == l && d1[u] * 2 < l && l < d1[v] * 2) Inc(res, Sqr(c1[u]) * Sqr(c2[v]));
        }
    }
    res = (c1[t] * c2[s] - res) % MOD;
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 9292
#include <bits/stdc++.h>
#define ll long long

#define TASKNAME ""

using namespace std;

const int INF = 1e9 + 7;
const int MAXN = 1e6 + 7;
const double EPS = 1e-8;
const int N = 2e5 + 7;
const int SQ = sqrt(N);

bitset <N> a[SQ];

int main() {
    #ifdef MY
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #else
        //freopen(TASKNAME".in", "r", stdin);
        //freopen(TASKNAME".out", "w", stdout);
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // MY
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    vector <vector <int> > gr(n);
    vector <int> st(n, 0), c[2];
    c[0].resize(n, 0);
    c[1].resize(n, 0);
    vector <bool> exist(n, true);
    set <pair <int, int> > q;
    for (int i = 0; i < m; i++) {
        int v, u;
        cin >> v >> u;
        v--, u--;
        gr[v].push_back(u);
        gr[u].push_back(v);
        st[v]++, st[u]++;
        c[s[v] - 'A'][u]++;
        c[s[u] - 'A'][v]++;
    }
    for (int i = 0; i < n; i++) {
        q.insert({st[i] - max(c[0][i], c[1][i]), i});
    }
    while (!q.empty()) {
        auto t = *q.begin();
        //cout << t.second << " " << t.first << "\n";
        if (t.first) break;
        int v = t.second;
        exist[v] = false;
        q.erase(q.begin());
        for (int u : gr[v]) {
            if (!exist[u]) continue;
            //cout << u << " ";
            q.erase({st[u] - max(c[0][u], c[1][u]), u});
            c[s[v] - 'A'][u]--;
            st[u]--;
            q.insert({st[u] - max(c[0][u], c[1][u]), u});
        }
        //cout << "\n";
    }
    if (q.size()) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}


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

using namespace std;

long long n, a, b, ans;

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

	cin >> n >> a >> b;

	if (a + b == 0)
		return cout << 0, 0;

	ans = (n / (a + b)) * a;
	ans += min(n % (a + b), a);

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int parent[10010];
void init(int N){int i=0;for(;i<N;i++)parent[i]=i;}
int root(int a){
	if(parent[a]==a)return a;
	return parent[a]=root(parent[a]);
}
bool is_same_set(int a,int b){return root(a)==root(b);}
void unite(int a,int b){parent[root(a)] = root(b);}

int i, s, N, M, A[10010], B[10010], COST[10010];
pair<int,int> bridge[10010];
int main(){
	for(;cin>>N>>M,N;cout<<s<<endl){
		for(i=0;i<M;i++){
			cin>>A[i]>>B[i]>>COST[i];
			bridge[i].first = COST[i];
			bridge[i].second = i;
		}
		sort(bridge, bridge+M);
		init(N);
		for(s=i=0;i<M;i++){
			int cost = bridge[i].first;
			int a = A[bridge[i].second];
			int b = B[bridge[i].second];
			if(is_same_set(a,b))continue;
			unite(a,b);
			s+=cost;
		}
	}
}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    rep(i,5){
        int x; cin >> x;
        if(x == 0){
            cout << i+1 << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve(){
    int n, q;
    cin >> n;
    Vl s(n);
    rep(i, 0, n) cin >> s[i];
    cin >> q;
    Vl t(q);
    rep(i, 0, q) cin >> t[i];

    int ans = 0;
    rep(i, 0, q){
        rep(j, 0, n){
            if(t[i] == s[j]){
                ans++;
                break;
            }
        }
    }
    cout << ans << "\n";
}


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

    solve();
    return 0;
}



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

int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  for(int i = 0; i<n; i++) cin >> a.at(i);
  int res = 0;
  for(int i = 0; i<n; i+=2){
    if(a.at(i)%2 == 1) res++;
  }
  cout << res << endl;
}

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

using namespace std;

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

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

    cout << setprecision(9) << v[N-1] << endl;
}

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

bool IsPrime(int num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false; // 偶数はあらかじめ除く

  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
    {
      // 素数ではない
      return false;
    }
  }

  // 素数である
  return true;
}
int main()
{
  long x;
  cin >> x;
  long ans = 0;
  for (long i = x; i < 100009;i++){
    if(IsPrime(i)){
      ans = i;
      break;
    }
  }
  if (x == 2)
    ans = 2;
  cout << ans << endl;
}


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

using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)

string solve(string& s) {
  reverse(s.begin(), s.end());
  const vector<string> t {"maerd", "remaerd", "esare", "resare"};
  int size{};
  for (int i = 0; i < s.size();) {
    bool check = false;
    for (auto e : t) {
      if (s.substr(i, e.size()) == e) {
        size += e.size();
        i += e.size();
        check = true;
      }
    }
    if (!check)
      break;
  }
  if (s.size() == size)
    return "YES";
  return "NO";
}

int main() {
  string s;
  cin >> s;
  cout << solve(s) << endl;
}


Measured memory_bytes: 512
#include <iostream>

int main() {
    int X, A, B;
    std::cin >> X >> A >> B;

    if (A >= B) {
        std::cout << "delicious" << std::endl;
    } else if (A < B && (B - A) <= X) {
        std::cout << "safe" << std::endl;
    } else {
        std::cout << "dangerous" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int H,W;
string board[50];
int dj[]={-1,-1,-1,0,0,1,1,1};
int di[]={-1,0,1,-1,1,-1,0,1};
int ni,nj,b;

int main(){
cin >>H >>W;
for (int i=0;i<H;i++)cin >>board[i];
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
	if(board[i][j]=='.'){
      b=0;
        for (int k=0;k<8;k++){
          ni=i+di[k];nj=j+dj[k];
          if(ni<0||nj<0||ni>=H||nj>=W)continue;
          if(board[ni][nj]=='#')b++;
        }
      board[i][j]='0'+b;   
      }
}}
  for(int i=0;i<H;i++)cout <<board[i]<<endl;
}

Measured memory_bytes: 256