akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <cstdlib>
#include <algorithm>
#include <string>

using namespace std;

const int N = 30;

int h, w, t, p;
char data[N][N], next[N][N];
int dy[] = {0, -1, 0, 1};
int dx[] = {1, 0, -1, 0};
map<char, int> ctoi;
string itoc = "ENWS";

void copy(){
   for(int i=0;i<h;++i){
      for(int j=0;j<w;++j){
         data[i][j] = next[i][j];
      }
   }
}

void print(){
   for(int i=0;i<h;++i){
      for(int j=0;j<w;++j){
         cout << data[i][j];
      }
      cout << endl;
   }
}

main(){
   ctoi['E'] = 0;
   ctoi['N'] = 1;
   ctoi['W'] = 2;
   ctoi['S'] = 3;
   while(cin >> w >> h && (h || w)){
      p = 0;
      for(int i=0;i<h;++i){
         for(int j=0;j<w;++j){
            cin >> next[i][j];
            if(next[i][j] == 'E' ||
               next[i][j] == 'N' ||
               next[i][j] == 'W' ||
               next[i][j] == 'S') ++p;
         }
      }
      copy();
      for(t=0;t<=180;++t){
         if(p == 0) break;
         for(int i=0;i<h;++i){
            for(int j=0;j<w;++j){
               if(data[i][j] == '#' ||
                  data[i][j] == '.' ||
                  data[i][j] == 'X') continue;
               for(int k=0;k<4;++k){
                  int d = (ctoi[data[i][j]] + 3 + k) % 4;
                  int ty = i + dy[d];
                  int tx = j + dx[d];
                  if(ty<0 || ty>=h) continue;
                  if(tx<0 || tx>=w) continue;
                  if(data[ty][tx] == '.' || data[ty][tx] == 'X'){
                     data[i][j] = itoc[d];
                     next[i][j] = itoc[d];
                     break;
                  }
               }
            }
         }
         for(int i=0;i<h;++i){
            for(int j=0;j<w;++j){
               if(data[i][j] == '.' || data[i][j] == 'X'){
                  for(int k=0;k<4;++k){
                     int ty = i + dy[k];
                     int tx = j + dx[k];
                     if(ty<0 || ty>=h) continue;
                     if(tx<0 || tx>=w) continue;
                     if(data[ty][tx] == '#' ||
                        data[ty][tx] == '.' ||
                        data[ty][tx] == 'X') continue;
                        if(abs(ctoi[data[ty][tx]] - k) == 2){
                        if(data[i][j] == 'X') --p;
                        else next[i][j] = data[ty][tx];
                        next[ty][tx] = '.';
                        break;
                     }
                  }
               }
            }
         }
         copy();
      }
      if(t > 180) cout << "NA" << endl;
      else cout << t << endl;
   }
   return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public static void Main(string[] args)
	{
		long n = long.Parse(Console.ReadLine());
		long a = long.Parse(Console.ReadLine());
		long b = long.Parse(Console.ReadLine());
		long c = long.Parse(Console.ReadLine());
		long d = long.Parse(Console.ReadLine());
		long e = long.Parse(Console.ReadLine());
		long[] m = new long[]{0, a,b,c,d,e};
		
		long[] map=new long[6];
		map[0]=n;

		long time=0;
		long mi=99999999999999999;
		for(int i = 0; i < m.Length-1;i++)
		{
			time+=p(n,m[i],m[i+1],mi);
			mi=Math.Min(mi,m[i+1]);
			
			if(i!=m.Length-2)time++;
		}

		Console.WriteLine(time);
	}
	
	public static long p(long n, long si, long oi, long mi)
	{
		if(si!=0 && si <= oi)
			return 0;
		long r1 = (long)Math.Ceiling(n/(double)Math.Min(mi,si));
		long r2 = (long)Math.Ceiling(n/(double)Math.Min(mi,oi));
		if(si==0)
		{
			return r2;
		}
		return r2-r1;
	}
	
	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}


}

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

void MAIN() {
    std::vector<int> arr(3);
    for(int &now: arr) {
        scanf("%d", &now);
    }
    for(int i = 0; i < 3; ++ i) {
        if(arr[i] & 1) {
            continue;
        }
        puts("0");
        return ;
    }
    std::sort(arr.begin(), arr.end());
    printf("%lld\n", arr[0] * 1ll * arr[1]);
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// #define mp make_pair
//#define endl '\n'
 
int main() {
    ll a, b;
    string out = "IMPOSSIBLE";
    cin >> a >> b;
    if(a == b){
        cout << '0' << endl;
        return 0;
    }
    if((a+b)%2 == 0){
        ll k = (a+b) / 2;
        cout << k << endl;
        return 0;
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 256
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

s = input()[:-1]
t = input()[:-1]

dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]


def solve():
    for i, cs in enumerate(s):
        for j, ct in enumerate(t):
            if cs == ct:
                dp[i+1][j+1] = dp[i][j]+1
            else:
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])

    i = len(s)-1
    j = len(t)-1
    ans = ""
    while i >= 0 and j >= 0:
        if s[i] == t[j]:
            ans += s[i]
            i -= 1
            j -= 1
        else:
            if dp[i+1][j+1] == dp[i+1][j]:
                j -= 1
            elif dp[i+1][j+1] == dp[i][j+1]:
                i -= 1
            else:
                break
    print("".join(reversed(ans)))


