akhauriyash/Code-Regression huggingface dataset:
# define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <deque>
# include <iomanip>
# include <queue>
# include <sstream>
# include <unordered_set>
# include <unordered_map>
# include <climits>
# include <complex>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define MP make_pair
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define STRING(x) string x;cin>>x;
# define STR(x) STRING(x);
# define DOUBLE(x) double x;cin>>x;
# define DBL(x) DOUBLE(x); 
# define ALL(x) begin(x),end(x)
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl
# define INIT(a) memset(a,-1,sizeof a)
# define CLR(a) memset(a,0,sizeof a)
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
//const int M = 1000000007;
template<class T> void debug(T a) { for ( auto i : a )cout << i << endl; }

vi check_r(int r)
{
	vi a = { 100,200,300,400,500 };
	FOR(i, a.size())
	{
		if ( r == a[i] )return { i + 1 };
	}
	FOR(i, a.size())
	{
		if ( a[i] < r&&r < a[i + 1] )return { i + 1,i + 2 };
	}
}

vi check_t(int t)
{
	vi a = { 0,30,60,90,120,150,180 };
	FOR(i, a.size())
	{
		if ( t == a[i] )return { i * 5 };
	}
	FOR(i, a.size())
	{
		if ( a[i] < t&&t < a[i + 1] )return { i * 5,(i + 1) * 5 };
	}
}


int main()
{
	int N;
	cin >> N;
	FOR(i, N)
	{
		int r, t;
		cin >> r >> t;
		vi a = check_r(r), b = check_t(t);
		vi ans;
		for ( auto i : a )for ( auto j : b )
		{
			ans.push_back(i + j);
		}
		sort(ALL(ans));

		for ( int i = 0; i < ans.size(); i++ )
		{
			cout << (i != 0 ? " " : "") << ans[i];
		}
		cout << endl;
	}
}

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    string s;
    cin >> s;

    vector<char> display;
    rep(i, s.size()){
        if(s[i] == '0' || s[i] == '1') display.emplace_back(s[i]);
        else if(display.size() > 0) display.erase(display.end() - 1);
    }

    rep(i, display.size()) cout << display[i];
    cout << endl;
}

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

