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

using ll = long long;
//typedef long long ll;

#define INF ((1LL << 31) - 1)
#define INFLL ((1LL << 62) - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()

// 4近傍のときは for(int i = 0; i < 8; i+=2) などとして使うこと
int vx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, vy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

// [sx, se), [sy, ey)であることに注意
inline bool check(int sx, int ex, int sy, int ey, int x, int y) {
  return (sx <= x and x < ex and sy <= y and y < ey);
}

inline bool check(int ex, int ey, int x, int y) {
  return check(0, ex, 0, ey, x, y);
}

inline void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

ll n, k, cnt;
vector<ll> a;
map<ll, int> mp;

int main() {
  init();
  cin >> n >> k;
  a.resize(n);
  for (int i = 0; i < n; ++i) {
      cin >> a[i];
      if (mp[a[i]] == 0) {
          cnt++;
      }
      mp[a[i]]++;
  }

  ll ans = 0;

  if (cnt <= k) {
      cout << 0 << endl;
  }
  else {
    vector<pair<ll, ll> > p;
    auto itr = mp.begin();
    while (itr != mp.end()) {
      p.push_back({itr->second, itr->first});
      itr++;
    }

    sort(p.begin(), p.end());

    for (int i = 0; i < p.size(); ++i) {
        ans += p[i].first;
        cnt--;
        if (cnt <= k) break;
    }

    cout << ans << endl;
  }

  return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int64)1e9
#define REP(i, n) for(int64 i = 0; i < (n); i++)
#define FOR(i, a, b) for(int64 i = (a); i < (b); i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint32_t;
using int64 = int64_t;
using uint64 = uint64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

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

int main(void) {
  int64 n;
  while (cin >> n && n) {
    int64 sum = 0;
    REP(i, n/4) {
      int64 x;
      cin >> x;
      sum += x;
    }
    cout << sum << endl;
  }
}


Measured memory_bytes: 3060
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 500*a+100*b+50*c == X:
                ans += 1
print(ans)

Measured memory_bytes: 3060
n = int(input())
ls = list(map(int, input().split()))
rsw = [0]*1005
for i in ls:
    rsw[i] += 1
for i in range(1,1005):
    rsw[i] = rsw[i-1] + rsw[i]
res = 0
for i in range(n):
    for j in range(i+1,n):
        a = ls[i]
        b = ls[j]
        low = abs(a-b)
        high = a+b
        tmp = rsw[min(high,1004)-1] - rsw[low]
        if low < a < high:
            tmp -= 1
        if low < b < high:
            tmp -= 1
        res += tmp
print(res//3)

Measured memory_bytes: 74176
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

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

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

class Point{
public:
	double x;
	double y;
	Point(double _x, double _y) : x(_x), y(_y) {}
};

bool isInterSect(const Point& p1,const Point& p2,const Point& p3,const Point& p4){
	    if (((p1.x - p2.x) * (p3.y - p1.y) + (p1.y - p2.y) * (p1.x - p3.x)) * 
        ((p1.x - p2.x) * (p4.y - p1.y) + (p1.y - p2.y) * (p1.x - p4.x)) < 0){
			if (((p3.x - p4.x) * (p1.y - p3.y) + (p3.y - p4.y) * (p3.x - p1.x)) * 
            ((p3.x - p4.x) * (p2.y - p3.y) + (p3.y - p4.y) * (p3.x - p2.x)) < 0){
				return true;
			}
		}

		return false;
}

double getArea(const Point& p1, const Point& p2,const Point& p3){
	double a = hypot(p1.x-p2.x,p1.y-p2.y);
	double b = hypot(p2.x-p3.x,p2.y-p3.y);
	double c = hypot(p3.x-p1.x,p3.y-p1.y);

	double s = (a+b+c)/2.0;

	return sqrt(s*(s-a)*(s-b)*(s-c));
}

int main(){
	double x1,y1,x2,y2,x3,y3;
	double xp,yp;
	while(~scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)){
		double S1 = getArea(Point(x1,y1),Point(x2,y2),Point(x3,y3));

		double S2 = getArea(Point(xp,yp),Point(x2,y2),Point(x3,y3));
		double S3 = getArea(Point(x1,y1),Point(xp,yp),Point(x3,y3));
		double S4 = getArea(Point(x1,y1),Point(x2,y2),Point(xp,yp));

		if(S1 - EPS <= S2+S3+S4 && S2+S3+S4 <= S1 + EPS){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
}

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

using namespace std;
using ll = long long;

int main() {
    int n;
    cin>>n;
    ll ans=0;
    for(int i = 1;i <= n;++i) {
        if(i%3==0||i%5==0)continue;
        else ans+=i;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;


int main (){
    int a,b;
    while(true){
        cin>>a>>b;
        if(b == 0 && a == 0){
            break;
        }
        if(a>=b){
            cout<<b<<" "<<a<<endl;
        }
        else{
            cout<<a<<" "<<b<<endl;
        }
    }

	return 0;
}



Measured memory_bytes: 3044
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.LinkedList;

public class Main {
    public static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

    public static int nextInt() {
        try {
            in.nextToken();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return (int) in.nval;
    }

    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
        in.nextToken();
        String s = in.sval;
        LinkedList<Character> st = new LinkedList<Character>();
        int len = s.length();
        for (int i = 0; i < len; i++)
            st.add(s.charAt(i));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        int n = nextInt();
        boolean a = false;
        for (int i = 1; i <= n; i++) {
            int op = nextInt();
            if (op == 1)
                a = !a;
            else {
                int x = nextInt();
                in.nextToken();
                String c = in.sval;
                if ((x == 1 && !a) || (x == 2 && a))
                    st.addFirst(c.charAt(0));
                else
                    st.addLast(c.charAt(0));
            }
        }
        if (!a)
            while (!st.isEmpty())
                out.print(st.pollFirst());
        else {
            while (!st.isEmpty())
                out.print(st.pollLast());
        }
        out.flush();
    }

}

Measured memory_bytes: 62828
#include<stdio.h>
#include<math.h>
double f(double a, double b, double d)
{
	double r = d * acos(-1) / 180.0;
	if (b * cos(r) > a* sin(r))
		return a * (b * b / tan(r) / 2.0 - tan(r) * (b / tan(r) - a) * (b / tan(r) - a) / 2.0);
	else
		return a * b * b / tan(r) / 2.0;
}
int main()
{
	double a, b, x;
	scanf("%lf %lf %lf", &a, &b, &x);
	double min = 0, mid, max = 90;
	int i;
	for (i = 0; i < 10004; i++)
	{
		mid = (max + min) / 2.0;
		if (f(a, b, mid) < x)
			max = mid;
		else
			min = mid;
	}
	printf("%.20lf\n", min);
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){

  int n,b,f,r,v,i,j,k;
  int room[4][3][10];

  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	room[i][j][k]=0;
      }
    }
  }

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d%d%d%d",&b,&f,&r,&v);
    b-=1;
    f-=1;
    r-=1;
    room[b][f][r]+=v;
  }

  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	printf(" %d",room[i][j][k]);
      }
      puts("");
    }
    if(i<3){
      for(j=0;j<20;j++){
	printf("#");
      }
    puts("");
    }
  }
  return 0;
}

