akhauriyash/Code-Regression huggingface dataset:
import unittest
from io import StringIO
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    N = int(input())
    h = list(map(int, input().split()))

    import math

    # cf. https://qiita.com/suecharo/items/14137fb74c26e2388f1f

    def make_prime_list_2(num):
        if num < 2:
            return []

        # 0のものは素数じゃないとする
        prime_list = [i for i in range(num + 1)]
        prime_list[1] = 0  # 1は素数ではない
        num_sqrt = math.sqrt(num)

        for prime in prime_list:
            if prime == 0:
                continue
            if prime > num_sqrt:
                break

            for non_prime in range(2 * prime, num, prime):
                prime_list[non_prime] = 0

        return [prime for prime in prime_list if prime != 0]

    def prime_factorization_2(num, dict_counter):
        """numの素因数分解
        素因数をkeyに乗数をvalueに格納した辞書型dict_counterを返す"""

        if num <= 1:
            # 例えば1を食ったときの対処の仕方は問題によって違うと思うのでそのつど考える。
            # cf. https://atcoder.jp/contests/abc110/submissions/12688244
            return False
        else:
            num_sqrt = math.floor(math.sqrt(num))
            prime_list = make_prime_list_2(num_sqrt)

            # 何度もこの関数を呼び出して辞書を更新したい時はこれを引数にして
            # cf. https://atcoder.jp/contests/arc034/submissions/12251452

            for prime in prime_list:
                while num % prime == 0:
                    if prime in dict_counter:
                        dict_counter[prime] += 1
                    else:
                        dict_counter[prime] = 1
                    num //= prime
            if num != 1:
                if num in dict_counter:
                    dict_counter[num] += 1
                else:
                    dict_counter[num] = 1

            return dict_counter
    dict_counter = {}
    for i in range(1, N+1):
        prime_factorization_2(i, dict_counter)

    l = list(dict_counter.values())
    ll = len(l)
    
    cnts={2:0,4:0,14:0,24:0,74:0}

    cnt=0
    for i in l:
        if i>=2:
            cnts[2]+=1
        if i>=4:
            cnts[4]+=1
        if i>=14:
            cnts[14]+=1
        if i>=24:
            cnts[24]+=1
        if i>=74:
            cnts[74]+=1
    ans=0
    ans+=cnts[4]*(cnts[4]-1)//2*(cnts[2]-2)
    ans+=cnts[14]*(cnts[4]-1)+cnts[24]*(cnts[2]-1)
    ans+=cnts[74]
    print(ans)
                


    


resolve()

Measured memory_bytes: 49388
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

using namespace std;
using ll = long long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI = acos(-1.0);

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

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

    cout << T / A * B << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N,l,r,ninzu = 0;
  cin >> N;
  
  for (int i = 0 ; i < N; i++) {
    cin >> l >> r;
    ninzu += r - l + 1;
    }
  cout << ninzu << endl;

}

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

int binarySearch(int a[], int n, int key)
{
	int left = 0;
	int right = n;
	while (left < right) {
		int mid = (left + right) / 2;
		if (a[mid] == key) {
			return mid;
		}
		else if (key < a[mid]) {
			right = mid;
		}
		else {
			left = mid + 1;
		}
	}
	return -1;
}

