akhauriyash/Code-Regression huggingface dataset:
/*******************************\
   Name:    REAJUL HAQUE REAYZ  |
   School:  COMILLA UNIVERSITY  |
            CSE (5TH BATCH)     |
********************************/
#include<bits/stdc++.h>
#define endl "\n"
#define inf 1<<30
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define ss stringstream
#define all(v) v.begin(), v.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define bit_cnt(mask) __builtin_popcount(mask)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1000000007; /// 1e9+7
const int MAX = 100005;     /// 1e5+5
ll bigmod(ll n, ll r)
{
    if(r==0) return 1;
    if(r==1) return n;
    if(r%2==0)
    {
        ll ret = bigmod(n, r/2);
        return ((ret%MOD) * (ret%MOD)) % MOD;
    }
    else return ((n%MOD) * (bigmod(n,r-1)%MOD)) % MOD;
}
ll modinverse(ll a){return bigmod(a,MOD-2)%MOD;}
ll lcm(ll a, ll b) {a=abs(a); b=abs(b); return (a/__gcd(a,b))*b;}
ll gcd(ll a, ll b) {a=abs(a); b=abs(b); if(!b) return a; return __gcd(b,a%b);}

int n;
ll a[MAX], b[MAX], c[MAX];
ll x[MAX], y[MAX], z[MAX];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for(int i=0; i<n; i++) cin>>a[i];
    for(int i=0; i<n; i++) cin>>b[i];
    for(int i=0; i<n; i++) cin>>c[i];
    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);
    //cout<<"a = "; for(int i=0; i<n; i++) cout<<a[i]<<" "; cout<<endl;
    //cout<<"b = "; for(int i=0; i<n; i++) cout<<b[i]<<" "; cout<<endl;
    //cout<<"c = "; for(int i=0; i<n; i++) cout<<c[i]<<" "; cout<<endl;
    for(int i=0; i<n; i++){
        x[i] = b+n-upper_bound(b, b+n, a[i]);
    }
    for(int i=0; i<n; i++){
        y[i] = c+n-upper_bound(c, c+n, b[i]);
    }
    z[0]=y[0];
    for(int i=1; i<n; i++){
        z[i]=z[i-1]+y[i];
    }
    //cout<<"x = "; for(int i=0; i<n; i++) cout<<x[i]<<" "; cout<<endl;
    //cout<<"y = "; for(int i=0; i<n; i++) cout<<y[i]<<" "; cout<<endl;
    //cout<<"z = "; for(int i=0; i<n; i++) cout<<z[i]<<" "; cout<<endl;
    ll ans=0;
    for(int i=0; i<n; i++){
        if(x[i]==n) ans += z[n-1];
        else ans += z[n-1]-z[n-x[i]-1];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4992
# input
N = int(input())
H = list(map(int, input().split()))

# check
# 引用：https://qiita.com/c-yan/items/71ed57e83e3bee3e33ec
T = 0   # カウンタ
result = 0 # max保持
for i in range(N - 1):
    if H[i + 1] <= H[i]:
        T += 1
    else:
        result = max(T, result)
        T = 0
result = max(T, result)
print(result)

Measured memory_bytes: 14224
n = int(input())
ans = [0] * n
s = max(4, n - 2)
import math
t = math.sqrt(s)
t = math.floor(t)
for i in range(1, t + 1):
    for j in range(i, t + 2):
        for k in range(j, t + 3):
            x = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i
            if x <= n:
                if i == j == k:
                    ans[x - 1] += 1
                elif i == j != k or i != j == k or i == k != j:
                    ans[x - 1] += 3
                elif i != k != j:
                    ans[x - 1] += 6
        
for i in ans:
    print(i)

Measured memory_bytes: 9172
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        int h = sc.nextInt(), w = sc.nextInt();
        int n = sc.nextInt();
        char[][] map = new char[h+1][w+1];
        for(int i=1; i<=h; i++){
            String s = sc.next();
            for(int j=1; j<=w; j++){
                map[i][j] = s.charAt(j-1);
            }
        }

        int[][] J = new int[h+1][w+1];
        int[][] O = new int[h+1][w+1];
        int[][] I = new int[h+1][w+1];
        for(int i=1; i<=h; i++){
            for(int j=1; j<=w; j++){
                J[i][j] = J[i-1][j] + J[i][j-1] - J[i-1][j-1] + ((map[i][j]=='J')? 1 : 0);
                O[i][j] = O[i-1][j] + O[i][j-1] - O[i-1][j-1] + ((map[i][j]=='O')? 1 : 0);
                I[i][j] = I[i-1][j] + I[i][j-1] - I[i-1][j-1] + ((map[i][j]=='I')? 1 : 0);
            }
        }

        for(int i=0; i<n; i++){
            int h2 = sc.nextInt(), w2 = sc.nextInt();
            int h1 = sc.nextInt(), w1 = sc.nextInt();
            int cntJ = J[h1][w1] + J[h2-1][w2-1] - J[h1][w2-1] - J[h2-1][w1];
            int cntO = O[h1][w1] + O[h2-1][w2-1] - O[h1][w2-1] - O[h2-1][w1];
            int cntI = I[h1][w1] + I[h2-1][w2-1] - I[h1][w2-1] - I[h2-1][w1];
            System.out.println(cntJ+" "+cntO+" "+cntI);
        }
    }

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

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

