akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<queue>
#include<vector>
using namespace std;
int main()
{
  string s;
  cin>>s;
  if(s=="zyxwvutsrqponmlkjihgfedcba"){
    cout<<"-1";
    return 0;
  }
  s+='a'-1;
  for(int i=s.size()-1;i>=0;i--)
    while(s[i]<'z'){
      s[i]++;
      bool f=true;
      for(int j=0;j<i;j++)
        if(s[i]==s[j]){
          f=false;
          break;
        }
      if(f){
        for(int j=0;j<=i;j++)
          cout<<s[j];
        return 0;
      }
    }
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

// Description: ????????????
// Verifyed: various problem 
const R INF = 1E40L;
const R PI = acos(-1.0L);
using P=complex<R>;
const P O=0.0L;
using L=struct{P s,t;};
using VP=vector<P>;
using C=struct{P c;R r;};

istream& operator >> (istream& is,P& p){ R x,y;is >> x >> y; p=P(x,y); return is;}
ostream& operator << (ostream& os,P& p){ os << real(p) << " " << imag(p); return os;}

inline R dot(P o,P a,P b){return real(conj(a-o)*(b-o));}
inline R det(P o,P a,P b){return imag(conj(a-o)*(b-o));}
inline int sdot(P o,P a,P b){return sgn(dot(o,a,b));}
inline int sdet(P o,P a,P b){return sgn(det(o,a,b));}

//projection verify AOJ CGL_1_A
P proj(L l,P p){ R u=real((p-l.s)/(l.t-l.s)); return (1-u)*l.s+u*l.t;}

// cross point between circle and line 
// verified: AOJ CGL_7_D
P cir(C c,R t){return c.c+polar(c.r,t);}
VP cross(C c, L l){
	P h=proj(l,c.c),e=polar(sq(norm(c.r)-norm(h-c.c)),arg(l.t-l.s));
	return VP{h-e,h+e};
}

// cross point between circles
// verified: AOJ CGL_7_E
VP cross(C a,C b){
	P d=b.c-a.c,w=(norm(d)+norm(a.r)-norm(b.r))/(2.0L*norm(d))*d;
	return cross(a,{a.c+w,a.c+w+1il*w});
}


int main(void){
	C c1,c2;
	cin >> c1.c >> c1.r >> c2.c >> c2.r;
		
	VP res=cross(c1,c2);
	if(sgn(real(res[0])-real(res[1])>0)) swap(res[0],res[1]);
	if(sgn(real(res[0])-real(res[1]))==0 and sgn(imag(res[0])-imag(res[1]))>0) swap(res[0],res[1]);
	cout.precision(20);
	cout << fixed << res[0] << " " << res[1] << endl;
	return 0;
}

Measured memory_bytes: 3504
#include<iostream>
#include<math.h>
using namespace std;
int main() {
  int N;
  int xy[10][2];
  cin >> N;
  double sum = 0;
  int i,j;
  for(i=0;i<N;i++)cin >> xy[i][0] >> xy[i][1];
  for(i=0;i<N-1;i++) {
    for(j=i+1;j<N;j++) {
      sum += pow(pow(xy[i][0]-xy[j][0],2.0)+pow(xy[i][1]-xy[j][1],2.0),0.5);
    }
  }
  sum = sum*2/N;
  printf("%.8f\n",sum);
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    vector<int> A(3);
    rep(i, 3) cin >> A[i];
    sort(A.begin(), A.end());
    cout << A[0] + A[1] + A[2] * 10 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <stack>
 
using namespace std;

//(x,y)???????????????top
map<pair<int,int>,int> table;

//(x,y)?????????
map<pair<int,int>,int> h;

//        0 1 2 3 4 5
int dx[]={0,-1,0,0,1,0};
int dy[]={0,0,-1,1,0,0};

// f2[t][u]...f[0]=t,f[1]=u?????¨??????f[2]
// top,front(left)->front(right)
int f2[7][7]={
//front1,2,3,4,5,6
	{0,0,0,0,0,0,0},
	{0,0,3,5,2,4,0}, //top=1
	{0,4,0,1,6,0,3}, //top=2
	{0,2,6,0,0,1,5}, //top=3
	{0,5,1,0,0,6,2}, //top=4
	{0,3,0,6,1,0,4}, //top=5
	{0,0,4,2,5,3,0} //top=6
};

//f[0]:top
//f[1]:front(left)
//f[2]:front(right)
//f[5]+f[0]=f[4]+f[1]=f[3]+f[2]=7
class Dice
{
public:
	vector<int> f;
	Dice(int a,int b,int c){
		f.resize(6);
		f[0]=a,f[1]=b,f[2]=c;
		f[3]=7-f[2],f[4]=7-f[1],f[5]=7-f[0];
	}
	
	void rotX(int num){
		for(int i=0;i<num;i++){
			int tmp=f[0];
			f[0]=f[1];
			f[1]=f[5];
			f[5]=f[4];
			f[4]=tmp;
		}
	}
	
	void rotY(int num){
		for(int i=0;i<num;i++){
			int tmp=f[0];
			f[0]=f[3];
			f[3]=f[5];
			f[5]=f[2];
			f[2]=tmp;
		}
	}	
};




void update(Dice dice,int x,int y)
{

	int pos6,pos5,pos4;
	bool rolled=false;
	for(int i=0;i<6;i++){
		if(dice.f[i]==6) pos6=i;
		if(dice.f[i]==5) pos5=i;
		if(dice.f[i]==4) pos4=i;
	}
	
	if(pos6!=0 && pos6!=5){
		int nx=x+dx[pos6],ny=y+dy[pos6];

		if(h[make_pair(y,x)]>h[make_pair(ny,nx)]){
			if(pos6==1) dice.rotX(3);
			if(pos6==2) dice.rotY(1);
			if(pos6==3) dice.rotY(3);
			if(pos6==4) dice.rotX(1);
			update(dice,nx,ny);
			rolled=true;
		}
	}
	if(rolled) return ;

	if(pos5!=0 && pos5!=5){
		int nx=x+dx[pos5],ny=y+dy[pos5];

		if(h[make_pair(y,x)]>h[make_pair(ny,nx)]){
			if(pos5==1) dice.rotX(3);
			if(pos5==2) dice.rotY(1);
			if(pos5==3) dice.rotY(3);
			if(pos5==4) dice.rotX(1);
			update(dice,nx,ny);
			rolled=true;
		}
	}
	if(rolled) return ;
	
	if(pos4!=0 && pos4!=5){
		int nx=x+dx[pos4],ny=y+dy[pos4];

		if(h[make_pair(y,x)]>h[make_pair(ny,nx)]){
			if(pos4==1) dice.rotX(3);
			if(pos4==2) dice.rotY(1);
			if(pos4==3) dice.rotY(3);
			if(pos4==4) dice.rotX(1);
			update(dice,nx,ny);
			rolled=true;
		}
	}
	if(rolled) return ;
	
	h[make_pair(y,x)]++;
	table[make_pair(y,x)]=dice.f[0];
	
}



int main()
{
	long long n;
	while(cin>>n,n){
		table.clear();
		h.clear();

		for(int i=0;i<n;i++){
			int top,front;
			cin>>top>>front;
			Dice dice(top,front,f2[top][front]);
			update(dice,0,0);

		}


		vector<int> ans(6,0);
		for(auto it=table.begin();it!=table.end();it++){
			ans[(it->second)-1]++;
		}
		for(int i=0;i<5;i++) cout<<ans[i]<<" ";
		cout<<ans[5]<<endl;


	}

	

	return 0;
}

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

#define LL long long
#define int long long
#define MIN LLONG_MIN
#define MAX LLONG_MAX
#define PB push_back
#define N 200001
#define MX 262144
#define LG 17
#define M 1000000007
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define LD long double
#define F first
#define S second
#define endl "\n"

int32_t main()
{
    LL i,j,lt,d,z,v,c,r,l,t1,k,h,u,q,ts,te,x,y,n,m;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    LL a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    k=0;
    for(i=1;i<n-1;i++)
    {
        x=0;
        if(a[i-1]>a[i])
            x++;
        if(a[i+1]>a[i])
            x++;
        if(x==1)
            k++;
    }
    cout<<k;
}   

Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int n, m;
char g[55][55];

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++)
		scanf("%s", g[i] + 1);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(g[i][j] == '#' && g[i-1][j] != '#' && g[i+1][j] != '#' && g[i][j-1] != '#' && g[i][j+1] != '#')
				return puts("No"), 0;
	puts("Yes");
	return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    set<int> st;
    for(int i = 1; i <= n; i ++) {
        int x;
        cin >> x;
        st.insert(x);
    }
    if(st.size() == n) {
        cout << "YES";
    }
    else {
        cout << "NO";
    }
    return 0;
}