int main()
{
	int n = 0, q = 0;
	int s[Nmax] = { 0 }, t[Nmax] = { 9 };

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

	int cnt = 0;
	for (int i = 0; i < q; i++) {
		if (binarySearch(s, n, t[i]) != -1) {
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;

}


Measured memory_bytes: 3896
#include <bits/stdc++.h>
#include <string>
#include <iostream>

using namespace std;
 
 
 
int main(void){
  string S;
  string T;
  cin >> S;
  cin >> T;
  
  for(int i=0;i<int(S.length());i++){
    if(S[i]!=T[i]){
      cout << "No" << endl;
      return 0;
    }
      
  }
  cout << "Yes" << endl;
}

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

const int N = 3e3 + 20;
int dp[N][N];
pair<int, int> pre[N][N];
char c[N][N];

int main()
{
	string s1, s2;
	cin >> s1 >> s2;
	int t1 = s1.size(), t2 = s2.size();
	int tt = max(t1, t2) + 1;
	for (int i = 0; i < tt + 5; i++)
	{
		for (int j = 0; j < tt + 5; j++)
		{
			pre[i][j] = make_pair(-1, -1);
		}
	}
	for (int i = 1; i <= t1; i++)
	{
		for (int j = 1; j <= t2; j++)
		{
			if (s1[i - 1] == s2[j - 1])
			{
				c[i][j] = s1[i - 1];
				dp[i][j] = dp[i - 1][j - 1] + 1;
				pre[i][j] = make_pair(i - 1, j - 1);
				continue;
			}
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			if (dp[i - 1][j] > dp[i][j - 1]) pre[i][j] = make_pair(i - 1, j);
			else pre[i][j] = make_pair(i, j - 1);
		}
	}
	int x = t1, y = t2;
	string ans = "";
	while (pre[x][y] != make_pair(-1, -1))
	{
		if (int(c[x][y]) >= 97 && int(c[x][y]) <= 122) ans += c[x][y];
		pair<int, int> p = pre[x][y];
		x = p.first;
		y = p.second;
	}
	reverse(ans.begin(), ans.end());
	cout << ans;
}



Measured memory_bytes: 118768
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    long long ans=0;
    for(int i=k+1; i<=n; i++)
        ans+=(n/i)*1LL*(i-k)+max(n%i-k+1,0)-!k;
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppll pair <pll, pll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#pragma 03
using namespace std;
using namespace __gnu_pbds;
int main(){
	ll q; cin >> q;
	while (q--){
		ll a, b; cin >> a >> b; if (a > b) swap(a, b);
		if (a == b) cout << 2 * a - 2 << endl;
		else if (a + 1 == b) cout << 2 * a - 2 << endl;
		else{
			ll c = sqrt(a * b); if (c * c == a * b) c--;
			if (c * (c + 1) >= a * b) cout << 2 * c - 2 << endl;
			else cout << 2 * c - 1 << endl;
		} 
	}
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

using ll = long long;
using p = pair<ll, ll>;

const int N = 405;

// dp[l][r]: pair<ll, ll>: size of slime produced by merging [l, r], and cost of it.
p dp[N][N];
ll a[N];
int n;

bool update(ll& a, ll b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

void solve() {
    for (int i = 0; i < N; ++i) fill(dp[i], dp[i] + N, make_pair(0, __LONG_LONG_MAX__));
    for (int i = 0; i < n; ++i) {
        scanf("%lld", a + i);
    }
    for (int len = 0; len < n; ++len) {
        // [l, r]
        for (int l = 0, r = l + len; r < n; ++l, ++r) {
            if (!len) {
                dp[l][r] = make_pair(a[l], 0); // merge 1 slime need 0 cost
                continue;
            }
            for (int mid = l; mid + 1 <= r; ++mid) {
                // merge two slime [l, mid] and [mid + 1, r]
                ll b = dp[l][mid].first;
                ll c = dp[l][mid].second;
                ll d = dp[mid + 1][r].first;
                ll e = dp[mid + 1][r].second;
                if (b + c + d + e < dp[l][r].second) {
                    dp[l][r] = make_pair(b + d, b + c + d + e);
                }
            }
        }
    }
    // printf("%lld %lld\n", dp[0][n - 1].first, dp[0][n - 1].second);
    printf("%lld\n", dp[0][n - 1].second);
}

int main() {
    while (~scanf("%d", &n)) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 2688
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>

using namespace std;

const int N = 110, M = N * N;

int x[N], y[N], a[N], b[N];

int n;
int h[N], e[M], ne[M], idx;
void add(int a, int b)
{
    e[idx] = b;
    ne[idx] = h[a];
    h[a] = idx ++;
}

bool st[N];
int match[N];

bool find(int u)
{
    for(int i = h[u]; ~i; i = ne[i])
    {
        int j = e[i];
        if(!st[j])
        {
            st[j] = true;
            if(!match[j] || find(match[j]))
            {
                match[j] = u;
                return true;
            }
        }
    }
    return false;
}

int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; i ++)  scanf("%d%d", &x[i], &y[i]);
    for(int i = 1; i <= n; i ++)  scanf("%d%d", &a[i], &b[i]);
    
    memset(h, -1, sizeof h);
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
            if(x[i] < a[j] && y[i] < b[j])
                add(i, j);
    
    int res = 0;
    for(int i = 1; i <= n; i ++)
    {
        memset(st, 0, sizeof st);
        if(find(i))  res ++;
    }
    printf("%d", res);
	return 0;
}

Measured memory_bytes: 888
import java.util.*;

class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int a = Integer.parseInt(sc.nextLine());
        String s = sc.nextLine();
        if(a >= 3200) System.out.println(s);
        else System.out.println("red");
    }
}

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

constexpr int inf = 1e9;

template<typename T>
std::vector<T> table(int n, T v) { return std::vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return std::vector<decltype(val)>(n, std::move(val));
}

constexpr int dx[3] = {1, 0, -1};
constexpr int dy[2][3] = {
    {0, 1, 0}, // (x + y) % 2 == 0
    {0, -1, 0}
};

constexpr int df[20][2][3] = {
    {{1, 5, 4}, {4, 5, 1}},
    {{2, 6, 0}, {0, 6, 2}},
    {{3, 7, 1}, {1, 7, 3}},
    {{4, 8, 2}, {2, 8, 4}},
    {{0, 9, 3}, {3, 9, 0}},
    {{10, 0, 11}, {11, 0, 10}},
    {{11, 1, 12}, {12, 1, 11}},
    {{12, 2, 13}, {13, 2, 12}},
    {{13, 3, 14}, {14, 3, 13}},
    {{14, 4, 10}, {10, 4, 14}},
    {{5, 15, 9}, {9, 15, 5}},
    {{6, 16, 5}, {5, 16, 6}},
    {{7, 17, 6}, {6, 17, 7}},
    {{8, 18, 7}, {7, 18, 8}},
    {{9, 19, 8}, {8, 19, 9}},
    {{19, 10, 16}, {16, 10, 19}},
    {{15, 11, 17}, {17, 11, 15}},
    {{16, 12, 18}, {18, 12, 16}},
    {{17, 13, 19}, {19, 13, 17}},
    {{18, 14, 15}, {15, 14, 18}}
};
constexpr int dd[3][2][3] = { // only used on 0, ..., 4, 15, ..., 19
    {{2, 0, 1}, {1, 0, 2}},
    {{1, 2, 0}, {0, 2, 1}},
    {{0, 1, 2}, {2, 1, 0}}
};

int main() {
    constexpr int max_x = 201, max_y = 102;
    constexpr int cx = 100, cy = 50;
    auto in_range = [] (int x, int y) {
        return 0 <= x && x < max_x && 0 <= y && y < max_y;
    };

    int gx, gy, n;
    while(cin >> gx >> gy >> n, gx | gy | n) {
        gx += cx, gy += cy;
        auto d = table(max_x, max_y, 20, 3, inf);
        d[cx][cy][0][0] = 0;
        queue<tuple<int, int, int, int>> que;
        que.emplace(cx, cy, 0, 0);
        int ans = inf;
        while(!que.empty()) {
            int x, y, f, dir; tie(x, y, f, dir) = que.front();
            que.pop();
            if(x == gx && y == gy && f == n) {
                ans = d[x][y][f][dir];
                break;
            }
            for(int i = 0; i < 3; ++i) {
                const int nx = x + dx[i], ny = y + dy[(x + y) & 1][i];
                int nf = 0, nd = 0;
                if((x + y) & 1) {
                    nf = df[f][1][(i - dir + 3) % 3];
                } else {
                    nf = df[f][0][(i + dir) % 3];
                }
                if((5 <= f && f < 15) || (5 <= nf && nf < 15)) {
                    nd = dir;
                } else {
                    nd = dd[dir][(x + y) & 1][i];
                }
                if(!in_range(nx, ny) || d[nx][ny][nf][nd] != inf) continue;
                d[nx][ny][nf][nd] = d[x][y][f][dir] + 1;
                que.emplace(nx, ny, nf, nd);
            }
        }

        cout << ans << endl;
    }
}



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

using namespace std;

#define int long long

bool codejam = 0;

typedef long long li;
typedef long double ld;

void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1; 
	// cin >> t;
	int tt = t;
	while (t--) { 
		if (codejam) cout << "Case #" << tt - t << ": ";
		solve();
	}
	return 0;
}