int main(){
  double w,h,x,y;
  cin >>w>>h>>x>>y;
  double a;
  a=(w*h)/2;
  int b=0;
  if(x==w/2 && y==h/2){
    b=1;
  }
  cout << a << " " << b << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ZYCSwing
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] c = new int[n];
            int[] s = new int[n];
            int[] f = new int[n];
            for (int i = 0; i < n - 1; ++i) {
                c[i] = in.nextInt();
                s[i] = in.nextInt();
                f[i] = in.nextInt();
            }

            for (int i = 0; i < n - 1; ++i) {
                int cur = s[i] + c[i];
                for (int j = i + 1; j < n - 1; ++j) {
                    if (cur < s[j]) {
                        cur = s[j];
                    } else if (cur % f[j] != 0) {
                        cur += f[j] - cur % f[j];
                    }
                    cur += c[j];
                }
                out.println(cur);
            }

            out.println(0);
        }

    }
}



Measured memory_bytes: 26224
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

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

const long long INF = 1LL << 60;

int main()
{
	std::string a, b;
	std::cin >> a >> b;
	std::string ab = a + b;
	int ab_num = std::stoi( ab );
	bool isOk = false;
	for(int i=1; i<ab_num; i++)
	{
		if(i*i == ab_num)
		{
			isOk = true;
		}
	}
	if(isOk == true)
	{
		std::cout << "Yes" << std::endl;
	}
	else
	{
		std::cout << "No" << std::endl;
	}

	return 0;
}


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

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

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

int main() {
  int N;
  std::cin >> N;
  std::vector<int> x(N), y(N);
  rep(i, N) {
    std::cin >> x[i] >> y[i];
  }

  const double EPS = 1e-10;
  auto check = [&](double r) {
    std::vector<std::pair<double, double>> cs;
    for(int i = 0; i < N; ++i) {
      for(int j = i + 1; j < N; ++j) {
        double dx = x[i] - x[j];
        double dy = y[i] - y[j];
        double h = std::sqrt(dx * dx + dy * dy);

        if(2.0 * r < h + EPS) {
          continue;
        }

        double cos = 1.0 * dx / h;
        double sin = 1.0 * dy / h;

        double mx, my;
        mx = 0.5 * (x[i] + x[j]);
        my = 0.5 * (y[i] + y[j]);
        double delta = std::sqrt(r * r - h * h / 4);
        double px, py;
        px = mx - sin * delta;
        py = my + cos * delta;
        cs.push_back(std::make_pair(px, py));
        px = mx + sin * delta;
        py = my - cos * delta;
        cs.push_back(std::make_pair(px, py));
      }
    }

    for(auto p : cs) {
      double px, py;
      px = p.first;
      py = p.second;

      bool ok = true;
      rep(i, N) {
        double dx = x[i] - px;
        double dy = y[i] - py;
        if(dx * dx + dy * dy > r * r + EPS) {
          ok = false;
          break;
        }
      }
      if(!ok) continue;
      return true;
    }
    return false;
  };

  double l = 0;
  double r = 2000;

  while(r - l > EPS) {
    double m = (l + r) / 2;
    if(check(m)) {
      r = m;
    } else {
      l = m;
    }
  }

  std::cout << std::fixed << std::setprecision(10) << r << '\n';
}


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

using namespace std;

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

    long long n;
    cin >> n;
    vector<long long> a;
    long long sum = 0;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }

    long long per_move = n * (n + 1) / 2;
    if (sum % per_move) {
        cout << "NO";
        return 0;
    }

    long long total_moves = sum / per_move;

    long long m2 = 0;
    long long check_0 = 0;
    for (int i = 0; i < n; i++) {
        int pred = (i - 1 + n) % n;

        long long prev_sub = a[pred];
        long long cur_sub_delta = (prev_sub + total_moves) - a[i];
        if (cur_sub_delta % n || cur_sub_delta < 0) {
            cout << "NO";
            return 0;
        }
        check_0 += (cur_sub_delta / n) * (i == 0 ? 1 : n - i + 1);
        m2 += cur_sub_delta / n;
    }
    if (check_0 != a[0]) {
        cout << "NO";
        return 0;
    }
    if (m2 != total_moves) {
        cout << "NO";
        return 0;
    }
    cout << "YES";
}


Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cmath>

using namespace std;
const long long INF = (long long) (1e18)+1;

int main() {
  // map<string, int> words;
  vector<int> nums_1(3);
  vector<int> nums_2(3);
  vector<int> nums_3(3);

  for(int i=0; i<3; ++i){
    cin >> nums_1[i];
  }
  for(int i=0; i<3; ++i){
    cin >> nums_2[i];
  }
  for(int i=0; i<3; ++i){
    cin >> nums_3[i];
  }
  int n;
  cin >> n;

  vector<int> picks(n);

  vector<int> indexes;
  for(int i=0; i<n; ++i){
    cin >> picks[i];
    for (int j=0; j<3;++j) {
      if (nums_1[j] == picks[i]) {
        nums_1[j] = -1;
      }
      if (nums_2[j] == picks[i]) {
        nums_2[j] = -1;
      }

      if (nums_3[j] == picks[i]) {
        nums_3[j] = -1;        
      }
    }
  }
  
  // cout << "nums1" << endl;

  // for (auto& a : nums_1){
  //   cout << a << endl;
  // }
  //   cout << "nums2" << endl;

  // for (auto& a : nums_2){
  //   cout << a << endl;
  // }
  //   cout << "nums3" << endl;

  //   for (auto& a : nums_3){
  //   cout << a << endl;
  // }
  // bool flag = false;
  if ( nums_1[0] == -1 && nums_1[1] == -1 &&  nums_1[2] == -1 ){
    cout << "Yes" << endl;
  } else if ( nums_2[0] == -1 && nums_2[1] == -1 &&  nums_2[2] == -1 ){
    cout << "Yes" << endl;
  } else if ( nums_3[0] == -1 && nums_3[1] == -1 &&  nums_3[2] == -1 ){
    cout << "Yes" << endl;
  } else if ( nums_1[0] == -1 && nums_2[1] == -1 &&  nums_3[2] == -1 ){
    cout << "Yes" << endl;
  } else if ( nums_3[0] == -1 && nums_2[1] == -1 &&  nums_1[2] == -1 ){
    cout << "Yes" << endl;
  } else if ( nums_1[0] == -1 && nums_2[0] == -1 &&  nums_3[0] == -1 ){
    cout << "Yes" << endl;
  } else if ( nums_1[2] == -1 && nums_2[2] == -1 &&  nums_3[2] == -1 ){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  } 




  // for (int j=0; j<3;++k) {
  //   if (nums_1[i] == picks[i]) {
  //     nums_1[i] = -1;
  //   }
  //   if (nums_2[i] == picks[i]) {
  //     nums_2[i] = -1;
  //   }if (nums_2[i] == picks[i]) {
  //     nums_3[i] = -1;        
  //   }
  // }
  // if (nums_1[] )


  
}
// 84 97 66
// 79 89 11
// 61 59 7
// 7
// 89
// 7
// 87
// 79
// 24
// 84
// 30


