akhauriyash/Code-Regression huggingface dataset:
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 

 
void solve()
{
	char a ;
	cin>>a ;
	if(a-'a'>=0 && a-'a'<26){
		cout<<'a' ;
	}
	else{
		cout<<'A';
	}
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

int main(void) {
  int N;
  cin >> N;
  string s;
  unordered_map<string, int> hash;
  rep(i, N) {
    cin >> s;
    sort(s.begin(), s.end());
    hash[s]++;
  }

  ll ans = 0;
  for (auto& p : hash) {
    int num = p.second;
    ans += (ll)num * (num - 1) / 2;
  }

  cout << ans << endl;
  return 0;
}

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


string Convert(string s){

  int sum=1;
  char c=s[0];
  int i=1;
  string tmp="";

  while(i<(int)s.size()){

    if(s[i]==c)sum++;
    else{
      if(sum>=10){
	tmp.push_back('0'+sum/10);
	sum%=10;
      }
      tmp.push_back('0'+sum);

      tmp.push_back(c);
      sum=1;
      c=s[i];
    }

    i++;
  }

  if(sum>=10){
    tmp.push_back('0'+sum/10);
    sum%=10;
  }
  tmp.push_back('0'+sum);
  tmp.push_back(c);


  return tmp;

}

int main(){

  int n;
  string s;

  while(cin>>n,n){
    cin>>s;
    
    for(int i=0; i<n; i++){
      
      s = Convert(s);
      // cout << s << endl;
    }
    
    cout << s << endl;
  }

  return 0;
}

Measured memory_bytes: 1344
#include<bits/stdc++.h>
using namespace std;
int a[2][8010],cnt[2],tot[2],x[2];
int abs(int x){return x>0?x:-x;}
bool f[2][8010];
bool dp(int *a,int n,int c,int t,bool *f){
	if(t>c)return 0;
	for(int i=1;i<=c;i++)f[i]=0;
	f[0]=1;
	for(int i=0;i<n;i++)
		for(int j=c;j>=a[i];j--)if(f[j-a[i]])f[j]=1;
	return f[t];
}
bool judge(){
	for(int i=0;i<2;i++){
		if(tot[i]+x[i]&1)return 0;
		if(!dp(a[i],cnt[i],tot[i],tot[i]+x[i]>>1,f[i]))return 0;
	}
	return 1;
}
int main(){
	char s[8010];
	scanf("%s",s);
	for(int i=0;i<2;i++)scanf("%d",x+i);
	int len=strlen(s);
	s[len++]='T';
	s[len]='\0';
	int cur=0;
	while(cur<len&&s[cur++]!='T')x[0]--;
	for(int i=0;i<2;i++)x[i]=abs(x[i]);
	int b=1;
	while(cur<len){
		if(s[cur]=='T')tot[b]+=a[b][cnt[b]++],b^=1;
		else a[b][cnt[b]]++;
		cur++;
	}
	puts(judge()?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    int A,B,C;
    cin >> A >> B >> C;
    pr(C-min(A-B,C));
}


Measured memory_bytes: 256
//Use valgrind once if the submission doesn't go through. It can detect uninitialized variables and see where they could be an issue.
#pragma GCC optimiza("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <numeric>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);

	int primes[]={2 ,3 ,5 ,7 ,11 ,13 ,17 ,19 ,23,29 ,31 ,37 ,41 ,43 ,47 ,53 ,59 ,61 ,67,71 ,73 ,79 ,83 ,89 ,97 ,101 ,103 ,107 ,109,113 ,127 ,131 ,137 ,139 ,149 ,151 ,157 ,163 ,167,173 ,179 ,181 ,191 ,193 ,197 ,199 ,211 ,223 ,227,229 ,233 ,239 ,241 ,251 ,257 ,263 ,269 ,271 ,277,281 ,283 ,293 ,307 ,311 ,313 ,317 ,331 ,337 ,347,349 ,353 ,359 ,367 ,373 ,379 ,383 ,389 ,397 ,401,409 ,419 ,421 ,431 ,433 ,439 ,443 ,449 ,457 ,461,463 ,467 ,479 ,487 ,491 ,499 ,503 ,509 ,521 ,523,541 ,547 ,557 ,563 ,569 ,571 ,577 ,587 ,593 ,599,601 ,607 ,613 ,617 ,619 ,631 ,641 ,643 ,647 ,653,659 ,661 ,673 ,677 ,683 ,691 ,701 ,709 ,719 ,727,733 ,739 ,743 ,751 ,757 ,761 ,769 ,773 ,787 ,797,809 ,811 ,821 ,823 ,827 ,829 ,839 ,853 ,857 ,859,863 ,877 ,881 ,883 ,887 ,907 ,911 ,919 ,929 ,937,941 ,947 ,953 ,967 ,971 ,977 ,983 ,991 ,997}, count[sizeof(primes)/sizeof(int)]={0};
	int n,mc{0},tgcd{0};
	bool p;
	cin>>n;
	vector<int> a(n);
	for(auto &i:a){
		cin>>i;
		tgcd=gcd(tgcd,i);
		for(int j=0;j<sizeof(primes)/sizeof(int);++j){
			if(i%primes[j]==0){
				mc=max(mc,++count[j]);
				while(i%primes[j]==0){
					i/=primes[j];
				}
			}
		}
	}
	p=mc<2;
	sort(a.begin(),a.end());
	for(int i=1;i<a.size();++i){
		p=p&&(a[i]==1||a[i]!=a[i-1]);
	}
	if(p){
		cout<<"pairwise coprime"<<endl;
	}
	else if(tgcd==1){
		cout<<"setwise coprime"<<endl;
	}
	else{
		cout<<"not coprime"<<endl;
	}
}


Measured memory_bytes: 7140
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/math/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  boost::for_each(vc, [&os, &vc](T value) {
    os << value;
    if (value != vc.back())
      os << '\n';
    });
  return os;
}