void solve() {
	int n; cin >> n;
	cout << 180 * (n - 2);
}


Measured memory_bytes: 256
n, m = map(int, input().split())
A = []
for i in range(n):
    A.append(list(map(int, input().split())))
    
vec=[]
for i in range(m):
    vec.append(int(input()))

for i in range(n):
    sum = 0
    for ii in range(m):
        sum += A[i][ii]*vec[ii]
    
    print(sum)
    


Measured memory_bytes: 6012
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  (B) <= (A) && (A) <= (C)
#define AIN(A, B, C) assert(IN(A, B, C))

void solve(){
      int l,r,x;
       cin>>l>>r>>x;
       int c=0;
       for(int i=l;i<=r;i++){
       	if(i%x==0)c++;
       }
       cout<<c;
}
int main() {
    ios;
	int t=1;
	//cin>>t;
	while(t--)solve();
 
    
}


Measured memory_bytes: 3612
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n,l=MI()
tastes=[]
sche=n*(n-1)//2+n*l
dif=10**8
for i in range(1,n+1):
    taste=sche-(l+i-1)
    if abs(l+i-1)<dif:
        dif=abs(l+i-1)
        ans=taste
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define fastio      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int N = 1e6 + 6;

int main()  {
    fastio;
    int n;
    cin>>n;
    vector<int>vec(n);
    for(int i =0 ; i < n ; i++) cin>>vec[i];
    sort(vec.begin() , vec.end());
    int ans = 0;

    for(int i=0 ; i < n ; i++ ) {
        for(int j = i + 1; j < n  ; j++ ) {
            for(int k = j + 1; k < n ; k++ ) {

                if(vec[i] != vec[j] && vec[j] != vec[k] && vec[i] != vec[k] && vec[i] + vec[j] > vec[k]) ans++;
            }
        }
    }
    cout<<ans<<'\n';
    return 0;
    
}

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

const int MAX_Q = 50;
int N, M, Q, ans;
int a[MAX_Q], b[MAX_Q], c[MAX_Q], d[MAX_Q];

void dfs(vector<int> A) {
    if (A.size() >= N) {
        int cur = 0;
        rep(i, Q) {
            if (A[b[i]] - A[a[i]] == c[i]) {
                cur += d[i];
            }
        }
        ans = max(ans, cur);
        return;
    }
    
    A.push_back(A.back());
    while (A.back() <= M) {
        dfs(A);
        A.back()++;
    }
}

int main() {
    cin >> N >> M >> Q;
    rep(i, Q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }
    dfs(vector<int>{1});
    cout << ans << endl;
}

Measured memory_bytes: 3632
#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++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

int C;

// dijkstra O(ElogV)
// verify : https://onlinejudge.u-aizu.ac.jp/problems/GRL_1_A
template<typename T>
struct Dijkstra {
private:
    int V;
    struct edge { int to; T cost; };
    vector<vector<edge>> G;
public:
    const T inf = numeric_limits<T>::max();

    // s から i の最小コスト
    // 経路がない場合は inf
    vector<vector<T>> d;

    Dijkstra(int V) : V(V) {
        G.resize(V);
    }

    // 辺の追加
    // 有向の場合　directed = true
    void add_edge(int from, int to, T weight, bool directed = false) {
        G[from].push_back({to,weight});
        if (!directed) G[to].push_back({from,weight});
    }

    void build(int s) {
        d.assign(V, vector<T>(C+1,inf));
        typedef pair<pair<T,int>, int> P; //(cost,v)
        priority_queue<P, vector<P>, greater<P>> pq;
        d[s][0] = 0;
        pq.push(P({d[s][0],0}, s));
        while (!pq.empty()) {
            P p = pq.top(); pq.pop();
            int v = p.second;
            int c = p.first.first;
            int k = p.first.second;
            if (d[v][k] < c) continue;
            for (const edge &e : G[v])
            {
                // 最小値が更新されるとき push
                if (k < C && d[e.to][k+1] > d[v][k] + e.cost / 2) {
                    d[e.to][k + 1] = d[v][k] + e.cost / 2;
                    pq.push({{d[e.to][k + 1],k + 1}, e.to});
                }
                if (d[e.to][k] > d[v][k] + e.cost) {
                    d[e.to][k] = d[v][k] + e.cost;
                    pq.push({{d[e.to][k],k}, e.to});
                }
            }
        }
    }
};

