akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  vll T(N), X(N), Y(N);
  REP(i, 0, N) {
    cin >> T[i] >> X[i] >> Y[i];
  }

  ll cT = 0;
  ll cX = 0;
  ll cY = 0;
  REP(i, 0, N) {
    ll xlen = abs(X[i] - cX);
    ll ylen = abs(Y[i] - cY);
    ll tlen = abs(T[i] - cT);
    if (xlen + ylen > tlen) {
      cout << "No" << endl;
      return 0;
    }
    if (tlen % 2 == 0) {
      if ((xlen + ylen) % 2 != 0) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      if ((xlen + ylen) % 2 == 0) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 2560
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits, ascii_letters
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
import numpy as np
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()
ans = [ascii_uppercase[(ascii_uppercase.index(S[i])+N)%26] for i in range(len(S))]
#print(ans)
print(*ans, sep="")

Measured memory_bytes: 14012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<int, ll> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
// const ll MAXN = 

int n, k;
string s;
int l[100005], r[100005];
/********** Good Luck :) **********/
int main () {
    TIME(main);
    IOS();

    cin >> n >> k;
    cin >> s;

    int cnt1 = 0, cnt2 = 0, ans = 0;
    REP (i, n-1) {
        if (s[i] == 'L' && s[i+1] == 'R') {
            cnt1++;
        } else if (s[i] == 'R' && s[i+1] == 'L') {
            cnt2++;
        } else if (s[i] == s[i+1]) {
            ans++;
        }
    }

    debug(ans, cnt1, cnt2);
    int mx = min({k, cnt1, cnt2});
    ans += mx * 2;
    if (k-mx > 0) {
        ans += min(k-mx, max(cnt1, cnt2) - mx);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, b = 0;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  for (int i = 1; i < n - 1; i++) {
    if (a.at(i - 1) < a.at(i) && a.at(i) < a.at(i + 1)) {
      b++;
    }
    if (a.at(i + 1) < a.at(i) && a.at(i) < a.at(i - 1)) {
      b++;
    }
  }
  cout << b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100],n,m,sum;
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=n;i>=n-m+1;i--)
    sum+=a[i];
    cout<<sum<<endl;
    return 0;
}

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

int main() {
 int x1,y1,x2,y2,a,b;
 cin >> x1 >> y1 >> x2 >> y2 ;

  a=x2 - x1;
  b=y2 - y1;

  int x3,y3,x4,y4;

  x3 = x2 -b;
  y3 = y2 +a;
  x4 = x3 -a;
  y4 = y3 -b;

  cout << x3 << endl;
  cout << y3 << endl;
  cout << x4 << endl;
  cout << y4 << endl;
}


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

int main()
{
    int a, b, c, x, t = 0, ans = 0;
    cin >> a >> b >> c >> x;
    for(int i=0; i<=a; i++){
        for(int j=0; j<=b; j++){
            for(int k=0; k<=c; k++){
                t = 500 * i + 100 * j + 50 * k;
                if(t == x) ans++;
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let n = lines.next().unwrap().unwrap().parse::<u64>().unwrap();

    if n % 2 == 1 {
        println!("0");
        return;
    }

    let mut ans = 0;
    let mut i = n / 2;
    while i != 0 {
        i /= 5;
        ans += i;
    }

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


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while (stdIn.hasNextInt()) {
			int n = stdIn.nextInt();
			int i = stdIn.nextInt();
			int cou = 0;
			int ni=n+i;
			while(ni>0){
				ni/=10;
				cou++;
			}
			System.out.println(cou);
		}
	}
}

Measured memory_bytes: 26456
//https://blog.csdn.net/hesorchen
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define lowbit(a) (a & (-a))
#define mod 1000000007
#define INF 0x3f3f3f3f
#define endl "\n"
#define MAX 100010
string a;
stack<char> st;
string ans;
int main()
{
    int n;
    cin >> n >> a;
    int c = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] == '(')
        {
            c++;
            ans = ans + '(';
        }

        else
        {
            c--;
            if (c>=0)
                ans = ans + ')';
            else
            {
                c++;
                ans = '(' + ans + ")";
            }
        }
    }
    while (c--)
    {
        ans = ans + ')';
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int d = a / b;
		int r = a % b;
		double f = (double)a / (double)b;
		System.out.printf("%d %d %05f", d, r, f);
	}
}

Measured memory_bytes: 17320
# ALDS1_1_B - Greatest Common Divisor
def gcd(x: int, y: int) -> int:
    while x % y:
        x, y = y, x % y
    return y


