akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#define PR pair<int,int>
#define F first
#define S second
#define N 200005
using namespace std;

int n, sz, a[N], v[N], d[N];
vector<int> gr[N];
stack<PR> st;

void f(int p) {
	if(v[p]) return;
	int k = lower_bound(d, d+sz, a[p]) - d;
	if(k == sz) sz++;
	v[p] = sz;
	st.push({k, d[k]});
	d[k] = a[p];
	for(auto x:gr[p]) f(x);
	PR t = st.top(); st.pop();
	d[t.F] = t.S;
	if(t.S==1e9) sz--;
}

int main() {
	int i, t1, t2;
	cin >> n;
	for(i=1; i<=n; i++) scanf("%d", &a[i]);
	for(i=0; i<n-1; i++) {
		scanf("%d%d", &t1, &t2);
		gr[t1].push_back(t2);
		gr[t2].push_back(t1);
	}
	for(i=0; i<n; i++) d[i] = 1e9;
	f(1);
	for(i=1; i<=n; i++) printf("%d\n", v[i]);
	return 0;
}

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

#define ll long long
using namespace std;
const int N = 1e6 + 5, mod = 998244353;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll x;
    cin >> x;
    ll y = x / 500;
    cout << y * 1000 + (x %500) / 5 * 5;
    return 0;
}

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

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, Y) = Read2Longs();
            for (var x = 0; x <= N; x++)
            {
                for (var y = N - x; y >= 0; y--)
                {
                    var z = N - (x + y);
                    if (x * 10000 + y * 5000 + z * 1000 == Y)
                    {
                        return $"{x} {y} {z}";
                    }
                }
            }
            return "-1 -1 -1";
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28264
#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;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    ll l = 0, r = s.length() - 1, ans = 0;
    while(l < r) {
    	if(s[l++] != s[r--]) {
    		ans++;
    	}
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) find(Range(c), x) != c.end()
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"

using namespace std;
using ll = long long;