Measured memory_bytes: 256
a1, b1 = list(map(int, input().split()))
a2, b2 = list(map(int, input().split()))
a3, b3 = list(map(int, input().split()))
r = [a1, b1, a2, b2, a3, b3]
if r.count(1) <= 2 and r.count(2) <= 2 and r.count(3) <= 2 and r.count(4) <= 2:
    print('YES')
else:
    print('NO')
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define stdi(in) freopen(in, "r", stdin)
#define stdo(out) freopen(out, "w", stdout)
#define stdio(in, out) stdi(in); stdo(out)
#define pb push_back

using namespace std;

typedef long long ll;

const int MAX = 1e5+7;
const ll MOD = 1e9+7;

ll dp[MAX][2];
vector<int> G[MAX];

ll solve(int s, int c, int p){

	if(dp[s][c]!=-1) return dp[s][c];

	ll ans = 1;
	for(auto v: G[s]){
		if(v==p) continue;

		if(c==1){
			ans = (ans*solve(v,0,s))%MOD;
			continue;
		}

		ll tmp = (solve(v,0,s)+solve(v,1,s))%MOD;
		ans = (ans*tmp)%MOD;
	}

	return dp[s][c] = ans;
}

int main(){

	/*#ifndef ONLINE_JUDGE
        stdio("in", "out");
    #endif*/
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	memset(dp, -1, sizeof(dp));
	for(int i=0;i<n-1;i++){
		int u,v;
		cin>>u>>v;
		G[u].pb(v);
		G[v].pb(u);
	}

	ll ans = solve(1,0,0);
	ans = (ans+solve(1,1,0))%MOD;

	cout<<ans<<'\n';

	return 0;
}

Measured memory_bytes: 15616
import sys
import itertools

sys.setrecursionlimit(10 ** 8)
ni = lambda: int(sys.stdin.readline())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
ns = lambda: sys.stdin.readline().rstrip()


N = ni()
M = 55555


def solve():
    ans = []
    for p in range(7, M, 10):
        pr, j = True, 3
        while j * j <= p:
            if p % j == 0:
                pr = False
                break
            j += 2
        if pr:
            ans.append(p)
            if len(ans) == N:
                break
    print(*ans)


solve()


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

// 連想配列
void answer1() {
  map<int, bool> mp;
  int in;
  while (cin >> in) {
    if (mp.find(in) == mp.end()) {
      mp[in] = true;
    }
  }
  cout << mp.size() << endl;
}

// バケット法
void answer2() {
  bool d[101] = {0};
  int in;
  while (cin >> in) {
    d[in] = true;
  }
  int count = 0;
  for (int d_i: d) {
    if (d_i) {
      count++;
    }
  }
  cout << count << endl;
}

// 順序付集合
void answer3() {
  set<int> st;
  int in;
  while (cin >> in) {
    st.insert(in);
  }
  cout << st.size() << endl;
}

int main() {
  int N;
  cin >> N;
  //answer1();
  //answer2();
  answer3();
}


Measured memory_bytes: 256
/**
 *COYG, 14 FA Cups we are back baby
 */
#include <bits/stdc++.h>
using namespace std;
#define mod 		1000000007
#define ll 		long long
#define mp 		make_pair
#define pb 		push_back
#define forn(i,n) 	for(int i=0;i<n;i++)
#define for1(i,n) 	for(int i=1;i<n;i++)
#define ford(i,n) 	for(int i=n-1;i>=0;i--)
#define vi 		vector<int>
#define vl 		vector<ll>
#define pii 		pair<int,int>
#define pll 		pair<ll,ll>
#define vpi 		vector<pair<int,int> >
#define vpl		vector<pair<ll,ll> >
#define vvi 		vector<vector<int> >
#define vvl 		vector<vector<ll> >
#define ull 		unsigned long long
#define IOS 		ios_base::sync_with_stdio(false);
#define PI 		3.1415926535897932384626
#define ff 		first
#define ss 		second
#define char2Int(c) 	(c-'0')
#define FOREACH(i,t) 	for (auto i=t.begin(); i!=t.end(); i++)
#define clr(a,x) 	memset(a,x,sizeof(a)) //set elements of array to some value
#define all(x)		(x).begin(),(x).end()//cout<<"Case #"<<zzz<<": ";
#define plll pair<ll,pll >
int n;int dp[100001];int a[100001];
int getans(int curr)
{
    if(dp[curr]!=-1)return dp[curr];
    int flag=0;
    forn(i,n)
    {
        if(a[i]<=curr)
        {
            if(getans(curr-a[i])==0)flag=1;
        }
    }
    dp[curr]=flag;
    return flag;
}
void solve()
{
    cin>>n;int k;cin>>k;forn(i,n)cin>>a[i];
    forn(i,k+1)dp[i]=-1;dp[0]=0;
    if(getans(k))cout<<"First";
    else cout<<"Second";
    cout<<endl;
}
int main()
{
    IOS;cin.tie(NULL);
    int zz;zz=1;
    //cin>>zz;
    for(int zzz=1;zzz<=zz;zzz++)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 8728
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N,i;
    cin >> N;
    ll A[N+1],B;
    for(i=0;i<=N;i++){
        cin >> A[i];
    }
    ll ans=0;
    for(i=0;i<N;i++){
        cin >> B;
        ans+=min(A[i]+A[i+1],B);
        A[i+1]=max(A[i+1]-max(B-A[i],(ll)0),(ll)0);
    }
    cout << ans;
    return 0;
}


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