Measured memory_bytes: 9600
while True:
    count = 0
    n, x = map(int, input().split(' '))
    
    if n == 0 and x == 0:
        break
    
    
    for i in range(1,n+1):
        for j in range(i+1, n+1):
            for k in range(j+1, n+1):
                if i + j + k == x:
                    count += 1

    print(count)


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

int main(void)
{
    long long deposit = 100;
    long long X;
    cin >> X;

    int count = 0;
    while (1) {
        if (deposit >= X) {
            cout << count << endl;
            return 0;
        }
        else {
            deposit += deposit / 100;
            count++;
        }
    }
}


Measured memory_bytes: 3636
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define rev(i,a,b) for (int i=(a)-1;i>=b;i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef queue<int> qi;
typedef vector<int> vi;
typedef vector<string> vs;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

#define NUM 1000000

bool prime[NUM];

void hurui() {
	rep(i,0,NUM) prime[i] = true;
	prime[0] = false;
	int num = sqrt(NUM);
 	rep(i,1,num) {
		if (prime[i])
			for (int j=i+1; (i+1)*j<=NUM; j++)
				prime[(i+1)*j-1] = false;
	}
}

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

	int a, d, n;

	hurui();

	// rep(i,0,60) {
	// 	cout << prime[i] << " ";
	// 	if(i % 20 == 0) cout << endl;
	// }

	while(true) {
		cin >> a >> d >> n;
		if(a == 0 && d == 0 && n == 0) break;

		ll tmp = a;
		int cnt = 0;
		while(tmp < NUM && cnt < n) {
			if(prime[tmp-1]) {
				cnt++;
				// cout << cnt << " : " << tmp << endl;
			}
			tmp += d;
		}

		cout << tmp-d << endl;
	}


	return 0;
}