Measured memory_bytes: 612
//In The Name of Allah
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template < class T > using Tree = tree < T , null_type , less < T > , rb_tree_tag , tree_order_statistics_node_update >;

typedef long long            ll;
typedef long double          ld;
typedef string               str;
typedef pair < ll , ll >     pll;

#define X               first
#define Y               second
#define pb              push_back
#define all(x)          (x).begin(), (x).end()
#define SZ(x)           (ll)(x.size())
#define sep             ' '
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define dbl_io(x)       cout << fixed << setprecision(x);

const int N = 1e5 + 10;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 10;

ll ans[10], h, w;
map < pll , ll > mp;

void upd(ll x, ll y){
    if (!(1 <= x && x <= h && 1 <= y && y <= w && x + 2 <= h && y + 2 <= w))
        return ;
    ll t = 0;
    for (ll i = 0; i < 3; i ++)
        for (ll j = 0; j < 3; j ++)
            if (mp[make_pair(x + i, y + j)])
                t ++;
    ans[t] ++;
    ans[t - 1] --;
}

int main(){
    fast_io
    //dbl_io(10);
    cin >> h >> w;
    ans[0] = (h - 2) * (w - 2);
    ll q; cin >> q;
    while (q --){
        ll x, y;
        cin >> x >> y;
        mp[make_pair(x, y)] = 1;
        for (ll i = 0; i < 3; i ++)
            for (ll j = 0; j < 3; j ++)
                upd(x - i, y - j);
    }
    for (ll i = 0; i < 10; i ++)
        cout << ans[i] << '\n';
    return 0;
}


Measured memory_bytes: 156544
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;

int main(){
	int R;
	cin>>R;
	if(R<1200){
		cout<<"ABC";
	}else if(R<2800){
		cout<<"ARC";
	}else{
		cout<<"AGC";
	}
	 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <iomanip>
using namespace std;
typedef long long ll;
const int maxn = 605;
vector<int>G[maxn];
int in[maxn]={0};
int top[maxn]={0};
double dp[maxn];
void gettop(int n){
    queue<int>qq;
    for(int i=1;i<=n;i++){
        if(in[i]==0)
            qq.push(i);
    }
    int ind=-1,u;
    while(!qq.empty()){
        top[++ind]=qq.front();
        u=qq.front();
        qq.pop();
        for(int i=0;i<G[u].size();i++){
            in[G[u][i]]--;
            if(in[G[u][i]]==0)
            qq.push(G[u][i]);
        }
    }
}

double gao(int n,int block){
    int u;
    dp[n]=0;
    for(int i=n-1;i>0;i--){
        double ans = 0;
        double maxnum = 0;
        int num = G[i].size();
        for(int j=0;j<num;j++){
            ans+=dp[G[i][j]];
            maxnum = max(maxnum,dp[G[i][j]]);
        }
        if(num>=2&&block==i){
            ans -= maxnum;
            num--;
        }
        dp[i]=ans/num+1;
    }
    return dp[1];
}
int main()
{
    int n,m;
    int u,v;
    cin >> n >>m;
    for(int i=0;i<m;i++){
        cin >> u >> v;
        G[u].push_back(v);
        in[v]++;
    }
    gettop(n);
    dp[1]=0;
    double res = 1e18;
    for(int i=0;i<=n;i++)
        res=min(res,gao(n,i));
    cout << fixed ;
    cout << setprecision(10) << res << endl;
    return 0;
}


Measured memory_bytes: 1408
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int ret = 0;
            switch (Console.ReadLine())
            {
                case "SUN": ret = 7; break;
                case "MON": ret = 6; break;
                case "TUE": ret = 5; break;
                case "WED": ret = 4; break;
                case "THU": ret = 3; break;
                case "FRI": ret = 2; break;
                case "SAT": ret = 1; break;
            };
            Console.WriteLine(ret);
        }
    }
}

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

