akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int N, K;
    int P = 0, M = 0, Z = 0;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i,N) {
        cin >> A[i];
        if (A[i] > 0) P++;
        else if (A[i] < 0) M++;
        else Z++;
    }

    bool plusable = false;
    for (int i = 0; i <= min(M, K); i += 2) {
        if (K - i <= P) plusable = true;
    }

    ll ans = 1;

    if (!plusable) {
        if (Z > 0) {
            cout << 0 << endl;
            return 0;
        }
        vector<ll> B(N);
        rep(i,N) B[i] = abs(A[i]);
        sort(B.begin(), B.end());
        rep(i,K) {
            ans *= B[i];
            ans += MOD;
            ans %= MOD;
        }
        ans *= -1;
        ans += MOD;
        ans %= MOD;
        cout << ans << endl;
        return 0;
    }

    deque<ll> plus, minus;
    rep(i,N) {
        if (A[i] > 0) plus.push_back(A[i]);
        else minus.push_back(A[i]);
    }

    sort(plus.begin(), plus.end(), greater<ll>());
    sort(minus.begin(), minus.end());

    while (K > 0) {
        bool flag = true;
        if (K >= 2 && minus.size() >= 2) {
            if (plus.size() == 0) flag = false;
            else if (plus.size() == 1) flag = false;
            else if (plus[0] * plus[1] <= minus[0] * minus[1]) flag = false;
        }
        if (flag) {
            ans *= plus[0]; plus.pop_front();
            ans %= MOD;
            K--;
        } else {
            ans *= minus[0]; minus.pop_front();
            ans %= MOD;
            ans *= minus[0]; minus.pop_front();
            ans %= MOD;
            K -= 2;
        }
    }

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

Measured memory_bytes: 6428
/* A - Registration */

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

int main(void){
  char S[15], T[15], *s, i;
  scanf("%s", S);
  scanf("%s", T);
  s = (char*)malloc(sizeof(char) * (strlen(S) + 1));
  for(i = 0; i < strlen(S); i++){
    s[i] = T[i];
  }
  s[i] = '\0';
  if(strcmp(S, s) == 0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
}


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

int main()
{
	int n, m = 0;

	cin >> n;

	for (int i = 1; i <= n; i++) {
		if (i < 10)
			m++;
		else if (i > 99 && i < 1000)
			m++;
		else if (i > 9999 && i < 100000)
			m++;
	}

	cout << m << endl;

	return 0;
}

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

int main(){
  char ch1,ch2,ch3,ch4;
  cin>>ch1>>ch2>>ch3>>ch4;
  if(ch1==ch2 || ch2==ch3 || ch3==ch4) cout<<"Bad"<<endl;
  else cout<<"Good"<<endl;
  return 0;
}
  

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	int n;
	unsigned int s;

	cin >> n;

	for( int i = 0;i < n;i++ ){
		cin >> s;
		cout << "Case " << i + 1 << ":" << endl;

		for( int j = 0;j < 10;j++ ){
			s *= s;
			s /= 100;
			unsigned int a = s / 10000;
			a *= 10000;
			s -= a;

			cout << s << endl;
		}
	}
	

	return 0;
}

Measured memory_bytes: 0
n = int(input())
A = [[0, 0, 0]]
for i in range(n):
    A.append([int(i) for i in input().split()])

ans = 'Yes'
for i in range(n):
    dist = abs(A[i][1] - A[i + 1][1]) + abs(A[i][2] - A[i + 1][2])
    if A[i + 1][0] - A[i][0] - dist < 0:
        ans = 'No'
    elif (A[i + 1][0] - A[i][0] - dist) % 2 == 1:
        ans = 'No'
        
print(ans)

Measured memory_bytes: 21156
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using static System.Math;

class Program{
	static int n;
	static int k;
	static string s;
	static RSQ1 rsq;
	static bool f; //先頭が立っているか

	static void Main(){
		string[] input = Console.ReadLine().Split();
		n = int.Parse(input[0]);
		k = int.Parse(input[1]);
		s = Console.ReadLine();

		f = s[0] == '0';
		List<int> ls = new List<int>();
		if (f) ls.Add(0);
		int count = 0;
		for (int i = 0;i < n;i++){
			count++;
			if (i == n - 1 || s[i] != s[i + 1]){
				ls.Add(count);
				count = 0;
			}
		}

		int lsc = ls.Count();
		if (lsc / 2 <= k){
			Console.WriteLine(n);
			return;
		}
		rsq = new RSQ1(lsc);
		for (int i = 0;i < lsc;i++) rsq[i] = ls[i];

		long ans = 0;
		for (int i = 0;i < lsc ;i+=2)
				ans = Max(ans,rsq.Query(i,Min(i + 1 + 2 * k,lsc)));
		Console.WriteLine(ans);
	}
}

struct RSQ1
{
    private int n;
    private long[] dat;
    public int Length { get; private set; }
    public long this[int i]
    {
        get
        {
            if (i < 0 || i >= this.Length)
                throw new IndexOutOfRangeException();
            return dat[i + n - 1];
        }
        set { this.Update(i, value); }
    }

