akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{   
    static IEnumerable<int[]> Pattern(int index, int n, int[] array)
    {
        if(index == n)
            yield return array;
        else
        {
            foreach(int i in Enumerable.Range(0, 4))
            {
                array[index] = i;
                foreach(var ret in Pattern(index + 1, n, array))
                    yield return ret;
            }
        }
    }
    public void Slove()
    {
        var inputs = Console.ReadLine().Split();
        int n = int.Parse(inputs[0]);
        int[] target = 
            inputs.Skip(1)
            .Select(int.Parse)
            .OrderBy(x => x)
            .ToArray();
        int[] bsum = new int[2 << n];
        int[] bamboo =
            Enumerable.Range(0, n)
            .Select(x => int.Parse(Console.ReadLine()))
            .ToArray();
        foreach(int i in Enumerable.Range(0, bsum.Length))
        {
            foreach(int j in Enumerable.Range(0, n))
            {
                if((i >> j & 1) == 1)
                    bsum[i] += bamboo[j];
            }
        }
      //System.Console.WriteLine(string.Join(",", bsum));
        long min =
            Pattern(0, n, new int[n])
            .Where(x => Enumerable.Range(0, 3).All(y => x.Contains(y)))
            .Select(x => 
            {
                //System.Console.WriteLine(string.Join(",", x));
                return Enumerable.Range(0, 3).Select(i =>
                {
                    int[] a = 
                        x.Select((Value, Index) => new {Value, Index}).Where(y => y.Value == i).Select(y => bamboo[y.Index]).ToArray();
                    return (a.Length - 1) * 10 + Math.Abs(a.Sum() - target[i]);
                })
                .Sum();
            })
            .Min();
        System.Console.WriteLine(min);
    }
    
    static void Main(string[] args)
    {
        new Program().Slove();
    }
}


Measured memory_bytes: 17856
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    long long n, k, m, sum, ac = 0, pe = 0;
    cin >> n >> m;
    map<long, long> cnt;
    map<long, long> pba;
    vector<long> ps(m);
    vector<string> ss(m);
    for (int i = 0; i < m; i++) {
        cin >> ps[i];
        cin >> ss[i];
        if (ss[i] == "AC") {
            if (cnt[ps[i]] < 1) {
                ac++;
                pe += pba[ps[i]];
            }
            cnt[ps[i]]++;
        }
        if (ss[i] == "WA" && cnt[ps[i]] < 1) {
            pba[ps[i]]++;
        }
    }
    cout << ac << " " << pe << endl;
}

Measured memory_bytes: 19072
#include <iostream>
#include<math.h>
using namespace std;

int main()
{
   int a=0,b=0,c=0,i=0,kazu=0;

        cin >> a;
        cin >> b;
        cin >> c;
        for(i=a;i<=b;i++){
            if(c%i == 0){
                kazu++;
            }

        }
   cout << kazu << endl;

}

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