template<class T1, class T2>
inline
std::ostream&
operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  //string S{}; std::cin >> S;
  ui r{}, D{}; std::cin >> r >> D;
  ui X{}; std::cin >> X;

  vector<ll> ans(10);
  rep(0, ans.size())
  {
    if (!i)
    {
      ans[i] = (ll)r * X - D;
    }
    else
    {
      ans[i] = (ll)r * ans[i - 1] - D;
    }
  }

  using std::cout;
  cout << ans << '\n';
  
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define oo 0x3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	//run();
	int a, b;
	cin >> a >> b;
	for (int i = 1;; i++) {
		int x = i * 8 / 100;
		int y = i * 10 / 100;
		if (x == a && y == b)
			RT(i);
		if (x > a)
			RT(-1);
	}
}


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

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

  vector<string> t(n);
  rep(i, n){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    t[i] = s;
  }
  sort(t.begin(), t.end());

  ll sum = 0;
  ll cnt = 1;
  rep(i, n-1){
    if(t[i] == t[i+1]) cnt++;
    else{
      sum += (cnt*(cnt-1))/2;
      cnt = 1;
    }
  }
  sum += (cnt*(cnt-1))/2;

  cout << sum << endl;

}


Measured memory_bytes: 5760
def main():
    N = int(input())
    A = [int(input()) for i in range(N)]
    max_i = 0
    sec_i = 0
    m = 0
    s = 0
    for ind, val in enumerate(A):
        if val > m:
            s = m
            sec_i = max_i
            m = val
            max_i = ind
        elif s < val <= m:
            s = val
            sec_i = ind
    for i in range(N):
        if i == max_i:
            print(s)
        else:
            print(m)

main()

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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int S = s.size();
  if (S % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }
  
  bool ok = true;
  for (int i = 0; i < S/2; i++) {
    if (s.at(i) != s.at(i+S/2)) {ok = false;}
  }
  
  if (ok) {cout << "Yes" << endl;}
  else {cout << "No" << endl;}
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  
  int n, i ,s = 0, temp[45];
  
  scanf("%d",&n);

  for(i = 1; i <= n; i++)
    {
      if(i == 1|| i == 2)
	{
	  s++;
	  temp[i] = s;
	}
      else 
	{
	  s = temp[i - 1] + temp[i - 2];
	  temp[i] = s;
	}
    }

  printf("%d\n",s);
 
  return 0;
}