    /* nを要素数として、すべて0で初期化 */
    public RSQ1(int n)
    {
        Length = n;
        this.n = 1;
        while (this.n < n) this.n *= 2;
        dat = new long[2 * this.n];
    }

    /* k番目(0-indexed)をaに変更 */
    public void Update(int k, long a)
    {
        k += n - 1;
        dat[k] = a;
        while (k > 0)
        {
            k = (k - 1) / 2;
            dat[k] = dat[k * 2 + 1] + dat[k * 2 + 2];
        }
    }

    private long Query_(int a, int b, int k, int l, int r)
    {
        if (r <= a || b <= l) return 0;
        if (a <= l && r <= b) return dat[k];
        long v1 = Query_(a, b, k * 2 + 1, l, (l + r) / 2);
        long v2 = Query_(a, b, k * 2 + 2, (l + r) / 2, r);
        return v1 + v2;
    }

    /* [a,b)の和を求める */
    public long Query(int a, int b)
    {
        return Query_(a, b, 0, 0, n);
    }
}

Measured memory_bytes: 16200
s=input()
x=0
y=0
u=int(s[0:2])
d=int(s[2:])

if 1<=u and u<=12:
    x=1
else:
    x=-1
if 1<=d and d<=12:
    y=1
else:
    y=-1
    
if x*y==1 and x<0:
    print('NA')
elif x*y==1:
    print('AMBIGUOUS')
elif x==1 and y==-1:
    print('MMYY')
else:
    print('YYMM')



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  ll n;
  cin >> n;
  cout << n * (n - 1) / 2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  int N,x,ans=0;
  cin >> N >> x;
  vector<int> v(N);
  FOR(i,0,N)cin >> v[i];
  sort(ALL(v));
  FOR(i,0,N){
    if(v[i] <= x){
      x -= v[i];
      ans++;
    }
  }
  if(ans < N)cout << ans << endl;
  else if(x != 0)cout << ans-1 << endl;
  else cout << ans << endl;
}


Measured memory_bytes: 256
import Control.Monad
import Data.List
main = do
  [x,y,z,k] <- map read . words <$> getLine :: IO [Int]
  as <- map read . words <$> getLine :: IO [Int]
  bs <- map read . words <$> getLine
  cs <- map read . words <$> getLine
  let ab = take k $ sortBy (flip compare) [a+b| a <- as, b <- bs]
      abc = take k $ sortBy (flip compare) [ab+c| ab <- ab, c <- cs]
  mapM_ print abc

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

int main(){
    int num=1,n,cnt=0;
    cin >> n;
    vector<int> btn(n),visit(n);
    for(int i=0;i<n;i++)
        cin >> btn.at(i);
    while(cnt<n){
        num = btn.at(num-1);
        if(visit.at(num-1)==0)
            visit.at(num-1)=1;
        else
            cnt = n;        
        cnt++;
        if(num==2)
            break;
    }
    if(cnt<n)
        cout << cnt << endl;
    else
        cout << -1 << endl;        
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int K;
  cin>>N>>K;
  int sum=0;
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    if(abs(x-K)<x){
      sum=sum+abs(x-K);
    }
    else{
      sum=sum+x;
    }
  }
  cout<<2*sum<<endl;
}

Measured memory_bytes: 256
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque


def main():
    s = input()

    aa = ['AKIHABARA', 'AKIHABAR', 'AKIHABRA', 'AKIHABR', 'AKIHBARA', 'AKIHBAR', 'AKIHBRA', 'AKIHBR']
    bb = ['KIHABARA', 'KIHABAR', 'KIHABRA', 'KIHABR', 'KIHBARA', 'KIHBAR', 'KIHBRA', 'KIHBR']

    if s in aa or s in bb:
        print('YES')
    else:
        print('NO')





if __name__ == '__main__':
    main()
    # test()



Measured memory_bytes: 38892
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include <string.h>
using namespace std;