int main() {
    while (true) {
        int n, m, s, d; cin >> C >> n >> m >> s >> d;
        if (!C) break;
        Dijkstra<ll> G(n);
        s--; d--;
        REP(i, m) {
            int a, b; ll c; scanf("%d %d %lld", &a, &b, &c);
            a--; b--;
            G.add_edge(a, b, c);
        }
        G.build(s);
        ll ans = LLINF;
        REP(i, C+1) {
            ans = min(ans, G.d[d][i]);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3192
#include<iostream>
#include<cstdio>
#include<cstring>
#define N 100010
#define M 200010
using namespace std;
int n,m,l[M],r[M],d[M],x[N];
bool vis[N];
int read()
{
	int x=0,f=1;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
struct edge
{
	int t,w;
	edge *next;
}*con[N];
void ins(int x,int y,int w)
{
	edge *p=new edge;
	p->t=y;
	p->w=w;
	p->next=con[x];
	con[x]=p;
}
void dfs(int v,int dis)
{
	x[v]=dis;vis[v]=1;
	for(edge *p=con[v];p;p=p->next)
		if(!vis[p->t]) dfs(p->t,dis+p->w); 
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;i++)
	{
		l[i]=read();r[i]=read();d[i]=read();
		ins(l[i],r[i],d[i]);
		ins(r[i],l[i],-d[i]);
	}
	for(int i=1;i<=n;i++)
		if(!vis[i]) dfs(i,0);
	bool flag=1;
	for(int i=1;i<=m;i++)
		if(x[r[i]]-x[l[i]]!=d[i]) {flag=0;break;}
	if(flag) puts("Yes");
	else puts("No");		
	return 0;
}

Measured memory_bytes: 18176
main :: IO ()
main = do
  sn <- getContents
  
  let s = lines sn
  let ac = length $ filter (== "AC") s
  let wa = length $ filter (== "WA") s
  let tle = length $ filter (== "TLE") s
  let re = length $ filter (== "RE") s
  
  putStr "AC x "
  print ac
  putStr "WA x "
  print wa
  putStr "TLE x "
  print tle
  putStr "RE x "
  print re

Measured memory_bytes: 22536
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	string str;
	cin >> str;

	for (int i = 0; i < str.length(); i++)
	{
		if (str[i] == '7')
		{
			cout << "Yes";
			return 0;
		}
	}

	cout << "No";

	return 0;
}

Measured memory_bytes: 3612
import sys
readline = sys.stdin.readline

def main():
    N, M = map(int, readline().rstrip().split())
    A = [readline().rstrip() for _ in range(N)]
    B = [readline().rstrip() for _ in range(M)]
    if A == B:
        print('Yes')
        return
    for h in range(N-M):
        for w in range(N-M):
            a = [l[w:w+M] for l in A[h:h+M]]
            if a == B:
                print('Yes')
                return

    print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		int[] h = nextInts();

		long[] dp = new long[N+1];
		dp[0]=0;
		dp[1]=Math.abs(h[1]-h[0]);
		if(N>2){
			dp[2]=Math.min(Math.abs(h[2]-h[1])+dp[1], Math.abs(h[2]-h[0]));
		}
		for(int i=2;i<N;i++){
			dp[i]=Math.min(Math.abs(h[i]-h[i-1])+dp[i-1], Math.abs(h[i]-h[i-2])+dp[i-2]);
		}
		System.out.println(dp[N-1]);

	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}

Measured memory_bytes: 33860
#pragma GCC optimize ("O3")

#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 << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int 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 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 A, B;
    cin >> A >> B;

    vi v = {A + B, A - B, A * B};

    print(*max_element(ALL(v)));

    
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using Int = int64_t;

const Int N = 312345;
bool is_prime[N];

int main() {
   for(Int i = 0; i < N; ++i) {
      is_prime[i] = true;
   }
   is_prime[0] = is_prime[1] = false;
   for(Int i = 2; i * i < N; ++i) {
      if( is_prime[i] ) {
         for(Int k = 2*i; k < N; k+=i) {
            is_prime[k] = false;
         }
      }
   }
   for(;;) {
      Int n;
      std::cin >> n;
      if( n == 0 ) break;
      Int count = 0;
      for(Int i = n+1; i <= 2*n; ++i) {
         if( is_prime[i] ) {
            count += 1;
         }
      }
      std::cout << count << std::endl;
   }
}




Measured memory_bytes: 3400
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;


typedef struct node_t {
    struct node_t *next;
    struct node_t *prev;
    unsigned int v;
} node;


node *nil;


void init(void)
{
    nil = (node *)malloc(sizeof(node));
    nil->next = nil;
    nil->prev = nil;
    nil->v = 0;
}


void insert_node(unsigned int v)
{
    node *tmp;
    tmp = (node *)malloc(sizeof(node));
    tmp->v = v;

    tmp->next = nil->next;
    nil->next->prev = tmp;
    tmp->prev = nil;
    nil->next = tmp;
}


void delete_node(unsigned int v)
{
    node *tmp;

    for (tmp = nil; tmp->next != nil && tmp->next->v != v; tmp = tmp->next) ;

    node *d = tmp->next;
    if (d == nil)
        return;

    tmp->next->next->prev = tmp;
    tmp->next = tmp->next->next;
    free(d);
}


void delete_first(void)
{
    delete_node(nil->next->v);
}


void delete_last(void)
{
    node *d;
    d = nil->prev;
    if (d == nil)
        return;

    nil->prev->prev->next = nil;
    nil->prev = nil->prev->prev;
    free(d);
}


void print_list()
{
    node *tmp;
    for (tmp = nil->next; tmp->next != nil; tmp = tmp->next) {
        cout << tmp->v << " ";
    }
    cout << tmp->v << endl;
}


int main(void)
{
    int n;
    char cmd[16];

    init();

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%s", cmd);
        if (cmd[0] == 'i') {
            unsigned int v;
            scanf("%u", &v);
            insert_node(v);
        } else if (strlen(cmd) == 6) {
            unsigned int v;
            scanf("%u", &v);
            delete_node(v);
        } else if (cmd[6] == 'F') {
            delete_first();
        } else if (cmd[6] == 'L') {
            delete_last();
        }
    }

    print_list();

    return 0;
}