Measured memory_bytes: 2112
n=int(input())
csf=[list(map(int,input().split())) for i in range(n-1)]
for i in range(n-1):
    time=0
    for j in range(i,n-1):
        c,s,f=csf[j]
        if time<s:
            time=s+c
        else:
            if time%f==0:
                time+=c
            else:
                time=(time//f+1)*f+c
    print(time)
print(0)

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


int main(){
  int n,i;
  cin >> n;
  vector<int> a(n);
  for(i=0;i<n;++i){
    cin >> a[i];
  }
  int ans=0;
  for(i=0;i<n;++i){
    if(a[i]%2==0){
      int b=a[i];
      while(b%2==0){
        ans++;
        b=b/2;
      }
    }else{
      continue;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


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

long long A[N];
long long sum[N+1];
sum[0]=0;
rep(i,N){
    cin>>A[i];
    sum[i+1]=sum[i]+A[i];
}
map<long long,int>mp;
for(int i=1;i<=N;i++){

    long long res=sum[i]%M;
    if(mp.find(res)==mp.end()){
        mp.insert(make_pair(res,1));
    }
    else{
        mp[res]++;
    }
}

auto iter=mp.begin();
long long ans=0;
while(iter!=mp.end()){
    long long  n=iter->second;
    if(iter->first==0){
        ans+=n;
    }
    if(n>=2){
        ans+=(n*(n-1))/2;
    }
    iter++;
}

cout<<ans<<endl;
 return 0;
}
/*

*/


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod = 1e9+7;
ll power(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1)res=res*a%mod;
        b>>=1;
        a=a*a%mod;
    }
    return res;
}
int a[111];
int main(){
    ll n,i,j,t,x,y,ma=0,mi=1e17;
    cin>>n;
    for(i=0;i<n;i++)cin>>a[i];
    for(i=0;i<=100;i++){
        ll cnt=0;
        for(j=0;j<n;j++)cnt+=(a[j]-i)*(a[j]-i);
        mi=min(mi,cnt);
    }
    cout<<mi;
}
/*
7
140 1
120 2
100 3
120
100
-1
100
*/


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Set;

public class Main {

	/** ACGTの文字のセット */
	private static final Set<Character> SET = Set.of('A', 'C', 'G', 'T');

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			String s = scanner.next();
			int current = 0, max = 0;
			for (char a : s.toCharArray()) {
				if (SET.contains(a)) {
					current++;
				} else {
					if (current > max) {
						max = current;
					}
					current = 0;
				}
			}
			if (current > max) {
				max = current;
			}
			System.out.println(max);
		}
	}
}


Measured memory_bytes: 35388
n = int(input())
a = [0] * n
b = [0] * n
s = 0
for i in range(n):
    a[i],b[i] = map(str, input().split())
    if b[i] == 'BTC':
        s += float(a[i]) * 380000.0
    s += float(a[i])

print(s)



Measured memory_bytes: 3060
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<cstdlib>
#include<list>
#include<set>
#include<numeric>

#define MOD 1000000007

using namespace std;
typedef long long ll;
//typedef pair<int, int> P;

vector<ll> P1,P2;
ll ans;

