akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int INF = 1<<29;

int dp[150][10][77];
int stones[150][10][2];
int col[150];

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  while (true) {
    int N, M;
    cin >> N >> M;
    if (N == 0 && M == 0) break;
  
    REP(i, N) {
      cin >> col[i];
      REP(j, col[i]) {
	cin >> stones[i][j][0] >> stones[i][j][1];
      }
    }

    REP(i, N) REP(j, col[i]) REP(k, M+1) dp[i][j][k] = INF;
    REP(j, col[0]) dp[0][j][0] = 0;
    REP(j, col[1]) dp[1][j][1] = 0;
    REP(i, N-1) {
      REP(j, col[i]) {
	int x_now = stones[i][j][0], d_now = stones[i][j][1];
	REP(m, M+1) {
	  if (dp[i][j][m] == INF) continue;
	  REP(k, col[i+1]) {
	    dp[i+1][k][m] = min(dp[i+1][k][m], dp[i][j][m] + (d_now + stones[i+1][k][1]) * abs(x_now - stones[i+1][k][0]));
	  }
	  if (i < N-2 && m < M) {
	    REP(k, col[i+2]) {
	      dp[i+2][k][m+1] = min(dp[i+2][k][m+1], dp[i][j][m] + (d_now + stones[i+2][k][1]) * abs(x_now - stones[i+2][k][0]));
	    }
	  }
	}
      }
    }

    int ans = INF;
    REP(j, col[N-1]) REP(m, M+1) ans = min(ans, dp[N-1][j][m]);
    REP(j, col[N-2]) REP(m, M) ans = min(ans, dp[N-2][j][m]);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	char c; cin>>c;
	if(isupper(c)) {
		cout<<"A"<<endl;
	}
	else{
		cout<<"a"<<endl;
	}




	return 0;
}


Measured memory_bytes: 3628
numero = int(input())
numerostr = input().split(" ")
numeros=[]
for q in numerostr:
    numeros.append(int(q))
minimo=max(numeros)
for i in range(1,numero+1):
    k = abs(sum(numeros[:i])-sum(numeros[i:]))
    if k < minimo:
        minimo=k
print(minimo)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    int x, y;
    cin >> x >> y;
    cout << 6/(x*y) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <cmath>
#define PI 3.14159265359
using namespace std;

int main()
{
	int m;
	char s[4][100001];
	char ox[100001];
	cin >> m;
	for (int i = 0; i < m; ++i) {
		cin >> ox[i];
	}

	if (ox[0] == 'o') {
		s[0][0] = 'S';
		s[0][1] = 'S';
		s[1][0] = 'S';
		s[1][1] = 'W';
		s[2][0] = 'W';
		s[2][1] = 'W';
		s[3][0] = 'W';
		s[3][1] = 'S';
	}
	if (ox[0] == 'x') {
		s[0][0] = 'S';
		s[0][1] = 'W';
		s[1][0] = 'S';
		s[1][1] = 'S';
		s[2][0] = 'W';
		s[2][1] = 'S';
		s[3][0] = 'W';
		s[3][1] = 'W';
	}
	int i = m - 1;
	for (int n = 0; n < 4; ++n) {
		for (i = 1; i < m; ++i) {
			if (ox[i] == 'x'&&s[n][i] == 'S'&&s[n][i - 1] == 'W')s[n][i + 1] = 'S';
			else if (ox[i] == 'x'&&s[n][i] == 'S'&&s[n][i - 1] == 'S')s[n][i + 1] = 'W';
			else if (ox[i] == 'o'&&s[n][i] == 'S'&&s[n][i - 1] == 'S')s[n][i + 1] = 'S';
			else if (ox[i] == 'o'&&s[n][i] == 'S'&&s[n][i - 1] == 'W')s[n][i + 1] = 'W';
			else if (ox[i] == 'o'&&s[n][i] == 'W'&&s[n][i - 1] == 'S')s[n][i + 1] = 'W';
			else if (ox[i] == 'o'&&s[n][i] == 'W'&&s[n][i - 1] == 'W')s[n][i + 1] = 'S';
			else if (ox[i] == 'x'&&s[n][i] == 'W'&&s[n][i - 1] == 'S')s[n][i + 1] = 'S';
			else if (ox[i] == 'x'&&s[n][i] == 'W'&&s[n][i - 1] == 'W')s[n][i + 1] = 'W';
		}
		if (s[n][i] == s[n][0] && ((s[n][0] == 'S'&&ox[0] == 'o' &&s[n][1] == s[n][m - 1]) || (s[n][0] == 'S'&&ox[0] == 'x'&&s[n][1] != s[n][m - 1]) || (s[n][0] == 'W'&&ox[0] == 'x'&&s[n][1] == s[n][m - 1]) || (s[n][0] == 'W'&&ox[0] == 'o'&&s[n][1] != s[n][m - 1]))) {
			for (int j = 0; j < m; ++j) {
				cout << s[n][j];
			}
			cout << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 768
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
import java.util.stream.LongStream;
import java.util.Scanner;
import java.util.OptionalInt;

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

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] a = new int[N];
            for (int i = 0; i < N; i++) {
                a[i] = in.nextInt();
            }

            int min = Arrays.stream(a).min().getAsInt();
            int max = Arrays.stream(a).max().getAsInt();
            long cost = Long.MAX_VALUE;
            for (int i = min; i <= max; i++) {
                final int y = i;
                long temp = Arrays.stream(a).mapToLong(x -> (long) Math.pow(x - y, 2)).sum();
                cost = Math.min(cost, temp);
            }
            out.println(cost);
        }

    }
}



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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';
/*
struct BinaryIndexedTree {
private:
    int n,b;
    vector<int> bit;
public:
    BinaryIndexedTree(int n_) {
        n = n_+10;
        b = 1;
        while (b < n) b <<= 1;
        b >>= 1;
        bit = vector<int>(n,0);
    }

    void add(int a,int w) {
        a++;
        for (int x = a;x < n;x += x&-x) bit[x] += w;
    }

    int sum(int a) {
        a++;
        int ret = 0;
        for (int x = a;x > 0;x -= x&-x) ret += bit[x];
        return ret;
    }

    void update(int a,int w) {
        // a++;
        int v = w-sum(a)+sum(a-1);
        add(a,v);
    }

    int lower_bound(int w) {
        if (w <= 0) return 0;
        int x = 0;
        for (int k = b;k > 0;k /= 2) {
            if (x+k < n && bit[x+k] < w) {
                w -= bit[x+k];
                x += k;
            }
        }
        return x;
    }
};*/

