akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1=sc.next();
        String s2=sc.next();
        s1 = "?"+s1;
        s2 = "?"+s2;
        int[][] dp= new int[1010][1010];
        int count=0;
        for(int i=0; i<s1.length(); i++) {
        	if(s1.charAt(0)!=s2.charAt(0))
        		dp[i][0]=i+1;
        	else
        		dp[i][0]=i;
        }
        for(int i=0; i<s2.length(); i++) {
        	if(s1.charAt(0)!=s2.charAt(0))
        		dp[0][i]=i+1;
        	else 
        		dp[0][i]=i;
        }
        
        for(int i=1; i<s1.length(); i++) {
        	for(int j=1; j<s2.length(); j++) {
        		
        		if(s1.charAt(i)==s2.charAt(j)) {
        			count=0;
        		}
        		else {
        			count=1;
        		}
        		dp[i][j]=Math.min(dp[i-1][j-1]+count, Math.min(dp[i-1][j]+1, dp[i][j-1]+1));
        	}
        }
        
        System.out.println(dp[s1.length()-1][s2.length()-1]);
	}
}


Measured memory_bytes: 31100
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >>N;
  vector<int>p(N);
  vector<int>c(N);
  for(int i=0;i<N;i++){
    cin>>p.at(i);
    c.at(i)=p.at(i);
  }
  sort(c.begin(),c.end());
  int count=0;
  int atai1=0;
  int atai2=0;
  for(int i=0;i<N;i++){
    if(c.at(i)!=p.at(i)){
      count++;
      if(count==1)atai1=i;
      if(count==2)atai2=i;
    }
    if(count>2){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  if(count==1){
    cout<<"NO"<<endl;
    return 0;
  }
  if(count==0){
    cout<<"YES"<<endl;
    return 0;
  }
  if(p.at(atai2)==c.at(atai1)){
    if(p.at(atai1)==c.at(atai2)){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
  return 0;
}

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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, m;
  cin >> n >> m;
  set<ll> ac;
  map<ll, ll> pn;

  rep(i, m) {
    ll x;
    string s;
    cin >> x >> s;
    if (ac.find(x) != ac.end()) continue;
    if (s == "AC")
      ac.insert(x);
    else
      pn[x]++;
  }

 ll sacon = 0;
 for (auto& x : pn)
   if(ac.find(x.first) != ac.end()) sacon += x.second;
 
  cout << ac.size() << " " << sacon << endl;

  return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n),b(n-1);
    for (int i = 0; i < n - 1; i++) {
        cin >> b.at(i);
    }

    a.at(0) = b.at(0);
    a.at(1) = b.at(0);

    for (int i = 1; i < n - 1; i++) {
        if (a.at(i) > b.at(i)) {
            a.at(i) = b.at(i);
        }
        a.at(i+1) = b.at(i);
    }

    int count = 0;
    for (int i = 0; i < n; i++) {
        count += a.at(i);
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> s(h);
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}

	vector<vector<int>> ans(h, vector<int>(w));
	vector<bool> f(h);
	int ichigo = 1;
	int p = -1;
	for (int i = 0; i < h; i++) {
		p = -1;
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#') {
				f[i] = true;
				for (int k = p + 1; k <= j; k++) {
					ans[i][k] = ichigo;
				}
				ichigo++;
				p = j;
			}
		}
		if (f[i]) {
			for (int k = p + 1; k < w; k++) {
				ans[i][k] = ichigo - 1;
			}
		}
	}

	for (int i = 1; i < h; i++) {
		if (!f[i] && f[i - 1]) {
			f[i] = true;
			for (int j = 0; j < w; j++) {
				ans[i][j] = ans[i - 1][j];
			}
		}
	}

	for (int i = h - 2; i >= 0; i--) {
		if (!f[i] && f[i + 1]) {
			f[i] = true;
			for (int j = 0; j < w; j++) {
				ans[i][j] = ans[i + 1][j];
			}
		}
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << ans[i][j] << (j == w - 1 ? "" : " ");
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
using namespace std;
int main() {
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i < n; i++) {
        ans += (n - 1) / i;
    }
    cout << ans << endl;
}

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}
P projection(const L &l, const P &p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}
double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}
double distanceSS(const L &s, const L &t) {
  if (intersectSS(s, t)) return 0;
  return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
             min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}
typedef vector<P> G;

bool contains(const P p, const G g) {
  REP(i,g.size())
    if (ccw(g[i],g[(i+1)%g.size()], p) != -1)
      return 0;
  return 1;
}