int main()
{
	ll N, S;
	while (1) {
		cin >> N >> S;
		if (N == 0 && S == 0)break;
		ans = 0;
		P1.clear(),P2.clear();

		P1.push_back(0);
		for (int i = 0; i < N; i++) {
			int a;
			cin >> a;
			P1.push_back(a);
		}
		sort(P1.begin(),P1.end());

		for (int i = 0; i <= N; i++) {
			for (int j = i; j <= N; j++) {
				if (P1[i] + P1[j] <= S)P2.push_back(P1[i] + P1[j]);
			}
		}
		sort(P2.begin(),P2.end());
		int cnt = P2.size() - 1;
		for (int i = 0; i < P2.size(); i++) {
			while (P2[i] + P2[cnt] > S)cnt--;
			if (P2[cnt] + P2[i] <= S)
				ans = max(ans, P2[cnt] + P2[i]);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 6868
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int A[SIZE],B[SIZE];
int dp[SIZE][2];
template <class T>
void maa(T& x,T y){
    if(x<y)x=y;
}
template <class T>
void mii(T& x,T y){
    if(x>y)x=y;
}
int main(){
    int N,T;
    R(N,T);
    T--;
    FOR(i,1,N)R(A[i],B[i]);
    MS1(dp);
    dp[0][0]=0;
    FOR(i,1,N){
        for(int j=T;j>=0;j--){
            maa(dp[j][1],dp[j][0]+B[i]);
            if(j>=A[i]){
                REP(k,2){
                    if(dp[j-A[i]][k]!=-1)maa(dp[j][k],dp[j-A[i]][k]+B[i]);
                }
            }
        }
    }
    int an=0;
    FOR(i,0,T)REP(j,2)maa(an,dp[i][j]);
    W(an);
    return 0;
}


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

int main(){
  int mod=1e9+7;
  int n;
  cin>>n;
  vector<int> a(n),b(n);
  for(int i=0; i<n; i++) cin>>a[i];
  b[n-1]=0;
  for(int i=1; i<n; i++) b[n-i-1]=(b[n-i]+a[n-i])%mod;
  int ans=0;
  for(int i=0; i<n; i++){
    ans=(ans+(int64_t)a[i]*b[i])%mod;
  }
  cout<<ans<<endl;  
}

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

signed main() {
 
	int n, w;
	cin >> n >> w;
	
	vector<int> value(n), weight(n);
	rep(i, n){
		cin >> value[i] >> weight[i];
	}
	
	int dp[105][10005] = {};
	rep(i, n){
		rep(j, w+1){
			if(j >= weight[i]){
				dp[i+1][j] = max(dp[i+1][j-weight[i]] + value[i], dp[i][j]);
			}
			else{
				dp[i+1][j] = dp[i][j];
			}
		}
	}
		
	cout << dp[n][w] << endl;
	
    return 0;
}


Measured memory_bytes: 11312
function Main(input){
    meter = parseInt(input.split(" ")[0], 10);
    time = parseInt(input.split(" ")[1], 10);
    speed = parseInt(input.split(" ")[2], 10);
    if(time * speed >= meter){
        console.log("Yes");
    }else{
        console.log("No");
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29680
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int k = n%10;
    if (k==2||k==4||k==5||k==7||k==9)
    	printf("hon\n");
    else if(k==0||k==1||k==6||k==8)
    	printf("pon\n");
    else if (k==3)
    	printf("bon\n");
    return 0;
 }

    

Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

#define rep(i, n) for(int i=0;i<(int)(n);++i)

using namespace std;

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 trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

using ll = long long;
using P = pair<int, int>;

const unsigned long long INF = 1LL << 60;

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

int n;
int a[100];

int main() {
    cin >> n;
    rep(i, n) cin >> a[i];

    for (int i = n - 1; i >= 0; i--) {
        cout << a[i];
        if (i > 0) {
            cout << ' ';
        }
    }
    cout << endl;
}



Measured memory_bytes: 3000
#include <stdio.h>
int main(){
  int n,a[100],i;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(n;n>0;n--){
    i=n-1;
    printf("%d",a[i]);
    if(i)printf(" ");
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int x;
    cin >> x;
    int ans=10-x/200;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  lb  lower_bound
#define  ub  upper_bound
#define  F   first
#define  S   second
const int N=2e5+2;

int main()
{
    ft
    ll i,j,n,m,l,r,s=0;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>l;
        s+=l;
    }
    if(s>=n)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}


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

bool cmp(int a,int b)
{
   return a>b;
}
int main()
{
  int n,k,x,i;
  cin>>n>>k;
  int a[200000+5]={0};
  for(i=0;i<n;i++) 
  {
   cin>>x;
   a[x]++;
  }
  sort(a+1,a+200000+1,cmp);
  int count=0;
  for(i=k+1;i<=200000;i++)  count+=a[i];
  cout<<count<<endl;
  return 0;
}
  

Measured memory_bytes: 1024
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto K = readln.chomp.to!int;
    auto AS = readln.split.to!(long[]);
    reverse(AS);
    long min_a = 2, max_a = 2;
    foreach (i, a; AS) {
        if ((min_a + a - 1) / a * a > max_a) {
            writeln(-1);
            return;
        }
        min_a = (min_a + a - 1) / a * a;
        max_a = max_a / a * a + a - 1;
    }
    writefln("%d %d", min_a, max_a);
}

Measured memory_bytes: 4132
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;
 
int main(void) {
  ll h, w; cin >> h >> w;
  ll a = h*w;
  if (h == 1 || w == 1) plexit(1)
  pl((a+2-1)/2)
  return 0;
}


Measured memory_bytes: 3444
#import heapq
#import itertools
#import math
#import numpy as np
#import sys

S = list(input())
#A,B,C = list(map(int, input().split()))
# S = [input() for _ in range(H)]
# T = [list(map(int,input().split())) for _ in range(N)]
# sys.exit()
ans = 0
if len(S) % 2 == 0 :
    h = int(len(S) / 2)
    s1 = S[0:h]
    s2 =  S[::-1][0:h]
    for i in range(h) :
        if s1[i] != s2[i] :
            ans += 1

else :
    h = int((len(S) - 1) / 2)
    s1 = S[0:h]
    s2 =  S[::-1][0:h]
    for i in range(h) :
        if s1[i] != s2[i] :
            ans += 1

print(ans)

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

int main() {
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(i==s.size()-1){
      break;
    }
    if(s.at(i) == s.at(i+1)){
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}


Measured memory_bytes: 256
h,n = map(int,input().split())
a = [0]*n
b = [0]*n
for i in range(n):
    a[i] , b[i] = map(int,input().split())

dp = [100000000000000 for i in range(h+1)]
dp[0] = 0

for i in range(h):
    for j in range(n):
        if (i+1) - a[j] < 0:
            dp[i+1] = min(dp[i+1],dp[0]+b[j])
        else:
            dp[i+1] = min(dp[i+1],dp[i+1-a[j]]+b[j])
            
print(dp[h])

Measured memory_bytes: 42604
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  [a,b,k] <- map (read::String->Int) . words <$> getLine
  (putStrLn .unlines .map show .nub) $ take k [a..b] ++ (reverse .take k) [b,b-1..a]

Measured memory_bytes: 3944
import java.util.*;
public class Main {
	final double EPS =1.0e-8;

	private double [] getInterSectP(double a, double b, double c, double d, double e, double f) {
		double [] result = new double[2];
		double temp1 = a * e - d * b;
		double temp2 = c * e - f * b;
		double x = temp2 / temp1;
		double y = ((double)c - x * a) / b;
		if(x == -0.0){
			x = 0.0;
		}
		result[0] = x;
		result[1] = y;
		return result;
	}

	private double [] getLine(double x1, double y1, double x2, double y2){
		double [] result = new double[3];
		double xDiff = x2 - x1;
		if(Math.abs(xDiff) < EPS){
			result[0] = 1.0;
			result[1] = 0.0;
			result[2] = x1;
		}
		else{
			result[0] = (y2-y1) / xDiff;
			result[1] = 1.0;
			result[2] = y1 - result[0] * x1;
		}
		return result;
	}

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n-- > 0){
			double [] x = new double[3];
			double [] y = new double[3];
			for(int i=0; i < 3; i++){
				x[i] = sc.nextDouble();
				y[i] = sc.nextDouble();
			}
			double [] midx = new double[2];
			double [] midy = new double[2];
			double [][] oldline = new double[2][3];
			for(int i=0; i < 2; i++){
				midx[i] = (x[i+1] + x[(i+2) % 3]) / 2;
				midy[i] = (y[i+1] + y[(i+2) % 3]) / 2;
				oldline[i] = getLine(x[i+1], y[i+1], x[(i+2)%3], y[(i+2)%3]);
			}
			double [][] line = new double[2][3];
			for(int i=0; i < 2; i++){
				if(oldline[i][1] == 0){
					line[i][0] = 0.0;
					line[i][1] = 1.0;
					line[i][2] = midy[i];
				}
				else if(oldline[i][0] == 0){
					line[i][0] = 1.0;
					line[i][1] = 0.0;
					line[i][2] = midx[i];
				}
				else{
					line[i][0] = 1.0 / oldline[i][0];
					line[i][1] = 1.0;
					line[i][2] = midy[i] + line[i][0] * midx[i];
				}
			}
			double [] result = getInterSectP(line[0][0], line[0][1], line[0][2], line[1][0], line[1][1], line[1][2]);
			double dis = Math.sqrt((result[0] - x[0]) * (result[0] - x[0]) + (result[1] - y[0]) * (result[1] - y[0]));
			System.out.printf("%1.3f %1.3f %1.3f\n",result[0],result[1],dis);

		}
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();
	}
}

Measured memory_bytes: 12000
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        v: [(String, usize); n],
    }
    let mut v2: Vec<(&String, &usize, usize)> = v
        .iter()
        .enumerate()
        .map(|(i, x)| (&x.0, &x.1, i + 1))
        .collect();
    v2.sort_by_key(|a| (a.0.clone(), -(a.1.clone() as i32)));
    for vi in v2 {
        println!("{}", vi.2);
    }
}

Measured memory_bytes: 4352
#include <stdio.h>
int main(void)
{
	int a,b,t,i,j;
	while(scanf("%d %d",&a,&b) != EOF)
	{
		if(a < b){
				t = a;
				a = b;
				b = t;
			 }
		i = a;
		j = b;
		while(a != 0 && b != 0)
		{
			a = a % b;
			if(a == 0){
					printf("%d %d\n",b,i/b*j);
					break ;
			  	}
			b = b % a;
			if(b == 0){
					printf("%d %d\n",a,i/a*j);
					break ;
			  	}
		}
	}

	return 0;
}




Measured memory_bytes: 1924
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
       int s =sc.nextInt();
       ArrayList<Integer> List = new ArrayList<>();
       List.add(s);
       int opt=0;
       while(true){
           int now_num = List.get(List.size()-1);
           int num = now_num%2;
           int next_num;
           if(num==0) next_num=now_num/2;
           else next_num=3*now_num+1;
           if(List.contains(next_num)==true){
               List.add(next_num);
               opt = List.size();
               break;
           }
           else List.add(next_num);
       }
        System.out.println(opt);
    }
}

Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] h = new int[N];
		for (int i = 0; i < h.length; i++) {
			h[i] = sc.nextInt();
		}
		sc.close();
		int pre = -1;
		for (int i = 0; i < h.length; i++) {
			if (pre <= h[i] - 1)
				pre = h[i] - 1;
			else if (pre <= h[i]) {
				pre = h[i];
			} else {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 50856
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  int cnt[M];
  fill(cnt, cnt + M, 0);
  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    for (int j = 0; j < K; j++) {
      int A;
      cin >> A;
      cnt[--A]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) ans += cnt[i] == N;
  cout << ans << '\n';
  return 0;
}


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


using namespace std;
const long long INF = 1LL <<60;

int main(void){
  long long res=0;
  long long i,j,k;
  long long n;
  long long l[100];
  
  cin>>n;
  for(i=0;i<n;i++){
    cin>>l[i];
  }
  sort(l,l+n);
  /*
  for(i=0;i<n;i++){
	cout<<l[i]<<endl;
  }*/
  
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      for(k=j+1;k<n;k++){
        //cout<<i<<j<<k<<endl;
        //cout<<l[i]<<l[j]<<l[k]<<endl;
        if(l[i]+l[j]>l[k] && l[i]!=l[j] && l[j]!=l[k]){
          //cout<<l[i]<<l[j]<<l[k]<<endl;
          res++;
        }
      }
    }
  }
  
  cout<<res<<endl;
  return 0;
  
}    

