akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c,n,x[1000],y[1000],z[1000];
  cin>>a>>b>>c>>n;
  long long ans=2*(a*b+b*c+c*a),d[8]={0,0,1,0,0,-1,0,0};
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i]>>z[i];
    ans+=6;
    for(int j=0;j<6;j++){
      int nx=x[i]+d[j],ny=y[i]+d[j+1],nz=z[i]+d[j+2];
      if(nx<0||a<=nx||ny<0||b<=ny||nz<0||c<=nz){ans-=2;continue;}
      for(int k=0;k<i;k++)
	if(nx==x[k]&&ny==y[k]&&nz==z[k]){ans-=2;break;}
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m, ans;
	cin >> n >> m;
	ans = (n - 1) * (m - 1);
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
 
/*------------------------------------------------------------------*/
 
int main(){
    ll a, b, c; cin >> a >> b >> c;
    ll k; cin >> k;
    if(k % 2 == 0)cout << a - b << endl;
    else cout << b - a << endl;
}


Measured memory_bytes: 256
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define repr(i,a,b) for (int i = a; i > b; --i)
#define mm(lamb, tttt) memset(lamb, tttt, sizeof lamb)
 
#define null NULL
#define eps 0.000000001
#define mod 1000000007
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (int)V.size()
#define _ <<" "<<
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
ll dp[3009][3009];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 	
	//freopen ("test.txt","r",stdin);
	//string a,b;
	//cin>>a>>b;
	ll n;cin>>n;
	ll a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}

	for(int i=n-1 ; i>=0;i--)
	{
		for(int j = i ; j<n;j++)
		{
			if(i==j)
			{
				dp[i][j] = a[i];
			}
			else
			{
				dp[i][j] = max(a[i] - dp[i+1][j] , a[j] - dp[i][j-1]);

			}
		}
	}

	cout<<dp[0][n-1];

}