Measured memory_bytes: 34388
function Main(input) {
	input = input.trim().split("\n");
  var list = {
  	"A" : input[0].split(""),
  	"B" : input[1].split(""),
  	"C" : input[2].split("")
  }
  var turn = "A";
  while(true){
    if(list[turn].length == 0){
       break;
    }else{
       turn = list[turn].shift().toUpperCase();
    }
  }
  console.log(turn);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 20);

int n;
int a[MAXN];

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

bool on_bound(int x, int y) { return a[x] <= y; }

void solve()
{
	sort(a, a + n);
	reverse(a, a + n);

	int x = 0, y = 0;
	while(true)
	{
		if(on_bound(x + 1, y + 1)) break;
		x++, y++;
	}

	int up_parity = (a[x] - y) & 1;
	int right_parity = 0;

	while(!on_bound(x, y)) x++, right_parity ^= 1; 

	if(up_parity == 1 && right_parity == 1) cout << "Second" << endl;
	else cout << "First" << endl;
}

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

	read();
	solve();
	return 0;
}



Measured memory_bytes: 640
# 解法1
# def main():
#   N, M = map(int, input().split())
#   num = [-1] * N

#   for _ in range(M):
#     s, c = map(int, input().split())
#     s -= 1
#     if s == 0 and c == 0:
#       if N != 1:
#         print(-1)
#         return
#     if num[s] == -1:
#       num[s] = c
#     elif num[s] != c:
#       print(-1)
#       return

#   ans = ""
#   for i in range(len(num)):
#     c = num[i]
#     if c == -1:
#       if i != 0 or N == 1:
#         ans += "0"
#       else:
#         ans += "1"
#     else:
#       ans += str(c)

#   print(ans)

# 解法2
def main():
  N, M = map(int, input().split())
  S = [0] * M
  C = [0] * M
  for i in range(M):
    s, c = map(int, input().split())
    S[i] = s-1
    C[i] = c

  if N == 1:
    start = 0
  else:
    start = 10 ** (N - 1)

  for n in range(start, 10 ** (N)):
    n = str(n)
    ok = True
    for i in range(M):
      s = S[i]
      c = C[i]
      if n[s] != str(c):
        ok = False
        break
    if ok:
      print(n)
      return

  print(-1)
main()


Measured memory_bytes: 62964
var
  s:string;
  i,j,n,m,d,x,y:longint;
begin
  s:='RGBY';
  readln(n,m,d);
  for i:=0 to n-1 do
  begin
  for j:=0 to m-1 do
  begin
    x:=(m+i+j)div d mod 2;
    y:=(m+i-j)div d mod 2;
    write(s[2*x+y+1]);
  end;
  writeln;
  end;
end.

Measured memory_bytes: 384
package main

import (
	"fmt"
)

func main() {
	var A,B,C,X,cnt int
	fmt.Scan(&A,&B,&C,&X)

	for i := 0; i <= A; i++ {
		for j := 0; j <= B; j++ {
			for k := 0; k <= C; k++ {
				if 500 * i + 100 * j + 50 * k == X {
					cnt++;
				}
			}
		}
	}
	fmt.Println(cnt)
	
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

const int maxn = 5e5 + 10;

int n;
string s;
int st[4 * maxn];

void build(int id = 1, int l = 0, int r = n) {
	if(r - l <= 1) {
		int pos = s[l] - 'a';
		st[id] = (1 << pos);
		return;
	}
	
	int mid = (r + l) / 2;
	build(2 * id, l, mid);
	build(2 * id + 1, mid, r);
	
	st[id] = st[id * 2] | st[id * 2 + 1];
}

int get(int x, int y, int id = 1, int l = 0, int r = n) {
	if(x >= r || y <= l) return 0;
	if(x <= l && y >= r) return st[id];

	int mid = (r + l) / 2;
	return get(x, y, id * 2, l, mid) | get(x, y, id * 2 + 1, mid, r);
}

void modify(int pos, char x, int id = 1, int l = 0, int r = n) {
	if(r - l <= 1) {
		st[id] = (1 << (x - 'a'));
		return;
	}
	
	int mid = (r + l) / 2;
	if(pos < mid) {
		modify(pos, x, id * 2, l, mid);
	} else modify(pos, x, id * 2 + 1, mid, r);
	
	st[id] = st[id * 2] | st[id * 2 + 1];
}


void solve() {
	cin >> n >> s;
	
	build();
	
	int q;
	cin >> q;
	while(q--) {
		int type;
		cin >> type;
		if(type == 1) {
			int i;
			char c;
			cin >> i >> c;
			modify(i - 1, c);	
		} else {
			int l, r;
			cin >> l >> r;
			l--; r--;
			cout << __builtin_popcount(get(l, r + 1)) << endl;
		}
	}	
}

int main(){
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 7988
#include <bits/stdc++.h>
using namespace std ;
#define data_type long long
#define endl "\n"
int main()
{
    data_type t,n,m,b,c,d,k,i,a=-1,te=0;
    cin>>n;
    vector<data_type>vc(5);
    for(auto &i:vc)
        cin>>i;
    for(int i=0; i<5; i++)
        {
            if(i==0)
                vc[i]=(n+vc[i]-1)/vc[i]+i;
            else
                vc[i]=max(vc[i-1]+1,(n+vc[i]-1)/vc[i]+i);
        }

    cout<<vc.back()<<endl;

    return 0;
}



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

//関数


//main関数
int main() {
    
    
    //入力
    long H,W;
    cin>>H>>W;
    vector<vector<char>> A(H,vector<char>(W));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>A.at(i).at(j);
        }
    }
    
    //計算
    vector<vector<long>> cost(H,vector<long>(W,INF));
    queue<pair<long,long>> que;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(A.at(i).at(j)=='#'){
                que.push(make_pair(i,j));
                
                cost.at(i).at(j)=0;
            } 
        }
    }
    
    while(!que.empty()){
        long h=que.front().first,w=que.front().second;
        if(h+1<H && cost.at(h+1).at(w)>cost.at(h).at(w)+1) {
            vector<long> state(2);
                que.push(make_pair(h+1,w));
                
                cost.at(h+1).at(w)=cost.at(h).at(w)+1;
        }
        if(h-1>=0 && cost.at(h-1).at(w)>cost.at(h).at(w)+1) {
            vector<long> state(2);
                que.push(make_pair(h-1,w));
                
                cost.at(h-1).at(w)=cost.at(h).at(w)+1;
        }
        if(w+1<W && cost.at(h).at(w+1)>cost.at(h).at(w)+1) {
            vector<long> state(2);
                que.push(make_pair(h,w+1));
                
                cost.at(h).at(w+1)=cost.at(h).at(w)+1;
        }
        if(w-1>=0 && cost.at(h).at(w-1)>cost.at(h).at(w)+1) {
            vector<long> state(2);
                que.push(make_pair(h,w-1));
                
                cost.at(h).at(w-1)=cost.at(h).at(w)+1;
        }
        
        que.pop();
    }
    
    
    long ans=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
          //  cout<<cost.at(i).at(j)<<" ";
            ans=max(ans,cost.at(i).at(j));
        }
      //  cout<<endl;
    }
    
    
 
    //出力
    cout<<ans<<endl;
}

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