Measured memory_bytes: 3632
/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  double n;
  cin >> n;
  cout << 2*n*3.1415<<endl;
}


Measured memory_bytes: 3736
# import numpy as np
# import queue
# import heapq


def main():
    A, B, C, K = map(int, input().split())

    mv = 0
    if K <= A:
        mv = K
    elif A < K < A+B:
        mv = A
    else:
        mv = A - (K - A - B)

    print(mv)


if __name__ == "__main__":
    main()


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

int main() {
	int H,W;
	bool aw=true;
	cin>>H>>W;
	char m[H][W];
	int wlH[H],wlW[W];
	for(int i=0;i<H;i++){
	    for(int j=0;j<W;j++){
	        cin>>m[i][j];
	        wlW[j]=0;
	    }
	    wlH[i]=0;
	}
	//cin
	for(int k=0;k<H;k++){
	    for(int l=0;l<W;l++){
	        if(m[k][l]=='#'){
	            aw=false;
	        }
	    }
	    if(aw==true){
	        wlH[k]=1;
	    }
	    aw=true;
	}
	//any H to keep
	for(int m1=0;m1<W;m1++){
	    for(int n=0;n<H;n++){
	        if(m[n][m1]=='#'){
	            aw=false;
	        }
	    }
	    if(aw==true){
	        wlW[m1]=1;
	    }
	    aw=true;
	}
	//any W to keep
	for(int p=0;p<H;p++){
	    if(wlH[p]!=1){
	        for(int q=0;q<W;q++){
	            if(wlW[q]!=1){
	                cout<<m[p][q];
	            }
	        }
	        cout<<endl;
	    }
	    
	}
	//cout
	return 0;
}


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