int main() {
    char  s[10];
    
    cin >> s;
    
    if ( s[0] >= 'A' && s[0] <= 'Z' ) {
        cout << "A" << endl;
    } else {
        cout << "a" << endl;
    }
    
    return 0;
    
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    long long int N,M,H,W,x,i,j,k,ans,count,cost,tmp,a,b,c,d,c1,c2,HP;
    long long int S[110000];
    //long long int T[11000];
    //long long int U[300000];
    //long long int Ssum[300000];
    string T[110],TA,V,G,ans2;
    bool flag;
    count=0;
    ans=std::pow(10,18);
    ans=0;
    flag=false;
        cin >> HP >>N;
    for (i=0;i<N;i++){
        cin >>S[i];
        count+=S[i];
    }
    

    
        //cin >> c >>d;
        //count=0;
    
    //cout << count<<endl;
    
    
    
    if (HP<=count){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
    
}


Measured memory_bytes: 4420
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#define M 10000
#define E 500000
    
typedef struct edge {
    int from, to, cost;
} Ed;
Ed e[E];
int d[M];
    
void sp(int,int);
   
int main(int argc,char* argv[])
{
    int vn, en, an;
    int i, j, vi;
    scanf("%d", &vn);
    
    en=0;
    for(i=0; i<vn; i++) {
        scanf("%d", &vi);
        scanf("%d", &an);
        for(j=1; j<=an; j++) {
            e[en].from=vi;
            scanf("%d %d", &e[en].to, &e[en].cost);
            en++;
        }
    }
        
    sp(vn, en);
    for(i=0; i<vn; i++) {
        printf("%d %d\n", i, d[i]);
    }
    return 0;
}
void sp(int vn, int en)
{
    int i, new=1;
    for(i=1; i<vn; i++) d[i]=INT_MAX;
        
    while(new) {
        new=0;
        for(i=0; i<en; i++) {
            if(d[e[i].from] !=INT_MAX && d[e[i].from]+e[i].cost < d[e[i].to]) {
                d[e[i].to] = d[e[i].from]+e[i].cost;
                new++;
            }
        }
    }
}

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

int main() {
  char c;
  cin >> c;
  const string vowel = "aiueo";
  string s = "consonant";
  for (int i = 0; i < vowel.size(); i++) {
  	if (c == vowel.at(i)) {
    	s = "vowel";
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] P = new int[N];
    for (int i = 0; i < N; i++) { P[i] = sc.nextInt(); }
    
    int ans = 0;
    int min = 1000000;
    for (int i = 0; i < N; i++) {
      if (P[i] < min) {
        ans++;
      }
      min = Math.min(min, P[i]);
    }
    
    System.out.println(ans);
    
  }
}

Measured memory_bytes: 85096
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   string s, t;
   cin >> s >> t;

   vector< vector<int> > log(26);
   bool rec[26];
   memset(rec, 0, sizeof(rec));
   for (int i = 0; i < (int)s.size(); i++) {
      int id = s[i] - 'a';
      log[id].push_back(i);
      rec[id] = true;
   }

   int N = t.size();
   int tlog[N];
   int tmp = -1;
   int cnt = 0;
   for (int i = 0; i < N; i++) {
      int id = t[i] - 'a';
      if (!rec[id]) {
         cout << "-1" << endl;
         return 0;
      }
      int pos = upper_bound(log[id].begin(), log[id].end(), tmp) - log[id].begin();
      // cout << t[i] << " " << pos << endl;
      if (pos == log[id].size()) {
         pos = 0;
         cnt++;
      }
      // cout << t[i] << " " << pos << endl;
      tlog[i] = log[id][pos];
      tmp = tlog[i];
      // cout << t[i] << " " << tmp << endl;
   }
   ll M = s.size();
   ll ans = cnt *  M + tmp + 1;  
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 1468
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

void solve()
{
    ll x;
    cin>>x;
    if(x>=30)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define ull         unsigned long long int
#define ll          long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
#define ordered_set     tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> 
 
const long long INF = (long long) 1e14+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

ll power(ll x,ll y){
  ll res=1;
  while(y>0){
    if(y%2) res=(x%hell*res%hell)%hell;
    x=(x%hell*x%hell)%hell;    
    y=y/2;
  }
  
  return res%hell;
}
 
ll modinv(ll x){
  return power(x,hell-2);
}    
    
ll gcd(ll a,ll b){
    while(b!= 0){
	    ll t=b;
	    b=a%t;
	    a=t;
	}
	return a;
}    
        
void fastIO(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}    

void solve(){    
    ll n;
    cin>>n;
    vector<pair<ll,ll>> vec(n);
    
    forn(i,0,n)
    cin>>vec[i].F>>vec[i].S;    
    
    ll ans=0;
    ll mn=INF;
    ll mx=-INF;
    
    forn(i,0,n){
        mx=max(mx,vec[i].F+vec[i].S);
        mn=min(mn,vec[i].F+vec[i].S);
    }
    
    ans=max(ans,abs(mx-mn));
    mn=INF;
    mx=-INF;
    
    forn(i,0,n){
        mx=max(mx,vec[i].F-vec[i].S);
        mn=min(mn,vec[i].F-vec[i].S);
    }
    ans=max(ans,abs(mx-mn));
    cout<<ans;
}     
    
int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;    
      
   while(test--)
   solve();
}    

Measured memory_bytes: 6344
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  bool first = false;
  rep(i, N) {
    int a;
    cin >> a;
    if(a % 2) first = true;
  }
  cout << (first ? "first" : "second") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  long a,b,c=0,d=0,e,n,m,x,y;
  cin>>a>>b>>n;
  rep(i,1,min(a,b)+1){
    if(a%i==0 && b%i==0){
      c++;
    }
  }
  rep(i,1,min(a,b)+1){
    if(a%i==0 && b%i==0){
      d++;
    }
    if(d==c-n+1){
      co(i);
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
N = int(input())

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))


sume = 0

for i in range(N-1):
    if(A[i+1] == 1 + A[i]):
        sume += C[A[i]-1]
          
        
sume += sum(B)
print(sume)

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

vector<int> a(4);

bool dfs(int i, int sum, vector<string> &A) {
	if (i == 4) return sum == 7;
	A.at(i - 1) = "+";
	if (dfs(i + 1, sum + a.at(i), A)) return true;
	A.at(i - 1) = "-";
	if (dfs(i + 1, sum - a.at(i), A)) return true;
	return false;
}

int main() {
	string S;
	cin >> S;
	for (int i = 0; i < 4; i++) {
		a.at(i) = S.at(i) - '0';
	}
	vector<string> A(3);
	if (dfs(1, a.at(0), A)) {
		printf("%d%s%d%s%d%s%d=7\n", a.at(0), A.at(0).c_str(), a.at(1), A.at(1).c_str(), a.at(2), A.at(2).c_str(), a.at(3));
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int a; cin >> a;
    int ans = 0;
    rep(i,a){
        int b,c; cin >> b >>c;
        ans += c-b+1;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
object MainKt {
  @JvmStatic fun main(args:Array<String>) {
    val s=readLine()
    for (c in 0..3)
    {
      print(s!![c])
    }
    print(" ")
    for (c in 4..11)
    {
      print(s!![c])
    }
    println()
  }
}


Measured memory_bytes: 18344
s = []
while True:
    try:
        s.append(str(input()))
    except EOFError:
        break

def func(x):
    array = []
    if len(x) == 1:
        return x[0]
    for i in range(len(x)-1):
        array.append((x[i] + x[i+1]) % 10)
    return func(array)

for i in range(len(s)):
    arr = list(s[i])
    for j in range(len(arr)):
        arr[j] = int(arr[j])
    print(func(arr))
        

Measured memory_bytes: 7600
#include<bits/stdc++.h>
using namespace std;
using FLOAT = double;
struct Point{
    FLOAT x, y;
    FLOAT operator * (const Point& point)const{return x * point.x + y * point.y;}
    FLOAT norm2()const{return x * x + y * y;}
    Point operator - (const Point& point)const{return {x - point.x, y - point.y};}
    Point operator + (const Point& point)const{return {x + point.x, y + point.y};}
    Point operator * (const FLOAT& k)const{return {k * x, k * y};}
};
Point operator * (const FLOAT& k, const Point& point){return point * k;}
struct Line{
    Point A, B;
    Point AB()const{return B - A;}
};
Point projection(const Point& point, const Line& line){
    return line.A + (point - line.A) * line.AB() / line.AB().norm2() * line.AB();
}
Point reflection(const Point& point, const Line& line){
    return 2 * projection(point, line) - point;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed << setprecision(20);
    Line line;
    cin >> line.A.x >> line.A.y >> line.B.x >> line.B.y;
    int q;
    cin >> q;
    for(int i = 0; i < q; i += 1){
        Point point;
        cin >> point.x >> point.y;
        auto result = reflection(point, line);
        cout << result.x << " " << result.y << "\n";
    }
    return 0;
}


Measured memory_bytes: 3304
#include<bits/stdc++.h>
using namespace std;
int  main()
{
	int K;
	cin>>K;
	if(K==1)
	cout<<"ACL"<<endl;
	if(K==2)
	cout<<"ACLACL"<<endl;
	if(K==3)
	cout<<"ACLACLACL"<<endl;
	if(K==4)
	cout<<"ACLACLACLACL"<<endl;
	if(K==5)
	cout<<"ACLACLACLACLACL"<<endl;
	cout<<endl; 
	return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define rep(i,n) for(int i=0; i <(n); i++)

int main(){
  char s[26];
  int ck[26]={0};
  int cnt[26]={0};
  scanf("%s",s);
  int len=strlen(s);
  rep(i,len){
    ck[i]=s[i]-'a';
    //printf("%d\n",ck[i]);
  }
  rep(j,len){
    //printf("%d",ck[j]);
    cnt[ck[j]]++;
  }
  rep(k,26){
    if(cnt[k]>1){
      printf("no\n");
      return 0;
    }
  }
  printf("yes\n");
  return 0;
}


Measured memory_bytes: 1588
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
int n;
cin>>n;
int a,ans=0;
for(int i=0;i<n;i++)
{
cin>>a;
if(i%2==0 && a%2!=0)
{
ans++;
}
}
cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include <iostream>

using namespace std;

#define BIGINT_SIZE (1000)

class BigInt {
private:
    unsigned int _num[BIGINT_SIZE]{};

    void carry_up() {
        for (int i = 0; i < BIGINT_SIZE - 1; ++i) {
            if (_num[i] >= 10) {
                _num[i + 1] += _num[i] / 10;
                _num[i] %= 10;
            }
        }
    }

public:
    BigInt() {
        for (unsigned int &i : _num) {
            i = 0;
        }
    }

    void add(int num) {
        _num[0] += num;
        carry_up();
    }

    string to_string() {

        int i = BIGINT_SIZE - 1;
        for (; i >= 0; --i) {
            if (_num[i] != 0) break;
        }
        if (i < 0) {
            return "0";
        }

        string ret;
        while (i >= 0) {
            ret += ::to_string(_num[i]);
            i--;
        }

        return ret;
    }
};

int main() {
    string s, t;
    cin >> s >> t;

//    unordered_map<string, int> mp;
    BigInt count;

    int prev_pos = -1;
    for (char c : t) {
        if (++prev_pos >= s.length()) {
            prev_pos = 0;
            count.add(s.length());
        }

        int pos_from_prev_pos = s.find(c, prev_pos);

        if (pos_from_prev_pos != string::npos) {
            prev_pos = pos_from_prev_pos;
            continue;
        }

        count.add(s.length());
        int pos_from_top = s.find(c);
        if (pos_from_top == string::npos) {
            cout << "-1" << endl;
            return 0;
        }

        prev_pos = pos_from_top;
    }

    count.add(prev_pos + 1);

    string answer = count.to_string();
//    if (answer.length() <= (s.length() * (10 ^ 100))) {
    cout << answer << endl;
//    } else {
//        cout << "-1" << endl;
//    }
}


Measured memory_bytes: 640
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=2e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const double PI = acos(-1);

void solve(){
    int a,b,c;
    cin>>a>>b>>c;
    loop(b+1,i,1){
        if((a*i)%b==c){
            cout<<"YES"<<Endl;
            return;
        }
    }
    cout<<"NO"<<Endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}


Measured memory_bytes: 3632
n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
	c=(n+1)//i
	d=(n+1)%i
	ans+=max(0,i-k)*c
	if d-k>=0:
		ans+=d-k
if k==0:
	ans-=n
print(ans)


	


Measured memory_bytes: 39280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e4 + 7;
const double pi = acos(-1);
const int mod = 998244353;
const double eps = 1e-8;

int main(){     	
	double l;
	cin >> l;
	printf("%.8lf\n",(double)l*l*l/27.0);
    return 0;
}


Measured memory_bytes: 256
<?php
$N = trim(fgets(STDIN));
$A[] = explode(' ', trim(fgets(STDIN)));
$A[] = explode(' ', trim(fgets(STDIN)));

$B[0][0] = $A[0][0];
$B[1][$N-1] = $A[1][$N-1];
for ($i = 1; $i < $N; $i++) {
    $B[0][$i] = $B[0][$i-1] + $A[0][$i];
    $B[1][$N-$i-1] = $B[1][$N-$i] + $A[1][$N-$i-1];
}

$max = 0;
for ($i = 0; $i < $N; $i++) {
    $max = max($max, $B[0][$i] + $B[1][$i]);
}
print "{$max}\n";

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

int main()
{
    std::uint64_t N;
    std::cin >> N;

    std::uint64_t counter = 1;
    std::uint64_t total   = 26;
    std::uint64_t current = 26;
    while(total < N)
    {
        counter += 1;
        current *= 26;
        total   += current;
    }
    total -= current;

    std::uint64_t rest = N - total - 1;
    std::string name(counter, 'a');
    for(std::size_t i=0; i<name.size(); ++i)
    {
        name.at(i) = 'a' + rest % 26;
        rest /= 26;
    }
    std::reverse(name.begin(), name.end());
    std::cout << name << std::endl;

    return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>

int main(){

     int a, b, c;

     scanf ("%d %d", &a, &b);

     if (a > b) {
          while(b != 0) {
               c = b;
               b = a % c;
               a = c;
          } 
     }

     else {
          while(a != 0) {
               c = a;
               a = b % c;
               b = c;
          } 
     }
 
     printf ("%d\n", c);
  
     return 0;


}

Measured memory_bytes: 2748
#include <cstdio>
#include <sstream>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <iostream>
#include <fstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <iterator>
#include <iomanip>
#include <unordered_map>
#include <bits/stdc++.h>

using namespace std;


int main()
{
    int h,w;

    cin>>h>>w;
    char grid[h][w];
    int dp[h+1][w+1]= {};
    for(int i=0; i<h; i++)
        for(int j=0; j<w; j++)
            cin>>grid[i][j];

    dp[h-1][w]=1;

    for(int i=h-1; i>=0; i--)
        for(int j=w-1; j>=0; j--)
            if(grid[i][j]=='.')
                dp[i][j]=(dp[i][j+1]+dp[i+1][j])%1000000007;

    cout<<dp[0][0]<<endl;

}


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

int main() {

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

    vector<int> ac(N + 1), wa(N + 1);
    rep(i, M) {
        int p;
        string s;
        cin >> p >> s;

        if (ac[p] >= 1)
            continue;
        if (s == "AC")
            ac[p]++;
        else
            wa[p]++;
    }

    int ans_ac = 0, ans_wa = 0;

    for (int i = 1; i <= N; i++) {
        if (ac[i] >= 1) {
            ans_ac++;
            ans_wa += wa[i];
        }
    }

    cout << ans_ac << " " << ans_wa << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>

using lint = long long;

template <class T, class E>
struct StarrySkyTree {
    using OMerger = std::function<E(E, E)>;
    using Applier = std::function<T(T, E)>;

    int length;

    T d_unit;
    E o_unit;

    std::vector<E> ope;

    OMerger omerge;
    Applier app;

    void update(int ql, int qr, E e, int nidx, int nl, int nr) {
        if (nr <= ql || qr <= nl) return;
        if (ql <= nl && nr <= qr) {
            ope[nidx] = omerge(ope[nidx], e);
            return;
        }

        int nm = (nl + nr) / 2;
        update(ql, qr, e, nidx * 2 + 0, nl, nm);
        update(ql, qr, e, nidx * 2 + 1, nm, nr);
    }

    void update(int ql, int qr, E e) { return update(ql, qr, e, 1, 0, length); }

    T query(int idx) {
        idx += length;
        T dat = d_unit;
        while (idx > 0) {
            dat = app(dat, ope[idx]);
            idx >>= 1;
        }
        return dat;
    }

    explicit StarrySkyTree(int n, T d_unit, E o_unit,
                           OMerger omerge,
                           Applier app)
        : length(1),
          d_unit(d_unit),
          o_unit(o_unit),
          omerge(omerge),
          app(app) {
        while (length < n) length <<= 1;
        ope.assign(length * 2, o_unit);
    }
};

void solve() {
    int n, d;
    lint a;
    std::cin >> n >> d >> a;

    std::vector<std::pair<int, lint>> ps(n);
    for (auto& p : ps) {
        std::cin >> p.first >> p.second;
    }
    std::sort(ps.begin(), ps.end());

    StarrySkyTree<lint, lint>
        seg(
            n, 0, 0,
            [](lint e, lint f) { return e + f; },
            [](lint a, lint e) { return a + e; });

    for (int i = 0; i < n; ++i) {
        seg.update(i, i + 1, ps[i].second);
    }

    lint ans = 0;
    int r = 0;
    for (int l = 0; l < n; ++l) {
        while (r < n && ps[r].first - ps[l].first <= d * 2) ++r;

        lint h = seg.query(l);
        if (h < 0) continue;

        lint t = (h + a - 1) / a;
        ans += t;
        seg.update(l, r, -t * a);
    }

    std::cout << ans << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}


Measured memory_bytes: 7552
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
int main(void){
char s[200000];
int n,N;cin >> N;
cin >> s;
n = strlen(s);
for(int i = 0; i < n; i++){
    int m = s[i];
    m += N;
    if(m > 90) m -= 26;
    s[i] = m;
    cout << s[i];
    }
cout << "\n";    
}

Measured memory_bytes: 256
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]
A = [0 for i in range(26)]
ans = 0
for i in range(D):
  K = []
  for k in range(26):
    t = k+1
    A[t-1] = i+1
    c = 0
    for j in range(26):
      c += C[j] * (i+1-A[j])
    an = S[i][t-1]-c
    K.append([ans + an, t])
  K.sort()
  a = K[-1][1]
  print(a)
  ans = K[-1][0]
  

Measured memory_bytes: 9392
import java.util.List;
import java.util.Scanner;
import java.util.Vector;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String K = sc.next();
		int d = sc.nextInt();

		long f[] = new long[d];
		long g[] = new long[d];
		g[0] = 1;

		for (int j = 0; j < K.length(); j++) {
			int x = K.charAt(j) - '0';
			long f1[] = new long[d];
			long g1[] = new long[d];
			for (int i = 0; i < d; i++) {
				long sumF = 0;
				long sumG = 0;
				for (int k = 0; k < 10; k++)
					sumF = (sumF + f[(i + d - (k % d)) % d])%1000000007;
				for (int k = 0; k < x; k++)
					sumG = (sumG + g[(i + d - (k % d)) % d]) %1000000007;
				f1[i] = sumF + sumG;
				g1[i] = g[(i + d - (x % d)) % d];
			}
			f = f1;
			g = g1;
		}
		System.out.println((f[0]+g[0]+1000000006)%1000000007);

	}

}


Measured memory_bytes: 39664
from itertools import chain


def cost(p1, p2):
    return abs(p1 - p2)


input()
points = tuple(chain.from_iterable(([0], tuple(map(int, input().split(' '))), [0])))

base_cost = sum([cost(p, pre_p) for pre_p, p in zip(points, points[1:])])

for pre_p, p, next_p in zip(points, points[1:], points[2:]):
    diff = cost(pre_p, next_p) - cost(pre_p, p) - cost(p, next_p)
    print(base_cost + diff)


Measured memory_bytes: 14168
#include<bits/stdc++.h>
#define ll long long
#define pa pair<int,int>
using namespace std;
int n,k,A[504],sum;
int det[504];
bool check(int x){
    if(sum%x!=0)return 0;
    for(int i=1;i<=n;i++)det[i]=A[i]%x;
    sort(det+1,det+n+1);
    int l=1,r=n;
    ll opc=0;
    while(l<=r){
        if(det[l]%x==0){
            ++l;continue;
        }
        if(det[r]%x==0){
            --r;continue;
        }
        int delta=min(det[l]%x,x-(det[r]%x));
        det[l]-=delta;
        det[r]+=delta;
        opc+=delta;
    }
    return (opc<=k);
}
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)scanf("%d",&A[i]);
    sum=0;
    for(int i=1;i<=n;i++)sum+=A[i];
    int ans=1;
    for(int k=sqrt(sum);k>=1;k--){
        if(check(k))ans=max(ans,k);
        if(check(sum/k))ans=max(ans,sum/k);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;
struct segment
{
    double B;
    double E;
};
segment seg[1100000];
bool cmp(segment a,segment b)
{
    return a.B<b.B;
}
int main()
{
    int n,m;
    double h,r;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%lf%lf",&h,&r);
        seg[i].B=h-r;
        seg[i].E=h+r;
    }

    sort(seg+1,seg+1+n,cmp);
    m=seg[1].E;
    int cnt=1;

    for(int i=2; i<=n; i++)
    {
        if(seg[i].B-m<0)
        {
            if(seg[i].E<m)
                m=seg[i].E;
            else
                continue;
        }
        else
        {
            cnt++;
            m=seg[i].E;
        }
    }
    printf("%d",cnt);
    return 0;
}


Measured memory_bytes: 1664
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * 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);
        SightseeingTour solver = new SightseeingTour();
        solver.solve(1, in, out);
        out.close();
    }

    static class SightseeingTour {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int[][] C = new int[N][N];
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    C[i][j] = in.nextInt();
                }
            }
            long ans = 0;
            for (int i = 0; i < N; i++) {
                for (int j = i; j < N; j++) {
                    ans += Math.min(C[i][j], C[j][i]);
                }
            }
            out.println(ans);
        }

    }
}

