akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (ll i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (ll i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

    int n; cin >> n;

    int ans = 1;
    while(ans <= n) {
        ans *= 2;
    }

    print(ans / 2);
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(void) {

  while(1) {
    int a, b;

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

    if ((a == 0) && (b == 0))
      break;

    if (a > b)
      printf("%d %d\n", b, a);
    else
      printf("%d %d\n", a, b);
  }
  return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back

int mod = 1e9+7;

ll dp[105][4][4][4];

void solve () {
  dp[0][3][3][3] = 1;
  rep(idx, 1, 105) {
    rep (i, 0, 4) {
      rep(j, 0, 4) {
        rep(k, 0, 4) {
          rep(l, 0, 4) {
            if (i == 0 && k == 2 && l == 1) continue;
            if (i == 0 && j == 2 && l == 1) continue;
            if (i == 0 && j == 1 && k == 2) continue;
            if (j == 0 && k == 1 && l == 2) continue;
            if (i == 2 && j == 0 && k == 1) continue;
            if (j == 2 && k == 0 && l == 1) continue;
            if (i == 0 && j == 2 && k == 1) continue;
            if (j == 0 && k == 2 && l == 1) continue;
            dp[idx][j][k][l] += (dp[idx - 1][i][j][k] % mod);
          }
        }
      }
    }
  }
};

int main() {
  int N;
  cin >> N;
  solve();

  ll ans = 0;
  rep(i, 0, 4) {
    rep(j, 0, 4) {
      rep(k, 0, 4) {
        ans += dp[N][i][j][k];
        ans = ans % mod;
      }
    }
  }
  cout << ans << endl;
};


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, h;
	cin >> n >> h;
	vi v(n);
	int maxa = 0;
	REP(i, n) {
		int a;
		cin >> a >> v[i];
		maxa = max(a, maxa);
	}
	sort(ALL(v));
	int cnt = 0;
	RREP(i, n) {
		if (v[i] < maxa)continue;
		cnt++;
		h -= v[i];
		if (h <= 0)break;
	}
	if (h <= 0)cout << cnt << endl;
	else cout << cnt + (h + maxa - 1) / maxa << endl;
}


Measured memory_bytes: 640
mod=10**9+7
N,M=map(int,input().split())
S=[int(i) for i in input().split()]
T=[int(i) for i in input().split()]
dp=[[0 for j in range(M)] for i in range(N)]
ans=[[0 for j in range(M+1)] for i in range(N+1)]
for i in range(N+1):
    ans[i][0]=1
for j in range(M+1):
    ans[0][j]=1
for i in range(N):
    for j in range(M):
        if S[i]==T[j]:
            dp[i][j]=ans[i][j]
        else:
            dp[i][j]=0
        ans[i+1][j+1]=dp[i][j]+ans[i+1][j]+ans[i][j+1]-ans[i][j]
        ans[i+1][j+1]%=mod
print(ans[N][M])


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    rep(i,s.size()-2){
        if (s[i]==s[i+1] && s[i+1]==s[i+2]){
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;
    char s[52][52];
    bool flg;
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            cin >> s[i][j];
        }
    }
    int cnt = 0;
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            if (s[i][j] == '#' && s[i][j - 1] != '#' && s[i - 1][j] != '#' && s[i + 1][j] != '#' && s[i][j + 1] != '#')
            {
                cnt++;
            }
        }
    }

    if (cnt == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

class LowLink:
    def __init__(self, v):
        self.size = len(v)
        self.v = v
        self.cnt = 0
        self.pre = [None]*self.size
        self.low = [None]*self.size
        self.par = [None]*self.size
        self.bridge = []
        for x in range(self.size):
            if self.pre[x] is None:
                self.pre[x] = self.low[x] = self.cnt
                self.dfs(x)

    def dfs(self, x):
        for y in self.v[x]:
            if self.pre[y] is None:
                self.cnt += 1
                self.pre[y] = self.low[y] = self.cnt
                self.par[y] = x
                py = self.dfs(y)
                if py < self.low[x]:
                    self.low[x] = py
            else:
                if self.par[x] != y and self.pre[y] < self.low[x]:
                    self.low[x] = self.pre[y]
            if self.pre[x] < self.low[y]:
                self.bridge.append((x,y))

        return self.low[x]

    def bridge(self):
        return self.bridge

def solve():
    n,m = LI()
    v = [[] for i in range(n)]
    for i in range(m):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    ans = LowLink(v)
    print(len(ans.bridge))
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38384
a, b = map(int, input().split())
A = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ans = ""
for i in range(a):
  t = list(input().split())
  if 'snuke' in t:
    ans += A[t.index("snuke")]
    ans += str(i + 1)
print(ans)

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

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

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n; cin>>n;
  vector<ll> c(3);
  cin>>c[0]>>c[1]>>c[2];
  vector<string> s(n);
  rep(i, n)cin>>s[i];

  map<string, pi>m;
  m["AB"] = {0,1};
  m["AC"] = {0,2};
  m["BC"] = {1,2};

  if(c[0]+c[1]+c[2]==0) { cout<<"No"<<endl; return 0; }

  if(c[0]+c[1]+c[2]==1 || c[0]+c[1]+c[2]>=3) {
    vector<char> result;

  for(auto cs:s){
    int l = m[cs].first;
    int r = m[cs].second;
    if(c[l]>c[r]){
      c[r]++; c[l]--; result.push_back("ABC"[r]);
    }else{
      c[l]++; c[r]--; result.push_back("ABC"[l]);
    }
    if(c[0]<0 || c[1]<0 || c[2]<0) { cout<<"No"<<endl; return 0; }
  }
  cout<<"Yes"<<endl;
  for(auto cs: result)cout<<cs<<endl;
  return 0;

    return 0;
  }

  vector<char> result;
  rep(i, n){
    auto cs = s[i];
    int l = m[cs].first;
    int r = m[cs].second;

    if(c[l]>c[r]){
      c[l]--;c[r]++;
      result.push_back("ABC"[r]);
    }else if(c[r]>c[l]){
      c[r]--;c[l]++;
      result.push_back("ABC"[l]);
    }else{
      if(i<n-1 && (m[s[i+1]].first == l || m[s[i+1]].second == l) ){
        c[r]--;c[l]++;
        result.push_back("ABC"[l]);
      }else{
        c[l]--;c[r]++;
        result.push_back("ABC"[r]);
      }
    }
    if(c[0]<0 || c[1]<0 || c[2]<0) { cout<<"No"<<endl; return 0; }
  }

  cout<<"Yes"<<endl;
  for(auto cs: result)cout<<cs<<endl;

  return 0;
}