using namespace std;
using ll = long long;
int main() {
    int n;
    cin>>n;
    vector<int> v(n);
    int ans=0;
    for(int i = 0;i < n;++i) {
        cin>>v[i];
    }
    vector<int> c(n);
    for(int i = 0;i < n;++i) {
        cin>>c[i];
    }
    for(int i = 0;i < n;++i) {
        if(c[i]<v[i])ans+=v[i]-c[i];
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
	long long m;
	cin >> m;
	long long csum, dsum, res;
	long long dcnt;
	long long cnt_tmp;

	vector<long long> d(m);
	vector<long long> c(m);

	for(int i=0; i<m; i++){
		cin >> d[i] >> c[i];
	}

	res = 0;

	csum = 0;
	for(int i=0; i<m; i++){
		csum += c[i];
	}
	res += csum - 1;

	dsum = 0;
	dcnt = 0;
	for(int i=0; i<m; i++){
		dsum += d[i]*c[i];
	}
	dcnt = dsum/9;
	if(dsum%9==0){
		dcnt--;
	}
	res += dcnt;

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

int main()
{
  int n, m;
  int day = 0;
  cin >> n >> m;

  for (int i = 0; i < m; i++)
  {
    int a;
    cin >> a;
    day += a;
  }

  if (day > n)
  {
    cout << -1;
  }
  else
  {
    cout << n - day;
  }

  return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;;
typedef long long ll;
int main()
{
	int m,n,s;
	cin>>m>>n>>s;
	vector<string> vs;
	for(int i=0;i<m;i++){string s ; cin>>s ; vs.push_back(s);
	}
	ll ans = 1e12;
	for(int mask=0;mask<1<<(m-1);mask++)
	{
		vector<ll> bounds;bounds.push_back(0);
		ll cur = 0;
		for(int i=0;i<m-1;i++)
		{
			if(mask&(1<<i))
				bounds.push_back(i+1) , cur++;
		}
		bounds.push_back(m);
		ll k = bounds.size()-1;
		vector<ll> cnt(k);
		for(int j=0;j<n;j++)
		{
			ll pos = 0;
			vector<ll> add(k);
			for(int i=0;i<m;i++)
			{
				if(i == bounds[pos+1]) pos++;
				add[pos]+=vs[i][j]-'0';
			}
//			cout<<mask<<","<<j<<"\n\n";
			for(int i=0;i<k;i++)
				cnt[i]+=add[i];
//			cout<<mask<<","<<j<<"\n\n";
			bool isok = true;
			for(int i=0;i<k;i++)
				 if(cnt[i]>s)
				 	isok = false;
//			cout<<mask<<","<<j<<"\n\n";
			if(isok == true)
				continue;
//			cout<<mask<<","<<j<<"\n\n";
			cur++;
			for(int i=0;i<k;i++)
				cnt[i] = add[i];
//			cout<<mask<<","<<j<<"\n\n";
			isok = true;
//			cout<<mask<<","<<j<<"\n\n";
			for(int i=0;i<k;i++)
				if(cnt[i]>s)
					isok = false;
//			cout<<mask<<","<<j<<"\n\n";
			if(!isok)
				cur = 123456789101112;
//			cout<<mask<<","<<j<<"\n\n";
		}
		ans = min(ans,cur);
	}
	cout<<ans<<endl;
} 

Measured memory_bytes: 384
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

a, b, h, m = map(int, input().split())

import math

_long = 2 * math.pi * (((60 * h) + m) / 720)
short = 2 * math.pi * (m/60)
diff = abs(_long - short)
if diff > math.pi:
    diff = 2 * math.pi - diff
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(diff)))


Measured memory_bytes: 62500
N = int(input())
dp = [100000 for i in range(N+1)]
dp[:2] = [0, 1]
f = lambda n: [n**i for i in range(10) if n**i <= 100000]
c = f(6)+f(9)
for i in range(100000):
    for x in c:
        if i+x <= N:
            dp[i+x] = min(dp[i+x], dp[i]+1)
else:
    print(dp[N])


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

#define M 1000010
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  return -1;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + key % ( M - 1 ); }

int find(char str[]){
  int key = getKey( str );
  for( int i = 0;; i++ ){
    int tmp = ( h1( key ) + i * h2( key ) ) % M;
    if( strcmp( H[tmp], "\0" ) == 0 ) return false;
    
    if( strcmp( H[tmp], str ) == 0 ){
      return true;
    }
  }
  return false;
}

int insert(char str[]){
  int key = getKey( str );
  for( int i = 0;; i++ ){
    int tmp = ( h1( key ) + i * h2( key ) ) % M;
    if( strcmp( H[tmp], "\0" ) == 0 ){
      strcpy( H[tmp], str );
      return true;
    }
    if( strcmp( H[tmp], str ) == 0 ) return false;
  }
  return false;
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
  scanf("%d", &n);
    
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
	
    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }

  return 0;
}



Measured memory_bytes: 16832
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long 
using namespace std;
signed main(void)
{
     int n,k;
     cin>>n>>k;
     int arr[n+1];
     for(int  i = 1;i<=n;i++)
      cin>>arr[i];
      
     int dp[n+1][k+1];
     
     for(int  j = 0;j<=k;j++)
     {
          dp[1][j] = (j>arr[1])?0:1;
     }
     
     for(int i = 2;i<=n;i++)
     {
          for(int j = 0;j<=k;j++)
          {
              dp[i][j] = (mod+((j-1>=0)?dp[i][j-1]:0)+dp[i-1][j]-((j-1-arr[i]>=0)?dp[i-1][j-1-arr[i]]:0))%mod;
          }
     }
     
    cout<<dp[n][k]<<endl; 
}


























Measured memory_bytes: 78336
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