Measured memory_bytes: 41512
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] h = new int[N];
    for (int i = 0; i < N; i++) {
      h[i] = sc.nextInt();
    }
    long[] cost = new long[N];
    cost[0] = 0;
    cost[1] = Math.abs(h[1] - h[0]);
    for (int i = 2; i < N; i++) {
      cost[i] = Math.min(cost[i - 2] + Math.abs(h[i] - h[i - 2]), cost[i - 1] + Math.abs(h[i] - h[i - 1]));
    }
    System.out.println(cost[N - 1]);
  }
}

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


int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long test;
    test=1;
    // cin>>test;
    while(test--)
    {
        int n,m,i,j;
        cin>>n>>m;
        char s[n][n],s1[m][m];
        for(i=0;i<n;i++)
        {
            for(j=0;j<n;j++)cin>>s[i][j];
        }
        for(i=0;i<m;i++)
        {
            for(j=0;j<m;j++)cin>>s1[i][j];
        }
        for(i=0;i<=n-m;i++)
        {
            for(j=0;j<=n-m;j++)
            {
                bool match=true;
                for(int a=0;a<m;a++)
                {
                    
                    for(int b=0;b<m;b++)
                    {
                        if(s[i+a][j+b]!=s1[a][b])
                        match=false;
                    }
                }
                if(match)
                {
                    cout<<"Yes";
                    return 0;
                }
            }
        }
        cout<<"No";
    
    }
}