Measured memory_bytes: 6728
#include "bits/stdc++.h"
using namespace std;
int main(){
    int N;
    cin >> N;
    map<string, int> data;//文字列→個数
    for(int i = 0; i < N; i++){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if(data.count(s))
    data.at(s)++;
    else 
    data[s] = 1; 
    }
    long long sum = 0;
    for(pair<string, int> p: data){
        long long d = p.second;
        sum += d * (d - 1) / 2;

    }
    cout << sum << endl;
    return 0; 
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  cin >> x >> y;
  if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11)){
      cout << "Yes" << endl;
  }else if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12)){
      cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
using namespace std;
typedef pair<ll, ll> P;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main(void){
	int a, b, c;
	cin >> a >> b >> c;
	if (b >= a * c)cout << c << endl;
	else cout << b / a << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<set>
using namespace std;
int main()
{
    int n;
    cin >> n;
    unordered_set<string> s;
    for(int i=0;i<n;i++)
    {
        string s1;
        cin >> s1;
        s.insert(s1);
    }
    cout << s.size();
}

Measured memory_bytes: 17560
N, M = map(int, input().split())
SetFrom, SetTo = set(), set()
for i in range(M):
    a, b = map(int, input().split())
    a, b = min(a, b), max(a, b)
    if a == 1:
        SetFrom |= {b}
    elif b == N:
        SetTo |= {a}
print("POSSIBLE" if SetFrom & SetTo else "IMPOSSIBLE")

Measured memory_bytes: 18992
def examA():
    A, B, C = LI()
    S = A+B+C
    cur = 0
    for i in range(32):
        if A%2==1 or B%2==1 or C%2==1:
            break
        A = (S-A)//2
        B = (S-B)//2
        C = (S-C)//2
        cur +=1
    if cur==32:
        ans = -1
    else:
        ans = cur
    print(ans)
    return

def examB():
    N, M = LI()
    cur = [0]*N
    for i in range(M):
        a, b = LI()
        cur[a-1] +=1
        cur[b-1] +=1
    ans = "YES"
    for j in cur:
        if j%2==1:
            ans = "NO"
            break
    print(ans)
    return


def clear_maze(h,w,s,maze):
#    debug_print(maze)
    distance = [[inf for _ in range(w)] for _ in range(h)]
    def bfs():
        queue = []
        queue.insert(0, s)
        distance[s[0]][s[1]] = 0
        while len(queue):
            y, x = queue.pop()
            for i in range(0, 4):
                nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]
                if (0<= nx <w and 0<= ny <h and maze[ny][nx] != '#' and distance[ny][nx] == inf):
                    queue.insert(0, (ny, nx))
                    distance[ny][nx] = distance[y][x] + 1
        return distance
    return bfs()
def examC():
    H, W, K = LI()
    A = [SI() for _ in range(H)]
    sx = W-1; sy = H-1
    for i in range(H):
        for j in range(W):
            if A[i][j]=="S":
                sy = i; sx = j
                break
        if sy!=H-1 or sx!=W-1:
            break
    D = clear_maze(H,W,[sy,sx],A)
#    print(D)
    ans = inf
    for i in range(H):
        for j in range(W):
            if D[i][j]>K:
                continue
            cur = min((i+K-1)//K,(j+K-1)//K,(H+K-i-2)//K,(W+K-j-2)//K)
            ans = min(ans,cur+1)
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = 10**18

if __name__ == '__main__':
    examC()


Measured memory_bytes: 53724
// Problem : C - gacha
// Contest : AtCoder - AtCoder Beginner Contest 164
// URL : https://atcoder.jp/contests/abc164/tasks/abc164_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define vii vector<pii>
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


int solve(){

	int n;cin>>n;
	set<string> s;
	for(int i=0;i<n;i++){
		string tmep;cin>>tmep;
		s.insert(tmep);
	}
	cout<<s.size()<<endl;


    return 0;
}
signed main(){
    asdf
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 19128
a, b, x = map(int, input().split())
import math

if x > (0.5*(a**2)*b):
    print(math.degrees(math.atan(((2*b)/a) - ((2*x)/(a**3)))))
else:
    print(math.degrees(math.atan((a*(b**2))/(2*x))))

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

template<class T>
struct ModInt {
    T x;
    ModInt(T x = 0) :x(x% mod) {}
    ModInt& operator+=(const ModInt a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(const ModInt a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator*=(const ModInt a) {
        (x *= a.x) %= mod;
        return *this;
    }
    ModInt operator+(const ModInt a) const {
        ModInt res(*this);
        return res += a;
    }
    ModInt operator-(const ModInt a) const {
        ModInt res(*this);
        return res -= a;
    }
    ModInt operator*(const ModInt a) const {
        ModInt res(*this);
        return res *= a;
    }
    ModInt pow(T t) const {
        if (!t) return 1;
        ModInt a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    ModInt inv() const {
        return pow(mod - 2);
    }
    ModInt& operator/=(const ModInt a) {
        return (*this) *= a.inv();
    }
    ModInt operator/(const ModInt a) const {
        ModInt res(*this);
        return res /= a;
    }
};
using mint = ModInt<long long>;


int n;
int a[1000005];
void solve() {
    cin >> n;
    rep(i, n) cin >> a[i];

    int val[] = { 0,0,0 };
    mint ans = 1;
    rep(i, n) {
        ll cnt = 0;
        bool ok = false;
        rep(j, 3) {
            if (val[j] == a[i]) { ++cnt; if (!ok) { ok = true; ++val[j]; } }
        }

        ans *= mint(cnt);

    }

    cout << ans.x << endn;

}

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


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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll x;
    cin>>x;
    ll hundred = x/500;
    x%=500;
    cout<<hundred*1000+ x/5 * 5;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
   string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    int count=0;
    for(int j=0;j<s.size();j++){
       if(s[i]==s[j]) count++;
    }
    if(count%2!=0){
        cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a+b == 15) puts("+");
  else if(a*b == 15) puts("*");
  else puts("x");
  return 0;
}


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


int main(void){
    char s[200001];
    char t[200001];
    int count = 0;
    scanf("%s", s);
    scanf("%s", t);
    for (int i=0; i<strlen(s);i++){
        if (s[i] != t[i]){
            char* temp = s[i];
            s[i] = t[i];
            t[i] = temp;
            count ++;
        }
    }
    printf("%d\n", count);
}

Measured memory_bytes: 2488
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <stack>
#include <list>
#include <bitset>
#include <iostream>
#include <map>
#include <set>
#include <unordered_map>
using namespace std;
typedef long long ll;
const int maxn=200050;
int n;

void solve(){
	scanf("%d",&n);
	int sum=0,flag=0;
	for(int i=1;i<=n;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		if(a==b)	sum++;
		else	sum=0;
		if(sum>=3)	flag=1;
	}
	printf("%s\n",flag?"Yes":"No");
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

long long int g(long long int a, long long int b) {
	return b == 0 ? a : g(b, a % b);
}
long long int l(long long int a, long long int b) {
	return a / g(a, b) * b;
}
int main() {
	long long int n, m; std::cin >> n >> m;
	std::vector<int> numbers(n); for (auto& n : numbers) std::cin >> n;
	long long int bit = -numbers.front() & numbers.front();
	if (std::all_of(numbers.begin(), numbers.end(), [bit](int val) {return (-val & val) == bit; })) {
		long long int lcm = numbers.front() / 2;
		for (auto i = 0; i < n; ++i) {
			if (lcm > m) break;
			lcm = l(lcm, numbers[i] / 2);
		}
		if (lcm > m) std::cout << 0 << std::endl;
		else std::cout << m / lcm - (m / lcm / 2) << std::endl;
	}
	else {
		std::cout << 0 << std::endl;
	}
}

Measured memory_bytes: 888
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#define INF 9999999999
#define EPS 1.0e-6

using namespace std;

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

int V,E,r;
vector<P> G[105000];
ll d[105000];

void dijkstra(int s)
{
	fill(d, d + V, INF);
	d[s] = 0;
	priority_queue<P,vector<P>,greater<P>>que;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		for (int i = 0; i < G[v].size(); i++) {
			P e = G[v][i];
			int to = e.first;
			int cost = e.second;
			if (d[to] > d[v] + cost) {
				d[to] = d[v] + cost;
				que.push(P(d[to], to));
			}
		}
	}
}

int main()
{
	cin >> V >> E >> r;
	int s, t, di;
	for (int i = 0; i < E; i++) {
		cin >> s >> t >> di;
		G[s].push_back(P(t, di));
	}
	dijkstra(r);
	for (int i = 0; i < V; i++) {
		if (d[i] == INF)cout << "INF" << endl;
		else cout << d[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 13604
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const double EPS = 1e-3;
const double PI = 3.1415926535897932384626433832795028841971;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

int ans = IINF;

void calc(string s, char c, int num)
{
    bool ok = true;
    rep(i, s.size())
    {
        ok &= s[i] == c;
    }
    if (ok)
    {
        ans = min(ans, num);
        return;
    }
    string t = "";
    rep(i, s.size() - 1)
    {
        if (s[i] == c)
        {
            t += s[i];
        }
        else
        {
            t += s[i + 1];
        }
    }
    calc(t, c, num + 1);
}
int main()
{
    string s;
    cin >> s;
    rep(i, s.size())
    {
        calc(s, s[i], 0);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
	const int DATASETS = 1000;

	int n, MAX, MIN;

	string S[DATASETS], MAX1, MIN1;

	cin >> n;

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

	for (int i = 0; i < n; i++)
	{
		MAX1 = S[i]; sort(MAX1.begin(), MAX1.end(), greater<char>());
		MIN1 = S[i]; sort(MIN1.begin(), MIN1.end());

		MAX = stoi(const_cast<const string&>(MAX1));
		MIN = stoi(const_cast<const string&>(MIN1));

		cout << MAX - MIN << endl;
	}

	return 0;
}

Measured memory_bytes: 1240
MOD=1000000007
N,M=map(int,input().split())
cnt=[0 for _ in range(N+1)]
cnt[0]=1
for _ in range(M):
    a=int(input())
    cnt[a]=-1
for i in range(1,N+1):
    if cnt[i]==-1:
        cnt[i]=0
        continue
    if i==1:
        cnt[i]=cnt[i-1]
    else:
        cnt[i]=(cnt[i-1]+cnt[i-2])%MOD
print(cnt[N])


Measured memory_bytes: 12896
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<iomanip>
#include<queue>
#include<cmath>
#include<stack>
#include <map>
#define ll long long int
#define skip cin>>ws;
#define vll vector<ll> 
#define vb vector<bool>
#define vpll vector<pair<ll,ll>>
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define vs vector<string>
#define vvpll vector<vector<pair<ll, ll>>>
#define pb push_back
#define pob pop_back()
#define MOD (ll)(1e9 + 7)
#define test ll t; cin>>t; while(t--)

using namespace std;

void enter(vll &ar)
{
    ll n = ar.size();

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

void show(vll &a)
{
    ll n = a.size();

    for(ll i=0;i<n;i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<"\n";
}

void SieveOfErat1sthenes(int n, vll &pri) 
{ 
    vb prime(n+1, true); 
   
    for (int p=2; p*p<=n; p++) 
    { 
        
        if (prime[p] == true) 
        { 
            pri.pb(p);
            
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}

ll mo(ll a)
{
    return a%MOD;
}

bool compare(pll a, pll b)
{
    return a.first>b.first;
}

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

    ll n;
    cin>>n;

    vector<double> a(n);
    for(ll i=0;i<n;i++) cin>>a[i];

    vector<vector<double>> tails((n-1)/2+1, vector<double>(n+1));

    tails[0][0] = 0;

    for(ll i=1;i<=n;i++)
    {
        tails[0][i] = tails[0][i-1]*a[i-1] + (1-a[i-1]);
    }

    for(ll i=1;i<=(n-1)/2;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            tails[i][j] = tails[i-1][j-1]*(1-a[j-1]) + tails[i][j-1]*a[j-1];
        }
    }

    double ans = 1 - tails[(n-1)/2][n];

    cout<<fixed<<setprecision(10)<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 38664
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int n;
    cin >> n;
    int cnt=0;
    repeq(i,n){
        int keta = log10(i)+1;
        if(keta%2 != 0) cnt++;
    }

    cout << cnt << endl;

}

Measured memory_bytes: 640
use std::io;


fn main() {
    let _n = read_one::<usize>();
    let a = read::<usize>();
    let mut ans = 0;
    for i in a.iter() {
        ans += i - 1;
    }
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
num_of_path = int(input())

while num_of_path != 0:
	inf = 1e8
	data = []
	num_of_cities = 0
	for _ in range(num_of_path):
		add_data = list(map(int,input().split()))
		data.append(add_data)
		if num_of_cities < max(add_data[0],add_data[1]):
			num_of_cities = max(add_data[0],add_data[1])

	num_of_cities += 1
	w = [[1e8]*num_of_cities for i in range(num_of_cities)]
	for d in data:
		w[d[0]][d[1]] = d[2]
		w[d[1]][d[0]] = d[2]


	for k in range(num_of_cities):
		for j in range(num_of_cities):
			for i in range(num_of_cities):
				w[i][j] = min(w[i][j],w[i][k]+w[k][j])

	for i,row in zip(range(num_of_cities),w):
		row[i] = 0		

	s = [sum(w[i]) for i in range(num_of_cities)]
	print(f"{s.index(min(s))} {min(s)}")

	num_of_path = int(input())



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


int main(){
    int n;
    cin>>n;
    int h[n];
    int dp[n];
    for(int i=0;i<n;i++)    cin>>h[i];
    dp[0] = 0;
    dp[1] = dp[0] + abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        dp[i] = min(dp[i-1]+ abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
INF = 100000

h, w = map(int, input().split())
C = [list(map(int, input().split())) for i in range(10)]
A = [list(map(int, input().split())) for i in range(h)]

dist = [[INF for j in range(10)] for i in range(10)]

for i in range(10):
    for j in range(10):
        dist[i][j] = C[i][j]

for k in range(10):
    for i in range(10):
        for j in range(10):
            dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])

ans = 0

for al in A:
    for a in al:
        if a != -1:
            ans += dist[a][1]

print(ans)

Measured memory_bytes: 40284
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#define ll  long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define main() int main()
#define ff1(i,n) for(int i=1;i<=n;++i)
#define ff0(i,n) for(int i=0;i<n;++i)
#define pi acos(-1.0)
#define ms(a, x) memset(a, x, sizeof(a))
#define lowbit(x) ((x)&(-(x)))
#define pb push_back
#define binarycount __builtin_popcount(x)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define fir first
#define sec second
#define debug(x) cout<<x<<'\n'
#define sa(a) scanf("%d", &a)
#define sab(a, b) scanf("%d%d", &a, &b)
#define pa(a) printf("%d",a)
#define pab(a,b) printf("%d%d",a,b)
#define pii pair<int,int>
using namespace std;

#define maxn 200005
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
const double eps = 1e-8;
ll gcd(ll a, ll b) {return b==0?a:gcd(b, a%b);}
ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}
ll powmod(ll a,ll b){
    ll ans = 1, pow = a%mod;
    while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; }
    return ans%mod;
}
ull a[maxn];
const ll maxx=1e18;
bool judge(ull a, ull b) {
    if (maxx/a<b) {
        return true;
    }
    return false;
}
main() {
    int n;
    cin>>n;
    int f=1;
    for (int i=0;i<n;i++) {
        cin>>a[i];
        if (a[i]==0) f=0;
    }
    if(f==0){
    	cout<<0<<endl;
    	return 0;
	}
    ll ans=1;
    for (int i=0;i<n;i++) {
        if (judge(ans,a[i])) {
            cout<<"-1"<<endl;
            return 0;
        }
        ans*=a[i];
    }
    cout<<ans<<endl;


}
 

Measured memory_bytes: 4392
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, m, i, j, k, s, t, a, b, d, ans, id, MOD = 1000000007, ex;
	cin >> n >> m >> s >> t;
	vector<vector<pair<long long, long long>>> edge(n + 1);
	for (i = 0; i < m; i++) {
		cin >> a >> b >> d;
		edge[a].push_back({ d, b });
		edge[b].push_back({ d, a });
	}
	for (i = 1; i <= n; i++) sort(edge[i].begin(), edge[i].end());

	vector<long long> dist1, dist2, dp1, dp2;
	priority_queue<pair<long long, long long>> q;	

	// move from S
	dist1.assign(n + 1, 1LL << 60);
	dp1.assign(n + 1, 0);
	dist1[s] = 0;
	q.push({ 0, s });

	while (!q.empty()) {
		id = q.top().second;
		d = -q.top().first; 
		q.pop();
		if (dist1[id] != d) continue;

		if (id == s) dp1[s] = 1;
		else {
			for (auto p : edge[id]) {
				if (dist1[p.second] + p.first == d) dp1[id] = (dp1[id] + dp1[p.second]) % MOD;
			}
		}

		for (auto p : edge[id]) {
			if (d + p.first < dist1[p.second]) {
				dist1[p.second] = d + p.first;
				q.push({ -dist1[p.second], p.second });
			}
		}
	}

	// move from t
	dist2.assign(n + 1, 1LL << 60);
	dp2.assign(n + 1, 0);
	dist2[t] = 0;
	q.push({ 0, t });

	while (!q.empty()) {
		id = q.top().second;
		d = -q.top().first;
		q.pop();
		if (dist2[id] != d) continue;

		if (id == t) dp2[t] = 1;
		else {
			for (auto p : edge[id]) {
				if (dist2[p.second] + p.first == d) dp2[id] = (dp2[id] + dp2[p.second]) % MOD;
			}
		}

		for (auto p : edge[id]) {
			if (d + p.first < dist2[p.second]) {
				dist2[p.second] = d + p.first;
				q.push({ -dist2[p.second], p.second });
			}
		}
	}
	
	ans = (dp1[t] * dp1[t]) % MOD;
	ex = 0;
	d = dist1[t];
	if (d % 2 == 0) {
		// meet at the same vertice
		for (i = 1; i <= n; i++) {
			if ((dist1[i] == d / 2) && (dist2[i] == d / 2)) {
				ex = (ex + ((dp1[i] * dp1[i]) % MOD) * ((dp2[i] * dp2[i]) % MOD)) % MOD;
			}
		}
	}

	for (i = 1; i <= n; i++) {
		for (auto p : edge[i]) {
			a = i; b = p.second; 
			if ((dist1[a] * 2 < d) && (dist2[b] * 2 < d) && (dist1[a] + dist2[b] + p.first == d)) {
				// meet on the edge
				ex = (ex + ((dp1[a] * dp1[a]) % MOD) * ((dp2[b] * dp2[b]) % MOD)) % MOD;
			}
		}
	}

	ans = (ans + MOD + MOD - ex) % MOD;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 17144
mod = 10 ** 9 + 7

n = gets.to_s.to_i

dp = Array.new(n+1){ Hash.new(0) }
dp[0]["TTT"] = 1

AGC = "AGC".freeze

n.times do |i|
  
  dp[i].each do |(k, v)|
    
    x, y, z = k.chars
    "ACGT".each_char do |c|
      
      next if (x+y+z+c)[AGC]
      next if (y+x+z+c)[AGC]
      next if (x+z+y+c)[AGC]
      next if (x+y+c+z)[AGC]
      
      s = y + z + c
      dp[i+1][s] += v
      dp[i+1][s] %= mod if dp[i+1][s] >= mod
    end
  end
end

ans = dp[n].values.reduce(0){|s,t| s+t } % mod

puts ans

Measured memory_bytes: 2428
/*
          ,     \    /      ,
         / \    )\__/(     / \
        /   \  (_\  /_)   /   \
   ____/_____\__\@  @/___/_____\____
  |             |\../|              |
  |              \VV/               |
  |        ------hoi-------         |
  |_________________________________|
   |    /\ /      \\       \ /\    |
   |  /   V        ))       V   \  |
   |/     `       //        '     \|
   `              V                '
*/

#include <bits/stdc++.h>

#define ld long double
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define f first
#define se second
#define Speedforce boost();
#define fop(s1, s2) freopen(s1, "r", stdin);freopen(s2, "w", stdout);

using namespace std;

void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const int N = 1e6;
const ll inf = 1e9 + 7;
const ld PI = acos(-1);

ll bin_pow(ll x, ll y){
    ll res = 1, base = x;
    while(y){
        if(y & 1){
            res *= base;
            res %= inf;
        }
        base *= base;
        base %= inf;
        y /= 2;
    }
    return res;
}

int a, b, c;

int main(){
    Speedforce
    //fop("", "")
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+50;
ll n,m,k;
ll a[maxn],b[maxn];
int main()
{
	scanf("%lld%lld%lld",&n,&m,&k);
	memset(a,0,sizeof a);
	memset(b,0,sizeof b);
	for(int i=1;i<=n;++i)
	{
		scanf("%lld",&a[i]);
		a[i]+=a[i-1];
	}
	for(int i=1;i<=m;++i)
	{
		scanf("%lld",&b[i]);
		b[i]+=b[i-1];	
	}
	/*for(int i=0;i<=n;++i) cout<<a[i]<<" ";
	cout<<endl;
	for(int i=0;i<=m;++i) cout<<b[i]<<" ";
	cout<<endl;*/
	int maxx=0,cnt=m;
	for(int i=0;i<=n;++i)
	{
		if(a[i]<=k)
		{
			int l=0,r=m,mid;
			while(l<=r)
			{
				mid=(l+r)/2;
				if(a[i]+b[mid]>k) r=mid-1;
				else if(a[i]+b[mid]<k) l=mid+1;
				else 
				{
					r=mid;
					break;
				}
			}	
			maxx=max(r+i,maxx);	
		}	
	}	
	cout<<maxx<<endl;
	return 0;
}

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

using namespace std;

int main() {
  string T,S; cin >> T >> S;
  for(int i=0;i<=(int)T.size()-(int)S.size();++i)
    if(T.substr(i,S.size())==S) cout << i << endl;
  
  return 0;
}


Measured memory_bytes: 3212
def check(n):
    i = 2
    while i*i<=n:
        if n%i==0:
            return False
        i+=1
    return True
n = int(input())
a = [2]
i = 6
while i<=55555:
    if check(i):
        a.append(i)
    i+=5
for i in range(n):
    print(a[i],end=' ')


Measured memory_bytes: 3060
a,b,k=gets.split(" ").map(&:to_i)
p = []
if ((b-a+1)/k) < 2
  (a..b).each do |i|
    p << i
  end
else
  (a..a+(k-1)).each do |i|
    p << i
  end
  (b-k+1..b).each do |i|
    p << i
  end
end

p.length.times do |i|
  print("#{p[i]}\n")
end

Measured memory_bytes: 1916
def dfs(x, y): 
    if x == h-1 and y == w-1:
        a[x][y] = "."
        judge()

    if a[x][y] == "#":
        a[x][y] = "."

    if y+1 < w and a[x][y+1] != ".":
        dfs(x, y+1)#右
    
    if x+1 < h and a[x+1][y] != ".":
        dfs(x+1, y)#下
    
    judge()
    
def judge():
    for i in range(h):
        if "#" in a[i]:
            print("Impossible")
            exit()
    print("Possible")
    exit()

h, w = map(int, input().split())
a = []
for i in range(h):
    a.append(list(input()))

dfs(0, 0)

Measured memory_bytes: 3064
import itertools


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

    A, B, C, D = [], [], [], []
    for _ in range(q):
        a, b, c, d = map(int, input().split())
        A.append(a)
        B.append(b)
        C.append(c)
        D.append(d)
    if m == 1:
        return sum(D)
    ans = 0
    length = m+n-1
    for item in itertools.combinations(range(length), m-1):
        ptn = []
        num = 1
        p = 0
        for i in range(length):
            if i == item[p]:
                num += 1
                p += 1
                p = min(m-2, p)
                continue
            ptn.append(num)
        tmp = 0
        for k in range(q):
            if (ptn[B[k]-1] - ptn[A[k]-1]) == C[k]:
                tmp += D[k]

        ans = max(tmp, ans)
    return ans

print(main())


Measured memory_bytes: 9224
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

typedef db T;
const db eps = 1e-8;
int sgn(T x){return (x>eps)-(x<-eps);}
struct P{
    T x,y;
    P(){} P(T x,T y):x(x),y(y){}
    void read(){scanf("%lf%lf",&x,&y);}
    P operator - (const P&b) const {return P(x-b.x,y-b.y);}
    P operator + (const P&b) const {return P(x+b.x,y+b.y);}
    T operator * (const P&b) const {return x*b.x+y*b.y;}
    P operator * (const T&k) const {return P(x*k,y*k);}
    T operator ^ (const P&b) const {return x*b.y-y*b.x;}
    bool operator < (const P&b) const {return sgn(y-b.y)?y<b.y:x<b.x;}
};
T cross(P o,P a,P b){return (a-o)^(b-o);}
int crossOp(P o,P a,P b){return sgn(cross(o,a,b));}
struct L{
    P s,t;
    L(){} L(P s,P t):s(s),t(t){}
};
P insLL(L a,L b){
    P s = a.s - b.s , v = a.t - a.s , w = b.t - b.s;
    db k1 = s ^ w , k2 = w ^ v;
    return a.s + v * (k1 / k2);
}
typedef vector<P> polygon;
T area(polygon A) {
    T res=0;
    rep(i,0,sz(A)) res+=A[i]^(A[(i+1)%sz(A)]);
    return res / 2;
}
polygon convexCut(polygon A,P s,P t){
    int n=sz(A);
    polygon B;
    rep(i,0,n){
        P u=A[i],v=A[(i+1)%n];
        int d1 = crossOp(s,t,u) , d2 = crossOp(s,t,v);
        if(d1 >= 0) B.pb(u);
        if(d1 * d2 < 0) B.pb(insLL(L(u,v),L(s,t)));
    }
    return B;
}
int main(){
    int n;scanf("%d",&n);
    polygon A;
    rep(i,0,n){
        P p;p.read();
        A.pb(p);
    }
    int Q;scanf("%d",&Q);
    rep(i,0,Q){
        P s,t;s.read();t.read();
        printf("%.10f\n",area(convexCut(A,s,t)));
    }
    return 0;
}

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

long long dp[1005 * 100];
pair<int, int> a[105];

int main()
{
    int n, w;
    cin >> n >> w;
    for(int i = 0; i < n; ++i){
        cin >> a[i].first >> a[i].second;
    }
    for(int i = 0; i <= 100000; ++i){
        dp[i] = 1e18;
    }

    for(int i = 1; i <= a[0].second; ++i){
        dp[i] = a[0].first;
    }
    dp[0] = 0;

    for(int i = 1; i < n; ++i){
        for(int j = 100000; j >= a[i].second; --j){
            dp[j] = min(dp[j], dp[j - a[i].second] + a[i].first);
        }
    }

    for(int i = 100000; i >= 0; --i){
        if(dp[i] <= w){
            cout << i << "\n";
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
  int i, n, a[100];

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
  for(i = n - 1; i >= 0; i--){
    printf("%d", a[i]);
    if(i){
      printf(" ");
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
using namespace std;
struct po {
  string str;
  int score;
};

int main() {


int flg = 0;
  while(1) {
    
    int n;
    cin >> n;
    if(n == 0) break;

    po team[11];
    for(int i=0;i<n;i++) {
      int a,b,c;
      cin >> team[i].str >> a >> b >> c;
      team[i].score = a*3+c;
    }

    for(int i=0;i<n;i++) {
      for(int j=n-1;j>i;j--) {
	if(team[j].score > team[j-1].score) {
	  po t = team[j];
	  team[j] = team[j-1];
	  team[j-1] = t;
	}
      }
    }

    if(flg == 1) cout << endl;
    for(int i=0;i<n;i++) 
      cout << team[i].str<<","<<team[i].score<<endl;

    flg = 1;

  }

  return 0;
}

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

using namespace std;

#define ll long long

//iostream::sync_with_stdio(false);

const int maxn = 1e5 + 5;

int main()
{
    int n, k;
    int m[1005];
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    {
        cin >> m[i];
    }
    sort(m, m + n);
    int sum = 0;
    for(int i = 0; i < k; i++)
    {
        sum += m[i];
    }
    cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3640
using System;
class p
{
  static void Main()
  {
    string S = Console.ReadLine();
    int min = int.MaxValue;
    for (int i = 0; i < S.Length - 2; i++) {
      min = Math.Min(min, Math.Abs(753 - int.Parse(S.Substring(i, 3))));
    }
    Console.WriteLine(min);
  }
}

Measured memory_bytes: 13140
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  int n; std::cin >> n;
  std::vector<int> p(n);
  for (int i = 0; i < n; ++i) std::cin >> p[i];

  int cnt = 0;
  for (int i = 1; i < n - 1; ++i) {
    if (p[i] < p[i-1] && p[i] > p[i+1]) {
      ++cnt;
    } else if (p[i] > p[i-1] &&  p[i] < p[i+1]) {
      ++cnt;
    }
  }
  std::cout << cnt << std::endl;
}


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

int main() 
{
    int N;
    cin >> N;
    vector<int>A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    vector<int> ans;
    for(int i = N-1; i >= 0; i-=2){
        ans.push_back(A[i]);
    }
    for (int i = N%2; i < N; i+=2) {
        ans.push_back(A[i]);
    }
    
    for (int i = 0; i < N; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 5068
n, m = map(int, input().split())

a = []
for i in range(n):
	s = input()
	a.append(s)
b = []
for i in range(m):
	t = input()
	b.append(t)

for i in range(n-m+1):
	for j in range(n-m+1):
		flg = False
		for k in range(i,i+m):
			for l in range(j,j+m):
				if a[k][l] != b[k-i][l-j]:
					flg = True
					break
			if flg:
				break
		if flg == False:
			print ("Yes")
			exit()
print ("No")

Measured memory_bytes: 3064
import scala.io.StdIn

object Main {
  def main(args: Array[String]){
    val N = StdIn.readInt()
    val inputs = (0 to N-1).map(_ => StdIn.readInt)
    println(inputs.filter{i =>
      (2 to Math.sqrt(i).toInt).forall(i % _ != 0)}.length)
  }
}

Measured memory_bytes: 120292