#define INF 1LL << 30

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> hi(N);
  for (int i=0;i<N;i++){
    cin >> hi[i];
  }
  sort(hi.begin(),hi.end());
  int mi = INF;
  for (int i=0;i<N-K+1;i++){
    mi = min(mi, hi[i+K-1] - hi[i]);
  }
  cout << mi << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
 
int main()
{
int a[3];
cin>>a[0]>>a[1]>>a[2];
for(int i=0;i<3;i++)
for(int j=i;j<3;j++)
if(a[i]>a[j])
swap(a[i],a[j]);
for(int i=0;i<3;i++)
{
cout<<a[i];
if(i==2)
cout<<endl;
else
cout<<" ";
}
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int main(){
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin >> k;
    long long ar[k];
    for(int i  =0; i<k; i++){
        cin >> ar[i];
    }
    long long low = 2LL;
    long long high = 2LL;
    bool ok = true;
    for(int i = k-1; i>=0; i--){
        long long a = ar[i];
        long long nl;
        if(low%a==0){
            nl = low;
        }
        else{
            nl = ((low/a)+1LL)*a;
        }
        long long nh;
        if(high%a==0){
            nh = a+high-1LL;
        }
        else{
            nh = ((high/a)+1LL)*a-1LL;
        }
        low = nl;
        high = nh;
        if(nl>nh){
            break;
        }
    }
    if(low<=high){
        cout << low << " " << high << endl;
    }
    else{
        cout << "-1" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1024
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(int n, void delegate() pred) {
    foreach(i; 0..n) pred();
}
T[] rep(T)(int n, T delegate() pred) {
    T[] res = new T[n];
    foreach(ref e; res) e = pred();
    return res;
}

void main() {
    int N = readln.chomp.to!int;
    readln.split.to!(int[]).sort().enumerate.filter!(a => a.index%2==0).map!(a => a.value).sum.writeln;
}


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

int main()
{
    // 入力
    int N,C[4]={0,0,0,0};
    int result=0;
    cin >> N;
    string S[N];
    rep(i,N){
        cin >> S[i];
    }

    //cout << "" << endl;
    // 計算
    rep(i,N){
        if (S[i]=="AC"){
            C[0]++;
        } else if (S[i]=="WA"){
            C[1]++;
        } else if (S[i]=="TLE"){
            C[2]++;
        } else if (S[i]=="RE"){
            C[3]++;
     }
    }

    // 出力
    cout << "AC x " << C[0] << endl;
    cout << "WA x " << C[1] << endl;
    cout << "TLE x " << C[2] << endl;
    cout << "RE x " << C[3] << endl;
    return 0;  
}


Measured memory_bytes: 6712
#include <stdio.h>

int main(void){
  char s[4] = {'\0'};
  scanf("%3s", s);
  int num = 700;
  for(int i = 0; i < 3; i++){
    if(s[i] == 'o') num += 100;
  }
  printf("%d\n", num);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

// xがyに行く
vvvll dp(101, vvll(8, vll(8, 0)));
vvll dpb(8, vll(8, 0));

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll h, w, k;
    cin >> h >> w >> k;
    ll r = powint(2, w-1);
    rep(i, r){
        rep(j, w-1){
            if((i>>j)&1 && (i>>(j+1))&1) goto invalid;
        }
        rep(j, w){
            if((i>>j)&1) dpb[j][j+1]++;
            else if(j > 0 && (i>>(j-1))&1) dpb[j][j-1]++;
            else dpb[j][j]++;
        }
        invalid:;
    }
    rep(i, 8)rep(j, 8){
        dp[1][i][j] = dpb[i][j];
    }
    repr(i, 2, h+1){
        rep(j, 8)rep(k, 8)rep(l, 8){
            dp[i][j][k] += (dp[i-1][j][l]*dpb[l][k])%MOD;
            dp[i][j][k] %= MOD;
        }
    }
    cout << dp[h][0][k-1] << endl;
    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    vector<int> a(100);
    int n;
    while (cin >> n)
    {
        a[n]++;
    }

    int v = *max_element(ALL(a));

    rep(i, 100)
    {
        if (v == a[i])
        {
            OP(i)
        }
    }

    return 0;
}


Measured memory_bytes: 3020
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int p[20];
  for(int i = 0;i<n;i++)cin>>p[i];
  int ans=0;
  for(int j=0;j<n-2;j++){
    if((p[j]>p[j+1]&&p[j+1]>p[j+2])||(p[j]<p[j+1]&&p[j+1]<p[j+2]))ans++;
  }
  cout<<ans<<endl;
}

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

string ItoS(int a){
  string res;
  if(a == 0) return "0";
  while(a) res = char(a%10+'0')+res,a/=10; 
  return res;
}

int main(){
  while(1){
  int n;
  string str;
  cin>>n;
  if(n==0)break;
  cin>>str;

  while(n--){
    str+='#';
    string nstr;
    int cnt = 1;
    char pre = str[0];
    for(int j=1;j<(int)str.size();j++){
      if(str[j]!=pre) nstr+=ItoS(cnt)+pre,cnt=0;
      cnt++;
      pre = str[j];
    }
    str = nstr;
  }
  cout<<str<<endl;
  }

  return 0;
}

Measured memory_bytes: 3152
a = int(input())

b = {}
for _ in range(a):
    S = input()
    if S in b:
        b[S] += 1
    else:
        b[S] = 1

m = max(b.values())
l = []
for k in b:
    v = b[k]
    if v != m:
        continue
    l.append(k)

for s in sorted(l):
    print(s)

Measured memory_bytes: 32984
K, N = list(map(int, input().split()))
A = list(map(int, input().split()))
ans = float('inf')

for i in range(N):
    ans = min(ans, K-A[i]+A[i-1], A[i]+K-A[(i+1)%N])

print(min(A[-1]-A[0], ans))
    

Measured memory_bytes: 26444
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <limits>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <iterator>
#include <queue>
#include <stack>
#include <vector>
#include <utility>

#define FOR(i,k,n) for(int (i) = (k); (i) < (n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x,y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
template<class T> using vv=vector< vector<T> >;
typedef deque<int> di;
typedef deque< deque<int> > ddi;


int main() {
    int I, O, T, J, L, S, Z;
    while(cin >> I >> O >> T >> J >> L >> S >> Z) {
    ull count = 0;
    count += O;
    ull c1 = 0,c2 = 0;
    if(I > 0 && min(J,L) >= 1) {
        c1 += 3;
        c1 += ((J-1)/2)*2;
        c1 += ((L-1)/2)*2;
        c1 += ((I-1) / 2)*2;
    } 

    c2 += (I / 2)*2;
    c2 += (J/2)*2;
    c2 += (L/2)*2;
    
    count += max(c1, c2);
    cout << count << endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
   
   string s;
   cin >> s;


   int l = s.length()-1;
   long long sum = 0;
   for(int i=0;!(i&(1<<l));i++){
      long long x=0;
      for(int k=0;k<l+1;k++){
        x*=10;
         x += s[k]-'0';
        if((i >> k)&1){
            sum += x;
            x=0;
        }
      }
      sum+=x;
    }
     
       cout <<sum <<endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int h, n, x, sum = 0;
    cin >> h >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> x;
        sum += x;
    }
    if (sum >= h) cout << "Yes";
    else cout << "No";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using  namespace  std;
using ll=long long;
const int mod =1e9+7;
int main(){
  int n;
  cin>>n;
  vector<ll> a(n);
  for(int i=0;i<n;i++)cin>>a.at(i);
  ll ans=0;
map<ll,ll> mp; 
mp[0]=1;
ll sum=0;
  for(int i=0;i<n;i++) {
     sum+=a.at(i);
     ans+=mp[sum];
    mp[sum]++;
     }
   cout<<ans<<endl;
   }
  


Measured memory_bytes: 14336
#include "bits/stdc++.h"
using namespace std;
using long_t = int64_t;

struct Solver {
	Solver() {
		ios::sync_with_stdio( false );
		cout << fixed << setprecision( 10 );
	}

	void solve() {
		int N;
		string S;
		cin >> N >> S;

		long_t ans = combi( S );
		for( int i = 0; i < N; ++i ) {
			for( int j = i+1; j < N; ++j ) {
				int k = j + j-i;

				if( k < N && S[i] != S[j] && S[j] != S[k] && S[i] != S[k] ) {
					ans -= 1;
				}
			}
		}

		cout << ans << endl;
	}

	long_t combi( const string& S ) const {
		long_t r = 0;
		long_t g = 0;
		long_t b = 0;

		for( int i = 0; i < S.size(); ++i ) {
			if( S[i] == 'R' ) { r += 1; continue; }
			if( S[i] == 'G' ) { g += 1; continue; }
			if( S[i] == 'B' ) { b += 1; continue; }
		}

		return r*g*b;
	}
};

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


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int max_i = 1;
	int min_i = -1;
	map<int,int> data;
	data[0] = a[0];
	bool mode = true;
	for (int i = 1; i < n; ++i) {
		if (mode) {
			data[max_i] = a[i];
			++max_i;
			mode = false;
		}
		else {
			data[min_i] = a[i];
			--min_i;
			mode = true;
		}
	}

	if (n%2 == 0) {
		for (int i = max_i-1; i > min_i; --i) {
			cout << data[i] << " ";
		}
		cout << endl;
	}
	else {
		for (int i = min_i+1; i < max_i; ++i) {
			cout << data[i] << " ";
		}
		cout << endl;
	}

	return 0;
}



Measured memory_bytes: 12288
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define ld double
#define pb push_back
#define EPS 1e-9
#define all(a) a.begin(),a.end()
#define sz(a) int((a).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
using namespace std;
typedef pair<int, int> II;
typedef pair<II, int> III;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    string s;
    cin >> s;
    if (s[0] != 'A') cout << "WA";
    else {
        int cnt = 0;
        FOR(i,2,sz(s)-2)
            if (s[i] == 'C') cnt++;
        if (cnt != 1) cout << "WA";
        else {
            cnt = 0;
            FOR(i,0,sz(s)-1)
                if (s[i] >= 'A' && s[i] <= 'Z') cnt++;
            if (cnt == 2) cout << "AC";
            else cout << "WA";
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define ll long long

int main(){
  int n;cin>>n;
  vector<int>d(n);
  int sum=0;
  for(int i=0;i<n;i++)
    cin>>d.at(i);
  for(int i=0;i<n;i++)
  {
    for(int j=i+1;j<n;j++)
    {
      sum+=d.at(i)*d.at(j);
    }
  }
  cout<<sum;
}
  
  
  
  
  
  

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os<<"("<<p.first<<","<<p.second<<")";
    return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os<<"{";
    rep(i, v.size()) {
        if (i) os<<",";
        os<<v[i];
    }
    os<<"}";
    return os;
}

string s[310];
int f[310];
int c[310][310];

int main() {
	int H, W, K;
	cin >> H >> W >> K;
	rep(i, H) cin >> s[i];

	int now = 1;

	rep(i, H) {
		int la = -1;
		rep(j, W) {
			if (s[i][j] == '#') {
				for (int k = la + 1; k <= j; ++k) {
					c[i][k] = now;
				}
				f[i] = 1;
				now++;
				la = j;
			}
		}
		if (la != -1) {
			for (int k = la + 1; k < W; ++k) {
				c[i][k] = c[i][la];
			}
		}
	}

	int la = -1;

	rep(i, H) {
		if (f[i]) {
			for (int k = la + 1; k < i; ++k) {
				rep(j, W) {
					c[k][j] = c[i][j];
				}
			}
			la = i;
		}
	}

	for (int k = la + 1; k < H; ++k) {
		rep(j, W) {
			c[k][j] = c[la][j];
		}
	}

	rep(i, H) {
		rep(j, W) {
			printf("%d%c", c[i][j], j == W-1 ? '\n' : ' ');
		}
	}


	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long x,N,sum=0;
  cin>>N>>x;
  vector<long long> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
    sum+=a.at(i);
  }
  sort(a.begin(),a.end());
  int ans=0;
  if(sum==x){
    ans=N;
  }
  else if(sum<x){
    ans=N-1;
  }
  else{
    ans=N;
    while(x<sum){
      sum-=a.at(ans-1);
      ans--;
      if(ans==0)
        break;
   }
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int mask = (1 << 17) - 1;
const int mod = 1e9 + 7;
int f[47][mask + 7];
int ap(int st, int x) {
    return ((st << x) | (1 << (x - 1))) & mask;
}
int main() {
    int n, x, y, z;
    scanf("%d%d%d%d", &n, &x, &y, &z);
    int S = 0;
    S = ap(S, x);
    S = ap(S, y);
    S = ap(S, z);
    f[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= mask; j++)
        for (int k = 1; k <= 10; k++) {
            int ns = ap(j, k);
            if ((ns & S) == S) continue;
            f[i][ns] = (f[i][ns] +f[i - 1][j]) % mod;
        }
    }
    int ans = 1;
    for (int i = 1; i <= n; i++) ans = 10LL * ans % mod;
    for (int i = 0; i <= mask; i++) ans = (ans - f[n][i]) % mod;
    printf("%d\n", (ans + mod) % mod);
    return 0;
}

Measured memory_bytes: 22272
#include <cstdio>

int main(){
		int h,w;
		int a[500][500];
		int o[260000][4];
		int cnt = 0;

		scanf("%d %d\n",&h,&w);
		for(int i=0 ; i<h ; ++i){
				for(int j=0 ; j<w ; ++j){
						scanf("%d",&a[i][j]);
				}
		}

		for(int i=0 ; i<h ; ++i){
				for(int j=0 ; j<w ; ++j){
						if(a[i][j] % 2 == 1){
								if(j != w-1){
										++a[i][j+1];
										o[cnt][0] = i+1;
										o[cnt][1] = j+1;
										o[cnt][2] = i+1;
										o[cnt][3] = j+2;
										++cnt;
								}
								else{
										if(i != h-1){
												++a[i+1][j];
												o[cnt][0] = i+1;
												o[cnt][1] = j+1;
												o[cnt][2] = i+2;
												o[cnt][3] = j+1;
												++cnt;
										}
								}
						}
				}
		}
		printf("%d\n",cnt);
		for(int i=0 ; i<cnt ; ++i){
				printf("%d %d %d %d\n",o[i][0],o[i][1],o[i][2],o[i][3]);
		}

}


Measured memory_bytes: 6784
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 998244353
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  int H,W;
  cin >> H >> W;
  char A[H][W];
  rep(i,H) cin >> A[i];
  bool reach[H][W]={};
  int dis[H][W];
  rep(i,H) rep(j,W) dis[i][j]=INF;
  rep(i,H) rep(j,W) if(A[i][j]=='#') dis[i][j]=0;
  queue<pint> dark;
  rep(i,H) rep(j,W) if(A[i][j]=='#') dark.push(pint(i,j));
  while(!dark.empty()){
    pint p=dark.front();
    dark.pop();
    if(p.first<0 || p.first>=H || p.second<0 || p.second>=W) continue;
    if(reach[p.first][p.second]) continue;
    reach[p.first][p.second]=true;
    dark.push(pint(p.first+1,p.second));
    dark.push(pint(p.first-1,p.second));
    dark.push(pint(p.first,p.second+1));
    dark.push(pint(p.first,p.second-1));
    if(p.first!=0) dis[p.first-1][p.second]=min(dis[p.first-1][p.second],dis[p.first][p.second]+1);
    if(p.first!=H-1) dis[p.first+1][p.second]=min(dis[p.first+1][p.second],dis[p.first][p.second]+1);
    if(p.second!=0) dis[p.first][p.second-1]=min(dis[p.first][p.second-1],dis[p.first][p.second]+1);
    if(p.second!=W-1) dis[p.first][p.second+1]=min(dis[p.first][p.second+1],dis[p.first][p.second]+1);
  }
  int ans=0;
  rep(i,H) rep(j,W) ans=max(ans,dis[i][j]);
  cout << ans << endl;
}

Measured memory_bytes: 38928
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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 (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;


struct UnionFind {
	VI par;
	UnionFind(int N) :par(N) {
		REP(i,N)par[i] = i;
	}
	int root(int x) {
		if (par[x] == x)return x;
		return par[x] = root(par[x]);
	}
	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry)return;
		par[rx] = ry;
	}
	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

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

	int N, K; cin >> N >> K;
	int ans = 0;
	REP(i, N) {
		int a; cin >> a;
		ans += min(a, abs(K - a))*2;
	}

	cout << ans << endl;

	return 0;
}



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

whole = sum(a)

if n == 2:
    print(abs(a[0] - a[1]))
else:
    now = 0
    ans = float("inf")
    for i in a[:-1]:
        now += i
        diff = abs(whole - 2 * now)
        ans = min(ans, diff)

    print(ans)

Measured memory_bytes: 24832
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int m=10000000;
  for(int i=0;i<s.size()-2;i++){
    int a=s[i]-'a'+49;
    int b=s[i+1]-'a'+49;
    int c=s[i+2]-'a'+49;
    int num=100*a+10*b+c;
    m=min(m,abs(753-num));
  }
  cout<<m<<endl;
}


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