int main(void) {
    int datamax,datanum;
    int equalnum;
    int i;
    char hebi[201];
    scanf("%d",&datamax);
    for(datanum=0;datanum<datamax;datanum++) {
        scanf("%s",hebi);
        if(strlen(hebi)<2 || hebi[0]!='>') {
            puts("NA");
            continue;
        }
        if(hebi[1]=='\'') {
            equalnum=0;
            i=2;
            while(hebi[i]=='=') {
                i++;
                equalnum++;
            }
            if(hebi[i]!='#' || equalnum<=0)puts("NA");
            else {
                i++;
                while(hebi[i]=='=') {
                    i++;
                    equalnum--;
                }
                if(equalnum!=0)puts("NA");
                else if(hebi[i]!='~' || hebi[i+1]!=0)puts("NA");
                else puts("A");
            }
        } else if(hebi[1]=='^') {
            i=2;
            while(hebi[i]=='Q' && hebi[i+1]=='=')i+=2;
            if(i==2)puts("NA");
            else if(hebi[i]!='~' || hebi[i+1]!='~' || hebi[i+2]!=0)
                puts("NA");
            else puts("B");
        } else puts("NA");
    }
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	int temp=0;
	for(int i=1;i<n;i++){
		int sisa=n-i;
		// cout << sisa << '\n';
		for(int j=1;j*j<=sisa;j++){
			if(sisa%j==0){
				if((sisa/j)==j) temp++;
				// cout << j << '\n';
				else temp+=2;
			}
		}
	}
	cout << temp << '\n';
}

Measured memory_bytes: 3628
X,N=map(int,input().split())
a_list=list(map(int,input().split()))
if N==0:
    print(X)