constexpr int MAX_SIZE = 10;
constexpr int dx[4] = {1, -1, 0, 0};
constexpr int dy[4] = {0, 0, 1, -1};
constexpr char dc[4] = {'R', 'L', 'D', 'U'};

int h, w;
string field[MAX_SIZE];
string ans = "";

inline bool out(int x, int y) {
	return x < 0 || y < 0 || x >= w || y >= h;
}

bool dfs(int rest, int x, int y, int d) {
	if(rest == 0) return true;

	for(int nd = 0; nd < 4; ++nd) {
		if(d == (nd ^ 1)) continue;

		int nx = x + dx[nd];
		int ny = y + dy[nd];

		while(!out(nx, ny)) {
			if(field[ny][nx] == 'o') {
				field[ny][nx] = '.';
				if(dfs(rest - 1, nx, ny, nd)) {
					ans = dc[nd] + ans;
					return true;
				}

				field[ny][nx] = 'o';
				break;
			}
			nx += dx[nd];
			ny += dy[nd];
		}
	}

	return false;
}

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

	cin >> h >> w;
	for(int i = 0; i < h; ++i) {
		cin >> field[i];
	}

	int sx, sy, sd;
	int cnt = 0;
	for(int i = 0; i < h; ++i) {
		for(int j = 0; j < w; ++j) {
			if(field[i][j] == 'o') {
				++cnt;
			}
			else if(field[i][j] != '.') {
				sx = j;
				sy = i;
				for(int d = 0; d < 4; ++d) {
					if(field[i][j] == dc[d]) {
						sd = d;
						break;
					}
				}
			}
		}
	}

	dfs(cnt, sx, sy, sd);
	cout << ans << endl;

	return EXIT_SUCCESS;
}

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

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

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

  // 最後のボタン押したときの秒数を事前に入れとく
  long long sum = t;
  // 前との差がt未満なら差を足す。
  // t以上ならtを足す。

  for (int i = 1; i < n; i++) {
    long long sa = tt[i] - tt[i - 1];
    if (sa < t) {
      sum += sa;
    } else {
      sum += t;
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int n;
  int k;
  cin>>n>>k;
  int count=0;
  int hoge;
  rep(i,0,n){
    cin>>hoge;
    if(hoge>=k) count++;
  }
  cout<<count;

}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
import collections

n = int(input())
l = list(map(int, input().split()))
c = collections.Counter(l)
s = sum(l)

q = int(input())
for q in range(q):
    a, b = map(int, input().split())
    if c[a] == 0:
        print(s)
    elif c[b] == 0:
        s = s + (b-a) * c[a]
        c[b] = c[a]
        c[a] = 0
        print(s)
    else:
        s = s + (b-a) * c[a]
        c[b] += c[a]
        c[a] = 0
        print(s)


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

using namespace std;

int main() {
    string s;
    cin >> s;
    const int maxn = 5e5 + 5;
    int x[maxn];
    vector <int> minima;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '<' && (i == 0 || s[i - 1] == '>'))
            x[i] = 0, minima.push_back(i);
    }
    memset(x, 0, sizeof x);
    for (int i: minima) {
        int cur = x[i];
        for (int j = i - 1; j >= 0 && s[j] == '>'; j--) x[j] = max(x[j], ++cur);
        cur = x[i];
        for (int j = i; j < s.length() && s[j] == '<'; j++) {
                x[j + 1] = max(x[j + 1], ++cur);
        }
    }
    int n = s.length() - 1;
    if (s[n] == '>') {
        int cur = 0;
        for (int i = n; i >= 0 && s[i] == '>'; i--)
            x[i] = max(x[i], ++cur);
    }
    long long ans = 0;
    for (int i = 0; i <= s.length(); i++) ans += x[i];
    cout << ans;
    return 0;
}


Measured memory_bytes: 3456
#include <iostream>
using namespace std;
#define ll long long
const ll N = 1e7+1e5;
ll d,i,n,summ,f[N];
int main ()
{
    cin>>n;
    for(d=1; d<=n; ++d)
    {
        for(i=d; i<=n; i+=d)
            f[i]++;
    }
    for (i=1; i<=n; ++i)
        summ+=i*f[i];
    cout<<summ<<"\n";
}



Measured memory_bytes: 81692
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;


