akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long lol;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
#define VL vector<lol>
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{INF};
    string s, t; cin >> s >> t;
    int lens = s.length(); int lent = t.length();
    int kai = lens - lent + 1;
    REP(i, kai)
    {
        lol n = lent;
        REP(j, lent)
        {
            if(s[i+j] == t[j]) {n--;}
            //cout << s[i+j] << " " << t[i+j] << endl;
        }
        //cout << n << endl;
        result = min(result, n);
    }

    cout << result << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int n;
    bool p[10001] = {0};
    
    for (int i = 4; i <= 10000; i += 2) p[i] = 1;
    p[0] = p[1] = 1;
    
    for (int i = 3; i * i <= 10000; i += 2){
        if (!p[i]){
            for (int j = i * i; j <= 10000; j += 2 * i) p[j] = 1;
        }
    }
    
    vector<int> v;
    for (int i = 2; i <= 10000; i++) if (!p[i]) v.push_back(i);
    
    while (scanf("%d", &n) && n){
        int num = 0;
        int s = 0;
        for (int head = 0, tail = 0; tail <= head; tail++){
            while (head < v.size() && s + v[head] <= n){
                s += v[head++];
            }
            if (s == n){
                num++;
            }
            s -= v[tail];
        }
        printf("%d\n", num);
    }
    
    return (0);
}

Measured memory_bytes: 1236
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

S = list(map(int, list(input())))
#print(S)
mod = 2019
mod_list = [0]
#last = 0
ten = 1

for num in S[::-1]:
    yo = (num * ten + mod_list[-1]) % mod
    #print(yo)
    mod_list.append(yo)
    #last = yo
    ten = (ten * 10) % mod

cnt = [0]*2019

for yo in mod_list:
    cnt[yo] += 1

ans = 0
for i in range(2019):
    ans += cnt[i] * (cnt[i]-1) // 2

print(ans)

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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define sz(v) ll(v.size())


void solve(ll N, ll K, vector<ll> a){
    ll dp[K+1];
    rep(i, K+1) {
        vector<ll> A;
        rep(j, N) {
            if (a[j] <= i) A.push_back(a[j]);
        }
        if (sz(A) == 0) dp[i] = 0;
        else {
            vector<ll> B;
            rep(j, sz(A)) {
                B.push_back(dp[i-A[j]]);
            }
            sort(B.begin(), B.end());
            ll m = 0;
            while(find(B.begin(), B.end(), m) != B.end()) m++;
            dp[i] = m;
        }
    }
    if (dp[K] == 0) cout << "Second" << endl;
    else cout << "First" << endl;
}

int main() {
  ll N;
    scanf("%lld",&N);
    ll K;
    scanf("%lld",&K);
    vector<ll> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
  solve(N, K, move(a));
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#define N 100
#define INF 100000000

int G[N+1][N+1], vis[N+1], n, size[N+1];

void dfs(int p, int t){
  int i;
  vis[p] = t;
  for(i=1;i<=size[p];i++) if(t + 1 < vis[G[p][i]]) dfs(G[p][i], t + 1);
}

main(){
  int i, j, u;
  scanf("%d", &n);
  for(i=1;i<=n;i++){
    vis[i] = INF;
    scanf("%d", &u);
    scanf("%d", &size[u]);
    for(j=1;j<=size[u];j++) scanf("%d", &G[u][j]);
  }
  dfs(1, 0);
  for(i=1;i<=n;i++) printf("%d %d\n", i, (vis[i] == INF) ? -1 : vis[i]);
  return 0;
}



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

int main()
{
	string s;
	string t;
	cin >> s;
	cin >> t;
	long long ans =0;
	for(int i=0; i<s.length();i++)
	{
		if(s[i] != t[i])
			ans ++;
	}
	cout << ans;
}

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

using namespace std;
typedef long long ll;

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

/*Solve*/

int main(){
    ll H,W;
    cin >> H >> W;
    ll h,w;
    cin >> h >> w;
    cout << (H-h)*(W-w);
    
}

Measured memory_bytes: 256
//
//  main.cpp
//  A - Harmony
//
//  Created by Hashizo on 2019/07/27.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>

using namespace std;

#undef INT_MAX
#undef INT_MIN

#define INT_MAX	2147483647
#define INT_MIN	(-INT_MAX  -1)

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

int main(int argc, const char * argv[]) {
	int a,b;
	cin >> a >> b;
	
	if(abs(a-b) % 2 != 0){
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}
	
	int c = abs(a-b) / 2;

	if(a > b) {
		c = a - c;
	}
	else {
		c = b - c;
	}
	
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		int a,b,W,H;
		Scanner br=new Scanner(System.in);
		while(true){
			H=br.nextInt();
			W=br.nextInt();
			if(H==0 && W==0){
				break;
				}else{
					for(a=1;a<=H;a++){
						for(b=1;b<=W;b++){
							System.out.print("#");
							}
						System.out.println();
						}
					System.out.println();
					}
			}
		}
	}