//vector??????????§£???
int main(){
	while (1){
		int n;
		cin >> n;
		//???????????¶
		if (n == 0) break;
		//??\???
		vector<int> num;
		for (int i = 0; i < n; i++){
			int tmp;
			cin >> tmp;
			num.push_back(tmp);
		}
		//????¨????????°????????????§???????¨????
		int max = -1;
		int min = 99999;
		int sum = 0;
		for (int i = 0; i < num.size(); i++){
			if (num[i] >= max) max = num[i];
			if (num[i] <= min) min = num[i];
			sum += num[i];
		}
		//??????????¨????
		int avg = floor((sum - max - min) / (n - 2));
		cout << avg << endl;
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("path.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s, t;
    cin >> s >> t;
    cout << t + s;

    return 0;
}


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

int rotire[300010];

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

    for (int i = 1; i <= s.size(); i++)
        rotire[i] = (s[i - 1] == 'W') + rotire[i - 1];

    int best = 1e9;

    for (int i = 1; i <= s.size(); i++)
        best = min(best, (int)(rotire[i - 1] + s.size() - i - rotire[s.size()] + rotire[i]));

    cout << best << '\n';

    return 0;
}


Measured memory_bytes: 1796
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	double a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	string ans;
	if(w>=v){
		cout<<"NO";
		return 0;
	}
	double t1;
	t1 = (abs(b-a))/(v-w);
	if(t1>t) cout<<"NO";
	else cout<<"YES";
	
	return 0;
}

Measured memory_bytes: 3828
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

int n, table[30005][105]{};
vector<int> t, v;

int main() {
    cin >> n;
    t.resize(n + 2);
    v.resize(n + 2);
    t[0] = 0;
    v[0] = 0;
    t[n + 1] = 0;
    v[n + 1] = 0;
    for (int i = 1; i <= n; i++) cin >> t[i];
    for (int i = 1; i <= n; i++) cin >> v[i];
    int tsum = 0;
    for (int i = 0; i <= n + 1; i++) {
        for (int j = 0; j <= 102 - v[i]; j++) {
            table[tsum + t[i] + j][v[i] + j] = 1;
        }
        for (int j = 1; j <= 102 - v[i]; j++) {
            if (tsum - j < 0) break;
            table[tsum - j][v[i] + j] = -1;
        }
        for (int j = 0; j < t[i]; j++) {
            table[tsum + j][v[i]] = 2;
          	table[tsum + j][104] = v[i];
        }
        tsum += t[i];
    }
    table[tsum][0] = -1;
    int cv = 0;
    double ans = 0;
    for (int i = 0; i < tsum; i++) {
        if (table[i][cv] == 1) {
            if (table[i + 1][cv] == -1 || table[i + 1][cv] == 2) {
                ans += double(cv + 0.25);
            } else {
                ans += double(cv * 2 + 1) / 2;
                cv++;
            }
        } else if (table[i][cv] == -1) {
            ans += double(cv * 2 - 1) / 2;
            cv--;
        } else {
            ans += double(cv);
        }
    }
    
    printf("%.5lf",ans);
    return 0;
}

Measured memory_bytes: 10496
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[] S = sc.next().toCharArray();
    int[] a = new int[26];
    for (char c : S) {
      a[c-'a'] = 1;
    }
    
    int count = 0;
    int minIndex = Integer.MAX_VALUE;
    for (int i = 0; i < a.length; i++) {
      if (a[i] == 1) {
        count++;
      } else {
        minIndex = Math.min(minIndex, i);
      }
    }
    
    System.out.println(count == 26 ? "None" : (char) ('a' + minIndex));
  }
}

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

int main(){
  int a, b, c, k, n, d;
  a = -1;
  b = -1;
  c = -1;
  cin >> k >> n;
  for(int i = 0; i < k + 1; i++){
    for(int j = 0; j < k + 1 - i; j++){
      d = (k - i - j) * 10000 + j * 5000 + i * 1000;
      if(d == n){
        a = k - i - j;
        b = j;
        c = i;
      }
    }
  }
  cout << a << ' ' << b << ' ' << c << ' ' << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	int n; cin >> n;
	if(2800 <= n)cout << "AGC" << endl;
	else if(1200 <= n) cout << "ARC" << endl;
	else cout << "ABC" << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main {

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

    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] k = new int[m];
    int[][] s = new int[m][];
    int[] p = new int[m];

    for (int i = 0; i < m; i++) {
      k[i] = sc.nextInt();
      s[i] = new int[k[i]];
      for (int j = 0; j < k[i]; j++) {
        s[i][j] = sc.nextInt();
      }
    }

    for (int i = 0; i < m; i++) {
      p[i] = sc.nextInt();
    }

    int ans = 0;

    for (int i = 0; i < Math.pow(2,n); i++) {
      boolean b = true;
      for (int j = 0; j < m; j++) {
        int count = 0;
        for (int v = 0; v < k[j]; v++) {
          if ((1&i >> s[j][v]-1) == 1) count++;
        }
        if (count % 2 != p[j]) b = false;
      }
      if (b) ans++;
    }

    System.out.println(ans);

  }

}