ll substep(ll stairs);

int main()
{
    int H,W;
    cin >> H >> W;
    vector<vector<char>> A(H);
    vector<vector<int>> dist(H);
    
    deque<P> q;
    for(int i=0;i<H;i++) {
        A[i].assign(W, '0');
        dist[i].assign(W, 0);
        for(int j=0;j<W;j++) {
            cin >> A[i][j];
            if(A[i][j]=='#') q.push_back(P(i,j));
        }
    }
    
    P tmp;
    int i,j;
    int maxt=0 , t;
    while(!q.empty()){
        tmp = q.front();
        q.pop_front();
        i = tmp.first;
        j = tmp.second;
        t = dist[i][j];
        if(i>=1      &&  A[i-1][j]=='.') {
            q.push_back(P(i-1,j));
            A[i-1][j] = '#';
            dist[i-1][j] = t + 1;
            maxt = max(maxt , t+1);
        }
        if(j>=1      &&  A[i][j-1]=='.') {
            q.push_back(P(i,j-1));
            A[i][j-1] = '#';
            dist[i][j-1] = t + 1;
            maxt = max(maxt , t+1);
        }
        if(j<=W-2    &&  A[i][j+1]=='.') {
            q.push_back(P(i,j+1));
            A[i][j+1] = '#';
            dist[i][j+1] = t + 1;
            maxt = max(maxt , t+1);
        }
        if(i<=H-2    &&  A[i+1][j]=='.') {
            q.push_back(P(i+1,j));
            A[i+1][j] = '#';
            dist[i+1][j] = t + 1;
            maxt = max(maxt , t+1);
        }
    }
    
    cout << maxt << endl;
    
    return 0;
}


Measured memory_bytes: 13328
#include <iostream>
#include <string>
#include <iomanip>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main()
{
	int x;
	cin >> x;
	if(x == 7 || x == 5 || x == 3) puts("YES");
	else puts("NO");
	return 0;
}

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

void fnTrace(const vector<int> &cnrvnSort)
{
  for (int i = 0; i < cnrvnSort.size(); i++)
  {
    if (i) cout << " ";
    cout << cnrvnSort[i];
  }
  cout << endl;
}

void fnInsertionSort(vector<int> &rvnSort)
{
  for (int nSorting = 1; nSorting < rvnSort.size(); nSorting++)
  {
    int nTrg = rvnSort[nSorting];
    int nSorted = nSorting - 1;

    while (nSorted >= 0          &&
           nTrg  < rvnSort[nSorted])
    {
      rvnSort[nSorted + 1] = rvnSort[nSorted];
      nSorted--;
    }
    rvnSort[nSorted + 1] = nTrg;
    fnTrace(rvnSort);
  }
}

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

  vector<int> vnSort;
  int nMaxSiz;
  
  cin >> nMaxSiz;
  for (int i = 0; i < nMaxSiz; i++)
  {
    int nNum;
    cin >> nNum;
    vnSort.push_back(nNum);
  }

  fnTrace(vnSort);
  fnInsertionSort(vnSort);

  return 0;
}

Measured memory_bytes: 1220
import sys

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
for i in S:
    i.insert(0, '.')
    i.append('.')
S.insert(0, ['.' for _ in range(W+2)])
S.append(['.' for _ in range(W+2)])
DI = [-1, 0, 0, 1]
DJ = [0, -1, 1, 0]
count = 0

for i in range(1, H+1):
    for j in range(1, W+1):
        if S[i][j] == '#':
            # '#'であれば隣接マスを探索
            for di, dj in zip(DI, DJ):
                if S[i+di][j+dj] == '#':
                    count += 1
            if count == 0:
                print('No')
                sys.exit()
            count = 0
print('Yes')


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

int main(){
	int n;
	cin >> n;
	vector<string> s(n);
  rep(i, n) cin >> s[i];
	vector<int> c(4, 0);
	
	rep(i, n) {
		if (s[i] == "AC") c[0]++;
		if (s[i] == "WA") c[1]++;
		if (s[i] == "TLE") c[2]++;
		if (s[i] == "RE") c[3]++;
	}
	cout << "AC x " << c[0] << endl;
  cout << "WA x " << c[1] << endl;
  cout << "TLE x " << c[2] << endl;
  cout << "RE x " << c[3] << endl;
}


Measured memory_bytes: 6424
import sys
import random
from copy import copy
from math import floor, e

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def write_output(out):
    with open("my_sample3.out", mode="w") as f:
        for x in out:
            f.write(str(x + 1) + "\n")


