akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;


void Main(){
    string s, t; cin >> s >> t;
    ll n = s.size();
    
    vector<vll> data(26);
    
    rep(i, n){
        int tmp = s[i] - 'a';
        data[tmp].pb(i);
    }
    
    /*
    rep(a, 26){
        cout << char('a' + a) << ": ";
        for(auto x : data[a]){
            cout << x << " ";
        }    
        cout << endl;
    }
    */
    
    int m = t.size();
    ll now = 0;
    ll tot = 0;
    
    rep(i, m){
        int tmp = t[i] - 'a';
        if(data[tmp].size() == 0){
            cout << -1 << endl;
            return;          
        }

        auto it = lower_bound(all(data[tmp]), now);
        
        if(it == data[tmp].end()){
            it = lower_bound(all(data[tmp]), 0);
            now = *it + 1;
            if(n != 1) tot = ((tot-1)/n + 1) * n + now;
            else tot += now;
            // cout << now << " " << tot << endl;
        }else{
            now = *it + 1;
            if(n != 1) tot =  ((tot-1)/n) * n + now;
            else tot += now;
            // cout << now << " " << tot << endl;
        }
    }
    
    cout << tot << endl;
    return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

class point {
public:
	double x, y;
	point() {}
	point(double a, double b) { x = a; y = b; }
	point operator +( point p ) { return point( x + p.x, y + p.y ); }
	point operator -( point p ) { return point( x - p.x, y - p.y ); }
	point operator *( double a ) { return point( x * a, y * a ); }
	point operator /( double a ) { return point( x / a, y / a ); }
};

double norm( point p ) { return p.x * p.x + p.y * p.y; }

int main()
{
	point c1, c2;
	double r1, r2;
	cin >> c1.x >> c1.y >> r1 >> c2.x >> c2.y >> r2;

	double d = sqrt( norm( c2 - c1 ) );
	double a = acos( ( r1 * r1 + d * d - r2 * r2 ) / ( 2 * r1 * d ) );
	point c = c2 - c1;
	double t = atan2( c.y, c.x );
	point cp1 = c1 + point(  cos(t + a) * r1, sin(t + a) * r1 );
	point cp2 = c1 + point(  cos(t - a) * r1, sin(t - a) * r1 );
	if( cp1.x > cp2.x ) swap( cp1, cp2 );
	else if( cp1.x == cp2.x && cp1.y > cp2.y ) swap( cp1, cp2 );

	cout << fixed << setprecision(10) << cp1.x << " " << cp1.y  << " " << cp2.x << " " << cp2.y << endl;
}



Measured memory_bytes: 3632
x1, y1, x2, y2 = map(int, input().split())

dx, dy = x2-x1, y2-y1
x, y = x2, y2
ans = []
for i in range(2):
    dx, dy = -dy, dx
    x, y = x+dx, y+dy
    ans.append(x)
    ans.append(y)
for a in ans:
    print(a, end='')
    print(' ', end='')

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
int main()
{
  int n,a,b,c,x=0 ;
  scanf("%d",&n);
  while(n--)
  {
    scanf("%d%d%d",&a,&b,&c);
	if(b+c>a)
	{
		    x=1;
			break;
	}
	else
	{
	  if((a-b-c)%2!=0)
	  {
		  x=1;
		  break;
	  }
	      
	}
  }
  if(x==1)
      printf("No\n");
  else
	  printf("Yes\n");
  return 0;
}

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

int w, h;
int c[50][50];

void dfs(int x, int y){
    c[x][y] = 0;
    for(int dx=-1; dx<=1; dx++){
        for(int dy=-1; dy<=1; dy++){
            int nx = x + dx;
            int ny = y + dy;
            if(0<=nx && nx<h && 0<=ny && ny<w && c[nx][ny]==1) dfs(nx, ny);
        }
    }
    return;
}

int main(){
  	cin >> w >> h;
    while(w!=0){
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                cin >> c[i][j];
            }
        }
        int ans = 0;
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                if(c[i][j]==1){
                    dfs(i, j);
                    ans++;
                }
            }
        }
        cout << ans << endl;
      	cin >> w >> h;
    }
}


Measured memory_bytes: 3212
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <string>
#include <complex>
#include <cstdio>
using namespace std;

int v[50][50];
int main(){
	int h,w,t;
	int p;
	cin >> w >> h >> t >> p;
	
	for(int i = 0 ; i < p ; i++){
		int x,y,z;
		cin >> x >> y >> z;
		if( z <= t ) v[y][x]++;
	}
	int sum = 0;
	for(int i = 0 ; i < h ; i++){
		for(int j = 0 ; j < w ; j++){
			int s;
			cin >> s;
			sum += s * v[i][j];
		}
	}
	cout << sum << endl;

}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    ll N, M; string S, T; cin >> N >> M >> S >> T;

    ll lcm = N * M / __gcd(N, M);

    if(S[0] != T[0]) { cout << -1 << endl; return 0; }
    if(__gcd(N, M) == 1) { cout << lcm << endl; return 0; }

    int k = M / __gcd(N, M);
    int l = N / __gcd(N, M);
    while(k < M and l < N) {
        if(S[l] != T[k]) {cout << -1 << endl; return 0;}
        k += M / __gcd(N, M);
        l += N / __gcd(N, M);
    }
    cout << lcm << endl;
    return 0;
    
}