int main() {
    int S; cin >> S;
    int h,m,s;
    h=S/3600;
    S%=3600;
    m=S/60;
    S%=60;
    s=S;
    cout << h << ":" << m << ":" << s << endl; 
    return 0;
}


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

int main() {
int N,X=1;
  cin>>N;
  vector<int> A(N);
  	for(int i=0;i<N;i++){
      cin>>A.at(i);
    }
  
  for(int i=0;i<N;i++){
    if(A.at(i)%2==1){
      X*=1;
    }
    else{
      if((A.at(i)%3==0)||(A.at(i)%5==0)){
        X*=1;
      }
        else{
          X*=0;
        }
    }
  }
  if(X==1){
  cout<<"APPROVED"<<endl;
  }
  else{
    cout<<"DENIED"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double lf;
typedef pair<int, int> pi;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    map<string, int> M;
    fr(i,0,n)
    {
        string s;
        cin>>s;
        M[s]++;
    }
    cout<<"AC x "<< M["AC"]<< "\n";
    cout<<"WA x "<< M["WA"]<< "\n";
    cout<<"TLE x "<< M["TLE"]<< "\n";
    cout<<"RE x "<< M["RE"]<< "\n";
    return 0;
}



Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin >> A >> B;
  for(int i=0;i<A;i++){
    for(int j=0;j<B;j++){
      string C;cin >>C;
      if(C=="snuke"){
        char D='0'+j+17;
        cout<<D<<i+1;
      }
    }
  }
}

        


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