Measured memory_bytes: 21972
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
// dfmt on

void main()
{
    long N = lread();
    long[string] D;
    foreach (i; 0 .. N)
    {
        char[] S = sread().dup;
        sort(cast(ubyte[]) S);
        D[cast(string) S] = D.get(cast(string) S, 0) + 1;
    }
    D.values.map!((x) => combination(x, 2)).sum().writeln();
}

/// Number of k-combinations
T combination(T = long)(T n, T k)
{
    assert(0 <= k);
    assert(0 <= n);
    if (n < k)
        return 0;
    k = min(n - k, k);
    if (k == 0)
        return 1;
    if (k == 1)
        return n;
    return memoize!combination(n - 1, k - 1) + memoize!combination(n - 1, k);
}


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

void solve(void)
{
  //CODE
  ll a;
  cin>>a;
  cout<<pow(a,2)+pow(a,3)+a;
  
}


int main()
{

  //TESTCASE
  long long t;
  //cin>>t;
  //while(t--)
    solve();

  return 0;
}


Measured memory_bytes: 4188
module Main where
 
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Text.Printf

main :: IO ()
main = do
    -- _ <- getLine
    ns <- fmap (fmap (read :: String -> Int) . words) . lines <$> getContents
    -- ns <- fmap (fmap (read :: String -> Int) . words) . lines <$> (return "8 6\n50000000 30000000\n1999999999 2000000000\n")
    forM_ [0..length ns-1] $ \i -> do
      let (x,y) = ((ns!!i)!!0, (ns!!i)!!1)
      printf "%d %d\n" (gcd x y) (lcm x y)

Measured memory_bytes: 4136
from collections import deque

N = int(input())
S = input()
que = deque(S)
l = r = 0

for s in S:
    if s == '(':
        l += 1
    else:
        r += 1
    if l < r:
        que.appendleft('(')
        l += 1
else:
    ans = "".join(que)
    if r < l:
        ans = ans + ")" * (l - r)
print(ans)

Measured memory_bytes: 9348
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    if(N <= 999) {
        output("ABC");
    }
    else output("ABD");
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        int ans = 0;
        int count = 0;
        for (Character c : s.toCharArray()) {
            if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
                count++;
            } else {
                if (ans < count) {
                    ans = count;
                    count = 0;
                }
            }
        }

        System.out.print(Math.max(ans, count));
    }

}

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

