akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    string s; cin >> s;
    rep(i, s.size()) {
        if (s[i] != '?') cout << s[i];
        else cout << 'D';
    }
    cout << endl;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X,A,B;
  cin >> X >> A >> B;
  if (B<=A){
    cout << "delicious" << endl;
  }
  else if (A<B&&B<=A+X){
    cout << "safe" << endl;
  }
  else {
    cout << "dangerous" << endl;
  }
          }

Measured memory_bytes: 256
package main

import (
    "bufio"
    "os"
    "strconv"
    "fmt"
    "container/heap"
)

const INF = 100000000000000


/*********** PriorityQueue ***********/
type PriorityQueue struct {
    arr []interface{}
    comp CompFunc
}

type CompFunc func(p, q interface{}) bool

func NewPriorityQueue() *PriorityQueue {
    return new(PriorityQueue)
}

func (pq PriorityQueue) Len() int {
    return len(pq.arr)
}

func (pq PriorityQueue) Swap(i, j int) {
    pq.arr[i], pq.arr[j] = pq.arr[j], pq.arr[i]
}

func (pq PriorityQueue) Less(i, j int) bool{
    return pq.comp(pq.arr[i], pq.arr[j])
}

func (pq *PriorityQueue) Push(x interface{}) {
    pq.arr = append(pq.arr, x)
}

func (pq *PriorityQueue) Pop() interface{} {
    n := pq.Len()
    item := pq.arr[n - 1]
    pq.arr = pq.arr[:n - 1]
    return item
}

func (pq *PriorityQueue) IsEmpty() bool {
    return pq.Len() == 0
}

/* type for edge */
type Edge struct {
    to int
    cost int
}

/* type for dijkstra */
type State struct {
    time int
    node int
}

/* dijkstra */

func dijkstra(start int, edges [][]Edge, n int, comp CompFunc) []int {
    var dist []int
    for i := 0; i < n; i++ {
        dist = append(dist, INF)
    }
    dist[start] = 0
    que := new(PriorityQueue)
    que.comp = comp
    heap.Push(que, State{time: 0, node:start})
    for !que.IsEmpty() {
        state := heap.Pop(que).(State)
        for _, edge := range edges[state.node] {
            newTime := state.time + edge.cost
            if dist[edge.to] > newTime {
                dist[edge.to] = newTime
                heap.Push(que, State{time: newTime, node: edge.to})
            }
        }
    }
    return dist
}
/* input */
var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
    sc.Scan()
    n, _ := strconv.Atoi(sc.Text())
    return n
}