Measured memory_bytes: 640
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

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

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                 \
  sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(    \
            c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) cerr << boolalpha << i;
  ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
  sim dor(const c &) { ris; }
#endif
}
;
#define deb(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define memo(dp, val) memset(dp, val, sizeof(dp))
#define NINJA                                                                  \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define all(a) a.begin(), a.end()
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define dloop(i, n) for (int i = n - 1; i >= 0; i--)
#define iii tuple<int, int, int>
#define vi vector<int>
#define ii pair<int, int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int, int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

int32_t main() {
  NINJA;

  int n;
  cin >> n;

  cout << !n << endl;

  return 0;
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            Console.WriteLine(Console.ReadLine().Split(' ')
                .Select(num => int.Parse(num)).Any(num => num % 2 == 0 && num % 3 != 0 && num % 5 != 0)
                ? "DENIED" : "APPROVED");
        }
    }
}

Measured memory_bytes: 28100
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
#include <cmath>
#include <queue>
#include <string.h>

int main(int argc, char *argv[])
{
	int n;

	cin>>n;
	
	map<ll,ll> cnt;
	vector<ll> a(n);

	for (int i=0;i<n;i++)
	{
		cin>>a[i];
		if (cnt.count(a[i])==0) cnt[a[i]]=1; else cnt[a[i]]++;
	}
	ll sum=0;
	for (auto j=cnt.begin();j!=cnt.end(); j++)
	{
		ll y=j->second;
		sum+=(y*(y-1)/2);
	}

	for (int i=0;i<n;i++)
	{
		ll y=cnt[a[i]];
		
		cout<<sum-(y*(y-1))/2+((y-1)*(y-2))/2<<endl;
	}

	return 0;
}


Measured memory_bytes: 11008
// Author: Jinhai Chen
#include <cstring>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long ll;



int main() {
#ifdef CJHCJH
//	freopen("data.in","r",stdin);
#endif
	ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	if(k*2-1<=n) puts("YES");
	else puts("NO");


	return 0;
}














Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <math.h>
#include <set>
  
#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;
  
int main(){
	int a,b,c;
	while(1){
		cin>>a>>b>>c;
		if(!a&&!b&&!c)break;
		int ma=0;
		for(int i=1;i<c;i++){
			for(int j=1;j<c;j++){
				if(i*(100+a)/100+j*(100+a)/100==c){
					ma=max(ma,i*(100+b)/100+j*(100+b)/100);
				}
			}
		}
		cout<<ma<<endl;
	}
}


Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int N;
    cin >> N;
    VI B(N - 1);
    REP(i, N - 1) cin >> B[i];

    VI A(N);
    A[0] = B[0];
    REP(i, N - 1) {
        if (i + 1 < N - 1) A[i + 1] = min(B[i], B[i + 1]);
        else A[i + 1] = B[i];
    }

    //FORE(e, A) cerr<< e<< " "; cerr << endl;
    cout << accumulate(ALL(A), 0LL) << endl;
}


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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)          \
  sort(x.begin(), x.end()); \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << "(" << #x << ", " << #y << ") = " \
                          << "(" << x << ", " << y << ")" << '\n'

typedef long long int ll;
typedef pair<int, int> P;

const long long INF = 3e18 + 12;
const int inf = 1e9;