Measured memory_bytes: 256
import kotlin.math.abs

fun main() = Thread(null, ::abc173e, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc173e() {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    val aList = readLine()!!.split(' ').map { it.toLong() }

    if (k == n) return println(aList.fold(Mint(1), Mint::times))

    val (positives, negatives) = aList
        .sortedByDescending { abs(it) }.partition { it > 0 }.toList().map { ArrayDeque(it) }

    var answer = Mint(1)

    if (k % 2 != 0) {
        if (positives.isEmpty()) return println(negatives.takeLast(k).fold(Mint(1), Mint::times))
        else answer *= positives.removeFirst()
    }

    repeat(k / 2) {
        when {
            positives.size >= 2 && negatives.size >= 2 -> {
                val pos = positives.take(2).reduce(Long::times)
                val neg = negatives.take(2).reduce(Long::times)
                if (pos > neg) {
                    answer *= pos
                    repeat(2) { positives.removeFirst() }
                } else {
                    answer *= neg
                    repeat(2) { negatives.removeFirst() }
                }
            }
            positives.size >= 2 -> answer *= positives.removeFirst() * positives.removeFirst()
            negatives.size >= 2 -> answer *= negatives.removeFirst() * negatives.removeFirst()
            else -> error("なんで？")
        }
    }

    println(answer)
}

private const val MOD = 1_000_000_007L

@Suppress("unused")
private class Mint(value: Long = 0L) {
    constructor(other: Mint) : this(other.value)

    private val value = if (value < 0) (value % MOD) + MOD else value % MOD
    operator fun unaryPlus() = this
    operator fun unaryMinus() = Mint(MOD - this.value)
    operator fun inc() = this.plus(1)
    operator fun dec() = this.minus(1)
    operator fun plus(other: Long) = Mint(this.value + other)
    operator fun plus(other: Mint) = this.plus(other.value)
    operator fun minus(other: Long) = Mint(this.value - other)
    operator fun minus(other: Mint) = this.plus(-other)
    operator fun times(other: Long) = Mint(this.value * Mint(other).value)
    operator fun times(other: Mint) = this.times(other.value)
    operator fun div(other: Long) = this.times(modPow(other, MOD - 2))
    operator fun div(other: Mint) = this.div(other.value)
    fun mod(mod: Long) = Mint(this.value % mod)
    fun modPow(other: Long) = Mint(modPow(this.value, other))
    fun toLong() = this.value
    override fun toString() = this.value.toString()
    override fun hashCode() = value.hashCode()
    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false
        other as Mint
        return value == other.value
    }

    companion object {
        private fun modPow(n: Long, p: Long): Long {
            var x = n % MOD
            var y = p
            var result = 1L
            while (y > 0) {
                if (y % 2 == 1L) result = (result * x) % MOD
                y = y shr 1
                x = (x * x) % MOD
            }
            return result
        }
    }
}


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