Measured memory_bytes: 70016
#include<stdio.h>
#include<string.h>
int main()
{
    char str[10000];
    int n,s,i;
    scanf("%d",&s);
    scanf("%s",str);
    n=strlen(str);
    for(i=0;i<n;i++)
    {
    if(str[i] <= 'Z'-s)
        printf("%c",str[i]+s);
    else
        printf("%c",str[i]+s-26);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string s;
  cin >> s;
  vector<int> cnt(100);
  rep(i,3) {
    cnt[s[i]-'a']++;
  }
  bool ok = true;
  rep(i,3) {
    if (cnt[i] != 1) ok = false;
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
int main(){
	int n,i,j,num;
	int a[4][13]={0};
	char c;
	std::cin>>n;
	for(i=0;i<n;i++){
		std::cin>>c>>num;
		if(c=='S')
			a[0][num-1]=1;
		if(c=='H')
			a[1][num-1]=1;
		if(c=='C')
			a[2][num-1]=1;
		if(c=='D')
			a[3][num-1]=1;
	}
	
	for(i=0;i<4;i++){
		for(j=0;j<13;j++){
			if(a[i][j]==0){
				if(i==0) std::cout<<"S "<<j+1<<std::endl;
				if(i==1) std::cout<<"H "<<j+1<<std::endl;
				if(i==2) std::cout<<"C "<<j+1<<std::endl;
				if(i==3) std::cout<<"D "<<j+1<<std::endl;
			}
		}
	
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()

int main(){
  ll n,k,x,y; cin >> n >> k >> x >> y;
  if(n<=k) cout << x*n << endl;
  else cout << k*x + (n-k)*y << endl;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
 struct Node
 {
     int key;
     Node *next,*prev;
 };
 Node* nil;
 Node* listSearch(int key)
 {
     Node* cur=nil->next;
     while(cur!=nil&&cur->key!=key)
     {
         cur=cur->next;
     }
     return cur;
 }
 void init()
 {
     nil=(Node*)malloc(sizeof(Node));
     nil->next=nil;
     nil->prev=nil;
 }
 void printList()
 {
     Node* cur=nil->next;
     int isf=0;
     while(1)
     {
         if(cur==nil) break;
         if(isf++>0) printf(" ");
         printf("%d",cur->key);
         cur=cur->next;
     }
     printf("\n");
 }
 void deleteNode(Node *t)
 {
     if(t==nil) return ;
     t->prev->next=t->next;
     t->next->prev=t->prev;
     free(t);
 }
 void deleteFirst()
 {
     deleteNode(nil->next);
 }
 void deleteLast()
 {
     deleteNode(nil->prev);
 }
 void deleteKey(int key)
 {
     deleteNode(listSearch(key));
 }
 void insert(int key)
 {
     Node *x=(Node*)malloc(sizeof(Node));
     x->key=key;
     x->next=nil->next;
     nil->next->prev=x;
     nil->next=x;
     x->prev=nil;
 }
 int main()
 {
    int key,n,i;
    int size=0;
    char com[20];
    int np=0,nd=0;
    scanf("%d",&n);
    init();
    for(i=0;i<n;i++)
    {
        scanf("%s%d",com,&key);
        if(com[0]=='i'){insert(key);np++;size++;}
        else if(com[0]=='d')
        {
            if(strlen(com)>6)
            {
            if(com[6]=='F') deleteFirst();
            else if(com[6]=='L') deleteLast();
            }
            else
            {
                deleteKey(key); nd++;
            }
            size--;
        }
    }
    printList();
    return 0;
 }



Measured memory_bytes: 33944
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N, M;
  cin >> N >> M;
  vector<pll> P(2 * M);
  REP(i, 0, M) {
    ll a, b;
    cin >> a >> b;
    P[i * 2] = pll(a - 1, b - 1);
    P[i * 2 + 1] = pll(b - 1, a - 1);
  }

  REP(i, 0, N) {
    cout << count_if(P.begin(), P.end(), [& i](const pll p) {
      return p.first == i;
    }) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int h, m, s, S;
	
	scanf("%d", &S);
	
	h = S / (60 * 60);
	m = (S % (60 * 60)) / 60;
	s = S % 60;
	
	printf("%d:%d:%d\n", h, m, s);
	
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int maxn  = 3005;
string s, t, ansString = "";
int dp[maxn][maxn];

int solve(int sIndx, int tIndx)
{
    if(sIndx == s.size() || tIndx == t.size())
        return 0;
    if(dp[sIndx][tIndx] != -1)
        return dp[sIndx][tIndx];
    int ans = INT_MIN;
    ans = max(ans, solve(sIndx + 1, tIndx));
    ans = max(ans, solve(sIndx, 1 + tIndx));
    if(s[sIndx] == t[tIndx])
    {
        ans = max(ans, 1 + solve(sIndx + 1, tIndx + 1));
    }
    return dp[sIndx][tIndx] = ans;
}

void printSolution(int i, int j)
{
    if(i == (int)s.size() || j == (int)t.size())
    {
        return;
    }
    if(s[i] == t[j])
    {
        ansString += s[i];
        printSolution(i + 1, j + 1);
    }
    else if(dp[i + 1][j] > dp[i][j + 1])
        printSolution(i + 1, j);
    else
        printSolution(i, j + 1);
}
int main()
{
    IO;
    cin >> s >> t;
    memset(dp, -1, sizeof dp);
    solve(0,0);
    printSolution(0,0);
    cout << ansString;
    return 0;
}


Measured memory_bytes: 35968
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=998244353;

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

int p[55];

signed main(){
	int n;
	bool ans = false;
	cin >> n;
	for(int i = 0;i < n;i++) cin >> p[i];
	for(int i = 0;i < n;i++){
		for(int j = i;j < n;j++){
			swap(p[i],p[j]);
			bool flag = true;
			for(int k = 0;k < n;k++){
				if(p[k] != k + 1) flag = false;
			}
			if(flag) ans = true;
			swap(p[i],p[j]);
		}
	}
	if(ans) YES();
	else NO();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b,i;
  cin>>a>>b;
  for(i=0;i<=10000;i++){
    if(i*8/100==a&&i/10==b){
      cout<<i;
      return 0;
    }
  }
  cout<<-1;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <set>
#include <vector>
#include <climits>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> graph[n];
    array<int, 3> points[n];
    int cost[n], edge[n];
    for (int i = 0; cin >> points[i][0] >> points[i][1]; i++) {
        points[i][2] = i;
        cost[i] = INT_MAX;
        edge[i] = -1;
    }
    sort(points, points + n, [](const array<int, 3>& left, const array<int, 3>& right) {
        return left[0] < right[0];
    });
    for (int i = 1; i < n; i++) {
        auto dist = min(abs(points[i - 1][0] - points[i][0]), abs(points[i - 1][1] - points[i][1]));
        graph[points[i - 1][2]].emplace_back(points[i][2], dist);
        graph[points[i][2]].emplace_back(points[i - 1][2], dist);
    }
    sort(points, points + n, [](const array<int, 3>& left, const array<int, 3>& right) {
        return left[1] < right[1];
    });
    for (int i = 1; i < n; i++) {
        auto dist = min(abs(points[i - 1][0] - points[i][0]), abs(points[i - 1][1] - points[i][1]));
        graph[points[i - 1][2]].emplace_back(points[i][2], dist);
        graph[points[i][2]].emplace_back(points[i - 1][2], dist);
    }
    long long result = 0;
    set<int> mst = {0};
    set<pair<int, int>> set;
    int weight[n];
    fill(weight, weight + n, INT_MAX);
    auto update = [&](const vector<pair<int, int>>& nodes) {
        for (auto& p : nodes) {
            if (mst.find(p.first) != end(mst)) {
                continue;
            }
            if (weight[p.first] > p.second) {
                set.erase({weight[p.first], p.first});
                weight[p.first] = p.second;
                set.emplace(p.second, p.first);
            }
        }
    };
    update(graph[0]);
    do {
        auto current = set.begin()->second;
        auto cost = set.begin()->first;
        set.erase(set.begin());
        mst.emplace(current);
        result += cost;
        update(graph[current]);
    } while (!set.empty());
    cout << result;
    return 0;
}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

vector<int> A, B;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int N;
	cin>>N;
	B.resize(N);
	for(int i=0;i<N;i++) cin>>B[i];
	for(int i=0;i<N;i++) {
		bool valid=false;
		for(int j=B.size()-1;j>=0;j--) {
			if(B[j]==j+1) {
				valid=true;
				A.push_back(B[j]);
				B.erase(B.begin()+j);
				break;
			}
		}
		if(!valid) {
			cout<<"-1\n";
			return 0;
		}
	}
	reverse(A.begin(),A.end());
	for(auto a: A) cout<<a<<'\n';
	return 0;
}

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

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, sum, A[500010], rui[500000], dp[5000];
str S, T, U; bool check = true;	vector<ll> R, G, B;



int main() {
	//Code Line
	cin >> n;
	cin >> S;
	for (int i = 0; i < n; i++) {
		if (S[i] == 'R')R.push_back(i);
		if (S[i] == 'G')G.push_back(i);
		if (S[i] == 'B')B.push_back(i);
	}

	for (int i = 0; i < R.size(); i++) {
		for (int j = 0; j < G.size(); j++) {
			c = 0;
			a = max(R[i], G[j]);
			b = min(R[i], G[j]);
			auto it = find(ALL(B), a - b + a);
			if (it != B.end())c++;
			 it = find(ALL(B), b - (a - b));
			if (it != B.end())c++;
			if ((a - b) % 2 == 0) {
				it = find(ALL(B), (a + b) / 2);
				if (it != B.end())c++;
			}
			
			sum += B.size() - c;


		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3652
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	vector<int>A(3);
	IN(A);
	SO(A);
	int sum = A[0] + A[1] + A[2];
	int ans = 3 * (A[2] + ((A[0]+A[1])&1) ) - sum;
	
	cout << ans/2 << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 384
local n,x=io.read("n","n")
local a={}
for i=1,n do
    a[i]=io.read("n")
end

local counter=0
for i=1,n-1 do
    local sum=a[i]+a[i+1]
    if sum>x then
        local diff=sum-x
        counter=counter+diff
        if diff<a[i+1] then
            a[i+1]=a[i+1]-diff
        else
            diff=diff-a[i+1]
            a[i+1]=0
            a[i]=a[i]-diff
        end
    end
end
print(counter)

Measured memory_bytes: 4292
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int C = sc.nextInt();
    int[] B = new int[M];
    int[][] A = new int[N][M];
    for (int i = 0; i < M; i++) {
      B[i] = sc.nextInt();
    }
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < M; j++) {
        A[i][j] = sc.nextInt();
      }
    }
    Main abc122B = new Main();
    System.out.println(abc122B.solve(N, M, C, B, A));
  }

  public int solve(int N, int M, int C, int[] B, int[][] A) {
    int ans = 0;
    for (int[] a : A) {
      int sum = C;
      for (int i = 0; i < M; i++) {
        sum += a[i] * B[i];
      }
      if (sum > 0) ans += 1;
    }

    return ans;
  }
}


Measured memory_bytes: 22100
#include<bits/stdc++.h>
using namespace std;
vector<int>e[1500001];
int dp[1500001];
int vis[1500001];
int dfs(int u)
{
	if(vis[u]==1){printf("-1");exit(0);}
	if(dp[u]) return dp[u];
	vis[u]=1;
	int ans=1;
	for(int i=0;i<e[u].size();i++)
	{
		//printf("%d::%d %d\n",u,e[u][i],dfs(e[u][i])+1);
		ans=max(ans,dfs(e[u][i])+1);
	}
	vis[u]=0;
	return dp[u]=ans;
}
int main() 
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int pre=0;
		for(int j=1;j<n;j++)
		{
			int x;
			scanf("%d",&x);
			int now=min(i,x)*n+max(i,x);
			e[pre].push_back(now);
			pre=now;
		}
	}
	int ans=dfs(0);
	printf("%d",ans-1);
	return 0;
}


Measured memory_bytes: 62848
#include <stdio.h>
#include <cmath>
#include <algorithm>

int main(){
	int n,tmp,count = 0,limit;
	scanf("%d",&n);

	for(int i = 0; i < n; i++)
	{
		scanf("%d",&tmp);
		limit = sqrt(tmp);
		for(int j = 2; j <= limit; j++){
			if(tmp%j==0){
				count++;
				break;
			}
		}
	}
	printf("%d\n",n-count);
}



Measured memory_bytes: 2616
import java.util.Scanner;
import java.util.HashMap;
import java.util.Map;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    HashMap<Integer, Integer> a = new HashMap<>();
    int s = Integer.parseInt(sc.next());
    int m = 0;
    
    loop:
    for(int i = 1;; i++) {
      a.put(i, s);
      
      if(s % 2 == 1){
      	s = 3 * s + 1;
      } else {
        s = s / 2;
      }
      
      for(Map.Entry<Integer, Integer> entry : a.entrySet()) {
        if(entry.getValue() == s) {
        	m = i + 1;
          	break loop;
        }
      }
    }
    
    System.out.println(m);
  }
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
using s64 = int64_t;
using u64 = uint64_t;

template <typename T> T mod_sub (T a, T b, T m);

int main() {
	u64 N, K;
	cin >> N >> K;
	
	u64 mod = pow(10, 9) + 7;
	
	vector<u64> biggers(N+1, N);
	vector<u64> smallers(N+1);
	
	for(u64 i=1; i<=N; i++) {
		smallers[i] = smallers[i-1] + i;
		biggers[i]  = biggers[i-1] + N - i;
	}
	
	u64 ans = 0;
	
	for(u64 i=K-1; i<=N; i++) {
		ans = (ans + mod_sub(biggers[i] + 1, smallers[i], mod)) % mod;
	}
	
	cout << ans;
	
	return 0;
}

template <typename T> T mod_sub (T a, T b, T m) {
	return (a < b) ? m + a - b : (a - b) % m;
}

Measured memory_bytes: 6424
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int D = scanner.nextInt();
		int N = scanner.nextInt();
		scanner.close();

		if (N == 100) {
			N = 101;
		}

		if (D == 0) {
			System.out.println(N);
		} else if (D == 1) {
			System.out.println(N * 100);
		} else if (D == 2) {
			System.out.println(N * 10000);
		}
	}
}