Measured memory_bytes: 2164
import sys
sys.setrecursionlimit(1000000)
#def input():
#    return sys.stdin.readline()[:-1]

'''
n=int(input())
for i in range(n):
    a[i]=int(input())
    a[i],b[i]=map(int,input().split())
a=[int(x) for x in input().split()]
n,m=map(int,input.split())

'''

test_data1 = '''\
A??C
'''

test_data2 = '''\
ACACAC
'''

test_data3 = '''\
7
994 518 941 851 647 2 581
'''

test_data4 = '''\
?AC?AC
'''
td_num=3

def GetTestData(index):
    if index==1:
        return test_data1
    if index==2:
        return test_data2
    if index==3:
        return test_data3
    if index==4:
        return test_data4
    
if False:
    with open("../test.txt", mode='w') as f:
        f.write(GetTestData(td_num))
    with open("../test.txt") as f:
        # Start Input code ---------------------------------------
        n=int(f.readline())
        a=[int(x) for x in f.readline().split()]
        # End Input code ---------------------------------------
else:
    # Start Input code ---------------------------------------
    n=int(input())
    a=[int(x) for x in input().split()]
    # End Input code ---------------------------------------
#print(n,a,sum(a)-n)
print(sum(a)-n)


Measured memory_bytes: 38896
#include<bits/stdc++.h>
#include<iostream>
#include<fstream>
#define ll long long
using namespace std;

int main(){
    int N;  cin >> N;
    vector<ll> A(N,0), B(N,0);
    ll sum = 0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        B[i] = abs(A[i]);
        sum += B[i];
    }

    int cnt = 0;
    sort(B.begin(), B.end());
    for(int i=0; i<N; i++){
        if(A[i]<0) cnt++;
    }
   
    if(cnt%2==0) cout << sum << endl;
    else{
        cout << sum - 2*B[0] << endl;
    }
}

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

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

    while( cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3] )
    {
        int c[10] = {};

        for( int i = 0; i < 4; i++ )
        {
            c[a[i]]++;
            c[b[i]]++;
        }

        int hit = 0;
        for( int i = 0; i < 4; i++ )
            if( a[i] == b[i] )
                hit++;

        int blow = 0;
        for( int i = 0; i < 10; i++ )
            if( c[i] == 2 )
                blow++;

        cout << hit << " " << blow - hit << endl;
    }
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

ll po(ll x, ll y) {
    ll ans = 1;
    while(y) {
        if(y % 2) (ans *= x) %= MOD;
        (x *= x) %= MOD;
        y >>= 1;
    }
    return ans;
}

ll fact(ll x) {
    ll ans = 1;
    repi2(i, 2, x) (ans *= i) %= MOD;
    return ans;
}

ll gyakugen(ll x) {
    return po(x, MOD - 2);
}

map<ll, pair<ll, ll>> mae;

void prepare() {
    repi(i, 2000) {
        ll temp = fact(i);
        ll gyaku = gyakugen(temp);
        mae[i] = pair<ll, ll>{temp, gyaku};
    }
}

ll comb(ll n, ll r) {
    return mae[n].first * mae[r].second % MOD * mae[n - r].second % MOD;
}

int main(void) {
    prepare();
    ll N, K;
    cin >> N >> K;
    repi2(i, 1, K) cout << comb(N - K + 1, i) * comb(K - 1, i - 1) % MOD << endl;
    return 0;
}


Measured memory_bytes: 3888
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <list>
#include <queue>
#include <deque>
#include <math.h>
using namespace std;

typedef pair<int, int> P;
#define ll long long
#define int ll
#define INF (1LL<<60)
#define mod 1000000007
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

// 素数判定
bool isprime(ll  n){
	if (n < 2) return false;
	else if (n == 2) return true;
	else if (n % 2 == 0) return false;
	else
		for (int i = 3; i*i <= n; i++)
			if (n%i == 0) return false;

	return true;
}

// ax+by=1の解
ll extgcd(ll a, ll b, ll& x, ll& y){
	ll d = a;
	if (b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a / b)*x;
	}
	else{
		x = 1; y = 0;
	}
	return d;
}

// mod mでのaの逆数
ll mod_inverse(ll a, ll m){
	ll x, y;
	extgcd(a, m, x, y);
	return (m + x%m) % m;
}