int main()
{
	int N, K;
	cin >> N >> K;
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		int h;
		cin >> h;
		cnt += h >= K;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll MOD = 1e9+7;
const ll INF = 1e9+10;



ll ans;

struct query{
	int a, b, c, d;
	query(int aa, int bb, int cc, int dd){
		a = aa;
		b = bb;
		c = cc;
		d = dd;
	}
};

vector<query> arr;

void f(vi v, int pos, int n, int m){
	if(pos == n){
		ll aux = 0;
		FOR(i, arr.size()){
			int a = arr[i].a;
			int b = arr[i].b;
			int c = arr[i].c;
			int d = arr[i].d;
			if(v[b] - v[a] == c){
				aux += d;
			}
		}
		ans = max(aux, ans);
		return;
	}
	int mini = 1;
	if(pos > 0) mini = v[pos-1];
	for(int i = mini; i <= m; i++){
		v[pos] = i;
		f(v, pos+1, n, m);
	}
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
 
	int n, m, q; cin >> n >> m >> q;
	vi v(n, INF);
	FOR(i, q){
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		arr.PB(query(a-1,b-1,c,d));
	}

	f(v, 0, n, m);

	cout << ans << '\n';


	return 0;
}

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

int main() {
  // 入力
  int N;
  cin >> N;

  if (N / 10 == 9 || N % 10 == 9) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    string s;
    cin >> s;

    bool ok = true;

    if(s[0] != 'A'){
        cout << "WA" << endl;
        return 0;
    }

    int c_cnt = 0;
    for(int i = 2; i < (int)s.size()-1; i++){
        if(s[i] == 'C') c_cnt++;
    }
    if(c_cnt != 1){
        cout << "WA" << endl;
        return 0;
    }

    for(int i = 1; i < (int)s.size(); i++){
        if(isupper(s[i])){
            if(s[i] != 'C') ok = false;
        }
    }
    if(ok) cout << "AC" << endl;
    else cout << "WA" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<string>
#include<sstream>
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cstdio>
//#include<bits/stdc++.h>
using namespace std;

vector<string> code;
map<string, int> val;
map<char, int> a;

int get_val(string str) {
	if(str.find("[") == string::npos) {
		stringstream ss(str);
		int v; ss >> v;
		return v;
	}
	if(count(str.begin(), str.end(), '[') == 1) {
		if(!val.count(str)) return -1;
		return val[str];
	}
	string cur = str.substr(str.find("[") + 1);
	int v = get_val(cur);
	stringstream ss;
	ss << v;
	string s; ss >> s;
	if(!val.count(str.substr(0, 2) + s)) return -1;
	return val[str.substr(0, 2) + s];
}
void add_arr(const string str) {
	stringstream ss(str.substr(2));
	int v; ss >> v;
	a[str[0]] = v;
}
int main() {
	ios::sync_with_stdio(false);
	string line, l, r, name;
	int rval, lval, bug;
	while(code.clear(), val.clear(), a.clear(), bug = -1, true) {
		cin >> line;
		if(line == ".") break;
		while(true) {
			code.push_back(line);
			cin >> line;
			if(line == ".") break;
		}
		for(size_t i = 0; i != code.size(); i++) {
			if(code[i].find("=") == string::npos) 
				add_arr(code[i]);
			else {
				l = code[i].substr(0, code[i].find("="));
				r = code[i].substr(code[i].find("=") + 1);
				rval = get_val(r.substr(0, r.find("]")));
				lval = get_val(l.substr(l.find("[") + 1, l.find("]") - l.find("[") - 1));
				if(rval == -1 || lval == -1 || !a[code[i][0]] || lval >= a[code[i][0]]) {bug = i; break;}
				stringstream ss;
				ss << lval;
				string s; ss >> s;
				name = code[i].substr(0, 2) + s;
				val[name] = rval;
			}
		}
		cout << bug + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3336
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)
        {
            var k = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            var ans = "";
            if (s.Length <= k) ans = s;
            else
            {
                Console.WriteLine(s.Substring(0, k) + "...");
            }
            /*var n = Console.ReadLine();
            var hon = new char[] { '2','4', '5', '7','9' };
            var pon= new char[] { '0', '1', '6', '8' };
            var bon= new char[] { '3' };
            for (int i = 0; i < hon.Length; i++)
            {
                if (n[0] == hon[i]) ans = "hon";
            }
            for (int i = 0; i < pon.Length; i++)
            {
                if (n[0] == pon[i]) ans = "pon";
            }
            if (n[0] == bon[0]) ans = "bon";*/
            Console.WriteLine(ans);




        }

        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }
        
        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }

        public static long Gcd(long a, long b)
        {
            long x = Math.Max(a, b);
            long y = Math.Min(a, b);
            if (x % y == 0) return y;
            else return Gcd(y, x % y);
        }
    }
}


Measured memory_bytes: 27404
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long int llint;