int main(void){
    Cin(string, s);
    Sort(s);
    Cin(string, t);
    DeSort(t);
    Cout(s < t ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#define all(x) (x).begin(), (x).end()
#define xx first
#define yy second

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int main()
{
	int n, a, b;
	scanf("%d %d %d", &n, &a, &b);

	for (int r = 0; r <= a - 1 && n - r >= b; r++)
	{
		//맨앞에 r개 짜투리를 남겨놓고
		//나머지를 b개 단위로 묶은 그냥 숫자로 본다
		if ((n - r + b - 1) / b != a - r)
			continue;

		for (int i = 1; i <= r; i++)
			printf("%d ", i);

		//r+1부터 역순 짜투리
		for (int k = 0; k < a - r; k++)
		{
			int start = min(n, r + (k + 1) * b);

			while (start > r + k * b)
			{
				printf("%d ", start);
				start--;
			}
		}

		return 0;
	}

	printf("-1\n");

	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
 
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
 
  std::string A, B;
  std::cin >> A >> B;
  if (A.length() < B.length()) {
    std::cout << "LESS\n";
    return 0;
  } else if (A.length() > B.length()) {
    std::cout << "GREATER\n";
    return 0;
  }
 
  for (size_t i=0; i<A.length(); ++i) {
    if (A[i] < B[i]) {
      std::cout << "LESS\n";
      return 0;
    } else if (A[i] > B[i]) {
      std::cout << "GREATER\n";
      return 0;
    }
  }
 
  std::cout << "EQUAL\n";
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
	int month[12]={0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30};
	int m, d, days, i;
	while(1){
		scanf("%d %d", &m, &d);
		if(m == 0) break;
		days = 0;
    	for(i = 0; i < m; i++) days += month[i];
    	days += d;
    	switch(days % 7){
    		case 0:
    			printf("Wednesday\n");
    			break;
    		case 1:
    			printf("Thursday\n");
    			break;
    		case 2:
    			printf("Friday\n");
    			break;
    		case 3:
    			printf("Saturday\n");
    			break;
    		case 4:
    			printf("Sunday\n");
    			break;
    		case 5:
    			printf("Monday\n");
    			break;
    		case 6:
    			printf("Tuesday\n");
    			break;
    	}
	}
	return 0;
}

Measured memory_bytes: 584
/*     ####   ####  #               ####  #        ##   #    # #    # ###### #####
	  #      #    # #              #      #       #  #  ##  ## ##  ## #      #    #
	   ####  #    # #               ####  #      #    # # ## # # ## # #####  #    #
		   # #  # # #                   # #      ###### #    # #    # #      #####
	  #    # #   #  #              #    # #      #    # #    # #    # #      #   #
	   ####   ### # ###### #######  ####  ###### #    # #    # #    # ###### #    #
*/
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<pair<LL, LL> > VP;
 
 
#define For(in) for (LL i = 0; i < (n); i++)
#define FOR(in) for(LL i=1; i <= (n); i++)
#define pb push_back
#define srt(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define uniq(v) v.erase(unique(v.begin(), v.end()), v.end());
#define exit(); return 0;
#define no "NO"
#define yes "YES"
#define con continue;
 
 
bool is_prime[1000001];
VLL primes;
void seive()
{
	LL maxN = 1000001;
	is_prime[0]=true;
	is_prime[1]=true;
	
	for(LL i=2; i*i<=maxN; i++)
	{
		if(!is_prime[i])
		{
			for(LL j=i*i; j<=maxN; j+=i)
				is_prime[j]=true;
		}
	}
	for(LL i=2; i<=maxN; i++)
	{
		if(!is_prime[i])primes.pb(i);
	}
}

 
LL binpow(LL a, LL b, LL c)
{
	a %= c;
	LL res = 1 ;
	while(b > 0){
		if(b & 1)
		res = res * a % c ;
		a = a * a % c ;
		b >>= 1;
		//cout<<res<<endl;
	}
	return res;
}
 
LL mod = 1e9+7;
 
int main()
{
	ios_base::sync_with_stdio(false);
	//seive();

	//LL q,t;
	//cin>>t;
	//while(t--)
	//{
		LL a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,r=0,u=0,w=0,x=0,y=0,z=0;
		//LL aa[10000];
		LL flag=0, flag1=0, co=0, co1=0, co2=0, co3=0, x1=0, x2=0, y1=0, y2=0, z1=0, z2=0;
		LL ma=0, mi=100000000;
		LL mid=0, temp=0, stop=0, start=0, ans=0;
		double pi= 3.141592653589793;
		double d1=0.0, d2, d3, d4;
		VLL v,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10;
		VS vs, vs1, vs2, vs3, vs4;
		VP vp, vp1,vp2;
		char ch, ch1, ch2[1001];
		string str, str1, str2, str3, str4, str5;
		pair<LL, LL> pa;
		list<LL> li, li1;
		map<LL, LL> mp, mp1;
		set<LL> st;
		map<LL ,LL> :: iterator imll;
		VLL :: iterator ivll;
		set<LL> :: iterator isll;
		VP :: iterator ivp;
		
		cin>>a>>b>>c;
		
		for(i=a; i<=b; i++)
		{
			if(i%c==0)x++;
		}
		cout<<x<<endl;
		
		
	//}
	exit()
 
 
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;

const int dy[] = {0,0,1,-1};
const int dx[] = {1,-1,0,0};
int main()
{
	ll n;
	cin >> n;
	ll ans = 0;
	for(ll a = 1; a <= n; a++){
		for(ll b = a; a * b < n; b++){
			bool same = false;
			if(a == b) same = true;
			ll c = n - a * b;
			if(c < 1) continue;
			else {
				if(same) ans ++;
				else ans += 2;
			}
		}
	}
	cout << ans << endl;
	
}


Measured memory_bytes: 3644
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
P<int,int> p[1000005];
int n;
priority_queue<P<int,int>> q;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>n;
	FOR(i,1,n){
		cin>>s;
		int sum=0,mini=0;
		for(auto u:s){
			if(u=='('){
				sum++;
			}else{
				sum--;
				gmin(mini,sum);
			}
		}
		p[i]=MP(-mini,sum);
	}
	sort(p+1,p+n+1);
	int now=0,start=1;
	P<int,int> cur;
	FOR(i,1,n){
		while(start<=n&&p[start].F<=now){
			q.emplace(MP(p[start].S+p[start].F,p[start].F));
			start++;
		}
		if(q.empty()||q.top().S>now){
			cout<<"No\n";RE 0;
		}
		cur=q.top();q.pop();
		now+=cur.F-cur.S;
	}
	if(now)cout<<"No\n";
	else cout<<"Yes\n";
	RE 0;
}




Measured memory_bytes: 19392
#include<bits/stdc++.h>
using namespace std;
const int N=200002;
int a[N];
int b[N];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		if(b[i]<=a[n/2]){
			printf("%d\n",a[n/2+1]);
		}else{
			printf("%d\n",a[n/2]);
		}
	}
	return 0;
}

Measured memory_bytes: 3712
#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define INT_MAX_VALUE 2147483647
#define LONG_LONG_MAX_VALUE 9223372036854775807
#define ll long long
#define ld long double

struct XX{
    ll la;
    ll lb;
    ll ra;
    ll rb;
    ll q;
};

class xxGreater {
public:
    bool operator()(const XX& riLeft, const XX& riRight) const {
        //第2条件
        if((riLeft.q) == (riRight.q)){
            return riLeft.q < riRight.q;//<:昇順(小さいものから順番)、>:降順(大きいものから順番)
            //プライオリティキューの場合は > で、top()すると値の小さいものがとれる
        }
        //第1条件
        return (riLeft.q) < (riRight.q);
    }
};