#define int long long
#define ll long long
#define pb push_back

int n, m, q;
vector<int> a;
vector<int> b;
vector<int> c;
vector<int> d;

int ans = 0;

int summ = 0;

void rec(vector<int> kek){
    if (kek.size() == n){
        summ++;
        int now = 0;
        for(int i = 0; i < q; i++){
            if (kek[b[i]] - kek[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans, now);
        return;
    }
    else{
        for(int i = kek[(int) kek.size() - 1]; i <= m; i++){
            kek.pb(i);
            rec(kek);
            kek.pop_back();
        }
    }
}

main(){
    cin >> n >> m >> q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    for(int i = 0; i < q; i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    for(int i = 1; i <= m; i++){
        rec({i});
    }
    cout << ans;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> s(N);
  for(int i = 0; i < N; i++) {
    cin >> s.at(i);
  }
  int sum = 0; 
  for(int i = 0; i < N; i++) {
    sum += s.at(i);
  }
  sort(s.begin(), s.end());
  reverse(s.begin(), s.end());
  int cnt, j, m = 0;
  for(int i = 0; i < N; i++) {
    if(s.at(i) % 10 != 0) {
      cnt++;
    }
  }
  for(int i = 0; i < N; i++) {
    if(s.at(i) % 10 != 0) {
      m = s.at(i);
    }
  }
  if(sum%10 != 0) {
    cout << sum;
  }
  else {
    if(cnt == 0) {
      cout << "0";
    }
    else {
      cout << sum - m;
    }
  }
  
}



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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)

int main()
{
  string s;
  cin >> s;
  ll n = s.length();
  int c0 = 0;
  int c1 = 0;
  for(ll i = 0;i < n;i++)
  {
    if(s.at(i) == '0') c0++;
    if(s.at(i) == '1') c1++;
  }
  cout << min(c0,c1)*2 << endl;
}


Measured memory_bytes: 512
n, *XY = map(int, open(0).read().split())
XY = list(zip(XY[::2], XY[1::2]))
A = [x+y for x, y in XY]
B = [x-y for x, y in XY]
print(max(max(A) - min(A), max(B) - min(B)))

Measured memory_bytes: 56476
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {

	char S[4];
	scanf("%s", S);

	switch (S[0]) {
	case 'a':
		switch (S[1]) {
		
		case 'b':
			switch (S[2]) {
			case 'c':
				printf("Yes\n");
				break;

			default:
				printf("No\n");
			}
			break;

		case 'c':
			switch (S[2]) {
			case 'b':
				printf("Yes\n");
				break;

			default:
				printf("No\n");
				break;

			}
			break;

		default:
			printf("No\n");
		}

		break;

	case 'b':
		switch (S[1]) {

		case 'a':
			switch (S[2]) {
			case 'c':
				printf("Yes\n");
				break;

			default:
				printf("No\n");
			}
			break;

		case 'c':
			switch (S[2]) {
			case 'a':
				printf("Yes\n");
				break;

			default:
				printf("No\n");
				break;

			}
			break;

		default:
			printf("No\n");
		}
		break;

	case 'c':
		switch (S[1]) {

		case 'a':
			switch (S[2]) {
			case 'b':
				printf("Yes\n");
				break;

			default:
				printf("No\n");
			}
			break;

		case 'b':
			switch (S[2]) {
			case 'a':
				printf("Yes\n");
				break;

			default:
				printf("No\n");
				break;

			}
			break;

		default:
			printf("No\n");
		}

	}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 100000000000000000;

const ll M = 3000;

template <typename T>
struct Edge
{
    int to;
    T cost;
};

template <typename T>
struct WeightedGraph
{
    int n;
    vector<vector<Edge<T>>> g;
    
    WeightedGraph(int n) : n(n){
        g.resize(n);
    }
    
    void init(int n_){
        n = n_;
        g.resize(n_);
    }
    
    void add_edge(int from, int to, T cost){
        g[from].push_back((Edge<T>){to, cost});
    }
};

int main()
{
    ll n, m, s;
    cin >> n >> m >> s;
    WeightedGraph<P> g(n);
    for(int i = 0; i < m; i++){
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        g.add_edge(u, v, P(a, b));
        g.add_edge(v, u, P(a, b));
    }
    ll c[52], d[52];
    for(int i = 0; i < n; i++) cin >> c[i] >> d[i];
    ll dp[52][3005];
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= M; j++) dp[i][j] = INF;
    }
    for(int i = 0; i <= min(M, s); i++) dp[0][i] = 0;
    while(true){
        bool f = false;
        for(int u = 0; u < n; u++){
            for(int j = M - 1; j >= 0; j--) dp[u][j] = min(dp[u][j], dp[u][j + 1]);
            for(int j = 0; j < M; j++){
                if(j >= c[u]) dp[u][j] = min(dp[u][j], dp[u][j - c[u]] + d[u]);
                for(Edge<P> e : g.g[u]){
                    int v = e.to;
                    if(j >= e.cost.first && dp[v][j - e.cost.first] > dp[u][j] + e.cost.second){
                        f = true;
                        dp[v][j - e.cost.first] = dp[u][j] + e.cost.second;
                    }
                }
            }
        }
        if(!f) break;
    }
    for(int i = 1; i < n; i++){
        cout << dp[i][0] << endl;
    }
}


Measured memory_bytes: 4816