Measured memory_bytes: 34216
#include<bits/stdc++.h>
#define minf 0x80000000
using namespace std;
int n,k,r,s,p;
string t;

void add(vector<int>&v,int i){
	if(t.at(i)=='r')v.at(i)=p;
	else if(t.at(i)=='s')v.at(i)=r;
	else v.at(i)=s;
}

int main(){
	cin>>n>>k>>r>>s>>p;
	cin>>t;
	vector<int>v(t.size(),minf);
	for(int i=0;i<v.size();++i){
		if(v.at(i)==minf){
			add(v,i);
			for(int j=i+k;j<v.size();j+=k){
				if(t.at(j)==t.at(j-k)&&v.at(j-k)!=0)v.at(j)=0;
				else add(v,j);
			}
		}
	}
	cout<<accumulate(v.begin(),v.end(),0)<<"\n"s;
}

Measured memory_bytes: 896
#include <iostream>
#include <queue>
#include <tuple>
#include <vector>

using namespace std;
using ll = long long;

template <class T>
struct Edge {
    int to;
    T cost;
    Edge(int to, T cost) : to(to), cost(cost){};
};

template <class T = int>
class Graph {
public:
    explicit Graph(int N = 0) : size(N) { path.resize(size); }
    void span(int u, int v, T cost = 1) { path[u].push_back(Edge<T>(v, cost)); }
    vector<Edge<T>> operator[](int v) const { return path[v]; }

    int size;
    vector<vector<Edge<T>>> path;
};

const ll INF = 1LL << 50;

template <class T>
vector<T> dijkstra(const Graph<T>& graph, int s) {
    vector<T> dist(graph.size, INF);
    dist[s] = 0;

    priority_queue<pair<int, T>, vector<pair<int, T>>, greater<pair<int, T>>> que;
    que.push(make_pair(0, s));

    while (!que.empty()) {
        int v;
        T d;
        tie(d, v) = que.top();
        que.pop();
        if (d > dist[v]) continue;

        for (const auto& e : graph[v]) {
            if (dist[e.to] <= dist[v] + e.cost) continue;
            dist[e.to] = dist[v] + e.cost;
            que.push(make_pair(dist[e.to], e.to));
        }
    }
    return dist;
}

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

    Graph<ll> graph(N);
    for (int i = 0; i < N; ++i) {
        int v, k;
        cin >> v >> k;
        for (int j = 0; j < k; ++j) {
            int sv;
            ll c;
            cin >> sv >> c;
            graph.span(v, sv, c);
        }
    }

    auto dist = dijkstra<ll>(graph, 0);
    for (int v = 0; v < N; ++v) cout << v << " " << dist[v] << endl;
    return 0;
}



Measured memory_bytes: 11836
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            double max = 0, min = double.MaxValue;

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                double cur = double.Parse(input);

                max = Math.Max(max, cur);
                min = Math.Min(min, cur);
            }
            Console.WriteLine(max - min);
        }
    }
}

Measured memory_bytes: 9228
from itertools import permutations as per
n,m = map(int,input().split())
g = [[] for i in range(n)]
for i in range(m):
  a,b = map(int,input().split())
  a-=1;b-=1
  g[a].append(b)
  g[b].append(a)
c = 0
for i in per(range(2,n+1)):
  cur = 1
  f = 1
  for j in range(n-1):
    pre,cur = cur,i[j]
    if cur-1 not in g[pre-1]:
      f = 0
      break
  c += f
print(c)

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <iostream>
#define ll long long
using namespace std;
int main()
{
	int sum=0;
	long long a,b,ys;
	scanf("%lld %lld",&a,&b);
	for(int i=a;i<=b;i++)
	{
		ll a=i,hws=0;
		ys = i;
		while(a!=0)
		{
			hws=hws*10+a%10;
			a = a/10;
		}
		if(hws==ys)
		{
			sum++;
		}
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i;cin >> n;
  int a[n],s[200000] = {};
  for(i=0;i<n;i++){
    cin >> a[i];
    if(i-a[i]>=0) s[i-a[i]]++;
  }
  long long ans = 0;
  for(i=0;i<n;i++){
    if(a[i]+i<200000) ans += s[a[i]+i];
  }
  cout << ans << "\n";
}

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

#define FOR(i,a,b) for(i=(a);i<(b);i++)
#define RFOR(i,a,b) for(i=(b);i>=(a);i--)
#define REP(i,n) for(i=0;i<(n);i++)
#define RREP(i,n) for(i=(n)-1;i>=0;i--)
#define MREP(i,n,x) for(i=0;i<(n);i=x)
#define IL() while(1)
#define mLOOP(a,b) while((a)<(b)) 
#define MLOOP(a,b) while((a)>(b))
#define ELOOP(a,b) while((a)==(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)>(b)?(b):(a))
#define ABS(x) ((x)<0?-1*(x):(x))
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define int(x) scanf("%d",&x);
#define sint(x,y) scanf("%d %d",&x,&y);
#define lint(x,y) scanf("%d\n%d",&x,&y);
#define char(x) scanf("%c",&x);
#define double(x) scanf("%lf",&x);
#define string(x,n) scanf("%s",x);

ull gcd(ull a,ull b){
    if(b==0)return a;
    return gcd(b,a%b);
}

int main(){
    ull n,x,i,res;
    in("%lld %lld",&n,&x);
    res = 3*(n-gcd(n,x));
    out("%lld\n",res);
    return 0;
}

Measured memory_bytes: 128
#! /usr/bin/env python3

# from math import gcd
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
import copy

N, M = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(M)]