// nの階乗 mod p
ll factorial(int n, int p){
	ll r = 1;
	for (int i = 1; i <= n; i++)
		r = (r*i) % p;
	return r;
}

// nPr
ll permutation(int n, int r){
	ll a = 1;
	for (int i = n - r + 1; i <= n; i++)
		a *= i;
	return a;
}

// nPr mod p
ll permutation(int n, int r, int p){
	ll a = 1;
	for (int i = n-r+1; i <= n; i++)
		a = (a*i) % p;
	return a;
}

// nCr mod p
ll combination(int n, int r, int p){
	if (r == 0 || r == n) return 1;
	if (r > n / 2) r = n - r;
	ll numerator = permutation(n, r, p);
	ll denominator = factorial(r, p) % p;
	ll inv = mod_inverse(denominator, p);
	return (numerator * inv) % p;
}

signed main(){
	int N, M;
	cin >> N >> M;

	if (isprime(M)) cout << N << endl;
	else{
		int result = 1;
		for (int i = 2;; i++){
			int power = 0;
			while (M>0 && M%i == 0){
				M /= i;
				power++;
			}
//			if (power > 0){
				result *= combination(N + power - 1, power, mod);
				result = result % mod;
//			}
			if (M == 1) break;
		}
		cout << result << endl;
	}

	return 0;
}


Measured memory_bytes: 256
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    a = list(map(int,input().split()))
    a.sort()
    ans = a[0] + a[1] + a[2] * 10
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
from collections import defaultdict

n = int(input())
s_list = [input() for _ in range(n)]
m = int(input())
t_list = [input() for _ in range(m)]

def make_count_dict(target_list):
    count_dict = defaultdict(int)
    for key in target_list:
        count_dict[key] += 1
    return count_dict

s_dict = make_count_dict(s_list)
t_dict = make_count_dict(t_list)

ans = 0
for s in s_dict.keys():
    temp = s_dict[s] - t_dict[s]
    if temp > ans:
        ans = temp
print(ans)

Measured memory_bytes: 3316
N, M, X = map(int, input().split())
book = [list(map(int, input().split())) for i in range(N)]

min_value = -1
for i in range(2**N):
    sum = [0 for k in range(M+1)]
    for j in range(N):
        if (i >> j) & 1:
            sum = [x+y for x, y in zip(sum, book[j])]
    if min(sum[1:]) >= X and (min_value > sum[0] or min_value == -1):
        min_value = sum[0]

print(min_value)


Measured memory_bytes: 9208
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define maxN 100007
using namespace std;
int main(){
  fastio;
  ld a=0,b=0;
  cin>>a>>b;
  ll new_b=round(b*100);
  ll ans=a*new_b/100;
  cout<<ans;
}

Measured memory_bytes: 3796
def gcd(a, b):
    while b!=0:
        a, b = b, a%b
    return a


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
a, b = map(int, input().split(' '))
gc = gcd(a, b)
r = []
r = factorization(gc)
if r[0][0] == 1:
    print(1)
else:
    print(len(r)+1)

Measured memory_bytes: 3064
from collections import defaultdict, Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)


values = reversed(sorted(set(a)))
s = 0
m = 0
above = dict()
n_above = dict()
for v in values:
    above[v] = s
    n_above[v] = m
    s += c[v] * v
    m += c[v]
above[0] = s
n_above[0] = m


m = 0
u = [0]
for v in a:
    if v > m:
        u.append(v)
        m = v

r = defaultdict(int)
last = 0
for j, v in enumerate(u):
    r[v] = last - (above[v] - n_above[v] * v)
    last = above[v] - n_above[v] * v



m = 0
for v in a:
    if v > m:
        print(r[v])
        m = v
    else:
        print(0)



Measured memory_bytes: 49932
#include <stdio.h>
#include <stdlib.h>
int kuaipai(const void *aaaaaa, const void *bbbbbb)
{return *(int *)aaaaaa - *(int *)bbbbbb;}
int s[200005][5],a[200005],b[200005];

int main()
{
    int i,M,N,t,j=1,k=1,x=1,y=1;
    scanf("%d%d",&M,&N);
    for(i=1;i<=N;i++)
        scanf("%d%d",&s[i][1],&s[i][2]);
    for(i=1;i<=N;i++)
    {
        if(s[i][1]==1)
            a[j++]=s[i][2];
        if(s[i][2]==M)
            b[k++]=s[i][1];
    }
    qsort(a, j, sizeof(a[0]), kuaipai);
    qsort(b, k, sizeof(b[0]), kuaipai);
    for(t=1;t<=200000;t++)
    {
        if(a[x]>b[y])
            y++;
        if(a[x]<b[y])
            x++;
        if(a[x]==b[y])
        {printf("POSSIBLE\n");  return 0;}
    }
    printf("IMPOSSIBLE\n");
    return 0;
}