else:
    if X in a_list:
        for i in range(N//2+2):
            #print(i)
            if X-i in a_list:
                
                if X+i in a_list:
                    a=1
                else:
                    print(X+i)
                    break
            else:
                print(X-i)    
                break        
    else:
        print(X)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define pi 3.14
using namespace std;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<long long,int> pli;
typedef pair<int,long long> pil;
const int INF=1000000007;
const int MOD=1000000007;
const int nmax=101234;

int n,m,f[nmax],flg;
char s[nmax];
vector<int> v2;

int F(int i)
{
    if(s[f[i]]=='0')
        return f[i];
    else
        return f[i]=F(f[i]+1);
}

int main()
{
    scanf("%d%d %s",&n,&m,s);
    if(s[0]=='1' || s[n]=='1')
        flg=1;
    else
    {
        for(int i=1; i<=n; ++i)
            f[i]=i;
        for(int i=n; i;)
        {
            if(i<=m)
            {
                v2.pb(i);
                break;
            }
            int pos=F(i-m);
            if(pos==i)
            {
                flg=1;
                break;
            }
            v2.pb(i-pos);
            i=pos;
        }
    }
    if(flg==1)
        printf("-1\n");
    else
        for(int i=(int)v2.size()-1; i>=0; --i)
            printf("%d%c",v2[i],i==0?'\n':' ');
    return 0;
}


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

int main(){
  int m,n;
  cin>>m>>n;
  bool p[200][200]={};
  for(int i=1;i<200;i++){
    for(int t=0;t<200;t++){
      p[i][t]=true;
    }
  }
  for(int i=0;i<m;i++){
    for(int t=0;t<n;t++){
      char c;
      cin>>c;
      if(c=='o'){p[i][t]=false; p[i][t+1]=false; if(t!=0){p[i][t-1]=false;}}
      if(c=='x'){
	for(int x=-1;x<=1;x++){
	  for(int y=-1;y<=1;y++){
	    if(i+x<0 || t+y<0){continue;}
	    p[i+x][t+y]=false;
	  }
	}
      }
    }
  }
  int count=0;
  for(int i=1;i<m;i++){
    for(int t=0;t<n;t++){
      if(p[i][t]){count++;}
    }
  }
  cout<<count<<endl;







  return 0;
}



Measured memory_bytes: 3132
A, B, M = map(int, input().split())
a = [int(s) for s in input().split()]
b = [int(s) for s in input().split()]
m = []


for n in range(M):
    m.append([int(s) for s in input().split()])

minValue = min(a) + min(b)

for i in range(M):
    discountPrice = a[m[i][0] - 1] + b[m[i][1] - 1] - m[i][2]
    if discountPrice  < minValue:
        minValue = discountPrice

print(minValue)


Measured memory_bytes: 36964
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cmath>
#include<string>
#include<algorithm>
#define inf 0x3f3f3f3f
#define ll long long
#define ull unsigned long long
#define pi acos(-1.0)
using namespace std;
const int maxn = 1e6+5;

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


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort(reverse=True)
    return divisors


n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

div = make_divisors(sum(a))

for x in div:
    aa = [ai % x for ai in a]
    aa.sort()
    ss = aa[:len(aa) - sum(aa) // x]
    s = sum(ss)

    if 0 <= s <= k:
        print(x)
        break

# 2 | 3 5 | 8 _ 3
# 3 | 3 1 2 1 | 7 _ 4
# 4 | 1 2 0 1 3 2 1 0 | 10 _ 5


Measured memory_bytes: 3188
n = int(input())
v = list(map(int, input().split()))

even = []
odd = []
for i in range(n):
    if i % 2 == 0:
        even.append(v[i])
    else:
        odd.append(v[i])


def search_mode(list):
    dict = {}
    mode = 0
    for l in list:
        if l in dict.keys():
            dict[l] += 1
            if mode < dict[l]:
                mode = dict[l]
        else:
            dict[l] = 1
    dict = sorted(dict.items(), key=lambda x: -x[1])
    return dict


even_dict = search_mode(even)
odd_dict = search_mode(odd)

if len(even_dict) == 1 and len(odd_dict) == 1:
    if even_dict[0][0] == odd_dict[0][0]:
        print(n // 2)
    else:
        print(0)
elif len(even_dict) == 1:
    if even_dict[0][0] == odd_dict[0][0]:
        print(len(odd) - odd_dict[1][1])
    else:
        print(len(odd) - odd_dict[0][1])
elif len(odd_dict) == 1:
    if odd_dict[0][0] == even_dict[0][0]:
        print(len(even) - even_dict[1][1])
    else:
        print(len(even) - even_dict[0][1])
elif even_dict[0][0] == odd_dict[0][0]:
    eo01 = n - even_dict[0][1] - odd_dict[1][1]
    eo10 = n - even_dict[1][1] - odd_dict[0][1]
    max_count = min(eo01, eo10)
    print(max_count)
else:
    print(n - even_dict[0][1] - odd_dict[0][1])



Measured memory_bytes: 20712
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
using namespace std;

int main(){
  int N; cin >> N;
  vector<char> S(N);
  bool four = false;
  for(int i = 0; i < N; i++){
    cin >> S[i];
    if(S[i] == 'Y') four = true;
  }
  if(four) cout << "Four" << endl;
  else cout << "Three" << endl;
}


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

int main() {
  while (1) {
    char c;
    scanf("%c", &c);
    int a = atoi(&c);
    if (a == 0)
      return 0;
    while (1) {
      scanf("%c", &c);
      if (c == '\n') {
        cout << a << endl;
        break;
      }
      a += atoi(&c);
    }
  }
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

int abs(int n)
{
	if (n < 0) return -n;
	else return n;
}

int main()
{
	int n, m;
	cin >> n >> m;
	pair <int, int> stu[n];
	pair <int, int> che[m];
	REP(i, n) cin >> stu[i].first >> stu[i].second;
	REP(i, m) cin >> che[i].first >> che[i].second;

	REP(i, n){
		int min = INF;
		int far;
		REP(j, m){
			far = abs(che[j].first - stu[i].first) + abs(che[j].second - stu[i].second);
			if (min > far){
				min = far;
			}
		}

		REP(j, m){
			if (min == abs(che[j].first - stu[i].first) + abs(che[j].second - stu[i].second)){
				cout << j + 1 << endl;
				break;
			}

		}

	}
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var k = int.Parse(Console.ReadLine());
        var s = Console.ReadLine().Split(' ');

        var ans = 0;
        for (int i = 0; i < n; i++)
        {
            var x = int.Parse(s[i]);
            ans += Math.Min(x * 2,
                Math.Abs(x - k) * 2);
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11220
q = int(raw_input())
for _ in xrange(q):
  x0,y0,x1,y1,x2,y2,x3,y3 = map(float, raw_input().split())
  ax = x1-x0
  ay = y1-y0
  bx = x3-x2
  by = y3-y2
  inner = ax*bx+ay*by
  outer = ax*by-ay*bx
  if inner == 0:
    print 1
  elif outer == 0:
    print 2
  else:
    print 0

Measured memory_bytes: 6468
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim (lld)1e9+7
#define MAX2 (int)2e5+9
#define ff first
#define ss second
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const lld mod=lim;

lld power(lld x, lld y, lld p)  
{   lld res = 1;     x = x % p; if (x == 0) return 0;  
  
    while (y > 0)  
    { if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;   }  
    return res;  } 


int extend_gcd(int a, int b, int& x, int& y) {
    if (b == 0) { x = 1;y = 0;return a;}
    int x1, y1;
    int d = extend_gcd(b, a % b, x1, y1);
    x = y1; y = x1 - y1 * (a / b);return d;	}

int rowNum[]={-1,0,0,1};
int colNum[]={0,-1,1,0};

int main()
{
	fastio
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i<s.size();i++)
	{
		ans+=(s[i]-'0');
		ans%=9;
	}

	ans%=9;

	if(ans==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

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

typedef long long ll;

const ll mod = 1000000007;

using namespace std;

// 到達できる数から逆算する

int main()
{
    int N, M;
    cin >> N >> M;

    int a[100000] = {};

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

    // そこまでの到達数をメモする
    ll dp[N+1] = {};
    dp[0] = 1;

    // １か２移動できるので、その分用意する
    if (a[1]) dp[1] = 0;
    else dp[1] = 1;

    for (int i = 2; i < N +1; ++i) {
        // 壊れた床に到達するのは0
        if (a[i] == 1) dp[i] = 0;
        else dp[i] = (dp[i-1] + dp[i-2]) % mod;
    }

    cout << dp[N] << endl;
}

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

int main() {
    int w,h,n;
    cin >> w >> h >> n;
    vector<vector<bool>> p(h, vector<bool>(w, true));
    for(int i = 0; i < n; i++) {
        int x,y,a;
        cin >> x >> y >> a;
        if(a==1){
            for(int j = 0; j < h; j++) {
                for(int k = 0; k < x; k++) {
                    p.at(j).at(k)=false;
                }
            }
        }
        if(a==2){
            for(int j = 0; j < h; j++) {
                for(int k = x; k < w; k++) {
                    p.at(j).at(k)=false;
                }
            }
        }
        if(a==3){
            for(int j = 0; j < y; j++) {
                for(int k = 0; k < w; k++) {
                    p.at(j).at(k)=false;
                }
            }
        }
        if(a==4){
            for(int j = y; j < h; j++) {
                for(int k = 0; k < w; k++) {
                    p.at(j).at(k)=false;
                }
            }
        }
    }
    int ans=0;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(p.at(i).at(j)==true) ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long
#define inf 100000000000LL
#define N 200005
using namespace std;
ll n,m,a[N],y,tg[N*4];
struct T
{
	ll x,y;
}s1[N*4],s2[N*4];
void up(ll k)
{
	ll l=k<<1,r=l^1;
	s1[k]=s1[l].y-s1[l].x<s1[r].y-s1[r].x?s1[l]:s1[r];
	s2[k]=s2[l].y+s2[l].x<s2[r].y+s2[r].x?s2[l]:s2[r];
}
void add(ll k,ll x)
{
	tg[k]+=x;
	s1[k].y+=x;
	s2[k].y+=x;
}
void dn(ll k)
{
	if (tg[k])
	{
		add(k<<1,tg[k]);add(k<<1|1,tg[k]);
		tg[k]=0;
	}
}
void build(ll k,ll l,ll r)
{
	if (l==r){s1[k]=s2[k]=(T){l,inf};return;}
	ll mid=l+r>>1;
	build(k<<1,l,mid);
	build(k<<1|1,mid+1,r);
	up(k);
}
void add(ll k,ll l,ll r,ll x,ll y,ll p)
{
	if (x<=l&&r<=y){add(k,p);return;}
	ll mid=l+r>>1;dn(k);
	if (x<=mid) add(k<<1,l,mid,x,y,p);
	if (y>mid) add(k<<1|1,mid+1,r,x,y,p);
	up(k);
}
ll Get1(ll k,ll l,ll r,ll x,ll y)
{
	if (x<=l&&r<=y) return s1[k].y-s1[k].x;
	ll mid=l+r>>1,ans=inf*10;dn(k);
	if (x<=mid) ans=min(ans,Get1(k<<1,l,mid,x,y));
	if (y>mid) ans=min(ans,Get1(k<<1|1,mid+1,r,x,y));
	return ans;
}
ll Get2(ll k,ll l,ll r,ll x,ll y)
{
	if (x<=l&&r<=y) return s2[k].y+s2[k].x;
	ll mid=l+r>>1,ans=inf*10;dn(k);
	if (x<=mid) ans=min(ans,Get2(k<<1,l,mid,x,y));
	if (y>mid) ans=min(ans,Get2(k<<1|1,mid+1,r,x,y));
	return ans;
}
ll Get(ll k,ll l,ll r)
{
	if (l==r)
	{
		return s1[k].y;
	}
	ll mid=l+r>>1;dn(k);
	return min(Get(k<<1|1,mid+1,r),Get(k<<1,l,mid));
}
int main()
{
	scanf("%lld%lld%lld%lld",&n,&m,&a[0],&y);
	build(1,1,n);
	add(1,1,n,y,y,-inf);
	Get(1,1,n);
	for (ll i=1;i<=m;i++)
	{
		scanf("%lld",&a[i]);
//a[i]=rand()%n+1;
//cout<<i<<endl;
		ll t1=Get1(1,1,n,1,a[i])+a[i],t2=Get2(1,1,n,a[i],n)-a[i];
		ll tmp=min(t1,t2);
		add(1,1,n,1,n,abs(a[i]-a[i-1]));
		ll t3=Get1(1,1,n,a[i-1],a[i-1])+a[i-1];
		if (tmp<t3)add(1,1,n,a[i-1],a[i-1],tmp-t3);
		//Get(1,1,n);
	}
	printf("%lld\n",Get(1,1,n));
}

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

const int MAX = 200010;

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

  vector<unsigned long long> ans(s.size(), 0);
  vector<unsigned long long> rec(26, 0);

  ans[0] = 1;
  rec[s[0] - 'a'] = 1;
  for (int i = 1; i < s.size(); ++i) {
    ans[i] = ans[i - 1];
    ans[i] += (i - rec[s[i] - 'a']);

    rec[s[i] - 'a']++;
  }
  cout << ans.back() << endl;
}


Measured memory_bytes: 2180