void roundRobinScheduling(int q, queue<string> name, queue<int> time){
	int timeSpend = 0;
	while (name.size() > 0) {
		if (q - time.front() >= 0) {
			timeSpend += time.front();
			cout << name.front() << " " << timeSpend << endl;
		} else {
			name.push(name.front());
			time.push(time.front() - q);
			timeSpend += q;
		}
		name.pop();
		time.pop();
	}
}

int main(int argc, char const* argv[])
{
	int n, q;
	cin >> n >> q;
	queue<string> name;
	queue<int> time;
	for (int i=0; i<n; i++) {
		string tmp_name;
		int tmp_time;
		cin >> tmp_name;
		cin >> tmp_time;
		name.push(tmp_name);
		time.push(tmp_time);
	}
	roundRobinScheduling(q, name, time);

	return 0;
}


Measured memory_bytes: 4696
#include <vector>

template<class T, class E, class U, class To, class Adj, class Ope, class Merge>
std::vector<T> rerooting(const std::vector<std::vector<E>>& G, int r, U ide, To to, Adj adj, Ope ope, Merge merge) {
  int N = G.size();
  std::vector<T> tdp(N);
  std::vector<int> par(N, -1);
  std::vector<int> que(N);
  int qi = 0;
  que[qi++] = r;

  int MAX = 1;
  for(int i = 0;i < qi;i++) {
    int v = que[i];
    for(const auto& e: G[v]) {
      int t = to(e);
      if(t == par[v]) continue;
      par[t] = v;
      que[qi++] = t;
    }
    MAX = std::max(MAX, (int)G[v].size() + 1);
  }

  for(int i = qi; i --> 0;) {
    int v = que[i];
    U sum = ide;
    for(const auto& e : G[v]) {
      int t = to(e);
      if(t == par[v]) continue;
      sum = ope(sum, adj(tdp[t], e));
    }
    tdp[v] = merge(sum, v);
  }

  std::vector<U> f(MAX);
  std::vector<U> b(MAX);

  for(int i = 0; i < qi; i++) {
    int v = que[i];
    for(int j = 0;j < G[v].size();j++) {
      int t = to(G[v][j]);
      f[j + 1] = adj(tdp[t == par[v] ? v : t], G[v][j]);
    }
    b[G[v].size()] = ide;
    for(int j = G[v].size(); j --> 0;) b[j] = ope(f[j + 1], b[j + 1]);
    f[0] = ide;
    for(int j = 0;j < G[v].size(); j++) {
      int t = to(G[v][j]);
      f[j + 1] = ope(f[j], f[j + 1]);
      if(t != par[v]) {
        tdp[t] = merge(ope(f[j], b[j + 1]), v);
      }
      tdp[v] = merge(f[G[v].size()], v);
    }
  }
  return tdp;
}

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }


int main() {
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  i64 N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  rep(i,0,N - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  auto res = rerooting<int>(G, 0, 1,
        [](int t) { return t; },
        [&](int t, int) { return (t + 1) == M ? 0 : t + 1; },
        [&](int a, int b) { return (int)(i64(a) * b % M); },
        [](int a, int) { return a; }
      );

  rep(i,0,N) {
    cout << res[i] << "\n";
  }
}


Measured memory_bytes: 8056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v) cerr << #v << ":"; rep(i, v.size()) cerr << " " << v[i]; cerr << 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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

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


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>

int main()
{
  int n;
  std::cin >> n;
  
  std::vector<int> ds;
  for(int i=0; i<n; i++)
  {
    int d;
    std::cin >> d;
    ds.push_back(d);
  }
  std::sort(ds.begin(), ds.end());

  std::cout << ds[ds.size()/2] - ds[ds.size()/2-1];;
}


Measured memory_bytes: 892
N = int(input())
P = [int(i) for i in input().split()]
p_sorted = list(sorted(P))

if P == p_sorted:
    print('YES')
    exit()
for i in range(N):
    for j in range(i + 1, N):
        P[i], P[j] = P[j], P[i]
        if P == p_sorted:
            print('YES')
            exit()
        P[i], P[j] = P[j], P[i]