Measured memory_bytes: 5244
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
const double EPS = 1e-11;
const double PI = 2 * acos(0.0);
using ll = long long;
using ull =  unsigned long long;

#define input freopen("input.txt", "r", stdin)
#define output freopen("output.txt", "w", stdout)
#define fast_io ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#define pf printf
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define sll(x,y) scanf("%lld %lld",&x,&y)

#define pii pair<int,int>
#define nl '\n'
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define uniq(a) a.erase(unique(a.begin(), a.end()), a.end())
#define out(x) cout <<"#x = "<<x<<endl
#define outt(x,y) cout <<"# "<<x<<" "<<y<<endl
#define mem(array,value) memset(array,value,sizeof(array))
#define MX 10005

int h[100007];
int n;
int dp[100007];
int solve(int pos)
{
	if(pos==n)return 0;

	if(dp[pos]!=-1)return dp[pos];
	int a,b;
	 a = abs(h[pos]-h[pos+1])+solve(pos+1);
	if(pos+2<=n){
		 a = min(a,abs(h[pos]-h[pos+2])+solve(pos+2));
	}
	return dp[pos]=a;
}
int main()
{
	mem(dp,-1);
	cin >>n;
	for(int i=1;i<=n;i++)cin >>h[i];
	cout <<solve(1)<<endl;

	return 0;
}

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

int main(){
int A,B;
cin >> A >> B;
int a,b,c,d;
a = floor(A/0.08);
b = floor(B/0.1);
c = min(a,b);
d = max(a,b);
int p = 44;

for(int i = c;i < d+100;i++){
  int C,D;
	C = floor(i*0.08);
    D = floor(i*0.1);
if(C==A&&D==B){
	cout << i << endl;
	p = 33;
	break;
}

}


if(p == 44){
	cout << -1 << endl;
}


}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>
 
using namespace std;
 
typedef long long ll;
typedef ll li;
typedef pair<int,int> PI;
#define EPS (1e-10L)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define REP(i, n) rep (i, n)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define CLR(a) memset((a),0,sizeof(a))
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
template<typename T,typename U> ostream& operator<< (ostream& out, const pair<T,U>& val){return out << "(" << val.F << ", " << val.S << ")";}
template<class T> ostream& operator<< (ostream& out, const vector<T>& val){out << "{";rep(i,SZ(val)) out << (i?", ":"") << val[i];return out << "}";}
void pkuassert(bool t){t=1/t;};
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};

int w,h;
int in[40][40];
bool vis[40][40][4];

void solve(){
  rep(i,h)rep(j,w) cin >> in[i][j];
  int c[4];
  rep(i,4) cin >> c[i];

  priority_queue<pair<PI,PI> > q;
  q.push(mp(mp(0,0),mp(0,0)));
  CLR(vis);
  
  while(!q.empty()){
    int cc=-q.top().F.F;
    int cd=q.top().F.S;
    int cx=q.top().S.F;
    int cy=q.top().S.S;    
    q.pop();
    if(cx==h-1 && cy==w-1){
      cout << cc << endl;
      return;
    }
    if(vis[cx][cy][cd]) continue;
    vis[cx][cy][cd]=true;
    rep(i,4){
      int nd=(cd+i)&3;
      int nx=cx+dx[nd];
      int ny=cy+dy[nd];
      if(min(nx,ny)<0 || nx>=h || ny>=w) continue;
      int nc=cc;
      if(i!=in[cx][cy]) nc += c[i];
      q.push(mp(mp(-nc,nd),mp(nx,ny)));
    }
  }
}

int main(){
  while(cin >> w >> h && w && h) solve();
}

Measured memory_bytes: 1340
// A - Round One
#include <bits/stdc++.h>
using namespace std;

int main(){
	int A,B; cin>>A>>B;
	int ans;
	if(A==1 && B==2) ans = 3;
	if(A==2 && B==1) ans = 3;
	if(A==1 && B==3) ans = 2;
	if(A==3 && B==1) ans = 2;
	if(A==2 && B==3) ans = 1;
	if(A==3 && B==2) ans = 1;
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, Npow, divisor, modinv, bitSearch, bitList, dfs, bfs//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
//***********//
//main内でCOMinit(N+1)を忘れずに！
vl fac, finv, inv;
void COMinit(ll N) {
	fac.resize(N);
	finv.resize(N);
	inv.resize(N);
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
	cin >> N >> K;
	COMinit(N+2);
	for (i = K; i <= N+1; i++) {
		ll m1 = ((0 + i - 1) * i / 2)%MOD;
		ll m2 = ((N - i + 1 + N) * i / 2)%MOD;
		ans =  ((ans +m2 - m1 + 1)%MOD+MOD)%MOD;
		//debug(m1, m2, ans);
	}
	cout << ans;
}

Measured memory_bytes: 7944
N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]

l = []
r = []
for x, y in X:
    if x == 1:
        l.append(y)
    if y == N:
        r.append(x)
        
print('POSSIBLE' if len(set(l) & set(r)) > 0 else 'IMPOSSIBLE')