struct UnionFind {
private:
    vector<int> par,sizes;
public:
    UnionFind (int n) {
        par.resize(n);
        sizes = vector<int>(n,1);
        for (int i = 0;i < n;++i) par[i] = i;
    }

    int find(int x) {
        if (par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x,int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (sizes[x] < sizes[y]) swap(x,y);
        par[y] = x;
        sizes[x] += sizes[y];
    }

    bool same(int x,int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return sizes[find(x)];
    }
};

int main() {
    int n;
    cin >> n;
    vector<pair<int,P>> c(n);
    for (int i = 0;i < n;++i) cin >> c[i].first >> c[i].second.first;
    for (int i = 0;i < n;++i) c[i].second.second = i;
    sort(c.begin(),c.end());
    set<P> st;
    UnionFind uf(n);
    for (int i = 0;i < n;++i) {
        if (st.empty() || st.begin()->first > c[i].second.first) {
            st.insert(c[i].second);
        } else {
            P b = *st.begin();
            auto it = st.begin();
            while (!st.empty() && it->first < c[i].second.first) {
                uf.unite(it->second,c[i].second.second);
                it = st.erase(it);
            }
            st.insert(b);
        }
    }
    for (int i = 0;i < n;++i) cout << uf.size(i) << newl;   
}

Measured memory_bytes: 11472
from itertools import accumulate as acc

H, W, K = map(int, input().split())
S = [list(map(int, list(input()))) for _ in range(H)]

acc_list = [list(acc([0] + s)) for s in S]

def solve(l, x, limit):
    part_num = len(l)-1
    ok, ng = x, W+1
    while abs(ok-ng) > 1:
        mid = (ok+ng)//2
        score = 0
        for i in range(part_num):
            s = 0
            for j in range(l[i], l[i+1]):
                # print(i, j, mid)
                s += acc_list[j][mid] - acc_list[j][x]
            score = max(s, score)
        if score <= limit:
            ok = mid
        else:
            ng = mid
    return ok

min_num = 10**18
for i in range(1<<(H-1)):
    l = []
    for j in range(H-1):
        if (i>>j)&1:
            l.append(j+1)
    h_split_num = len(l)
    l = [0] + l + [H]
    x = solve(l, 0, K)
    w_split_num = 0
    flag = True
    while x < W:
        w_split_num += 1
        r = solve(l, x, K)
        if x == r:
            flag = False
            break
        x = r
    if flag:
        split_num = w_split_num + h_split_num
        min_num = min(split_num, min_num)

print(min_num)


Measured memory_bytes: 9356
import java.util.*;

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

      
		for(int i=0; i<n ;i++){
          a[i] = sc.nextInt();
        }
      Arrays.sort(a, Comparator.reverseOrder());
            int x = a[0]/2;
      	for(int i=1; i<n ;i++){
          x= x+a[i] ;
        }
      System.out.println(x);
      
    }
}

Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();

        String result;
        if(a > b) {
            result = "a > b";
        } else if(a < b) {
            result = "a < b";
        } else {
            result = "a == b";
        }

        System.out.println(result);
    }

}

Measured memory_bytes: 17228
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    private static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(final String[] args) throws IOException {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out, true);

        int n = in.nextInt();
        int[] dp = new int[n + 1];

        for (int x = 1; x <= n; x++) {
            for (int y = 1; y <= n; y++) {
                for (int z = 1; z <= n; z++) {
                    int value = (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
                    if (value > n) {
                        break;
                    }
                    dp[value]++;
                }
            }
        }

        for (int i = 1; i <= n; i++) {
            out.println(dp[i]);
        }
    }
}


Measured memory_bytes: 35084
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    int cx = 0, cy = 0, ct = 0;
    bool ok = true;
    rep(_, n){
        int x, y, t; cin >> t >> x >> y;

        int d = abs(x - cx) + abs(y - cy);
        int dt = t - ct;
        if(d > dt or (dt - d) % 2 == 1){
            ok = false;
        }
        cx = x, cy = y, ct = t;
    }

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

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;