//map<long long,long long> prime_f(long long n){
//    map<long long,long long>res;
//    for(int i=2;i*i<=n;i++){
//        while(n%i==0){
//            ++res[i];
//            n/=i;
//        }
//    }
//    if(n!=1)res[n]=1;
//    return res;
//}


int n;
//int dat[2*10000000];
//int dat2[2*10000000];
int dat[2*100];
int dat2[2*100];

void init(int n_){
    n=1;
    while(n<n_)n*=2;
    for(int i=0;i<2*n-1;i++){
        dat[i]=0;
        dat2[i]=0;
    }
}

void initset(int k,int a){
    k+=n-1;
    dat[k]=a;
    while(k>0){
        k=(k-1)/2;
        dat[k]=dat[k*2+1]+dat[k*2+2];
    }
}

//[a,b)の間を[l,r]区間で比較しアップデート
//引数のindexに注意
//nは固定。initで計算すみ
//update2(L[i],R[i]+1,0,0,n,D[i]);
void update2(int a,int b,int k,int l,int r,int v){//v更新値、区間は0-index
    if(r<=a || b<=l)return;
    if(a<=l && r<=b){
        dat[k]+=dat2[k];
        if(r-l>1){
            dat2[k*2+1]+=dat2[k]/2;
            dat2[k*2+1]+=dat2[k]/2;
        }
        dat2[k]=v*(r-l);
        return;
    }else{
        update2(a,b,k*2+1,l,(l+r)/2,v);
        update2(a,b,k*2+2,(l+r)/2,r,v);
        return;
    }
}

int query(int a,int b,int k,int l,int r){
    if(r<=a || b<=l)return 0;
    if(a<=l && r<=b){
        dat[k]+=dat2[k];
        if(r-l>1){
            dat2[k*2+1]+=dat2[k]/2;
            dat2[k*2+1]+=dat2[k]/2;
        }
        dat2[k]=0;
        return dat[k];
    }
    else{
        int vl=query(a,b,k*2+1,l,(l+r)/2);
        int vr=query(a,b,k*2+2,(l+r)/2,r);
        return vl+vr;
    }
}



int main(int argc, const char * argv[])
{
    //scanf("%s",S);
    //scanf("%d",&N);
    //scanf("%lld %lld",&target1,&target2);
    //sscanf(tmp.c_str(),"%dd%d%d",&time[i], &dice[i], &z[i]);
    //getline(cin, target);
    //ifstream ifs( "1_06.txt" );//テスト用
    //ifs >> a;
    //ここから
    
    //入力高速化
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    
    if(K%2==0){
        cout << A-B << endl;
    }else{
        cout << B-A << endl;
    }
    
    
    //ここまで
    //cout << "ans" << endl;改行含む
    //printf("%.0f\n",ans);//小数点以下表示なし
    //printf("%.7f\n",p);
    
    return 0;
}




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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, M; scanf("%d %d", &N, &M);
  vector<vector<int>> dist(N + 1, vector<int>(N + 1, INF));
  vector<vector<int>> pred(N + 1, vector<int>(N + 1, -1));
  int a, b, c;
  for (int i = 0; i < M; ++i) {
    scanf("%d %d %d", &a, &b, &c);
    dist[a][b] = dist[b][a] = c;
    pred[a][b] = a;
    pred[b][a] = b;
  }
  for (int k = 1; k <= N; ++k) {
    for (int i = 1; i <= N; ++i) {
      for (int j = 1; j <= N; ++j) {
        if (dist[i][j] > dist[i][k] + dist[k][j]) {
          dist[i][j] = dist[i][k] + dist[k][j];
          pred[i][j] = pred[k][j];
        }
      }
    }
  }

  set<pair<int, int>> edges;
  for (int i = 1; i <= N; ++i) {
    for (int j = i + 1; j <= N; ++j) {
        int u = i, v = j;
        while (true) {
          edges.insert(make_pair(min(pred[u][v], v), max(pred[u][v], v)));
          v = pred[u][v];
          if (u == v) { break; }
        }
    }
  }
  int ans = M - edges.size();
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>


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

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