graph = [[] for i in range(N)]

for A, B in AB:
    graph[A-1] += [B]
    graph[B-1] += [A]

D = deque([0])
visited = [0] * N
visited[0] = 1

ret = [0 for i in range(N)]

while D:
    v = D.popleft()
    for i in graph[v]:
        i -= 1
        if visited[i]: continue
        visited[i] = 1
        ret[i] = v + 1
        D.append(i)

if any(ret[1:]):
    print("Yes")
    for i in ret[1:]:
        print(i)
else:
    print("No")

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

using namespace std;

int main()
{
    int k;
    cin >> k;
    int tmp = 7, cnt = 1;
    map<int, bool> dict;
    while(tmp%k != 0 && dict[tmp%k] == false){
        //prepare for next
        //cout << "tmp is : " << tmp << '\n';
        tmp %= k;
        dict[tmp] = true;
        tmp = 10*tmp + 7;
        cnt++;
    }
    if(tmp%k==0)
        cout << cnt << '\n';
    else
        cout << -1 << '\n';
    return 0;
}


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

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

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            int i = s.length() - 1;
            while (i > 0) {
                if (s.substring(0, i / 2).equals(s.substring(i / 2, i))) {
                    break;
                } else {
                    i--;
                }
            }
            out.println(i);
        }

    }
}



Measured memory_bytes: 21972
#[allow(dead_code)]
fn scan<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn scan_split<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|t| t.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn scan_split_with<T: std::str::FromStr>(ch: char) -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split(ch)
        .map(|t| t.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn scan_lines<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| scan::<T>()).collect()
}

#[allow(unused_macros)]
macro_rules! scan_as_tuple {
    ( $t:ty ) => {
        (scan::<$t>(),)
    };
    ( $( $t:ty ),* ) => {
        {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).ok();
            let v = s.trim().split_whitespace();
            let mut it = v;
            let ret = ( $(it.next().unwrap().parse::<$t>().ok().unwrap()),* );
            assert!(it.next() == None, "not all tokens consumed");
            ret
        }
    };
}

fn main() {
    let (a, op, b) = scan_as_tuple![i32, String, i32];
    println!("{}", match op.chars().nth(0).unwrap() {
        '+' => a + b,
        '-' => a - b,
        _ => 0
    });
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

vector<vector<int>> g;
vector<int> d;

void add_edge(int a, int b) {
  g[a].push_back(b);
  g[b].push_back(a);
}

void dfs(int cur, int prev) {
  //  cerr << cur << " " << prev << endl;
  // if (prev = -1) d[cur] = 0;
  for (auto&& c : g[cur]) {
    if (c != prev) {
      d[c] = d[cur] + 1;
      dfs(c, cur);
    }
  }
}
P get_d() {
  int tmp_d = 0;
  int tmp_num;
  P ret;
  for (int i = 0; i < d.size(); i++) {
    if (d[i] > tmp_d) {
      tmp_d = d[i];
      tmp_num = i;
    }
  }
  return make_pair(tmp_num, tmp_d);
}

int main() {
  int n;
  cin >> n;
  g.resize(n);
  d.resize(n, 0);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    add_edge(a, b);
  }
  // for (int i = 0; i < n; i++) {
  //   cerr << i << " ";
  //   for (auto&& w : g[i]) cerr << w << " ";
  //   cerr << endl;
  // }
  d[0] = 0;
  dfs(0, -1);
  // for (int i = 0; i < n; i++) cerr << i << ' ' << d[i] << endl;
  P x = get_d();
  d.assign(n, 0);
  dfs(x.first, -1);
  // for (int i = 0; i < n; i++) cerr << i << ' ' << d[i] << endl;
  P y = get_d();
  int diam = y.second;
  string ans;
  if (diam % 3 == 1)
    ans = "Second";
  else
    ans = "First";
  cout << ans << endl;
}