Measured memory_bytes: 61028
n = int(input())
a = list(map(int, input().split()))

from functools import reduce
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
"""
def gcds(*numbers):
    return reduce(gcd, numbers)
"""
l = [0 for _ in range(n)]

for i in range(1, n):
    l[i] = gcd(l[i - 1], a[i - 1])
last_gcd = 0
for i in range(n - 2, -1, -1):
    last_gcd = gcd(last_gcd, a[i + 1])
    l[i] = gcd(last_gcd, l[i])
print(max(l))




Measured memory_bytes: 14584
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<int>v;
int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
  	int n,tmp;

    while(cin>>n){
      v.clear();
      for(int i=0;i<n;i++){
        cin>>tmp;
        v.push_back(tmp);
      }
      int f = 1;
      for(int i=0;i<n;i++){
        if(v[i] == f)
          f++;
      }
      if(f!=1)
        cout<<n-f+1<<endl;
      else
        cout<<"-1"<<endl;
    }
	return 0;
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {

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

		boolean[] ACcon =new boolean[N + 1];
		int[] WAcon =new int[N + 1];

		int ACans =0;
		int WAans =0;

		for (int i = 0; i < M; i++) {
			int Q = sc.nextInt();
			String result = sc.next();

			if (ACcon[Q] == false && result.equals("WA")) {
				WAcon[Q]++;
			}
			if (ACcon[Q] == false && result.equals("AC")) {
				ACcon[Q] = true;
			}
		}

		for (int i = 1; i < N+1; i++) {
			if (ACcon[i]) {
				ACans++;
				WAans += WAcon[i];
			}
		}

		System.out.println(ACans + " " + WAans);

	}
}

Measured memory_bytes: 60192
fun main(args : Array<String>) {
    val towns = IntArray(4){0}

    repeat(3) {
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        towns[a-1]++
        towns[b-1]++
    }

    println(if (towns.find { it > 2 } == null) "YES" else "NO")
}

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