def main():
    d = int(readline())
    c = list(map(int, readline().split()))
    s = [list(map(int, readline().split())) for _ in range(d)]

    sat_cur = 0
    last = [1] * 26
    out = [-1] * d

    for day in range(d):
        estimate = [0.0] * 26
        for cid in range(26):
            if s[day][cid] > 16000:
                estimate[cid] = last[cid] * c[cid] + c[cid] ** 1
        cur = estimate.index(max(estimate))
        out[day] = cur
        sat_cur += s[day][cur]
        last[cur] = 1
        for cid in range(26):
            if cid != cur:
                sat_cur -= last[cid] * c[cid]
                last[cid] += 1

    # print("begin", sat_cur)
    out_best = copy(out)
    sat_best = sat_cur
    num_of_try = 10000
    for i in range(1, num_of_try + 1):
        change_num = floor((num_of_try - i) / 5000)
        out_temp = copy(out_best)
        for j in range(change_num):
            c_day = int(random.triangular(0, 365 - 0.01, 50))
            c_cid = random.randint(0, 25)
            out_temp[c_day] = c_cid

        last = [1] * 26
        sat_temp = 0
        for day in range(d):
            cur = out_temp[day]
            sat_temp += s[day][cur]
            last[cur] = 1
            for cid in range(26):
                if cid != cur:
                    sat_temp -= last[cid] * c[cid]
                    last[cid] += 1
        if sat_temp > sat_best:
            # print(i, ":", sat_temp)
            out_best = out_temp
            sat_best = sat_temp

    for x in out_best:
        print(x + 1)

    # write_output(out_best)


if __name__ == '__main__':
    main()


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

namespace abc120_a
{
    class Program
    {
        public static int FavoriteSound(int A, int B, int C)
        {
            int count = 0;
            if (B < A) return count;

            while(B >= A)
            {
                if (count == C) return count;
                if (B >= A)
                {
                    B -= A;
                    ++count;
                }

            }
            return count;
        }

        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);    //何円で鳴るか
            int B = int.Parse(input[1]);    //手持ちのお金
            int C = int.Parse(input[2]);    //最大回数

            Console.WriteLine(FavoriteSound(A, B, C));
        }
    }
}


Measured memory_bytes: 11092
n=int(input())
a=list(map(int,input().split()))
q=int(input())
b=[]
c=[]
for _ in range(q):
    x,y=map(int,input().split())
    b.append(x)
    c.append(y)

d=[0]*100001
for i in a:
    d[i]+=1

ans=sum(a)
for m,p in zip(b,c):
    minus=d[m]
    d[m]=0
    d[p]+=minus
    ans+=(p-m)*minus
    print(ans)


Measured memory_bytes: 22104
n, a, b = map(int, input().split())
x = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    if (x[i+1] - x[i]) * a > b:
        ans += b
    else:
        ans += (x[i+1] - x[i]) * a
print(ans)


Measured memory_bytes: 15020
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
          

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n , l;
    string s[102];
    cin >> n >> l;
    for ( int i = 0 ; i < n ; i++ ) cin >> s[i];
    sort( s , s + n );
    for ( int i = 0 ; i < n ; i++ ) cout << s[i];
}

Measured memory_bytes: 256
N = int(input())
b = [0] + list(map(int, input().split()))
#print(b[N])
flag = [1] * (N + 1) #抜き取った番号を記録する配列
ans = []
i = N
_i = 0
while True:
    #print(i - _i)
    if b[i - _i] > i - _i:
        print(-1)
        exit()
        break
    elif b[i - _i] == i - _i:
        ans.append(i - _i)
        del b[i - _i]
        i -= 1
        _i = 0
    else:
        _i += 1
    if _i >= i:
        #print(list(reversed(ans)))
        break
for a in reversed(ans):
    print(a)

Measured memory_bytes: 79672
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>

int main(int argc, char* argv[]){
  int n;
  std::vector<std::string>s;
  std::cin >> n;
  for (int i = 0; i < n; i++){
	char str [10];
    std::cin >> str;
    std::sort(str, str + 10);   
    s.push_back(std::string(str));
  }

  std::sort(s.begin(), s.end());

  
  long long c = 0;
  long long c_i = 1;
  int i = 0;
  int j = 1;
  while (j < n){
    if (s[i] == s[j]){
      c_i++;
      j++;
    } else {
      c += c_i * (c_i - 1) / 2;
      c_i = 1;
      i = j;
      j++;
    }
  }
  c += c_i * (c_i - 1) / 2;
  std::cout << c << std::endl;
  return 0;
}

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