int main(){
	int N;
	cin >> N;
	int A,B,C,D;
	A=(N/1000)%10;
	B=(N/100)%10;
	C=(N/10)%10;
	D=N%10;

	     if(A+B+C+D==7)cout<<A<<"+"<<B<<"+"<<C<<"+"<<D<<"=7"<<endl;
	else if(A+B+C-D==7)cout<<A<<"+"<<B<<"+"<<C<<"-"<<D<<"=7"<<endl;
	else if(A+B-C+D==7)cout<<A<<"+"<<B<<"-"<<C<<"+"<<D<<"=7"<<endl;
	else if(A+B-C-D==7)cout<<A<<"+"<<B<<"-"<<C<<"-"<<D<<"=7"<<endl;
	else if(A-B+C+D==7)cout<<A<<"-"<<B<<"+"<<C<<"+"<<D<<"=7"<<endl;
	else if(A-B+C-D==7)cout<<A<<"-"<<B<<"+"<<C<<"-"<<D<<"=7"<<endl;
	else if(A-B-C+D==7)cout<<A<<"-"<<B<<"-"<<C<<"+"<<D<<"=7"<<endl;
	else if(A-B-C-D==7)cout<<A<<"-"<<B<<"-"<<C<<"-"<<D<<"=7"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;
const ll NCK_MAX = 510000;
ll extgcd(ll a, ll b, ll& x, ll& y) {
  if (b == 0) {
    x = 1, y = 0; return a;
  }
  ll q = a/b, g = extgcd(b, a - q*b, x, y);
  ll z = x - q * y;
  x = y;
  y = z;
  return g;
}
 
ll invmod (ll a, ll m) { // a^-1 mod m
  ll x, y;
  extgcd(a, m, x, y);
  x %= m;
  if (x < 0) x += m;
  return x;
}
 
ll *fac, *finv, *inv;
 
void nCk_init(ll mod) {
  fac = new ll[NCK_MAX];
  finv = new ll[NCK_MAX];
  inv = new ll[NCK_MAX];
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll i = 2; i < NCK_MAX; i++) {
    fac[i] = fac[i-1] * i % mod;
    inv[i] = mod - inv[mod%i] * (mod / i) % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}
 
ll nCk(ll n, ll k, ll mod) {
  if (fac == NULL) nCk_init(mod);
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}
int main(void){
    ll n,ans=0;
    cin>>n;
    for(ll i=1;3*i<=n;i++){
        ll a=n-3*i;
        ans+=nCk(a+i-1,a,mod);
        ans%=mod;
    }
    cout<<ans<<endl;
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> p(N, 0);
    for (int i = 0; i < N; i++)
        cin >> p[i];
    sort(p.begin(), p.end());
    cout << accumulate(p.begin(), p.begin() + K, 0) << endl;
    return 0;
}

Measured memory_bytes: 3568
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n,a,b; cin >>n>>a>>b;
  if((a+b==0)||(a==0)){
    cout<<0<<endl;
  return 0;
  }
  if(n%(a+b)<=a) cout<<(n/(a+b))*a+n%(a+b)<<endl;
  else cout<<(n/(a+b))*a+a<<endl;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var n=Arr.shift()-0;
for(var I=0;I<n;I++){
   var str=Arr.shift();
   var arr=[];
   for(var i=1;i<str.length;i++){
      arr.push([str.slice(0,i),str.slice(i,str.length)]);
   }
   var obj={};
   for(var i=0;i<arr.length;i++){
      var A=arr[i][0];
      var B=arr[i][1];
      var a=A.split("").reverse().join("");
      var b=B.split("").reverse().join("");
      obj[A+B]=true;
      obj[A+b]=true;
      obj[a+B]=true;
      obj[a+b]=true;
      obj[B+A]=true;
      obj[B+a]=true;
      obj[b+A]=true;
      obj[b+a]=true;
   }
   console.log(Object.keys(obj).length);
}

Measured memory_bytes: 13092
#include <cstdio>
#include <stack>
using namespace std;

int main() {

    int sh, sm, ss, eh, em, es;
    for (int i = 0; i < 3; i++) {
        scanf("%d %d %d %d %d %d", &sh, &sm, &ss, &eh, &em, &es);
        if (ss > es) { es+=60-ss; sm++; }
        else  es-=ss;
        if (sm > em) { em+=60-sm; sh++; }
        else em-=sm;
        printf("%d %d %d\n", eh-sh, em, es);
    }
    return 0;
}



Measured memory_bytes: 2696
#include <iostream>
#include <numeric>
#include <vector>
#include <string>

#include <algorithm>
using namespace std;

using ll = long long int;

int main(void) {

    ll result = 0;

    int n,t;
    ll before = 0;
    cin >> n >> t;

    before -= (t+10);

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        if (before + t >= a) {
            result -= before + t - a;
        }

        result += t;

        before = a;
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>l(n);
	for(int i=0;i<n;i++)
		cin>>l[i];
	int cnt=0;
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			for(int k=j+1;k<n;k++){
				int a=l[i],b=l[j],c=l[k];
				if(a==b||a==c||b==c)
					continue;
				if(a+b>c&&a+c>b&&b+c>a)
					cnt++;
			}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <tuple>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <complex>
#include <bitset>
#include <numeric>
#include <random>
using namespace std;

//make_tuple emplace_back next_permutation
#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define SE second
#define FI first
#define DBG(...) string s999=#__VA_ARGS__;replace(ALL(s999),',',' ');stringstream ds999; ds999<<s999; debug(ds999,__VA_ARGS__);
inline void debug(stringstream& ds){cerr<<endl;return;}
template<typename F, typename... R>void debug(stringstream& ds,const F& f, const R&... r){string n; ds>>n; cerr<< n <<' '<<f<<' '; debug(ds,r...);}
#define ALL(v) (v).begin(),(v).end()
#define SI(v) (int)(v).size()
typedef long long LL;  typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
typedef pair<int,int>PI; typedef vector<int> VI;
const LL LINF=334ll<<53; const int INF=15<<26; const LL MOD=1E9+7;
void fail(){cout <<"No"<<endl; exit(0);}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<PI> a;
    FOR(i,1,n+1) {
        int tmp;
        cin >> tmp;
        a.push_back(make_pair(tmp,i));
    }
    VI ans,cnt(n+1),rank(n+1);
    queue<int> t,ne;
    sort(ALL(a));
    REP(i,n) {
        rank[a[i].SE]=i+1;
    }
    REP(i,n){
        REP(j,a[i].SE-1)ne.push(a[i].SE);
        cnt[a[i].SE]=a[i].SE-1;
    }
    a.insert(a.begin(),MP(0,0));

    REPN(i,1,n){
        REP(j,a[i].FI-a[i-1].FI-1){
            //DBG(t.size())
            if(!ne.empty()){
                ans.push_back(ne.front());
                ne.pop();
            }else{
                if(t.empty()){
                    //cout << 'A'<<endl;
                    fail();
                }
                ans.push_back(t.front());
                t.pop();
            }
        }
        //DBG(ne.front(), a[i].SE)
        if(!ne.empty() and rank[ne.front()]<=rank[a[i].SE]){
            //cout << 'B'<<endl;
            fail();
        }
        ans.push_back(a[i].SE);
        REP(j,n-a[i].SE)t.push(a[i].SE);
    }
    //DBG(a[n].SE)
    FOR(i,a[n].FI,n*n){
            ans.push_back(t.front());
                t.pop();
    }
    cout << "Yes"<<endl;
    REP(i,ans.size()-1)cout << ans[i]<<' ';
    cout << ans[ans.size()-1]<<endl;


    return 0;
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long 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; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    int ans = 1e9;
    for(int i = 0; i < N; i++){
        int a; cin >> a;
        int cnt = 0;
        while(a%2 == 0){
            a /= 2;
            cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}


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

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

string s;
int dp[(1 << 26) + 5];
void solve() {
    cin >> s;
    auto n = sz(s);
    int x = 0;
    fillArray(dp, iinf);
    dp[0] = 0;
    rep(i, n) {
        x ^= 1 << (s[i] - 'a');
        rep(j, 26) mins(dp[x], dp[x ^ (1 << j)] + 1);
    }
    cout << max(1, dp[x]) << endl;
}

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


Measured memory_bytes: 262736
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 2e5+10;
LL num[maxn];
int main()
{
 int n,k;
    cin >> k >> n;
    for(int i = 0;i<n;++i)
    {
        cin >> num[i];
    }
    num[n] = num[0]+k;
    LL ans = 1e9;
    for(int i = 1;i<=n;++i)
    {
        ans = min(ans,k-num[i]+num[i-1]);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <regex>
using namespace std;
typedef long long ll;

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MAX_V 100000

#define MOD 1000000007L
#define INF 100000000000

signed main() {
	int x;
	cin >> x;
	cout << (x < 1200 ? "ABC" : "ARC") << endl;
}


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

using namespace std;

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

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

  int sum = 0;
  for (int i = 1; i < N; ++i) {
    sum += L[i];
  }

  if (L[0] < sum) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())
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;
}
#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;

    vector<double> Ps(N);
    REP(n, N) cin >> Ps[n];

    const int offset = 5000;
    vector<vector<double>> dp(N, vector<double>(offset * 2));

    REP(n, N) {
        if (n == 0) {
            dp[n][1 + offset] = Ps[n];
            dp[n][-1 + offset] = 1.0 - Ps[n];
        }
        else {
            for(int i = -(n + 1); i <= (n + 1); ++i) {
                dp[n][i + offset]
                    = dp[n - 1][i - 1 + offset] * Ps[n]
                    + dp[n - 1][i + 1 + offset] * (1.0 - Ps[n]);
            }
        }
    }
    double ans = 0;
    FOR(i, 1, N + 1) {
        ans += dp[N - 1][i + offset];
    }
    cout << fixed << setprecision(20) << ans << endl;

    return 0;
}


Measured memory_bytes: 234752
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			TreeMap<Long, Long> map = new TreeMap<Long, Long>();

			for (long i = 0; i < n; i++) {
				long a = sc.nextLong();
				if (map.keySet().contains(a)) {
					map.put(a, map.get(a)+ 1);
				} else {
					map.put(a, 1l);
				}
			}

			int count = 0;
			long result = 1l;
			Long[] tmp = map.keySet().toArray(new Long[map.size()]);

			for (int i = tmp.length - 1; 0 <= i; i--){
				if (2 <= map.get(tmp[i])) {
					if (count == 0 && 4 <= map.get(tmp[i])) {
						System.out.println(tmp[i] * tmp[i]);
						return;
					}
					result *= tmp[i];
					count++;
					if (count == 2) {
						System.out.println(result);
						return;
					}
				}
			}
			System.out.println(0);
		}
	}
}