int main()
{
  int n,k;
  cin >> n >> k;
  rep(i,n+1) {
    if(i*2+(n - i)*4 == k){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No"<< endl;
  return 0;
}


Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll k;
    cin >> k;
    string s;
    cin >> s;
    ll n = s.size();
    if (n <= k) {
        cout << s << endl;
        return 0;
    }
    REP(i, k) {
        cout << s[i];
    }
    cout << "..." << endl;
    return 0;
}

Measured memory_bytes: 3664
package main

import "fmt"

func main() {
	var N int
	var s string
	fmt.Scanln(&N)
	fmt.Scanln(&s)

	r := 0
	b := 0
	for i := 0; i < N; i++ {
		if s[i] == 'R' {
			r++
		} else {
			b++
		}
	}

	if r > b {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <string>


using namespace std;


int main()
{
    string s;
    long int K;
    cin >> s >> K;


    int len = (int)(s.length());

    for( int i = 0; 0 < K && i < len; ++i ){
        if( s[i] == 'a' ) continue;

        int cost = ('z' - s[i]) % 'z' + 1;
        //cout << "cost:" << cost << " K:" << K;
        if( cost <= K ){
            K -= cost;
            s.replace(i, 1, "a");
        }
        //cout << " s:" << s << endl;
    }

    //cout << "K:" << K << endl;

    if( 0 < K ){
        s[len-1] = ((s[len-1] - 'a') + K) % 26 + 'a';
        /*
        if( len == 1 ){
            s[0] = ((s[0] - 'a') + K) % 26 + 'a';
        } else {
            for( int i = len - 1; 0 < K && -1 < i; --i ){
                //if( s[i] == 'a' ) continue;

                int cost = K;
                //cout << "*cost:" << cost << " K:" << K;
                K -= cost;
                s[i] += cost;

                //cout << "*cost:" << cost << " K:" << K << " s:" << s << endl;
            }
        }
        */
    }


    cout << s << endl;


    return 0;
}

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

#define MOD 1000000007
typedef long long ll;

#define rep(i, n) for(i=0;i<(int)(n);i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define bit(n) (1LL<<(n))
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(void){
  int an,bn,m,i,result=999999,price,amin,bmin;
  int a[200001], b[200001], x[200001], y[200001],c[200001];
  scanf("%d %d %d", &an, &bn, &m);
  
  for(i=0;i<an;i++) scanf("%d", &a[i]);
  
  for(i=0;i<bn;i++) scanf("%d", &b[i]);
  
  for(i=0;i<m;i++) scanf("%d %d %d", &x[i], &y[i], &c[i]);
  
  amin = a[0];
  bmin = b[0];
  for(i=1;i<an;i++) amin = min(amin, a[i]);
  for(i=1;i<bn;i++) bmin = min(bmin, b[i]);
  
  result = amin + bmin;
  
  for(i=0;i<m;i++){
    //set wari
    price = a[x[i]-1] + b[y[i]-1] - c[i];
    result = min(price, result);
  }
  
  printf("%d", result);
  
  return 0;
}



Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main() {

    int D, N;
    cin >> D >> N;

    if(N == 100)
        ++N;
    if(D == 0)
        cout << N << "\n";
    else if (D == 1)
        cout << N << "00\n";
    else
        cout << N * 10000<< "\n";
    
    return 0;
}

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

typedef long long ll;
int mod = 2019;

int sum[200005],num[3000];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string a = " ",b;
	cin >> b;
	a += b;
	int base = 1;
	for (int i = a.length() - 1; i >= 1; i--)
	{
		sum[i] = sum[i+1];
		int t = a[i] - '0';
		sum[i] += t * base;
		sum[i] %= mod;
		base *= 10;
		base %= mod;
	}
	ll ans = 0;
	for (int i = a.length() - 1; i >= 1; i--)
	{
		if( sum[i] == 0 ) ans++;
		ans += num[sum[i]];
		num[sum[i]] ++;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 4080
#include <algorithm>
#include <cstdio>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
long long arr[45], x[1005], y[1005];
int main()
{
	// freopen("ARC103-D.in", "r", stdin);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%lld%lld", x + i, y + i);
		if ((x[i] + y[i] ^ x[0] + y[0]) & 1)
		{
			puts("-1");
			return 0;
		}
	}
	int m = 40;
	arr[0] = arr[1] = arr[2] = arr[3] = 1;
	for (int i = 4; i < m; i++)
		arr[i] = arr[i - 1] << 1;
	std::reverse(arr, arr + m);
	if (x[0] + y[0] & 1)
		m--;
	printf("%d\n", m);
	for (int i = 0; i < m; i++)
		printf("%lld%c", arr[i], " \n"[i + 1 == m]);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			if (my_abs(y[i]) >= my_abs(x[i]))
			{
				putchar(y[i] >= 0 ? 'U' : 'D');
				y[i] += arr[j] * (y[i] >= 0 ? -1 : 1);
			}
			else
			{
				putchar(x[i] >= 0 ? 'R' : 'L');
				x[i] += arr[j] * (x[i] >= 0 ? -1 : 1);
			}
		}
		puts("");
	}
	return 0;
}


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

using namespace std;
vector<vector<pair<int,int>>> adj(100005);
int colors[100005];
int vis[100005];
void dfs(int cur){
    vis[cur]=1;
    for(int i=0;i<adj[cur].size();i++){
        int w=adj[cur][i].second;
        int to=adj[cur][i].first;
        if(w%2==0){
            colors[to]=colors[cur];
        }
        else{
            colors[to]=(!colors[cur]);
        }
        if(!vis[to]){
            dfs(to);
        }
    }
}

int main() {
    //freopen("sample-8.in", "r", stdin);
    //freopen("output8.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int u,v,w;
        cin>>u>>v>>w;
        adj[u].push_back({v,w});
        adj[v].push_back({u,w});
    }
    dfs(1);
    for(int i=1;i<=n;i++){
        cout<<colors[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 7936
def solve():
  while True:
    n = int(input())
    if not n: break
    m = int(input())
    s = input()
    ind = 0
    ans = 0
    while ind < m:
      if s[ind] == "I":
        count = 0
        while ind + 2 < m:
          if s[ind + 1] == "O" and s[ind + 2] == "I":
            count += 1
            ind += 2
          else:
            break
        if count - n + 1 >= 0:
          ans += (count - n + 1)
      ind += 1
    print(ans)
solve()


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

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
  int i,j,k,n;
  char in[3];
  int res[4];

  rep(i,3) in[i] = '\0';
  rep(i,4) res[i] = 0;
  while(scanf("%d,%s\n",&k,&in) != EOF){
    if(strcmp(in,"A") == 0) res[0]++;
    if(strcmp(in,"B") == 0) res[1]++;
    if(strcmp(in,"AB") == 0) res[2]++;
    if(strcmp(in,"O") == 0) res[3]++;
  }
  rep(i,4) printf("%d\n",res[i]);

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    ll n, x, d;

    cin >> n >> x >> d;

    if (d < 0)
    {
        x *= -1;
        d *= -1;
    }

    if (d == 0)
    {
        if (x == 0)
            cout << 1 << endl;
        else
            cout << n + 1 << endl;
        return 0;
    }

    ll res = 0;

    ll mi = 0;
    ll mx = 0;

    static map<int, vector<pair<ll, ll>>> ra;

    for (ll i = 1; i <= n; i++)
    {
        mi += i - 1;
        mx += n - i;

        ll cmin = x * i + d * mi;
        ll cmax = x * i + d * mx;

        ra[(x + d * (ll)1e8) % d * i % d].push_back({cmin, cmax});
    }

    ra[0].push_back({0, 0});

    for (auto i : ra)
    {
        SORT(i.second);

        ll end = i.second[0].first;

        for (auto p : i.second)
        {
            res += max(0ll, (p.second - max(p.first - d, end - d)) / d);

            end = max(end, p.second + d);
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 22144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
int main(void){
    ll n,m;
    string s,t;
    cin>>n>>m>>s>>t;
    ll x=lcm(n,m);
    map<ll,ll> mm;
    ll a=x/n,b=x/m;
    for(ll i=0;i<n;i++){
        ll z=s[i]-'a'+1;
        mm[i*a]=z;
    }
    for(ll i=0;i<m;i++){
        ll z=t[i]-'a'+1;
        if(mm[i*b]>0&&mm[i*b]!=z){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<x<<endl;
}

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

int main(){
    int n;
    cin >> n;
    bool ok = true;
    for(int i = 0; i < n; i++){
        int x;  cin >> x;
        if(x%2) continue;
        ok &= x%3==0 || x%5==0;
    }
    cout << (ok ? "APPROVED" : "DENIED") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	ios_base::sync_with_stdio(0);
	
	priority_queue<ll> pq;
	string s;
	
	while(cin>>s && s!="end")
	{ 
		 ll x;

		if(s=="insert") 
		{		 cin>>x;
			
			pq.push(x);
	
			
		}
		else {
			x=pq.top();
			pq.pop();
			printf("%lld\n",x);
		}
	}
	return 0;
}

Measured memory_bytes: 11172
#include <stdio.h>

void    check_seven(char *n)
{
    int i;
    int flag;

    i = 0;
    flag = 0;
    while (n[i] != 0)
    {
        if (n[i] == '7')
        {
            flag = 1;
        }
        i++;
    }
    if (flag == 1)
    {
        printf("Yes");
    }
    else if (flag == 0)
    {
        printf("No");
    }
    
}

int     main()
{
    char input[4];

    scanf("%s", input);
    check_seven(input);
    return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include <string.h>
#include <vector>
#include <deque>
#include <bitset>
#include <string>
#include <limits.h>
#include <stdint.h>
#include <algorithm>
#include <tuple>
#include <iomanip>
#include <set>
#include <assert.h>
using namespace std;

int main(int argc, char* argv[])
{
	if (argc >= 2) {
		FILE* fp = freopen(argv[1], "r", stdin);
	}

	int N, M;
	cin >> N >> M;

	std::vector<std::vector<int>> list(N + 1);
	std::vector<int> dist(N + 1, INT_MAX);
	for (int i = 1; i <= M; i++) {
		int A, B;
		cin >> A >> B;
		list[A].push_back(B);
		list[B].push_back(A);
	}
	std::deque<int> st;
	dist[1] = 0;
	st.push_back(1);
	bool result = false;
	while (!st.empty()) {
		auto t = st.front();
		st.pop_front();

		if (t == N) {
			result = true;
			break;
		}

		if (dist[t] < 2) {
			for (int b : list[t]) {
				if (dist[b] > dist[t] + 1) {
					dist[b] = dist[t] + 1;
					st .push_back(b);
				}
			}
		}
	}
	cout << (result ? "POSSIBLE" : "IMPOSSIBLE");

	return 0;
}


Measured memory_bytes: 13168
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define in auto&it
#define out auto it 
#define rep(i,si,n) for(int i=si;i<n;++i)
int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		//freopen("error.txt","w",stderr);
	#endif
	fastio
	int n;
	cin>>n;
	if(n>=30) cout<<"Yes";
	else cout<<"No";
	//cerr<<"time:  "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<'\n';
	return 0;
}


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

int main(){
  long long N;
  cin >> N;
  
  vector<long long> s(13);
  s.at(0) = 1;
  for (int i=1 ; i<12 ; i++){
    s.at(i) = s.at(i-1)+pow(26, i);
  }
  
  int k = 1;
  for (int i=0 ; i<12 ; i++){
    if (s.at(i) <= N && N < s.at(i+1)){
      k = i+1;//k文字の名前
      break;
    }
  }
  
  long long l = N-s.at(k-1)+1;//k文字の名前のうち辞書順でl番目
  
  vector<char> answer(k);
  if (k != 1){
    for (int i=0 ; i<k-1 ; i++){
      long long jou = pow(26, k-i-1);
      int number = l/jou;
      if (l%jou==0)
        number -= 1;
      else if (l%26==0 && l/26<26)
        number = l/26;
      answer.at(i) = 'a'+number;
      l -= number*pow(26, k-i-1);
    }
  }
  if (l==0)
    answer.at(k-1) = 'z';
  else
    answer.at(k-1) = 'a'+l-1;
  for(int i=0 ; i<k ; i++)
    cout << answer.at(i);
}

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

using namespace std;
typedef long long ll;

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

ll max(ll a, ll b) {return a < b ? b : a; }

int main() {
  int N, K;
  cin >> N >> K;
  
  ll sum = 0;
  
  for(int b = K + 1; b <= N; ++b) {
    
    sum += (b - K) * (N / b);
    // if(K != 0) {
      int nmod = (N - b * (N / b));
      sum += max(nmod - K + (K!=0), 0);
    // }
  }
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(int argc, char const *argv[])
{
	int a, b, c; cin >> a >> b >> c;
	int ans = min(b / a, c);
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 105000;

int n, x;
int b[MAXN], low[MAXN], up[MAXN];
long long total;

bool can(long long mid) {
  if (mid == 0) {
    return total == 0;
  }

  long long takeX = mid / x;
  long long rem = mid - 1ll * takeX * x;

  vector < pair<long long, int> > v;
  for (int i = 0; i < n; i++) {
    v.push_back({1ll * b[i] * low[i] + 1ll * (x - b[i]) * up[i], i});
  }
  sort(all(v));
  reverse(all(v));

  vector <long long> sum;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      sum.push_back(v[i].first);
    } else {
      sum.push_back(sum[i - 1] + v[i].first);
    }
  }

  if (rem == 0) {
    return sum[takeX - 1] + total >= 0;
  }

  for (int i = 0; i < n; i++) {
    int idx = v[i].second;
    long long cur = 1ll * min(rem, 1ll * b[idx]) * low[idx];
    if (rem > b[idx]) {
      cur += 1ll * (rem - b[idx]) * up[idx];
    }
    if (takeX) {
      cur += sum[takeX - 1];
      if (i <= takeX - 1) {
        cur -= v[i].first;
        cur += v[takeX].first;
      }
    }
    if (cur + total >= 0) {
      return true;
    }
  }

  return false;
}

int main() { 

  scanf("%d %d", &n, &x);
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", &b[i], &low[i], &up[i]);
  }

  for (int i = 0; i < n; i++) {
    total -= 1ll * low[i] * b[i];
  }

  long long l = 0, r = 1ll * x * n;
  while (l < r) {
    long long mid = (l + r) / 2;
    if (can(mid)) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }

  cout << l << endl;

  return 0;
}


Measured memory_bytes: 6344
import Control.Applicative

toInt :: String -> Int
toInt = read

solve :: Int -> Int -> Int -> Int -> Int
solve x y z acc =
  if quot x ((y + z) * acc + z) == 1 && mod x ((y + z) * acc + z) < y + z
  then acc
  else solve x y z (acc + 1)

main :: IO ()
main = do
  [x', y', z'] <- map toInt . words <$> getLine
  putStrLn $ show $ solve x' y' z' 1


Measured memory_bytes: 508
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		int c = s.nextInt();
		System.out.println(((a < b) && (b < c)) ? "Yes" : "No");
	}
}

Measured memory_bytes: 17160
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

# define M_PI           3.14159265358979323846  /* pi */

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int r;
    cin>>r;
    double ans=2*r*3.14159265359;
    printf("%.10lf",ans);
    return 0;
}


Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;cin>>n;
  vector<int> p(n),q(n);
  for(int i=0;i<n;i++)
    cin>>p[i];
  for(int i=0;i<n;i++)
    cin>>q[i];
  int count=0;
  if(p<q)
    while(p!=q && next_permutation(p.begin(),p.end()))
      count++;
  else
    while(p!=q && next_permutation(q.begin(),q.end()))
      count++;
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define RI register int
const int mod=1e9+7,N=65540;
int n,m,a[17],f[17][N],fac[N],inv[N],ifac[N],bin[17],sz[N];

int qm(int x) {return x>=mod?x-mod:x;}
int C(int d,int u) {
	if(d<u) return 0;
	return 1LL*fac[d]*ifac[u]%mod*ifac[d-u]%mod;
}
void prework() {
	bin[0]=1;for(RI i=1;i<=n;++i) bin[i]=bin[i-1]<<1;
	fac[0]=1;for(RI i=1;i<=bin[n];++i) fac[i]=1LL*fac[i-1]*i%mod;
	inv[0]=inv[1]=1,ifac[0]=1;
	for(RI i=2;i<=bin[n];++i) inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
	for(RI i=1;i<=bin[n];++i) ifac[i]=1LL*ifac[i-1]*inv[i]%mod;
	f[0][0]=1;
	for(RI i=1;i<=m;++i)
		for(RI j=0;j<bin[n];++j) {
			f[i][j]=qm(f[i][j]+f[i-1][j]);
			if(bin[n]-a[i]-j<0||!f[i-1][j]) continue;
			for(RI k=0;k<n;++k) if(!(j&bin[k])) 
				f[i][j|bin[k]]=qm(f[i][j|bin[k]]+
					1LL*f[i-1][j]*C(bin[n]-a[i]-j,bin[k]-1)%mod*fac[bin[k]]%mod);
		}
}
void work() {
	int ans=0;
	for(RI i=1;i<bin[n];++i) sz[i]=sz[i>>1]+(i&1);
	for(RI zt=0;zt<bin[n];++zt)
		if(sz[zt]&1) ans=qm(ans-1LL*fac[bin[n]-1-zt]*f[m][zt]%mod+mod);
		else ans=qm(ans+1LL*fac[bin[n]-1-zt]*f[m][zt]%mod);
	ans=1LL*ans*bin[n]%mod;
	printf("%d\n",ans);
}

bool cmp(int x,int y) {return x>y;}
int main()
{
	scanf("%d%d",&n,&m);
	for(RI i=1;i<=m;++i) scanf("%d",&a[i]);
	sort(a+1,a+1+m,cmp);
	prework(),work();
	return 0;
}

Measured memory_bytes: 5376
import qualified Data.ByteString.Char8 as BS
import Data.Maybe (fromJust)
import Data.Array.IArray
import Control.Monad

solve :: Array (Int,Int) Int -> [Int]
solve c = do
    a1 <- [0..100]
    let b1 = c!(1,1) - a1
        b2 = c!(1,2) - a1
        b3 = c!(1,3) - a1
        a2 = c!(2,1) - b1
        a3 = c!(3,1) - b1
    guard $  a2+b2 == (c!(2,2))
          && a2+b3 == (c!(2,3))
          && a3+b2 == (c!(3,2))
          && a3+b3 == (c!(3,3))
    return a1

main :: IO ()
main = do
    c <- listArray ((1,1),(3,3))
        . concatMap (map (fst . fromJust . BS.readInt) . BS.words)
        . BS.lines <$> BS.getContents :: IO (Array (Int,Int) Int)
    putStrLn $ if null (solve c) then "No" else "Yes"

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

void dump(const vector<int>& A)
{
    for (int i = 0; i < A.size(); i++) {
        if (i)
            cout << " ";
        cout << A[i];
    }
    cout << endl;
}
int main()
{
    int n, q;
    cin >> n >> q;
    vector<vector<int>> A(n);
    for (int i = 0; i < q; i++) {
        int query;
        cin >> query;
        if (query == 0) {
            int t, x;
            cin >> t >> x;
            A[t].push_back(x);
        }
        if (query == 1) {
            int t;
            cin >> t;
            dump(A[t]);
        }
        if (query == 2) {
            int t;
            cin >> t;
            A[t].clear();
        }
    }
    return 0;
}


Measured memory_bytes: 5860
#include <bits/stdc++.h>
using namespace std;
int main() {
 string S;
 cin>>S;
 vector<bool>vec(4);
 int s=S.size();
for(int i=0; i<s; i++){
if(S.at(i)=='N'){
vec.at(0)=true;
}
else if(S.at(i)=='W'){
vec.at(1)=true;
}
else if(S.at(i)=='S'){
vec.at(2)=true;
}
else if(S.at(i)=='E'){
vec.at(3)=true;
}
}
if(vec.at(0)==true&&vec.at(1)==true&&vec.at(2)==true&&vec.at(3)==true){
cout<<"Yes"<<endl;
}
else if(vec.at(0)==true&&vec.at(1)==false&&vec.at(2)==true&&vec.at(3)==false)
cout<<"Yes"<<endl;
else if(vec.at(0)==false&&vec.at(1)==true&&vec.at(2)==false&&vec.at(3)==true)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define exists(s,x) (s).find(x)!=(s).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
#define fi first
#define se second
typedef long long ll;

struct UnionFind {
  vector<int> data;
  int group_count;
  UnionFind(int size) : group_count(size), data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
        group_count -= 1;
        if (data[y] < data[x]) swap(x, y);
        data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M, K; cin >> N >> M >> K;
    vector<vector<int>> G(N);
    UnionFind UF(N);
    vector<int> fr(N);
    vector<int> bl(N);
    REP(i,M) {
        int a, b; cin >> a >> b; a--; b--;
        UF.unionSet(a,b);
        fr[a] ++;
        fr[b] ++;
    }
    REP(i,K) {
        int a, b; cin >> a >> b; a--; b--;
        if(UF.findSet(a,b)) {
            bl[a]++;
            bl[b]++;
        }
    }
    REP(i,N) {
        if(i) cout << ' ';
        cout << UF.size(i) - fr[i] - bl[i] - 1;
    }
    cout << endl;
    return 0;
}

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

using namespace std;

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

using ll = long long;

int N;
ll K, a[100010];

string tobs(ll x) {
  string res;
  REP(i,60) {
    if (x & (1LL << i)) res += '1';
    else res += '0';
  }
  reverse(res.begin(), res.end());
  return res;
}

int main() {
  cin >> N >> K;
  REP(i,N) scanf("%lld", &a[i]);

  int cnt[60];
  REP(i,60) cnt[i] = 0;
  REP(i,N) {
    string bs = tobs(a[i]);
    REP(j,bs.length()) if (bs[j] == '1') cnt[j]++;
  }

  ll k = 0;
  REP(i,60) {
    int digit = 60 - i - 1;
    // cout << cnt[i] << ' ' << (1LL<<digit) << endl;
    if (cnt[i] <= N / 2 && (1LL<<digit) + k <= K) {
      k += (1LL<<digit);
    }
  }

  ll res = 0LL;
  REP(i,N) res += (k ^ a[i]);
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dbg puts("It's Just Begining.Wait For The End!!!!!\n")
#define CHECK(x) cout << (#x) << " is " << (x) <<"\n";
#define endl printf("\n")
typedef pair<ll,ll> pii;
#define pb push_back
#define ms(a,b) memset(a, b, sizeof(a))
#define in(x) scanf("%lld",&x)
#define out(x) printf("%lld",x)
#define X first
#define Y second
#define sps printf(" ")
#define dou(x) cout<<fixed<<setprecision(6)<<x
#define all(v) v.begin(),v.end()
int main()
{
    ll i,j,k,l,n,m;
    in(n);
    ll sum=((n*(n+1))/2);
    for(i=1;i<=n;i++)
    {
        if(i%3==0||i%5==0)sum-=i;
    }
    out(sum);endl;
}


Measured memory_bytes: 3844
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <bits/stdc++.h>
#include <cmath>
#include <stdio.h>
#include <utility>
using namespace std;
#define ll long long

int main()
{
  int n;cin>>n;
  int sum=0;
  sum=(n*(n+1))/2;
  cout<<sum<<endl;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
long long s[100005];
int main(){
     s[0]=1;
     for(int i=1;i<=100000;i++)
     {
          s[i]=s[i-1]*i%MOD;
     }
     int n,m;
     scanf("%d%d",&n,&m);
     if(abs(n-m)>1){
          printf("0\n");
          return 0;
     }
     if(n!=m)
     printf("%lld\n",s[n]*s[m]%MOD);
     if(n==m)printf("%lld\n",2ll*s[n]*s[m]%MOD);
     return 0;
}


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

if K%2 == 1:
  sur0 = []
  for i in range(1,N+1):
    if i%K == 0:
      sur0.append(i)
  print(len(sur0)**3)
    
else:
  sur0 = []
  surhalf = []
  for i in range(1,N+1):
    if i%K == 0:
      sur0.append(i)
    elif i%K == K/2:
      surhalf.append(i)
  print(len(sur0)**3 + len(surhalf)**3)

Measured memory_bytes: 11040
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'
 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  ll A,B;
  cin >> A >> B;
  string s1(A, '0'+B);
  string s2(B, '0'+A);
  if (s1 < s2) {
    cout << s1 << endl;
  } else {
    cout << s2 << endl;
      }

}



Measured memory_bytes: 3592
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, a, b, co[100009], k;
vector<pair<int, int> > vec[100009];


void fun(int i, int from)
{
	int cur = k;
	set<int> vis;
	vis.clear();
	for (int j = 0; j < (int)vec[i].size(); j++) {
		if (vec[i][j].fi == from) {
			vis.insert(co[vec[i][j].se]);
			break;
		}
	}
	for (int j = 0; j < (int)vec[i].size(); j++) {
		if (co[vec[i][j].se] == 0) {
			while (!vis.empty() && vis.count(cur)) {
				cur--;
			}
			co[vec[i][j].se] = cur;
		}
		vis.insert(co[vec[i][j].se]);
	}
	for (int j = 0; j < (int)vec[i].size(); j++) {
		if (vec[i][j].fi != from) {
			fun(vec[i][j].fi, i);
		}
	}
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		cin >> a >> b;
		vec[a].pb({ b, i });
		vec[b].pb({ a, i });
	}
	for (int i = 1; i <= n; i++) {
		k = max(k, (int)vec[i].size());
	}
	fun(1, 0);
	cout << k << E;
	for (int i = 0; i < n - 1; i++) {
		cout << co[i] << E;
	}
	//system("pause");
	return 0;
}


Measured memory_bytes: 17536
#include <bits/stdc++.h>
using namespace std;
char a[1000];
int main()
{
	long long n,a1=0,a2=0,a3=0,a4=0;
	cin>>n;
	while(n--)
	{
		memset(a,'\0',sizeof(a));
		cin>>a;
			if(a[0]=='B')
			{
				a1++;
			}
			if(a[strlen(a)-1]=='A')
			{
				a2++;
			}
			if(a[strlen(a)-1]=='A'&&a[0]=='B')
			{
				a4++;
			}
		for(int i=0;i<strlen(a)-1;i++)
		{
			if(a[i]=='A'&&a[i+1]=='B')
			{
				a3++;
			}
		}
	}
	long long aa=min(a1,a2);
	if(a1==a4&&a2==a4&&a4!=0)
	{
		cout<<aa+a3-1<<endl;
	}
	else
	cout<<aa+a3<<endl;
}

Measured memory_bytes: 256
n,m = (int(i) for i in input().split())
#print(n,m)
#for i in range(n):
mylist1=[[] for i in range(n)]
for i in range(n):
    mylist1[i]=[int(i) for i in input().split()]

mylist2=[[] for i in range(m)]
for i in range(m):
    mylist2[i]=[int(i) for i in input().split()]  

for i in range(n):
    dist= float("inf")
    ans=0
    for j in range(m):
        tmp=abs(mylist1[i][0]-mylist2[j][0])+abs(mylist1[i][1]-mylist2[j][1])
#        print(tmp)
        if tmp < dist:
            ans=j
            dist=tmp
    print(ans+1)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define fore(e, u, v) for (int p = e(u), v = e[p].y; p; v = e[p = e[p].nxt].y)
#define ri rd<int>
using namespace std;
typedef long long LL;
const int maxN = 1e5 + 7;
const int V = 1e5 + 3;
 
inline int mo(int x) {return (x % 3 + 3) % 3;}
 
template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}
 
int n, m;
int vis[maxN], mn, mx;
LL cnt[3], tag, all, edd;
LL ans = 0;
 
struct vec {
	static const int maxE = maxN;
	int g[maxN], te;
	struct edge {int y, d, nxt;} e[maxE << 1];
	inline void push(int x, int y, int d) {e[++te] = (edge){y, d, g[x]}; g[x] = te;}
	inline void link(int x, int y, int d) {push(x, y, d), push(y, x, -d);}
	inline int& operator () (int x) {return g[x];}
	inline edge& operator [] (int x) {return e[x];}
}e;
 
void dfs(int x, int d) {
	if (d < mn) mn = d;
	if (d > mx) mx = d;
	vis[x] = mo(d);
	++cnt[mo(d)]; ++ all;
	fore (e, x, y) {
		if (~vis[y]) {
			if (vis[y] != mo(d + e[p].d)) tag = 1;
		}
		else dfs(y, d + e[p].d);
		++ edd;
	}
}
 
int main() {

	n = ri(), m = ri();
	memset(vis, -1, sizeof vis);
	rep (i, 1, m) {
		int x = ri(), y = ri();
		e.link(x, y, 1);
	}
 
	rep (i, 1, n) if (vis[i] == -1) {
		memset(cnt, 0, sizeof cnt); all = tag = edd = 0;
		mx = 0, mn = V << 1;
		dfs(i, V);
		if (tag == 1) ans += all * all;
		else if (mx > mn + 1) ans += cnt[0] * cnt[1] + cnt[1] * cnt[2] + cnt[2] * cnt[0];
		else ans += edd >> 1;
	}
 
	printf("%lld\n", ans);
 
	return 0;
}

Measured memory_bytes: 6400
n, k = map(int, input().split())
x = list(map(int, input().split()))

ans = []
for i in range(n - k + 1):
    left = x[i]
    right = x[i + k - 1]
    ans.append(min(abs(left) + abs(right - left),
                   abs(right) + abs(left - right)))

print(min(ans))

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

using namespace std;

int a[2019], b[2019];

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

    long long ans = 0LL;
    char g = getchar();
    while (g > '0' && g <= '9')
    {
        int x = g - '0';
        ++b[x];
        for (int i = 0; i < 2019; ++i)
            b[(i * 10 + x) % 2019] += a[i];

        ans += 1LL * b[0];
        for (int i = 0; i < 2019; ++i)
            a[i] = b[i], b[i] = 0;
        g = getchar();
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3648
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
	int N;
	string S;
	cin >> N;
	cin >> S;
	long long int num[26] = {};
	for(int i = 0; i < S.size(); i++){
		num[S[i] - 'a'] += 1;
	}
	long long int ans = 1;
	for(int i = 0; i < 26; i++){
		ans *= num[i] + 1;
		ans %= MOD;
	}
	ans += MOD - 1;
	ans %= MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
N,M=map(int,input().split())
H=list(map(int,input().split()))
L=[1]*N
for i in range(M):
    a,b=map(int,input().split())
    if H[a-1]>H[b-1]:#aの方が高い場合
        if L[b-1]==1:
            L[b-1]-=1
    elif H[a-1]<H[b-1]:
        if L[a-1]==1:
            L[a-1]-=1
    elif H[a-1]==H[b-1]:
        if L[a-1]==1 and L[b-1]==1:
            L[a-1]-=1
            L[b-1]-=1
        elif L[a-1]==1 and L[b-1]==0:
            L[a-1]-=1
        elif L[a-1]==0 and L[b-1]==1:
            L[b-1]-=1
print(sum(L))

Measured memory_bytes: 20076