typedef long long ll;

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

    int n,ans=1,sum=0;
    cin >> n;
    vector<int> a(n);
    map<int,int> mp;
    set<int> st;
    for(int i=0;i<n;i++){
        cin >> a[i];
        mp[a[i]]++;
        st.insert(a[i]);
    }
    if(n==1){
        cout << 1 << endl;
        return 0;
    }
    if(n==2){
        if(abs(a[0]-a[1])<=2){
            cout << 2 << endl;
        }else{
            cout << 1 << endl;
        }
        return 0;
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++){
        sum = 0;
        if(st.count(a[i])==1 && st.count(a[i]+1)==1 && st.count(a[i]+2)==1){
            sum += mp[a[i]] + mp[a[i]+1] + mp[a[i]+2];
            ans = max(ans,sum);
        }
    }
    for(int i=0;i<n-1;i++){
        sum = 0;
        if(a[i]+1==a[i+1]){
            sum += mp[a[i]] + mp[a[i+1]];
            ans = max(ans,sum);
        }
    }
    for(int i=0;i<n;i++){
        ans = max(ans,mp[a[i]]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
# coding: utf-8
import sys
input = sys.stdin.readline

def dp_happiness(N):
    yesterday_a, yesterday_b, yesterday_c = 0, 0, 0
    for _ in range(N):
        a, b, c = map(int, input().split())

        today_a = a + max(yesterday_b, yesterday_c)
        today_b = b + max(yesterday_c, yesterday_a)
        today_c = c + max(yesterday_a, yesterday_b)

        yesterday_a = today_a
        yesterday_b = today_b
        yesterday_c = today_c
    return max(today_a, today_b, today_c)

N = int(input())
print(dp_happiness(N))

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define repl(k,n) for(k=0;k<n;++k)

int main() {
	string S;
	string T;
	cin >> S >> T;
	int i;
	int ans = 0;
	rep(i, S.size()) {
		if (S[i] != T[i]) ans = ans + 1;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3912
N = int(input())
robot = {}

for i in range(N):
  x, l = map(int, input().split())
  robot[x] = l

s_robot = sorted(robot.items(), key=lambda x:x[0])

pre_arm = -10**10
cnt = 0
for key, val in s_robot:
  l_arm = key - val
  r_arm = key + val
  if pre_arm > l_arm:
    cnt += 1
    if pre_arm > r_arm:
      pre_arm = r_arm
  else:
    pre_arm = r_arm
    
print(N-cnt)

Measured memory_bytes: 24160
#include<bits/stdc++.h>
#define F first
#define S second
using ll = long long;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using namespace std;
using vl = vector<ll>;
using pll =  pair<ll,ll>;


void  solve(){
    int n,y,x;
    cin>>n;
    vector<pll> a;
    for(int i=0;i<n;i++){
        cin>>x;
        a.push_back({x,i});
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++){
        cout<<a[i].S+1<<" ";
    }
}
        
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //int n; cin>>n; for(int i=0;i<n;i++)
        solve();
    return 0;
}

Measured memory_bytes: 2544
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;

char s[200];

void solve(){
	cin>>s+1;
	if(s[3]==s[4] && s[5]==s[6]) cout<<"Yes\n";
	else cout<<"No\n";
}

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

Measured memory_bytes: 256
#include <iostream>
    using namespace std;
     
    int main() {
    		int n,a,b;
    	cin>>n;
    	if (n==1){
    		cout<<"Hello World"<<endl;
    	}
    	if (n==2){
    		cin>>a>>b;
    		cout<<a+b<<endl;
    	}
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e5+9;
 
int main()
{   
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,q,x,y,sum=0;
    map<int,int>cnt;
    cin>>n;
    for(int i=0;i<n;i++){ 
        cin>>x;
        sum+=x;
        cnt[x]++;
    }
    cin>>q;
    while(q--){ 
        cin>>x>>y;
        sum-=x*cnt[x];
        sum+=cnt[x]*y;
        cnt[y]+=cnt[x];
        cnt[x]=0;
        cout<<sum<<'\n';
    }
}



Measured memory_bytes: 7972
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main(void){
    int a,b;
    cin >> a >> b;
    
    int res;
    if(a>b){
        res = a*2 - 1;
    }else if(a<b){
        res = b*2 - 1;
    }else{
        res = a*2;
    }
    
    cout << res << endl;
    
}


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

int main()
{
	int i=0,num[6],onum=-1;
	char order[100],c;	
	cin>>num[0]>>num[1]>>num[2]>>num[3]>>num[4]>>num[5];
	while(scanf("%c",&c)!=EOF){   
        order[i]=c;
        i++;
		onum++;
    }
	for(i=0;i<=onum;i++){
		if(order[i]=='E'){
			swap(num[0],num[3]);
			swap(num[2],num[3]);
			swap(num[3],num[5]);
		}
		if(order[i]=='W'){
			swap(num[0],num[2]);
			swap(num[2],num[3]);
			swap(num[2],num[5]);
		}
		if(order[i]=='S'){
			swap(num[0],num[1]);
			swap(num[0],num[4]);
			swap(num[4],num[5]);
		}
		if(order[i]=='N'){
			swap(num[0],num[1]);
			swap(num[1],num[4]);
			swap(num[1],num[5]);
		}
	}
	cout<<num[0]<<endl;
    return 0;
}

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

using namespace std;

int main() {
  int N;
  cin>>N;
  int K;
  cin>>K;
  int counter=0;
  for(int i=0; i<N; i++) {
      int tall;
      cin>> tall;
      if(tall>=K){
         counter++; 
      }
  }
  cout<<counter;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int r;
  cin >> r;
  printf("%5f\n", 2 * r * M_PI);
  return 0;
}


Measured memory_bytes: 3760
n = gets.to_i
h = gets.split().map(&:to_i)
i = 0

ans = "Yes"
n.times do
  if h[i] > h[i-1]
    h[i] -= 1
  end
  i += 1
end
r = h.sort
if h == r
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 10104
#include "bits/stdc++.h"
using namespace std;
int main()

{
    int A, B;
    cin >> A >>  B;

    if (A >= 13 )
        cout << B << endl;
    else if (13 > A &&  A >= 6 )
        cout << B /2 << endl;
    else 
        cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void hoge(int n, int k, int sm[], int lg[], int s, int l, bool haszero) {
  int z = haszero ? 1 : 0;
  int minvalue = INT_MAX;
  if (k <= s + z) {
    minvalue = sm[k-1-z];
  }
  if (k <= l + z) {
    minvalue = min(minvalue, lg[k-1-z]);
  }
  int startvalue = 0;
  if (k > l+z) {
    startvalue = k-l+z-1;
  }
  for (int i = 0; i < min(s,n-k+1); i++) {
    minvalue = min(minvalue, sm[startvalue+i]*2+lg[k-z-startvalue-i-2]);
    minvalue = min(minvalue, sm[startvalue+i]+lg[k-z-startvalue-i-2]*2);
  }
  cout << minvalue << endl;
}
int main() {
  int n, k, s, l;
  int sm[100000];
  bool haszero = false;
  int lg[100000];
  s=l=0;
  
  cin >> n >> k;
  for(int i =0; i < n; i++) {
    int v;
    cin >> v;
    if (v < 0) {
      sm[s++] = v;
    } else if (v == 0) {
      haszero = true;
    }
    else {
      lg[l++] = v;
    }
  }
  int sm2[100000];
  for(int i = 0; i < s; i++) {
    sm2[i]=sm[s-1-i] * -1;
  }
  if (s < l) {
    hoge(n, k, sm2, lg, s, l, haszero);
  } else {
    hoge(n, k, lg, sm2, l, s, haszero);
  }
  return 0;
}

Measured memory_bytes: 1024
n, k = map(int, raw_input().split())
aa = []
bb = []
for i in range(n):
    a,b = map(int, raw_input().split())
    aa.append(a)
    bb.append(b)

ans = 0

def hoge(x, k):
    xx = x
    if (x & (1 << k)) == 0:
        return x
    for i in range(k):
        x |= (1<<i)
    x -= 1 << k
    return min(xx,x)
        

for j in range(31):
    kk = hoge(k, j)
    res = 0
    for i in range(n):
        if (aa[i]|kk) == kk:
            res += bb[i]
    ans = max(ans, res)

print(ans)

Measured memory_bytes: 14240
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
set<int> si;
int n,k;
int fin = -1;
int s_int(string s){
    return atoi(s.c_str());
}
int check(int n){
    bool ok = 1;
    while(n >= 0){
        if(si.find(n%10) != si.end()){
            return 0;
        }
        n /= 10;
        if(n == 0) break;
    }
    return 1;
}
vector<int> solve(){
    vector<int> ans;
    queue<string> que;
    rep(i,10){
        string s = "";
        s += char('0' + i);
        que.push(s);
    }
    while(1){
        string fa = que.front(); que.pop();
        if(fa.size() > fin) return ans;
        if(!check(s_int(fa))){
            continue;
        }
        if(s_int(fa) >=n){
            if(fin == -1) fin = fa.size(); 
            ans.push_back(s_int(fa));
        }
        rep(i,10){
            que.push(string(fa + char('0' + i)));
        }
    }
}
int main(){
    cout << fixed << setprecision(10);
    cin >> n >> k;
    rep(i,k){
        int x;
        cin >> x;
        si.insert(x);
    }
    vector<int> ans = solve();
    sort(ans.begin(),ans.end());
    cout << ans[0] << endl;
    return 0;
}

Measured memory_bytes: 5236
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>


using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から
#define REP(i,N) for(int j=i;j<N;j++) //iから

typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

#define MOD ((ll)1e+7 + 9)




//cout<<fixed<<setprecision(10);
int main(){
    int n;
    cin>>n;
    int m=111;
    while(m<n){
        m+=111;
    }
    cout<<m<<endl;

    return 0;
}



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

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

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

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

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

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    if (s[0]=='7'||s[1]=='7'||s[2]=='7'){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 3636
# Atcoder ABC 157
# Problem B

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

n = int(input())

for _ in range(n):  #b_n roop
   b = int(input())
   for i in range(3):
    for j in range(3):
      if b == a[i][j]:
        a[i][j] = 0  #make a 0
        
for i in range(3):
    bingo = False
    if sum(a[i]) == 0: #横チェック
     print("Yes")
     exit()
    if sum([a[0][i], a[1][i], a[2][i]]) == 0: #縦チェック
     print("Yes")
     exit()

if sum([a[0][0], a[1][1], a[2][2]]) == 0: #斜めチェック
    print("Yes")
    exit()

if sum([a[2][0], a[1][1], a[0][2]]) == 0: #逆斜めチェック
    print("Yes")
    exit()

#n(Yes)=0のとき
print("No")

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

int main(){
    int n;
    cin >> n;
    int d;
    int moti[101]={};
    for(int i=0;i<n;i++){
        cin >> d;
        moti[d]=1;
    }
    int sum=0;
    for(int i=0;i<=100;i++){
        sum+=moti[i];
    }
    cout << sum << endl;
}



Measured memory_bytes: 256
from collections import defaultdict

def solve(graph, m, brg):
  ans = 0
  for i in range(m):
    if len(graph[i]) == 1 and set(sorted([graph[i][0], i])) not in brg:
      graph[graph[i][0]].remove(i)
      brg.append(set(sorted([graph[i][0], i])))
      ans += 1
  return ans, graph

n, m = map(int, input().split())
graph = defaultdict(list)
for i in range(m):
  a, b = map(int, input().split())
  graph[a-1].append(b-1)
  graph[b-1].append(a-1)

brg = []
ans = 0
result = -1
while result != 0:
  result, graph = solve(graph, m, brg)
  ans += result
print(ans)

Measured memory_bytes: 3444
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val S = in.next
  val rems = new Array[Int](2019)
  rems(0) = 1
  (S.size - 1 to 0 by -1).foldLeft((0, 1)){case ((rem, rem10), i) =>
    val newRem = (rem10 * 10 * (S(i) - '0') % 2019 + rem) % 2019
    rems(newRem) += 1
    (newRem, rem10 * 10 % 2019)
  }
  println(rems.map(n => n * (n - 1) / 2).sum)
}

Measured memory_bytes: 59104
#include <stdio.h>

int cnt=0,m=0;
int G[100];

void insertionSort(int *A,int n,int g){
  int i,j,v;
  for(i=g;i<n;i++){
    v  = A[i];
    j = i - g;
    while(j>=0 && A[j] > v){
      A[j+g] = A[j];
      j = j - g;
      cnt++;
    }
    A[j+g] = v;
  }
}

void shellSort(int *A,int n){
  int i,h=0;
  cnt = 0;
  while(1){
    h=h*3+1;
    if(h>n){
      for(i=0;i<m;i++){
	h=(h-1)/3;
	G[i]=h;
      }
      break;
    }
    m++;
  }

  for(i=0;i<m;i++){
    insertionSort(A,n,G[i]);
  }
  
}

int main(){
  int i,n,A[1000001];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  shellSort(A,n);
  printf("%d\n",m);
  for(i=0;i<m;i++){
    if(i)
      printf(" ");
    printf("%d",G[i]);
  }
  printf("\n%d\n",cnt);
  for(i=0;i<n;i++){
    printf("%d\n",A[i]);
  }
  return 0;
}



Measured memory_bytes: 5760
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll inf = 1e9 + 7;
const ll Mod = 998244353;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

int main(){
  int S; cin >> S;
  cout << S / 3600 << ":" << (S % 3600) / 60 << ":" << S % 60 << endl;
  return 0;
}



Measured memory_bytes: 3100
s=list(input())
a=int(s[0])*10+int(s[1])
b=int(s[2])*10+int(s[3])
if (a>12 or a<1) and (b>12 or b<1):
  print("NA")
elif (a>12 or a<1):
  print("YYMM")
elif (b>12 or b<1):
  print("MMYY")
else:
  print("AMBIGUOUS")


Measured memory_bytes: 3060
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let sx: i64 = sc.get();
    let sy: i64 = sc.get();
    let tx: i64 = sc.get();
    let ty: i64 = sc.get();
    let dx = tx - sx;
    let dy = ty - sy;
    for _ in 0..dx {
        print!("R");
    }
    for _ in 0..dy {
        print!("U");
    } 
    for _ in 0..dx {
        print!("L");
    }
    for _ in 0..dy {
        print!("D");
    } 
    print!("D");
    for _ in 0..dx+1 {
        print!("R");
    }
    for _ in 0..dy+1 {
        print!("U");
    } 
    print!("L");
    print!("U");
    for _ in 0..dx+1 {
        print!("L");
    }
    for _ in 0..dy+1 {
        print!("D");
    } 
    print!("R");
    println!("");
}


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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;


bool comp( pii a, pii b) {
    return a.ff < b.ff;
}


int main() {

    int n, m;
    cin >> n >> m;
    vector<pii> ab(n);

    fo(i, n) cin >> ab[i].ff >> ab[i].ss;

    sort(all(ab), comp);

    ll ans = 0;
    int cont = 0;

    for ( int i = 0; i < n and cont < m; i++ ) {
        ans += min(m - cont, ab[i].ss) * (ll) ab[i].ff;
        cont += min(m - cont, ab[i].ss);
    }

    cout << ans << endl;

    return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()

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

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;
int V, E, start;
int dp[1 << 20][20];
int graph[20][20];

int rec(int ss, int now) {
    if (dp[ss][now] != -1) {
        return dp[ss][now];
    }

    if (ss == (1 << V) - 1 && now == 0) {
        return dp[ss][now] = 0;
    }

    int res = iINF;

    REP(next, V) {
        if ((ss >> next) & 1) {
            continue;
        }
        if (graph[now][next] == -1) {
            continue;
        }

        res = min(res, rec(ss | (1 << next), next) + graph[now][next]);
    }

    return dp[ss][now] = res;
}


int main() { 
    cin >> V >> E;
    memset(graph, -1, sizeof(graph));

    REP(i, E) {
        int s, t, d;
        cin >> s >> t >> d;
        graph[s][t] = d;
    }

    memset(dp, -1, sizeof(dp));

    int ans = rec(0, 0);

    cout << (ans == iINF ? -1 : ans) << endl;

    return 0; 
}


Measured memory_bytes: 85032