void shu(char *pt,int *ph,int sy){

	int i,j,num;
	char ch;

	for(i=0;i < sy;i++){
		
		for(num=0;num < ph[i];num++){



	
			for(j=0;pt[j] !=  '\0';j++){

				if(pt[j+1] == '\0'){
					
					break;
				}
				ch = pt[j];
				pt[j] = pt[j+1];
		
	
		
				pt[j+1] = ch;

			}		
			
		}
	}
	
	printf("%s\n",pt);


}


int main(void){


	char T[201];
	int  h[100];

	int sy,i;

	while(1){

		scanf("%s",T);
		if(T[0] == '-' ){
			break;
		}
	
		scanf("%d",&sy);

		for(i=0;i< sy;i++){
		
			scanf(" %d",&h[i]);

		}


		shu(T,h,sy);

	}




return 0;


}

Measured memory_bytes: 584
#include<algorithm>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    lint k;
    cin >> k;

    constexpr int n = 50;

    vector<lint> a(n);
    rep(i, n){
        a[i] = i + k / n;
    }

    rep(c, k % n){
        rep(i, n){
            if(i == c){
                a[i] += n;
            }else{
                --a[i];
            }
        }
    }

    cout << n << endl;
    rep(i, n){
        if(i) cout << ' ';
        cout << a[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())

id = 0
res = []
for i in range(n):
    id += 1
    s, p = map(str, input().split())
    res.append([s, -1 * int(p), id])

res = sorted(res, key=lambda x: (x[0], x[1]))

for i in res:
    print(i[2])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000007
#define int long long
using namespace std;
int lv[514][514];
signed main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			int ci = i, cj = j;
			for(int k=1;k<=9;k++){
				if( (ci%2)+(cj%2)==1 ){
					cout<<k<<" ";
					k=100;
				}
				else{
					ci /= 2;
					cj /= 2;
				}
			}
		}
		cout<<endl;
	}
	return 0;
}

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

int main(void)
{
	int n, m;
	string kuji[1024], atari[128];
	int atarinum[128], money[128];
	
	while (cin >> n >> m, n){
		for (int i = 0; i < n; i++) cin >> atari[i] >> money[i];
		
		for (int i = 0; i < n; i++){
			int cnt = 0;
			for (int j = 7; 0 <= j; j--){
				if (atari[i][j] != '*') cnt++;
			}
			atarinum[i] = cnt;
		}
		
		int res = 0;
		for (int i = 0; i < m; i++) {
			cin >> kuji[i];
			for (int j = 0; j < n; j++){
				if (atari[j].substr(8-atarinum[j],atarinum[j]) == kuji[i].substr(8-atarinum[j],atarinum[j])) res += money[j];
			}
		}
		cout << res << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 968
#include <bits/stdc++.h>
#define ll long long
#define arena ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main()
{
    arena
   ll n;
   cin>>n;
   vector<ll> v;
   for(ll i=0;i<n;i++)
   {
       ll x;
       cin>>x;
       v.push_back(x);
   }
   sort(v.begin(),v.end());
   
   ll sum=0;
   for(ll i=0;i<n-2;i++)
   {
       for(ll j=i+1;j<n-1;j++)
       {
           auto it=lower_bound(v.begin(),v.end(),v[i]+v[j]);
           ll x=it-v.begin();
           x--;
           if(it!=v.end())
           {
               sum+=x-j;
           }
           else
           {
               sum+=(n-j-1);
           }
       }
   }
   cout<<sum;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	t := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&t[i])
	}

	var m int
	fmt.Scan(&m)
	p := make([]int, m)
	x := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&p[i], &x[i])
	}

	for i := 0; i < m; i++ {
		sum := 0
		pp, xx := p[i], x[i]
		for j := 0; j < n; j++ {
			if j == pp-1 {
				sum += xx
			} else {
				sum += t[j]
			}
		}
		fmt.Println(sum)
	}

}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 23 13:06:09 2020