int main() {
  int n;
  while(cin>>n,n) {
    int sx,sy,ex,ey;
    cin>>sx>>sy>>ex>>ey;
    P s(sx,sy), e(ex,ey);
    L l(s,e);
    G rect[n];
    int h[n];
    bool f = 0;
    REP(i,n) {
      int x1,y1,x2,y2;
      cin>>x1>>y1>>x2>>y2>>h[i];
      rect[i].push_back(P(x1,y1));
      rect[i].push_back(P(x1,y2));
      rect[i].push_back(P(x2,y2));
      rect[i].push_back(P(x2,y1));

      REP(j,4) {
        if (intersectSS(l, L(rect[i][j], rect[i][(j+1)%4]))) // R[XãÉubNª éB
          f = 1;
      }
      if (contains(s,rect[i]))  // ubNªR[XðÜÞB
        f = 1;
    }
    if (f) {
      puts("0.0000");
//      cout << 0 << endl;
      continue;
    }
    double ans = INF;

    // R[XÆubNÌÓÆÌ£ÌÅZðßéB
    REP(i,n) {
      REP(j,4) {
        double d = distanceSS(l, L(rect[i][j], rect[i][(j+1)%4]));
        if (h[i] >= d)
          ans = min(ans, d);
        else
          ans = min(ans, (d*d+h[i]*h[i])/(2*h[i]));
      }
    }
    printf("%.5f\n", ans);
    
  }
}

Measured memory_bytes: 0
#include<stdio.h>

#define N 2000000000

int n;
int count=0;
int A[500000];

void merge(int A[], int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1];
    int R[n2];
    for(int i=0; i<n1; i++){
        L[i] = A[left+i];
    }
    for(int i=0; i<n2; i++){
        R[i] = A[mid+i];
    }
    L[n1]=N;
    R[n2]=N;
    int i=0;
    int j=0;

    for(int k=left; k<right; k++){
        count++;
        if(L[i] <= R[j]){
            A[k] = L[i];
            i++;
        }
        else{
            A[k] = R[j];
            j++;
        }
    }
}