def main():
    A, B = tuple(map(int, input().split()))
    ans = gcd(A, B)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;

int n,m;
vector<bool> used(60);
vector<int> g[60];

void dfs(int d,int v){
  if(used[v]){
    return ;
  }
  used[v]=true;
  if(d==n-1){
    return ;
  }
  if(g[v].empty()){
    return ;
  }
  rep(i,len(g[v])){
    dfs(d+1,g[v][i]);
  }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>m;
    vector<int> a(m),b(m);
    rep(i,m){
      cin>>a[i]>>b[i];
    }
    int ans=0;
    rep(i,m){
      rep(j,60){
        g[j].clear();
      }
      rep(j,m){//消す橋
        if(j==i){
          continue;
        }
        g[a[j]].push_back(b[j]);
        g[b[j]].push_back(a[j]);
      }
      rep(j,len(used)){
        used[j]=false;
      }
      dfs(0,1);
      if(count(begin(used),end(used),true)!=n){
        /*
        cout<<i<<' '<<count(begin(used),end(used),true)<<'\n';
        if(i==4){
          cout<<' '<<g[7][0]<<'\n';
          FOR(k,1,8){
            cout<<used[k]<<' ';
          }
          cout<<'\n';
        }
        */
        ans++;
      }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
H, W = map(int,input().split())
N = int(input())
A = list(map(int,input().split()))
for i in range(N-1):
    A[i+1] = A[i] + A[i+1]
C = [[0 for i in range(W)] for j in range(H)]
cnt = 1
index = 0
for i in range(H):
    for j in range(W):
        if cnt > A[index]:
            index += 1
        C[i][j] = index + 1
        cnt += 1
for i in range(H):
    if i % 2 == 0:
        print(*C[i])
    else:
        print(*C[i][::-1])

Measured memory_bytes: 4208
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int arr[2050][2050];
void fill(int s,int e,int n,int m)
{
    if(n==0) {arr[s][e+(1<<m)-1]=1;return;}
    if(m==0) {arr[s+(1<<n)-1][e]=1;return;}
    arr[s+(1<<n)-1][e+(1<<m)-1]=1;
    fill(s,e,n-1,m-1);
    fill(s+(1<<n),e,n-1,m-1);
    fill(s,e+(1<<m),n-1,m-1);
    fill(s+(1<<n),e+(1<<m),n-1,m-1);
    return;
}
int main()
{
    int n,m;
    cin>>n>>m;
    fill(1,1,n-1,m-1);
    for(int i=1;i<1<<n;cout<<'\n',i++)for(int j=1;j<1<<m;j++)cout<<arr[i][j];
    return 0;
}

Measured memory_bytes: 11520
#include<cstdio>
int n,k,i,j,l,a[300005];
int main(){
    scanf("%d%d",&k,&n);
    if(k&1){
        while(j<n)
            a[j++]=k+1>>1;
        for(j=n;i<n-1;i+=2)
            if(--a[--j])
                while(++j<n)
                    a[j]=k;
        while(l<j)
            printf("%d ",a[l++]);
    } else{
        for(;i<n;i++)
            printf("%d ",k/(1+!i));
    }
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 10e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  int A,B,K;
  cin >> A >> B >> K ;
  if( B-A < 2 * K)
  {
    FOR(i,A,B+1)
    {
      cout << i << endl;
    }
    return 0;
  }
  rep(i,K)
  {
    cout << A + i << endl;
  }
  rep(i,K)
  {
    cout << B - K + i + 1<< endl;
  }
}



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

#define ll long long
#define MOD (1000000007LL)
using namespace std;

ll exp(ll b, ll i){
    if(i == 0) return 1;
    ll r = 1;
    ll e = exp(b, i / 2);
    if(i % 2 == 1) r *= b;
    r *= e;
    r %= MOD;
    r *= e;
    return r % MOD;    
}

ll inv(ll x){
    return exp(x, MOD - 2);
}

int main(void){
    ll fact[100001];
    ll st[100001];
    ll f = 1;
    fact[0] = 1;
    st[0] = 0;
    for(ll i = 1; i <= 100001; i++){
        f *= i;
        f %= MOD;
        fact[i] = f;
        st[i] = fact[i - 1] + st[i - 1] * i;
        st[i] %= MOD;
        // cout << i << " " << st[i] << endl;
    }

    int N;
    cin >> N;
    vector<ll> x(N);
    for(int i = 0; i < N; i++){
        cin >> x[i];
    }

    ll ans = 0;
    ll m = 0;
    for(int i = 0; i < N - 1; i++){
        ll d = x[i + 1] - x[i];
        ll c = st[i + 1] * fact[N - 1];
        c %= MOD;
        c *= inv(fact[i + 1]);
        c %= MOD;
        ans += d * c;
        ans %= MOD;
    }

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


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

int main()
{
	int N,K,a;
	int imin;
	int ans=2e9;
	
	cin >> N >> K;
	for(int i=0;i<N;i++)
	{
		cin >> a;
		if(a==1)imin=i;
	}
	
	for(int i=0;i<K;i++)
	{
		int tmp=0;
		int left,right;
		left=max(imin-i,0);
		right=max(N-imin-K+i,0);
		
		if(left!=0)tmp+=(left/(K-1));
		if(left%(K-1)!=0)tmp++;
		if(right!=0)tmp+=(right/(K-1));
		if(right%(K-1)!=0)tmp++;
		ans=min(ans,tmp);
	}
	ans++;
	cout << ans << endl;
	return 0;
}



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

using namespace std;
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define rep(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define frep(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define fwr(x) { cout << x << '\n'; }

typedef complex<ld> cplex;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int inf = 1e9 + 7;
const ll linf = 1ll * inf * inf;
const int N = 1000000 + 1;
const int M = 5000;
const int multipleTest = 0;
const double pi = acos(-1);

int n, m;
vi adj[N];

int state[N];

void dfs(int u) {
    if (state[u] == 2) return;
    state[u] = 1;
    
    for (int v : adj[u]) {
        if (state[v] == 1) {
            puts("No");
            exit(0);
        }
        dfs(v);
    }
    state[u] = 2;
}
int tIn[N];

vii nxt[N], prv[N];

map<int, int> st;

void check(int u, int d) {
    if (st.count(u)) {
        if (st[u] != d) {
            puts("No");
            exit(0);
        }
        return;
    }
    st[u] = d;
    for (ii x : nxt[u]) {
        int v = x.first;
        int c = x.second;
        check(v, d + c);
    }
}

void solve() {
    cin >> n >> m;
    rep(i, 0, m) {
        int u, v, d;
        scanf("%d%d%d", &u, &v, &d);
        adj[u].push_back(v);
        tIn[v]++;
        
        nxt[u].push_back(make_pair(v, d));
        nxt[v].push_back(make_pair(u, -d));
    }
    for (int i = 1; i <= n; ++i) if (!tIn[i]) dfs(i);
    for (int i = 1; i <= n; ++i) if (state[i] == 0) {
        puts("No");
        return;
    }
    
    for (int i = 1; i <= n; ++i) if (!tIn[i] && !st.count(i)) check(i, 0);
    puts("Yes");
}

int main() {
#ifdef _LOCAL_
    freopen("inp.txt", "r", stdin);
    //    freopen("out.txt", "w", stdout);
#endif
    
    int Test = 1;
    if (multipleTest)
        cin >> Test;
    
    for(int i = 0; i < Test; ++i) {
        //        printf("Case #%d: ", i + 1);
        solve();
    }
#ifdef _LOCAL_
    cout<< "\n" << 1.0 * clock() / CLOCKS_PER_SEC << "\n";
#endif
}


Measured memory_bytes: 95104
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
int main(int argc, char *argv[])
{
	int n,k;
	cin>>n>>k;
	if(n%k==0)
		printf("0\n");
	else
		printf("1\n");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {

	int n, x;
	cin >> n >> x;
	long long int a[100001];
	int i;
	for (i = 1; i <= n; i++) {
		cin >> a[i];
	}

	long long int counter = 0;
	for (i = 1; i <= n; i++) {
		if (a[i] + a[i - 1] > x) {
			//cout << i << endl;
			counter = counter + (a[i] + a[i - 1] - x);
			a[i] = a[i] - (a[i] + a[i - 1] - x);
			//cout << a[i] << endl;a
			
		}
	}
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 4376
dic = {"a":0, "b":1, "c":2}
c = [[dic[i] for i in input()] for _ in range(3)]

turn = 0
while c[turn]:
    next_turn = c[turn][0]
    c[turn] = c[turn][1:]
    turn = next_turn
else:
    rdic = {0:"A", 1:"B", 2:"C"}
    print(rdic[turn])

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

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



int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  if (b > n) {
    cout << a * n / b << endl;  
  }
  else {
    cout << a * (b - 1) / b << endl;
  }
  

}



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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define read            freopen("in.txt","r",stdin)
#define write           freopen("out.txt","w",stdout)
#define loop(i,a,b)     for (ll i = a; i <= b; i++)
#define rloop(i,a,b)    for (ll i = a; i >= b; i--)
#define ms(a,x)         memset(a,x,sizeof a)
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd((a),(b))
#define lcm(a,b)        ((a)*(b))/(gcd(a,b))
#define sq(a)           (a)*(a)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)

int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        ll n;
        cin>>n;
        ll a[n+1],b[n+1];
        ms(b,0);
        loop(i,1,n) cin>>a[i];
        loop(i,1,n)
        {
            b[i]=b[i-1]+a[i];
        }
        ll ans=0;
        loop(i,1,n-1)
        {
            ans= (ans+(b[n]-b[i])%mod*a[i]%mod)%mod;
        }
        if(ans<0) ans=(ans+mod)%mod;
        cout<<ans;

    }
    return 0;
}


Measured memory_bytes: 6784
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        if( B % A == 0 ){
            System.out.println(A+B);
        } else {
            System.out.println(B-A);
        }
    }
}


Measured memory_bytes: 21204
#include <stdio.h>

int main( )
{
	unsigned int num,Num;
	scanf("%d",&num);
	Num = num;


	int sum = 0;


	for(;num/10 != 0;)
	{
		sum += num%10;
		num = num/10;
	}
	sum +=num;

	if(Num%sum == 0)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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 int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

int main(){
	int n;
	cin >> n;
	vector<int> x(n);
	rep(i,n) cin >> x[i];
	vector<int> y = x;
	sort(x.begin(), x.end());
	int c1 = x[n/2-1];
	int c2 = x[n/2];
  rep(i,n){
	if(y[i] > c1) cout << c1 << endl;
	else cout << c2 << endl;}
}

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

int main()
{
  int p[] = {500,100,50,10,5,1};
  int data;
  while(cin >> data,data){
    data = 1000 - data;
    int cnt = 0;
    Rep(i,6) {
      while(p[i] <= data) {
	data -= p[i];cnt++;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 3040
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int cnt;
ll num[60000];
ll memo[60000];
ll a,b,c,d;

int uniquell(ll*a,ll*ans,int cnt){
	sortup(a,cnt);
	int c=0;
	ans[0]=a[0];
	rep(i,1,cnt)if(a[i]!=ans[c])ans[++c]=a[i];
	return c+1;
}

int bs(ll x){
	int l=0,r=cnt;
	while(r-l>1){
		int m=(l+r)/2;
		if(num[m]<=x)l=m;
		else r=m;
	}
	return l;
}

#define chmin(x,y)(x=min(x,y))
ll f(ll x){
	if(x==0)return 0;
	if(x==1)return d;
	if(x==2)return min(2*d,a+d);
	int idx=bs(x);
	if(memo[idx])return memo[idx]-1;
	
	ll ans=INF;
	if(x<1e12/d)ans=x*d;
	
	ll t;
	if(x%2<=0){
		t=f(x/2);
		chmin(ans,t+a+d*(x%2));
	}else{
		t=f(x/2+1);
		chmin(ans,t+a+d*(2-x%2));
	}

	if(x%3<=1){
		t=f(x/3);
		chmin(ans,t+b+d*(x%3));
	}else{
		t=f(x/3+1);
		chmin(ans,t+b+d*(3-x%3));
	}

	if(x%5<=2){
		t=f(x/5);
		chmin(ans,t+c+d*(x%5));
	}else{
		t=f(x/5+1);
		chmin(ans,t+c+d*(5-x%5));
	}

	memo[idx]=ans+1;
	return ans;
}

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		ll n;
		scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
		cnt=0;
		for(ll temp0=n;temp0;temp0/=2){
			for(ll temp1=temp0;temp1;temp1/=3){
				for(ll temp2=temp1;temp2;temp2/=5){
					num[cnt++]=temp2;
					num[cnt++]=temp2+1;
				}
			}
		}
		cnt=uniquell(num,num,cnt);
		rep(i,0,cnt)memo[i]=0;
		printf("%lld\n",f(n));
	}
}

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

using namespace std;

int F[207][207];

int main()
{
//    freopen("TEST.INP", "r", stdin);
//    freopen("TEST.OUT", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int t;
    cin >> t;
    for (int i = 1; i <= t; ++i)
        for (int j = 1; j <= t; ++j)
            F[i][j] = __gcd(i, j);

    long long ans = 0LL;
    for (int i = 1; i <= t; ++i)
        for (int j = 1; j <= t; ++j)
            for (int k = 1; k <= t; ++k)
                ans += F[F[i][j]][k];

    cout << ans;
    return 0;
}


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

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    if ((A + B) % 2 == 0) cout << "Alice" << endl;
    else if ((A + B) % 2 == 1) cout << "Borys" << endl;
    else cout << "Draw" << endl;
}

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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve()
{
  int N, M;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s[i];
  }
  cin >> M;
  vector<string> t(M);
  for (int i = 0; i < M; i++) {
    cin >> t[i];
  }
  map<string, int> mp;
  for (int i = 0; i < N; i++) {
    mp[s[i]]++;
  }
  for (int i = 0; i < M; i++) {
    mp[t[i]]--;
  }
  int mx = 0;
  dump(mp);
  for (auto& m : mp) {
    mx = max(mx, m.second);
  }
  cout << mx << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    string s, t; cin >> s >> t;
    vector<char> sc(s.size());
    for(int i = 0; i < s.size(); i++){
        sc[i] = s[i];
    }
    sort(all(sc));
    vector<char> tc(t.size());
    for(int i = 0; i < t.size(); i++){
        tc[i] = t[i];
    }
    sort(all(tc), greater<>());
    string ss;
    for(char c : sc) ss += c;
    string tt;
    for(char c : tc) tt += c;
    if(ss < tt) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
  
int main()
{
  int S, h, m, s;
  cin >> S;

  s = S % 60;
  m = ((S - s)/60)%60;
  h = (S - s - 60*m)/3600;

  cout <<h<<":"<<m<<":"<<s<<"\n";

  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())

using namespace std;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

using ll = long long;
constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}

struct City {
    int cityNum;
    int prefNum;
    int year;
    string ID = "";
};

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

    int N, K;
    cin >> N >> K;
    vector<int>A(N);
    cin >> A;

    int ans = INF;
    REP(i, N - K + 1) {
        if (A[i] > 0) {
            ans = min(ans, A[i + K - 1]);
        }
        else if (A[i + K - 1] > 0) {
            ans = min(ans, abs(A[i]) * 2 + A[i + K - 1]);
            ans = min(ans, abs(A[i]) + A[i + K - 1] * 2);
        }
        else {
            ans = min(ans, abs(A[i]));
        }
    }
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int main (void){
  int i,count;
  long long int a[200],max=0,flag=0,n,k[100]={0};
  scanf("%d",&n);
 
  max=0;
  flag=0;
  for(i=0;i<n;i++)
  {
      scanf("%lld",&a[i]);
  }
  
  while(1)
  {
  for(i=0;i<n;i++)
  {
      if(a[i]%2==0){
          a[i]/=2;
        
          
      }else{
          flag=1;
          break;
          
      }
    
  }
  
  if(flag==1)
  {
      break;
  }
  max++;
  }
  printf("%lld",max);
   return 0;
    
}

Measured memory_bytes: 128
main(){
int i,n,a[200002],b[200002]={0};
long long c=0;
scanf("%d",&n);
for(i=0;i<n;i++)scanf("%d",&a[i]);
for(i=0;i<n;i++){
	if(i+a[i]<=n)b[i+a[i]]++;
	if(i-a[i]>=0)c+=b[i-a[i]];
}
printf("%lld",c);
}

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

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  
  int64_t ans = 0;
  if (X > Y) {
    if (A + B < 2 * C) {
      ans = A * X + B * Y;
    }
    else if (2 * C < A) {
      ans = C * X * 2;
    }
    else {
      ans = C * Y * 2 + A * (X - Y);
    }
  }
  else {
    swap(A, B);
    swap(X, Y);
    if (A + B < 2 * C) {
      ans = A * X + B * Y;
    }
    else if (2 * C < A) {
      ans = C * X * 2;
    }
    else {
      ans = C * Y * 2 + A * (X - Y);
    }
  }
  cout << ans << endl;
}

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

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const int max_n = 2000+10;
int H,W;
int field[max_n][max_n];
int dp1[max_n][max_n];
int dp2[max_n][max_n];

int solve(void) {
    for(int row = 1;row <= H;row++) {
        for(int col = 1;col <= W;col++) {
            if(field[row][col] == 0 && field[row][col-1] != -1) {
                dp1[row][col] = dp1[row][col-1]+1;
            } else if(field[row][col] == -1) {

            } else {
                dp1[row][col] = 1;
            }
        }

        for(int col = W-1;col >= 1;col--) {
            if(field[row][col] == 0 && field[row][col+1] != -1) {
                dp1[row][col] = dp1[row][col+1];
            } else if(field[row][col] == -1) {
                dp1[row][col] = 0;
            }
        }
    }

    for(int col = 1;col <= W;col++) {
        for(int row = 1;row <= H;row++) {
            if(field[row][col] == 0 && field[row-1][col] != -1) {
                dp2[row][col] = dp2[row-1][col]+1;
            } else if(field[row][col] == -1) {

            } else {
                dp2[row][col] = 1;
            }
        }
    

        for(int row = H-1;row >= 1;row--) {
            if(field[row][col] == 0 && field[row+1][col] != -1) {
                dp2[row][col] = dp2[row+1][col];
            } else if(field[row][col] == -1) {
                dp2[row][col] = 0;
            }
        }
    }

    int ans = 0;
    for(int i = 1;i <= H;i++) {
        for(int j = 1;j <= W;j++) {
            ans = max(dp1[i][j]+dp2[i][j]-1,ans);
        }
    }
    
    return ans;
}

int main(void) {
    cin>>H>>W;
    
    for(int i = 0;i < H;i++) {
        string s;
        cin>>s;
        for(int j = 0;j < W;j++) {
            if(s[j] == '#') {
                field[i+1][j+1] = -1;
            }
        }
    }

    cout<<solve()<<endl;

    return 0;
}


Measured memory_bytes: 47616
#include <stdio.h>

int main()
{   int n,m;
    scanf("%d%d",&n,&m);
    int k[m],s[11][11]={0};
    for(int i=0;i<m;i++){
        scanf("%d",&k[i]);
        for(int j=0;j<k[i];j++){
            scanf("%d",&s[i][j]);
        }
    }
    
    int p[m];
    for(int i=0;i<m;i++){
        scanf("%d",&p[i]);
    }
    int ans=0;
    for(int i=0;i<pow(2,n);i++){
        int cnt=0;
        for(int j=0;j<m;j++){
            int chk=0;
            for(int l=0;l<k[j];l++){
                if(i&((int)pow(2,s[j][l]-1))){
                    chk++;
                    //printf("chk increased @ i=%d,s[%d][%d]\n",i,j,l);
                }
            }
            if(chk%2==p[j]){
                cnt++;
                //printf("count increased at j=%d\n",j);
            }
        }
        if(cnt==m){
            ans++;
            //printf("ans increased @%d\n",i);
        }
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <map>
#include <algorithm>
#include <cstring>

using namespace std;

typedef pair<int,int> result;
int h,w,s;
result dp[33][33][33][33];
bool done[33][33][33][33];
int sum[33][33];
int g[33][33];

int get(int a,int b,int c,int d)
{
  return sum[d][c]-sum[b][c]-sum[d][a]+sum[b][a];
}

result solve(int a,int b,int c,int d)
{
  result& res = dp[a][b][c][d];
  if( done[a][b][c][d] ) return res;
  res = result(1,s-(get(0,0,w,h)-get(a,b,c,d)));
  //printf("%d %d %d %d\n",a,b,c,d);
  if( res.second < 0 ) res = result(0,0);
  for( int i = a+1; i < c; i++ ) {
    result p = solve(a,b,i,d);
    result q = solve(i,b,c,d);
    res = max(res,result(p.first+q.first,min(p.second,q.second)));
  }
  for( int i = b+1; i < d; i++ ) {
    result p = solve(a,b,c,i);
    result q = solve(a,i,c,d);
    res = max(res,result(p.first+q.first,min(p.second,q.second)));
  }
  done[a][b][c][d] = true;
  return res;
}

int main(void)
{
  for(;;) {
    scanf("%d%d%d",&h,&w,&s); if(h+w+s==0)break;
    for( int i = 0; i < h; i++ ) {
      for( int j = 0; j < w; j++ ) {
        scanf("%d", g[i]+j);
      }
    }
    for( int i = 0; i < h; i++ ) {
      for( int j = 0; j < w; j++ ) {
        sum[i+1][j+1] = sum[i+1][j]+g[i][j];
      }
    }
    for( int i = 0; i < h; i++ ) {
      for( int j = 0; j <= w; j++ ) {
        sum[i+1][j] += sum[i][j];
      }
    }
    memset(done,0,sizeof(done));
    result res = solve(0,0,w,h);
    if( w == 1 && h == 1 ) res = result(1,0);
    printf("%d %d\n",res.first,res.second);
  }
  return 0;
}

Measured memory_bytes: 11476
#include<iostream>

using namespace std;

int main(){
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 0;i <= n;i++){
		if(i % 2){
			int count = 0;
			for(int j = 1;j <= i;j++){
				if(i % j == 0){
					count++;
				}
			}
			if(count == 8){
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(long long i=0;i<(n);++i)
#define Fr(i,n) for(long long i=1;i<=(n);++i)
#define ifr(i,n) for(long long i=(n)-1;i>=0;--i)
#define iFr(i,n) for(long long i=(n);i>0;--i)

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h,m,hh,mm,k;
  cin>>h>>m>>hh>>mm>>k;
  cout<<max(0,60*(hh-h)+mm-m-k);

 
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long A, B, C;
  cin >> A >> B >> C;
  long long num = 0;
  long long ans = 0;
  if(A*B*C %2 == 0){
    ans = 0;
  }
  else{
    num = max(A, B);
    num = max(num, C);
    if(num == A){
      ans = B*C;
    }
    if(num == B){
      ans = A*C;
    }
    if(num == C){
      ans = A*B;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli t, x;
int main() {
  cin >> t >> x;
  printf("%.12lf\n", (double)t / x);
  return 0;
}



Measured memory_bytes: 256
n,m,q = map(int, raw_input().split(' '))
reqs= [map(int, raw_input().split(' ')) for _ in range(q)]
max_ = [0]

def dfs(i, cur, n, m, reqs ):
	if n == 0:
		score = 0
		for a,b,c,d in reqs:
			if cur[b-1] - cur[a-1] == c: score += d
		max_[0] = max(max_[0], score)
		return 

	for j in range(i, m+1):
		dfs(j, cur + [j], n-1, m, reqs)

dfs(1, [], n, m, reqs)
print max_[0]


Measured memory_bytes: 81856
// AOJ 2570: Shipura
// 2017.12.1 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

#define M  1000000007
#define TOP -1
#define SFT -2
#define S   -3

char b1[2000002];
int stack[2000002], top;

int main()
{
	int x, y;
	char *p;

	while (fgets(b1+1, sizeof(b1), stdin) && *(b1+1) != '#') {
		p = b1, *p++ = 0; while (*p >= ' ') *p++; *p-- = 0;
		while (*p) {
			if (*p == '<') { *p-- = ' '; continue; }
			if (!isdigit(*p) && *p != 'S') { p--; continue; }
			if (*p == 'S') p--;
			else while (isdigit(*p)) p--;
			while (*p == ' ') p--;
			if (*p == '>' && *(p-1) == '>') *p = 'R', *(p-1) = ' ', p-=2;
		}

		p++, stack[0] = TOP, top = 1;
		while (*p) {
			while (*p == ' ') p++;
			if (*p == 'S') { p++, stack[top++] = S; continue; }
			if (*p == 'R') { p++, stack[top++] = SFT; continue; }
			if (isdigit(*p)) {
				x = 0; while (isdigit(*p)) x = (x<<3)+(x<<1) + (*p++ & 0xf);
			} else {		//  '>'
				p++;
				x = stack[--top];
				x = (long long)x * x % M;
				top--;
			}
			if (stack[top-1] == SFT) {
				top -= 2;
				y = stack[top];
				if (x > 31) y = 0;
				else y >>= x;
				x = y;
			}
			stack[top++] = x;
		}
		printf("%d\n", x);
	}
	return 0;
}

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

int main(void) 
{
    int r;
    cin >> r;

    cout << 2* r * M_PI << endl;
    return 0;
}

Measured memory_bytes: 3788
S = input()
T = input()
ls = len(S)
lt = len(T)

dp = [[0]*(lt+1) for _ in range(ls+1)]
dp[0][0] = 0
for i, s in enumerate(S):
    for j, t in enumerate(T):
        if s == t:
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1)
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j])
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1])

ans = ''
i = ls
j = lt
while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans = S[i-1] + ans
        i -= 1
        j -= 1
print(ans)

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

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define fr(i, a, b) for(int i = a ; i < b ; i++)
#define frr(i, a, b) for(int i = a ; i >= b ; i--)
#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str() // int to string
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)
#define deb(x) cout << #x" = " << x << '\n'
#define has(cont, x) ((cont).find((x)) != (cont).end())
#define sz(x) ((int)(x).size())

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

int main() {
//    freopen("input.in", "r", stdin);
	char lul[123456];
	scanf("%s", lul);
	fr(i, 0, strlen(lul)) putchar((lul[i] == ',' ? ' ' : lul[i] ));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<map>
#include<set>
#include<bitset>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//Library
/*Union-Find木
int par[1000010], rankh[1000010];
void init(int n) {
	for (int i = 0; i <= n; i++) {
		par[i] = i;
		rankh[i] = 0;
	}
}
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 (rankh[x] < rankh[y])par[x] = y;
	else {
		par[y] = x;
		if (rankh[x] == rankh[y])rankh[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
template<typename t>
t GCD(t a, t b) {
	while (max(a, b) % min(a, b)) {
		if (a > b)a %= b;
		else b %= a;
	}
	return min(a, b);
}
Union-Find木end*/
//Library end
int a[100][100], b[100], ans;
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++)cin >> a[i][j];
	}
	for (int i = 0; i < m; i++)cin >> b[i];
	for (int i = 0; i < n; i++) {
		ans = 0;
		for (int j = 0; j < m; j++) {
			ans += a[i][j] * b[j];
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3128
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<math.h>

using namespace std;

typedef long long ll;

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

const ll INF = 1LL << 60;


signed main() {

	ll l, r;
	cin >> l >> r;
	ll ans = 2019;

	if (r - l >= 2019) {
		cout << 0;
		return 0;
	}
	else {
		for (int i = l; i <= r - 1; i++) {
			for (int j = i + 1; j <= r; j++) {
				ll a = i % 2019;
				ll b = j % 2019;
				ll c = (a * b) % 2019;
				ans = min(c, ans);
			}
		}
		cout << ans;
	}
}


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

using namespace std;

int Ma[67500000], m;

int main()
{
    string s;
    cin >> s;
    long long n=s.length(), a;
    long long H[n+1], D[n+1];
    for (int i = 0; i < 67500000; i++)
    {
        Ma[i] = 2000000;
    }
    H[0] = 0;
    D[0] = 0;
    Ma[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        D[i] = 2000000000;
        a = s[i-1] - 'a';
        H[i] = (H[i-1] ^ (1 << a));
        for (int y = 0; y < 26; y++)
        {
            int b = (1 << y);
            a = Ma[(b ^ H[i])];
            if (a != 2000000)
            {
                D[i] = min(D[i], a+1);
            }
        }
        a = Ma[H[i]];
        if (a != -1)
        {
            D[i] = min(D[i], a+1);
        }
        m = D[i];
        Ma[H[i]] = min(m, Ma[H[i]]);
    }
    cout << D[n];
    return 0;
}


Measured memory_bytes: 267396
#include<iostream>
using namespace std;
long long int k[21][101],n,num[100],sum;
main(){
cin>>n;
for(int i=0;i<n;i++){cin>>num[i];}
k[num[0]][0]=1;
for(int i=1;i<n-1;i++){for(int j=0;j<21;j++){
if(j+num[i]<21){k[j+num[i]][i]+=k[j][i-1];}
if(j-num[i]>=0){k[j-num[i]][i] += k[j][i-1];}
}}
sum=k[num[n-1]][n-2];
cout<<sum<<endl;}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> x(N), y(N), index(N);
    rep(i, N) {
        cin >> x[i] >> y[i];
    }
    rep(i, N) {
        index[i] = i;
    }

    auto dist = [&](int i, int j) {
        int dx = x[i] - x[j];
        int dy = y[i] - y[j];
        return sqrt(dx*dx + dy*dy);
    };

    double total = 0;
    int count = 0;
    do {
        for (int i = 0; i < N-1; i++) {
            total += dist(index[i], index[i+1]);
        }
        count++;
    } while (next_permutation(index.begin(), index.end()));

    printf("%.10f", total / count);
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int h[N+5] = {0};
  rep(i,N) cin >> h[i];
  
  int ans = 0;
  rep(i, N) {
    if (h[i] >= K) ans += 1;
  }
  cout << ans;
  return 0;
}



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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(void){
    int N; cin >> N;
    int M; cin >> M;
    UnionFind uf(N);
    int acc = 0;
    pair<int, pair<int, int> > edge[M]; // (cost, (node_x, node_y))
    priority_queue<pair<int, pair<int, int> >, vector<pair<int, pair<int, int> > >, greater<pair<int, pair<int, int> > > > pq;
    rep(i, M){
        int x, y, cost; cin >> x >> y >> cost;
        //x--; y--;
        edge[i] = make_pair(cost, make_pair(x, y));
    }
    rep(i, M) pq.push(edge[i]);
    rep(i, M){
        pair<int, pair<int, int> > op;
        op = pq.top();
        int x = op.second.first;
        int y = op.second.second;
        int c = op.first;
        pq.pop();
        if(!uf.issame(x, y)){
            uf.merge(x, y);
            acc += c;
        }
    }
    cout << acc << endl;
    return 0;
}


Measured memory_bytes: 5656