int main() {
	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;

	int sum = a1 + a2 + a3;
	if (sum >= 22) {
		cout << "bust" << endl;
	}
	else {
		cout << "win" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
  int n;
  string s;
  while(cin>>s){
    n=s.size();
    int ans=0;
    for(int i=0; i<(s.size()+1)/2; ++i){
      n=s.size();
//      cout<<s[i]<<" "<<s[n-i-1]<<endl;
      if(s[i]!=s[n-i-1]){
        if(s[i]=='x'){
          ++ans;
          s.erase(s.begin()+i, s.begin()+i+1);
//          cout<<s<<endl;
          --i;
        }
        else if(s[n-i-1]=='x'){
          s.erase(s.begin()+n-i-1, s.begin()+n-i);
          --i;
//          cout<<s<<endl;
          ++ans;
        }
        else{
          ans=-1;
          break;
        }
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 512
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    int a = Integer.parseInt(data[0]);
    int b = Integer.parseInt(data[1]);
    int c = Integer.parseInt(data[2]);
    
    if (c >= a && c<= b){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 22612
#include <iostream>

using namespace std;

int A[20];
int M[200];

bool check(int M,int i){
  if(i<0){
    return M == 0;
  }
  return check(M-A[i],i-1)||check(M,i-1);
}

int main(){
  int n;
  cin >> n;
  for(int i=0;i<n;++i){
    cin >> A[i] ;
  }
  int q;
  cin >> q;
  for(int i=0;i<q;++i){
    int M;
    cin >> M;
    if(check(M,n-1)){
      cout << "yes" << endl;
    }else{
      cout << "no" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3028
#include <bits/stdc++.h> 
using namespace std; 
#define lli long long int
lli a[100009];
lli ans[100009];
int main() 
{ 
  int h1, m1, h2, m2, k, m;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int h = h2-h1;
    m = m2-m1;
  cout << h*60+m-k;
  return 0; 
} 


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

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());

    int X;
    cin >> X;

    if (X == 7 || X == 5 || X == 3) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  bool f=!(s.size()%2);
  for(int i=0;f&&i<s.size();i+=2)f&=(s[i]=='h'&&s[i+1]=='i');
  cout<<(f?"Yes":"No")<<endl;
}

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

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    rep(i,60) {
        ll x = 0;
        rep(j,n) if (a[j]>>i&1) ++x;
        ll now = x * (n-x) % mod;
        rep(j,i) now = now*2 % mod;
        ans += now;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}
















Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define mp make_pair
// GCD inbuilt func: __gcd(a,b)
// LCM formula: (a*b)/__gcd(a,b)

int main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
	// CODE goes here
    int x,y;
    cin >> x >> y;
    if(y%2 || y>4*x || y<2*x) cout << "No\n";
    else cout << "Yes\n";
	return 0;
}


Measured memory_bytes: 3620
import numpy as np
import collections
n = int(input())
a_n = np.array(input().split(),dtype='int')
diff = a_n[1:] - a_n[:-1]
if len(set(diff))==2:
    print(0)
elif len(set(diff))==1:
    print(int(n/2))
else:
    odd_th = collections.Counter(a_n[1::2]).most_common()
    eve_th = collections.Counter(a_n[0::2]).most_common()
    if odd_th[0][0]==eve_th[0][0]:
        if odd_th[0][1]>eve_th[0][1]:
            odd_ = odd_th[0][1]
            eve_ = eve_th[1][1]
        elif odd_th[0][1]<eve_th[0][1]:
            odd_ = odd_th[1][1]
            eve_ = eve_th[0][1]
        else:
            if odd_th[1][1]>=eve_th[1][1]:
                odd_ = odd_th[1][1]
                eve_ = eve_th[0][1]
            else:
                odd_ = odd_th[0][1]
                eve_ = eve_th[1][1] 
    else:
            odd_ = odd_th[0][1]
            eve_ = eve_th[0][1]
    print(n-odd_-eve_)

Measured memory_bytes: 30892
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int n, m;
    std::cin>>n;
    std::vector<int> t(n);
    for(int i = 0;i < n;i++){
        std::cin>>t[i];
    }
    std::cin>>m;
    std::vector<int> p(m), x(m);
    for(int i = 0;i < m;i++){
        std::cin>>p[i]>>x[i];
    }

    std::vector<int> ans(m);
    int sum = std::accumulate(t.begin(),t.end(), 0);
    for(int i = 0;i < m;i++){
        ans[i] = sum - t[p[i]-1] + x[i];
    }
    for(const auto& a : ans){
        std::cout<<a<<std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a, b;

	scanf("%d %d", &a, &b);

	if (a < b) {
		printf("a < b\n",a ,b);
	}
	else if (a > b) {
		printf("a > b\n",a ,b);
	}
	else if (a == b) {
		printf("a == b\n", a, b);
	}

	return(0);
}


Measured memory_bytes: 2120
#include<iostream>
#include<algorithm>
#include<string>
std::string S;
std::string akiba[] = {
	"AKIHABARA",
	"KIHABARA",
	"AKIHBARA",
	"AKIHABRA",
	"AKIHABAR",
	"KIHBARA",
	"KIHABRA",
	"KIHABAR",
	"AKIHBRA",
	"AKIHBAR",
	"AKIHABR",
	"AKIHBR",
	"KIHABR",
	"KIHBAR",
	"KIHBRA",
	"KIHBR" };
int main() {
	std::cin >> S;
	int ac = 0;
	for (auto u : akiba) {
		if (S == u) {
			std::cout << "YES" << std::endl;
			return 0;
		}
	}
	std::cout << "NO" << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec A(N); cin >> A;
    int x = 0;
    REP(i, N) x ^= A[i];
    x ^= bit(60) - 1;

    vec ls(60, -1);
    REP(i, N){
        int a = A[i] & x;
        IREP(k, 60) if((a >> k) & 1){
            if(ls[k] == -1){
                ls[k] = a;
                break;
            }else a ^= ls[k];
        }
    }
    int y = 0;
    IREP(k, 60) if(((y >> k) & 1) == 0 && ls[k] != -1) y ^= ls[k];
    int ans = 0;
    REP(k, 60){
        if((x >> k) & 1){
            if((y >> k) & 1) ans += bit(k + 1);
        }else ans += bit(k);
    }
    Out(ans);

    return 0;
}


Measured memory_bytes: 1024
// problem: "https://atcoder.jp/contests/abc153/tasks/abc153_a"

#include<bits/stdc++.h>

using namespace std;

int main()
{
    int h,a;
    cin>>h>>a;

    if(h%a)
        cout<<h/a+1;
    else
        cout<<h/a;

    return 0;
}


Measured memory_bytes: 256
N=int(input())
A=[int(i) for i in input().split()]
A.sort(reverse=True)
ali=[]
bob=[]

for i in range(N//2):
    ali.append(A[i*2])
    bob.append(A[i*2+1])
if N%2==1:
    ali.append(A[-1])
    
        
print(sum(ali)-sum(bob))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl;
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl;
#define dbv(v) cerr << #v << ":"; for (auto i : v) cerr << i << ' '; cerr << endl;
#define dbvp(v) cerr << #v << ":"; for (auto i : v) cerr << "{"  << i.f << ',' << i.s << "} "; cerr << endl;
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl;
#define pb push_back
#define pf push_front
#define oo (ll)1e18
#define inf (int)1e10
#define ll long long 
#define ld long double
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
typedef tuple<ll,ll,ll> tl3;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string lts(ll x) {stringstream s; s << x; return s.str(); }
ll stl(string x) {stringstream s(x); ll temp; s >> temp; return temp; }
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
const int MAXN = 305;
template <typename T> void maxself(T& a, T b) {
    a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
    a = min(a, b);
}

//#define cerr if(0)cout


int main() {
    IAMSPEED
	string str; cin >> str;
	int n= str.size();
	int ans = 0;
	string s1, s2;
	FOR(i,0,n/2-1) {
		s1.pb(str[i]);
	}
	FOR(i,n/2,n-1) {
		s2.pb(str[i]);
	}
	
	reverse(all(s2));
	if (s2.size()>s1.size()) s2.pop_back();
	db2(s1,s2)
	FOR(i,0,s2.size()-1) {
		if (s1[i] != s2[i]) ++ans;
	}
	cout << ans;
}


Measured memory_bytes: 256
"""
s=1817181712114 なら
4
10
100
2000
10000
700000
1000000
80000000
100000000
7000000000
10000000000
800000000000
1000000000000
の数列とみて, 各々%Pを取ってzero sum range
P=2,5がコーナー
"""
from collections import Counter
def make_modlist(Len,mod):
    modlist=[0]*Len
    modlist[0]=1
    for i in range(1,Len):
        modlist[i]=10*modlist[i-1]%mod
    return modlist
n,p=map(int,input().split())
a=list(map(int,input()))
ans=0
a.reverse()
if p==2 or p==5:
    for i in range(n):
        if a[i]%p==0:
            ans+=n-i
else:
    d=make_modlist(n,p)
    b=[0]*(n+1)
    for i in range(n):
        b[i+1]=a[i]*d[i]%p
    for i in range(1,n+1):
        b[i]+=b[i-1]
        b[i]%=p
    for i in Counter(b).values():
        ans+=i*(i-1)//2
print(ans)

Measured memory_bytes: 21160
a=[list(map(int,input().split())) for _ in [0]*3]
n=int(input())
b=[int(input()) for _ in range(n)]

import numpy as np

for i in range(3):
  a[i]=[1 if x in b else 0 for x in a[i]]   

s_1=max(np.sum(a,axis=0))
s_2=max(np.sum(a,axis=1))
s_3=a[0][0]+a[1][1]+a[2][2]
s_4=a[0][2]+a[1][1]+a[2][0]

if max(s_1,s_2,s_3,s_4)==3:
  print("Yes")
else:
  print("No")

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

const int N=2e5+10;
typedef long long LL;

int n,m;
LL v[N<<1];
int l[N<<1],r[N<<1],rnd[N<<1],s[N<<1],rt,sz;
void update(int k){s[k]=s[l[k]]+s[r[k]]+1;}
void rturn(int &k)
{int t=l[k];l[k]=r[t];r[t]=k;s[t]=s[k];update(k);k=t;}
void lturn(int &k)
{int t=r[k];r[k]=l[t];l[t]=k;s[t]=s[k];update(k);k=t;}
void insert(int &k,LL x)
{
	if(!k){k=++sz;v[k]=x;s[k]=1;rnd[k]=rand();return;}
	s[k]++;
	if(x<v[k]){insert(l[k],x);if(rnd[l[k]]<rnd[k])rturn(k);}
	else {insert(r[k],x);if(rnd[r[k]]<rnd[k])lturn(k);}
}

int t;

void ask(int k,LL x)
{
	if(!k)return;
	if(x>=v[k]){t+=s[k]-s[r[k]];ask(r[k],x);}
	else ask(l[k],x);
}


int main()
{
	scanf("%d%d",&n,&m);
	LL res,Ans;
	res=Ans=0;
	for(int i=1;i<=n;i++)
	{
		insert(rt,res);
		int x;
		scanf("%d",&x);
		x-=m;
		res+=x;
		t=0;
		ask(rt,res);
		Ans+=t;
	}
	cout<<Ans<<endl;
}
		

Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll K;
    cin >> K;
    string S;
    cin >> S;
    if(S.size() <= K)
        cout << S << endl;
    else
        cout << S.substr(0, K) << "..." << endl;
}

Measured memory_bytes: 3632
n=int(input())
a=[int(j) for j in input().split()]
mod=10**9+7
m=len(bin(max(a)))-2
l=[[0,0] for i in range(m)]
for i in a:
    b=bin(i)[2:].rjust(m,"0")[::-1]
    for j in range(m):
        if b[j]=="0":
            l[j][0]+=1
        else:
            l[j][1]+=1

ans=0
for i in range(m):
    ans+=l[i][0]*l[i][1]*pow(2,i,mod)
    ans=ans%mod
print(ans)







Measured memory_bytes: 125624
import math

def all_divisor(n):
  small = [1]
  large = [n]
  for i in range(2, int(math.sqrt(n))+1):
    if n % i == 0:
      small.append(i)
      large.append(n//i)
  large.reverse()
  divisor = small + large
  return divisor


n = int(input())
n_divisor = all_divisor(n)
ans = 0
for i in n_divisor:
  mini_ans = (n - i) // i
  if i >= mini_ans:
    break
  ans += mini_ans 
print(ans)

Measured memory_bytes: 3304
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>

using namespace std;

typedef long long ll;

const ll q = 10000000000 + 7;

int main() {
	
	int n, k;
	cin >> n >> k;
	string str;
	cin >> str;

	int dif = 0;
	char c;
	c = str[0];
	for (int i = 1; i < n; i++)
	{
		if (str[i] != c) {
			c = str[i];
			dif++;
		}
	}

	dif = max(dif - k * 2, 0);
	int sum = n - 1 - dif;

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std ;
int main () {
  int N ;
  cin >> N ;
  int L ;
  cin >> L ;
  vector<string> line(N) ;
  for (int i = 0 ; i < N ;i++ ) cin >> line[i] ;
  sort(line.begin(),line.end()) ;
  for(int i = 0 ; i < N ; i++) cout << line[i] ;
  cout << endl ;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>
using namespace std;

#define all(c) c.begin(),c.end()
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i,0,n)
#define MAX(x, y)  ((x > y)? x : y);
#define MIN(x, y)  ((x < y)? x : y);
#define dump(x)  cout << #x" = " << x << endl;
#define debug(x) cout << #x" = " << x << " (" << __LINE__ << ") " << __FILE__ << endl;

typedef long long ll;
typedef vector<int> vi;

int main() {
	vector<int> vi(int('z') - int('a') + 1);
	string s;
	cin >> s;

	REP(i, s.size()) {
		++vi[int(s[i]) - int('a')];
	}

	REP(i, vi.size()) {
		if (vi[i] % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr int INF = 1001001001;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n,-1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y);}
    int size(int x) { return -d[find(x)];}
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep (i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a, b);
    }
    
    int ans = 0;
    vector<bool> p(n, false);
    rep (i, n) {
        int r = uf.find(i);
        if (!p[r]) {
            p[r] = true;
            ans++;
        }
    }
    cout << ans-1 << endl;
    
    return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int A,B;
  cin >> A >> B;
  int ans = 0;
  for (int i = A; i <= B; i++) {
    string str = to_string(i);
    if (str[0] == str[4] && str[1] == str[3]) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
  int a[10], b[10];

  for (int i = 0; i < 10; i++){
    cin >> a[i];
  }
  for (int i = 0; i < 10; i++){
    cin >> b[i];
  }
  sort(a, a + 10);
  sort(b, b + 10);

  cout << a[9] + a[8] + a[7] << " " << b[9] + b[8] + b[7] << endl;
  return 0;
}

Measured memory_bytes: 1180
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>

using namespace std;

int main()
{
  long N;
  long t[5];
  long ans = 5;
  long bottom = 10000000000000001;
  scanf("%ld", &N);
  for (int i=0;i<5;i++) {
    scanf("%ld", &t[i]);
    if (bottom > t[i]) bottom = t[i];
  }
  ans += N / bottom;
  if (bottom == 1)
    ans--;
  printf("%ld\n", ans);
  return 0;
}


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

int ssort(int A[],int n){
    int minj, s=0;

    for(int i=0; i<n-1; i++){
        minj = i;
        for(int j=i+1; j<n; j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        swap(A[i], A[minj]);
        if(i != minj) s++;
    }
    return s;
}

int main(){
    int A[100], s, n;
    cin >> n;

    for(int i=0; i<n; i++)
        cin >> A[i];

    s = ssort(A, n);

    for(int i=0; i<n; i++){
        if(i) cout << ' ';
        cout << A[i];
    }

    cout << endl;
    cout << s << endl;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> h(N);
    rep(i, N) {
        cin >> h[i];
    }
    vector<ll> dp(N + 1, 10e9);
    dp[0] = 0;
    FOR(i, 0, N - 1) {
        FOR(j, 1, 3) {
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
        }
    }
    cout << dp[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class _C
{
	void _()
	{

		var S = _Ss()[0];


		int n = 0;
		for (int i = 0; i < S.Length; i++)
			if (S[i] == 'N')
				n++;

		int s = 0;
		for (int i = 0; i < S.Length; i++)
			if (S[i] == 'S')
				s++;

		int e = 0;
		for (int i = 0; i < S.Length; i++)
			if (S[i] == 'E')
				e++;

		int w = 0;
		for (int i = 0; i < S.Length; i++)
			if (S[i] == 'W')
				w++;

		if(
			n>=1 && s==0 || 
			n==0 && s >= 1 ||
			w>=1 && e==0 || 
			w==0 && e>=1 )
			Console.WriteLine("No");
		else
			Console.WriteLine("Yes");
	}

	static void Main(string[] args)
  {
    new _C()._();
  }

  #region

  string _S()
  {
    return Console.ReadLine();
  }

  string[] _Ss()
  {
    return Console.ReadLine().Split();
  }

  int[] _N(int n)
  {
    var x = new int[n];
    for (var i = 0; i < n; i++)
    {
      x[i] = int.Parse(Console.ReadLine());
    }
    return x;
  }

  int[] _Ns()
  {
    var ss = Console.ReadLine().Split();

    var x = new int[ss.Length];
    for (var i = 0; i < ss.Length; i++)
      x[i] = int.Parse(ss[i]);

    return x;
  }
  #endregion
}


Measured memory_bytes: 2648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC121A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();

            int H = int.Parse(str[0]);
            int W = int.Parse(str[1]);

            string[] str2 = Console.ReadLine().Split();

            int h = int.Parse(str2[0]);
            int w = int.Parse(str2[1]);

            int x = H * W - h * W - (H - h) * w;

            Console.WriteLine(x);

            Console.ReadKey();

        }
    }
}
  

Measured memory_bytes: 13140
for i in range(3):
    l=list(map(int,input().split()))
    a=(l[3]-l[0])*3600+(l[4]-l[1])*60+l[5]-l[2]
    h,a=divmod(a,3600)
    m,s=divmod(a,60)
    print(h,m,s)


Measured memory_bytes: 5592
from collections import deque
N = int(input())
A = list(map(int, input().split()))

B = deque()

if N % 2 == 0:
    for i in range(N):
        if i % 2 == 0:
            B.append(A[i])
        else:
            B.appendleft(A[i])
else:
    for i in range(N):
        if i % 2 == 0:
            B.appendleft(A[i])
        else:
            B.append(A[i])

print(*B)

Measured memory_bytes: 25416
#include <stdio.h>

#define NUM_OF_MONEY_TYPE	( 6 )

int moneyType[ NUM_OF_MONEY_TYPE ] = { 500, 100, 50, 10, 5, 1 };

int getNumOfChange( int change );

int main( void )
{
	int change;
	int money;
	
	while( scanf("%d", &money), money )
	{
		change = 1000 - money;
		
		printf( "%d\n", getNumOfChange( change ) );
	}
	
	return (0);
}

int getNumOfChange( int change )
{
	int i;
	int j;
	
	int numOfChange = 0;
	int nowArray = 0;
	
	while( change != 0 )
	{
		numOfChange += change / moneyType[ nowArray ];
		change = change % moneyType[ nowArray ];
		nowArray++;
	}
	
	return (numOfChange);
}

Measured memory_bytes: 600
import math
A, B, H, M= map(int, input().split())
hour_angle = 30 * H + 0.5 * M
minu_angle = 6 * M
min_angle = min(hour_angle, minu_angle)
max_angle = max(hour_angle, minu_angle)
dif_num = max_angle - min_angle
answer1 = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(dif_num))
answer2 = math.sqrt(answer1)
print(answer2)

Measured memory_bytes: 9404
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int a;
  cin>>a;
  string s;
  cin>>s;
  if(a>=3200) cout<<s<<endl;
  else cout<<"red"<<endl;
}







Measured memory_bytes: 256
// Problem : D - Line++
// Contest : AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n; i >= a; i--)
#define pb              push_back
#define lb              lower_bound
#define ub              upper_bound
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + mod - b % mod) % mod;  }

#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << " | ";
	err(++it, args...);
}

const ll inf = 1e18;
const int nax = 2e3 + 5;

//https://github.com/Ashishgup1/Competitive-Coding/blob/master/Dijkstra.cpp
vector<pll>g[nax];
ll arrival[nax] , departure[nax];

void dijkstra(ll source,ll n)
{
	for(ll i=1;i<=n;i++)
	{
		arrival[i]=inf;
		departure[i]=inf;
	}
	arrival[source]=0;
	set<pair<ll, ll> > s;
	s.insert({0, source});
	while(!s.empty())
	{
		auto x = *(s.begin());
		s.erase(x);
		departure[x.second]=arrival[x.second];
		for(auto it:g[x.second])
		{
			if(arrival[it.first] > departure[x.second] + it.second)
			{
				s.erase({arrival[it.first], it.first});
				arrival[it.first]=departure[x.second] + it.second;
				s.insert({arrival[it.first], it.first});
			}
		}
	}
}

int main()
{
	speedup_IO;

	int t = 1;
	//cin >> t;
	while (t--)
	{
		ll n,x,y;
		cin>>n>>x>>y;
		
		//cout<<n<<endl;
		
		forn(i,2,n+1)
		{
			g[i].pb({i-1,1});
			g[i-1].pb({i,1});
		}
		g[x].pb({y,1});
		g[y].pb({x,1});
		
		
		ll ans[n+1];
		reset(ans,0);
		
		forn(i,1,n+1)
		{
			dijkstra(i,n);
			forn(j,1,n+1)
			{
				ans[arrival[j]]++;
			}
		}
		forn(i,1,n)
		{
			cout<<ans[i]/2<<endl;
		}
	}

	return 0;
}


Measured memory_bytes: 512
#include <cstdio>
using namespace std;
int main(){
	int x[100]={},i;
	x[65]=1;
char a[3];
	while(scanf("%s",&a)!=EOF){
		int s=x[a[0]];
		x[a[0]]=x[a[2]];
		x[a[2]]=s;
	}
	for(i=65;i<=67;i++){
		if(x[i]==1){
			if(i==65) printf("A\n");
			if(i==66) printf("B\n");
			if(i==67) printf("C\n");
		}}
	return 0;
}

Measured memory_bytes: 948
from fractions import gcd
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))

cnt = 1
for i in range(n):
    cnt = a[i] * cnt // gcd(a[i],cnt)


b = [cnt // a[i] for i in range(n)]
print(sum(b)%(10**9+7))

Measured memory_bytes: 264632
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int n,k; cin >> n>>k;
	if((n+1)/2>=k)cout << "YES"<< endl;
	else cout <<"NO"<< endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    vector<int> v;
    for(int i=1; (1LL<<i)-1<=n; ++i)
        v.push_back(i);
    n -= (1LL << v.size()) - 1;

    for(int i=v.size()-1; i>=0; --i){
        if(n & (1LL << i))
            v.insert(v.begin() + i, v.size() + 1);
    }
    int m = v.size();
    for(int i=1; i<=m; ++i)
        v.push_back(i);

    cout << v.size() << endl;
    cout << v[0];
    for(unsigned i=1; i<v.size(); ++i)
        cout << ' ' << v[i];
    cout << endl;

    return 0;
}


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

using namespace std;

const int N=2005;

bitset<N*N>f;

int main(){
    int n,s=0;scanf("%d",&n);
    f[0]=1;
    for(int i=1,x;i<=n;++i)scanf("%d",&x),f|=f<<x,s+=x;
    for(int i=(s+1)/2;;++i)if(f[i])return printf("%d\n",i),0;
}



Measured memory_bytes: 1664
#include<stdio.h>
int main(void)
{
    long int h,n,a,i,sum = 0;
  
    scanf("%ld %ld",&h,&n);
    for(i = 1 ; i <= n ; i++)
    {
        scanf("%ld",&a);
        h -= a;
    }
    
    if(h<=0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 1664
# import sys
# input = sys.stdin.readline
Q = 10**9+7
def main():
    N = int( input())
    S = input()
    left = 0
    ans = 1
    # for i in range(N*2):
    #     s = S[i]
    for s in S:
        if s == "B":
            if left%2 == 0:
                left += 1
            else:
                ans *= left
                left -= 1
        else:
            if left%2 == 1:
                left += 1
            else:
                ans *= left
                left -= 1
        ans %= Q
    if left > 0 or ans == 0:
        print(0)
        return
    for i in range(1,N+1):
        ans *= i
        ans %= Q
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=5e5+10;
const int MOD=1e9+7;

ll s;
void solve(){
  cin>>s;
  ll a=1e9;
  if(s%a==0){
    cout<<0<<" "<<0<<" "<<a<<" "<<0<<" "<<0<<" "<<s/a;
  }
  else{
    ll b=s/a+1;
    ll c=a*b-s;
    ll d=1;
    cout<<0<<" "<<0<<" "<<a<<" "<<d<<" "<<c<<" "<<b<<" ";
  }
}

int main(){
  solve();
}

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

using namespace std;
using ll =long long;
using db = double;

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; }

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(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)
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
const int mod = 1e9 + 7;

//ここから書き始める
int main()
{
	cout << setprecision(10);

	int n,t,a;
	cin >> n >> t >> a;
	db ans = 100000000;

	int num = 1; 
	vector<int> h(n);
	rep(i,n){
		cin >> h[i];
		db temp = abs ( a - (t - h[i]*0.006) );
		if( chmin(ans,temp)) num = i + 1;
	}
	cout << num << endl;

}


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

int main() {
  int a,b,c,d,e,sum;
  cin>>a;
  int h[a];
  for(int i=0;i<a;i++){
  	cin>>h[i];
  }
  d=1000000;
  for(int i=0;i<a;i++){
  	d=min(h[i],d);
    if(d>=h[i]){
      sum++;
    	//cout<<h[i]<<endl;
    }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 1024
def answer(arr, k):
    _mod = (10**9+7)
    left = 0
    right = 0
    for i in range(len(arr)):
        for j in range(i, len(arr)):
            if arr[i] > arr[j]:
                left += 1
            if arr[i] < arr[j]:
                right += 1
    
    left = (left * (k*(k+1))//2)
    right = (right * (k*(k-1))//2)
    return int((left+right)%_mod)
    
n, k = map(int, input().split())
arr = list(map(int, input().split()))
print(answer(arr, k))
# print(answer2(arr, k))

Measured memory_bytes: 40176
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#define ll long long
#define mod 1000000007
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
int a[maxn];
int n,m;
int main()
{
	n=read(); m=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	ll ans=0;
	for(int i=1;i<=n;i++){
		int cnt=0;
		for(int j=1;j<i;j++)
			cnt+=(a[j]>a[i]);
		ans+=(ll)m*cnt%mod;
		for(int j=i;j<=n;j++)
			cnt+=(a[j]>a[i]);
		ans+=(ll)m*(m-1)/2%mod*cnt%mod;
	}
	writeln(ans%mod);
	return 0;
}

Measured memory_bytes: 128
inn=[]
hoge=[]
zero=0

mini=0

for i in range(5):
    a=int(input())
    inn.append(a)
    if a%10==0:
        zero +=1

amari=[]
for v in inn:
    amari.append(v%10)

if max(amari)==0:
    print(sum(inn))
    exit()
else:
    amari.sort()
    for v in amari:
        if v!=0:
            mini=v
            break
    for v in inn:
        hoge.append((v//10)*10+10)

    print(sum(hoge)+mini-10-10*zero)
    exit()


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

using namespace std;

const int INF = 1e9 + 5;

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

	int v[n];
	
	for (int i = 0; i < n; i++)
		scanf("%d", &v[i]);

	vector <int> dp(n, INF);

	dp[0] = 0;
	if(n > 1)
		dp[1] = abs(v[1]-v[0]);
	for (int i = 2; i < n; i++) {
		dp[i] = min(dp[i-1]+abs(v[i]-v[i-1]), dp[i-2]+abs(v[i]-v[i-2]));
	}

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

}

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

using namespace std;

int main()
{
   
    string s;
    cin>>s;
    int i;
    int cnt=0,flag=0;
    
    for(i=0;i<s.length();i++)
      {
          if(s[i]=='C')
             cnt=1;
             
          if(s[i]=='F' && cnt==1)
              {
                  flag=1;
                  break;
              }
      }
      
      if(flag==1)
          printf("Yes");
          
      else
         printf("No");
    
  
  
}

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

int arr[100000], value[100000];

int find(int x){
	if (arr[x] == x)return x;
	else {
		int fx = arr[x];
		arr[x] = find(arr[x]);
		value[x] += value[fx];
		return arr[x];
	}
	return arr[x] == x ? x : arr[x] = find(arr[x]);
}

void relate(int a, int b, int c)
{
	int fa = find(a), fb = find(b);
	if (fa != fb){
		value[fa] = c + value[b] - value[a];
		arr[fa] = fb;
	}
}

int main()
{
	int n, q, ch, a, b, c;
	scanf("%d%d", &n, &q);
	for (int i = 0; i < n; ++i)arr[i] = i;
	
	while (q--){
		scanf("%d", &ch);
		if (ch){
			scanf("%d%d", &a, &b);
			if (find(a) == find(b))cout << value[a] - value[b] << endl;
			else printf("?\n");
		}else{
			scanf("%d%d%d", &a, &b, &c);
			relate(a, b, c);
		}
	}
	return 0;
}


Measured memory_bytes: 5172
#include<bits/stdc++.h>
using namespace std;
#define INS(x) x.begin(),x.end()
#define debug(x) cout<<x;

int k;
    
vector<long long> countSteppingNumbers(long long low, long long high) 
{
    vector<long long> res;
    stack<long long> tmp;
    int cnt=0;
    for(long long i=0;i<10;i++)
    {
        tmp.push(i);
        
    }
    while(tmp.size())
    {
        long long val=tmp.top();
        tmp.pop();
        if(val>=low && val<=high)
        {
            res.push_back(val);
            cnt++;
        }
        if(val==0)
        {
            continue;
        }
        if(val>high)
        {
            continue;
        }
        long long mod=val%10;
        if(mod>0)
        {
            tmp.push(val*10+mod-1);
        }
        tmp.push(val*10+mod);
        if(mod<9)
        {
            tmp.push(val*10+mod+1);
        }
    }
    sort(res.begin(),res.end());
    return res;
}
    
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>k;
    vector<long long> ans=countSteppingNumbers(1,3234566667);

    cout<<ans[k-1];
    
    return 0;
}

Measured memory_bytes: 1400
import sys
import collections


def main():
    n = int(sys.stdin.readline().strip())
    s = sys.stdin.readline().strip()
    # s = 'strangeorange'
    dp = [[0] * n for _ in range(n)]

    for i in range(n):
        dp[i][i] = 1

    res = 0
    for i in range(n-1, -1, -1):
        for j in range(n-1, i, -1):
            if s[i] == s[j]:
                if j == n-1:
                    dp[i][j] = 1
                else:
                    dp[i][j] = dp[i+1][j+1]+1
                res = max(res, min(dp[i][j], j-i))
    print(res)


main()


Measured memory_bytes: 230024
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin >> N;
    vector<pair<int,int>> ans;
    if(N%2==0){
        for(int i=1;i<=N;i++)for(int j=i+1;j<=N;j++){
            if(i+j==N+1)continue;
            else ans.push_back({i,j});
        }
    }else{
        for(int i=1;i<=N-1;i++)for(int j=i+1;j<=N-1;j++){
            if(i+j==N)continue;
            else ans.push_back({i,j});
        }
        for(int i=1;i<=N;i++)if(i==N)continue;
        else ans.push_back({i,N});
    }
    cout << ans.size() << endl;
    for(auto x:ans)cout << x.first << " " << x.second << endl;
}

Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }


    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        var x = Read();
        var y = new long[5];
        for (int i = 0; i < 5; i++)
            y[i] = Read();
        var min = y.Min();
        var f = new long[6];
        var nowf = new long[6];
        f[0] = x;
        nowf[0] = x;
        if (x % min == 0)
            Console.WriteLine(x / min + 4);
        else
            Console.WriteLine(x / min  +5);


      
     
        

        Console.Out.Flush();
    }
}





Measured memory_bytes: 13396
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
#define int long long int
int max_query(int tree[],int start,int end,int left,int right,int index)
{
	if(left>end||start>right)
	   return 0;
	if(start>=left&&end<=right)
	   return tree[index];
	else
	{
		int mid=(start+end)/2;
		int x=max_query(tree,start,mid,left,right,2*index);
		int y=max_query(tree,mid+1,end,left,right,2*index+1);
		return max(x,y);
	}
}
void update(int tree[],int start,int end,int point,int val,int index)
{
	if(point>end||point<start)
	   return ;
	if(start==end)
	{
		tree[index]=val;
		return ;
	}
	else
	{
		int mid=(start+end)/2;
		update(tree,start,mid,point,val,2*index);
		update(tree,mid+1,end,point,val,2*index+1);
		tree[index]=max(tree[2*index],tree[2*index+1]);
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	int tree[4*n+1]={0};
	int j,arr[n];
	for(j=0;j<n;j++)
	{
		cin>>arr[j];
		arr[j]--;
	}
	int arr2[n];
	for(j=0;j<n;j++)
	{
		cin>>arr2[j];
	}
	int value[n]={0};
	int answer=0;
	for(j=n-1;j>=0;j--)
	{
		int x=arr[j];
		int next=max_query(tree,0,n-1,x+1,n-1,1);
		int here=arr2[j]+next;
		value[x]=here;
		update(tree,0,n-1,x,here,1);
	}
	for(j=0;j<n;j++)
	   answer=max(answer,value[j]);
	cout<<answer<<endl;
}


Measured memory_bytes: 14556
#define _GLIBCXX_DEBUG
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
void solve(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int sum = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            sum += a[i] * a[j];
        }
    }
    cout << sum;
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    while(t--) solve();
}

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

typedef struct unionfind {
  //コンストラクタみたいな
  vector<int> r;
  unionfind(int n) {
    r = vector<int>(n, -1);
  }

  //xがどの根に繋がっているかを返す
  int root(int x) {
    if(r[x]<0) return x;
    else return root(r[x]);
  }

  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    // if(x==y) return false;
    if(x==y) return;

    //より木が高い方をxにする．r[x]とr[y]は負であることに注意
    if(r[x]>r[y]) swap(x,y);
    r[x] += r[y];
    r[y] = x;
    // return true;
    return;
  }

  int size(int x) {
    return -r[root(x)];
  }

} Unionfind;




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

  Unionfind mao(n);
  for(int i=0; i<m; i++) {
    int a,b;
    cin>>a>>b;
    mao.unite(a-1, b-1);
  }

  int ans = 0;
  for(int i=0; i<n; i++) {
    ans = max(ans, mao.size(i));
  }

  cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 4044