int main(){
  int N;
  cin >> N;
  vector<string> W(N);
  for(int i = 0; i < N; i++){
    cin >> W[i];
  }
  bool ok = true;
  for(int i = 0; i < N-1; i++){
    for(int j = i+1; j < N; j++){
      if(W[i] == W[j]){
        ok = false;
      }
    }
  }
  for(int i = 0; i < N-1; i++){
    if(W[i][W[i].size()-1] != W[i+1][0]){
      ok = false;
    }
  }
  if(ok){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
cout << endl;
  int sum[n] = {};
  int i;
  for (i = 1; i < n; i++) {
    sum[i] = (s.at(i - 1) == 'A' && s.at(i) == 'C' ? sum[i - 1] + 1 : sum[i - 1]);
    //cout << (s.at(i - 1) == 'A' && s.at(i) == 'C') << sum[i] + 1  sum[i - 1]
  }
//cout << endl;


  int l, r;
  for (i = 0; i < q; i++) {
    cin >> l >> r;
    cout << sum[r - 1] - sum[l - 1] << endl;
  }

  /*
cout << endl;

for (i = 0; i < n; i++) {
cout << sum[i] ;
}
cout << endl;
*/
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

void solve() {
    i64 n;
    std::cin >> n;
    i64 a, b;
    std::cin >> a >> b;
    if((b-a) % 2 == 0) {
        std::cout << (b-a) / 2 << std::endl;
    } else {
        std::cout << std::min<i64>(a-1,n-b)+(b - a + 1) / 2 << std::endl;
    }
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
#define MAX 1000000

int main(){
	bool p[MAX+1];
	int n, ans;

	for(int i=0 ; i<=MAX ; i++){
		p[i] = (i<=1)? false : true ;
	}

	for(int i=2 ; i<=sqrt((long double)MAX)+1 ; i++){
		if(p[i]){
			for(int j=i*2 ; j<=MAX ; j+=i){
				p[j] = false;
			}
		}
	}

	while( cin >> n ){		
		ans = 0;
		for(int i=0 ; i<=n ; i++){
			if(p[i]){
				ans++;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()

def main():
  N, M = map(int, input().split())

  height = [i for i in list(map(int, input().split()))]

  results = [0 for i in range(N)]

  for i in range(M):
    a, b = map(int, input().split())
    if height[a-1] == height[b-1]:
      results[a-1] = 1
      results[b-1] = 1
    elif height[a-1] < height[b-1]:
      results[a-1] = 1
    else:
      results[b-1] = 1
  print(results.count(0))

if __name__ == '__main__':
  main()

Measured memory_bytes: 20136
#include <iostream>
using namespace std;
int main(void){
    int s[100000],t[50000];
    int n,q,x=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    cin>>q;
    for(int i=0;i<q;i++){
        int lb=0,ub=n;
        cin>>t[i];
        while(ub-lb>=1){
            int mid=(lb+ub)/2;
            if(t[i]>s[mid])lb=mid+1;
            else if(t[i]<s[mid])ub=mid;
            else {
                x++;
                break;
            }
        }
    }
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 3576
#pragma GCC optimize("Ofast")
#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;


/*
           1) long long vs int overflow
           2) read question carefully
*/

#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define umapii unordered_map < int , int >
#define umapll unordered_map<ll,ll>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define ll long long
#define pi pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vs vector<string>
#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pi>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define all(v) (v).begin(),(v).end()
#define FOR(i,a,b) for(int i = a;i <= b; i++)

#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";

const ll mod = 1000000007;
/*STL:
       (1) PRIORITY_QUEUE pq:
       -> priority_queue < int > pq; // max_heap
       -> priority_queue < int , vector < int > , greater < int > > pq; // min_heap 
       -> pq.top()   --> returns the maximum or minimum element
       -> pq.push()  --> push element into the queue
       -> pq.pop()   --> remove top most element
       -> pq.empty() --> checks whether queue is empty or not



*/
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}

const int inf = 1e9 + 7;

int main(){
    ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    vector<int> dp(n + 1, inf);
    dp[0] = 0;
    for(int i = 0; i < n; i++){
       if(i+1<n) dp[i + 1] = min(dp[i+1],dp[i]+ abs(h[i+1]-h[i]));
       if(i+2<n) dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
    }
    cout<<dp[n-1]<<'\n';
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N,V,P;
    ll M;
    cin>>N>>M>>V>>P;
    vector<ll> A(N);
    rep(i,N){
        cin>>A.at(i);
    }
    sort(A.rbegin(),A.rend());
    vector<ll> S(N+1);
    rep(i,N){
        S.at(i+1)=S.at(i)+A.at(i);
    }

    vector<bool> judge(N,false);
    rep(i,P){judge.at(i)=true;}
    
    for(int i=P;i<N;i++){
        if(A.at(i)==A.at(i-1)){
            judge.at(i)=judge.at(i-1);
            continue;
        }
        if(V-(N-i)-(P-1)<=0){
            if(A.at(i)+M>=A.at(P-1)){
                judge.at(i)=true;
            }
        }
        else{
            if(A.at(i)+M<A.at(P-1))continue;
            if((A.at(i)+M)*(i-P+1)-(S.at(i)-S.at(P-1))>=M*(V-(N-i)-(P-1))){
                //cout<<(A.at(i)+M)<<" "<<(i-P+1)<<" "<<(S.at(i)-S.at(P-1))<<" "<<(V-(N-i)-(P-1))<<endl;
                judge.at(i)=true;
            }
        }
    }
    int ans=0;
    rep(i,N){
        if(judge.at(i))ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4824
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;


int main() {

	ll x[5], y[5];
	cin >> x[1] >> y[1] >> x[2] >> y[2];

	ll a = x[2] - x[1];
	ll b = y[2] - y[1];
	x[3] = x[2] - b;
	y[3] = y[2] + a;
	x[4] = x[3] - a;
	y[4] = y[3] - b;

	cout << x[3] << " " << y[3] << " " << x[4] << " " << y[4];

	
	system("PAUSE");
}

Measured memory_bytes: 504
n,W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
inf = float('INF')
bag = [inf for _ in range(10**5+1)]
bag[0] = 0

ans = 0
for w,v in a:
    left = v if v < 100001 else 100001
    right = left + ans + 1 if left + ans + 1 < 100001 else 100001
    for i in range(left, right)[::-1]:
        if bag[i-v] + w < bag[i] and bag[i-v] + w < W+1:
            bag[i] = bag[i-v] + w
            if i > ans:
                ans = i
print(ans)


Measured memory_bytes: 5460
while True:
    n = input()
    if n == "-":
        break
    nl = list(n)
    m = int(input())
    c = 0
    for i in range(m):
        c += int(input())
    for j in range(c % len(n)):
        nl.append(nl.pop(0))
    print("".join(nl))
    nl.clear()


Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  char c[3][3];
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> c[i][j];}
  }
  
  string res = "";
  res += c[0][0];
  res += c[1][1];
  res += c[2][2];
  
  cout << res << endl; return 0;
}

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

const ll MOD = 1000000007;
const ll MAX = 510000;

ll fac[MAX], finv[MAX], inv[MAX];

int main(int argc, char **argv)
{
	ll N, K; cin >> N >> K;
	ll res{0};

	for (ll i = K; i <= N+1; ++i)
	{
		(res += (N+1-i) * i + 1) %= MOD;
	}
	
	std::cout << res << std::endl;
}



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

const char word[4] = {'A', 'C', 'G', 'T'};
const char change[4] = {'T', 'G', 'C', 'A'};

int main() {
    char b;
    cin >> b;
    for (int i = 0; i < 4; i++) {
        if (b == word[i]) {
            b = change[i];
            break;
        }
    }
    cout << b << endl;
}

Measured memory_bytes: 256
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    s = input()
    ma = 0
    maa = 0
    for i in s:
        if i == "R":
            ma += 1
            if ma > maa:
                maa = ma
        else:
            ma = 0
    print(maa)

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 68732
n = int(input())
a = list(map(int, input().split()))
input()
m = list(map(int, input().split()))

n2 = 2**n
aa = [0 for _ in range(n2)]
for i in range(n):
    t = 2**i
    for j in range(n2):
        if (j//t)%2:
            aa[j] += a[i]
aa = set(aa)

for k in m:
    if k in aa:
        print('yes')
    else:
        print('no')

Measured memory_bytes: 44972
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe


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

int a;
string s;

cin >> a >> s;

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






//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;
int gc(int a,int b){
  if(b==0)return a;
  
  if(a<b)return gc(b,a);
  return gc(b,a%b);
}
signed main(){
  int x;cin>>x;
  cout<<360/gc(360,x)<<endl;
  return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    int n, w;
    Item[] is;

    public static void main(String[] args) {
        Main m = new Main();
        m.read();
        m.solve();
    }

    void read() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        w = sc.nextInt();
        is = new Item[n];
        for (int i = 0; i < n; i++) {
            int v = sc.nextInt();
            int w = sc.nextInt();
            is[i] = new Item(w, v);
        }
    }

    void solve() {
        int[][] dp = new int[n+1][w+1];
        for (int i = 1; i < n+1; i++) {
            int w = is[i-1].w;
            int v = is[i-1].c;
            for (int j = 0; j < this.w+1; j++) {
                if (j - w < 0)
                    dp[i][j] = dp[i-1][j];
                else
                    dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-w]+v);
            }
        }
        int ans = Integer.MIN_VALUE;
        for (int i = 0; i < w + 1; i++) {
            ans = ans > dp[n][i] ? ans : dp[n][i];
        }
        System.out.println(ans);
    }

    private class Item {
        int w, c;
        Item(int w, int c) {
            this.w = w;
            this.c = c;
        }
    }
}

Measured memory_bytes: 31088
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(a + b < 24 ? a + b : (a + b) % 24);
		sc.close();
	}
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

int main()
{   
    int h, w, k;
    cin >> h >> w >> k;
    vs s(h);
    rep(i, h) cin >> s[i];

    int ans = 0;
    rep(ybit, 1<<h) rep(xbit, 1<<w) {
        int cnt = 0;
        rep(i, h) rep(j, w) {
            if(ybit>>i&1) continue;
            if(xbit>>j&1) continue;
            if(s[i][j] == '#') cnt++;
        }
        if(cnt == k) ans++;
    } 

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
	int N, L;
	cin >> N >> L;
	vector<string> S(N);
	for(int i=0; i<N; i++) cin >> S[i];

	for(int i=0; i<N-1; i++){
		for(int j=i; j<N; j++){
			if(S[i]>S[j]){
				string temp = S[j];
				S[j] = S[i];
				S[i] = temp;
			}
		}
	}
	for(int i=0; i<N; i++) cout << S[i];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k;
    string s;
    cin >> n >> k >> s;
    int cnt = 0;
    for(int i=0;i<n;i++){
        if(i != 0 && s[i] == 'L' && s[i-1] == 'L'){
            cnt++;
        }
        if(i != n-1 && s[i] == 'R' && s[i+1] == 'R'){
            cnt++;
        }
    }
    cout << min(cnt + k*2, n-1) << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
int main() {
    int n,k;
    std::vector<int> a;
    std::vector<int> num;
    std::cin >> n;
    std::cin >> k;
    int i,tmp;
    for(i=0;i<n;i++) {
        std::cin >> tmp;
        a.push_back(tmp);
    }
    std::sort(a.begin(),a.end());
    tmp = 1;
    for(i=1;i<n;i++){
        if(a[i]==a[i-1])
            tmp++;
        else{
            num.push_back(tmp);
            tmp=1;
        }
    }
    num.push_back(tmp);
    std::sort(num.begin(),num.end());
    if(k>=num.size())
        std::cout << 0;
    else{
        tmp=0;
        for(i=num.size();i>k;i--){
            tmp+=num[num.size()-i];
        }
        std::cout << tmp;
    }
}

Measured memory_bytes: 2548
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

typedef long long   ll;
typedef long double ld;

#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)

#define endl '\n'
#define INF  0x7f7f7f7f7f7f7f7f
#define INFi 0x7f7f7f7f


ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll solve(int N, const vector<ll> & L) {
  ll res=0;
  ll a, b, c;
  rep(i, N)
    rep3(j, i, N)
    rep3(k, j, N)
    if (i!=j && j!=k && k!=i){
      a=L[i], b=L[j], c=L[k];
      if (a!=b && b!=c && c!=a)
        if (a+b>c && b+c>a && c+a>b)
          res++;
    }

  return res;
}

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

  int N;
  cin >> N;
  vector<ll> L(N);
  rep (i, N) {
    cin >> L[i];
  }

  auto ans = solve(N, L);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3196