func main() {
    sc.Split(bufio.ScanWords)
    n := readInt()
    var edges [][]Edge
    for i := 0; i < n; i++ {
        edges = append(edges, make([]Edge, 0))
    }
    for i := 0; i < n - 1; i++ {
        a, b, c := readInt() - 1, readInt() - 1, readInt()
        edges[a] = append(edges[a], Edge{to: b, cost: c})
        edges[b] = append(edges[b], Edge{to: a, cost: c})
    }

    var comp CompFunc
    comp = func(p, q interface{}) bool {
        return p.(State).time < q.(State).time
    }
    
    q, k := readInt(), readInt() - 1
    dist := dijkstra(k, edges, n, comp)
    for i := 0; i < q; i++ {
        x, y := readInt() - 1, readInt() - 1
        fmt.Println(dist[x] + dist[y])
    }
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ans = 0;
  if (a >= b) {
    ans += b;
  } else {
    ans += a;
  }
  if (c >= d) {
    ans += d;
  } else {
    ans += c;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	LL n,m;
	int i,j,k;
	LL a,b,c;
	cin>>n;
	for(a=-400;a<400;a++){
		for(b=-400;b<400;b++){
			if(a*a*a*a*a-b*b*b*b*b==n){
				cout<<a<<" "<<b<<endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  int k,b,c,d,e,f,g,h,j;
  k=0; b=0; c=0; d=0; e=0; f=0; g=0; h=0; j=0;
  for(int i=0;i<N;i++){
    if(a.at(i)<=399){k++;}
    if(400<=a.at(i) && a.at(i)<=799){b++;}
    if(800<=a.at(i) && a.at(i)<=1199){c++;}
    if(1200<=a.at(i) && a.at(i)<=1599){d++;}
    if(1600<=a.at(i) && a.at(i)<=1999){e++;}
    if(2000<=a.at(i) && a.at(i)<=2399){f++;}
    if(2400<=a.at(i) && a.at(i)<=2799){g++;}
    if(2800<=a.at(i) && a.at(i)<=3199){h++;}
    if(3200<=a.at(i)){j++;}
  }
  int A=0;
  if(k!=0){A++;}
  if(b!=0){A++;}
  if(c!=0){A++;}
  if(d!=0){A++;}
  if(e!=0){A++;}
  if(f!=0){A++;}
  if(g!=0){A++;}
  if(h!=0){A++;}
  if(A!=0){cout << A << " ";}
  else{cout << 1 << " ";}
  cout << j+A << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
arr = ['']*H
for i in range(H):
    arr[i] = input()
 
#print(arr)
dp = [[0]*W for _ in range(H)]

# arr =[
# ['.','.'],
# ['#','.'],
# ['.','.'],
# ['.','#'],
# ['.','.']
# ]








flag= False
#print(arr)
for h in range(H-1,-1,-1):
    #print(h,W-1)

    if arr[h][W-1]=='#':
        dp[h][W-1]=0
        flag =  True
    if flag:
        dp[h][W-1]=0
    else:
        dp[h][W-1]=1
#print(dp)
    
flag = False
for w in range(W-1,-1,-1):
    #print(h,W-1)
    if arr[H-1][w]=='#':
        dp[H-1][w]=0
        flag =  True
    if flag:
        dp[H-1][w]=0
    else:
        dp[H-1][w]=1


#print(dp)

MOD = 10**9+7

dp[H-1][W-1]=0

for row in range(H-1,0,-1):
    for col in range(W-1,0,-1):
        if arr[row-1][col-1]=='#':
            dp[row-1][col-1]=0
        elif dp[row][col-1] ==0 or dp[row-1][col]==0:
            dp[row-1][col-1] = max(dp[row][col-1],  dp[row-1][col])
            dp[row-1][col-1]%=MOD

        elif dp[row][col-1] > 0 and dp[row-1][col]>0:
            dp[row-1][col-1] = dp[row][col-1] +  dp[row-1][col]
            dp[row-1][col-1]%=MOD
        elif  dp[row][col-1] == 0 and dp[row-1][col] == 0:
            dp[row-1][col-1]==0


print(dp[0][0])



            
    


Measured memory_bytes: 43712
#include <iostream>
using namespace std;
int main() {
	int H, W;
	cin >> H >> W;
	int x = 0, y = 0;
	for (int i = 1; i <= H; i++) {
		for (int j = 0; j < W; j++) {
			string S;
			cin >> S;
			if (S == "snuke") {
				x = j;
				y = i;
			}
		}
	}
	cout << (char)('A' + x);
	cout << y << endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author indy256
 */

#include <bits/stdc++.h>

using namespace std;

void solve(istream &in, ostream &out) {
    int n;
    in >> n;
    string s;
    in >> s;

    vector<int> a1, a2, a3;
    set<int> s1, s2, s3;
    for (int i = 0; i < n; ++i) {
        int v = s[i] - '0';
        int v3 = 100 * v;
        for (auto x:s2) {
            int y = v3 + x;
            s3.emplace(y);
        }
        int v2 = 10 * v;
        for (auto x:s1) {
            int y = v2 + x;
            s2.emplace(y);
        }
        s1.emplace(v);
    }

    int res = s3.size();
    out << res << '\n';
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solve(in, out);
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef  long long ll;


int main(){
  int H, W;
  string s[50];
  int dx[4] = {1,-1, 0, 0};
  int dy[4] = {0,0,1,-1};
  cin >> H >> W;

  for(int i =0; i < H; i++){
    cin >> s[i];
  }

  for(int i = 0; i < H; i++){
    for(int j =0; j < W; j++){
      if(s[i][j]=='#'){
        int flag =0;
        for(int k=0; k <4; k++){
          if(i+dx[k]>=0 && j+dy[k]>=0 && i+dx[k]<H && j+dy[k]<W){
            if(s[i+dx[k]][j+dy[k]]=='#')
              flag =1;
          }
        }
        if(!flag){
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }

  cout << "Yes" <<endl;
  
  return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		long H = Long.parseLong(sc.next());
		long W = Long.parseLong(sc.next());
		long a = 0;
		long b = 0;
		int cnt=0;
		for(int i=0;i<n;i++) {
			a = Long.parseLong(sc.next());
			b = Long.parseLong(sc.next());
			if(a >= H && b>=W) {
				cnt++;
			}
		}

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

}


Measured memory_bytes: 25796
import sys
import heapq
import copy

n = int(input())
a = []

for _ in range(n):
	a.append(-1 * int(input()))

b = copy.deepcopy(a)
heapq.heapify(b)

for i in range(n):
	maximum = heapq.heappop(b)
	if maximum == a[i]:
		tmp = maximum
		maximum = heapq.heappop(b)
		print(maximum * (-1))
		heapq.heappush(b,tmp)
	else:
		print(maximum * (-1))
	heapq.heappush(b,maximum)


Measured memory_bytes: 124632
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    if(N == 3){
        cout << "2 5 63" << endl;
        return 0;
    }
    vector<int> v[4];
    rep(i,2,30001){
        if(i % 6 == 0)v[0].push_back(i);
        if(i % 6 == 2)v[1].push_back(i);
        if(i % 6 == 3)v[2].push_back(i);
        if(i % 6 == 4)v[3].push_back(i);
    }
    rep(i,0,4)reverse(v[i].begin(), v[i].end());
    vector<int> ans;
    rep(i,0,N/2){
        if(i % 2 == 0 && v[1].size() && v[3].size()){
            ans.push_back(v[1].back());
            ans.push_back(v[3].back());
            v[1].pop_back();
            v[3].pop_back();
        }
        if(i % 2 == 1 && v[2].size() >= 2){
            rep(j,0,2){
                ans.push_back(v[2].back());
                v[2].pop_back();
            }
        }
    }
    while(N != ans.size()){
        ans.push_back(v[0].back());
        v[0].pop_back();
    }
    rep(i,0,N)cout << ans[i] << " ";
}

Measured memory_bytes: 640
L=list(map(int,input().split()))

if(L[0] == L[1] or L[1] == L[2] or L[2] == L[0]):

    if(L[0] == L[1]):
        if(L[2] == L[0]):
            print("No")
            exit()
    print("Yes")
    exit()
print("No")
    


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//adds two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set]
//(2)set.order_of_key(k)[count of elements strictly less than k]
#define ll long long
#define ld long double
#define vv vector
#define pp pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
typedef pair<ll, ll> pll;
typedef vv<bool> vbool;
typedef vv<ll> vll;
typedef vv<ld> vld;
typedef vv<pll> vpll;
#ifdef LOCAL
#include "prettyprint.hpp"
#define LG(args...)                           \
{                                             \
	string _s = #args;                        \
	replace(_s.begin(), _s.end(), ',', ' ');  \
	stringstream _ss(_s);                     \
	err(istream_iterator<string>(_ss), args); \
	cerr << endl;                             \
}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "(" << *it << ":" << a << ") ";
	err(++it, args...);
}
#define fastio
#else
#define LG(...)
#define fastio                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);
#define endl "\n"
#endif
//:::::::::::::::::::::::::::::::::::::::::::::
const ll INF = 9e18;
const ll MOD = 1e9 + 7;

int main(){
	fastio;
	int x;
	cin>>x;
	cout<<1-x;
}

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

using A = int64_t;
int64_t x;
vector<A> rs;

struct Chart {
    vector<A> ch;
    vector<A> ch_min;
    vector<A> ch_max;
    bool bouncing;
    void init(A a, bool _bouncing) {
        ch = {a};
        ch_min = {a};
        ch_max = {a};
        bouncing = _bouncing;
    }
} ch_x, ch_0, ch_a;

int64_t min(int64_t a, int64_t b) { return a < b ? a : b; }
int64_t max(int64_t a, int64_t b) { return a > b ? a : b; }

void update_chart(Chart& ch, A rd) {
    if (ch.ch.size() % 2 == 1) {
        auto v = ch.ch.back() - rd;
        ch.ch.push_back(ch.bouncing ? max(0, v) : v);
    } else {
        auto v = ch.ch.back() + rd;
        ch.ch.push_back(ch.bouncing ? min(x, v) : v);
    }
    ch.ch_min.push_back(min(ch.ch_min.back(), ch.ch.back()));
    ch.ch_max.push_back(max(ch.ch_max.back(), ch.ch.back()));
}

void make_charts() {
    ch_0.init(0, true);
    ch_x.init(x, true);
    ch_a.init(0, false);
    for (size_t i = 1; i < rs.size(); i++) {
        update_chart(ch_0, rs[i] - rs[i-1]);
        update_chart(ch_a, rs[i] - rs[i-1]);
        update_chart(ch_x, rs[i] - rs[i-1]);
    }
}

A calc(A v1, A d, size_t ri) {
    if (ri % 2 == 0)
        return max(0, v1 - d);
    return min(x, v1 + d);
}

void go() {
    A k, q;
    cin >> x >> k;
    rs.push_back(0);
    while (k--) {
        A r;
        cin >> r;
        rs.push_back(r);
    }
    make_charts();
    cin >> q;
    while (q--) {
        A t, a;
        cin >> t >> a;
        const size_t ri = (upper_bound(rs.begin(), rs.end(), t) - rs.begin()) - 1u;
        if (ch_a.ch_min[ri] < -a) {
            cout << calc(ch_0.ch[ri], t - rs[ri], ri) << endl;
        } else if (ch_a.ch_max[ri] > x - a) {
            cout << calc(ch_x.ch[ri], t - rs[ri], ri) << endl;
        } else
            cout << calc(ch_a.ch[ri] + a, t - rs[ri], ri) << endl;
    }
}

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


Measured memory_bytes: 11548
A=list(input())
B=list(input())
C=list(input())
turn=A
win='A'
while True:
  if turn==[]:
    print(win)
    break
  next=turn.pop(0)
  if next=='a':
    turn=A
    win='A'
  elif next=='b':
    turn=B
    win='B'
  elif next=='c':
    turn=C
    win='C'

Measured memory_bytes: 3064
n, a, b = [int(x) for x in input().split()]

if a == 0 and b == 0:
    print("0")
elif a >= n:
    print(n)
else:
    x = n // (a + b)
    if x == 0:
        print(a)
    else:
        if (n - ((a + b) * x)) >= a:
            print(a * x + a)
        else:
            print((a * x + (n - (a + b) * x)))


Measured memory_bytes: 3060
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[] a=new int[5];
		a[0] = sc.nextInt();
		a[1] = sc.nextInt();
		a[2] = sc.nextInt();
		a[3] = sc.nextInt();
		a[4] = sc.nextInt();
		int k = sc.nextInt();
		boolean e=false;
		for(int i = 0; i<5; i++){
			for(int j = i+1; j<5; j++){
				if(!(Math.abs(a[i]-a[j])<=k)){
					System.out.println(":(");
					return;
				}
			}
		}
		System.out.println("Yay!");	
	}
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double dl;
#define lp1(i,n) for(int i=0;i<n;i++)
#define lp2(i,n) for(int i=1;i<=n;i++)
#define pi cosa(-1)
ll lcm(ll a,ll b)
{
    return a/__gcd(a,b)*b;
}
ll gcd(ll a,ll b)
{
	while(b ^= a ^= b ^= a = a % b);
	return a;
}
std::string s;
void cin_space()
{

    std::getline(std::cin, s);
}
void sortstring(string &str)
{
   sort(str.begin(), str.end());
}
bool check_prime(ll n)
{
    ll q=sqrt(n)+1;
    for(int i=2;i<q;i++)
        if(n%i==0)
            return 0;
    return 1;
}
ll ceil(ll n,ll k){
    return (n+k-1)/k;
}
#define i64 long long
i64 M;
i64 F(i64 N,i64 P)
{
	if(P==0) return 1;
	if(P%2==0)
	{
		i64 ret=F(N,P/2);
		return ((ret%M)*(ret%M))%M;
	}
	else return ((N%M)*(F(N,P-1)%M))%M;

}
ll m;
ll bigmod(ll n,ll p)
{
    if(p==0)
        return 1;
    if(p%2==0)
    {
        ll ret=bigmod(n,p/2);
        return ((ret*m)*(ret*m))%m;
    }
    else
        return ((n%m)*(bigmod(n,p-1)))%m;
}
void solution()
{

    double sum=0.0,x;
    string s,m,n="04",t="30",y;
    cin>>s;
    m+=s[5];
    m+=s[6];
    y+=s[8];
    y+=s[9];
    if(m<=n && y<=t)
        cout<<"Heisei"<<endl;
    else
        cout<<"TBD"<<endl;
}

int main()
{   /*ll t;
    cin>>t;
    while(t--){*/
        solution();
    //}

    return 0;
}


Measured memory_bytes: 3608
import java.util.*;

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

        int[] list=new int[N];
        
        long[] count=new long[N+1];
        
        for(int i=0;i<N;i++){
            int tmp=sc.nextInt();
            list[i]=tmp;
            count[tmp]++;
        }
        
        long ans=0L;
        
        for(int i=0;i<N+1;i++){
            ans+=(count[i]*(count[i]-1))/2;
        }
        
        for(int i=0;i<N;i++){
            long next=ans-(long)count[list[i]]+1;
            System.out.println(next);
        }
    }
}

Measured memory_bytes: 104052
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
#define P pair<int, int>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i = 1; i <= n; i++){
        int A;
        cin >> A;
        a[i] = A;
    }
    int f = 1, cnt = 0;
    int pre = 1;
    vector<int> C(n+1);
    C[1]++;
    while(true){
        //cout << f << " " << pre << endl;
        f = a[f];
        C[f]++;
        if(C[f] > 1){
            cout << -1 << endl;
            return 0;
        }
        if(pre == f) break;
        cnt++;
        pre = f;
        if(f == 2) break;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4028
from sys import stdin
INF = float("inf")#無限大の設定1
IINF = 10 ** 18#無限大の設定2
MOD = 10 ** 9 + 7#まれに用いるmodを予め設定しておく
n = (stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
#A, B, C = map(int, stdin.readline().rstrip().split())
#S = [list(stdin.buffer.readline().decode().rstrip()) for _ in range(h)]
S =['SUN','MON','TUE','WED','THU','FRI','SAT']
a = S.index(n)
print(len(S) - a)


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

const int MAX = 200000;

bool solve(vector<int> graph[], bool check[], int i, int n, int depth) {
	if (depth == 2)return false;
	check[i] = true;
	for (int j = 0; j < graph[i].size(); j++) {
		if (check[graph[i][j]])continue;
		if (graph[i][j] == n)return true;
		if (solve(graph, check, graph[i][j], n, depth + 1)) {
			return true;
		}
	}
	return false;
}

int main() {
	int N, M;
	bool check[MAX] = { false };
	vector<int> graph[MAX];

	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	if (solve(graph, check, 0, N - 1, 0)) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}

	return 0;
}

Measured memory_bytes: 12144
n, k = map(int, input().split())
alist = sorted(map(int, input().split()))
mod = 10**9 + 7

def comb(n, r, p=mod):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
p = mod
N = n
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

amax = 0
amin = 0
i = 0
while i <= n-k:
    cnt = comb(n-i-1, k-1)
    amax += (alist[n-i-1] * cnt)%mod
    amin += (alist[i] * cnt)%mod
    i += 1

print((amax - amin) % mod)

Measured memory_bytes: 20048
#include<bits/stdc++.h>
using namespace std;
#define mod                   1000000007
#define ll                    long long
#define Author                std::ios_base::sync_with_stdio(0);
#define u_map                 unordered_map<ll,ll>
#define n_map                 map<ll,ll>
#define n_pair                pair<ll,ll>
#define all(v)                v.begin(),v.end()
#define frr(i,j,k)           for(int i=j; i<k; i++)
#define frp(i,j,k)           for(int i=j; i>=k; i--)
#define pb(a)                 push_back(a)
#define lb(v,t)               lower_bound(all(v),t)-v.begin()
#define ub(v,t)               upper_bound(all(v),t)-v.begin()
#define in(t)                 scanf("%lld",&t);
#define out(t)                printf("%lld\n",t);
#define inputarr(a,n)        for(int i=0;i<n;++i) cin>>a[i]
#define printarr(a,n)        for(int i=0;i<n;++i) cout<<a[i]<<" "
#define mem(a)              memset(a,0,sizeof(a))
#define int_max     INT_MAX64
ll abst(ll a){if(a<0)return -a; return a;}
ll power(ll a, ll b){ll res=1;while(b){if(b&1)res=res*a;a=a*a;b/=2;}return res;}
ll invmod(ll a){return power(a,mod-2);}
ll lcm(ll a, ll b){return a*b/__gcd(a,b);}
ll ncr(ll n, ll r){ll p=1;ll i;for(i=1; i<=r; i++){p*=(n-i+1);p*=i;}return p;}
ll ans=0;
int main(){
    ll n;
    cin>>n;
    if(n==1){
        cout<<0;
        return 0;
    }
    ll h[n+1];
    frr(i,0,n)cin>>h[i];
    ll dp[n+1];
    mem(dp);
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;++i){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
        //cout<<dp[i]<<" ";
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
int a[200000];
using namespace std;
int main()
{
	int n,b;
	cin>>n;
	for(int t=2;t<=n;t++)
	{
		cin>>b;
		a[b]++;
	}
	for(int t=1;t<=n;t++)
	{
		cout<<a[t]<<endl;
	}
	return 0;
}

Measured memory_bytes: 4416
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	int count=0,m=0;
	cin>>s>>t;
	for(int i=0;i<=s.length()-t.length();i++)
	{
		int l=i;
		for(int j=0;j<t.length();j++)
		{
			if(s[i]==t[j])
			{
				count++;
				m=max(count,m);
			}

			

			i++;
		}

		i=l;
		count=0;
	}

	cout<<t.length()-m<<endl;
	return 0;
}

Measured memory_bytes: 3576
#include <cmath>
#include <iostream>

using namespace std;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)

int X;
int ans;

bool IsPrime(int N)
{
    int sqrtN = (int)sqrt(N);
    RPT(i, 2, sqrtN)
    if (N % i == 0) return false;

    return true;
}

void resolve()
{
    cin >> X;

    ans = X;
    while (1) {
        if (IsPrime(ans)) break;
        ans++;
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){  
int a, b, c, d, e, f, i;  
char op;  
for(i = 0; i < 200000; i++){
    cin >> a >> op >>b; 
    if ( op == '+' ){     c = a + b;  cout << c << endl;  } 
    else if ( op == '-' ){      d = a - b;  cout << d << endl;  } 
    else if ( op == '*' ){    e = a * b;  cout << e << endl;;  } 
    else if ( op == '/' ){     f = a / b;  cout << f << endl;;  }  
    else break;
    }
return 0;}


Measured memory_bytes: 3096
#include<iostream>
#include<string>
#include<stack>
using namespace std;
	
int main(){
	string s;
  	int dummy;
  	cin >> dummy;
  	cin >> s;
  	int zero = 0, ichi = 0;
  	for(auto c:s){
     	if(c== 'R')zero++;
      	else ichi++;   
    }
  	
     if(zero > ichi){
       cout << "Yes" << endl;
     }else{
     cout << "No" << endl;
     }

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>

using namespace std;

int num(vector<int> &v, int cnt) {
  int result = 0;
  for (auto x : v) {
    if (x >= cnt)
      result++;
  }
  return result;
}

void cntDiv(vector<int> &v, int max) {
  int n = max;
  for (int i = 2; i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    v[i] += cnt;
  }
}

int main() {
  int N;
  cin >> N;
  vector<int> v(N+1);

  for (int i = 1; i <= N; i++) {
    cntDiv(v, i);
  }

  cout <<
    num(v, 74) +
    (num(v, 2)-1) * num(v, 24) +
    (num(v, 2)-2) * (num(v, 4)-1) * num(v, 4) / 2 +
    (num(v, 4)-1) * num(v, 14) << endl;

  return 0;
}


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

#define MAX 40

typedef struct node_t {
	int key;
	struct node_t *parent;
	struct node_t *left;
	struct node_t *right;
} node;

node* newNode(int);
void reTree(int, int, int, node *, char);
void postorder(node *);

int pre[MAX], in[MAX];
int flag=0;

int main(void)
{
	int i, n;
	node *root;
	
	scanf("%d",&n);
	for (i=0; i<n; i++) {
		scanf("%d",&pre[i]);
	}
	for (i=0; i<n; i++) {
		scanf("%d",&in[i]);
	}
	
	root = newNode(0);
	
	reTree(n, 0, 0, root, 'l');
	
	postorder(root->left);
	printf("\n");
	
	return 0;
}

node* newNode(int key)
{
	node *tmp;
	
	tmp = (node *)malloc(sizeof(node));
	if (tmp == NULL) exit(0);
	
	tmp->key = key;
	tmp->parent = NULL;
	tmp->left = NULL;
	tmp->right = NULL;
	
	return tmp;
}

void reTree(int n, int phead, int ihead, node *parent, char ch)
{
	int cnt, key;
	node *node;
	
	if(n==0) return;
	
	key = pre[phead];
	cnt = 0;
	
	while (in[ihead + cnt] != key) {
		cnt++;
	}
	
	
	node = newNode(key);
	node->parent = parent;
	if(ch == 'l') parent->left = node;
	else if(ch == 'r') parent->right = node;
	
	reTree(cnt, phead+1, ihead, node, 'l');
	reTree(n-cnt-1, phead+cnt+1, ihead+cnt+1, node, 'r');
}

void postorder(node *node)
{
	
	if(node->left != NULL) postorder(node->left);
	if(node->right != NULL) postorder(node->right);
	if (flag==0) {
		printf("%d",node->key);
		flag = 1;
	} else {
		printf(" %d",node->key);
	}
}

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

using namespace std;

#define int long long

int gcd(int x, int y) {
    while (x > 0 && y > 0) {
        int c = x % y;
        x = y, y = c;
    }
    return x + y;
}

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    cin >> a >> b;
    cout << a * b / gcd(a, b);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    rep(i, 1, 10)
    {
        if (n % i == 0 && n / i <= 9)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll modinv(ll a, ll m) {ll b = m, u = 1, v = 0;while (b) {ll t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
const int INF = 1e9;
const ll LLINF = 1e16;

int main(void)
{
    ll k;
    cin >> k;
    if(gcd(k,10) == 1){
        ll sev = 7;
        int cnt = 1;
        while(true) {
            if(sev % k == 0){
                cout << cnt << endl;
                break;
            }
            sev = (sev * 10 + 7) % k;
            cnt++;
        }
    }
    else{
        cout << -1 << endl;
    }
     return 0;
}

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

typedef pair<long long, long long> ii;


long long mod = 1000000007;

int main(){
	//freopen("i.txt","r",stdin);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int rows, cols;
	cin >> rows >> cols;
	
	int k;
	cin >> k;
	
	bool grid[rows][cols];
	
	for(int r = 0;r < rows;r++){
		string s;
		cin >> s;
		for(int c = 0;c < cols;c++){
			if(s[c] == '#') grid[r][c] = true;
			else grid[r][c] = false;
		}
	}
	
	int answer[rows][cols];
	int cnt = 1;
	set<int> emp;
	for(int r = 0;r < rows;r++){
		bool first = true;
		for(int c = 0;c < cols;c++){
			if(grid[r][c]){
				if(first){
					first = false;
				}
				else{
					cnt++;
				}
			}
			answer[r][c] = cnt;
		}
		cnt++;
		if(first){
			emp.insert(r);
			
		}
	}
	set<int> settle;
	while(!emp.empty()){
		for(int r : emp){
			if(r != rows-1){
				int dr = r + 1;
				if(emp.find(dr) == emp.end()){
					for(int c = 0;c < cols;c++){
						answer[r][c] = answer[dr][c];
					}
					emp.erase(r);
					break;
				}
				
				
			}
			if(r != 0){
				int dr = r - 1;
				if(emp.find(dr) == emp.end()){
					for(int c = 0;c < cols;c++){
						answer[r][c] = answer[dr][c];
					}
					emp.erase(r);
					break;
				}
			}
		}
	}
	
	
	
	map<int,int> dis;
	for(int r = 0;r < rows;r++){
		for(int c = 0;c < cols;c++){
			dis[answer[r][c]] = 0;
		}
	}
	int cc = 1;
	for(map<int,int>::iterator it = dis.begin();it != dis.end();it++){
		it->second = cc;
		cc++;
	}
	for(int r = 0;r < rows;r++){
		for(int c = 0;c < cols;c++){
			answer[r][c] = dis[answer[r][c]];
			cout << answer[r][c] << " ";
		}
		cout <<"\n";
	}
	
	
	
	
}


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

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	cin >> N;

	bool result = false;

	for( int i = 1; i <= 9; ++i ) {
		int x = N/i;
		if( x <= 9 && x*i == N ) {
			result = true;
			break;
		}
	}

	cout << (result ? "Yes": "No") << endl;

	return 0;
}


Measured memory_bytes: 256
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll x;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>x;
	if(x<1200)
	cout<<"ABC";
	else
	cout<<"ARC";
	return 0;
}


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


#define ll long long
#define MOD 1000000007
#define PI 3.1415


int main(){
    string n;
    cin>>n;
    
    for(int i=0;i<n.size();i++){
        if(n.at(i)=='7'){
            cout<<"Yes"<<endl;
            break;
        }
        if(i==n.size()-1){
            cout<<"No"<<endl;
            break;
        }
    }
}


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

int main() {
    int n, q;
    string s;
    cin >> n >> q >> s;
    s = ' ' +  s;
    vector<int> dp(n+1);
    rep(i, n+1) {
        if (i == 0 || i == 1) dp[i] == 0;
        else if (s[i-1] == 'A' && s[i] == 'C') dp[i] = dp[i-1] + 1;
        else dp[i] = dp[i-1];
        // cout << dp[i] << " ";
    }
    cout << endl;
    rep(i, q) {
        int l, r;
        cin >> l >> r;
        // int cnt = 0;
        // for (int i = l; i <= r - 1; i++) {
        //     if (s[i] == 'A' && s[i+1] == 'C') cnt++;
        // }
        // cout << cnt << endl;
        cout << dp[r] - dp[l] << endl;
    }
}

Measured memory_bytes: 3900
from enum import Enum
import sys
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
 
class Type(Enum):
    win_Taro = 0
    win_Hanako = 1
    EVEN = 2
 
def comp_str(A,B):
    if A > B:
        return Type.win_Taro
    elif A < B:
        return Type.win_Hanako
    else:
        return Type.EVEN
 
N = int(input())
 
point_Taro = 0
point_Hanako = 0
 
for loop in range(N):
    line = str(input()).split()
    ret_type = comp_str(line[0],line[1])
    if ret_type == Type.win_Taro:
        point_Taro += 3
    elif ret_type == Type.win_Hanako:
        point_Hanako += 3
    else:
        point_Taro += 1
        point_Hanako += 1
 
print("%d %d"%(point_Taro,point_Hanako))


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

int main() {
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    int n, u, k, v;
    std::cin >> n;
    for (int i=0; i<n; i++) {
        std::cin >> u >> k;
        int vv[100]={};
        for (int j=0; j<k; j++) {
            std::cin >> v;
            vv[v-1]=1;
        }
        for (int j=0; j<n; j++) {
            std::cout << vv[j];
            if (j == n-1) {
                std::cout << "\n";
            } else {
                std::cout << " ";
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
	if(number1 > number2){
		swap(number1,number2);
	}
	if(number1 == 0 || number1 == number2){
		return number2;
	}else{
		return gcd(number2 % number1,number1);
	}
}

ll i,j,k,ii,jj,r,l;
ll n,m,num,sum,ans;
ll a,b,c,d,e,g,h,w;
ll x[500005],y[500005],z[1000005];
char s[1000005];

int main(){
	ll x1,x2,x3,x4,y1,y2,y3,y4;
	cin >> x1 >> y1 >> x2 >> y2;
	ll dx = x2 - x1;
	ll dy = y2 - y1;
	y3 = y2 + dx;
	x3 = x2 - dy;
	x4 = x3 - dx;
	y4 = y3 - dy;
	pe(x3);pe(y3);pe(x4);p(y4);
	
	return 0;

}

Measured memory_bytes: 23936
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli n, ans, min = INF;
	cin >> n;
	for(lli i=1; i*i<=n; ++i){
		if(n%i == 0){
			ans = i-1+n/i - 1;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		show();
	}
	
	public static void show(){
		for(int i = 1;i <= 9;i++){
			for(int j = 1;j <= 9;j++){
				System.out.println(i + "x" + j + "=" + (i * j));
			}
		}
	}

}

Measured memory_bytes: 24124
from numpy import*;N,K=map(int,input().split());m,L,o=zeros((3*K,3*K)),2*K,0
for _ in[0]*N:x,y,c=input().split();t=c=='W';m[int(x)%L,int(y)%L]+=2*t-1;o+=t
for _ in"00":m[L:]=m[:K];m=cumsum(m,0);m[:L]-=m[K:];m=m.T
m=m[:L,:L];print(o-int((m+roll(roll(m,K,0),K,1)).min()))

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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    size_t n, k;
    cin >> n >> k;
    auto r = n - k;
    vector<vector<unsigned long>> C(n + 10, vector<unsigned long>(n + 10));
    C[0][0] = 1;
    for(size_t i = 1; i < n + 10; ++i){
        C[i][0] = 1;
        for(size_t j = 1; j <= i; ++j)C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
    }
    for(size_t i = 1; i <= k; ++i){
        cout << C[r + 1][i] * C[k - 1][i - 1] % MOD << endl;
    }
    return 0;
}

Measured memory_bytes: 31872
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		char[] s = scanner.nextLine().toCharArray();
		char[] t = scanner.nextLine().toCharArray();
		long ans = 0;

		for(int i = 0; i < s.length; i++) {

			if(s[i] != t[i]) ans++;

		}

 		System.out.println(ans);
	}
}


Measured memory_bytes: 43144
#include<bits/stdc++.h>
#define pi 3.141592653897932384626
#define abs(x) ((x)>0?(x):(-(x)))
#define eps (double)(0.0000001)
//freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
using namespace std;
int main()
{
    char a[10];
    fgets(a,INT_MAX,stdin);
    long s=0;
    for(long i=0;i<3;++i)if(a[i]=='o')++s;
    cout<<100*(7+s)<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		char[] inS = stdin.next().toCharArray();
		Arrays.sort(inS);
		char[] inT = stdin.next().toCharArray();
		Arrays.sort(inT);

		String result = "No";
		for (int indexS = 0, indexT = (inT.length - 1); (indexS < inS.length) || (indexT >= 0); indexS++, indexT--) {
			if (indexS >= inS.length) {
				result = "Yes";
				break;
			}
			else if (indexT < 0) {
				result = "No";
				break;
			}

			if (inS[indexS] < inT[indexT]) {
				result = "Yes";
				break;
			}
			else if (inS[indexS] > inT[indexT]) {
				result = "No";
				break;
			}
		}

		System.out.println(result);
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  size_t n; std::cin >> n;
  std::vector<std::pair<size_t, size_t>> ret;
  size_t forbidden = n + (n % 2 == 0);
  auto sum = std::vector<size_t>(n + 1, 0);
  for (size_t i = 1; i <= n; i++) {
    for (size_t j = i + 1; j <= n; j++) {
      if (i + j != forbidden) {
        ret.emplace_back(i, j);
        sum.at(i) += j;
        sum.at(j) += i;
      }
    }
  }
  for (size_t i = 1; i <= n; i++) {
    assert(sum.at(i) == n * (n + 1) / 2 - forbidden);
  }
  std::cout << ret.size() << std::endl;
  std::for_each(ret.begin(), ret.end(), [](auto e){
    std::cout << e.first << " " << e.second << std::endl;
  });
  return 0;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int n,r;
	cin>>n>>r;
	cout<<(n>=10?r:r+100*(10-n))<<endl;
	return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())

ans1 = 0
ans2 = 0
if K%2 == 1:
    for i in range(1,N+1):
        if i%K == 0:
            ans1 += 1
            
        ans = ans1**3
else:
    for i in range(1,N+1):
        if i%K == 0:
            ans1 += 1
        if i%K == K//2:
            ans2 += 1
        ans = ans1**3 + ans2**3
            
print(ans)

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

#define INF 0x3f3f3f3f
#define NINF -0x3f3f3f3f

using namespace std;

typedef pair<int,int> pii;

int main ()
{
	int Q,H,S,D;
	scanf("%d %d",&Q,&H);
	scanf("%d %d",&S,&D);
	
	int N;
	scanf("%d",&N);
	
	long long lt1 = min(4LL*Q,min(2LL*H,min(1LL*S,1LL*H+2LL*Q)));
	long long ans = lt1*N;
	
	if (N & 1)
		ans = min(ans,D*(N/2LL)+lt1);
	else
		ans = min(ans,D*(N/2LL));
		
	printf("%lld\n",ans);
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>

using namespace std;

typedef long long int ll;
typedef long int li;

int main(void){
    ll ans=0;
    ll n;
    cin >> n;
    int a[5];
    for(int i=1;i<5;i++){
        a[i]=n%10;
        n/=10;
        if(a[i]==2)ans++;
    }
    
        cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def myAnswer(a:list,b:list,XYC:list) -> int:
   ans = min(a) + min(b)
   for x,y,c in XYC:
      total = a[x-1] + b[y-1] - c
      ans = min(total,ans)
   return ans



def modelAnswer():
   tmp=1
def main():
   A, B, M = map(int,input().split())
   a = list(map(int,input().split()))
   b = list(map(int,input().split()))
   XYC = []
   for _ in range(M):
      XYC.append(list(map(int,input().split())))
   print(myAnswer(a,b,XYC))

if __name__ == '__main__':
   main()

Measured memory_bytes: 38444
# Author: cr4zjh0bp
# Created: Thu Mar 12 20:12:47 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

N, A, B = na()

def digit_sum(n):
    s = str(n)
    n = 0
    for i in range(len(s)):
        n += int(s[i])
    return n

ans = 0
for i in range(N + 1):
    d = digit_sum(i)
    if d >= A and d <= B:
        ans += i

print(ans)

Measured memory_bytes: 3064
import sys
S = input()
N = len(S)
ans = 0
x = 0
for i in range (0,N):
  if (S[i] == "A") or (S[i] == "T") or (S[i] == "C") or (S[i] == "G"):
    x = x + 1
  else:
    ans = max(x,ans)
    x = 0
  if i == N-1:
    ans = max(x,ans)
    print(ans)
    sys.exit()

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		//2????????´??°?????\???
		String data[] = br.readLine().split(" ");
		int a = Integer.parseInt(data[0]);
		int b = Integer.parseInt(data[1]);
		int d = a / b;
		int r = a % b;
		double f;
		f = (double)a / b;

		System.out.print(d +" "+ r +" ");
		System.out.printf("%.5f\n",f);





	}

}

Measured memory_bytes: 24876
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

b = []
count = 1
del_x = 0
for i in range(0, n):
    if a[i] == count:
        count += 1
    else:
        del_x += 1

if count == 1:
    print(-1)
else:
    print(del_x)


Measured memory_bytes: 24744
#include <iostream>
#include <cctype>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <cstring>
#include <fstream>
#include <cmath>
#include <stack>
#include <algorithm>
#include <queue>
#include <iterator>
#include <limits>
#define PI 3.1415926535
#define MAX 100
#define swap(a,b,t) (t=a,a=b,b=t)

        
using namespace std;

int main()
        { 
        int num[5],i=0,m1=0,mn=124,d;
        while(i<5)
        {
        cin>>num[i];
        if(m1<num[i])
        m1=num[i];
        if(mn>num[i])
        mn=num[i];
        i++;
        }
        cin>>d;
        if(m1-mn<=d)
        cout<<"Yay!";
        else
        cout<<":(";
        //system("pause");
        return 0;
        } 
        




Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main()
{
    char a,b;
    scanf("%c %c",&a,&b);
        if(a=='D'&&b=='H')
            printf("D\n");
        else  if(a=='H'&&b=='D')
            printf("D\n");
        else  if(a=='H'&&b=='H')
            printf("H\n");
        else
            printf("H\n");
    return 0;
}


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

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

const long long MOD = 1000000007;

int main(){
  int n,m,b,c;
  cin>>n>>m;
  vector<int> a(n);
  
  rep(i,n) cin>>a.at(i);
  sort(a.begin(),a.end());
  
  vector<pair<int,int>> ex(m);
  rep(i,m){
    cin>>b>>c;
    ex.at(i)=make_pair(c,b);
  }
  sort(ex.begin(),ex.end());
  reverse(ex.begin(),ex.end());
  int x=0;
  rep(i,m){
    if(x>=n) break;
    else if(a.at(x)<ex.at(i).first){
      int xx=x;
      for(int j=xx;j<min(xx+ex.at(i).second,n);j++){
        if(a.at(j)<ex.at(i).first){ 
          a.at(j)=ex.at(i).first;
          x++;
        }
        else break;
      }
    }
    else break;
  }
  ll ans=0;
  rep(i,n) ans+=a.at(i);
  
  cout<<ans<<endl;
}


Measured memory_bytes: 1408
import itertools

N = int(input())
Town = []
for _ in range(N):
    Town.append(list(map(int, input().split())))

kyori = 0
num = 0
for v in itertools.permutations(Town, N):
    num += 1
    for i in range(N-1):
        kyori += ((v[i][0]-v[i+1][0])**2 + (v[i][1]-v[i+1][1])**2)**0.5

print(kyori/num)

Measured memory_bytes: 3064
# ABC099C - Strange Bank
# DP ver.
def main():
    n = int(input())
    dp = [i for i in range(n + 1)]  # initialize with using only ¥1
    cand = []  # 6^n, 9^n <= n
    for i in (6, 9):
        p = 1
        while i ** p <= n:
            cand += [i ** p]
            p += 1
    for i in range(n + 1):
        for j in cand:
            if j > n:
                break
            if i - j >= 0:
                dp[i] = min(dp[i], dp[i - j] + 1)
    print(dp[-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 7064
#include <iostream>
#include <algorithm>
#include <vector>
static const int N = 2001;
using namespace std;
struct data{
  int correctcnt,time,tnum;
  bool operator<(const data& right)const{
    if(correctcnt!=right.correctcnt) return correctcnt>right.correctcnt;
    if(time!=right.time) return time<right.time;
    return tnum>right.tnum;
  }
};
int main(){
  int M,T,P,R,i,j,m[N],t[N],p[N],in_j[N],incorrectcnt;
  while(1){
    cin >> M >> T >> P >> R;
    vector<data> V(T);
    if(M==0&&T==0&&P==0&&R==0) break;
    for(i=0;i<R;i++){
      cin >> m[i] >> t[i] >> p[i] >> in_j[i];
    }
    for(i=0;i<T;i++){
      V[i].tnum=i+1;
      V[i].correctcnt=V[i].time=0;
    }
    for(i=0;i<R;i++){
      if(in_j[i]==0){
    V[t[i]-1].correctcnt++;
    incorrectcnt=0;
    for(j=0;j<i;j++){
      if(t[i]==t[j]&&p[i]==p[j]) incorrectcnt++;
    }
    V[t[i]-1].time+=m[i]+20*incorrectcnt;
      }
    }
    sort(V.begin(),V.end());
    for(i=0;i<T-1;i++){
      cout << V[i].tnum;
      if(V[i].correctcnt==V[i+1].correctcnt&&V[i].time==V[i+1].time) cout << '=';
      else cout << ',';
    }
    cout << V[T-1].tnum << endl;
  }  
  return 0;
}

Measured memory_bytes: 1252