akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int l, r, d;
  cin >> l >> r >> d;
  int cnt = 0;
  for(int i=l;i<=r;i++){
    if(i%d==0)cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void insertionSort(int arr[], int n)
{
    int i, key, j;
    for (i = 1; i < n; i++)
    {
        key = arr[i];
        j = i-1;

        while (j >= 0 && arr[j] > key)
        {
            arr[j+1] = arr[j];
            j = j-1;
        }
        arr[j+1] = key;
    }
}
int binarySearch(int arr[], int l, int r, int x)
{
    if (r >= l)
    {
        int mid = l + (r - l)/2;

        // If the element is present at the middle
        // itself
        if (arr[mid] == x)
            return mid;

        // If element is smaller than mid, then
        // it can only be present in left subarray
        if (arr[mid] > x)
            return binarySearch(arr, l, mid-1, x);

        // Else the element can only be present
        // in right subarray
        return binarySearch(arr, mid+1, r, x);
    }

    // We reach here when element is not
    // present in array
    return -1;
}

int gcd(int u, int v)
{
    return (v != 0) ? gcd(v, u % v) : u;
}

int cdig(int b)
{
    int a=b;
    int count=0;
    while(a)
    {
        a=a/10;
        count++;
    }
    return count;
}

int dig_sum(int a)
{
    int b,sum=0;
    while(a)
    {
        sum=sum+a%10;
        a=a/10;
    }
    return sum;
}

int abs(int a)
{
    if(a<0)
    {
        a=a*(-1);
        return a;
    }
    return a;
}

int ar_to_num(int ar[],int n)
{
    int sum=0;
    for(int i=0,j=n-1; i<n; i++,j--)
    {
        sum=sum+(ar[i]*pow(10,j));
    }
    return sum;
}

int pow(int a,int n)
{
    if(n==0)
        return 1;
    int b=1;
    for(int i=0; i<n; i++)
        b*=a;
    return b;
}
void get_ar(int a,int ar[])
{
    for(int i=0; i<a; i++)
        cin>>ar[i];
}

int main()
{
    int a,b;
    cin>>a>>b;
    int c=min(a,b);
    int d=max(a,b);
    for(int i=c;i<=d;i++)
    {
        if((a*b*i)%2!=0)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0:
        break
    a = sorted(list(map(int, input().split())))
    ans = 1000001
    for i in range(n - 1):
        j = a[i + 1] - a[i]
        if j < ans:
            ans = j
    print(ans)

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

  const int MOD = 1000000007;

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

  //for
  #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }






  int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    int sum = 0; 
    REP(i, N) {
      cin >> a[i];
      sum += a[i];
    }

    int d = 100000;
    int ans;
    REP(i, N){
      if(d > abs(sum - a[i] * N)){
        d = abs(sum - a[i] * N);
        ans = i;
      }
    }
  print(ans);
  }




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

int digit(long long v) {
  int d = 1;
  while ((v /= 10) != 0) {
    d++;
  }
  return d;
}

int main() {
  long long n;
  scanf("%lld", &n);
  int ans = 12;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ans = min(max(digit(i), digit(n / i)), ans);
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(s, i, n) for (i = s; i < n; i++)
using namespace std;

int ans, N, A[200001];
int a[1000001];
bool f[1000001];


int main()
{
    int b,i, j,m;
    cin >> N;

    rep(1,i, N+1){
        cin >>A[i];
        a[A[i]]++;
        m=max(m,A[i]);
    }
    rep(1,i,N+1){
        if(a[A[i]]>1) f[A[i]]=true;
        for(j=A[i]*2;j<m+1;j+=A[i])
            f[j]=true;
    }
    
    rep(1,i, N+1)
    {
        if(!f[A[i]])ans++;
    }

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

Measured memory_bytes: 9088
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApplication2
{
    class Program
    {
        class GhostClass
        {
            string Name;
            int Morning;
            int Aftefnoon;

            public GhostClass(string[] input)
            {
                Name = input[0];
                Morning = int.Parse(input[1]);
                Aftefnoon = int.Parse(input[2]);
            }

            public void Disp()
            {
                Console.WriteLine("{0} {1} {2}", Name, Morning + Aftefnoon, Morning * 200 + Aftefnoon * 300);
            }
        }

        static void Main(string[] args)
        {
           
            List<GhostClass> list = new List<GhostClass>();
            string input;
            while ((input = Console.ReadLine()) != null)
            {
               list.Add(new GhostClass(input.Split(' ')));
            }

            list.ForEach(s => s.Disp());

        }
    }
}

Measured memory_bytes: 5708
#ifdef LOCAL_BUILD
#include "pch.h"
#define DLOG(msg) cout << "#" << __LINE__ << ":" << msg << endl;
#else
#include <bits/stdc++.h>
#define DLOG(msg)
#endif
using namespace std;

template <typename T>
struct LinkedList {
  void Insert(T x) {
    if (!tail_) {
      tail_.reset(new Cell(x));
      head_ = tail_.get();
    } else {
      head_->prev.reset(new Cell(x));
      head_->prev->next = head_;
      head_ = head_->prev.get();
    }
  }
  void Delete(T x) {
    for (Cell* cell = head_; cell; cell = cell->next) {
      if (cell->value == x) {
        if (cell->prev) {
          cell->prev->next = cell->next;
        } else {
          head_ = cell->next;
        }
        if (cell->next) {
          cell->next->prev.reset(cell->prev.release());
        } else {
          tail_.reset(cell->prev.release());
        }
        return;
      }
    }
  }
  void DeleteFirst() {
    head_ = head_->next;
    if (head_) {
      head_->prev.reset();
    } else {
      tail_.reset();
    }
  }
  void DeleteLast() {
    tail_.reset(tail_->prev.release());
    if (tail_) {
      tail_->next = nullptr;
    } else {
      head_ = nullptr;
    }
  }
  void print() const {
    bool first = true;
    for (Cell* cell = head_; cell; cell = cell->next) {
      if (!first) {
        cout << " ";
      }
      first = false;
      cout << cell->value;
    }
    if (!first) {
      cout << endl;
    }
  }

 private:
  struct Cell {
    explicit Cell(T val) : value(val) {}
    Cell* next = nullptr;
    unique_ptr<Cell> prev;
    T value;
  };

  Cell* head_ = nullptr;
  unique_ptr<Cell> tail_;
};

int main() {
  int n;
  cin >> n;
  string op;
  int operand;
  LinkedList<int> ll;
  for (int i = 0; i < n; ++i) {
    cin >> op;
    if (!op.compare("insert")) {
      cin >> operand;
      ll.Insert(operand);
    } else if (!op.compare("delete")) {
      cin >> operand;
      ll.Delete(operand);
    } else if (!op.compare("deleteFirst")) {
      ll.DeleteFirst();
    } else if (!op.compare("deleteLast")) {
      ll.DeleteLast();
    }
  }
  ll.print();
}

Measured memory_bytes: 36132
N = int(input())

from collections import deque,defaultdict
G = defaultdict(deque)
for i in range(1,N+1):
    t = [int(i) for i in input().split(' ')]
    for j in range(t[1]):
        G[t[0]].append(t[j+2])

time = 1
arrive_time = [-1] * (N + 1) # 到着時刻
finish_time = [-1] * (N + 1) # 到着時刻

def dfs(G,s):
    global time
    stack = deque([s])
    arrive_time[s] = time
    while stack:
        t = stack[-1]
        if G[t]:
            w = G[t].popleft()
            if arrive_time[w] >= 0:
                continue
            elif w in stack:
                continue
            else:
                time += 1
                arrive_time[w] = time
                stack.append(w)
        else:
            time += 1
            finish_time[t] = time
            stack.pop()
            
    return arrive_time,finish_time

for i in range(1,N+1):
    if arrive_time[i] < 0:
        arrive,finish = dfs(G,i)
        time += 1

for i, (a, f) in enumerate(zip(arrive,finish)):
    if not i == 0:
        print(i,a,f)


Measured memory_bytes: 6088
N, x = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)
answer = 0

for i, a in enumerate(A):
    if a > x:
        print(answer)
        exit()
    if i == N-1:
        if a != x:
            print(answer)
        else:
            answer += 1
            print(answer)
    else:
        x -= a
        answer += 1

Measured memory_bytes: 3060
// https://atcoder.jp/contests/abc065/tasks/arc076_b

#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <queue>
using namespace std;
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const int MAX = 100010;
static const ll INFTY = 1e18;

ll gcd(ll a, ll b){
    if(b == 0)return a;
    if(b > a) swap(a, b);
    gcd( b, a % b );
}

ll lcd(ll a, ll b){
    if(b > a) swap(a, b);
    ll tmp = a / gcd(a, b);
    return tmp * b; 
}


bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum+1; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {

    vector<int> PrimeNum(100010, 0);
    int Q;
    cin >> Q;
    vector<int> l(Q), r(Q);
    REP(i, Q){
        cin >> l[i] >> r[i];
    }

    for(int i = 100000; i >= 2; i--){
        if( i % 2 == 0) {
            PrimeNum[i] = PrimeNum[i+1];    
        } else{
            if(IsPrime(i) && IsPrime((i+1)/2)){
                PrimeNum[i] = PrimeNum[i+1]+1;
            }else {
                PrimeNum[i] = PrimeNum[i+1];
            }
        }
    }
    PrimeNum[0] = PrimeNum[1] = PrimeNum[2];
    REP(i, Q){
        cout << PrimeNum[l[i]] - PrimeNum[r[i]+1] << endl;
    }

    
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] grid = new String[n];
		for (int i=0;i<n;i++) {
			grid[i] = sc.next();
		}

		int ans = 0;
		for (int i=0;i<n;i++) {
			boolean sym = true;
			for (int j=0;j<n;j++) {
				for(int k=0;k<n;k++) {
					if (grid[j].charAt((k+i)%n) != grid[k].charAt((j+i)%n)) {
						sym=false;
					}
				}
			}
			if(sym) {
				ans += n;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 26800
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9

int main() {
	int a, b;
	cin >> a >> b;
	if (abs(a - b) % 2 == 0) {
		cout << max(a,b) - (abs(a - b) / 2) << endl;
	}
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 256
/* AOJ 0515 School Road */

#include <iostream>
#include <cstring>

using namespace std;

const int MAX_A = 16;
const int MAX_B = 16;

int n_routes[MAX_A + 1][MAX_B + 1];
bool closed[MAX_A + 1][MAX_B + 1];

int a, b;

void setup();
void solve();

int
main()
{
    for (;;) {
        cin >> a >> b;
        if (a == 0 && b == 0) break;

        setup();
        solve();
    }

    return 0;
}

void
setup()
{
    int n_closed;

    memset(n_routes, 0, sizeof n_routes);
    memset(closed, 0, sizeof closed);

    cin >> n_closed;
    while (n_closed--) {
        int i, j;

        cin >> i >> j;
        closed[i][j] = true;
    }
}

void
solve()
{
    int i, j;

    for (i = 1; i <= a; i++) {
        for (j = 1; j <= b; j++) {
            if (i == 1 && j == 1) {
                n_routes[i][j] = 1;
                continue;
            }

            if (closed[i][j]) continue;

            n_routes[i][j] = n_routes[i - 1][j] + n_routes[i][j - 1];
        }
    }

    cout << n_routes[a][b] << endl;
}

Measured memory_bytes: 1160
using System;

namespace abc045_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int h = int.Parse(Console.ReadLine());
            Console.WriteLine((a+b)*h/2);
            Console.ReadLine();
        }
    }
}

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

int gcd(int x, int y){
    if(y==0)
        return x;
    return gcd(y, x%y);
}

int main(){
    int n;scanf("%d", &n);
    vector<int> a(n);
    for(int i=0;i<n;i++)
        scanf("%d", &a[i]);
    vector<int> l(n),r(n);
    for(int i=0;i<n-1;i++)
        l[i+1]=gcd(a[i], l[i]);
    for(int i=n-1;i>0;i--)
        r[i-1]=gcd(a[i], r[i]);
    int ans=1;
    for(int i=0;i<n;i++){
        int tmp=gcd(l[i],r[i]);
        ans=max(ans,tmp);
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 1408
def main():
	s = input()
	ans = ''
	ans = solve(s[0], s[1:])
	print(ans)

def solve(left, right):
	if len(right) == 0:
		if eval(left) == 7:
			print(left + '=7')
			exit()
	else:
		solve(left + '-' + right[0], right[1:])
		solve(left + '+' + right[0], right[1:])

if __name__ == '__main__':
	main()

Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
    int a, b;
    scanf("%d%d", &a, &b);
    int ans = 0;
    if(a > b) ans = 2 * a - 1;
    else if(a == b) ans = a + b;
    else ans = 2 * b - 1;
    printf("%d\n", ans);
    return 0; 
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#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 pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N; cin >> N;
  int u, v; cin >> u >> v; u--; v--;
  vector<vector<int>> t(N);
  int a, b;
  int ans = 0;
  rep(i,N-1){
    cin >> a >>  b;
    a--; b--;
    t[a].pb(b);
    t[b].pb(a);
  }
  vector<int> du(N, -1);
  vector<int> dv(N, -1);

  queue<int> qu, qv;
  qu.push(u); du[u]=0;
  while(!qu.empty()){
    int now = qu.front(); qu.pop();
    rep(i, (int)t[now].size()){
      if(du[t[now][i]]>=0) continue;
      qu.push(t[now][i]);
      du[t[now][i]]=du[now]+1;
    }
  }
  qv.push(v); dv[v]=0;
  while(!qv.empty()){
    int now = qv.front(); qv.pop();
    rep(i, (int)t[now].size()){
      if(dv[t[now][i]]>=0) continue;
      qv.push(t[now][i]);
      dv[t[now][i]]=dv[now]+1;
    }
  }
  vector<int> yuyo(N);
  rep(i,N){
    yuyo[i] = dv[i]-du[i];
  }
  rep(i,N){
    if(yuyo[i]>0)
    ans = max(ans, yuyo[i]-1+du[i]);
  }

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


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

int main(){
    int N;
    int dummy;
    cin >> N;
    
    map<int, int> A;
    for(int i=1;i<N+1;i++){
        cin >> dummy;
        A[dummy] = i;
    }
    map<int, int>::iterator it;
    for(int i=1;i<N+1;i++){
        it = A.find(i);
        if(i != N) cout << it->second <<" ";
        else cout <<it->second <<endl;
    }
    return 0;
}

Measured memory_bytes: 5504
#include<cstdio>
#include<cmath>

int main()
{
	double x1, y1, x2, y2, xq, yq;
	while( scanf( "%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq ) != EOF )
	{
		double ang = ( std::atan2( yq - y1, xq - x1 ) - std::atan2( y2 - y1, x2 - x1 ) ) * -2.0;
		double x, y, tx = xq - x1, ty = yq - y1;
		x = tx * std::cos( ang ) - ty * std::sin( ang ) + x1;
		y = ty * std::cos( ang ) + tx * std::sin( ang ) + y1;

		printf( "%.4f %.4f\n", x, y );
	}

	return 0;
}

Measured memory_bytes: 1144
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

int main() {
	for (;;) {
		int H, W; cin >> H >> W;
		if (H == 0 && W == 0) break;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++)
				cout << ((i + j) % 2 ? '.' : '#');
			cout << endl;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1152
#pragma GCC optimize("trapv")
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10, I = 1e9 * 1e9;
const ld EPS = 1e-9 * 1e-2;

ll dp[3000][100];

int main()
{
	fastInp;

	ll n;
	cin >> n;

	pair<ll, ll> pr = { 0, 0 };
	for (int i = 0; i < n; i++) {
		ll t, a;
		cin >> t >> a;

		ll l = 0, r = INF;
		while (r - l > 1) {
			ll mid = (l + r) / 2;
			if (INT64_MAX / mid <= max(a, t)) {
				r = mid;
				continue;
			}
			if (t * mid >= pr.first && a * mid >= pr.second) {
				r = mid;
			}
			else {
				l = mid;
			}
		}

		pr = { t * r, a * r };
	}

	cout << pr.first + pr.second;
	return 0;
}

Measured memory_bytes: 3632
from math import sqrt

N = 10 ** 6

p = [True] * (N + 1)
p[0] = False
p[1] = False
n = int(sqrt(N) + 1)
for j in range(4, N + 1, 2):
  p[j] = False
for i in range(3, n + 1, 2):
  if p[i]:
    for j in range(i + i, N + 1, i):
      p[j] = False


X = int(input())
for i in range(X, N + 1):
    if p[i]:
        print(i)
        break

Measured memory_bytes: 10868
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string t; cin>>t;
  for(int i=0;i<t.size();i++){
    if(t.at(i)=='?'){
      cout<<"D";
    }else{
      cout<<t.at(i);
    }
  }
  cout<<endl;
}

Measured memory_bytes: 3732
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int N;
int P[50];


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

  cin >> N;
  int a;
  int cnt = 0;
  rep(i, N){
    cin >> a;
    a--;
    if (i!=a) cnt++;
  }

  if (cnt<=2) cout << "YES"<< endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
x, y, u, v = map(int, input().split())
x=u-x
y=v-y

ans  = "L"+"U"*(y+1)+"R"*(x+1)+"D"
ans += "L"*x+"D"*y
ans += "R"*x+"U"*y
ans += "R" + "D"*(y+1)+"L"*(x+1)+"U"
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int N;
	long long ans;
	scanf("%d", &N);
	long long *A;
	long long prev;

	A = malloc((1 + N) * sizeof(long long));
	ans = 0;
	scanf("%lld", &A[1]);
	prev = A[1];
	for (int i = 2; i <= N; i++) {
		scanf("%lld", &A[i]);
		if (A[i] < prev)
			ans += prev - A[i];
		else
			prev = A[i];
	}
	printf("%lld\n", ans);
	return (0);
}


Measured memory_bytes: 3268
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int size = 0;
        int[] al = new int[200000];
        for(int i = 2; i < 200000; i++){
        	boolean flg = true;
        	for(int j = 0; j < size; j++){
        		if(i % al[j] == 0){
        			flg = false;
        			break;
        		}
        	}
        	if(flg){
        		al[size] = i;
        		size++;
        	}
        }
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int p = sc.nextInt();
        while(n != -1 || p != -1){
            ArrayList<Integer> addlist = new ArrayList<Integer>();
            int idx = 0;
            for(int i = 0; i < al.length; i++){
                if(al[i] > n){
                    idx = i;
                    break;
                }
            }
           for(int i = idx; i < idx + p; i++){
                for(int j = i; j < idx + p; j++){
                    addlist.add(al[i] + al[j]);
                }
            }
            Collections.sort(addlist);
            System.out.println(addlist.get(p - 1));
            n = sc.nextInt();
            p = sc.nextInt();
        }
        sc.close();
    }
 
}

Measured memory_bytes: 66992
s = input()
t = input()
l = []
i = 0
while i < len(s) - len(t) + 1:
    for j in range(len(t)):
        if s[i+j] == "?" or s[i+j] == t[j]:
            if j == len(t) - 1:
                l.append(i)
                i += 1
            else: continue
        else:
            i += 1
            break
if not l: print("UNRESTORABLE")
else:
    idx = max(l)
    ans = list(s)
    for i in range(len(s)):
        if ans[i] == "?": ans[i] = "a"
    for i in range(len(t)):
        ans[idx+i] = t[i]
    print("".join(ans))

Measured memory_bytes: 3064
import java.util.Scanner;

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


		long[] A = new long[N];
		for (int i = 0; i < N; i++) {
			A[i] =  sc.nextLong();
			if(A[i] == 0) {
				System.out.println(0);
				return;
			}
		}

		long SUM = 1l;

		for (long I: A) {
			if (1000000000000000000L / I >= SUM) {
				SUM *= I;
			} else {
				System.out.println(-1);
				return;
			}
		}


		System.out.println(SUM);
		sc.close();
	}
}

Measured memory_bytes: 61384
from collections import deque
import sys
input = sys.stdin.readline

N, M = map(int, input().split())

G = [[] for _ in range(N + 1)]

for _ in range(M):
    l, r, d = map(int, input().split())
    G[l].append((r, -d))
    G[r].append((l, d))


MIN = -10 ** 18

lst = [MIN] * (N + 1)

que = deque()

for i in range(1, N + 1):
    if lst[i] == MIN:
        que.append(i)
        lst[i] = 0

    while que:
        tmp = que.popleft()
        for next_, d in G[tmp]:
            if lst[next_] == MIN:
                lst[next_] = lst[tmp] + d
                que.append(next_)
                continue
            
            if lst[next_] == lst[tmp] + d:
                continue
            else:
                print ('No')
                exit()

print ('Yes')


Measured memory_bytes: 66296
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		int sum=0;
		int a = sc.nextInt();
		for(int b=100;b>=1;b/=10) {
			if(a/b==1) {
			  sum+=1;
			  a=a-b*(a/b);
			}
		}
		System.out.printf("%d\n",sum);
		
		}
	}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    bool chk = false;
    while(n>0){
        if(n%10==7)chk = true;
        n/=10;
    }
    if(chk)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

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

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