Measured memory_bytes: 21376
#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 rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int ans = 0;
    rep(i,n) {
        int a;
        cin >> a;
        while(a%2 == 0) {
            a /= 2;
            ans++;
        }
    }
    cout << ans << endl;
}


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

int main() {
  string s;
  cin >> s;
  string t = "AKIHABARA";
  bool ok = true;
  int j = 0;
  for (int i = 0; i < t.length(); ++i) {
    if (t[i] == s[j]) {
      ++j;
    } else if (t[i] == 'A') {
    } else {
      ok = false;
    }
  }
  cout << (ok && j == s.length() ? "YES" : "NO") << endl;
}

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

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    while(1) {
        ll b;
        cin >> b;
        if(!b) break;
        // n*(2*a+n-1) == 2*b
        ll a, m;
        for(ll n=1; n*n<=2*b; n++) {
            ll x = (2*b/n-n+1)/2;
            if(n*(2*x+n-1) == 2*b)
                a = x, m = n;
        }
        cout << a << ' ' << m << endl;
    }
}



Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double 
#define pb push_back
#define pii pair<ll,ll>
ll M = 1e9+7;

ll power(ll a,ll b,ll c=M){
    ll res=1;
    a%=c;
    while(b>0){
        if(b%2)res= (res*a)%c;
        a = (a*a)%c;
        b/=2;
    }
    return res;
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a[n+1],b[n+1];
    ll ans=0;
    for(int i=0;i<n-1;++i)
        cin>>b[i];
    ans += b[0]+b[n-2];
    for(int i=n-2;i>0;--i)
        ans+= min(b[i],b[i-1]);
    cout << ans << '\n';
    return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;

ll INF = LLONG_MAX;
ll MOD = 1e9 + 7;

using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        res %= MOD;
        a = a * a;
        a %= MOD;
        b >>= 1;
    }
    return res;
}

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

	int N; cin >> N;
	vll args (N);
	F0R(i, N) cin >> args[i];

	sort(args.begin(), args.end(), greater<int>());

	ll total = 0;
	for (int i = 0; i < N; ++i) {
		ll count = binpow(4, N-1) * 2;
		count += count * binpow(2, MOD - 2) % MOD * i % MOD;
		total += args[i] * count % MOD;
		total %= MOD;
	}

	cout << total << endl;
}

Measured memory_bytes: 1792
# from math import ceil
def ceil(x,y):
  return (x-1)//y+1
N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]
t, a = 1, 1
for T, A in TA:
  rate = max(ceil(t, T), ceil(a, A))
  t = T * rate
  a = A * rate
print(t + a)    
    