// ----------------------------------------------

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  while (1) {
    c -= b;
    if (c <= 0) {
      cout << "Yes" << endl;
      return 0;
    }
    a -= d;

    if (a <= 0) {
      cout << "No" << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 3640
#include<iostream>

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	if(a == 1){
		if(b == 2){
			a = 3;
		}
		else{
			a = 2;
		}
	}
	else if(a == 2){
		if(b == 1){
			a = 3;
		}
		else{
			a = 1;
		}
	}
	else{
		if(b == 1){
			a = 2;
		}
		else{
			a = 1;
		}
	}
	cout << a << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int main(){
	int a,b;
	cin>>a>>b;
	if(b%a==0)cout<<b+a<<endl;
	else cout<<b-a<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
#define EPS (1e-10)
struct Point
{
    double x, y;
    Point() {}
    Point(double _x,double _y):x(_x),y(_y) {}
    Point operator +(Point a)
    {
        return Point(x+a.x,y+a.y);
    }
    Point operator -(Point a)
    {
        return Point(x-a.x,y-a.y);
    }

};
double dot(Point a,Point b)
{
    return a.x*b.x+a.y*b.y;
}
double cross(Point a,Point b)
{
    return a.x*b.y-a.y*b.x;
}
double norm(Point a)
{
    return a.x*a.x+a.y*a.y;
}
double abs(Point a)
{
    return sqrt(norm(a));
}

int n;
Point p1,p2,p3,p4;
int ccw(Point p1,Point p2,Point p)
{
    Point a=p2-p1;
    Point b=p-p1;
    if(cross(a,b)<-EPS) return -1;
    if(cross(a,b)>EPS) return 1;
    if(dot(a,b)<-EPS) return -2;
    if(norm(a)<norm(b)) return 2;
    return 0;
}
bool is_insect(Point p1,Point p2,Point p3,Point p4)
{
    if(ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0&&ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0) return true;
    return false;
}
double dist_lp(Point p1,Point p2,Point p)
{
    if(dot(p2-p1,p-p1)<0.0) return abs(p-p1);
    if(dot(p1-p2,p-p2)<0.0) return abs(p-p2);
    return fabs(cross(p2-p1,p-p1))/abs(p2-p1);
}
double dist_ll(Point p1,Point p2,Point p3,Point p4)
{
     if(is_insect(p1,p2,p3,p4)) return 0.0;
    return min(min(dist_lp(p1,p2,p3),dist_lp(p1,p2,p4)),min(dist_lp(p3,p4,p1),dist_lp(p3,p4,p2)));
}
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    while(n--)
    {
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&p1.x,&p1.y,&p2.x,&p2.y,&p3.x,&p3.y,&p4.x,&p4.y);
        printf("%.10lf\n",dist_ll(p1,p2,p3,p4));
    }

    return 0;
}

Measured memory_bytes: 3228
#include <iostream>

using namespace std;

void solve()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a < b && b < c)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  string str;
  cin >> n >> str;
  vector<int> w(n);
  w[0] = 0;
  if(str[0] == 'W')w[0]++;
  for(int i = 1;i <= n - 1;i++){
    w[i] = w[i - 1];
    if(str[i] == 'W')w[i]++;
  }
  vector<int> e(n);
  e[n - 1] = 0;
  if(str[n - 1] == 'E')e[n - 1]++;
  for(int i = n - 2;i >= 0;i--){
    e[i] = e[i + 1];
    if(str[i] == 'E')e[i]++;
  }
  int res = 0;
  res = INT_MAX;
  res = min(res,e[1]);
  res = min(res,w[n - 2]);
  for(int i = 1;i <= n - 2;i++){
    res = min(res,w[i - 1] + e[i + 1]);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3076
#include <stdio.h>

int main(void){
	int num,nums,i,j;
	int c=0;
	scanf("%d",&num);
	int n[num];
	for(i=0;i<num;i++){
		scanf("%d",&n[i]);
	}
	for(i=0;i<num;i++){
		for(j=num-1;j>i;j--)
		if(n[j]<n[j-1]){
			nums=n[j];
			n[j]=n[j-1];
			n[j-1]=nums;
			c++;
		}
	}
	for(i=0;i<num;i++){
		if(i>0)printf(" ");
		printf("%d",n[i]);
		if(i==num-1)printf("\n");
	}
	printf("%d\n",c);
	return 0;
}

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

int dis1(int me, int other, int sp1, int sp2){
  return abs(me+1-sp1) + abs(other+1-sp2) + 1;
}

int main(){
  int N, X, Y;
  cin >>N >>X >>Y;
  
  vector<vector<int>> dis(N,vector<int>(N,0));
/*  
  int ad;
  ad =(Y-X-1)%2;
  
  for (int i=0; i<(N); i++){
    //cout <<endl <<i+1 <<" :";
    for (int j=i; j<N; j++){
      //cout <<i+1 <<" " <<(X+(Y-X)/2)+ad <<endl;
      if(i+1<=X){
        if(j+1 <= (X+(Y-X-1)/2+ad)){
          dis.at(i).at(j) = abs(j-i);
          //cout <<dis.at(i).at(j) <<" " ;
        }else{
          //dis.at(i).at(j) = abs(i+1-X) + abs(j+1-Y) + 1;
          dis.at(i).at(j) = dis1(i,j,X,Y);
          //cout <<abs(i+1-X) <<abs(j+1-Y) <<endl;
          //cout <<"2: " <<dis.at(i).at(j) <<endl;
          //cout <<dis.at(i).at(j) <<" " ;
        }
      }else if(X<i+1 && i+1<(X+(Y-X-1)/2+ad)){
        if(j+1<Y){
          dis.at(i).at(j) = abs(i-j);
          //cout <<"1: " <<dis.at(i).at(j) <<endl;
          //cout <<dis.at(i).at(j) <<" " ;
        }else{
          dis.at(i).at(j) = dis1(i,j,X,Y);
          //cout <<"2: " <<dis.at(i).at(j) <<endl;
          //cout <<dis.at(i).at(j) <<" " ;
        }
      }else if( ad>0 && i+1==(X+(Y-X-1)/2+ad) ){
        dis.at(i).at(j) = abs(i-j);
        //cout <<"1: " <<dis.at(i).at(j) <<endl;
        //cout <<dis.at(i).at(j) <<" " ;
        //cout <<i <<endl;
      }else if( ((X+(Y-X-1)/2+ad)<i+1) && (i+1<Y) ){
        if(X<j+1){
          dis.at(i).at(j) = abs(i-j);
          //cout <<dis.at(i).at(j) <<" " ;
        }else{
          dis.at(i).at(j) = dis1(i,j,Y,X);
          //cout <<dis.at(i).at(j) <<" " ;
        }
      }else if(Y<=i+1){
        if (j+1 <(X+(Y-X-1)/2+ad)){
          dis.at(i).at(j) = dis1(i,j,Y,X);
          //cout <<dis.at(i).at(j) <<" " ;
        }else{
          dis.at(i).at(j) = abs(i-j);
          //cout <<dis.at(i).at(j) <<" " ;
        }
      }
    }
  }
  */
  vector<int> ans(N,0);
  for (int i=1; i<N+1; i++){
    for (int j=i+1; j<N+1; j++){
      int dis1 = abs(i-j);
      int dis2 = abs(X-i)+1+abs(j-Y);
      int dis3 = abs(Y-i)+1+abs(j-X);
      int dis = min(dis1,min(dis2,dis3));
      ans.at(dis)++;
    }
  }
  
  
  /*
  for(int i=0; i<N; i++){
    for(int j=i; j<N; j++){
      for (int k=0; k<N; k++){
        if (k == dis.at(i).at(j)){
          ans.at(k)++;
        }
      }
    }
  }
  */
  for (int i=1; i<N; i++){
    cout <<ans.at(i) <<endl;
  }
}

Measured memory_bytes: 16000
N=int(input())
a=list(map(int,input().split()))
b=[0]*9
for i in range(N):
  if a[i]<400:
    b[0]=1
  elif a[i]<800:
    b[1]=1
  elif a[i]<1200:
    b[2]=1
  elif a[i]<1600:
    b[3]=1
  elif a[i]<2000:
    b[4]=1
  elif a[i]<2400:
    b[5]=1
  elif a[i]<2800:
    b[6]=1
  elif a[i]<3200:
    b[7]=1
  else:
    b[8]+=1
if b[8]==N:#全員がつよい!
  print(1,min(N,8))
else:
  Min=0
  Max=0
  for i in range(8):
    Min+=b[i]
  print(Min,min(N,Min+b[8]))

Measured memory_bytes: 3064
#C
n = int(input())
a = list(map(int, input().split()))
#最大公約数
def gcd(a, b):
    while b != 0:
        if a < b:
            b, a = a, b
        a, b = b, a % b
    return a
#最大公倍数
def lcm(a, b):
    return a * b // gcd(a, b)
ans = a[0]
for i in range(1, n):
    ans = gcd(ans, a[i])
print(ans)

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

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

    sort(l.begin(), l.end());
    int ans = 0;

    for (int i = 0; i < n; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            for (int k = j+1; k < n; k++)
            {
                if(l[i]==l[j] || l[j]==l[k] || l[k]==l[i])
                {
                    continue;
                }
                if(l[i]+l[j]>l[k])
                {
                    ans++;
                }
            }
            
        }
        
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#from collections import deque,defaultdict
from sys import stdin
input = stdin.readline
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

s = ins()
t = ins()
x = 0
for i in range(len(s)):
    if s[i]!=t[i]:
        x += 1
print(x)


Measured memory_bytes: 73624
//AtCoder ABC088 B - Card Game for Two
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll N;
    cin>>N;
    vector<ll> an(N);
    for(auto&& a:an){
        cin>>a;
    }
    sort(an.begin(),an.end());
    ll alice=0,bob=0;
    for(ll i=0;i<N;++i){
        if(i%2==0){
            alice+=an.back();
        } else{
            bob+=an.back();
        }
        an.pop_back();
    }
    cout<<alice-bob<<endl;
    return 0;
}

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