print('NO')

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

#define int long long
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 (b<a) { a=b; return 1; } return 0; }

#define MOD 998244353

int n, s;

int a[3010];
int memo[3010][3010][2];

int dp(int i, int num, int start){
	if(num == 0){
		return n-i+1;
	}

	if(i == n) return 0;

	if(memo[i][num][start] != -1) return memo[i][num][start];

	int ans = 0;
	if(start == 0){
		ans = dp(i+1, num, 0);
		ans = (ans + dp(i+1, num, 1)) % MOD;
		if(num-a[i] >= 0) ans = (ans + dp(i+1, num-a[i], 1)) % MOD;
	}else{
		ans = dp(i+1, num, 1);
		if(num-a[i] >= 0) ans = (ans + dp(i+1, num-a[i], 1)) % MOD;
	}

	return memo[i][num][start] = ans;
}

signed main(){
	cin >> n >> s;
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}

	memset(memo, -1, sizeof(memo));

	cout << dp(0, s, 0) << endl;

	return 0;
}


Measured memory_bytes: 142080
#include <iostream>
using namespace std;
int main(void){
  long long N;
  cin >> N;
  
  long long i = 0;
  if(N % 11 > 6)
    i += 2;
  else if(N % 11 > 0)
    i++;
  
  i += N / 11 * 2;
  
  cout << i << endl;
  
  return 0;
}


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