@author: NEC-PCuser
"""
import string

S = input()
T = input()

dic = dict.fromkeys(string.ascii_lowercase, 0)
dic2 = dict.fromkeys(string.ascii_lowercase, 0)

for i in range(len(S)):
    dic[S[i]] += 1
    dic2[T[i]] += 1

li = []
li2 = []
for v in dic.values():
    li.append(v)
for v in dic2.values():
    li2.append(v)
li.sort()
li2.sort()

for i in range(len(li)):
    if li[i] != li2[i]:
        print("No")
        break
else:
    print("Yes")

        

Measured memory_bytes: 10232
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main {
    public static void main(String[] args) throws java.lang.Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        br.readLine();

        double[] array = Arrays.stream(br.readLine().split(" ")).mapToDouble(Double::parseDouble).toArray();
        Arrays.sort(array);

        double conbine = 0;
        for(int i = 0; i < array.length - 1; i++) {
            if(i == 0) {
                conbine = (array[i] + array[i + 1]) / 2;
            } else {
                conbine = (conbine + array[i + 1]) / 2;
            }

        }
        System.out.println(conbine);

    }
}

Measured memory_bytes: 27220
import fractions
    
a,b,c,d = map(int,input().split())
cd = c*d//fractions.gcd(c, d)

c1 = b//c
d1 = b//d
cd1 = b//(cd)

c2 = (a-1)//c
d2 = (a-1)//d
cd2 = (a-1)//cd

c3 = c1-c2
d3 = d1-d2
cd3 = cd1-cd2

print(b-a+1-c3-d3+cd3)

Measured memory_bytes: 64620
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;


int main() {
    int n;
    cin >> n;
    vector a(n,0);
    for (int i=0; i<n; i++) cin >> a[i];

    int ans = a[0];
    for (int i=0; i<n; i++) ans = gcd(ans, a[i]);
    cout << ans << endl;
}

Measured memory_bytes: 3256
#include <cstdio>
#include <algorithm>
#include <functional>

typedef long long int ll;

const int MAXN = 3e5 + 10;

struct T {
    int fx; ll wt;
    T(int _fx = 0, ll _wt = 0) { fx = _fx; wt = _wt; }
    bool operator < (const T &that) const {
        return wt == that.wt ? fx > that.fx : wt > that.wt;
    }
} ss[MAXN];

int n;
ll aa[MAXN], bb[MAXN], k;

bool check(ll x) {
    // 二分的是答案（最大值）
    ll cnt = 0;
    for (int i = 1; i <= n; ++i) {
        if (ss[i].wt <= x) return true;
        int idx = ss[i].fx;
        ll dd = (aa[idx] * bb[idx] - x + bb[idx] - 1ll) / bb[idx];
        if (dd > aa[idx]) return false;
        cnt += dd;
        if (cnt > k) return false;
    }
    return true;
}

int main() {
    scanf("%d %lld", &n, &k);
    for (int i = 1; i <= n; ++i) scanf("%lld", aa + i);
    for (int i = 1; i <= n; ++i) scanf("%lld", bb + i);
    std::sort(aa + 1, aa + 1 + n);
    std::sort(bb + 1, bb + 1 + n, std::greater<int>());
    for (int i = 1; i <= n; ++i) ss[i] = ((T) { i, 1ll * aa[i] * bb[i] } );
    std::sort(ss + 1, ss + 1 + n);
    ll l = 0, r = ss[1].wt, ans = 0;
    while (l <= r) {
        ll mid = (l + r) >> 1;
        if (check(mid)) {
            ans = mid; r = mid - 1;
        } else l = mid + 1;
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main(){

    int n;cin>>n;

    int f[105][13];
    ll p[105][14];

    rep(i,n){
        rep(j,10){cin>>f[i][j];}
    }
    rep(i,n){
        rep(j,11){cin>>p[i][j];}
    }
    ll mx = -10000000010;
    for(int bit = 1;bit<(1<<10);bit++){
        vector<int> cnt(n,0);
        rep(i,10){
            if(bit&(1<<i)){
                rep(j,n){
                    if(f[j][i]==1)cnt[j]++;
                }
            }
        }
        ll sum = 0;
        rep(j,n)sum += p[j][cnt[j]];
        mx = max(mx,sum);
    }
    cout<<mx<<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define mp            make_pair
#define M             1000000007
#define MM            998244353
#define fr            first
#define sc            second
#define all(v)        (v).begin(),(v).end()
#define rall(v)       (v).rbegin(),(v).rend()
#define vc            vector
#define vi            vector<int>
#define pii           pair<int,int>
#define psi           pair<string,int>
#define pis           pair<int,string>
#define mii           map<int,int>

int solve(){
	int a[3];
	for (int i = 0; i < 3; ++i)
	{
		cin>>a[i];
	}
	sort(a,a+3);
	if(a[0]==5&&a[1]==5&&a[2]==7) cout<<"YES";
	else cout<<"NO";
}
 
signed main() {
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--)
		solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d,e;cin >> a >> b >> c >> d >> e;
  if(a==0) cout << 1 << "\n";
  else if(b==0) cout << 2 << "\n";
  else if(c==0) cout << 3 << "\n";
  else if(d==0) cout << 4 << "\n";
  else if(e==0) cout << 5 << "\n";
 
}


Measured memory_bytes: 3548