Measured memory_bytes: 3188
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void solve() throws Exception {
		int n = scanInt();
		int a[] = new int[n];
		int prev = 0;
		boolean inc = true;
		for (int i = 0; i < n; i++) {
			a[i] = scanInt();
			if (a[i] <= prev) {
				inc = false;
			}
			prev = a[i];
		}
		if (inc) {
			out.print(1);
			return;
		}
		int l = 2, r = n;
		int pos[] = new int[n];
		int val[] = new int[n];
		bs: while (l < r) {
			int mid = (l + r) >> 1;
			int cnt = 0;
			int clen = 0;
			for (int ca: a) {
				if (ca > clen) {
					clen = ca;
					continue;
				}
				while (cnt > 0 && pos[cnt - 1] >= ca) {
					--cnt;
				}
				int cpos = ca - 1;
				while (cnt > 0 && pos[cnt - 1] == cpos && val[cnt - 1] == mid - 1) {
					--cnt;
					--cpos;
				}
				if (cpos == -1) {
					l = mid + 1;
					continue bs;
				}
				if (cnt > 0 && pos[cnt - 1] == cpos) {
					++val[cnt - 1];
				} else {
					pos[cnt] = cpos;
					val[cnt] = 1;
					++cnt;
				}
				clen = ca;
			}
			r = mid;
		}
		out.print(l);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 50876
n=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
v=n//1000
mod=n%1000
if mod==0:
    ans=0
else:
    ans=(v+1)*1000-n
print(ans)

Measured memory_bytes: 9172
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

int main(){
    int H,W;
    cin >> H >> W;
    int N;
    cin >> N;
    int a[N+1];
    for(int i = 1; i < N+1; i++) cin >> a[i];
    int ans[H][W];
    int x = 0, y = 0,v = 1;
    for(int i = 1; i < N+1; i++){
        while(a[i] > 0){
            ans[x][y] = i;
            a[i]--;
            if(v == 1) y++;
            else y--;
            if(y >= W){
                y = W-1;
                x++;
                v = 0;
            }
            else if(y < 0){
                y = 0;
                x++;
                v = 1;
            }
        }
    }
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 384
using System;

namespace abc079_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            Console.WriteLine((s[0] == s[1] || s[2] == s[3]) && s[1] == s[2] ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13140
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


ll gcd(ll a, ll b){
  if(b == 0) return a;

  return gcd(b, a%b);
}

/*
n X
x1 ... xn

n 10^5
X 10^9
xi 10^9
 */
int n,X,x[100000];

int main(){
  cin>>n>>X;
  REP(i,n){
    cin>>x[i];
    x[i] -= X;
  }

  int ans=x[0];
  for(int i=1; i<n; i++){
    ans = abs(gcd(ans, x[i]));
  }

  cout<<abs(ans)<<endl;
  
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

int main(){

  int n,k;
  cin >> n >> k;
  int a[n];
  rep(i,n) cin >> a[i];
  sort(a,a+n);
  bool dp[k+1];
  rep(i,k+1){
    dp[i]=false;//-1未定 //false:手番が負け true:手番が勝ち
  }
  rep1(i,k){
    rep(j,n){
      if(i-a[j]<0) break;      
      dp[i]|=!dp[i-a[j]];
      if(dp[i]) break;
    }
  }
  if(dp[k]) cout << "First" << endl;
  else cout << "Second" << endl;

  
  return 0;

}


Measured memory_bytes: 384
# coding: utf-8
import os
import time
import re
import math

def main():
    s=input().replace("BC","D")
    max=0
    acount=0
    for a in s:
        if a=='D':
            max+=acount
        elif a=='A':
            acount+=1
        else:
            acount=0
    print(max)
start=time.time();
main()
#print(time.time()*1000-start*1000)

Measured memory_bytes: 3752
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

class SCC:

    def __init__(self, n):
        self.n = n
        self.graph = [[] for i in range(n)]
        self.graph_rev = [[] for i in range(n)]
        self.used = [0]*n

    def add_edge(self, fr, to):
        if fr == to:
            return
        self.graph[fr].append(to)
        self.graph_rev[to].append(fr)

    def dfs(self, node, graph):
        self.used[node] = 1
        for nex in graph[node]:
            if self.used[nex]:
                continue
            self.dfs(nex,graph)
        self.order.append(node)

    def first_dfs(self):
        self.used = [0]*self.n
        self.order = []
        for i in range(self.n):
            if self.used[i]:
                continue
            self.dfs(i,self.graph)
    
    def second_dfs(self):
        self.used = [0]*self.n
        self.ans = []
        for node in reversed(self.order):
            if self.used[node]:
                continue
            self.used[node] = 1
            self.order = []
            self.dfs(node, self.graph_rev)
            self.order.reverse()
            self.ans.append(self.order)

    def scc(self):
        self.first_dfs()
        self.second_dfs()
        return self.ans
        
def main():
    n,m = map(int,input().split())
    scc = SCC(n)
    for _ in range(m):
        a,b = map(int,input().split())
        scc.add_edge(a,b)

    ans = scc.scc()

    print(len(ans))
    for i in ans:
        print(len(i),*i)

if __name__ == "__main__":
    main()

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

int gcd(int a, int b, int& x, int& y) {
    int d = a;
    if(b == 0){
        x = 1;
        y = 0;
    }
    else{
        d = gcd(b, a % b, y, x);
        y -= (a / b) * x;
    }
    return(0);
}
 
int main(void) {
    int a, b, x, y;
     
    cin >> a >> b;
    gcd(a, b, x, y);
    cout << x << " " << y << endl;
    return(0);
}

Measured memory_bytes: 1168
#include <iostream>

using namespace std;

int main() {
	double v;

	while (cin >> v) {
		v = 4.9 * ((v / 9.8) * (v / 9.8));

		for (int i = 1; ; i++) {
			if (5 * i - 5 > v) {
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

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

using namespace std;

#define ll long long
#define MoD 1e9 + 7
#define clear(a) memset(a, 0, sizeof(a))
#define fo(i, a, b) for(int i = a; i < b; i++)
#define re(i, a, b) for(int i = b; i > a; i--)
#define pb(a) push_back(a)

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


int n;
string s;

void solve(){
	cin >> s;
	s+=".";
	int ans=0;
	vector<int> v;

	fo(i, 0, 4){
		if(s[i]=='R') ans++;
		else {v.pb(ans);ans=0;}
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	cout << v[0] << '\n';
}

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

	int t=1;
	for(int i=1; i<=t; ++i) {
		solve();
	}

}


Measured memory_bytes: 3648
n = gets.to_i
for i in 1..n do
  if i % 3 == 0 then
    print(" #{i}")
    next
  end
  
  x = i
  while x > 0 do
    if x % 10 == 3 then
      print(" #{i}")
      break
    end
    x /= 10
  end
end
puts



Measured memory_bytes: 6868
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strRC = br.readLine().split(" ");
		ArrayList<Integer> niKaiso = new ArrayList<Integer>();
		ArrayList<ArrayList<Integer>> itiKaiso = new ArrayList<ArrayList<Integer>>();
		for (int i = 0; i < Integer.parseInt(strRC[0]) + 1; i++) {
			if (i == Integer.parseInt(strRC[0])) {
				for (int j = 0; j < Integer.parseInt(strRC[1]) + 1; j++) {
					Integer sum = 0;
					for (int k = 0; k < Integer.parseInt(strRC[0]); k++) {
						sum += itiKaiso.get(k).get(j);
					}
					niKaiso.add(sum);
				}
				itiKaiso.add(niKaiso);
			} else {
				String line = br.readLine();
				String[] lineArrays = line.split(" ");
				for (int j = 0; j < Integer.parseInt(strRC[1]) + 1; j++) {
					if (j == Integer.parseInt(strRC[1])) {
						Integer sum = 0;
						for (int k = 0; k < niKaiso.size(); k++) {
							sum += niKaiso.get(k);
						}
						niKaiso.add(sum);
					} else {
						niKaiso.add(Integer.parseInt(lineArrays[j]));
					}
				}
				itiKaiso.add(niKaiso);
				niKaiso = new ArrayList<Integer>();
			}
		}
		for (int i = 0; i < Integer.parseInt(strRC[0]) + 1; i++) {
			for (int j = 0; j < Integer.parseInt(strRC[1]) + 1; j++) {
				if (j == Integer.parseInt(strRC[1])) {
					System.out.println(itiKaiso.get(i).get(j));
				} else {
					System.out.print(itiKaiso.get(i).get(j) + " ");
				}
			}
		}
	}
}

Measured memory_bytes: 27356
n = int(input())
a = list(map(int, input().split()))

# 奇数が偶数個あればYES

cnt = 0
for i in a:
    if i % 2 == 1:
        cnt += 1

if cnt % 2 == 0:
    print("YES")
else:
    print("NO")

        


Measured memory_bytes: 14108
N = int(input())
A = [int(x) for x in input().split()]
res = {}
count = 0
for i in range(N):
  L = i+1 + A[i]
  res[L] = res.get(L,0) + 1
for i in range(N):
  R = i+1 - A[i]
  count = res.get(R,0) + count
print(count)

Measured memory_bytes: 40464
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int N, A[110], sum[2];
signed main() {
    cin >> N;
    rep(i,0,N) cin >> A[i];
    sort(A, A+N, greater<int>());

    rep(i,0,N) {
        int mo = i % 2;
        sum[mo] += A[i];
    }

    cout << sum[0] - sum[1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string.h>
#include <cstring>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <set>
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <cassert>

using namespace std;
using ll = long long;

#define nl "\n"
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define trav(x) for(auto& i: x)

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

	string s;
	cin >> s;
	bool ans = true;
	for(int i = 0; i < s.size(); i++) {
		if((i + 1) & 1) {
			if(s[i] == 'L') {
				ans = false;
				break;
			}
		} else {
			if(s[i] == 'R') {
				ans = false;
				break;
			}
		}
	}
	if(ans) {
		cout << "Yes";
	} else {
		cout << "No";
	}
}

Measured memory_bytes: 256
// D - Sum of Divisors

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	int N;
	cin >> N;
	ll ans = 0;
	for (int i=1; i<=N; i++) {
		for (int j=i; j<=N; j+=i) {
			ans += j;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<string>
#include<iostream>
#include<sstream>

using namespace std;

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

vector<int> hoge;

void saiki(int n,int maxi){
	
	if(n<0)return;
	if(n==0){
		rep(i,hoge.size()-1){
			printf("%d ",hoge[i]);
		}printf("%d\n",hoge[hoge.size()-1]);
		return;
	}
	
	for(int i=maxi; i>=1; i--){
		if(i>n)continue;
		hoge.push_back(i);
		saiki(n-i, i);
		hoge.pop_back();
	}
}

int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		
		saiki(n,n);
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 1e5 + 7;
const ll INF = 1e18;
ll dp[MAXN];
int main()
{
    int n, W; scanf("%d%d", &n, &W);
    for (int i = 1; i <= 100000; i++) dp[i] = INF;
    int ans = 0;
    for (int i = 1, w, v; i <= n; i++)
    {
        scanf("%d%d", &w, &v);
        for (int j = 100000; j >= v; --j) 
        {
            dp[j] = min(dp[j], dp[j - v] + w);
            if (dp[j] <= W) ans = max(ans, j);
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
int cidx;
void bfs(int idx,VVI& edge, vector<PII>&de,vector<bool>&used,VLL & c, VLL &ans){

  deque<int> que;
  que.push_back(idx);
  used[idx] = true;
  while(que.empty() == false){
    idx = que.front();
    que.pop_front();
    ans[idx] = c[cidx];
    cidx++;
    //cout << "idx"<< idx << ':' << ans[idx]<<endl;
    rep(i,edge[idx].size()){
      int e = edge[idx][i];
      if(used[e] == false){
        que.push_back(e);
        used[e] = true;
      }
    }
  }

}

ll efs(int idx, VVI&edge,vector<bool>&used, VLL &ans){
  if(used[idx]) return 0;
  used[idx] = true;
  ll res = 0;
  rep(x,edge[idx].size()){
    int i = edge[idx][x];
    if(used[i] == false)res += min(ans[i],ans[idx]) + efs(i,edge,used,ans);
  }
  return res;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    VVI edge(n);

    rep(i,n-1){
      int a,b;
      cin >> a >> b;
      a--,b--;
      edge[a].push_back(b);
      edge[b].push_back(a);
    }
    VLL c(n);

    rep(i,n) cin >> c[i];
    sort(all(c),greater<ll>());
    vector<PII> de(n);
    rep(i,n){
      de[i] = make_pair( edge[i].size() , i );
    }

    sort(all(de));
    reverse(all(de));

    vector<bool> used(n,false);
    vector<ll> ans(n);
    rep(i,n){
      int idx = de[i].second;
      //cout << "idx"<< idx << endl;
      if(used[idx] == false){
        bfs(idx,edge,de,used,c,ans);
      }
    }
    rep(i,n) used[i] = false;
    ll x = efs(0,edge,used,ans);
    cout << x << endl;
    rep(i,n) cout << ans[i] << ' ';
    cout << endl;
    return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n,h,a,sum=0;
	cin>>h>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		sum+=a;
		if(sum>=h)
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

int main() {
    int n;
    cin >> n;

    ll dp[101][64] = {};//dp[k][xyz] k文字のxyzで終わる条件を満たす文字列の数
    for (int i = 0; i < 64; i++) {
        dp[3][i] = 1;
    }
    int u[3];
    dp[3][u[0] = 0 * 16 + 1 * 4 + 2] = 0;
    dp[3][u[1] = 1 * 16 + 0 * 4 + 2] = 0;
    dp[3][u[2] = 0 * 16 + 2 * 4 + 1] = 0;

    for (int k = 4; k <= n; k++) {
        for (int i = 0; i < 64; i++) {
            for (int h = 0; h < 4; h++) {
                int v = h * 64 + i;
                int w0 = v & ~(3 * 16);
                int w1 = v & ~(3 * 4);
                if (w0 == 0 * 64 + 1 * 4 + 2) continue;
                if (w1 == 0 * 64 + 1 * 16 + 2) continue;
                dp[k][i] += dp[k - 1][v / 4];
            }
            dp[k][i] %= P;
        }
        dp[k][u[0]] = 0;
        dp[k][u[1]] = 0;
        dp[k][u[2]] = 0;
    }

    ll r = 0;
    for (int i = 0; i < 64; i++) {
        r += dp[n][i];
    }
    cout << r % P << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mx = 1e3+5;
const int m4 = 1e4+5;

struct node{
    int w, s, v;
    bool operator < (const node &ot){
        if(w+s != ot.w+ot.s)
            return w+s < ot.w+ot.s;
        if(w != ot.w) return w < ot.w;
        if(s != ot.s) return s < ot.s;
        return v < ot.v;
    }
}a[mx]; int n;
ll dp[mx][m4];

ll fun(int idx, int w){
    if(w >= m4) return 0;
    if(idx == n) return 0;

    ll &ans = dp[idx][w];
    if(ans != -1) return ans;

    ans = 0;
    if(w <= a[idx].s)
        ans = a[idx].v+fun(idx+1, w+a[idx].w);
    ans = max(ans, fun(idx+1, w));
    return ans;
}

int main(){

    cin.tie( nullptr );
    ios_base::sync_with_stdio(0);

    cin >> n;
    for(int i=0; i<n; i++)
        cin >> a[i].w >> a[i].s >> a[i].v;

    sort(a, a + n);
    memset(dp, -1, sizeof dp);
    cout << fun(0, 0) << "\n";

    return 0;
}


Measured memory_bytes: 82288
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        while (sc.hasNext()){
            int n = sc.nextInt();
            StringBuffer sb = new StringBuffer(sc.next());
            int k = sc.nextInt();

            char ch = sb.charAt(k-1);

            for (int i = 0; i < sb.length(); i++) {
                if (sb.charAt(i) != ch)
                    sb.setCharAt(i, '*');
            }

            System.out.println(sb);

        }
    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
string s,t;
int min(int a,int b)
{
	return a>=b?b:a;
}
int main()
{
	cin>>s;
	cin>>t;
	int end1=t.size();
	for(int i=0;i<=s.size()-t.size();i++)
	{
		int ans=0;
		for(int j=0;j<t.size();j++)
		{
			if(t[j]==s[i+j])
			{
				ans++;
			}
		}
		end1=min(end1,t.size()-ans);
	}
	cout<<end1;
}

Measured memory_bytes: 3636
x, n = (int(i) for i in input().split())
p = [int(i) for i in input().split()]

if n == 0:
    print(x)
else:
    if x not in p:
        print(x)
    else:
        left = x-1
        right = x+1
        while True:
            if not left in p:
                print(left)
                exit()
            if not right in p:
                print(right)
                exit()
            left -= 1
            right += 1

Measured memory_bytes: 9204
fun main(args: Array<String>){
    val a = readLine()!!.toCharArray().map { it.toString() }.map { it.toInt() }
    for(i in 0 until (1 shl 3)){
        val op = Array(3){""}
        var ans = a[0]
        for (j in 0 until 3){
            if(i.shr(j).and(1) == 1){
                op[j] = "+"
                ans += a[j+1]
            } else {
                op[j] = "-"
                ans -= a[j+1]
            }
        }
        if(ans == 7) {
            println("${a[0]}${op[0]}${a[1]}${op[1]}${a[2]}${op[2]}${a[3]}=7")
            break
        }
    }
}

Measured memory_bytes: 33736
using System;
using System.Collections.Generic;
using System.Linq;

public static partial class Program
{
    public static void Main()
    {
        var nk = CRL().ArrayInts();

        if (nk[1] == 1)
        {
            CWL(0);
            return;
        }

        var most = nk[0] - nk[1] + 1;
        CWL(most - 1);
    }
}

public static partial class Program
{
    //テンプレここから
    public static int Sigma(int n, int next = 1, int val = 0) => next > n ? val : Sigma(n, next + 1, val + next);
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    public static int GCD(int a, int b) => b == 0 ? a : GCD(b, a % b);
    public static long LCM(long a, long b) => a * b / GCD(a, b);
    public static int LCM(int a, int b) => a * b / GCD(a, b);
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static int ToInt(this double d) => (int) d;
    public static long ToLong(this double d) => (long) d;
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static readonly int[] Dx = {0, -1, 0, 1};
    public static readonly int[] Dy = {-1, 0, 1, 0};
    public const int Mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToLong();
    public static int ToInt(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();
    public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);
    public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);

    public static string JoinToStr(this IEnumerable<int> array, string sep = "")
        => array.Select(x => x.ToString()).Join(sep);

    //テンプレここまで
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include<chrono>
#include<random>
using namespace std;
using namespace chrono;
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef vector<string> vs;
template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
mt19937 rnd(time(0));

vector<vi> grid;
vector<vl> dp;

const long long m = 1000000007;

int main() {

    int h, w;

    cin >> h >> w;

    grid.assign(h+1, vi(w+1));
    dp.assign(h+1, vl(w+1));

    char x;

    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cin >> x;
            if (x == '.') {
                grid[i][j] = 1;
            } else {
                grid[i][j] = 0;
            }
        }
    }

    dp[1][1] = 1;

    for (int k = 1; k < w+1; k++) {
        int col = k;
        int row = 1;

        while (row < h+1 && col >= 1) {
            
            if (grid[row][col] != 0){
                if (grid[row-1][col] == 1 && grid[row][col-1] == 1) {
                    dp[row][col] = (dp[row-1][col] + dp[row][col-1]) % m;
                } else if (grid[row-1][col] == 1) {
                    dp[row][col] = dp[row-1][col];
                } else if (grid[row][col-1] == 1) {
                    dp[row][col] = dp[row][col-1];
                }
            }

            

            row++;
            col--;
        }
    }

    for (int l = 2; l < h+1; l++) {
        int col = w;
        int row = l;

        while (row < h+1 && col >= 1) {

            if (grid[row][col] != 0){
                if (grid[row-1][col] == 1 && grid[row][col-1] == 1) {
                    dp[row][col] = (dp[row-1][col] + dp[row][col-1]) % m;
                } else if (grid[row-1][col] == 1) {
                    dp[row][col] = dp[row-1][col];
                } else if (grid[row][col-1] == 1) {
                    dp[row][col] = dp[row][col-1];
                }
            }         
            row++;
            col--;
        }
    }

    cout << dp[h][w] % m;

    return 0;
}


Measured memory_bytes: 12032
#include <iostream>

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    int c = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == t[i]) {
            c++;
        }
    }
    cout << c << "\n";
}

Measured memory_bytes: 256