void mergeaSort(int A[], int left, int right){
    int mid;
    if(left+1 < right){
        mid = (left+right)/2;
        mergeaSort(A, left, mid);
        mergeaSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main(void){
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d", &A[i]);
    }

    mergeaSort(A, 0, n);

    for(int i=0; i<n-1; i++){
        printf("%d ", A[i]);
    }
    printf("%d\n",A[n-1]);

    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 5668
//4??¬??????????????????????????¢???3?????????????????°Yes -> ??¨????????????????????????, 4????????°???????£????????????°??????
#include <iostream>
using namespace std;

int cnt[101];

int main() {
	int i, e;
	
	for (i = 0; i < 12; i++) { cin >> e; cnt[e]++; }
	for (i = 0; i < 101; i++) { if (cnt[i] % 4 != 0) { cout << "no" << endl; return 0; } }
	cout << "yes" << endl;
	return 0;
}

Measured memory_bytes: 3040
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,n,sum,y;
  	cin>>x>>n;
  	sum = 0;
  	vector<int> v(n);
  	for(int i=0;i<n;i++)
    {
      cin>>y;
      sum+=y;
    }
  	if(sum>=x)
      cout<<"Yes";
  	else
      cout<<"No";
  	return 0;
}


Measured memory_bytes: 640
%:pragma GCC optimize("Ofast")
  %:pragma GCC optimize("inline")
#include <bits/stdc++.h>
  #define int long long
#define rint register int
  using namespace std;

template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
int a, b, c, d, n;
main(void) {
  read(a); read(b); read(c); read(d); read(n);
  n *= 4;
  b = min(b, 2 * a);
  c = min(c, 2 * b);
  d = min(d, 2 * c);
  int ans = 0;
  ans += (n / 8) * d;
  // cout << ans << " " << n << "\n";
  n = n % 8;
  ans += (n / 4) * c;
  // cout << ans << " " << n << "\n";
  n = n % 4;
  ans += (n / 2) * b;
  n = n % 2;
  ans += (n / 1) * a;
  n = n % 1;
  cout << ans << "\n";
  
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vec vector
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
	ll n;

	cin >> n;

	cout << "ABC" << n;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> g[200002], v[3];
vector<int> D[200002];

int sz[3];
int val[200002];

int dfs(int u, int p, int d){
    D[d%2].emplace_back(u);
    for(int i=0;i<g[u].size();i++){
        int v = g[u][i];
        if(v == p) continue;
        dfs(v, u, d+1);
    }
}
int main(){
    int n, a, b;
    scanf("%d", &n);
    for(int i=1;i<=n-1;i++){
        scanf("%d%d", &a, &b);
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }   
    for(int i=1;i<=n;i++) v[i%3].emplace_back(i);
    dfs(1, 0, 0);
    for(int i=0;i<n;i++) sz[i] += D[i].size();

    if(sz[0] > sz[1]) swap(sz[0], sz[1]), swap(D[0], D[1]);
    if(sz[0] <= v[0].size()){
        for(int i=0;i<D[0].size();i++){
            int u = D[0][i];
            val[u] = v[0].back();
            v[0].pop_back();
        }
        for(int i=0;i<D[1].size();i++){
            int u = D[1][i];
            if(v[0].size() != 0){
                val[u] = v[0].back();
                v[0].pop_back();
            }
            else if(v[1].size() != 0){
                val[u] = v[1].back();
                v[1].pop_back();
            }
            else{
                val[u] = v[2].back();
                v[2].pop_back();   
            }
        }
    }
    else{
        for(int i=0;i<D[0].size();i++){
            int u = D[0][i];
            if(v[1].size() != 0){
                val[u] = v[1].back();
                v[1].pop_back();
            }
            else{
                val[u] = v[0].back();
                v[0].pop_back();   
            }
        }
        for(int i=0;i<D[1].size();i++){
            int u = D[1][i];
            if(v[2].size() != 0){
                val[u] = v[2].back();
                v[2].pop_back();
            }
            else{
                val[u] = v[0].back();
                v[0].pop_back();   
            }
        }
    }
    for(int i=1;i<=n;i++) printf("%d ", val[i]);
}

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

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REPO(i,n) for(int (i)=1; (i)<=(int)(n); (i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 3e2 + 10, MAX_M = 3e2 + 10, MOD = 1e9 + 7;

int N, M;
vector<pi> Ls[MAX_N];
int Dy[MAX_N][MAX_N][MAX_N];

int main() {
	cin >> N >> M;
	for(int i=0; i<M; i++) {
		int x, y, c; scanf("%d%d%d", &x, &y, &c);
		x+=2;
		y+=2;
		Ls[y].push_back(pi(x, c));
	}
	N+=2;
	for(int i=1; i<=N; i++) {
		sort(ALL(Ls[i]));
		/*
		for(pi &e : Ls[i]) printf("[%d %d] ", e.one, e.two); puts("");

		int nowC = 4;
		vector<pi> list;
		for(int j=0; j<SZ(Ls[i]); j++) {
			if(j+1 < SZ(Ls[i]) && Ls[i][j].two < Ls[i][j+1].two) {
				puts("0");
				return 0;
			}
			if(nowC != Ls[i][j].two) {
				nowC = Ls[i][j].two;
				list.push_back(Ls[i][j]);
			}
		}
		Ls[i].swap(list);

		for(pi &e : Ls[i]) printf("[%d %d] ", e.one, e.two); puts("");
		*/
	}
	Dy[0][1][2] = 1;
	for(int l=3; l<=N; l++) {
		for(int p=0; p<3; p++) {
			pi ix[3] = {pi(0, l-1), pi(0, l-1), pi(0, l-1)};
			ix[p] = pi(l-1, l-1);
			for(int i=ix[0].one; i<=ix[0].two; i++)
				for(int j=ix[1].one; j<=ix[1].two; j++)
					for(int k=ix[2].one; k<=ix[2].two; k++) {
						if(Dy[i][j][k] == 0) continue;
						int ch[3] ={i, j, k};
						for(int o=0; o<3; o++) {
							int temp = ch[o];
							ch[o] = l;
							bool isCan = true;
							for(pi &e : Ls[l]) {
								int now = 0;
								for(int o=0; o<3; o++) if(ch[o] >= e.one) now++;
								if(now != e.two) {
									isCan = false; break;
								}
							}
							if(isCan) {
//								printf("%d %d %d | %d\n", ch[0], ch[1], ch[2], Dy[i][j][k]);
								Dy[ch[0]][ch[1]][ch[2]] += Dy[i][j][k];
								if(Dy[ch[0]][ch[1]][ch[2]] >= MOD) Dy[ch[0]][ch[1]][ch[2]] -= MOD;
							}
							ch[o] = temp;
						}
					}
		}
		/*
		for(int i=0; i<=l; i++) for(int j=0; j<=l; j++) for(int k=0; k<=l; k++)
			if(i == l || j == l || k == l) {
				if(Dy[i][j][k])
					printf("%d %d %d : %d\n", i, j, k, Dy[i][j][k]);
			}
			*/
	}
	int ans = 0;
	for(int i=0; i<=N; i++) for(int j=0; j<=N; j++) for(int k=0; k<=N; k++)
		if(i == N || j == N || k == N) {
			ans += Dy[i][j][k];
			if(ans >= MOD) ans -= MOD;
		}
	printf("%d\n", ans);
	return 0;
}

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

int main()
{
    int h, w, k;
    cin >> h >> w >> k;

    vector<string> f(h);
    rep (i, h)
        cin >> f[i];

    int ans = 0;
    rep (bit, 1 << h + w)
    {
        int cnt = 0;
        vector<vector<bool>> ok(h, vector<bool>(w, false));
        rep (i, h + w)
        {
            if (i < h)
            {
                rep (j, w)
                {
                    if (bit & (1 << i))
                        ok[i][j] = true;
                }
            }
            else
            {
                rep (j, h)
                    if (bit & (1 << i))
                    {
                        if (bit & (1 << i))
                            ok[j][i - h] = true;
                    }
            }
        }

        rep (i, h + w)
        {
            if (i < h)
            {
                rep (j, w)
                    if (f[i][j] == '#' && ok[i][j] == false)
                    {
                        cnt++;
                        ok[i][j] = true;
                    }
            }
            else
            {
                rep (j, h)
                    if (f[j][i - h] == '#' && ok[j][i - h] == false)
                    {
                        cnt++;
                        ok[j][i - h] = true;
                    }
            }
        }
        if (cnt == k)
            ans++;
    }

    cout << ans << endl;
    return 0;
}


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

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

	string ans = "No";
	for (int i = 0; i < n.length(); i++) {
		if (n.at(i) == '7') {
			ans = "Yes";
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#define int long long

using namespace std;

signed main() {
  int n, m;
  while(cin >> n >> m, n != 0) {
    vector<int> cs(m);
    for (int i = 0; i < m; i++) {
      cin >> cs[i];
    }
    vector<int> y(n);
    for (int i = 0; i < n; i++) {
      cin >> y[i];
    }
    const int inf = 10000000000ll;
    vector<vector<int>> dp(n+1, vector<int>(256, inf));
    dp[0][128] = 0;
    for (int i=0; i<n; i++){
      for (int k=0; k < 256; k++) {
        for (auto c : cs) {
          int to = k + c;
          to = (to < 0) ? 0 :
               (to > 255) ? 255 :
               to;
          int cost = (to - y[i]) * (to - y[i]);
          dp[i+1][to] = min(dp[i+1][to], dp[i][k] + cost);
        }
      }
    }
    int res = inf;
    for (int k=0; k < 256; k++) {
      res = min(res, dp[n][k]);
    }
    cout << res << endl;
  }
}


Measured memory_bytes: 43704
#include<stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int a[3003];
    int i;
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
    int ans = 0;
    for (i = 0; i < n; i++)
        ans += a[i];
    ans -= n;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 mod=1e9+7;
const int INF=1001001001;

int main() {
  int N,M;
  cin>>N>>M;
  vector<int>X(M);
  for(int i=0;i<M;i++){
    cin>>X[i];
  }
  sort(X.begin(),X.end());
  vector<int>dis;
  for(int i=1;i<M;i++){
    dis.push_back(X[i]-X[i-1]);
  }
  sort(dis.rbegin(),dis.rend());
  int sum=0;
  for(int i=N-1;i<dis.size();i++){
    sum+=dis[i];
  }
  cout<<sum<<endl;
  return 0;  
}

Measured memory_bytes: 4256
def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table
 
 
 
n = int(input())
a = num_divisors_table(n)
ans = 0
 
for i in range(1, n + 1):
    ans += a[i] * i
print(ans)

Measured memory_bytes: 151708
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 105;
const ll LINF = 1e18 + 5;
int n, p[N], a, b;
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n;
 	cin >> a >> b;
 	int x = 0, y = 0, z = 0;
 	for(int i=1; i<=n; i++)
 	{
 		cin >> p[i];
 		if(p[i]<=a) x++;
 		else if(p[i]<=b) y++;
 		else z++;
 	}
 	int res = min(x, min(y, z));
 	cout << res;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
B = list(map(int, input().split()))
S = B[0] + B[N-2]
i = 0
while i <= N-3:
    if B[i] > B[i+1]:
        S += B[i+1]
    else:
        S += B[i]
    i += 1
print(S)

Measured memory_bytes: 9048
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
	ios_base::sync_with_stdio(0);
  	cin.tie(NULL); 

  	int a, b;
  	cin >> a >> b;

 	if(a != 1 and b != 1) cout << 1 << '\n';
 	else if(a != 2 and b != 2) cout << 2 << '\n';
 	else cout << 3 << '\n';
  
  	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
template <class... T> void printd(T&&...){ }
#endif

int b1[201][201], b2[201][201];

int main(){
    int n, ma, mb;
    cin >> n >> ma >> mb;
    vector<int> as(n), bs(n), cs(n);
    for(int i=0;i<n;i++){
        cin >> as[i] >> bs[i] >> cs[i];
    }
    for(int i=0;i<201;i++){
        for(int j=0;j<201;j++){
            b1[i][j] = b2[i][j] = M;
        }
    }
    for(int i=0;i<(1<<(n/2));i++){
        int suma = 0, sumb = 0, sumc = 0;
        for(int j=0;j<n/2;j++){
            if(i & (1 << j)){
                suma += as[j];
                sumb += bs[j];
                sumc += cs[j];
            }
        }
        b1[suma][sumb] = min(b1[suma][sumb], sumc);
    }
    for(int i=0;i<(1<<(n - n/2));i++){
        int suma = 0, sumb = 0, sumc = 0;
        for(int j=0;j<n - n/2;j++){
            if(i & (1 << j)){
                suma += as[j + n/2];
                sumb += bs[j + n/2];
                sumc += cs[j + n/2];
            }
        }
        b2[suma][sumb] = min(b2[suma][sumb], sumc);
    }
    // for(int i=0;i<20;i++){ for(int j=0;j<20;j++){ cout << b1[i][j] << ' '; } cout << '\n'; }
    // prints(321);
    // for(int i=0;i<20;i++){ for(int j=0;j<20;j++){ cout << b2[i][j] << ' '; } cout << '\n'; }
    int ans = M;
    for(int i=0;i<201;i++){
        for(int j=0;j<201;j++){
            if(b1[i][j] == M){ continue; }
            for(int k=0;k<201;k++){
                for(int l=0;l<201;l++){
                    if(i + j + k + l == 0){ continue; }
                    if(b2[k][l] == M){ continue; }
                    if((i + k) * mb == (j + l) * ma){
                        ans = min(ans, b1[i][j] + b2[k][l]);
                    }
                }
            }
        }
    }
    cout << (ans == M ? -1 : ans) << '\n';
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;



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

    string s;
    int k;
    set<string> se;
    cin >> s >> k;
    rep(i,s.length()){
        rep(j,6){
            string b = s.substr(i,j);
            se.insert(b);
        }
    }
    int i = 0;
    for(auto va:se){
        i++;
        if(i == k+1)cout << va << endl;
    }

    cout << endl;
    return 0;
}


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

using namespace std;

const int mod = 1007050321;
const int base = 521;
const int N = 2e5 + 5;
const int MOD = 1e9 + 7;
const int inf = 2e9;

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

    int n,m,a[1005];
    cin >> n >> m;

    int cnt = 0,sum = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    int x;
    x = (sum+4*m-1)/4/m;
    bool ok = true;
    for (int i = 1; i <= n; ++i) {
        if (a[i] >= x)
            cnt++;
    }
    if (cnt >= m)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int cnt = 0;
        int maxCnt = 0;
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            cnt = 0;
            int divided = i;
            while (true) {
                if (divided % 2 != 0) {
                    break;
                } else {
                    divided = divided / 2;
                    cnt++;
                }
                if (cnt > maxCnt) {
                    maxCnt = cnt;
                    ans = i;
                }
            }
        }
        if (n == 1) {
            System.out.println(1);
        } else {
            System.out.println(ans);   
        }
    }
}


Measured memory_bytes: 21844
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
	int n,m,x,y;
	int ma=-1000,mi=1000,tem;
	int i;
	scanf("%d%d%d%d", &n, &m, &x, &y);
	for(i=0; i<n; i++)
	{
		scanf("%d", &tem);
		ma = max(tem, ma);
	}
	for(i=0; i<m; i++)
	{
		scanf("%d", &tem);
		mi = min(tem, mi);
	}
	if(mi>=y || ma<=x || mi<=ma)
		printf("War\n");
	else
		printf("No War\n");
	return 0;
}

Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    s = s_input()
    t = s_input()

    count = 0

    for i in range(len(s)):
        if s[i] != t[i]:
            count += 1

    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 73512
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);



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

	int N, C;
	cin >> N >> C;

	vector<vector<int>>D(C, vector<int>(C, 0));
	rep(i, C)rep(j, C)cin >> D[i][j];

	vector<vector<int>>colorpop(3, vector<int>(C, 0));
	rep(i, N)rep(j, N) {
		int c;
		cin >> c;
		colorpop[(i + j) % 3][c - 1]++;
	}
	int ans = intmax;
	rep(i, C)rep(j, C)rep(k, C)if (i != j&&j != k&&k != i) {
		int score = 0;
		rep(a, C) {
			score += colorpop[0][a] * D[a][i];
			score += colorpop[1][a] * D[a][j];
			score += colorpop[2][a] * D[a][k];
		}
		ans = min(ans, score);
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
int main(){
    int n;
    std::vector<int> v(3000);
    int sum=0;
    std::cin >> n;
    for(int i=0; i<n; i++) {
        std::cin >> v[i];
        sum += v[i];
    }

    std::cout << sum-n << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

	for (int i = 0; i < S.length(); i++) {
		if (i % 2 == 0) {
			if (S[i] == 'L') {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			if (S[i] == 'R') {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;

}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD = 1000000007
INF = float("inf")

sys.setrecursionlimit(1000000)

class BIT:
    def __init__(self, li):
        self.n, self.data = len(li) + 1, [0] + li
        for i in range(1, self.n):
            if i + (i & -i) < self.n: self.data[i + (i & -i)] += self.data[i]

    def add(self, i, a):
        i += 1
        while i < self.n:
            self.data[i] += a
            i += i & -i

    # sum of [0, i)
    def acc(self, i):
        res = 0
        while i > 0:
            res += self.data[i]
            i -= i & -i
        return res

    # sum of [l, r)
    def get(self, l, r = None):
        if r is None: r = l+1
        res = 0
        # return self.acc(r) - self.acc(l)

        while l < r:
            res += self.data[r]
            r -= r & -r
        while r < l:
            res -= self.data[l]
            l -= l & -l
        return res


def main():
    N, Q = LI()
    A = LI()
    query = LIR(Q)
    bit = BIT(A)
    # print([bit.get(i) for i in range(N)])

    for a, b, c in query:
        if a == 0:
            bit.add(b, c)
        else:
            print(bit.get(b, c))
        # print([bit.get(i) for i in range(N)])




if __name__ == '__main__':
    main()

Measured memory_bytes: 180104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A;
  cin >> N >> A;
  if(N % 500 == 0){
    cout << "Yes" << endl;
  }else if(N % 500 <= A){
  	cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n,m = map(int, input().split(' '))
h = list(map(int, input().split(' ')))
a = [list(map(int, input().split(' '))) for _ in range(m)]

res = [set() for _ in range(n)]

for i,j in a:
    res[i-1].add(j-1)
    res[j-1].add(i-1)
ans = 0
res = [j if j != set() else set([i]) for i,j in enumerate(res)]
for i in range(n):
    for j in res[i]:
        if i == j:
            ans += 1
            break
        if h[i] <= h[j]:
            break
    else:
        ans += 1
print(ans)

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

using namespace std;

int main(){
        string s;
        cin>>s;
        bool res=false;
        for(int i=0;i<(int)s.length()-1;i++){
                if(s[i]=='A'&&s[i+1]=='C'){
                        res=true;
                }
        }
        if(res){
                cout<<"Yes"<<endl;
        }
        else{
                cout<<"No"<<endl;
        }
        return 0;
}


Measured memory_bytes: 256
N = int(input())
X = input()
ans = 0
r=0
g=0
b=0
G = []
R = []
B = []
for i in range(0,N):
    if(X[i] == 'G'):
        G.append(i)
        g+=1
for k in range(0,N):
    if(X[k] == 'R'):
        R.append(k)
        r+=1
for j in range(0,N):
    if(X[j] == 'B'):
        B.append(j)
        b+=1
ans = r*b*g
for i in range(0,N):
    for j in range(i+1,N):
        if(2*j-i < N) and X[i] != X[j]:
            if(X[2*j-i] != X[i]) and (X[2*j-i] != X[j]):
                ans -= 1
print(ans)

Measured memory_bytes: 73808
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a * b // gcd(a, b)

n = int(input())

res = 1

for _ in range(n):
    x = int(input())
    res = lcm(res, x)

print(res)

Measured memory_bytes: 3060
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    long a=sc.nextLong();
    long b=sc.nextLong();
    long k=sc.nextLong();

    if (a+b<=k) {
      a=0;
      b=0;
    }else{
      if (a>=k) {
        a-=k;
      }else{
        b=b-(k-a);
        a=0;
      }
    }

    System.out.println(a+" "+b);
  }
}


Measured memory_bytes: 23380
//                          **********  YATIN KWATRA  ********** 

//AC bakshi Rabha

#include <bits/stdc++.h>
#define ll                      long long 
#define ull                     unsigned long long 
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                      vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                      unordered_map                
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int> 
#define pll                     pair<long,long>
#define mll                     map<long,long>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define mod                     1000000007
// #define node                    Node

using namespace std;

void INPUT() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

}

#define pi 3.14159265358979323846
void solve()
{ 
   ll ln,lm,h,m;
   cin >> ln >> lm >> h >> m;

    if (h == 12LL) h = 0;  
    if (m == 60LL) m = 0;  
  

    long double hour_angle = 0.5 * (h * 60 + m);  
    long double minute_angle = 6 * m;  
   
    long double angle = abs(hour_angle - minute_angle);  
    angle = min(360 - angle, angle);  

   long double v = (long double)(cos((long double)(pi*angle)/180));
   v*= double(ln*lm);
   v*= double(2);
   long double ans = sqrt(ln*ln + lm*lm - v );
    
    cout << fixed << setprecision(20);
    cout << ans << endl;
       
}
int main() {
    
    FIO
  //  INPUT();
    
    int t;
    t = 1;
    //cin >> t;
    
    while(t--)
    {

       solve();
    }
    return 0;
}


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

#define PB push_back
#define SZ(c) int((c).size())
#define ALL(c) (c).begin(), (c).end()
#define CONTAINS(c, x) ((c).find(x) != (c).end())
#define REP(i, n) for(int i=1; i<=n; i++)
#define WAIT cout<<flush, system("PAUSE");
using namespace std;
const int MAX = 200100;

int N, A, B, u, v;
set<int> E[MAX], F[MAX];
int D[MAX], P[MAX], sol;
bool ok[MAX], used[MAX], escape;

void DFS(int n){
	for(auto x: F[n]) if (x!=P[n]){
		P[x] = n;
		D[x] = D[n] + 1;
		DFS(x);
	}
}

void DFS2(int n, int d){
	if (D[n] <= d) return;
	used[n] = true;
	sol = max(sol, D[n]);
	if (ok[n]) escape = true;
	
	for(auto x: E[n]) if (!used[x]){
		DFS2(x, d+1);
	}
}

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

	cin >> N >> A >> B;
	REP(I, N-1){
		cin >> u >> v;
		E[u].insert(v);
		E[v].insert(u);
	}
	
	REP(I, N-1){
		cin >> u >> v;
		F[u].insert(v);
		F[v].insert(u);
	}
	
	P[B] = D[B] = 0;
	DFS(B);
	
	REP(u, N) for(auto v: E[u])
	if (CONTAINS(F[u], v) || CONTAINS(F[v], u) || CONTAINS(F[ P[u] ], v) || CONTAINS(F[ P[v] ], u))
		;
	else ok[u] = ok[v] = true;
	
	//REP(I, N) if (ok[I]) cout << I << " ";
	//cout << endl;
	//REP(I, N) cout << D[I] << " ";
	//cout << endl;
	
	DFS2(A, 0);
	if (escape) sol = -1;
	else        sol *= 2;
	cout << sol << endl;
}

















Measured memory_bytes: 66688
#include <stdio.h>

int main()
{
	int N, M, K;
	scanf("%d %d %d", &N, &M, &K);
	
	int i, j, flag[1000001] = {1};
	for (i = 0; i <= N; i++) {
		for (j = 0; j <= M; j++) flag[i * M + j * N - i * j * 2] = 1;
	}
	
	if (flag[K] == 1) printf("Yes\n");
	else printf("No\n");
	
	fflush(stdout);
	return 0;
}

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

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

int digit=0;
for(int i=0;i<S.size();i++){
int ai=S.at(i)- '0';
digit=digit+ai;
}
if(digit%9==0){
cout<<"Yes"<<endl;
}else{
cout<<"No"<<endl;
}

}
  

Measured memory_bytes: 3716
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m,f,r,s;
        String g;
        while(true){
            m=sc.nextInt();
            f=sc.nextInt();
            r=sc.nextInt();
            if(m==-1&&f==-1&&r==-1){
                break;
            }
            s=m+f;
            if(m==-1 || f==-1 || s<30){
                g="F";
            }else if(s>=80){
                g="A";
            }else if(s>=65){
                g="B";
            }else if(s>=50 || r>=50){
                g="C";
            }else{
                g="D";
            }
            System.out.println(g);
        }
        sc.close();
    }
}