int N,K,A,B,C;
string ans="Yes";

int main() {
    cin >> N;

    bool f=false;
    for(int i=1; i<10; i++){
        for(int j=1; j<10; j++){
            if(i*j == N){
                f=true;
            }
        }
    }

    if(!f) ans="No";

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

Measured memory_bytes: 888
import java.io.*;
import java.util.*;


/**
 * AIZU ONLINE JUDGE
 * 1042
 *  2020/5/10
 */
public class Main {

    PrintStream log = new PrintStream(new OutputStream() { public void write(int b) {} } );
    PrintStream result = System.out;
    Scanner sc = new Scanner(System.in);

    void main() throws IOException {

        for(;;) {
            String s = sc.nextLine();
            if (s.equals("END OF INPUT"))
                break;
            String r = "";
            int cnt = 0;
            for(int i = 0; i < s.length() + 1; i++) {
                if (i >= s.length() || s.charAt(i) == ' ') {
                    r += cnt;
                    cnt = 0;
                }
                else
                    cnt++;
            }
            result.println(r);
        }
    }

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


}




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

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		int x, y, b, p;
		cin >> x >> y >> b >> p;
		if(b >= 5 && p >= 2){
			cout << int(float((b * x + p * y)) * 0.8f) << endl;
		}else{
			int total = b * x + p * y;
			if(b < 5){
				b = 5;
			}
			if(p < 2){
				p = 2;
			}
			int _total = int(float(b * x + p * y) * 0.8f);
			cout << (total <= _total ? total : _total) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3064
a = []
for i in range(3):
         a.append( list(map(int,input().split())))
n = int(input())
b = [int(input()) for j in range(n)]
for k in range(3):
         for l in range(3):
                  for m in range(n):
                           if a[k][l] == b[m]:
                                    a[k][l] = -1
if a[0][0] == a[0][1] == a[0][2] == -1 or  a[1][0] == a[1][1] == a[1][2] == -1 or  a[2][0] == a[2][1] == a[2][2] == -1 or  a[0][0] == a[1][0] == a[2][0] == -1 or  a[0][1] == a[1][1] == a[2][1] == -1 or  a[0][2] == a[1][2] == a[2][2] == -1 or  a[0][0] == a[1][1] == a[2][2] == -1 or  a[0][2] == a[1][1] == a[2][0] == -1 :
         print("Yes")
else:
         print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}



  








      

 
  int main() {
  string s;
  cin>>s;
  int bcount = 0;
  ll res = 0;
  for (int i = 0;i < s.size();i++){
    if (s[i]=='W'){
      res += bcount;
    }
    else {
      bcount++;
    }
  }
  cout << res << endl;

}




Measured memory_bytes: 3740
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define pb push_back
#define f first
#define s second
#define double long double
const int MAX=2e5+5;
const int MAX2=2e5+4;
const int MAAX=1e10;
const int MOD=1e9+7;
in main()
{
    string s;
    cin>>s;
    if(s[3]==s[2]&&s[4]==s[5])
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
 return 0;
}


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


int main(void) {
  int n;
  cin >> n;
  int a[n];
  int minuCnt = 0;
  rep (i, n) {
    cin >> a[i];
    if (a[i] < 0) minuCnt++;
    a[i] = abs(a[i]);
  }

  sort(a, a + n);

  ll ans = 0;
  rep (i, n) {
    ans += a[i];
  }
  
  cout << (minuCnt % 2 == 0 ? ans : ans - a[0] * 2) << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  ll ans = 0;
  ll x = 0;
  for (int i = 0; i < 40; ++i) {
    int cnt = 0;
    for (int j = 0; j < n; ++j) {
      if ((a[j] >> 1ll * (39 - i)) & 1) {
        cnt++;
      }
    }
    if (n - cnt <= cnt) {
      ans += (1ll << (39 - i)) * cnt;
    } else {
      if (x + (1ll << (39 - i)) <= k) {
        ans += (1ll << (39 - i)) * (n - cnt);
        x += (1ll << (39 - i));
      } else {
        ans += (1ll << (39 - i)) * cnt;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
if __name__ == '__main__':
	S = input()
	s_len = len(S)

	tmp = 753-int(S[0])
	for x in range(s_len):
		if x+3 <= s_len:
			tmp = min(tmp,abs(753 - int(S[x:x+3])))
	print(tmp)


Measured memory_bytes: 9168
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
using namespace std;
using ll = long long;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> d(k);
  for(int i = 0; i < k; i++){
    cin >> d[i];
  }
  string nstr;
  while(true){
    nstr = to_string(n);
    //cout << nstr << "," << nstr.size() << endl;
    n++;
    bool check = true;
    for(int i = 0; i < nstr.size(); i++){
      for(int j = 0; j < d.size(); j++){
        //cout <<stoi(nstr.substr(i,1)) << "," <<  d[j] << "   " << i << "/" << nstr.size() << endl;
        if(stoi(nstr.substr(i,1)) == d[j]){
          check = false;
          break;
        }
      }
    }
    if(check){
      break;
    }
  }
  cout << nstr << endl;
  return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=2e5+10;
int gcd(int n,int m)
{
    if(n==0)
        return m;
    else
        return gcd(m%n,n);
}
int32_t main()
{
    IOS;
    int n,k,s;
    cin>>n>>k>>s;
    if(s==1000000000)
    {
        for(int i=1;i<=k;i++)
    {
        cout<<s<<" ";
    }
    for(int i=k+1;i<=n;i++)
    {
        cout<<s-1<<" ";
    }
    cout<<endl;
    }
    else if(s==1)
    {
        for(int i=1;i<=k;i++)
    {
        cout<<s<<" ";
    }
    for(int i=k+1;i<=n;i++)
    {
        cout<<s+1<<" ";
    }
    cout<<endl;
    }
    else
    {
        for(int i=1;i<=k;i++)
    {
        cout<<s<<" ";
    }
    for(int i=k+1;i<=n;i++)
    {
        cout<<s+1<<" ";
    }
    cout<<endl;
    }
    
    


}

Measured memory_bytes: 1280
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
 	public static void main(String[] args) {  
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		long[] a = new long[N];
		long mod = (long)(1e9)+7;
		long sum = 0;
		long ans = 0;
		for (int i = 0; i < N; i++) {
			a[i] = I.nextLong();
			sum+=a[i];
		}
		sum%=mod;
		for (int i = 0; i < N; i++) {
			sum-=a[i];
			sum%=mod;
			if (sum<0) sum+=mod;
			ans+=sum*a[i];
			ans%=mod;
		}
		O.pln(ans);
	}
	public static double max(double a, double b) {return Math.max(a, b);}
	public static double min(double a, double b) {return Math.min(a, b);}
	public static long min(long a, long b) {return Math.min(a,b);}
	public static long max(long a, long b) {return Math.max(a,b);}
	public static int min(int a, int b) {return Math.min(a,b);}
	public static int max(int a, int b) {return Math.max(a,b);}
	public static long abs(long x, long y) {return Math.abs(x-y);}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return max(a,b);
		return GCD(min(a,b),max(a,b)%min(a,b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}


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

string S; int N, cnt;

int main() {
	cin >> N >> S;
	for (int i = 0; i < 1000; i++) {
		int c[3] = {i / 100, (i / 10) % 10, i % 10};
		int f = 0;
		for (int j = 0; j < N; j++) {
			if (S[j] == ('0' + c[f])) f++;
			if (f == 3) break;
		}
		if (f == 3) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

ll N, M, AI, BI, CI, par[100005], sz[100005];

ll findset(ll x) {
	if (par[x] == x) return x;
	else return par[x] = findset(par[x]);
}

bool sameset(ll x, ll y) {
	return findset(x) == findset(y);
}

void mergeset(ll x, ll y) {
	x = findset(x), y = findset(y);
	if (x == y) return;
	if (sz[x] > sz[y]) {
		par[y] = x;
		sz[x] += sz[y];
	}
	else {
		par[x] = y;
		sz[y] += sz[x];
	}
}

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

	cin >> N >> M;
	ll cnt = N;
	for (ll i = 0; i < 100005; i++) {
		par[i] = i;
		sz[i] = 1;
	}
	for (ll i = 0; i < M; i++) {
		cin >> AI >> BI >> CI;
		if (!sameset(AI, BI)) {
			mergeset(AI, BI);
			cnt--;
		}
	}

	cout << cnt << "\n";

}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n = 5;
  vector<int> time(n);
  rep(i,n) cin >> time[i];
  vector<int> N_time(n);
  
  rep(i,n){
    if(time[i]%10==0) N_time[i] = time[i];
    else N_time[i] = time[i]-time[i]%10+10;
  }

  int ans = INF;
  rep(i,n){
    int tmp = 0;
    rep(j,n){
      if(j!=i) tmp+=N_time[j];
    }
    tmp+=time[i];
    ans = min(ans,tmp);
  }

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


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

void calculate(){
    int N;
    cin >> N;
    for(int i = 1;i <= 9;++i){
        for(int j = i;j <= 9;++j){
            if(i * j == N)
            {
                cout << "Yes\n";
                return;
            }
        }
    }
    cout << "No\n";
}

int main(int, char**) {
    calculate();
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
n = int(input())
li = []
for i in range(n):
    xi,yi = map(int,input().split())
    li.append((xi,yi))
if n == 1:
    print(1)
    exit()
dic = defaultdict(int)
for i in range(n):
    for j in range(n):
        if i != j:
            xi = li[i][0]
            yi = li[i][1]
            xj = li[j][0]
            yj = li[j][1]
            dic[(xi-xj,yi-yj)] += 1
print(n-max(dic.values()))

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <vector>
using namespace std;
 typedef long long int ll;

int main(){
    string S;
    cin >> S;
    ll ans=0,black=0;
   for(int i=0;i<S.length();i++)
   {if(S[i]=='B'){black++;}else{ans+=black;}
   }
   cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(){
    char S[30];
    gets(S);
    int len=strlen(S);
    int a=0;
    for(int i=0;i<len;i++){
        for(int j=i+1;j<len;j++)
             if(S[i]==S[j]) {a++;break;}
        if(a==1) break;        
    }
    if(a==0) printf("yes");
    else printf("no");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#define pi 3.14159265358979323846
using namespace std;
int main()
{
	double a;
	cin >> a;
	cout << fixed;
	setprecision(6);
	cout << a*a*pi << ' ' << 2 * a*pi << endl;
	return 0;
}

Measured memory_bytes: 1284
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int n;
int s[400][400];

int jdg(int n){
    int k1 = floor(sqrt(n));
    return k1*(k1+1)==n;
}

int main() {
    cin >> n;
    n*=2;
    if(!jdg(n)){
        put("No");
        return 0;
    }else{
        put("Yes");
        int k = floor(sqrt(n))+1;
        vector<int> b(k);
        b[0] = k-1;
        REP(i,k-1){
            b[i+1] = b[i]+i-2;
        }
        vector<vector<int>> sc(k);
        int cnt = 1;
        REP(i,k-1){
            REP(j,k-1-i){
                sc[i].push_back(cnt);
                sc[i+j+1].push_back(cnt);
                cnt++;
            }
        }
        /*REP(i,n){
            auto itr = lower_bound(all(b),i+1);
            int  d = itr - b.begin();
            s[d][cnt++] =
            
        }*/
        //vector<vector<int>> s(k);
        put(k);
        REP(i,k){
            cout << k-1 << " ";
            REP(j,k-1){
                cout << sc[i][j] << " ";
        }
        put("");
    }
    
        
    }
    return 0;
}



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

#define bug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << " = " << a << ' ' ;err(++it, args...);}





int main(){

    int k,n,inx=0;

    cin>>k>>n;

    long long d=0,dmax=0;

    long long a[n+1];

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

    for(int i=1;i<n;i++){

    d+=(a[i]-a[i-1]);

    dmax=max(a[i]-a[i-1],dmax);
    }
    if(k-a[n-1]+a[0]<dmax){
        d+=(k-a[n-1]+a[0]),d-=dmax;
        //bug(k-a[n-1],d,dmax)
    }
    cout<<d<<endl;
}


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

int main() {
	using std::cerr;
	std::ios_base::sync_with_stdio(false), std::cin.tie(nullptr);

	int N; std::cin >> N;
	std::vector<int64_t> A(N); for (auto& a : A) std::cin >> a;
	std::vector<int64_t> B(N); for (auto& b : B) std::cin >> b;

	{
		int z = int(std::max_element(A.begin(), A.end()) - A.begin());
		std::rotate(A.begin(), A.begin()+z, A.end());
		std::rotate(B.begin(), B.begin()+z, B.end());
	}

	A.push_back(A[0]);

	std::vector<int64_t> C(N+1);
	for (int i = 1; i <= N-1; i++) {
		C[i+1] = 2 * (C[i] + B[i]) - C[i-1];
	}

	double ans = 0;
	std::vector<std::pair<int, int64_t>> hull;
	for (int i = 0; i <= N; i++) {
		int64_t v = A[i] - C[i];
		while (hull.size() >= 2 &&
				(hull[hull.size()-1].second - hull[hull.size()-2].second) * (i - hull[hull.size()-2].first)
				<= (v - hull[hull.size()-2].second) * (hull[hull.size()-1].first - hull[hull.size()-2].first)) {
			hull.pop_back();
		}
		hull.emplace_back(i, v);
	}
	for (int z = 1; z < int(hull.size()); z++) {
		auto [i, v0] = hull[z-1];
		auto [j, v1] = hull[z];
		for (int k = i+1; k <= j-1; k++) {
			ans += double(v0 * (j - k) + v1 * (k - i)) / (j - i) + C[k];
		}
		ans += v1 + C[j];
	}
	ans /= N;
	std::cout << std::fixed << std::setprecision(20) << ans << '\n';

	return 0;
}


Measured memory_bytes: 14064
n, x = map(int, input().split())
p = [1] * n
c = [1] * n
for i in range(1, n):
    p[i] = 2 * p[i - 1] + 1
    c[i] = 2 * c[i - 1] + 3


def f(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= c[N - 1] + 1:
        return f(N - 1, X - 1)
    else:
        return f(N - 1, X - c[N - 1] - 2) + p[N - 1] + 1


ans = f(n, x)
print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys


def solve(S: str, T: str):
    count = 0
    for i in range(len(S)):
        if S[i] == T[i]:
            count += 1
        else:
            pass
    print(count)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N, M;
    cin >> N >> M;
    int ans = N * (N - 1) / 2 + M * (M - 1) / 2;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <tuple>
typedef long long int ll;
using namespace std;
int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a;
    vector<ll> b;
    vector<ll> c;
    for (int i = 1; i <= x; i++) {
        ll p;
        cin >> p;
        a.push_back(p);
    }
    for (int i = 1; i <= y; i++) {
        ll n;
        cin >> n;
        b.push_back(n);
    }
    for (int i = 1; i <= z; i++) {
        ll q;
        cin >> q;
        c.push_back(q);
    }
    vector<ll> ab;
    for (int i = 0; i < x; i++) {
        for (int j = 0; j < y; j++) {
            ab.push_back(a[i] + b[j]);
        }
    }
    sort(ab.begin(), ab.end());
    sort(c.begin(), c.end());
    vector<ll> res;
    int S = ab.size();
    int T = c.size();
    int s = min(k, S);
    int t = min(k, T);
    for (int i = 1; i <= s; i++) {
        for (int j = 1; j <= t; j++) {
            res.push_back(ab[ab.size() - i] + c[c.size() - j]);
        }
    }
    sort(res.begin(), res.end());
    for (int i = 1; i <= k; i++) {
        cout << res[res.size() - i] << endl;
    }
    return 0;
}

Measured memory_bytes: 44040
#include<iostream>
#include<utility>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<cstring>
#define nax 100005
#define mod 1000000007
#define ll long long int
using namespace std;
int main(){
  		int n=0;
  		string s;
		cin >>n ;
  		cin >> s;
		if(n>=3200){
			cout << s ;
		}
		else{
			cout << "red";
		}
		return 0;
	}

Measured memory_bytes: 256