akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace ConsoleApplication2
{
    class Program
    {

        static void Main(string[] args)
        {
            Dictionary<string, bool[]> cards = new Dictionary<string, bool[]>()
            {
                { "S", new bool[13] },
                { "H", new bool[13] },
                { "C", new bool[13] },
                { "D", new bool[13] },
            };

            int inputNum = int.Parse(Console.ReadLine());

            for (int i = 0; i < inputNum; i++)
            {
                string[] lines = Console.ReadLine().Split(' ');
                string type = lines[0];
                int cardNum = int.Parse(lines[1]);
                cards[type][cardNum - 1] = true;
            }

            foreach (var key in cards.Keys)
            {
                for(int i = 0; i < cards[key].Length; i++)
                {
                    if( cards[key][i])
                        continue;

                    Console.WriteLine("{0} {1}", key, i + 1);
                }
            }

        }
    }
}

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

int main() {
  string s;
  cin >> s;
  if(s[0]=='9' || s[1]=='9'){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
long long k,a,b,ans;
int main(){
	cin>>k>>a>>b;
	if(k+1ll<a)
	{
		cout<<k+1ll;
		return 0;
	}
	if(b-a>2ll)
	{
		k++,k-=a;
		if(k%2ll==1ll)
			cout<<(a+1+((k-1ll)/2ll*(b-a)));
		else
			cout<<(a+k/2ll*(b-a));
	}
	else
	{
		cout<<k+1ll;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <cstring>
#include <vector>

#define p 1000000007

using namespace std;

vector<int> a;
vector<long long int> sum_a;
vector<vector<long long int>> dp;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t = 1;
    while(t--){
        int n,k;
        cin >> n >> k;
        a = vector<int> (n);
        sum_a = vector<long long int> (n+1);
        sum_a[0] = 0;
        dp = vector<vector<long long int>> (n,vector<long long int> (k+1,0));
        for(int i=0 ; i<n ; i++){
            cin >> a[i];
            sum_a[i+1] = sum_a[i] + a[i];
        }
        for(int i=0 ; i<n ; i++){
            for(int sum=0 ; sum<=sum_a[i+1] && sum<=k; sum++){
                if(i==0 || sum==0){
                    dp[i][sum] = 1;
                    continue;
                }
                dp[i][sum] = (dp[i][sum-1] + dp[i-1][sum])%p;
                if(sum-a[i]-1 >=0){
                    dp[i][sum] = (dp[i][sum] - dp[i-1][sum-a[i]-1])%p;
                    if(dp[i][sum] < 0) dp[i][sum] += p;
                }
            }
        }
        cout << dp[n-1][k] << "\n";
    }
    return 0;
}



Measured memory_bytes: 82328
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, atan2
from operator import mul
from functools import reduce
sys.setrecursionlimit(10 ** 9)

INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7



def dijkstra(G, s=0):
    n = len(G)
    que = [(0, s)]
    dist = [INF] * n
    dist[s] = 0
    while que:
        min_dist, u = heappop(que)
        if min_dist > dist[u]:
            continue
        for v, c in enumerate(G[u]):
            if dist[u] + c < dist[v]:
                dist[v] = dist[u] + c
                heappush(que, (dist[u] + c, v))
    return dist


h, w = LI()
G = LIR(10)
G = [i for i in zip(*G)]
dist = dijkstra(G, 1)
A = LIR(h)
ret = 0
for y in range(h):
    for x in range(w):
        if A[y][x] != -1:
            ret += dist[A[y][x]]


print(ret)

Measured memory_bytes: 39920
#include <bits/stdc++.h>
using namespace std;
const int INF=1001001001;
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}
long long f(long long x,long long c,long long d){
    long long res=x;
    res-=x/c;
    res-=x/d;
    res+=x/lcm(c,d);
    return res;
}
int main() {
    long long a,b,c,d;cin>>a>>b>>c>>d;
    long long ans=f(b,c,d)-f(a-1,c,d);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<pll> X;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        ll x;
        cin >> x;
        X.emplace_back(x,i);
    }
    sort(begin(X),end(X));
}

int solve(){
    DBG(X)
    vector<ll> ans(N);
    for (int i = 0; i < N; i++)
    {
        if(i<N/2) ans[X[i].second]=X[N/2].first;
        else ans[X[i].second]=X[(N-1)/2].first;
    }
    for(auto a:ans) cout << a <<"\n";
    
    return 0;
}   

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


Measured memory_bytes: 7788
#include<bits/stdc++.h>
using namespace std;
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define pb push_back
#define F first
#define S second

#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define int long long
#define ll long long
const int M=1e9+7;

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

int expo(int x, int y) {int res=1;x=x%M;while(y>0){if(y&1)res=(1ll*res*x)%M;
	y=y>>1;x=(1ll*x*x)%M;} return res;}
	
bool check(string s){
	int n = s.size();
	for(int i = 0 ; i < n / 2 ; i++){
		if(s[i] != s[n - 1 - i])
			return false;	
	}
	return true;
}
signed main(){
	gearup;
	int t = 1;
	//cin >> t;
	while(t--){
		string s;
		cin >> s;
		if(check(s) && check(s.substr(0, (s.size() - 1) / 2)) && check(s.substr((s.size() - 1) / 2 + 1, s.size() - (s.size() - 1) / 2))){
			cout << "Yes";
		}
		else
			cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main()
{
	int a,c;
	char b,n,m;
	int sum;
	while(scanf("%d",&a)!=EOF)
	{
		scanf("%c",&m);
		scanf("%c",&b);
		scanf("%c",&n);
		scanf("%d",&c);
		if(b==43)
		{
			sum=a+c;
			printf("%d\n",sum);
		}
		else
		{
			sum=a-c;
			printf("%d\n",sum);
		}

	}
	return  0;
}

Measured memory_bytes: 128
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto as = readln.split.to!(long[]);
    auto cs = new long[](N);
    auto ds = new long[](N);
    cs[0] = as[0];
    foreach (i; 1..N) cs[i] = gcd(cs[i-1], as[i]);
    ds[$-1] = as[$-1];
    foreach_reverse (i; 0..N-1) ds[i] = gcd(ds[i+1], as[i]);
    long r = max(ds[1], cs[$-2]);
    foreach (i; 1..N-1) r = max(r, gcd(cs[i-1], ds[i+1]));
    writeln(r);
}

Measured memory_bytes: 7044
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n = int(input())
    p = list(map(int,ipti().split()))

    cnt = 0
    for i in range(n):
        if (i + 1) != p[i]:
            cnt += 1

    if cnt < 3:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
def solve(N,K):
    if 2*K > N+1:
        print(-1)
        return

    def it():

        for i in range((N+1)//2):
            yield (K+i, K+N+i+N//2, K+N*2+i*2)
        for i in range(N//2):
            yield (K+(N+1)//2 + i, K+N+i, K+N*2+i*2+1)

    for a,b,c in it():
        print(a,b,c)

N,K = map(int,input().split())
solve(N,K)

Measured memory_bytes: 48856
#encoding:utf-8 No.0018 2014.10.1
while gets
  ary = $_.chomp.split
  ary.length.times do |i|
    ary[i] = ary[i].to_i
  end

  ary.length.times do |i|
    print "#{ary.sort.reverse[i]}"
    unless i == ary.length - 1 #要するに、出力するのが最後の要素でなければ
      print "\s"
    end
  end
  print "\n"
end

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

using namespace std;


#define PI 3.14159265
#define int long long


main(){


	int n; cin >> n;


	vector <int> a(n), b(n);


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

	int last = 0, znak = 1;

	for(int i = 0; i < n; i++){
		last += znak * a[i];
		znak *= -1;
	}

	// last /= 2;

	for(int i = 0; i < n; i++){
		b[i] = 2 * a[i] - last;
		last = b[i];
	}


	cout << b[n - 1] << " ";
	for(int i = 0; i < n - 1; i++){
		cout << b[i] << " ";
	}
	// cout << b[0] << endl;
	cout << endl;


	return 0;
}

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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    string s;
    cin >> s;
    i64 n = s.size() + 1;

    vector<i64> ans(n);
    for (i64 i = 0; i + 1 < n; i++) {
        if (s[i] == '<') ans[i + 1] = ans[i] + 1;
    }
    for (i64 i = n - 2; i >= 0; i--) {
        if (s[i] == '>') ans[i] = max(ans[i], ans[i + 1] + 1);
    }

    cout << accumulate(begin(ans), end(ans), 0l) << endl;
}

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


Measured memory_bytes: 4764
#include <stdio.h>
int main()
{
  for(;;){
    double d,e,f;
    scanf("%lf",&d);
    if(d < 0) break;
    d *= 16;
    e = (double)((int)d);
    f = d - e;
    if(f != 0){
      printf("NA\n");
    }else{
      int i,j,k;
      i = (int)(e) / 16;
      j = (int)(e) % 16;
      k = 1 << 8;
      if(i > k){
        printf("NA\n");
      }else{
        k >>= 1;
        while(k > 0){
          if((i & k) != 0){
            printf("1");
          }else{
            printf("0");
          }
          k >>= 1;
        }
        printf(".");
        k = 1 << 3;
        while(k > 0){
          if((j & k) != 0){
            printf("1");
          }else{
            printf("0");
          }
          k >>= 1;
        }
        printf("\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 620
#include <stdio.h>
int patition(int a[100000], int p, int r) {
    int x, i, j, tmp;
 
    x = a[r];
    i = p - 1;
    for (j = p; j < r; j++) {
        if (a[j] <= x) {
            i += 1;
            tmp = a[j];
            a[j] = a[i];
            a[i] = tmp;
        }
    }
    tmp = a[i+1];
    a[i+1] = a[r];
    a[r] = tmp;
    return i + 1;
}
 
int main(void) {
    int in[100000], n, i, p;
    const char *fmt = "%d";
 
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", in+i);
    }
    p = patition(in, 0, n-1);
 
    for (i = 0; i < p; i++) {
        printf(fmt, in[i]);
        fmt = " %d";
    }
    printf(" [%d]", in[p]);
    for (i = p+1; i < n; i++) {
        printf(fmt, in[i]);
    }
    putchar('\n');
    return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <cassert>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <math.h>
#include <set>
#include <bitset>
#define MAXN 100000
#define ll long long
using namespace std;


string S[111];
int main() {
    int H,W;
    cin>>H>>W;
    for(int i=0;i<H;i++)
        cin>>S[i];
    
    int ct=0;
    for(int i=0;i<H;i++)
        for(int j=0;j<W;j++)
            ct += (S[i][j]=='#');
    
    if (ct == H+W-1) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
    
}

Measured memory_bytes: 256
//QWsin
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=nxt[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
using namespace std;
inline int read()
{
	char ch=getchar();int ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

typedef long long ll;
const int INF=1<<30;

const int maxn=1000+10;
const int maxm=10000+10;

ll dp[maxn][maxm];

ll a[maxn],b[maxn];

int main()
{
//	freopen("std.in","r",stdin);
	int h,n;cin>>h>>n;
	rep(i,1,n) cin>>a[i]>>b[i];
	memset(dp,1,sizeof dp);
	dp[0][0]=0;
	rep(i,1,n) 
	{
		dp[i][h]=dp[i-1][h];
		for(int j=h-1;j>=0;--j) dp[i][j]=min(dp[i-1][j],dp[i][j+1]);
		rep(j,a[i],h) dp[i][j]=min(dp[i][j],dp[i][j-a[i]]+b[i]);
		rep(j,h-a[i],h) dp[i][h]=min(dp[i][h],dp[i][j]+b[i]);
	}
	cout<<dp[n][h]<<endl;
	return 0;
}


Measured memory_bytes: 79232
using System;
class ProgramB
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int k = int.Parse(input[0]);
            int x = int.Parse(input[1]);

            int min = x - k + 1;

            for(int i = 0; i < 2*k - 1;i++)
            {
                Console.Write(min+i);
                Console.Write(" ");
            }
            
            
        }
    }

Measured memory_bytes: 13140
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

vector<vector<int>> G;

vector<bool> seen, finished;

bool flag = false;

void dfs(int v) {
    seen[v] = true;
    for (auto nv : G[v]) {
        if (finished[nv]) continue;
        if (seen[nv] && !finished[nv]) {
            flag = true;
            continue;
        }
        dfs(nv);
    }
    finished[v] = true;
    return;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    G.resize(N);
    rep(i,M) {
        int s,t; cin >> s >> t;
        G[s].emplace_back(t);
    }

    seen.assign(N, false); finished.assign(N, false);

    rep(i,N) {
        if (finished[i]) continue;
        dfs(i);
    }

    cout << flag << endl;
}


Measured memory_bytes: 3216
n = int(input())
a = input()
b = input()
c = input()
ans = 0

for i in range(n):
    if a[i] == b[i] and b[i] == c[i]:
        continue
    elif (a[i] == b[i] and b[i] != c[i]) or (a[i] == c[i] and c[i] != b[i]) or (b[i] == c[i] and c[i] != a[i]):
        ans += 1
    elif a[i] != b[i] and b[i] != c[i]:
        ans += 2
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
 
int main(void)
{
    ll K;
    cin >> K;
 
    ll mod = 7;
 
    int ans = -1;
    FOR(i,1,K){
        if(mod % K == 0){
            ans = i;
            break;
        }
        mod = (mod*10 + 7) % K;
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n,x;
    cin >> n >> x;
    vector<ll>a(n);
    for(ll i=0;i<n;i++){
        cin >> a[i];
    }
    ll ans=0;
    for(ll i=1;i<n;i++){
        if(a[i-1]+a[i]>x){
            ll k=(a[i]+a[i-1]-x);
            ans+=k;
            a[i]-=k;
            if(a[i]<0) a[i]=0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4004
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    static final int MAX = 100100;
    InputStream in = System.in;
    PrintStream out = System.out;
    // static int dp[][] = new int[MAX][MAX];
    static int p[] = new int[20];

    public void _main(String[] args) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        int cnt=0;
        for (int i=0;i<n;i++) {
            p[i] = sc.nextInt();
        }
        for (int i=1;i<n-1;i++) {
            if (p[i-1] < p[i] && p[i] < p[i+1]) cnt++;
            else if (p[i+1]<p[i]&&p[i]<p[i-1]) cnt++;
        }
        out.println(cnt);
    }

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


Measured memory_bytes: 25172
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int n;
struct node{
	string nm; int sc,id;
	bool operator <(const node &j) const {
		return nm<j.nm||(nm==j.nm&&sc>j.sc);
	}
}re[200010];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		cin>>re[i].nm>>re[i].sc;
		re[i].id=i;
	}
	sort(re+1,re+n+1);
	for(int i=1;i<=n;++i){
		cout<<re[i].id<<endl;
	}
	return 0;
}

Measured memory_bytes: 6656
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        lr: [(usize, usize); n],
    }
    let mut result = 0;
    for (li, ri) in lr {
        result += ri - li + 1;
    }
    println!("{}", result);
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(void)
{
   int a[3][3], n, b[100], i, f, x=0, g;

   for(i=0;i<3;i++)
      for(f=0;f<3;f++)
         scanf("%d",&a[i][f]);
   scanf("%d",&n);
   for(g=0;g<n;g++)
      scanf("%d",&b[g]);


   for(i=0;i<3;i++)
      for(f=0;f<3;f++)
         for(g=0;g<n;g++)
            if(a[i][f]==b[g])
               a[i][f]=-1;

   for(i=0;i<3;i++)
      if((a[i][0]==-1)&&(a[i][1]==-1)&&(a[i][2]==-1)) x=1;

   for(f=0;f<3;f++)
      if((a[0][f]==-1)&&(a[1][f]==-1)&&(a[2][f]==-1)) x=1;

   if((a[0][0]==-1)&&(a[1][1]==-1)&&(a[2][2]==-1)) x=1;

   if((a[0][2]==-1)&&(a[1][1]==-1)&&(a[2][0]==-1)) x=1;

   if(x==1)
      printf("Yes\n");

   else
      printf("No\n");

   return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;
import java.util.function.IntPredicate;
 
public class Main{
	int N, K;
	int[] A;
	public void solve(){
		N = nextInt();
		K = nextInt();
		A = new int[N];
		for(int i = 0; i < N; i++){
			A[i] = nextInt();
		}
		int ans = 0;
		boolean[][] a1 = new boolean[N][K];
		boolean[][] a2 = new boolean[N][K];
 
 
		a1[0][0] = true;
		for(int i = 0; i < N - 1; i++){
			for(int j = 0; j < K; j++){
				if(a1[i][j]){
					a1[i + 1][j] = true;
					if(j + A[i] < K){
						a1[i + 1][j + A[i]] = true;
					}
				}
			}
		}
		
		a2[N - 1][0] = true;
		for(int i = N - 1; i > 0; i--){
			for(int j = 0; j < K; j++){
				if(a2[i][j]){
					a2[i - 1][j] = true;
					if(j + A[i] < K){
						a2[i - 1][j + A[i]] = true;
					}
				}
			}
		}
		
 
		int[][] bit2 = new int[N][K + 1];
		
		for(int i = 0; i < N; i++){
			for(int j = 0; j < K; j++){
				bit2[i][j + 1] = bit2[i][j];
				if(a2[i][j]){
					bit2[i][j + 1]++;
				}
			}
		}
		
		
		for(int i = 0; i < N; i++){
			if(A[i] >= K) continue;
			int kk = K - A[i];
			boolean flg = false;
			for(int j = 0; j < K; j++){
				if(a1[i][j]){
					if(bit2[i][K - j] - bit2[i][Math.max(kk - j, 0)] > 0){
						flg = true;
						break;
					}
				}
			}
			if(!flg){
				ans++;
			}
		}
		out.println(ans);
		
	}
	

	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

Measured memory_bytes: 244404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    int D[N][2];
    for (int i = 0; i < N; i++) {
        cin >> D[i][0] >> D[i][1];
    }
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (D[i][0] == D[i][1]) cnt++;
        else cnt = 0;
        if (cnt == 3) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3640
h,w,n = map(int, input().split())

# 黒マス black[y座標] = [x1,x2,...]
black = dict()

# 周囲に黒マスがあるマス
search = set()

for i in range(n):
    a,b = map(int, input().split())
    a-=1
    b-=1
    for x in [-1,0,1]:
        for y in [-1,0,1]:
            if 1<=a+y<h-1 and 1<=b+x<w-1:
                search.add((a+y,b+x))  # タプル。set()内にリストは格納できない。
    try:
        black[a][b]=1
    except:
        black[a]=dict()
        black[a][b]=1


ans = [0]*10
# 探索すべき全マスに対して、周囲の黒マスの数を数える。
for a,b in search:
    p = 0
    for y in [-1,0,1]:
        for x in [-1,0,1]:
            try:
                if black[a+y][b+x]==1:
                    p+=1
            except:
                continue
    ans[p]+=1
ans[0]=(h-2)*(w-2)-sum(ans[1:])

for a in ans:
    print(a)

Measured memory_bytes: 141560
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        
        int[] num = new int[3];
        num[0] = stdIn.nextInt();
        num[1] = stdIn.nextInt();
        num[2] = stdIn.nextInt();
        
        do {
            if (num[0] > num[1]) {
                int n = num[0];
                num[0] = num[1];
                num[1] = n;
            } else if (num[1] > num[2]) {
                int m = num[1];
                num[1] = num[2];
                num[2] = m;
            } else {
            }
            } while(!(num[0]<=num[1] && num[1]<=num[2]));
            
            System.out.println(num[0]+" "+num[1]+" "+num[2]);
    }
}

Measured memory_bytes: 26240
nm, left = map(int, input().split())
shops = []
for _ in range(nm):
    shops.append([int(x) for x in input().split()])
shops.sort(key=lambda x: x[0])
#print(shops)
total_cost = 0
for cost, stock in shops:
    if stock >= left:
        print(total_cost + cost * left)
        exit(0)
    else:
        left = left - stock
        total_cost += cost * stock
        #print("current : " + str(total_cost))


Measured memory_bytes: 22748
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#define MAX_V 100010

using namespace std;
vector<int> G[MAX_V];
int V;
priority_queue<int> que[MAX_V];

int dfs(int s, int p){
	for(int i=0;i<G[s].size();i++){
		if(G[s][i]!=p){
			que[s].push(dfs(G[s][i],s));
		}
	}
	int j=0,ans = 0;
	while(!que[s].empty()){
		j++;
		int e = que[s].top();
		que[s].pop();
		ans = max(ans,e+j);
	}
	return ans;
}

int main(){
	int i,j,s;
	cin >> V;
	for(i=1;i<=V-1;i++){
		cin >> s ;
		s--; 
		G[s].push_back(i);
		G[i].push_back(s);
	}
	
	cout << dfs(0,0) << endl;;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n;
  ll q,h,s,d;
  cin>>q>>h>>s>>d;
  cin>>n;
  
  vll v(4);
  v[0]=q;
  v[1]=min(h,v[0]*2);
  v[2]=min(s,v[1]*2);
  v[3]=min(d,v[2]*2);
  
  n*=4;
  ll ans = n/8*v[3]+n%8/4*v[2]+n%4/2*v[1]+n%2*v[0];
  cout<<ans<<endl;
  
  
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    const int cost[9] = {2, 5, 5, 4, 5, 6, 3, 7, 6};

    int n, m;
    cin >> n >> m;
    vs32 a(m);
    rep (i, m)
    {
        cin >> a[i];
        --a[i];
    }

    s64 dp[n + 1];
    rep (i, n + 1) dp[i] = -1;
    dp[0] = 0;

    rep (i, n)
    {
        rep (j, m)
        {
            if (i + cost[a[j]] <= n && dp[i] >= 0)
            {
                dp[i + cost[a[j]]] = MAX(dp[i + cost[a[j]]], dp[i] + 1);
            }
        }
    }

    string ans = "";
    int idx = n;
    while (idx != 0)
    {
        int temp = 0;
        rep (i, m)
        {
            if (dp[idx] == 1)
            {
                if (idx - cost[a[i]] == 0)
                {
                    temp = MAX(temp, a[i] + 1);
                }
            }
            else if (idx - cost[a[i]] > 0 && dp[idx] == dp[idx - cost[a[i]]] + 1)
            {
                temp = MAX(temp, a[i] + 1);                
            }
        }
        ans += to_string(temp);
        idx -= cost[temp - 1];
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>

using namespace std;
#define REP(i,m,n) for(long long i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

vector<vector<int>>now(20), vf(150), p(150);

int main() {
	int n;
	cin >> n;
	REP(i, 0, n) {
		REP(j, 0, 10) {
			int tmp;
			cin >> tmp;
			vf[i].push_back(tmp);
		}
	}
	REP(i, 0, n) {
		REP(j, 0, 11) {
			int tmp;
			cin >> tmp;
			p[i].push_back(tmp);
		}
	}
	int ans = -2000000000;
	REP(a, 0, 2) {
		REP(b, 0, 2) {
			REP(c, 0, 2) {
				REP(d, 0, 2) {
					REP(e, 0, 2) {
						REP(f, 0, 2) {
							REP(g, 0, 2) {
								REP(h, 0, 2) {
									REP(i, 0, 2) {
										REP(j, 0, 2) {
											if (a == 0 && b == 0 && c == 0 && d == 0 && e == 0 && f == 0 && g == 0 && h == 0 && i == 0 && j == 0) {
												break;
											}
											int hoge = 0;
											REP(k, 0, n) {
												hoge += p[k][a*vf[k][0] + b*vf[k][1] + c*vf[k][2] + d*vf[k][3] + e*vf[k][4] + f*vf[k][5] + g*vf[k][6] + h*vf[k][7] + i*vf[k][8] + j*vf[k][9]];
											}
											ans = max(ans, hoge);
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int n;
  bool s[30];

  fill(s, s+30, true);

  for(int i = 0; i < 28; i++) {
    cin >> n;
    s[n-1] = false;
  }

  for(int i = 0; i < 30; i++) {
    if(s[i]) cout << i+1 << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
string s;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>s;
    int n=s.length();
    int pos=0;
    ll a=0, b=0;
    ll ans=0;
    while(pos<n){
        while(pos<n&&s[pos]=='A'){
            a++;
            pos++;
        }
        while(pos<n-1&&s[pos]=='B'&&s[pos+1]=='C'){
            b++;
            pos+=2;
        }
        ans+=a*b;
        if(s[pos]!='A'){
            a=0;
            pos++;
        }
        b=0;
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 999999999;



int main()
{
     
  
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n;
    cin>>n;
    ll st = 1;
    ll count = 0;
    while(st<=n)
    {
        if(st%3==0 && st%5==0)
        {
            st++;
        }
        else if(st%3 == 0 || st%5==0)
            st++;
        else
        {
            //cout<<st<<endl;
            count = count + st;
            st++;
            
        }

    }
    cout<<count<<endl;
    return 0;
}

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

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    //int t=1 ; cin>>t ; while(t--)
    {
    	char c;
    	cin >> c;
    	c++;
    	cout << c;
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int[] A = new int[N+2];
		int sum = 0;
		A[N+1] = 0;
		A[0] = 0;
		for (int i = 1; i <= N; i++) {
			A[i] = reader.nextInt();
			sum += Math.abs(A[i-1] - A[i]);
		}
		sum += Math.abs(A[N] - A[N+1]);

		for (int i = 1; i <= N; i++) {
			int ans = sum;
			ans -= Math.abs(A[i-1] - A[i]);
			ans -= Math.abs(A[i+1] - A[i]);
			ans += Math.abs(A[i+1] - A[i-1]);
			System.out.println(ans);
		}
	}
}



Measured memory_bytes: 70084
def print_list(l):
    print(' '.join(map(str, l)))


n = int(input())
l = list(map(int, input().split()))

print_list(l)

for i in range(1, n):
    v = l[i]
    j = i - 1
    while j >= 0 and l[j] > v:
        l[j + 1] = l[j]
        j -= 1
    l[j + 1] = v
    print_list(l)



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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

ll pow_mod(ll n, ll k, ll m) {
    if (k == 0) {
        return 1;
    } else if (k%2) {
        return pow_mod(n, k-1, m) * n % m;
    } else {
        ll t = pow_mod(n, k/2, m);
        return t*t%m;
    }
}

ll comb(ll n, ll r) {
    ll ans = 1;

    for (ll i = n; i > n-r; i--) {
        ans = ans*i%MOD;
    }
    for (ll i = 1; i < r+1; i++) {
        ans = ans*pow_mod(i, MOD-2, MOD) % MOD;
    }

    return ans%MOD;
}

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll X, Y;
    cin >> X >> Y;

    if ((X+Y)%3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    ll n, m;
    n = (2*Y-X)/3;
    m = (2*X-Y)/3;
    if (n < 0 || m < 0) {
        cout << 0 << endl;
        return 0;
    }

    if (n < m) {
        swap(n, m);
    }

    n += m;

    cout << comb(n, m) << endl;
    return 0;
}

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

namespace _2006
{
    class Program
    {
        static void Main(string[] args)
        {
            List<char[]> letters = new List<char[]>
            {
                new char[]{'.',',','!','?',' ', },
                new char[]{'a','b','c', },
                new char[]{'d','e','f', },
                new char[]{'g','h','i', },
                new char[]{'j','k','l', },
                new char[]{'m','n','o', },
                new char[]{'p','q','r','s', },
                new char[]{'t','u','v', },
                new char[]{'w','x','y','z', },
            };
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                string s = Console.ReadLine(); int ret = -1; int count = -1;
                for (int j = 0; j < s.Length; j++)
                {
                    if (s[j] == '0' && ret != -1)
                    {
                        Console.Write(letters[ret][count % letters[ret].Count()]);
                        ret = -1; count = -1;
                    }
                    else if (s[j] != '0')
                    {
                        ret = int.Parse(s[j].ToString()) - 1; count++;
                    }
                }
                Console.WriteLine();
            }
        }
    }
}


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

int N;
ll a[100005];
vector<int> g[100005];
vector<int> G[100005];

vector<int> T;
int root=-1;
int parent[100005];
ll dp[100005];

void init(int pos,int prev=-1){
  parent[pos]=prev;
  for(int to:g[pos]){
    if(to==prev)continue;
    G[pos].push_back(to);
    init(to,pos);
  }
  T.push_back(pos);
}

bool solve(){
  if(N==2)return (a[0]==a[1]);
  
  for(int i=0;i<N;i++)if(g[i].size()>1)root=i;
  init(root);
  
  for(int v:T){
    if(v==root){
      vector<ll> t;
      ll sum=0;
      for(int child:G[v]){
        sum+=dp[child];
        t.push_back(dp[child]);
      }
      sort(t.begin(),t.end());
      reverse(t.begin(),t.end());

      int match;
      if(t[0] > sum-t[0]){
        match=sum-t[0];
      }else{
        match=sum/2;
      }
      if(match*2==sum&&match==a[v])return true;
      else return false;
      continue;
    }
    
    if(G[v].size()==0){
      dp[v]=a[v];
      if(a[v]!=dp[v])return false;
      continue;
    }
    if(G[v].size()==1){
      dp[v]=dp[ G[v].back() ];
      if(a[v]!=dp[v])return false;
      continue;
    }

    vector<ll> t;
    ll sum=0;
    for(int child:G[v]){
      sum+=dp[child];
      t.push_back(dp[child]);
    }
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());

    int match;
    if(t[0] > sum-t[0]){
      match=sum-t[0];
    }else{
      match=sum/2;
    }

    ll M=sum-a[v];
    ll U=a[v]-M;
    if(M>match || U<0 || U>sum || M<0 || M*2>sum)return false;

    dp[v]=U;
  }

  return true;
}

int main(){
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  for(int i=0;i<N-1;i++){
    int from,to;
    cin>>from>>to;
    from--,to--;
    g[from].push_back(to);
    g[to].push_back(from);
  }
  cout<< (solve()?"YES":"NO") <<endl;
  return 0;
}


Measured memory_bytes: 19196
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iterator>
#include <list>
#include <stack>
#include <queue>
#include <memory>
#include <ctime>
#include <bitset>
#include <map>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i = 0; i < n; i++)
#define MSG(a)	cout << #a << " " << a << endl;

int main()
{
	//ifstream ifs("2009-ho-data/data/2009-ho-t1-in2");
	int n;
	while( cin >> n && n)
	{
		int			l, ans = 0;
		string		s;
		vector<ll>	I, O;

		cin >> l >> s;

		rep(i,l) I.push_back(s[i] == 'I' ? i < 2 ? s[i] == 'I' ? 1 : 0 : I[i-2]+1 : 0);
		rep(i,l) O.push_back(s[i] == 'O' ? i < 2 ? s[i] == 'O' ? 1 : 0 : O[i-2]+1 : 0);

		rep(i,l-2*n) if(O[i+2*n-1] >= n && I[i+2*n] >= n+1) ans++;
		
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef struct node{
    int n;
    int flag;
    struct node* next[8];
}node;

void reset(node* target){
    for(int i=0; i<8; i++){
        target->next[i] = NULL;
    }
}

int t[8][8];

int func(node* target, int n){
    if((target->flag & n) == n){
        return 1;
    }
    int x = 0;
    for(int i=0; i<8; i++){
        if(t[target->n][i]){
            if((target->flag & (int)pow(2, i)) == 0){
                target->next[x] = (node*)malloc(sizeof(node));
                target->next[x]->n = i;
                target->next[x]->flag = target->flag + (int)pow(2,i);
                reset(target->next[x]);
                x++;
            }
        }
    }
    int sum = 0, y = 0;
    while(target->next[y] != NULL){
        sum += func(target->next[y], n);
        y++;
    }
    return sum;
}

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i=0; i<8; i++){
        for(int j=0; j<8; j++){
            t[i][j] = 0;
        }
    }
    for(int i=0; i<m; i++){
        int a, b;
        scanf("%d%d", &a, &b);
        a--;
        b--;
        t[a][b] = 1;
        t[b][a] = 1;
    }
    node root;
    root.n = 0;
    root.flag = 1;
    reset(&root);
    printf("%d", func(&root, (int)pow(2, n)-1));

    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int X;
    cin>>X;
    if(X>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3588
import java.io.*;
import java.util.*;
public class Main
{
            public static void main(String args[]) throws Exception
            {
                    Scanner cin=new Scanner(System.in);
                    int a=cin.nextInt(),b=cin.nextInt();
                    System.out.println(GCD(a,b));
            }
					public static  int GCD(int a, int b) {
						if (b==0) return a;
						return GCD(b,a%b);
					}
}


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

using namespace std;

int main() {
	int n;
	cin >> n;

	vector < int > w (n), sum (n + 1);

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

	sum[0] = 0;

	for (int i = 0; i < n; i++) {
		sum[i + 1] = sum[i] + w[i];
	}

	int ans = 100000;

	for (int i = 0; i < n; i++) {
		int a, b;
		a = sum[i];
		b = sum[n - 1];
		ans = min (abs (sum[i] - (sum[n] - sum[i])), ans);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
// By Atul Rathore

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

#define ll long long int
#define f(n) for(int i=0;i<n;i++)
#define p(x) cout<<x<<endl;
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007



int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio;

	int a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k <= a)cout << k;
	else if (k > a && k <= a + b)cout << a;
	else
	{
		cout << 2 * (a) - k + b;
	}

}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, k, n) for (int i = k; i < n; ++i)
#define fore(i,a) for (auto &i : a)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

template<typename T> T my_gcd(T a, T b) {
    return (a ? my_gcd(b % a, a) : b);
}

signed main (int argc, char *argv[]) {
    int n;
    cin >> n;
    vector<int> A(n);
    rep(i, n) cin >> A[i];

    vector<int> gcd_from_left, gcd_from_right;
    gcd_from_left.push_back(A[0]), gcd_from_right.push_back(A[n - 1]);
    for (int i = 1; i < n; ++i) {
        gcd_from_left.push_back(my_gcd(A[i], gcd_from_left[i - 1]));
        gcd_from_right.push_back(my_gcd(A[n - 1 - i], gcd_from_right[i - 1]));
    }

    priority_queue<int> gcds;
    int left = -1, right = n - 2;
    rep(_, n + 1) {
        if (left == -1) {
            gcds.push(gcd_from_right[right]);
        } else if (right == -1) {
            gcds.push(gcd_from_left[left]);
        } else {
            gcds.push(my_gcd(gcd_from_left[left], gcd_from_right[right]));
        }
        ++left, --right;
    }

    cout << gcds.top() << endl;
    
    return 0;
}

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

    int f(vector<int> v,int n,vector<int> &dp,int k)
    {
        dp[0]=0;
        dp[1]=abs(v[1]-v[0]);
        for (int i=2;i<n;i++)
            for (int j=i-1;j>=max(i-k,0);j--)
                dp[i]=min(dp[j]+abs(v[i]-v[j]),dp[i]);
        return dp[n-1];
    }

    int main()
    {
        int n,k;
        cin >> n >> k;
        vector<int> v(n);
        const int g=1e9;
        vector<int> dp(n+1,g);
        for (int i=0;i<n;i++)
            cin >> v[i];
        cout << f(v,n,dp,k);
    }

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main (int argc, const char * argv[])
{
    int a,b,c;
    cin >>a >>b>>c;
    if (a<b&&b<c){
        cout << "Yes"<<endl;
    } else {
        cout <<"No"<<endl;
    }
    // insert code here...
    //std::cout << "Hello, World!\n";
    return 0;
}

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

int main() {
  while(1) {
    string a, str;
    cin >> a;
    if(a=="#")break;

    for(int i=0;i<a.size();i++) 
      if(a[i] == 'w' || a[i] == 'n' ) str += a[i];

    int size = str.size();
    int ans = 0;
    for(int i=0;i<size;i++)
      if(str[i] == 'w')  ans += (1<<i)*90;
      else ans -= (1<<i)*90;

    size--;

    if(ans < 0 ) ans = (1<<size)*90+ans;
    while(size != 0) 
      if( ans % 2 == 0 ) ans /= 2,size--;
      else break;

    if(size == 0) cout << ans << endl;
    else cout << ans << "/" << (1<<size) << endl;

  }

  return 0;
}

Measured memory_bytes: 1196