Measured memory_bytes: 26256
import java.util.LinkedList;
import java.util.Scanner;
 
 
public class Main{
     
	public static final int DIRS = 4;
	
	public static final int NORTH = 0;
	public static final int EAST  = 1;
	public static final int SOUTH = 2;
	public static final int WEST  = 3;
	public static final String[] dir_str = new String[]{"N", "E", "S", "W"};
	
	public static final int[] vx = new int[]{0, 1, 0, -1};
	public static final int[] vy = new int[]{-1, 0, 1, 0};
	
	
    public static void main(String[] args){
    	
    	final Scanner sc = new Scanner(System.in);
    	
    	while(true){
    		final int H = sc.nextInt();
    		final int W = sc.nextInt();
    		final long L = sc.nextLong();
    		
    		if(H == 0 && W == 0 && L == 0){
    			break;
    		}
    		
    		int sx = -1;
    		int sy = -1;
    		int sdir = -1;
    		boolean[][] is_wall = new boolean[H][W];
    		for(int i = 0; i < H; i++){
    			char[] inputs = sc.next().toCharArray();
    			
    			for(int j = 0; j < W; j++){
    				if(inputs[j] == '#'){
    					is_wall[i][j] = true;
    				}else if(inputs[j] == 'N'){
    					sx = j;
    					sy = i;
    					sdir = NORTH;
    				}else if(inputs[j] == 'E'){
    					sx = j;
    					sy = i;
    					sdir = EAST;
    				}else if(inputs[j] == 'S'){
    					sx = j;
    					sy = i;
    					sdir = SOUTH;
    				}else if(inputs[j] == 'W'){
    					sx = j;
    					sy = i;
    					sdir = WEST;
    				}
    			}
    		}
    		
    		long[][][] visit_time = new long[H][W][DIRS];
    		for(int i = 0; i < H; i++){
    			for(int j = 0; j < W; j++){
    				for(int k = 0; k < DIRS; k++){
    					visit_time[i][j][k] = -1;
    				}
    			}
    		}
    		int x = sx;
    		int y = sy;
    		int dir = sdir;
    		long time = 0;
    		
    		while(time < L){
    			//System.out.println(x + " " + y + " " + dir + " " + time);
    			
    			if(visit_time[y][x][dir] >= 0){
    				final long diff_time = time - visit_time[y][x][dir];
    				time += ((L - time) / diff_time) * diff_time;
    				
    				if(time >= L){
    					break;
    				}
    				
    				for(int i = 0; i < H; i++){
    	    			for(int j = 0; j < W; j++){
    	    				for(int k = 0; k < DIRS; k++){
    	    					visit_time[i][j][k] = -1;
    	    				}
    	    			}
    	    		}
    			}
    			
    			visit_time[y][x][dir] = time;
    			
    			for(int offset = 0; offset < DIRS; offset++){
    				final int ndir = (dir + offset) % 4;
    				final int nx = x + vx[ndir];
    				final int ny = y + vy[ndir];
    				
    				if(nx < 0 || nx >= W || ny < 0 || ny >= H){
    					continue;
    				}if(is_wall[ny][nx]){
    					continue;
    				}else{
    					x = nx;
    					y = ny;
    					dir = ndir;
    					time++;
    					
    					break;
    				}
    			}
    		}
    		//System.out.println(time);
    		System.out.println((y + 1) + " " + (x + 1) + " " + dir_str[dir]);
    		
    	}
    }
     
}