int main() {
  string s; cin >> s;
  vector<string> days = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  reverse(days.begin(), days.end());
  rep(i, 7){
    if (s == days[i]) cout << i+1 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	string ss, memo[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	cin >> ss;
	for(int64 ii = 0;ii < 7;ii++)
	{
		if(ss == memo[ii])
		{
			cout << 7 - ii << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3580
#include"bits/stdc++.h"
#include<iostream>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
const ll inf = ll(1e18) + 1;

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) {
		cin >> a[i];
	}

	ll many = 1000;
	ll count;

	rep(i, n - 1) {

		if (a[i] <= a[i + 1]) {
			count = many / a[i];
			many -= count * a[i];
			many += a[i+1]*count;
		}

	}

	cout << many << endl;
	return 0;
}


Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define MAX 44
#define NIL
using namespace std;

int main() {
	int n;
	cin >> n;
	int fib[MAX + 1];
	fib[0] = 1, fib[1] = 1;
	for (int i = 0; i <= n - 2; i++)
		fib[i + 2] = fib[i + 1] + fib[i];
	cout << fib[n] << endl;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define llint long long int
#define ldouble long double

//setprecision()<<

using namespace std;

int main() {
    string S;
    cin>>S;
    string before="aa",after="bb";
    for(int i=0;i<2;i++){
        before.at(i)=S.at(i);
        after.at(i)=S.at(i+2);
    }
    int ben,afn;
    int jg=-1;
    ben=stoi(before);
    afn=stoi(after);
    if(1<=ben && ben<=12){
        if(0<=afn){
            jg=0;
        }
    }
    if(0<=ben){
        if(1<=afn && afn<=12){
            if(jg==0){
                jg=3; //amb
            }
            else{
                jg=1;
            }
        }
    }
    //cout<<ben<<afn<<endl;

string out;
    if(jg==-1){
        out="NA";
    }
    else if(jg==0){
        out="MMYY";
    }
    else if(jg==1){
        out="YYMM";
    }
    else{
        out="AMBIGUOUS";
    }

    cout<<out<<endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    string T, ans;
    cin >> T;
    ans = "";
    for(char c: T){
        char nc;
        nc = c;
        if(c == '?'){
            nc = 'D';
        }
        ans += nc;
    }
    cout << ans << endl;
    
    return 0;
}


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

const int MAXN = 200005;

char x[MAXN];
int n;

int main(){
	scanf("%s", x);
	n = strlen(x);
	
	int d = 0, r = 0;
	for(int i = 0; i < n; i++){
		if(x[i] == 'S'){
			d++;
			r++;
		}else{
			if(d > 0){
				d--;
				r--;
			}else{
				r++;
			}
		}
	}
	printf("%d\n", r);
	
	return 0;
}


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

#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for (int i=(a);i>=(b);--i)
using ll=long long;

ll N; int A, B, C, D; 
map<ll,ll> res;
ll dp(ll x) {
    if (x == 0) return 0;
    if (res.count(x)) return res[x];
    res[x] = 1e18;
    if (x <= res[x]/D) res[x] = min(res[x], (ll)x*D);
    res[x] = min(res[x], min(dp(x/2)+A+(ll)(x%2)*D, dp((x+1)/2)+A+(ll)(2-x%2)*D));
    res[x] = min(res[x], min(dp(x/3)+B+(ll)(x%3)*D, dp((x+2)/3)+B+(ll)(3-x%3)*D));
    res[x] = min(res[x], min(dp(x/5)+C+(ll)(x%5)*D, dp((x+4)/5)+C+(ll)(5-x%5)*D));
    return res[x];
}

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

    int T; cin >> T;
    while (T--) {
        cin >> N >> A >> B >> C >> D;
        res.clear();
        cout << dp(N) << '\n';
    }
}



Measured memory_bytes: 4368
#include <stdio.h>
int main(void){


 int n; 
 int card[52]={0}; scanf(" %d", &n); 
 for(int i=0; i<n; ++i){ 
     char c; int a; scanf(" %c %d", &c, &a); if(c=='S') card[a-1]=1;
     else if(c=='H') card[a-1+13]=1; else if(c=='C') card[a-1+26]=1;
 else if(c=='D') card[a-1+39]=1; 
     
 } 
 for(int i=0; i<52; ++i){ if(card[i]==0){ if(i<13) printf("S ");
 else if(i<26) printf("H "); else if(i<39) printf("C "); 
 else if(i<52) printf("D "); printf("%d\n", i%13+1); 
     
 }
 } 
 return 0;
 } 



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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x);1
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair	
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define yes cout<<"YES\n"
#define no cout<<"NO\n"

using namespace std;
typedef long long ll;
typedef long double ld;	
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
	 
const ll MAX = 10000000;
const ll inf = 5e18-1;

int main() {
	fastio;
	ll n,x,cont=0;
	cin>>n;
	ll p[n],k[n];
	f(i,0,n){
		cin>>x;
		p[i]=x;
	}
	f(i,0,n){
		k[i]=i+1;
	}
	f(i,0,n){
		if(p[i]!=k[i]) cont++;
	}
	if(cont==2 || cont==0) yes;
	else no; 

	return 0;
	}

Measured memory_bytes: 256
import Data.Char
main :: IO ()
main = do
  [n,a,b] <- map read . words <$> getLine  :: IO [Int]
  let xs = filter (\x -> let d = digs x in d>=a && d<=b) [1..n] 
  print $ sum xs

digs :: Int -> Int
digs = sum . map digitToInt . show

Measured memory_bytes: 1020
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		// 入力
		Scanner sc = new Scanner(System.in);
		int firstStr = Integer.parseInt(sc.next());
		int secondStr = Integer.parseInt(sc.next());
		int thirdStr = Integer.parseInt(sc.next());
		sc.close();
		
		
		System.out.println(firstStr * secondStr > thirdStr ? thirdStr: firstStr * secondStr);
	}
}