Measured memory_bytes: 63776
#n,m=map(int,input().split())
a=int(input())
ac=0
tle=0
wa=0
re=0
for i in range(a):
    temp=input()
    if temp=="AC":
        ac+=1
    if temp=="WA":
        wa+=1
    if temp=="TLE":
        tle+=1
    if temp=="RE":
        re+=1
print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)



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

#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

using Graph = vector<vector<int>>;

Graph G;

int n;


int main() {
    cin >> n;
    G.assign(n, vector<int>());
    REP(i,n){
        int u;
        cin >> u;
        u--;
        int k;
        cin >> k;
        REP(j,k){
            int v;
            cin >> v;
            v--;
            G[u].push_back(v);
        }
    }
    vector<int> dist(n, -1);
    queue<int> que;

    dist[0] = 0;
    que.push(0);

    while(!que.empty()){
        int v = que.front();
        que.pop();

        for(int next: G[v]){
            if(dist[next]!=-1) continue;

            dist[next] = dist[v] + 1;
            que.push(next);
        }
    }
    REP(i,n){
        cout << i+1 << " " << dist[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 3164
#include <iostream>
using namespace std;
 
int main(){
	int n; 
	cin >> n;
	int i; 
	for(i = 0; i< 3; i++){
		if(n%10 == 7){
			break;
		}
		n = n/10;
	}
 
	if(i==3) cout << "No" << endl;
	else     cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;


int main() {
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(a+b,min(a+c,b+c))<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;

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

using ll = long long;
using Pii = pair<int, int>;

const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;

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

using MIte = multimap<ll, ll, greater<ll> >::iterator;

//2040
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	// long long?
	ll A, B;
	cin >> A >> B;



	cout << (A-1)*(B-1)<< endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;

int main(){
    vvector(a,int,3,3,0);
    reprep(i,j,3,3)std::cin >> a[i][j];
    bool b=1;
    if(a[0][0]-a[0][1]!=a[1][0]-a[1][1])b=0;
    if(a[2][0]-a[2][1]!=a[1][0]-a[1][1])b=0;
    if(a[0][2]-a[0][1]!=a[1][2]-a[1][1])b=0;
    if(a[2][2]-a[2][1]!=a[1][2]-a[1][1])b=0;
    if(a[0][2]-a[0][0]!=a[1][2]-a[1][0])b=0;
    if(a[2][2]-a[2][0]!=a[1][2]-a[1][0])b=0;
    if(b)std::cout << Yes << std::endl;
    else std::cout << No << std::endl;
}

Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int[] a;
    int[] count;
    int i;

    count = new int[3];
    a = new int[5];

    for(;;){
      for(i = 0;i < 3;i++)count[i] = 0;
      a[0] = sc.nextInt();
      if(a[0] == 0)break;
      count[a[0] - 1]++;
      for(i = 1;i < 5;i++){
        a[i] = sc.nextInt(); count[a[i] - 1]++;
      }

      if(count[0] * count[1] * count[2] != 0){
        out.printf("3%n3%n3%n3%n3%n");
      }else if(count[0] == 5){
        out.printf("3%n3%n3%n3%n3%n");
      }else if(count[1] == 5){
        out.printf("3%n3%n3%n3%n3%n");
      }else if(count[2] == 5){
        out.printf("3%n3%n3%n3%n3%n");
      }else if(count[0] == 0){
        for(i = 0;i < 5;i++){
          if(a[i] == 2)out.println("1");
          else out.println("2");
        }
      }else if(count[1] == 0){
        for(i = 0;i < 5;i++){
          if(a[i] == 3)out.println("1");
          else out.println("2");
        }
      }else if(count[2] == 0){
        for(i = 0;i < 5;i++){
          if(a[i] == 1)out.println("1");
          else out.println("2");
        }
      }
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 20884
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
    ll n,a,b;cin >> n >> a >> b;
    while(true){
        if(a+1!=b)a++;
        else a--;
        if(a==0){
            cout << "Borys" <<endl;
            return 0;
        }
        if(b-1!=a)b--;
        else b++;
        if(b==n+1){
            cout << "Alice" <<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
    int c=0,i,j;
    char s[101];
    cin>>s;
    int l =strlen(s);
    for(i=0;i<l;i++){
        j=i+1;
        if(j%2==0){
            if(s[i]=='L'|| s[i]=='U'||s[i]=='D'){
                c++;
            }
        }
        else if(j%2!=0){
            if(s[i]=='R'|| s[i]=='U'||s[i]=='D'){
                c++;
            }
        }
        j=0;
    }
    if(c==l){
        cout<<"Yes";
    }
    else
        cout<<"No";
}


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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if (k <= a) {
    cout << k << endl;
  } else if (k <= a + b) {
    cout << a << endl;
  } else {
    cout << a - (k - a - b) << endl;
  }
}

Measured memory_bytes: 3632