Measured memory_bytes: 38156
from bisect import bisect_left

N=int(input())
A=list(map(int,input().split()))
A=sorted(A)

idx = bisect_left(A,0)
if idx != 0 and idx != N:
  if idx % 2 == 1:
    if abs(A[idx-1]) > abs(A[idx]):
      A[idx-1] *= -1
      A[idx] *= -1
  for i in range(0,idx-1,2):
    A[i] *= -1
    A[i+1] *= -1

if idx==N:
  if N % 2 == 0:
    print(-sum(A))
    exit()
  else:
    print(-sum(A[:-1])+A[-1])
    exit()

print(sum(A))

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


int main(){
    ios_base::sync_with_stdio(0);
    int N;
    cin >> N;
    vector <vector <long long> > tab;
    vector <vector <long long> > DP;
    tab.resize(N, vector <long long>(3));
    DP.resize(N, vector <long long>(3, 0));
    for (int i = 0; i < N; i++){
        for (int j = 0; j < 3; j++){
            cin >> tab[i][j];
        }
    }
    DP[0][0] = tab[0][0];
    DP[0][1] = tab[0][1];
    DP[0][2] = tab[0][2];
    for (int i = 1; i < N; i++){
        DP[i][0] = max(DP[i-1][1], DP[i-1][2]) + tab[i][0];
        DP[i][1] = max(DP[i-1][0], DP[i-1][2]) + tab[i][1];
        DP[i][2] = max(DP[i-1][0], DP[i-1][1]) + tab[i][2];
    }
    long long Res = 0;
    for (int j = 0; j < 3; j++){
        Res = max(Res, DP[N-1][j]);
    }
    cout << Res << "\n";
}

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