Measured memory_bytes: 20820
#include<bits/stdc++.h>
using namespace std;
int main(void){
    char c;
    cin>>c;
    if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
        cout<<"vowel"<<endl;
    }
    else{
        cout<<"consonant"<<endl;
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException, InterruptedException {
        Scanner sc = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        String n = sc.next();
        out.println(n.contains("7")?"Yes":"No");
        out.flush();
        out.close();
    }



    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        boolean ready() throws IOException {
            return br.ready();
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        Scanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        int nextChar() throws IOException {
            return next().charAt(0);
        }

        int[] nextIntArray(int n) throws IOException {
            int[] ans = new int[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextInt();
            return ans;
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

    }
}


Measured memory_bytes: 32688
# -*- coding: utf-8 -*-
import math

# スペース区切りの整数の入力
b, c = map(int, input().split())
# 文字列の入力
def combinations_count(n, r):
    return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

print(int(combinations_count(b+c, 2)-b*c))


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define ll long long
#define Inf 123372036854775806ll
using namespace std;

int main() {
    map<int,int> ids;
    int ct=0;
    for(int i=2;i<=14;i++) {
        if (i<=13)
            ids[i]=ct;
        else
            ids[1]=ct;
        ct++;
    }
    
    int a,b;
    cin>>a>>b;

    if (a==b)
        printf("Draw\n");
    else {
        if (ids[a]>ids[b])
            printf("Alice\n");
        else
            printf("Bob\n");
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    int n;cin>>n;
    int k=n/2;
    if(n&1)cout<<1.0-k*1.0/n;
    else cout<<0.5;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=100000+10;
ll x[maxn],d[maxn],c[maxn];
int ans[maxn],now[maxn],o[maxn],sta[maxn];
int i,j,l,t,n,m,top;
ll k;
void mult(int *a,int *b,int *c){
	int i;
	fo(i,1,n) o[i]=a[b[i]];
	fo(i,1,n) c[i]=o[i];
}
int main(){
	scanf("%d",&n);
	fo(i,1,n){
		scanf("%lld",&x[i]);
		d[i]=x[i]-x[i-1];
		ans[i]=now[i]=i;
	}
	scanf("%d%lld",&m,&k);
	fo(i,1,m){
		scanf("%d",&t);
		swap(now[t],now[t+1]);
	}
	top=0;
	while (k){
		sta[++top]=k%2;
		k/=2;
	}
	while (top){
		mult(ans,ans,ans);
		if (sta[top--]) mult(ans,now,ans);
	}
	fo(i,1,n) c[i]=d[ans[i]];
	fo(i,1,n) x[i]=x[i-1]+c[i];
	fo(i,1,n) printf("%lld.0\n",x[i]);
}

Measured memory_bytes: 4864
n = int(input())
a = list(map(int, input().split()))
aa = a+a
g = sum(a)//2
ans = []
for i in range(1):
    temp = sum([aa[i+1+j*2] for j in range(n//2)])
    ans.append(g-temp)
temp = ans[0]
for i in range(1,n):
    temp = a[i-1] - temp
    ans.append(temp)
for k in ans:
    print(2*k,end=" ")

Measured memory_bytes: 14156
# coding: utf-8
# Your code here!
N=int(input())
S=list(input())

ans=0
log=[1]*26
for item in S:
    item=ord(item)-97
    log[item]+=1

ans=1
for item in log:
    ans*=max(item,1)

print((ans-1)%(10**9+7))

Measured memory_bytes: 3956
s = input()
t = input()
for i in range(len(s) - len(t), -1, -1):
    ans = list(s)
    for j in range(len(t)):
        if s[i + j] != t[j] and s[i + j] != '?':
            break
        else:
            ans[i + j] = t[j]
    else:
        break
else:
    print('UNRESTORABLE')
    exit()
print(''.join(ans).replace('?', 'a'))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define repn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) for(int i = 0; i < (a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
const int MOD = 1e9 + 7;

ll dp[105][100005];

int a[105];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, k;
	cin >> n >> k;
	rep(i, n){
		cin >> a[i];
	}
	dp[0][0] = 1;
	rep(i, n){
		repn(j, 1, k + 1){
			dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;	
		}
		rep(j, k + 1){
			dp[i + 1][j] = dp[i][j];
			if(j - a[i] - 1 >= 0){
				dp[i + 1][j] -= dp[i][j - a[i] - 1];
			}
			dp[i + 1][j] += MOD;
			dp[i + 1][j] %= MOD;
		}
	}
	cout << dp[n][k] << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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




int main(){
	int N,T;
	cin>>N>>T;
	vector<int> A;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		A.push_back(a);
	}
	
	vector<int> maxi(N);
	for(int i=N-1;i>=0;i--){
		if(i==N-1){
			maxi[i]=A[i];
		}
		else{
			maxi[i]=max(A[i],maxi[i+1]);
		}
	}
	
	int ans = 1;
	int dis = 0;
	
	for(int i=0;i<N-1;i++){
		int a = maxi[i+1]-A[i];
		if(dis==a)ans++;
		if(dis<a){
			ans=1;
			dis=a;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 1144
/***********************************************************
 *This code By @1353055672(Ligen)                          *
 *[Warning]You're not excepted to understand this code!    *
 *STOI GDOI APIO CTS NOIP 2019 RP++                        *
 ***********************************************************/
//#pragma GCC optimize(3)
//#pragma comment(linker, "/STACK:102400000,102400000")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#include<ctime>
#include<vector>
#define ll long long
#define ull unsigned long long
#define mn 200020
#define Max(x,y) ((x>y)?x:y)
#define Min(x,y) ((x<y)?x:y)
#define Abs(x) (((x)<(0))?(-(x)):(x))
#define infll (ll)(1e18)
#define infint (int)(1<<30)
#define mod (int)(1e9+7)
#define FOR(a,b,c) for (register ll a=b;a<=c;a++)
#define FORD(a,b,c) for (register ll a=b;a>=c;a--)
using namespace std;
inline ll read(){
    ll x=0,f=1;char c;
    for(c=getchar();c<'0'||c>'9';f=((c=='-')?-1:f),c=getchar());
    for(;c>='0'&&c<='9';x=x*10+c-'0',c=getchar());return x*f;
}

template<typename T>
inline void write(T a){
    if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
    while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
}
inline void write_(){return;}
template<typename T,typename... Args>
inline void write_(T a,Args... b){write(a);putchar(' ');write_(b...);}
inline void writeln(){putchar('\n');return;}
template<typename T,typename... Args>
inline void writeln(T a,Args... b){write(a);putchar(' ');writeln(b...);}
//need c++11

//inline void write(ll a){
//    if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
//    while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
//}
//inline void write_(ll a){write(a);putchar(' ');}
//inline void writeln(ll a){write(a);putchar('\n');}

inline ll gcd(ll a,ll b){return a==0?b:gcd(b%a,a);}
inline ll lcm(ll a,ll b){return 1ll*a/gcd(a,b)*b;}
inline ll Pow(ll n,ll a){ll b=1;while(a){if(a&1)b=1ll*b*n%mod;n=1ll*n*n%mod;a>>=1;}return b;}
//---------------------Head Files--------------------------//

signed main(){
    ll n=read(),k=read();
    if(k==1)writeln(0);else
    writeln(n-k);
    return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split(" "))
c=[list(map(int,input().split(" "))) for i in range(h)]
d=[[0]*(w+1) for i in range(h+1)]
for i in range(h):
    for j in range(w):
        if c[i][j]==0:
            d[i+1][j+1]=min(d[i][j],d[i][j+1],d[i+1][j])+1
print(max([max(a) for a in d])**2)



Measured memory_bytes: 55188
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
int memo[30];
signed main(){
    int n,m;
    cin>>n>>m;
    rep(i,n){
        int k;
        cin>>k;
        rep(j,k){
            int a;
            cin>>a;
            memo[a-1]++;
        }
    }
    int ans=0;
    rep(i,m){
        if(memo[i]==n)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdint>
#include <cstdio>

#include <atcoder/fenwicktree>

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

  atcoder::fenwick_tree<intmax_t> ft(n);
  for (int i = 0; i < n; ++i) {
    int a;
    scanf("%d", &a);
    ft.add(i, a);
  }

  for (int i = 0; i < q; ++i) {
    int t;
    scanf("%d", &t);

    if (t == 0) {
      int p, x;
      scanf("%d %d", &p, &x);
      ft.add(p, x);
    } else if (t == 1) {
      int l, r;
      scanf("%d %d", &l, &r);
      printf("%jd\n", ft.sum(l, r));
    }
  }
}


Measured memory_bytes: 8200
use proconio::*;

fn main() {
    input! {
        k: i64,
    };

    let mut ans = -1;
    let mut seven: i64 = 7;
    for i in 1..=k {
        if seven.rem_euclid(k) == 0 {
            ans = i;

            break;
        }

        seven = (seven * 10 + 7).rem_euclid(k);
    }

    println!("{}", ans);
}


Measured memory_bytes: 2076
#include<bits/stdc++.h>
	using namespace std;
	#define ull 		unsigned long long
	#define ll 			long long
	#define M 			1000000007
	#define pb 			emplace_back
	#define p_q 		priority_queue
	#define pii         pair<ll,ll>
	#define vi          vector<ll>
	#define vii         vector<pii>
	#define mi          map<ll,ll>
	#define mii         map<pii,ll>
	#define all(a)      (a).begin(),(a).end()
	#define sz(x)       (ll)x.size()
	#define endl        '\n'
	#define gcd(a,b)    __gcd((a),(b))
	#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
	#define ios	    	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	#define mp 			make_pair
	#define lb 			lower_bound
	#define ub			upper_bound
	#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
	#define ini(a,n,b)	for(ll int i=0;i<n;i++) a[i]=0;
	#define cset(a)		__builtin_popcountll(a)
	#define hell 		(ull)1e9
	#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr<<endl; }
	void err(istream_iterator<string> it) {}
	template<typename T, typename... Args>
	void err(istream_iterator<string> it, T a, Args... args) {
		cerr << *it << " = " << a << endl;
		err(++it, args...);
	}
	double n;
	double dp[301][301][301];
	inline double solve(int x,int y,int z)
	{
		if(x==n)
			return 1;
		double &ans=dp[x][y][z];
		if(ans!=-1)
			return ans;
		ans=n;
		if(n!=x+y+z)
		{
			if(dp[x][y][z+1]==-1)
			ans+=(n-x-y-z)*solve(x,y,z+1);
		else
			ans+=(n-x-y-z)*dp[x][y][z+1];
	}
		if(z!=0)
		{
			if(dp[x][y+1][z-1]==-1)
			ans+=z*solve(x,y+1,z-1);
		else
			ans+=z*dp[x][y+1][z-1];
	}
		if(y!=0)
		{
			if(dp[x+1][y-1][z]==-1)
			ans+=y*solve(x+1,y-1,z);
		else
			ans+=y*dp[x+1][y-1][z];
		}
		ans/=(n-x);
		return ans;
	}
	signed main(void)
	{ios
		rep(i,0,301)
		rep(j,0,301)
		rep(k,0,301)
		dp[i][j][k]=-1;
		cin>>n;
		int a[(int)n];
		rep(i,0,(int)n)
		cin>>a[i];
		int b=0,c=0;
		rep(i,0,(int)n)
		{if(a[i]==1)
				b++;
			else if(a[i]==2)
				c++;}
		cout<<setprecision(15)<<solve(0,b,c)-1<<endl;
	}

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

int main() { 
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a[5];
	cin >> a[1] >> a[2] >> a[3];
	sort(a+1, a+4);
	if (a[1] == a[2] && a[3] != a[1]) {
		cout << "Yes";
		return 0;
	}
	if (a[2] == a[3] && a[1] != a[2]) {
		cout << "Yes";
		return 0;
	}
	cout << "No";
	return 0;
}

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

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    string S;
    cin >> S;
    scanInt(K);
    map<char, vector<int>> cmap;
    REP(i, S.size()){
        auto& c = S[i];
        cmap[c].emplace_back(i);
    }
    // priority_queue<string, vector<string>, greater<string>> q;
    set<string> q;
    REP(ns, S.size()){
        REP(l, min(static_cast<int>(S.size() - ns), K)){
            q.emplace(S.substr(ns, l + 1));
        }
    }
    // for (char c = cmap.begin()->first; c <= 'z'; ++c){
    //     REP(k, S.size()){
    //         for (auto& n : cmap[c]){
    //             if (n + k < S.size()){
    //                 q.emplace(S.substr(n, k + 1));
    //             }
    //         }
    //         if (K <= q.size()) break;
    //     }
    //     if (K <= q.size()) break;
    // }
    // for (auto& s : q){
    //     cout << s << endl;
    // }
    auto it = q.begin();
    REP(i, K - 1) ++it;
    cout << *it << endl;
    // if (K == 1){
    //     cout << cmap.begin()->first << endl;
    //     return 0;
    // }
    // for (auto& p : cmap){
    //     cout << p.first << ": ";
    //     for (auto& n : p.second){
    //         cout << n << " ";
    //     }
    //     cout << endl;
    // }
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#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()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  int count = 1;
  int res = 0;
  while(count < b){
    res++;
    count += a - 1;
  }
  cout << res << endl;


}


Measured memory_bytes: 256
n = int(input())
h = [int(i) for i in input().split()]

# dpの最小値を変更する関数
def chmin(a, b):
    if a > b:
        return b
    else:
        return a
    
# 無限大の値
f_inf = float('inf')

# DP テーブルを初期化　(最小化問題なので INF に初期化)
dp = [f_inf] * (10**5+10)

# 初期条件
dp[0] = 0

# 足場 i-1 から足場 i へ移動する。コストは|h[i]−h[i-1]|
# 足場 i-2 から足場 i へと移動する コストは |h[i]−h[i-2]|
for i in range(1, n):
    dp[i] = chmin(dp[i], dp[i - 1] + abs(h[i] - h[i-1]))
    # 一番目の足場では一つ前しか存在しない
    if i > 1:
        dp[i] = chmin(dp[i], dp[i - 2] + abs(h[i] - h[i -2]))

print(dp[n-1])

Measured memory_bytes: 52552
N,M = map(int,input().split())
A = []
B = [0] * (N + 5)

for i in range(M):
  A.append(int(input()))
  B[A[-1]] = -1
  
B[0] = 1
for i in range(N + 1):
  if B[i] == -1:
    continue
  if B[i + 1] != -1:
    B[i + 1] += B[i]
    B[i + 1] %= 1000000007
  if B[i + 2] != -1:
    B[i + 2] += B[i]
    B[i + 2] %= 1000000007
print(B[N])

Measured memory_bytes: 7848
n,k = map(int,input().split())
alllst = ['0','1','2','3','4','5','6','7','8','9']
dislike = [str(i) for i in input().split()]

lst = set(alllst) - set(dislike)

while True:
    st = set(str(n))
    if st.issubset(lst):
        print(n)
        break
    else:
        n += 1

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*((b)/gcd(a,b)))

int main(){
	int n;
	cin >> n;
	vector<long long> v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];
	long long t=1;
	for (int i = 0; i < n; ++i) t=lcm(v[i],t);
	cout << t << endl;
	return 0;
}


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

int main(){
  string a,b;
  cin >> a >> b;
  if(a.size()<b.size()) cout << "LESS" << endl;
  else if(a.size()>b.size()) cout << "GREATER" << endl;
  else{
      for(int i=0;i<a.size();i++){
          if(a[i]<b[i]){
              cout << "LESS" << endl;
              return 0;
          }
          else if(a[i]>b[i]){
              cout << "GREATER" << endl;
              return 0;
          }
          else continue;
      }
      cout << "EQUAL" << endl;
      return 0;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define pii pair<int, int>
#define mp make_pair
#define ll long long
using namespace std;
string d[100010];
int n,m;
pii a[15];
int tac[15]={-1,2,5,5,4,5,6,3,7,6};
bool ok(string s,string ss)
{
	if (ss=="SHN") return 1;
	while (s.size()<ss.size()) s='0'+s;
	while (ss.size()<s.size()) ss='0'+ss;
	return s>ss;
}
int main()
{
	cin >>n>>m;
	for (int i=0;i<m;i++)
	{
		int x;
		cin >>x;
		a[i]=mp(x,tac[x]);
	}
	fill(d,d+n+1,"SHN");
	d[0]="";
	for (int i=1;i<=n;i++)
	{
		//cout <<i<<" ######\n";
		for (int j=0;j<m;j++)
		{
			if (a[j].second<=i)
			{
				if (d[i-a[j].second]=="SHN") continue;
				string s=d[i-a[j].second]+(char)(a[j].first+'0');
				//cout <<"s: "<<s<<"  d[i]: "<<d[i]<<"\n";
				if (ok(s,d[i])) d[i]=s;
			}
		}
	}
	cout <<d[n];
	return 0;
}

Measured memory_bytes: 45056
a= []
for i in range(3):
  a_input = input().split()
  a.append(a_input)

n = int(input())
for i in range(n):
  x = input()
  for j in range(3):
    for k in range(3):
      if x == a[j][k]:
        a[j][k] = "0"

for i in range(3):
    if a[0][i] == "0" and a[0][i] == a[1][i] and a[0][i] == a[2][i]:
      print("Yes")
      exit()
    elif a[i][0] == "0" and a[i][0] == a[i][1] and a[i][0] == a[i][2]:
      print("Yes")
      exit()
    elif a[0][0] == "0" and a[0][0] == a[1][1] and a[1][1] == a[2][2]:
      print("Yes")
      exit()
    elif a[0][2] == "0" and a[0][2] == a[1][1] and a[0][2] == a[2][0]:
      print("Yes")
      exit()
print("No")
      

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

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

using namespace std;
typedef long long ll;

int main() {
  ll n, x;
  vector<ll> a(n);
  cin >> n >> x;

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

  ll ans = 0;
  rep(i,n-1){
    if(a[i]+a[i+1]>x){
      int t = a[i] + a[i + 1] - x;
      ans += t;
      if(t>a[i+1]){
        a[i] =a[i]- t - a[i + 1];
        a[i + 1] = 0;
      } else {
        a[i + 1] -= t;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 33024