int main(void) {
	
	int N, K;
	int count = 0;
	std::cin >> N >> K;
	std::vector<int> h(N, 0);
	for (int i = 0; i < N; i++) {
		std::cin >> h[i];
		if (h[i] >= K) {
			count++;
		}
	}
	std::cout << count;
	
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B, C, D, E;
  cin >> A;
  B = A/1000;
  C = (A-  B *1000 ) /100;
  D = (A - (A/100)*100 ) /10;
  E = A - (A/10) * 10;
    
  if((C==D)&&((B==C)||(D==E))){  
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

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

struct state {
	int x, y, t, c;
	state(int x, int y, int t, int c) : x(x), y(y), t(t), c(c) {};
	bool operator<(const state &o)const {
		return o.c<c;
	}
};

int main() {
	vvi field(200+1, vi(200+1));
	int sx, sy, gx, gy, n, x, y, lx, ly;
	cin >> sx >> sy >> gx >> gy >> n; 
	REP(i, n) {
		cin >> x >> y;
		field[y+100][x+100] = 1;
	}
	cin >> lx >> ly;

	priority_queue<state> Q;
	Q.push(state(sx+100, sy+100, 0, 0));
	vector<vvi> cost(200+1, vvi(200+1, vi(6, INF)));
	cost[sy+100][sx+100][0] = 0;
	while(!Q.empty()) {
		state st = Q.top();
		Q.pop();

		if(st.x == gx+100 && st.y == gy+100) {
			cout << st.c << endl;
			return 0;
		}

		REP(d, 7) {
			int nx = st.x + dx[d];
			int ny = st.y + dy[st.x%2][d];
			if(nx < 0 || lx < abs(nx-100) || ny < 0 || ly < abs(ny-100) || field[ny][nx]) {
				continue;
			}

			int nc = st.c;
			if(abs((st.x-100)*(st.y-100)*st.t)%6 != d) {
				nc++;
			}

			if(nc < cost[ny][nx][(st.t+1)%6]) {
				cost[ny][nx][(st.t+1)%6] = nc;
				Q.push(state(nx, ny, st.t+1, nc));
			}
		}
	}

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

Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

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

  string s;
  cin >> s;

  int x[30] = {0};
  rep(i, s.size()) { x[s[i] - 'A']++; }
  int c = 0;
  bool f = true;
  rep(i, 30) {
    if (x[i] != 0) {
      c++;
      if (x[i] != 2) f = false;
    }
  }

  if (c == 2 && f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main() {
    uint K; cin >> K;
    string S; cin >> S;
    if (S.size() <= K) {
        cout << S << endl;
    }
    else {
        string S2(K+3, '.');
        for (size_t i=0; i<K; i++) {
            S2[i] = S[i];
        }
        cout << S2 << endl;
    }
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
vector<vector<long long>> vec(10);
int main() {
    long long n, w;
    cin >> n >> w;
    long long sw, sv;
    cin >> sw >> sv;
    vec[0].emplace_back(sv);
    for (int i = 0; i < n - 1; i++) {
        long long nw, nv;
        cin >> nw >> nv;
        vec[nw - sw].emplace_back(nv);
    }
    sort(vec[0].rbegin(), vec[0].rend());
    sort(vec[1].rbegin(), vec[1].rend());
    sort(vec[2].rbegin(), vec[2].rend());
    sort(vec[3].rbegin(), vec[3].rend());
    for (int i = 0; i < 4; i++) {
        for (int j = 1; j < vec[i].size(); j++) {
            vec[i][j] += vec[i][j - 1];
        }
    }
    long long ans = 0;
    for (int i = 0; i < vec[0].size()+1; i++) {
        for (int j = 0; j < vec[1].size()+1; j++) {
            for (int k = 0; k < vec[2].size()+1; k++) {
                for (int l = 0; l < vec[3].size()+1; l++) {
                    long long co = 0;
                    co += sw * i;
                    co += (sw + 1) * j;
                    co += (sw + 2) * k;
                    co += (sw + 3) * l;
                    if (co <= w) {
                        long long a = 0;
                        if (i != 0) {
                            a += vec[0][i - 1];
                        }
                        if (j != 0) {
                            a += vec[1][j - 1];
                        }
                        if (k != 0) {
                            a += vec[2][k - 1];
                        }
                        if (l != 0) {
                            a += vec[3][l - 1];
                        }
                        if (a > ans) {
                            ans = a;
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}



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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> roads(n+1, 0);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    roads.at(a)++;
    roads.at(b)++;
  }
  for (int i = 1; i < n+1; i++) {
    cout << roads.at(i) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#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;
 

 
#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define MX 100005
#define N 102
 
//Solution
 
int n,W;
int w[N],v[N];
int dp[N][MX];
 
void solve(){
    cin>>n>>W;
    for(int i=1;i<=n;i++) cin>>w[i]>>v[i];
    for(int i=1;i<=n;i++){
        for(int j=0;j<=W;j++){
            dp[i][j] = dp[i-1][j];
            if(j >= w[i]) dp[i][j] = max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
        }
    }
    int ans = 0;
    for(int i=0;i<=W;i++) ans = max(ans,dp[n][i]);
    cout<<ans;
}
 
signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 81684
#include <stdio.h>

int main(void){
	
	
	int a,b,h,daikei;
	
	scanf("%d %d %d",&a,&b,&h);
	
	daikei = ((a + b) * h)/ 2;
	
	printf("%d\n",daikei);
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] a = new int [n];
    for(int i = 0;i < n;i++){
      a[i] = sc.nextInt();
    }

    int kind = 0;
    int[] l = new int [n];
    Arrays.sort(a);
    for(int i = 0;i < n - 1;i++){
      l[kind]++;
      if(a[i] != a[i + 1]){
        kind++;
      }
    }
    l[kind]++;
    kind++;

    if(k < kind){
      int kindSum = 0;
      Arrays.sort(l);
      for(int i = 0;k != kind;){
        if(l[i] != 0){
          kindSum += l[i];
          kind--;
        }
        i++;
      }
      System.out.println(kindSum);
    }else{
      System.out.println(0);
    }
  }
}

Measured memory_bytes: 66484
#include <cstdio>
#include <cstring>

int main(void){
  char ra[4005]={0};
  char rb[4005]={0};
  while(scanf("%s%s",ra,rb)!=EOF){
    int alen=strlen(ra);
    int blen=strlen(rb);
    //printf("%d\n%d\n",alen,blen);
    int i=0;
    int j=0;
    int k=0;
    int h=0;
    int km=0;
    int ans=0;
    /*raとrbをiだけずらす。*/
    for(i=-blen;i<alen;i++){
      /*k=(alen-i<blen)?alen-i:blen;
	h=(i<0)?-i:0;*/
      h=0;
      k=alen;
      km=0;
      for(j=h;j<k;j++){
	if(j>=0 && i+j>=0 ){
	  if(j>=alen || j+i>=blen){
	    ans=(ans<km)?km:ans;
	    km=0;
	    break;
	  }
	  if(ra[j]==rb[i+j]){
	    km++;
	  }
	  else{
	    ans=(ans<km)?km:ans;
	    km=0;
	  }
        }
      }
      ans=(ans<km)?km:ans;
      km=0;
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 980
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

bool can1(long long n, long long k){
  if (n%k==0) return false;
  if ((n-1)%k==0) return true;
  else return false;
}

int main(){
  long long N;
  scanf("%lld", &N);
  std::map<long long, int > mp1;
  long long temp = N-1;
  long long ans1=0;
  for (long long i=1; i*i<=temp; i++){
    if (temp%i==0){
      if (i>1) ans1++;
      if (i*i!=temp){
	ans1++;
      }
    }
  }
  
  
  long long ans2 = 0;
  for (long long i=1; i*i<=N; i++){
    temp = N;
    if (temp%i==0){
      if (i>1){
	while(temp%i==0){
	  temp = temp/i;
	}
	if (temp>0 && (temp-1)%i==0) ans2++;
      }
      //
      if (i*i!=N){
	long long opposite = N/i;
	temp = N;
	while(temp%opposite==0){
	  temp = temp/opposite;
	}
	if (temp>0 && (temp-1)%opposite==0) ans2++; 
      }
    }
  }
  std::cout << ans1+ans2 << std::endl;
  return 0;
  
}
 

Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll a,b,c; cin>>a>>b>>c;
	if((a==b && a!=c) || (a==c && a!=b) || (b==c && a!=c))cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

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

int main(){
    int x, y; cin >> x >> y;
    int a, b, c; cin >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    rep(i, 0, a) cin >> p[i];
    rep(i, 0, b) cin >> q[i];
    rep(i, 0, c) cin >> r[i];
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());

    vector<int> d;
    rep(i, 0, x) d.push_back(p[i]);
    rep(i, 0, y) d.push_back(q[i]);
    rep(i, 0, c) d.push_back(r[i]);
    sort(d.rbegin(), d.rend());

    ll ans = 0;
    rep(i, 0, x+y) ans += d[i];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4596
n=int(input())
a=list(map(int,input().split()))
ans=0
mod=10**9+7
for j in range(60):
    cnt1=sum([1 for i in a if i>>j&1])
    cnt0=n-cnt1
    ans+=(cnt1*cnt0*2**j)
print(ans%(10**9+7))


Measured memory_bytes: 42156
#include<string>
#include<iostream>
#include<cctype>
#include<cmath>
#include<cstdio>

using namespace std;

int main()
{
	double x1,y1,x2,y2;

	cin >> x1 >> y1 >> x2 >> y2;
	
	double c = sqrt(pow(x1-x2,2)+pow(y1-y2,2));
	
	printf("%f\n",c);
	
	return 0;
	
}

Measured memory_bytes: 1228
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
#include <cassert>
#include <complex>
using namespace std;
//#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<int,P> Q;

int board[505][505];

int main() {
    int n;
    cin>>n;
    vector<ll>a(n),b(n);
    for(int i=0;i<n;i++)cin>>a[i]>>b[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    if(n%2==1){
        cout<<b[n/2]-a[n/2]+1<<endl;
    }
    else{
        ll mi = a[n/2-1]+a[n/2];
        ll ma = b[n/2-1]+b[n/2];
        cout<<ma-mi+1<<endl;
    }
}


Measured memory_bytes: 6364
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define clr(v,line) memset(v,line,sizeof(v))
#define endl '\n'
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 <<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* coma = strchr(names + 1, ',');cerr.write(names, coma - names) << " : " << arg1<<" | ";__f(coma+1, args...);
}
#else
#define trace(...)
#endif
 
void file() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
}


ll n, w, sum = 0;

ll u[105], v[105];

std::vector<ll> dp;

int main(int argc, char const *argv[])
{
    // file();
    fast();

    cin>>n>>w;

    for (int i = 0; i < n; ++i)
    {
        cin>>u[i]>>v[i], sum+=v[i];
    }
    
    dp.assign(sum + 6, 1e9 + 7);
    
    // dp[i] = the minimum total weight with value i
    
    dp[0] = 0;
    for (int i = 0; i < n; ++i)
    {
        for (int j = sum; j >= v[i] ; --j)
        {
            dp[j] = min(dp[j], dp[j - v[i]] + u[i]);
        }
    }
    ll ans=0;
    for (ll i = 0; i <= sum; ++i)
    {
        if(dp[i]<=w)ans=max(ans, i);
    }
    cout<<ans;
    
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
#define MAX 20000
int prime_number[MAX] = {0};

int prime(int x){
	int i;
	for(i = 0; sqrt(x) >= prime_number[i]; i++){
		if(x % prime_number[i] == 0){
			return 0;
		}
	}
	return 1;
}

int main(void){
	int prime_count = 1;
	int i;
	int X;
	scanf("%d", &X);
	prime_number[0] = 2;
	
	//Ｘ以下の素数表を作成
	for(i = 3; i <= X; i++){
		if(prime(i)){
			prime_number[prime_count] = i;
			prime_count++;
		}
	}
	//２以外の偶数は素数たりえない
	if(X % 2 == 0){
		if(X != 2){
			i = X + 1;
		}
		else{
			i = X;
		}
	}
	else{
		i = X;
	}
	//最小素数判定
	for(; !prime(i); i += 2){
	}
	printf("%d", i);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int n; cin >> n;
  int memo[45];

  memo[0] = memo[1] = 1;

  for(int i = 2; i <= n; i++)
    memo[i] = memo[i - 1] + memo[i - 2];

  cout << memo[n] << endl;

  return 0;
}



Measured memory_bytes: 3112
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

int main(){
    int n;cin>>n;
    ll res = 0;
    rep(i,n){
        ll a;cin>>a;
        while(a%2==0){
            res++;
            a /= 2;
        }
    }
    cout<<res;
}



Measured memory_bytes: 256
N = int(input())
if N == 1:
  print(1)
elif 2 <= N <= 3:
  print(2)
elif 4 <= N <= 7:
  print(4)
elif 8 <= N <= 15:
  print(8)
elif 16 <= N <= 31:
  print(16)
elif 32 <= N <= 63:
  print(32)
elif 64 <= N <= 100:
  print(64)

Measured memory_bytes: 3060
n=int(input())
s=input()
rcount=0
wcount=0
n=len(s)
ans1=0
ans2=0
for i in range(0,n):
    if(s[i]=='R'):
        rcount+=1
    else:
        wcount+=1
for i in range(0,rcount):
    if(s[i]!='R'):
        ans1+=1
for i in range(rcount,n):
    if(s[i]!='W'):
        ans2+=1
print(min(ans1,ans2))

Measured memory_bytes: 67892
#include<stdio.h>
int main(void)
{
	int i,a,b,c,d,e; 
	while(1){
		scanf("%d",&d);
		if(d==0) break;
		c=0; e=0;
		for(i=0;i<12;i++){
			scanf("%d %d",&a,&b);
			c+=a-b;
			if(c>=d){
				e++;
			}
		}
		if(c<d){
			printf("NA\n");
		}
		else{
			printf("%d\n",12-e+1);
		}
	}
	return 0;
}

Measured memory_bytes: 612
k, s = map(int, input().split())
res = 0
for x in range(k+1):
  if 3 * x == s:
    res += 1
for x in range(k+1):
  for y in range(k+1):
    if x == y:
      continue
    if 2 * x + y == s:
      res += 3
for x in range(k+1):
  for y in range(x+1, k+1):
    d = s - x - y
    if d > y and d <= k:
      res += 6

print(res)

Measured memory_bytes: 3064
n, m = gets.split.map(&:to_i)

a, v, tmp, ans = [], Array.new(n, 0), 0, nil

n.times do |i|
  a << gets.to_i
end

m.times do |i|
  b = gets.to_i
  
  a.each_index do |j|
    if a[j] <= b
      v[j] += 1
      break
    end
  end
end

v.each_index do |i|
  ans, tmp = i + 1, v[i] if tmp < v[i]
end

puts ans

Measured memory_bytes: 8832
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
char mem[214514];
char t[214514];
char c[214514];
string s[214514];
int l[214514],r[214514];
int a[214514];
int sa[214514];
pair<int,int> b[214514];
signed main(){
	sc(s) sc(t)
	ic(n) ic(m)
	sc(ss)
	if(ss==s)cout<<n-1<<" "<<m<<endl;
	else cout<<n<<" "<<m-1<<endl;
}	

Measured memory_bytes: 4352
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] L = new int[N];
    for (int i = 0; i < N; i++) {
      L[i] = sc.nextInt();
    }
    sc.close();

    Arrays.sort(L);
    
    int answer = 0;

    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        int d = L[i] + L[j];
        int r = binary_search(L, d);
        int l = j + 1;
        answer += Math.max(0, r - l);
      }
    }

    System.out.println(answer);

  }

  public static int binary_search(int[] v, int x) {

    int l = -1;
    int r = v.length;

    while(r - l > 1) {

      int i = (l + r) / 2;

      if(x <= v[i]) {
        r = i;
      } else {
        l = i;
      }

    }

    return r;

  }

}

Measured memory_bytes: 25556
import java.util.*;


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

        Scanner s = new Scanner(System.in);
        
        int a = s.nextInt();
        int b = s.nextInt();

        int calc = (a + b) % 2;

        if (calc == 1) {
            System.out.println("IMPOSSIBLE");
        } else {
            System.out.println((a + b) / 2);
        }
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int n,l[200005],r[200005];
char s[200005];
int main()
{
    scanf("%d",&n);
    scanf("%s",s+1);
    for(int i=1;i<=n;i++)
    {
        l[i]=l[i-1];
        if(s[i]=='#') l[i]++;
    }
    for(int i=n;i>=1;i--)
    {
        r[i]=r[i+1];
        if(s[i]=='.') r[i]++;
    }
    int ans=1e9;
    for(int i=1;i<n;i++)
        ans=min(ans,l[i]+r[i+1]);
    ans=min(ans,l[n]);
    ans=min(ans,r[1]);
    printf("%d\n",ans);
}


Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char c = s.charAt(0);
        if (c - 'Z' > 0) {
            System.out.println("a");
        } else {
            System.out.println("A");
        }
    }
}

Measured memory_bytes: 35696
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

  int N=in();
  vector<int> l(N);
  for(auto& x:l) x=in();
  sort(l.rbegin(),l.rend());
  int sum = accumulate(l.begin()+1,l.end(),0);
  
  cout << (l[0]<sum ? "Yes" : "No") << endl;
  return 0;
}


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

namespace ABC177
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split(' ').ToList();
            List<long> A = new List<long>();
            long tmp = 0;
            long mod = (long)(Math.Pow(10, 9) + 7);
            for (int i = 0; i < N; i++)
            {
                A.Add(long.Parse(input[i]));
                tmp += A[i];
            }
            long sum = 0;

            for (int i = 0; i < N; i++)
            {
                tmp -= A[i];
                long a = tmp % mod;
                
                sum += A[i] * a;
                sum %= mod;
            }

            System.Console.WriteLine(sum);

            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 51408
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define PI 3.14159265358979323846264338327950288
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int N; cin >> N;
	vector<int> A(N); rep(i, N) cin >> A[i];
	vector<int> tmp = A;
	sort(tmp.begin(), tmp.end());
	int z = tmp[N - 1], y = tmp[N - 2];

	rep(i, N) {
		if (A[i] != z) cout << z << endl;
		else cout << y << endl;
	}

	return 0;
}


Measured memory_bytes: 4820
#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;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,pair<ll,ll> >
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 59;
ll i,j,n,m,c,e,d,x,y,s;
char a[N][N];
ll dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
bool visit[N][N];
ll di[N][N];
priority_queue<ii,vector<ii>,greater<ii> > pq;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>m;
    rep(i,0,n) rep(j,0,m){
        cin>>a[i][j];
        s += (a[i][j] == '#');
        di[i][j] = mod;
    }
    di[0][0] = 1;
    pq.push({1,{0,0}});
    while(!pq.empty()){
        ii u = pq.top();
        pq.pop();
        d = u.f; c = u.se.f; e = u.se.se;
        if(visit[c][e]) continue;
        visit[c][e] = 1;
        rep(i,0,4){
            x = c + dx[i];
            y = e + dy[i];
            if(x >= 0 and y >= 0 and x < n and y < m and a[x][y] != '#' and !visit[x][y] and di[x][y] > d + 1){
                di[x][y] = d + 1;
                pq.push({di[x][y],{x,y}});
            }
        }
    }
    cout<<(di[n - 1][m - 1] == mod ? -1 : n*m - di[n - 1][m - 1] - s);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = +100100100;
typedef pair<int,int> P;
const ll MO = 1000000007;

bool is_prime(ll x){
    if(x<=1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(ll i=3;i*i<=x;i+=2){
        if(x%i==0)return false;
    }
    return true;
}

vector<ll> divisor(ll x){
    vector<ll> rel;
    for(ll i = 1;i*i<=x;i++){
        if(x%i==0){
            if(i == x/i){
                rel.push_back(i);
                continue;
            }
            rel.push_back(i);
            rel.push_back(x/i);
        }
    }
    sort(rel.begin(),rel.end());
    // rep(i,rel.size()){
    //     cout << rel[i] << " ";
    // }
    // cout << endl;
    return rel;
}


int main(){
    ll a,b;
    cin >> a >> b;
    vector<ll> commons;
    if(a>b)swap(a,b);
    vector<ll> div_large = divisor(b);
    for(auto ele:divisor(a)){
        if(*lower_bound(div_large.begin(),div_large.end(),ele)==ele)commons.push_back(ele);
    }
    vector<ll>ans={1};
    for(auto ele : commons){
        if(is_prime(ele))ans.push_back(ele);
    }
    // if(is_prime(a))cout <<a<<" is prime"<<endl;
    // else cout << a << " is not prime"<<endl;;
    // if(is_prime(b))cout <<b<<" is prime"<<endl;
    // else cout << b << " is not prime"<<endl;
    // for(auto ele : ans){
    //     for(auto prime:commons)
    // }
    // for(auto ele:ans){
    //     cout << ele << " ";
    // }
    // cout << endl;
    cout << ans.size() << endl;
    return 0;
}

Measured memory_bytes: 512
n = int(input())
h = list(map(int,input().split()))

ans = 0
tmp = 0
for i in range(n):
  if i > 0:
    if h[i -1] >= h[i]:
      tmp = tmp + 1
    else:
      ans = max(ans,tmp)
      tmp = 0
print(max(ans,tmp))
  

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

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	for (int n, m; cin >> n >> m&&n;) {
		vector<int> a(n); rep(i, 0, n) { cin >> a[i]; }
		vector<int> b(m); rep(i, 0, m) { cin >> b[i]; }
		dumpc(a);
		dumpc(b);
		int A = accumulate(a.begin(), a.end(), 0);
		int B = accumulate(b.begin(), b.end(), 0);
		dump(A); dump(B);
		int mi = INF;
		int ansa, ansb;
		rep(i, 0, n)rep(j, 0, m) {
			if ((a[i] - b[j]) * 2 == A - B) {
				if (mi < a[i] + b[j])continue;
				mi = a[i] + b[j];
				ansa = a[i];
				ansb = b[j];
			}
		}
		if (mi == INF)cout << -1 << endl;
		else cout << ansa << " " << ansb << endl;
	}
	return 0;
}

Measured memory_bytes: 2964
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#define INF 10000000000
#define MOD 1000000007
using namespace std;
using ll = long long;
int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    ll res = 0;
    for(int d = 60;d >= -1;d--){
        if(d != -1 && !(k & (1LL<<d))){
            continue;
        }

        ll tmp = 0;
        for(int e =60; e >= 0;e--){
            ll mask = 1LL<<e;
            int num = 0;
            for(int i=0;i<n;i++){
                if(a[i] & mask){
                    num++;
                }
            }
            if(e > d){
                if(k & mask){
                    tmp += mask * (n - num);
                }else{
                    tmp += mask * num;
                }
            }else if(e == d){
                tmp += mask*num;
            }else{
                tmp += mask * max(num,n-num);
            }
        }
        res = max(res,tmp);
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define l long long
void frooty()
{
	l n;
	cin>>n;
	while(n!=0)
	{
		l div=n%10;
		if(div==7)
		{
			cout<<"Yes"<<endl;
			return ;
		}
		n/=10;
	}
	cout<<"No"<<endl;
	return ;
}
int main()
{
	l t=1;
	//cin>>t;
	while(t--)
	{
		frooty();
	}
}

Measured memory_bytes: 3596
n, m = map(int, input().split())
x = list()
for i in range(n):
    x.append(list(map(int, input().split())))
y=list()
for i in range(m):
    y.append(int(input()))
for i in range(n):
    a=0
    for j in range(m):
        a+=x[i][j]*y[j]
    print(a)


Measured memory_bytes: 6012