int main(){
  int x, y;
  cin >> x >> y;
  int ans = 0;
  if(x <= 3) ans += (4-x) *100000;
  if(y <= 3) ans += (4-y) *100000;
  if(x == 1 && y == 1) ans += 400000;
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
  unsigned long long W, H;
  std::cin >> W >> H;
  std::vector<unsigned> p(W);
  std::vector<unsigned> q(H);
  for (auto &i : p) {
    std::cin >> i;
  }
  for (auto &i : q) {
    std::cin >> i;
  }
  std::sort(p.rbegin(), p.rend());
  std::sort(q.rbegin(), q.rend());
  unsigned long long cost = 0ull;
  ++H;
  ++W;
  while (W > 1 || H > 1) {
    if (p.size() == 0) {
      cost += q.back() * W;
      --H;
      q.pop_back();
    } else if (q.size() == 0) {
      cost += p.back() * H;
      --W;
      p.pop_back();
    } else {
      if (p.back() < q.back()) {
        cost += p.back() * H;
        --W;
        p.pop_back();
      } else {
        cost += q.back() * W;
        --H;
        q.pop_back();
      }
    }
  }
  std::cout << cost;
  return 0;
}

Measured memory_bytes: 1024
d = int(input())
c = list(map(int,input().split()))
like=0
but=0
s=[]
last=[]
show=''
for i in range(26):
    last.append(0)