Measured memory_bytes: 22608
def ord(N,n):#N,nは正の整数、Nで割り切れる回数、許容はN^1000
    if n%N!=0:
        return 0
    else:
        return 1+ord(N,n//N)

def partions(M):#Mの約数列 O(n^(0.5+e))
    import math
    d=[]
    i=1
    while math.sqrt(M)>=i:
        if M%i==0:
            d.append(i)
            if i**2!=M:
                d.append(M//i)
        i=i+1
    d.sort()
    return d

N=int(input())
count=0
kouho=partions(N)
for i in range(1,len(kouho)):
    a=kouho[i]
    m=ord(a,N)
    s=N//pow(a,m)
    if s%a==1:
        count+=1

count+=len(partions(N-1))-1
print(count)

Measured memory_bytes: 39664
/*
 * 0604.cc: Take the 'IOI' train
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_M = 2000;
const int MAX_N = 2000;

/* typedef */

/* global variables */

int dp[MAX_M + 1][MAX_N + 1];

/* subroutines */

inline void setgreater(int &dst, int src) {
  if (dst < src) dst = src;
}

/* main */

int main() {
  int m, n;
  string s, t;
  cin >> m >> n >> s >> t;

  memset(dp, 0, sizeof(dp));
  
  for (int i = m; i >= 0; i--)
    for (int j = n; j >= 0; j--) {
      if ((i < m && s[i] == 'I') || (j < n && t[j] == 'I')) dp[i][j] = 1;
      
      if (i < m && j < n &&
	  ((s[i] == 'I' && t[j] == 'O') || (s[i] == 'O' && t[j] == 'I')) &&
	  dp[i + 1][j + 1] > 0)
	setgreater(dp[i][j], dp[i + 1][j + 1] + 2);

      if (i < m - 1 && s[i] == 'I' && s[i + 1] == 'O' && dp[i + 2][j] > 0)
	setgreater(dp[i][j], dp[i + 2][j] + 2);

      if (j < n - 1 && t[j] == 'I' && t[j + 1] == 'O' && dp[i][j + 2] > 0)
	setgreater(dp[i][j], dp[i][j + 2] + 2);
    }

  int maxd = 0;
  for (int i = 0; i <= m; i++)
    for (int j = 0; j <= n; j++)
      setgreater(maxd, dp[i][j]);
  printf("%d\n", maxd);
  return 0;
}

Measured memory_bytes: 16856
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    REP(i, n){
        ll a; cin >> a;
        if (a%2 == 1){
            continue;
        }
        if (a%3 == 0){
            continue;
        }
        if (a%5 == 0){
            continue;
        }
        cout << "DENIED" << endl;
        return 0;
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	a*=b;  c*=d;
	if(a>=c)
	cout<<a<<"\n";
	else
	cout<<c<<"\n";
	
	return 0;
}

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

public class Main implements Runnable {
	public static void main (String[] args) {new Thread(null, new Main(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int N = fs.nextInt();
		X[] a = new X[N];
		for(int i = 0; i < N; i++) a[i] = new X(fs.next(), i, fs.nextInt());
		Arrays.sort(a);
		for(X x : a) out.println(++x.id);
		
		out.close();
	}
	
	class X implements Comparable<X>{
		String name;
		int id, score;
		X(String s, int a, int b) {
			name = s;
			id = a; score = b;
		}
		public int compareTo(X x) {
			int comp = name.compareTo(x.name);
			if(comp == 0) comp = Integer.compare(x.score, score);
			return comp;
		}
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
		
		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}
		
	}

}

Measured memory_bytes: 25428
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int n;
    cin >> n;

    double ans;
    while(n){
        double x;
        string u;
        cin >> x >> u;
        ans += x * (u == "BTC" ? 380000.0 : 1);
        n--;
    }
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 256
def gcd(m,n):  
    while m%n>0:
        m,n=n,m%n
    else:
        return n

while True:
    try:    
        a,b = map(int,raw_input().split())
        a,b = max(a,b),min(a,b)
        g = gcd(a,b)
        l = a*b/g
        print "%d %d" % (g, l)
    except EOFError: 
        break

Measured memory_bytes: 4216
/*input
2
1 1
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=3e3+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=3.14159265358979323846;
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
ll mult(ll a,ll b){
    ll res=0LL;
    while(b){
        if(b&1) res=(res+a)%MOD;
        a=(a+a)%MOD;
        b>>=1;
    }
    return res%MOD;
}
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int arr[maxn];
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n;
    cin>>n;
    REP(i,n) cin>>arr[i];
    int ans=0;
    REP(i,n){
        REP(j,i){
            REP(k,j){
                vector<int> v;
                v.pb(arr[i]);
                v.pb(arr[j]);
                v.pb(arr[k]);
                SORT_UNIQUE(v);
                if(sz(v)!=3) continue;
                sort(ALL(v));
                if(v[0]+v[1]>v[2]){
                    ++ans;
                }
            }
        }
    }    
    cout<<ans;
}


Measured memory_bytes: 3636
import java.util.*;

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

        double ans = 0;
        double odd = 0;
        if(N % 2 == 0) odd = N / 2;
        else odd = (N + 1) / 2;
        ans = odd / N;
        System.out.println(ans);
    }
}

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

int main(){
	int n;
	cin>>n;
	string s[n];
	rep(i,n)cin>>s[i];
	rep(i,n){
		for(int j=i+1;j<n;j++){
			if(s[i]==s[j]){
				puts("No");
				return 0;
			}
		}
	}
	rep(i,n-1){
		if(s[i][s[i].size()-1]!=s[i+1][0]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
h.insert(0, 0)
h.append(0)
cnt = 0
while True:
    s = -1
    e = -1
    m_n = 10 ** 10
    for i in range(1, n + 2):
        if h[i] != 0 and h[i-1] == 0:
            s = i
            m_n = min(m_n, h[i])
            for j in range(i + 1, n + 2):
                if h[j] == 0 and h[j - 1] != 0:
                    e = j - 1
                    break
                else:
                    m_n = min(m_n, h[j])
    if s == -1 and e == -1:
        print(cnt)
        exit()
    else:
        cnt += m_n
        for i in range(s, e + 1):
            h[i] -= m_n



Measured memory_bytes: 40944
import java.util.Objects;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int N = Integer.parseInt(s.next());
        int M = Integer.parseInt(s.next());
        // 問題毎、正解しているかどうか(配列でやらないと遅い)
        boolean[] completed = new boolean[N];
        // 問題毎、wa数
        int[] wa = new int[N];
        // 求めたいものたち
        int acCount = 0;
        int waCount = 0;
        for (int i = 0; i < M; i++) {
            int p = Integer.parseInt(s.next()) - 1;
            // 正解している問題ならなにもしない
            if (completed[p]) {
                s.next();
                continue;
            }
            String S = s.next();
            if (Objects.equals(S, "WA")) {
                // 問題毎、wa数を記録する
                wa[p]++;
            } else {
                // 正解数と、wa数を増加(wa数は正解時のみカウントする)
                acCount++;
                waCount += wa[p];
                completed[p] = true;
            }
        }
        System.out.println(acCount + " " + waCount);
    }

}


Measured memory_bytes: 59184
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		for(;;){
			int n=5;
			int[] a=new int[n];
			boolean[] exist=new boolean[3];
			for(int i=0; i<n; i++){
				if((a[i]=sc.nextInt()-1)==-1){
					return;
				}
				exist[a[i]]=true;
			}
			int s=0;
			for(int i=0; i<3; i++){
				if(exist[i]){
					s++;
				}
			}
			if(s==2){
				for(int i=0; i<n; i++){
					if(exist[(a[i]+1)%3]){
						println("1");
					}else{
						println("2");
					}
				}
			}else{
				println("3\n3\n3\n3\n3");
				continue;
			}
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

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


def main():
    n = int(input())
    b = list(map(int, input().split()))

    result = b[0]
    for i in range(n - 1):
        if i == n - 2:
            result += b[n - 2]
        else:
            result += min(b[i], b[i + 1])

    print(result)


if __name__ == "__main__":
    main()


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

int main(){
    int h,w;
    cin >> h >> w;
    int a[h][w];
    vector<P>orig;
    vector<P>after;
    rep(i,h){
        rep(j,w){
            int temp;
            cin >> temp;
            a[i][j] = temp;
        }
    }
    int count = 0;
    rep(i,h-1){
        rep(j,w){
            if(a[i][j] % 2 != 0){
                a[i][j]--;
                a[i+1][j]++;
                count++;
              P hoge;
                hoge.first = i+1;
                hoge.second = j+1;
                orig.push_back(hoge);
                hoge.first = i+2;
                after.push_back(hoge);
            }
        }
    }
    rep(i,w-1){
        if(a[h-1][i] % 2 != 0){
            a[h-1][i]--;
            a[h-1][i+1]++;
            count++;
          P hoge;
            hoge.first = h;
            hoge.second = i+1;
            orig.push_back(hoge);
            hoge.second = i+2;
            after.push_back(hoge);
        }
    }
    cout << count << endl;
    rep(i,count){
        cout << orig[i].first << ' ' << orig[i].second << ' ' << after[i].first << ' ' << after[i].second << endl; 
    }

}

Measured memory_bytes: 6272
n,x = map(int,input().split())
al = list(map(int,input().split()))

al = sorted(al)
for idx, a in enumerate(al):
   if x >= a:
      x -= a
   else:
      print(idx)
      import sys
      sys.exit()
if x > 0:
   print(n-1)
else:
   print(n)

Measured memory_bytes: 3060
import sys
input=sys.stdin.buffer.readline
N = int(input())
M = [[0]*N for _ in range(N)]
for _ in range(N):
    nums = list(map(int,input().split()))
    a = nums[1]
    if a == 0:
        continue
    else:
        for j in nums[2:]:
            M[nums[0]-1][j-1] = 1
for i in range(N):
    print(" ".join(map(str,M[i])))


Measured memory_bytes: 5660
import java.util.Scanner;

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

    int N = scanner.nextInt();
    char[] s = scanner.next().toCharArray();

    if (N % 2 == 1) {
      System.out.println("No");
      return;
    }
    for (int i = 0; i < N / 2; i++) {
      if (s[i] != s[i + N / 2]) {
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
  }
}


Measured memory_bytes: 22228
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>> 
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>> 
#define pii pair<int,int> 
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
ld pie=3.141592653589;
int mod=1e9+7;

bool Compare(pair<int,int> a, pair<int,int> b)
{
    int l1=a.ss-a.ff+1;
    int l2=b.ss-b.ff+1;
    if(l1!=l2) return l1>l2;
    return a.ff > b.ff;
}
std::priority_queue<pii, std::vector<pii>, std::function<bool(pii, pii)>> pq(Compare);



int32_t main(){ 
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  int n; cin>>n;
  string s; cin>>s;
  vi red,white;
  f(i,0,n) if(s[i]=='R') red.pb(i); else white.pb(i);
  int cnt=0;
  if(sz(red)!=0 && sz(white)!=0){
    int l=0;int r=sz(red)-1;
    while(l<sz(white) && r>=0 && red[r]>white[l]){
      ++cnt;
      --r; ++l;
    }
  }    
  cout<<cnt;
  return 0; 
}
// check for overflows dummy !!!


Measured memory_bytes: 5744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef string st;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef vector<string>si;
typedef list<int>li;
typedef multiset<int>msi;
typedef map<int,int>ma;
typedef stack<int>sta;
typedef queue<string,int>que;
typedef priority_queue<int,vector<int>,greater<int> >pq;
#define dd(x) cout<<#x<<"="<<x<<",";
#define de(x) cout<<#x<<"="<<x<<endl;
#define df(x) cout<<x<<endl;
#define dg(x) cout<<x<<" ";
#define rep(i,a,b) for(i=a;i<b;++i)
#define per(i,a,b) for(i=b-1;i>=a;--i)
#define rpp(i,a,b) for(i=a;i<2*b-1;i+=2)
#define all(x) (x).begin(),(x).end()
#define sz(x) (x).size()
#define mp make_pair
#define pb push_back
#define po2 pop_back
#define po1 front_back
#define fi first
#define se second
#define Nmax 200005
//erase  merge atoi atof
ll n;
const int N=575757;
bool search(ll a[], int key){
	ll left = 0;
	ll right = n;
	ll mid ;
	while(left < right){
		mid = (left + right) / 2;
		if(a[mid] == key)
		return 1;
		else if(a[mid] < key){
			left = mid + 1;
			}
			else
			right = mid ;
	}
	return 0;
}
int main()
{
	ll  m, i, j, count = 0;
	cin >> n;
	ll s[n];
	rep(i, 0, n){
		cin>>s[i];
	}
	cin >> m;
	rep (i, 0, m){
		cin >> j;
		if(search(s, j))
		count++;
	}
	df(count);
	return 0;
}



Measured memory_bytes: 3796
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

//隣接するABの個数

int main(void){
	bool ans=false;
	ll n,m,x,y,cnt=1,a[200010]={},b[200010]={},ng[200010]={};
	string s;
	vector<ll> v[200010];
	cin>>n>>m>>s;
	rep(i,m){
		cin>>x>>y;
		v[x-1].push_back(y-1);
		v[y-1].push_back(x-1);
		if(s[x-1]=='A'){
			a[y-1]++;
		}else{
			b[y-1]++;
		}
		if(s[y-1]=='A'){
			a[x-1]++;
		}else{
			b[x-1]++;
		}
	}
	rep(i,n){
		if(ng[i]==1)continue;
		if(a[i]==0||b[i]==0){//周囲すべてからs[i]を引く
			queue<ll> Q;
			ng[i]=1;
			Q.push(i);
			while(!Q.empty()){
				ll p = Q.front();Q.pop();
				rep(j,v[p].size()){
					ll q = v[p][j];
					if(ng[q]==1)continue;
					if(s[p]=='A'){
						a[q]--;
					}else{
						b[q]--;
					}
					if(a[q]==0 || b[q]==0){
						ng[q]=1;
						Q.push(q);
					}
				}
			}
		}
	}
	//安全なやつで辺があるか確認
	rep(i,n){
		if(ng[i]==1)continue;
		rep(j,v[i].size()){
			ll p = v[i][j];
			if(ng[p]==0)ans=true;
		}
	}
	cout<<(ans?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 16388
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int main()
{
    char s[100005], ss[100005];
    scanf("%s", s);
    int sum=0, ans=0, len=strlen(s);
    while(1)
    {
        for(int i=1;i<len-1;i++)
        {
            if(s[i]!='\0')
            {
                int x=i-1; 
                while(s[x]=='\0')   x--;
                if(s[x]!=s[i+1])
                {
                    s[i]='\0';
                    sum++;
                }
            }
        }
        int cnt=0;
        for(int i=0;i<len;i++)
            if(s[i]!='\0')
                ss[cnt++]=s[i];
        for(int i=0;i<len;i++)
            s[i]=ss[i];
        len=cnt;
        if(sum==ans)
            break;
        ans=sum;
    }
    if(sum%2)
        printf("First\n");
    else
        printf("Second\n");
    return 0;
}

Measured memory_bytes: 384
N, K = map(int, input().split())
X = list(map(int, input().split()))

ans = 10**18
for l, r in zip(X, X[K - 1:]):
    if r <= 0:
        ans = min(ans, abs(l))
    if l >= 0:
        ans = min(ans, abs(r))
    if l < 0 < r:
        ans = min(ans, r - l + min(abs(r), abs(l)))
print(ans)


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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n), dp1(n), dp2(n);
    rep(i, 0, n) cin >> a[i];
    ll ans1 = 0, ans2 = 0;

    if(a[0] > 0){
        ans2 = a[0] - (-1);
        dp1[0] = a[0];
        dp2[0] = -1;
    }else if(a[0] == 0){
        ans1 = 1;
        ans2 = 1;
        dp1[0] = 1;
        dp2[0] = -1;
    }else{
        ans1 = 1 - a[0];
        dp1[0] = 1;
        dp2[0] = a[0];
    }
    rep(i, 1, n){
        if(dp1[i-1] < 0){
            if(dp1[i-1] + a[i] > 0){
                dp1[i] = dp1[i-1] + a[i];
            }else if(dp1[i-1] + a[i] == 0){
                ans1 += 1;
                dp1[i] = 1;
            }else{
                dp1[i] = 1;
                ans1 += 1 - (dp1[i-1] + a[i]);
            }
        }else{
            if(dp1[i-1] + a[i] < 0){
                dp1[i] = dp1[i-1] + a[i];
            }else if(dp1[i-1] + a[i] == 0){
                ans1 += 1;
                dp1[i] = -1;
            }else{
                dp1[i] = -1;
                ans1 += (dp1[i-1] + a[i]) - (-1);
            }
        }

        
        if(dp2[i-1] < 0){
            if(dp2[i-1] + a[i] > 0){
                dp2[i] = dp2[i-1] + a[i];
            }else if(dp2[i-1] + a[i] == 0){
                ans2 += 1;
                dp2[i] = 1;
            }else{
                dp2[i] = 1;
                ans2 += 1 - (dp2[i-1] + a[i]);
            }
        }else{
            if(dp2[i-1] + a[i] < 0){
                dp2[i] = dp2[i-1] + a[i];
            }else if(dp2[i-1] + a[i] == 0){
                ans2 += 1;
                dp2[i] = -1;
            }else{
                dp2[i] = -1;
                ans2 += (dp2[i-1] + a[i]) - (-1);
            }
        }
    }

    cout << min(ans1, ans2) << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	char s[101]={};
	cin>>s;
	int l=strlen(s);
	bool c=true;
	for(int i=0; i<l; i++){
		if(s[i]!='U' && s[i]!='D'){
			if(i%2==0){
				if(s[i]!='R'){
						c=false;
				}
			}else{
				if(s[i]!='L'){
					c=false;
				}
			}
		}
	}
	if(c){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

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

using namespace std;

int main(){
    string a, b, c; cin >> a >> b;
    c = (a + b);
    for(int i = 0;i < 320;++i){
        if(to_string((int)pow(i, 2)) == c){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
public class Main {

	/**
	 * ????????????????????????
	 *
	 * @param args
	 */
	public static void main(String[] args) {
		for (int i = 1; i < 10; i++) {
			for (int j = 1; j < 10; j++) {
				System.out.println(i + "x" + j + "=" + i * j);
			}
		}
	}
}

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

// struct Edge{
//     int v;
//     int cap;
//     int flow;
//     int rev;
// };

// class Graph{
//     public:
//         int V;
//         int *level;
//         vector<Edge> *adj;

//         Graph(int V)
//         {
//             this->V=V;
//             level=new int[V+1];
//             adj=new vector<Edge>[V+1];
//         }

//         void addEdge(int u,int v,int cap)
//         {
//             Edge a{v,cap,0,adj[v].size()};
//             Edge b{u,0,0,adj[u].size()};
//             adj[u].push_back(a);
//             adj[v].push_back(b);
//         }

//         bool bfs(int s,int t)
//         {
//             for(int i=0;i<=V;i++)
//             {
//                 level[i]=-1;
//             }
//             queue<int> q;
//             q.push(s);
//             level[s]=0;
//             while(!q.empty())
//             {
//                 int y=q.front();
//                 q.pop();
//                 for(auto it=adj[y].begin();it!=adj[y].end();it++)
//                 {
//                     Edge &e=(*it);
//                     if(e.flow<e.cap && level[e.v]==-1)
//                     {
//                         level[e.v]=level[y]+1;
//                         q.push(e.v);
//                     }
//                 }
//             }
//             return (level[t]!=-1);
//         }

//         int gflow(int cur,int t,int flow,int *start)
//         {
//             if(cur==t)
//             {
//                 return flow;
//             }
//             for(;start[cur]<adj[cur].size();start[cur]++)
//             {
//                 Edge &e=adj[cur][start[cur]];

//                 if(e.flow<e.cap && level[e.v]==level[cur]+1)
//                 {
//                     int cflow=min(flow,e.cap-e.flow);
//                     int tflow=gflow(e.v,t,cflow,start);
//                     if(tflow>0)
//                     {
//                         e.flow+=tflow;
//                         adj[e.v][e.rev].flow-=tflow;
//                         return tflow;
//                     }
//                 }
//             }
//             return 0;
//         }

//         int dinic(int s,int t)
//         {
//             if(s==t)
//             {
//                 return -1;

//             }
//             int tflow=0;
            
//             while(bfs(s,t))
//             {
//                 int *start=new int[V+1];
            
//                 while(int flow=gflow(s,t,INT_MAX,start))
//                 {
//                     tflow+=flow;
//                 }
//             }
//             return tflow;
//         }


// };

int main(){
    int d,t,s;
    cin>>d>>t>>s;
    if(t*s>=d)
    {
        cout<<"Yes"<<endl;
    }
    else 
    {
        cout<<"No"<<endl;
    }
    return 0;
}


       
    
    
    

Measured memory_bytes: 3612