int main() {
	long int N;
	cin >> N;
	int a = 0;
	for(int i = 0; i < 6; ++i){
			if(pow(10,i) <= N && N < pow(10,i + 1)){
				 a = i + 1;
				 break;
			}
	}
	long long int sum = 0;
	for(int i = 0; i < a  - 1; ++i){
			if(i%2 == 0) {
				sum += 9 * pow(10, i);
			}
	}
	if(a%2 == 1){
			cout << sum + N - pow(10,a -1)  + 1<< endl;
	} else {
			cout << sum << endl;
	}
}



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

bool istriangle(int a, int b, int c){
    int cnt=0;

    if(a<b+c)cnt+=1;
    if(b<a+c)cnt+=1;
    if(c<a+b)cnt+=1;

    if(cnt==3)return true;
    else return false;
}

int whichtriangle(int a, int b, int c){
    int longest, sub1, sub2;
    if(a>b){
        longest=a;
        sub1=b;
    }
    else {
        longest=b;
        sub1=a;
    }
    if(c>longest){
        sub2=longest;
        longest=c;
    }
    else {
        sub2=c;
    }

    if(longest*longest==sub1*sub1+sub2*sub2)return 1;
    else if(longest*longest>sub1*sub1+sub2*sub2)return 3;
    else return 2;

}

int main(){

    int a, b, c;
    int t=0;
    int types[4]={0, 0, 0, 0};

    while (1){
        cin >> a >> b >> c;
        if(istriangle(a, b, c) == 0)break;

        types[whichtriangle(a, b, c)]+=1;
        t+=1;

    }

    cout << t;
    for(int i=1;i<4;i++){
        cout << " " << types[i];
    }

    cout << endl;

}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

ll A, B;

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

    std::cin >> A >> B;

    ll d = B - A;
    ll x = d * (d + 1) / 2 - B;

    std::cout << x << std::endl;
}


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

int main(){
    double n,t;    cin>>n>>t;
    double max=0.0001;

    for(int i=0;i<n;i++){
        double x,h; cin>>x>>h;
        if(max<h/x)max=h/x;
    }
    max*=t;

    //cout<<max<<endl;
    printf("%.16f",max);

    return 0;
}





Measured memory_bytes: 3296
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, M = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    l=[10]*N
    for i in range(M):
        s,c=map(int, input().split())
        if l[s-1]!=10 and l[s-1]!=c:
            print(-1)
            exit()
        else:
            l[s-1]=c
    if N>1 and (0 in l[0:-1]):
        print(-1)
        exit()
    else:
        s=''
        for i, val in enumerate(l):
            if val==10:
                if i ==0 and N>=2:
                    s+=str(1)
                else:
                    s+=str(0)
            else:
                s+=str(val)
        print(s)
if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include<stdio.h>

int main()
{
	int biggest3[3] = {0,0,0};
	for(int i = 0; i < 10; i++)
	{
		int input = 0;
		scanf("%d", &input);

		for(int j = 0; j < 3; j++)
		{
			if(biggest3[j] < input)
			{
				int swap = biggest3[j];
				biggest3[j] = input;
				input = swap;
			}
		}
	}

	printf("%d\n%d\n%d\n", biggest3[0], biggest3[1], biggest3[2]);

	return 0;
}

Measured memory_bytes: 1028
from operator import itemgetter

n = int(input())
info = [list(map(int, input().split())) for i in range(n)]
a = [info[i][0] for i in range(n)]
b = [info[i][1] for i in range(n)]

a = sorted(a)
b = sorted(b)
if n % 2 == 1:
    l = a[n // 2]
    r = b[n // 2]
    print(r - l + 1)
else:
    l1, l2 = a[n // 2 - 1], a[n // 2]
    r1, r2 = b[n // 2 - 1], b[n // 2]
    print((r1 + r2) - (l1 + l2) + 1)

Measured memory_bytes: 132604
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define nl '\n'

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int , int> pi;

void solve()
{
	ll n; 
	cin>>n;
	ll answer = 0;
	for(ll i=1; i<=n; i++)
	{
		ll temp = n/i;
		answer += i*temp*(temp+1)/2;
	}
	cout<<answer<<nl;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	//cin>>t;
	t = 1;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 3528