for i in range(d):
    keys=list(map(int,input().split()))
    s.append(keys)
for  i in range(365):
    print(26)


Measured memory_bytes: 9508
N, K = map(int, input().split())
P = list(map(int, input().split()))

def expect(p):
  return (1+p)/2

tmp = sum([expect(p) for p in P[:K]])
maxV = tmp
for i in range(N-K):
  tmp -= expect(P[i]) 
  tmp += expect(P[i+K])
  maxV = max(maxV, tmp)
print(maxV)

Measured memory_bytes: 25060
#include<iostream>
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
#include <numeric>
#include<deque>
#include<queue>
#include<string>
#include <iomanip>

using namespace std;
typedef long long ll;

int main(void){
    int n, k;
    cin>>n>>k;
    vector <int> h(n);
    rep(i, n){
        int s;
        cin>>s;
        h[i]=s;
    }
    int ans=0;
    rep(i, n){
        if(h[i]>=k){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
 
using namespace std;
 
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 ll INF=1e9+7;

int main(){
    ll n;
    cin >> n;
    vector<ll> l(n);
    rep(i,n){
        cin >> l[i];
    }
    sort(l.begin(),l.end());
    ll ans=0;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            auto it=lower_bound(l.begin(),l.end(),l[i]+l[j])-l.begin();
            ans+=max(0LL,it-1-j);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll=long long;

int main(){
    ll n,i,k;
    string s;
    cin>>s;
    (s[2]==s[3] && s[4]==s[5]) ? cout<<"Yes" : cout<<"No";
    return 0;
}


Measured memory_bytes: 256