solve()


Measured memory_bytes: 111964
(defun split (delimiter target-string)
  (let ((delimiter-position (search delimiter target-string))
        (delimiter-size (length delimiter)))
    (if delimiter-position
        (cons (subseq target-string 0 delimiter-position)
              (split delimiter (subseq target-string (+ delimiter-position delimiter-size))))
        (list target-string))))

(defun is-approved-paper (n)
  (cond
    ((oddp n) T)
    ((= 0 (mod n 3)) T)
    ((= 0 (mod n 5)) T)
    (T nil)))

(defun confirm-papers (l)
  (cons (is-approved-paper (car l))
        (if (cdr l)
            (confirm-papers (cdr l))
            nil)))

(defun my-and (l)
  (and (car l)
       (if (cdr l)
           (my-and (cdr l))
           T)))

(defun is-approved (l)
  (if (my-and l)
      "APPROVED"
      "DENIED"))

(let* ((n (read))
      (papers-str (read-line))
      (papers (mapcar #'parse-integer (split " " papers-str))))
  (princ (is-approved (confirm-papers papers))))
  


Measured memory_bytes: 6504
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;


ll a, b, c;
string s;
ll ans;
int main() {
    ans=inf;
    cin>>s;
    REP(i,0,s.size()-2){

        b = (s[i+2]-'0') + (s[i+1]-'0')*10 + (s[i] - '0')*100;
        ans = min(ans, abs(753-b));
    }
    p(ans);


    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	const int MOD = 1000000007LL;

	int n;
	cin >> n;
	vector<string> s(2);
	for (int i = 0; i < 2; i++) {
		cin >> s[i];
	}

	ll ans = 1;
	int x = 0;
	ll pre = -1;

	while (x < n) {
		if (s[0][x] == s[1][x]) {
			if (pre < 0) {
				ans = 3;
			} else if (pre == 0) {
				ans = ans * 2 % MOD;
			}
			x++;
			pre = 0;
		} else {
			if (pre < 0) {
				ans = 6;
			} else if (pre == 0) {
				ans = ans * 2 % MOD;
			} else {
				ans = ans * 3 % MOD;
			}

			x += 2;
			pre = 1;
		}
	}

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


Measured memory_bytes: 256
ALP=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#print(len(ALP))

N=int(input())
S1=list(input())

S2=[]
for s in S1:
  ind=ALP.index(s)
  S2.append(ALP[(ind+N)%26])
  
print("".join(S2))

Measured memory_bytes: 3188
#include<iostream>
#include<cctype>
#include<string>
using namespace std;

int main(){
	char ch;
	char aaa[27]="abcdefghijklmnopqrstuvwxyz";
	int i=0;
	int num=0;
	int count[27]={0};

	//cin.getline(ch,1200,'\n');

	while(cin >> ch){
		ch=tolower(ch);
		num=ch-'a';
		count[num]++;
		//i++;
	}
	for(i=0;i<26;i++){
		cout<<aaa[i]<<" : "<<count[i]<<endl;
	}
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


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

    int t=1,te=0;
    // cin>>t;
    while(t--){
        int a,b;
        cin>>a>>b;

       for(int x=1;x<=1000000;++x){
        int x1 = x*0.08;
        int x2 = x*0.1;

        if(x1==a and x2==b){
            printf("%d\n",x);
            return 0;
        }

       }

       printf("-1\n");
        //printf("Case %d: ",++te);
    }
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

ll N,M,L;
//dijkstra
//参考：http://nocotan.github.io/%E3%82%A2%E3%83%AB%E3%82%B4%E3%83%AA%E3%82%BA%E3%83%A0/2017/01/26/dijkstra-copy.html

const ll MXV=300;//変更可
vector<edge> G[MXV];
vvl d(MXV,vl(MXV,INF));
vvl reh(MXV,vl(MXV,INF));
typedef pair<P,ll> T;

void dijkstra(int s){
    priority_queue<T,vector<T>,greater<T>> pq;
    reh[s][s]=0,d[s][s]=0;
    pq.push(T{{reh[s][s],d[s][s]},s});
    while(pq.size()){
        T t=pq.top();
        pq.pop();
        int V=t.second;
        if(make_pair(reh[s][V],d[s][V])<t.first){
            continue;
        }
        rep(i,G[V].size()){
            edge e=G[V][i];
            if(d[s][V]+e.cost<=L&&make_pair(reh[s][e.to],d[s][e.to])>make_pair(reh[s][V],d[s][V]+e.cost)){
                reh[s][e.to]=reh[s][V];
                d[s][e.to]=d[s][V]+e.cost;
                pq.push(T{{reh[s][e.to],d[s][e.to]},e.to});
            }
            if(d[s][V]+e.cost>L&&make_pair(reh[s][e.to],d[s][e.to])>make_pair(reh[s][V]+1,e.cost)){
                reh[s][e.to]=reh[s][V]+1;
                d[s][e.to]=e.cost;
                pq.push(T{{reh[s][e.to],d[s][e.to]},e.to});
            }            
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> M >> L;
    vl A(M),B(M),C(M);
    rep(i,M){
        cin >> A[i] >> B[i] >> C[i];
        if(C[i]>L)continue;
        A[i]--;B[i]--;
        G[A[i]].pb({B[i],C[i]});
        G[B[i]].pb({A[i],C[i]});
    }
    rep(i,N){
        dijkstra(i);
    }
    ll Q;
    cin >> Q;
    rep(QQ,Q){
        ll s,t;
        cin >> s >> t;
        s--;
        t--;
        if(reh[s][t]==INF){
            cout << -1 << endl;
        }
        else{
            cout << reh[s][t] << endl;
        }
    }
}

Measured memory_bytes: 9836
#include <iostream>

using namespace std;

int main()
{
  int A,B,C,D;
  int time[101] = {};
  cin >> A >> B >> C >> D;

  for(int i = 0; i <= 100; i++){
    if(A <= i && i <= B){
      if(C <= i && i <= D){
	time[i] = 1;
      }
    }
  }

  int ans;
  ans = 0;
  for(int i = 0; i <= 100; i++) ans += time[i];
  if(ans == 0) cout << ans << "\n";
  else cout << ans-1 << "\n";

  return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
raw = ['/' * (w+2)]
for hi in range(h):
  raw.append('/' + input() + '/')
raw += ['/' * (w+2)]
#print(raw)
for hi in range(h):
  ans = ''
  pre = raw[hi]
  now = raw[hi+1]
  pst = raw[hi+2]
  for wi in range(w):
    if now[wi+1] == '#':
      cnt = '#'
    else:
      cnt = 0
      can = pre[wi:wi+3] + now[wi:wi+3] + pst[wi:wi+3]
      for j in range(9):
        if can[j] == '#':
          cnt += 1
    ans += str(cnt)
  print(ans)

Measured memory_bytes: 3064
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


def main():
    n, y = map(int, input().split())

    b = False
    for i in range(n + 1):
        if i > y or b:
            break
        for j in range(n + 1):
            if i + j > n:
                break
            if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
                b = True
                print(i, j, n-i-j)
                break

    if not b:
        print(-1, -1, -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 6436
#include <iostream>
#include<cstdio>
using namespace std;
#define m 1000000100
int main()
{
    int n,p[200002],temp=-2*m;
    cin>>n;
    for(int i=0;i<n;i++)scanf("%d",&p[i]);
    int mint=p[0];
    for(int i=1;i<n;i++){
        temp>p[i]-mint?temp=temp:temp=p[i]-mint;
        mint<p[i]?mint=mint:mint=p[i];
    }
        //cout<<p[sell]-p[buy]<<"\n"<<endl;

    cout<<temp<<endl;
    return 0;
}



Measured memory_bytes: 3940
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    cin>>s;
    string b=s;
    reverse(s.begin(),s.end());
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='b')s[i]='d';
        else if(s[i]=='d')s[i]='b';
        else if(s[i]=='p')s[i]='q';
        else if(s[i]=='q')s[i]='p';
    }
    if(s==b) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 512
import math

class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __repr__(self):
        return "{:.8f} {:.8f}".format(self.x, self.y)

class kochCurveController:
    def insertTriangle(self,p1, p2,d):
        if d == 0:
            return
        s = self.secret(p1,p2,1,2)
        t = self.secret(p1,p2,2,1)
        u = self.calcVertex(s,t)

        self.insertTriangle(p1,s,d-1)
        print(s)
        self.insertTriangle(s,u,d-1)
        print(u)
        self.insertTriangle(u,t,d-1)
        print(t)
        self.insertTriangle(t,p2,d-1)


    def calcVertex(self,s,t):
        x = t.x - s.x
        y = t.y - s.y
        return Point(s.x+math.cos(math.radians(60))*x -math.sin(math.radians(60))*y, s.y+math.sin(math.radians(60))*x+math.cos(math.radians(60))*y)

    def secret(self,va,vb,a,b):
        return Point((b*(va.x)+a*(vb.x))/(a+b),(b*(va.y)+a*(vb.y))/(a+b))


K = kochCurveController()
N = int(input())
print(Point(0,0))
K.insertTriangle(Point(0,0),Point(100,0),N)
print(Point(100,0))




Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {
	static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {
		int N = in.nextInt(), M = in.nextInt();
		String[] a = new String[N], b = new String[M];
		a[0] = in.nextLine();
		for (int i = 0; i < N; i++) {
			a[i] = in.nextLine();
		}
		for (int i = 0; i < M; i++) {
			b[i]  = in.nextLine();
		}

		for(int i = 0; i <= N - M; i++){
			for(int j = 0; j <= N - M; j++){
				boolean f = true;
				for(int k = 0; k < M; k++){
					if(!b[k].equals(a[i + k].substring(j, j + b[k].length()))){
						f = false;
						break;
					}
				}
				if(f){
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 23124
#include <stdio.h>
#include <math.h>

int main(void){
    int n, d, count = 0;
    scanf("%d%d", &n, &d);
    int x[n][d];
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < d; j++) {
            scanf("%d", &x[i][j]);
        }
    }
    for(int i = 0; i < n-1; i++) {
        for(int j = i+1; j < n; j++) {
            double ans = 0;
            for(int k = 0; k < d; k++) {
                ans += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            double rout = sqrt(ans);
            if(ceil(rout) == floor(rout)) count++;
        }
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
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 Alice, Bob = 0;
  int max;
  for(int i=0;i<N;i++){
    max = 0;
    for(int j=0;j<N;j++){
      if(max<a.at(j))
        max = a.at(j);
    }
    for(int j=0;j<N;j++){
      if(max==a.at(j)){
        a.at(j) = 0;
        break;
      }
    }
    if(i%2==0)
      Alice += max;
    else
      Bob += max;
  }
  cout << Alice - Bob << endl;

}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  string s,t;
  ll ans = 1e10;
  ll n,m;
  cin >> s>>t;
  n = s.size();
  m = t.size();
  for(int i=0;i+m-1<n;i++){
    ll tmp = 0;
    for(int j=0;j<m;j++){
      if(s[i+j]!=t[j]){
        tmp++;
      }
    }
    ans = min(ans,tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3648
# include <bits/stdc++.h>
using namespace std;
namespace Base{
	# define mr make_pair
	typedef long long ll;
	typedef double db;
	const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
	const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
	template<typename T> void read(T &x){
    	x = 0; int fh = 1; double num = 1.0; char ch = getchar();
		while (!isdigit(ch)){ if (ch == '-') fh = -1; ch = getchar(); }
		while (isdigit(ch)){ x = x * 10 + ch - '0'; ch = getchar(); }
	    if (ch == '.'){
	    	ch = getchar();
	    	while (isdigit(ch)){num /= 10; x = x + num * (ch - '0'); ch = getchar();}
		}
		x = x * fh;
	}
	template<typename T> void chmax(T &x, T y){x = x < y ? y : x;}
	template<typename T> void chmin(T &x, T y){x = x > y ? y : x;}
}
using namespace Base;

const int N = 1510, P = 1e9 + 7;
int mul[N], eu[N], ev[N], mp[N][N], cnt[N], vis[N], n, k, f[N][N], ans, g[N][N];
int main(){
	read(n); read(k);
	mul[0] = 1; for (int i = 2; i <= n * 2; i += 2) mul[i] = 1ll * mul[i - 2] * (i - 1) % P;
	for (int i = 1; i <= n * 2; i++) vis[i] = 1;
	for (int i = 1; i <= k; i++){
		read(eu[i]); read(ev[i]);
		if (eu[i] > ev[i]) swap(eu[i], ev[i]);
		vis[eu[i]] = 0, vis[ev[i]] = 0;
		for (int j = eu[i] + 1; j <= ev[i] - 1; j++){
			for (int k = ev[i] + 1; k <= n * 2; k++) mp[j][k] = true;
			for (int k = 1; k <= eu[i] - 1; k++) mp[k][j] = true;
		}
		for (int j = eu[i] + 1; j < ev[i]; j++) mp[eu[i]][j] = mp[j][ev[i]] = true;
		for (int j = 1; j <= eu[i] - 1; j++) mp[j][eu[i]] = true;
		for (int j = ev[i] + 1; j <= 2 * n; j++) mp[ev[i]][j] = true;
	} 
	for (int i = 1; i <= n * 2; i++) cnt[i] = vis[i] + cnt[i - 1];

	for (int i = 1; i <= n * 2 - 1; i++){
		for (int j = 1; j <= 2 * n - i - 1; j++){
			int x = j, y = j + i;
			if (mp[x][y] == true) continue;
			int cntx = cnt[y] - cnt[x - 1], cnty = cnt[x - 1] + cnt[2 * n] - cnt[y];
			g[x][y] = mul[cnty];
			f[x][y] = (f[x][y] + 1ll * mul[cntx]) % P;
			for (int k = x + 1; k < y; k++){
				int cntx = cnt[y] - cnt[k];
				f[x][y] = (f[x][y] - 1ll * f[x][k] * mul[cntx] % P) % P;
			}
		}
	}
	
	for (int i = 1; i <= 2 * n; i++)
		for (int j = 1; j <= 2 * n; j++)
			ans = (ans + 1ll * f[i][j] * g[i][j]) % P;
	printf("%d\n", ((ans + mul[n * 2 - 2 * k]) % P + P) % P);
	return 0;
}

Measured memory_bytes: 16128
N = int(input())
answer = 0
divi=[]
for i in range(1, int(N**0.5)+1):
    if N % i == 0:
        divi.append(i)
        if i != N // i:
            divi.append(N//i)

divi.sort()
divi.pop(0)
for i in reversed(range(len(divi))):
    if N % (divi[i]-1) != N // (divi[i]-1):
        divi.pop(i)
        i = i-1



for i in  range(len(divi)):
    answer = answer + divi[i]-1
print(answer)

Measured memory_bytes: 3272
module Main where

import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    n <- readLn
    ss <- sort <$> replicateM n readLn :: IO [Int]

    let a = sum ss
    let mb = find ((/= 0) . (`mod` 10)) ss
    if a `mod` 10 /= 0
        then print a
        else do
            case mb of
                Nothing -> print 0
                Just b  -> print (a - b)

Measured memory_bytes: 1020
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc_056_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;
            int a = int.Parse(Console.ReadLine());
            for (int i = 1; i > 0; i++)
            {
                ans = i * (i + 1) / 2;
                if (ans >= a) { Console.WriteLine(i ); break; }
            }
            Console.ReadLine();

        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 1000000007
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}

int main() {
   fast();
   string s,t;
   cin>>s>>t;
   int d=s.length();
   int e=t.length();
   int ans=e;
   for(int j=0;j<=d-e;j++){
    int g=0;
   for(int i=j;i<j+e;i++){
       if(s[i]!=t[i-j]){
           g++;
       }
   }
   
   ans=min(ans,g);
   }
   cout<<ans<<"\n";

}

Measured memory_bytes: 3656
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let p: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();

    let mut count = 0;
    for i in 1..=n {
        if p[i - 1] != i {
            count += 1;
        }
    }

    if count <= 2 {
        return "YES".to_string();
    }
    return "NO".to_string();
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int dat[2000010];
int r=0;

void push(int a){
    dat[r]=a;
    int k=r;
    while(k&&dat[(k-1)/2]<dat[k]){
        swap(dat[(k-1)/2],dat[k]);
        k=(k-1)/2;
    }
    r++;
}

int pop(){
    int ret=dat[0];
    r--;
    dat[0]=dat[r];
    dat[r]=LLONG_MIN;
    int k=0;
    while(true){
        if(k*2+1>2000000)break;
        if(max(dat[k*2+1],dat[k*2+2])<=dat[k])break;
        if(dat[k*2+1]>=dat[k*2+2]){
            swap(dat[k],dat[k*2+1]);
            k=k*2+1;
        }
        else{
            swap(dat[k],dat[k*2+2]);
            k=k*2+2;
        }
    }
    return ret;
}

signed main(){
    fill_n(dat,2000010,LLONG_MIN);
    char str[10];
    while(scanf("%s",str),str[2]!='d'){
        if(str[0]=='i'){
            int a;
            scanf("%lld",&a);
            push(a);
        }
        else{
            printf("%lld\n",pop());
        }
    }
    return 0;
}

Measured memory_bytes: 18828
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
 		
int main() {

int N;
cin>>N;
bool can=true;
vec(X)
vec(Y)
vec(T)
pb(X,0) pb(Y,0) pb(T,0)
fx(N){
  int t,xx,yy;
	cin>>t>>xx>>yy;
  pb(T,t) pb(X,xx) pb(Y,yy)
	int z=abs(X.at(x)-X.at(x+1))+abs(Y.at(x)-Y.at(x+1));
	if(z>T.at(x+1)-T.at(x)){
		can=false;
		break;
	}else{
		if((T.at(x+1)-T.at(x)-z)%2!=0){
			can=false;
			break;
		}
	}
}

if(can){
	ce("Yes")
}else{
	ce("No")
}
	
}


Measured memory_bytes: 1644
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll a, b;
	cin>>a>>b;
	ll res = min(a, b);
	if(a%3==0 || b%3==0) res = 0;
	rep(j, 2){
		rep(i, 2){
			ll x[3];
			ll a1 = a/3+i, a2 = a-a1;
			x[0] = a1*b;
			x[1] = a2*(b/2);
			x[2] = a2*((b+1)/2);
			sort(x, x+3);
			res = min(res, x[2]-x[0]);
		}
		swap(a, b);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

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

  int n, u, v;
  cin >> n >> u >> v;
  u--, v--;

  vector<vector<int>> vec(n);
  rep(i, 0, n - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    vec[a].push_back(b);
    vec[b].push_back(a);
  }

  vector<int> dist_t(n, -1);
  dist_t[u] = 0;
  queue<int> que;
  que.push(u);
  while (!que.empty()) {
    int cur = que.front();
    que.pop();

    for (auto vv : vec[cur]) {
      if (dist_t[vv] != -1)
        continue;
      dist_t[vv] = dist_t[cur] + 1;
      que.push(vv);
    }
  }

  vector<int> dist_a(n, -1);
  dist_a[v] = 0;
  que.push(v);
  while (!que.empty()) {
    int cur = que.front();
    que.pop();

    for (auto vv : vec[cur]) {
      if (dist_a[vv] != -1)
        continue;
      dist_a[vv] = dist_a[cur] + 1;
      que.push(vv);
    }
  }

  int ans = 0;
  rep(i, 0, n) {
    if (dist_t[i] <= dist_a[i])
      chmax(ans, dist_a[i]);
  }

  cout << ans - 1 << endl;
}


Measured memory_bytes: 9536
#include<bits/stdc++.h> 
using namespace std;
int main(){
	string s;
	long long k,g[100]={1},cnt=0,num=0;
	cin>>s>>k;
	for(int i=1;i<s.size();i++){
		if(s[i]!=s[i-1]){
		    num+=g[cnt]/2;
		    cnt++;
		}
		g[cnt]++;
	}
	num+=g[cnt]/2;
	if(cnt==0){
		cout<<g[0]*k/2;
		return 0;
	}
	if(s[0]==s[s.size()-1]){
		cout<<k*num+(k-1)*((g[0]%2+g[cnt]%2)/2);
		return 0;
	}
	cout<<k*num;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define all(x) x.begin(),x.end()
#define endl '\n'
#define pb push_back
#define mpr make_pair
#define ff first
#define ss second
#define PI 3.1415926535897932384626
#define mod 1000000007
#define modd 998244353

void io() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	io();
	
	string s,t;
	cin>>s>>t;
	int ans=0;
	for(int i=0;i<s.length();i++)
		ans+=(s[i]!=t[i]);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3796
object Main extends App{
  import scala.io.StdIn._
  val Array(x,n) = readLine().split(" ").map(_.toInt)
  if(n == 0){
    println(x)
  } else {
    var p = readLine().split(" ").map(_.toInt).toSeq
    var u = (x to(101)).find(!p.contains(_)).get
    var d = (x - 1 to 0 by(-1)).find(!p.contains(_)).get
    val uD = u - x
    val dD = x - d
    val ans = if(dD <= uD) d else u
    println(ans)
  }
}


Measured memory_bytes: 54956
/// b.cpp

# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < __typeof(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < ll >
# define pb push_back
# define pdd pair < db , db >
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,m;
    fi>>n>>m;
    static vi g[1 << 20];
    while (m --)
    {
        int a,b;
        fi>>a>>b;
        g[a].pb(b);
        g[b].pb(a);
    }
    static int was[1 << 20];
    static int mark[1 << 20];
    vi vertices;
    function < void(int) > dfs = [&](int node)
    {
        vertices.pb(node);
        was[node] = 1;
        for (auto it : g[node])
            if (!was[it])
                mark[it] = mark[node] ^ 1,dfs(it);
    };
    int a = 0,b = 0,c = 0;
    for (int i = 1;i <= n;++i)
        if (!was[i])
        {
            vertices.clear();
            dfs(i);
            if (vertices.size() == 1)
                ++a;
            else
            {
                int w = 1;
                for (auto v : vertices)
                    for (auto it : g[v])
                        w &= mark[v] ^ mark[it];
                b += w;
                c += 1 - w;
            }
        }
    fo << (2ll * n * a - 1ll * a * a + 1ll * (b + c) * (b + c) + 1ll * b * b) << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 34812
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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 a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  ld a,b;
  cin>>a>>b;
  cout<<(ll)(a*b+0.001)<<endl;
  return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k,l,m,n;
    cin >> k;
    cin >> a >> b;
    l=(b/k)*k;
    if(a<=l)
    {
        cout << "OK" << endl;
    }
    else
    {
        cout << "NG" << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end()); 
  if (a < b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n, p; cin >> n >> p;
	string s; cin >> s;
	ll res = 0;
	if (p == 2 || p == 5)
	{
		rrep(i, n)if ((s[i] - '0') % p == 0)res += i + 1;
		cout << res << endl;
	}
	else
	{
		int f = 1;
		int r = 0;
		vector<ll> v(p, 0);
		rrep(i, n)
		{
			r = (r + f * (s[i] - '0')) % p;
			++v[r];
			f = (f * 10) % p;
		}
		res = v[0];
		rep(i, p)res += v[i] * (v[i] - 1) / 2;
		cout << res << endl;
	}
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO.Pipes;
using System.Runtime;
 
namespace Csharponly
{
    class Program
    {
        static public void Main()
        {
		string S = Onestring();
        string ans = "ABC";
        if(S == "ABC"){
            ans = "ARC";
        }
		Console.WriteLine(ans);
	
        }
 
　　　　//一つの文字列を受け渡す
        static string Onestring()
        {
            return Console.ReadLine();
        }
 
        //複数の文字列を配列で受け渡す
        //文字列と文字列の間は" "で区切る
        static string[] Arraystring()
        {
            return Console.ReadLine().Split(' ');
        }
 
        //一つの数字を受け渡す
        static int Oneint()
        {
            return int.Parse(Console.ReadLine());
        }
 
        //複数の数字を配列で受け渡す
        //数字と数字の間は" "で区切る
        static int[] Arrayint()
        {
            String[] input_line = Console.ReadLine().Split(' ');
            int[] input_num = new int[input_line.Length];
            for (int i = 0; i < input_line.Length; i++)
            {
                input_num[i] = int.Parse(input_line[i]);
            }
            return input_num;
        }
    }
}

Measured memory_bytes: 17312
#include <iostream>
#include <vector>
#define int long long
using namespace std;

signed main() {
  int K; cin >> K;
    cout << 50 << endl;

  for(int i = 0; i < 50; ++i) {
    if( i ) cout << ' ';
    cout << 49 - i + (K+49-i) / 50;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
n, k, q = map(int, input().split())
answers = []
for _ in range(q):
    answers.append(int(input()))

cnt_list = [(k-q)]*n
if q < k:
    for _ in range(n):
        print('Yes')
else:
    for i in answers:
        cnt_list[i-1] += 1
    for i in cnt_list:
        print('Yes') if i > 0 else print('No')

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()  
#define sz(x) int(x.size()) 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
const int mxn=0;
bool DEBUG=0;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int x; cin >> x;
	if(x>=30)cout << "Yes";
	else cout << "No";
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define ll long long
#define N 100010
#define inf 1000000000
using namespace std;
ll read(){
	char ch=getchar(); ll x=0; int op=1;
	for (; !isdigit(ch); ch=getchar()) if (ch=='-') op=-1;
	for (; isdigit(ch); ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
int n,m,cnt,tot,head[N],dep[N],s[N],k[N],a[N],sum,ans,len,sx,sy; bool vis[N];
struct edge{ int to,nxt; }e[N<<1];
void adde(int x,int y){
	e[++cnt].to=y; e[cnt].nxt=head[x]; head[x]=cnt;
}
void ins(int x,int y){
	adde(x,y); adde(y,x);
}
void dfs(int u,int fa){
	vis[u]=1; if (dep[u]&1) sum--; else sum++;
	for (int i=head[u],v; i; i=e[i].nxt) if ((v=e[i].to)!=fa){
		if (!vis[v]) dep[v]=dep[u]+1,dfs(v,u);
		else if (dep[v]<dep[u]) len=dep[u]-dep[v]+1,sx=u,sy=v;
	}
}
void dfs2(int u,int fa){
	vis[u]=1;
	for (int i=head[u],v; i; i=e[i].nxt) if (!vis[v=e[i].to]){
		dfs2(v,u); s[u]+=s[v]; k[u]+=k[v];
	}
}
int main(){
	n=read(); m=read();
	rep (i,1,m){
		int x=read(),y=read();
		ins(x,y);
	}
	dfs(1,0);
	if ((len&1) && (abs(sum)&1) || !(len&1) && sum){ puts("-1"); return 0; }
	rep (i,1,n) if (dep[i]&1) s[i]=1; else s[i]=-1;
	if (len&1) s[sx]+=sum/2,s[sy]+=sum/2,ans+=abs(sum/2);
	else k[sx]=1,k[sy]=-1;
	memset(vis,0,sizeof(vis));
	dfs2(1,0);
	rep (i,1,n) if (k[i]) a[++tot]=-k[i]*s[i];
	sort(a+1,a+1+tot);
	int X=a[(1+tot)/2]; ans+=abs(X);
	rep (i,1,n) ans+=abs(k[i]*X+s[i]);
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  int n;
  string c;
  cin >> n >> c;
  int l = 0,r = n-1,ans = 0;
  
  while (l < r){
    while (c[l] == 'R' && l < r){
      l++;
    }
    while (c[r] == 'W' && l < r){
      r--;
    }
    if (l >= r){
      break;
    }
    ans++;
    l++;
    r--;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3744
#include <stdio.h>

int main()
{
    int num1, num2;
    int sum, nDigit;
    
    nDigit = 1;
    
    while (scanf("%d", &num1) != EOF)
    {
          scanf("%d", &num2);
          
          sum = num1 + num2;
          
          //printf("\n suma %d\n", sum);
          
          while (sum >= 10) {
                sum = sum/10;
                nDigit++;
          }
          printf("%d\n",nDigit);
          nDigit = 1;
    }
    
    
    
    //system("PAUSE");
    
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  ll wa = 0;
  REP(i, N) {
    wa += A[i];
    wa %= MOD;
  }
  wa %= MOD;
  ll ans = 0;
  REP(i, N) {
    wa -= A[i];
    if (wa <= 0) {
      wa += MOD;
    }
    ll tmp = A[i] * (wa);
    tmp %= MOD;
    ans += tmp;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4808
#include<bits/stdc++.h>
#define REP(i, a, b) for(int i=a; i<(int)(b); i++)
#define RREP(i, n) for(int i=0; i>(int)(n); i--)
#define ALL(v) v.begin(), v.end()
#define INF 2e9
typedef long long ll;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return 1;}return 0;}

using namespace std;

ll MOD = (ll)1e9+7;

ll dp[111][111111];
int a[111];
int cum[111111];

int main(void)
{
	int N, K;
	cin >> N >> K;
	REP(i, 1, N+1){
		cin >> a[i];
	}
	dp[0][0] = 1;
	REP(i, 1, N+1){
		cum[0] = 0;
		REP(k, 1, K+2){
			cum[k] = (cum[k-1]+dp[i-1][k-1])%MOD;
		}
		REP(k, 0, K+1){
			dp[i][k] = (cum[k+1]-cum[max(k-a[i], 0)]+MOD)%MOD;
		}
	}
	cout << dp[N][K] << "\n";
	return 0;
}


Measured memory_bytes: 87424
<?php
list($n) = ints();
for ($i = 0; $i < $n; ++$i) {
    list($x, $l) = ints();
    $s[] = max(0, $x - $l);
    $e[] = $x + $l;
}
array_multisort($e, SORT_ASC, $s);
$t = 0;
$cnt = 0;
for ($i = 0; $i < $n; ++$i) {
    if ($s[$i] >= $t) {
        ++$cnt;
        $t = $e[$i];
    }
}
echo $cnt;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 32716
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll k, x;
    cin >> k >> x;
    for(ll i = x - k + 1; i <= x + k - 1; ++i){
        cout << i;
        if(i < x + k - 1){
            cout << ' ';
        }
    }
    cout << endl;
    return 0;
}


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


int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  rep(i, N) {
    cin >> P[i];
  }
  
  int cnt = 0;
  int val_min = 2*10e5+1;
  rep(i, N) {
    if (P[i] < val_min) {
      val_min = P[i];
      cnt++;
    } 
  }
  
  cout << cnt << endl;
}
    

Measured memory_bytes: 1024
import sys
from math import factorial

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    MOD = 10**9 + 7

    if N == M:
        return (2 * factorial(N) * factorial(M)) % MOD
    elif abs(N - M) == 1:
        return (factorial(N) * factorial(M)) % MOD
    else:
        return 0


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 5184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

struct UnionFind{
    vector<int> par;

    UnionFind(int n) : par(n, -1){ }
    void init(int n){ par.assign(n, -1); }

    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y){
        return root(x) == root(y);
    }

    bool unite(int x, int y){
        x = root(x); y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x){
        return -par[root(x)];
    }
};
// デクリメント忘れない


int main(){
    ll n, m; cin >> n >> m;
    UnionFind uf(n);
    rep(i, m){
        ll a, b; cin >> a >> b;
        a--, b--;
        uf.unite(a, b);
    }
    ll cnt = 0;
    rep(i, n){
        if(uf.issame(0, i)) continue;
        uf.unite(0, i);
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3748
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	int n;
	int a, b;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else {
		cin >> a >> b;
		cout << a + b << endl;
	}
}

Measured memory_bytes: 256