akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

using namespace std;

class Point {
    public:
    double x, y;
    
    Point(double x = 0, double y = 0): x(x), y(y) {}
    
    Point operator + (Point p) {return Point(x + p.x, y + p.y); }
    Point operator - (Point p) {return Point(x - p.x, y - p.y); }
    Point operator * (double a) {return Point(a * x, a * y); }
    Point operator / (double a) {return Point(x / a, y / a); }
    
    double abs() { return sqrt(norm()); }
    double norm() { return x * x + y * y; }
    
    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }
    
    bool operator == (const Point &p) const {
        return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS; 
    }
};

struct Segment {
    Point p1, p2;
};

typedef Segment Line;

class Circle {
    public:
    Point c;
    double r;
    Circle(Point c = Point(), double r = 0.0): c(c), r(r) {}
};

typedef Point Vector;

double norm(Vector a) {
    return a.x * a.x + a.y * a.y;
}

double abs(Vector a) {
    return sqrt(norm(a));
}

double dot(Vector a, Vector b) {
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
    return a.x * b.y - a.y * b.x;
}

bool isOrthogonal(Vector a, Vector b) {
    return equals(dot(a, b), 0.0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) {
    return isOrthogonal(a1 - a2, b1 - b2);
}

bool isOrthogonal(Segment s1, Segment s2) {
    return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

bool isParallel(Vector a, Vector b) {
    return equals(cross(a, b), 0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2) {
    return isParallel(a1 - a2, b1 - b2);
}

bool isParallel(Segment s1, Segment s2) {
    return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

Point project(Segment s, Point p) {
    Vector base = s.p2 - s.p1;
    double r = dot(p - s.p1, base) / norm(base);
    return s.p1 + base * r;
}

int main() {
    int n;
    double x1, y1, x2, y2, x, y;
    Segment s;
    cin >> x1 >> y1 >> x2 >> y2;
    s.p1 = Point(x1, y1); s.p2 = Point(x2, y2);
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> x >> y;
        Point p = project(s, Point(x, y));
        cout << fixed << setprecision(10) << p.x
        << " " << fixed << setprecision(10) << p.y << endl;
    }
    
    return 0;
}


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

int main(){
  ll n, q;
  cin >> n >> q;
  vector<ll> a(n), b(n);
  vector<ll> p(q+1), x(q+1);
  for(ll i=1; i<n; i++) cin >> a[i] >> b[i];
  for(ll i=1; i<q+1; i++) cin >> p[i] >> x[i];
  
  vector<vector<ll>> v(n+1);
  for(ll i=1; i<n; i++){
  	v[a[i]].push_back(b[i]);
  	v[b[i]].push_back(a[i]);
  }
  
  vector<ll> r(n+1, 0);
  for(ll i=1; i<q+1; i++) r[p[i]] += x[i];
  
  vector<bool> seen(n+1, false);
  queue<ll> que;
  que.push(1);
  while(!que.empty()){
    ll tmp = que.front();
    que.pop();
    if(seen[tmp]) continue;
    seen[tmp] = true;
    for(auto vp : v[tmp]){
      if(!seen[vp]){
        r[vp] += r[tmp];
        que.push(vp);
      }
    }
  }
  for(ll i=1; i<n+1; i++) cout << r[i] << " ";
  cout << endl;
}

Measured memory_bytes: 24176
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var S = Console.ReadLine();
        var T = new int[S.Length+1];

        var MOD = 2019;
        var m10 = 1;
        for (int i = T.Length - 2; i >= 0; i--)
        {
            T[i] = (T[i + 1] + m10 * (S[i] - '0')) % MOD;
            m10 = m10 * 10 % MOD;
        }

        var s = new int[MOD];
        for (int i = 0; i < T.Length; i++)
        {
            s[T[i]]++;
        }
        Console.WriteLine(s.Select(x => x * (x - 1) / 2).Sum());
    }
}


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

int main() {
	string s;
	cin >> s;
	string divide[4] = { "dream","dreamer","erase","eraser" };
	reverse(s.begin(), s.end());
	int i,j;
	for (i = 0; i < 4; i++) reverse(divide[i].begin(), divide[i].end());

	bool can1 = true;
	for (i = 0; i < s.size();) {
		bool can2 = false;
		for (j = 0; j < 4; j++) {
			string d = divide[j];
			if (s.substr(i, d.size()) == d) {
				can2 = true;
				i += d.size();
			}
		}
		if (!can2) {
			can1 = false;
			break;
		}
	}
	if (can1)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main() {
    int N, maxA = 0, ans = 0;
    cin >> N;
    for (int i = 0, A, B; i < N; i++) {
        cin >> A >> B;
        if (A > maxA) {
            maxA = A;
            ans = A + B;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
#include<cmath>
#include<cstring>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> A(N),B(N-1);
    rep(i,N-1)cin >> B[i];
    A[0]=B[0];
    A[N-1]=B[N-2];
    for(int i=1;i<N-1;i++){
        A[i]=min(B[i-1],B[i]);
    }
    ll res = 0;
    rep(i,N)res+=A[i];
    //rep(i,N)cout << A[i] << endl;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a, b, c;
    
    scanf("%d %d %d", &a, &b, &c);
    
    if( a + b >= c ){
        printf("%d\n", b+c);
    } else {
        printf("%d\n", a+b+b+1);
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll n,k,dame;
int main(){
	scanf("%lld%lld",&n,&k);
	rep(i,0,k){
		ll t;
		scanf("%lld",&t);
		dame|=1LL<<t;
	}
	rep(i,n,1000000){
		ll t=i,flag=0;
		while(t){
			flag|=1LL<<(t%10);
			t/=10;
		}
		if((flag&dame)==0){
			printf("%lld\n",i);
			return 0;
		}
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int main(){
    string s;
    cin >> s;
    int l = 0, lmax = 0;
    for(int i = 0; s[i] != '\0'; ++i){
        if(s[i] != 'A' && s[i] != 'T' && s[i] != 'C' && s[i] != 'G'){
            lmax = max(l, lmax);
            l = 0;
        }else{
            l++;
        }
    }
    
    lmax = max(l, lmax);
    //char ans = (b == 'A')? 'T' : (b == 'T')? 'A' : (b == 'C')? 'G' : 'C';
    //cout << ans << endl;
    cout << lmax << endl;
    return 0;
}

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

const int mod = 1e9 + 7, N = 1e5 + 10;

ll pw(ll a, ll b) {
    ll r = 1;
    for( ; b ; b >>= 1, a = a * a % mod) {
        if(b & 1) {
            r = r * a % mod;
        }
    }
    return r;
}

ll getinv(ll n) {
    return pw(n, mod - 2);
}

void upd(ll &a, ll b) {
    a = (a + b) % mod;
}

int n, d;
vector<vector<ll> > pts;

int main() {
    scanf("%d%d", &n, &d);
    for(int i = 0 ; i < n ; ++ i) {
        vector<ll> p;
        for(int j = 0, x ; j < d ; ++ j) {
            scanf("%d", &x);
            p.push_back(x);
        }
        pts.push_back(p);
    }
    int ans = 0;
    for(int i = 0 ; i < pts.size() ; ++ i) {
        for(int j = i + 1 ; j < pts.size() ; ++ j) {
            ll s = 0;
            for(int k = 0 ; k < d ; ++ k) {
                ll t = (pts[i][k] - pts[j][k]);
                s += t * t;
            }
            ll tmp = sqrt(s);
            if(tmp * tmp == s) {
                ++ ans;
            }
        }
    }
    printf("%d\n", ans);
}


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

for i in range(n):
    for j in range(l):
        ans=0
        for k in range(m):
            ans+=A[i][k]*B[k][j]
        if j==l-1:
            print(ans)
        else:
            print(ans, end=" ")


Measured memory_bytes: 6576
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);

int main() {
	int X, N, x;
	scanf("%d%d", &X, &N);
	map<int, bool> flag;
	for (int i = 0; i < N; i++) {
		scanf("%d", &x);
		flag[x] = 1;
	}
	int l = X, r = X;
	while (flag[l]) l--;
	while (flag[r]) r++;
	if (r - X < X - l) printf("%d\n", r);
	else printf("%d\n", l);
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1LL << 60;

ll N;
vector<ll> a;

int main() {
    cin >> N;
    a.resize(3 * N);
    rep(i, 3 * N) cin >> a[i];

    // 0 ~ N 
    ll left = 0;
    priority_queue<ll, vector<ll>, greater<ll>> pq1;
    for (int i = 0; i < N; i++) {
        left += a[i];
        pq1.push(a[i]);
    }

    ll right = 0;
    // 2N ~ 3N - 1
    priority_queue<ll> pq2;
    for (int i = 2 * N; i < 3 * N; i++) {
        right += a[i];
        pq2.push(a[i]);
    }
    vector<ll> a1(N + 1);
    a1[0] = left;
    for (int i = N; i < 2 * N; i++) {
        ll top = pq1.top();
        if (top < a[i]) {
            pq1.pop();
            pq1.push(a[i]);
            left -= top;
            left += a[i];
        }

        // cout << left << " " << a[i] << endl;

        a1[i - N + 1] = left;
    }

    vector<ll> a2(N + 1);
    reverse(a.begin(), a.end());
    a2[0] = right;
    for (int i = N; i < 2 * N; i++) {
        ll top = pq2.top();

        if (top > a[i]) {
            pq2.pop();
            pq2.push(a[i]);

            right -= top;
            right += a[i];
        }

        a2[i - N + 1] = right;
    }
    reverse(a2.begin(), a2.end());

    ll ans = -INF;
    for (int i = 0; i <= N; i++) {
        ll tmp = a1[i] - a2[i];
        ans = max(tmp, ans);
    }
    cout << ans << endl;
    // for (int i = 0; i <= N; i++) {
    //     cout << a2[i] << " ";
    // }
    // cout << endl;
    // while (pq1.size() > 0) {
    //     cout << pq1.top() << " ";
    //     pq1.pop();
    // }
    // cout << endl;

    // while (pq2.size() > 0) {
    //     cout << pq2.top() << " ";
    //     pq2.pop();
    // }
    // cout << endl;
}

Measured memory_bytes: 8736
def main():
    S = input()
    T = input()
    cnt = 0
    
    S_dict = {}
    T_dict = {}
    
    for i in range(len(S)):
        if(S[i] not in S_dict):
            S_dict[S[i]] = T[i]
        elif(S_dict[S[i]] != T[i]):
            print("No")
            break
        
        if(T[i] not in T_dict):
            T_dict[T[i]] = S[i]
        elif(T_dict[T[i]] != S[i]):
            print("No")
            break
    else:
        print("Yes")
main()

Measured memory_bytes: 3632
/*sort2*/
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> p;
#define le 1000000007;

int main(void){
  /*??\???????§?*/
  map<string,int> d;
  string str;
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> str;
    if(str=="insert"){
      cin >> str;
      d[str]++;
    }else{
      cin >> str;
      if(d[str]>0)cout << "yes" << endl;
      else cout << "no" << endl;
    }
  }
  /*??\?????????*/
  return 0;
}

Measured memory_bytes: 52560
#include<iostream>

using namespace std;

int main(){
    int a, b, c;

    cin >> a >> b >> c;

    if(a+b==c){
        cout << "Yes";
    }else if(a+c==b){
        cout << "Yes";
    }else if(b+c==a){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	int n,a,b;
	cin>>n;
	if(n==1){
		cout<<"Hello World"<<endl;
	}
	else{
		cin>>a>>b;
		cout<<a+b<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <cstdlib>
#include <stack>
#include <queue>
#include <list>
#include <set>
using namespace std;
#define llong long long int
#define rep(i, n) for (int i = 0; i < n; ++i)


int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    llong x, a[100001];
    cin >> n >> x;
    rep(i, n) {
        cin >> a[i];
    }

    llong ans = 0;
    int tmp;
    for (int i = 1; i < n; i += 2) {
        // cout << a[i] << endl;
        if (i == n - 1) {
            if (a[i-1] + a[i] > x) {
                tmp = min(a[i - 1] + a[i] - x, a[i]);
                ans += tmp;
                a[i] = a[i] - tmp;
                if (a[i-1] + a[i] > x) ans += a[i - 1] - x;
            }
        } else {
            if (a[i-1] + a[i] > x) {
                tmp = min(a[i - 1] + a[i] - x, a[i]);
                ans += tmp;
                a[i] = a[i] - tmp;
                if (a[i - 1] + a[i] > x) ans += a[i - 1] - x;
            }
            if (a[i] + a[i + 1] > x) {
                tmp = min(a[i] + a[i + 1] - x, a[i + 1]);
                ans += tmp;
                a[i + 1] = a[i + 1] - tmp;
                if (a[i] + a[i + 1] > x) {
                    ans += a[i] - x;
                    a[i] = a[i] - x;
                }
            }
        }
    }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int n,k;
int a[101];
bool dp[100001];
bool b(){
    dp[0]=0;
    int i=1;
    while(i<=k){
        bool gh=false;
        int index=0;

       while( index<n && (i-a[index])>=0){
          if(dp[i-a[index]]==0){
              gh=true;
              break;
          }
           index++;
       }
       dp[i]=gh;
       i++;

    }

   return dp[k];
}
int32_t main() {
    cin>>n>>k;  
    memset(dp, 1, sizeof dp);
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    sort(a,a+n);
    if(!b()){
    cout<<"Second";
    }else{
        cout<<"First";
    }
    return 0;
}


Measured memory_bytes: 3776
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
using namespace std;


int main(){
	/*input*/
	long long n;
	cin >> n;
	map<string,int> ma;
	int i = 0;
	int Max = 0;
	while(i < n){
		string tmp;
		cin >> tmp;
		ma[tmp]++;
		++i;
		Max = max(Max,ma[tmp]);
	}

	/*calc*/
//	map<string,int>::iterator ans = ma.begin();
//	int max = ans->second;
//	for(auto it = ma.begin(); it != ma.end(); ++it){
//		if(max < it->second) max = it->second;
//	}
//	for(auto it = ma.begin(); it != ma.end(); ++it){
//		if(max == it->second) cout << it->first << endl;
//	}
	
	for(auto& m : ma){
		if(Max == m.second) cout << m.first << endl;

	}

    /*output*/
//	cout<< ans <<endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    cout << (n + 1) / 2 << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iomanip>    // setw 控制输出间隔函数
#include <iostream>   // cin, cout, abs
#include <algorithm>  // max, min, swap, sort
#include <cmath>      // pow
#include <cstring>    // strlen
#include <set>        // set 集合
#include <stack>      // stack 栈
#include <queue>      // queue 队列
#include <string>     // string 字(yang)符(rou)串, substr
#include <map>
using namespace std;
int main()
{
    string h;
    cin >> h;
    cout << h[0] << h.size() - 2 << h[h.size() - 1];
    return 0;
}


Measured memory_bytes: 256
# 2019/05/08
# AtCoder Beginner Contest 080 - B

# Input
n = int(input())

# Init
wn = n
x = 0
while(wn > 0):
    x += wn % 10
    wn = int(wn / 10)

if n % x == 0:
    ans = "Yes"
else:
    ans = "No"

# Output
print(ans)


Measured memory_bytes: 2940
def divisor(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)

        i += 1

    return lower_divisors + upper_divisors[::-1]

n = int(input())
d = divisor(n)
if len(d) == 2:
    print(d[1] - 1)
elif len(d) % 2 == 0:
    k = len(d)//2
    u = d[k-1]
    v = d[k]
    print((u-1) + (v-1))
else:
    k = len(d)//2
    v = d[k]
    print((v-1)*2)


Measured memory_bytes: 9052
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math") 
///#pragma GCC target("avx2")
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <functional>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <climits>
#include <numeric>

using namespace std;
#define open_streams ifstream fin("olympiad.in");ofstream fout("olympiad.out")
#define close_streams fin.close();fout.close()
#define speed cout.tie(0);cin.tie(0);ios_base::sync_with_stdio(0)
#define ll long long
#define ull unsigned long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define UNIQ(a) a.resize(unique(all(a)) - a.begin())
#define eps 1e-6
//const double PI = M_PI;
const int INF = INT_MAX;
const ll limit = 1LL * 1e12;
const int MOD = 1e9 + 711;
const int MOD2 = 1e9 + 933;
//---------------------------------------------------------------------------
const int mod = 1e9 + 7;
const int maxn = 1e6 + 100;



signed main() {
	speed;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); ++i) {
		s[i] = 'x';
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int r = sc.nextInt();
    int d = sc.nextInt();
    int x = sc.nextInt();
    
    int x1 = r * x - d;
    int x2 = r * x1 - d;
    int x3 = r * x2 - d;
    int x4 = r * x3 - d;
    int x5 = r * x4 - d;
    int x6 = r * x5 - d;
    int x7 = r * x6 - d;
    int x8 = r * x7 - d;
    int x9 = r * x8 - d;
    int x10 = r * x9 - d;
    
    System.out.println(x1);
    System.out.println(x2);
    System.out.println(x3);
    System.out.println(x4);
    System.out.println(x5);
    System.out.println(x6);
    System.out.println(x7);
    System.out.println(x8);
    System.out.println(x9);
    System.out.println(x10);
  }
}

Measured memory_bytes: 21844
#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))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))

using namespace std;

using ll = long long; using ull = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;

const ll MOD = 1e9+7;

int main(){
  int n,m,l;
  cin>>n>>m>>l;
  ll A[n][m]; 
  ll B[m][l];
  ll C[n][l];
  REP(i,n){
    REP(j,l){
      C[i][j]=0;
    }
  }
  REP(i,n){
  REP(j,m){
  cin>>A[i][j];
  }
  }
  REP(i,m){
  REP(j,l){
  cin>>B[i][j];
  }
  }
  REP(i,n){
  REP(j,l){
  REP(k,m){
  C[i][j]+=A[i][k]*B[k][j];
  }
  }
  }
  REP(i,n){
    REP(j,l-1){
      cout<<C[i][j]<<" ";
    }
    cout<<C[i][l-1]<<endl;
  }

}


Measured memory_bytes: 3332
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL n;
    cin >> n;

    vector<LL> a(n);

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

    LL result = 0;

    for(int i = 0; i < n; i++){
        while(a[i] % 2 == 0){
            result++;
            a[i] /= 2;
        }
    }

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

Measured memory_bytes: 384
sx,sy,gx,gy = (int(x) for x in input().split())
ans = ''
if sx < gx and sy < gy:
  ans += 'R'*(gx-sx) + 'U'*((gy-sy)+1) + 'L'*((gx-sx)+1) + 'D'*((gy-sy)+1) + 'R'
  ans += 'D' + 'R'*((gx-sx)+1) + 'U'*((gy-sy)+1) + 'L'*((gx-sx)+1) + 'D'*(gy-sy)
elif sx < gx and sy > gy:
  ans += 'R'*(gx-sx) + 'U'*((gy-sy)+1) + 'L'*((gx-sx)+1) + 'D'*((gy-sy)+1) + 'R'
print (ans)


Measured memory_bytes: 9068
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 922337203685477580;//7;
constexpr auto mod = 1000000007;

int main() {

	int n;
	cin >> n;
	int u, v, w;
	vector<vector<pair<int, int>>> g(n);
	FOR(i, n - 1) {
		cin >> u >> v >> w;
		u--; v--; w %= 2;
		g[u].push_back({ v,w });
		g[v].push_back({ u,w });
	}
	VI ans(n);
	queue<pair<int,int>> bfs;
	bfs.push({ 0,1 });
	pair<int, int> a;
	vector<bool> vis(n, 0);
	while (!bfs.empty()) {
		a = bfs.front();
		bfs.pop();
		ans[a.first] = a.second;
		vis[a.first] = 1;
		for (auto b : g[a.first]) {
			if (vis[b.first])continue;
			if (b.second)bfs.push({ b.first,1 - a.second });
			else bfs.push({ b.first,a.second });
		}
	}
	for (auto e : ans)cout << e << endl;
}


Measured memory_bytes: 6784
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};

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

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
ll inf=998244353;
ll power(ll a,ll x){
    ll res=1;
    while(x>0){
        if(x&1) res=res*x%inf;
        x=x*x%inf;
        x>>=1;
    }
    return res;
}
string s;
int g(int i){
    if(i<0) return 0;
    if(i==0) return 1;
    if(i==1&&s[1]==s[0]) return 1;

}
int main(){
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if((i<b&&j<a)||(i>=b&&j>=a)){
                cout<<1;
            }else cout<<0;
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
#define N 200000
int main(){
  int n, i, j, max = 0, min = 0;
  int a[N];
  scanf("%d",&n);
  for(i = 0;i < n; i++){
    scanf("%d", &a[i]);
  }
  min = a[0];
  max = a[1] - a[0];
  for(j = 1; j < n; j++){
    if(max < (a[j] - min)) max = a[j] - min;
    if(min > a[j]) min = a[j];
  }
  printf("%d\n", max);
  return 0; }




Measured memory_bytes: 2564
// ~/SolverToBe/Developers/Corvus
// ~/sudo apt-get verdict Accpeted

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>
#include <limits.h>
#include <math.h>
#include <string.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <functional>
#include <assert.h>
#include <complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int N = 100005, M = 505;
const ll MOD = 1e9 + 7;
const double eps = 1e-9;
const double PI = acos(-1.0);

int n, k;
char s[N];

int main() {
	scanf("%d%d%s", &n, &k, s);
	k--;
	s[k] = (s[k] == 'A' ? 'a' : (s[k] == 'B' ? 'b' : 'c'));
	puts(string(s).c_str());
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
 
 

using namespace std;

int main() {
  int N;
  cin>>N; 
  vector<int> d(N);  
  vector<bool> a(N,false); 
  rep(j,N){
    cin>>d.at(j);
    d.at(j)--;
    if(d.at(j)==j){
      a.at(j)=true;
    }
  }
  int ans=0;
  rep(i,N-1){
    if(a.at(i)){
      a.at(i)=false;
      a.at(i+1)=false;
      ans++;
    }
  }
  if(a.at(N-1)){
    ans++;
  }
  
  
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
	#define int ll
    #define pb push_back
    #define ll long long
	#define all(a) a.begin(),a.end()
    #define pii pair<int,int>
    using namespace std;
    vector <vector<int>> v(200005);
    int power(int x, unsigned int y, unsigned int m) 
	{ 
    	if (y == 0) 
        	return 1; 
    	int p = power(x, y/2, m) % m; 
    	p = (p * p) % m; 
  
 	   return (y%2 == 0)? p : (x * p) % m; 
	} 
	int modInverse(int a, int m) 
	{   
    	return power(a, m-2, m);
	}
    signed main()
    {
    	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    	ll t=1;
    	// cin >> t;
    	/*SAARE INPUTS LENA*/
    	/*VARIABLES KI RANGE DEKHLENA*/
    	while(t-->0)
    	{
          	int visit[200005];
    int level[200005];
    int parent[200005];
    int x=0;
    		ll n=0,m=0;
    		cin>>n>>m;
    		ll a=0,b=0;
    		for (int i = 0; i < m; ++i)
    		{
    			// cout<<i<<endl;
    			cin>>a>>b;
    			v[a].pb(b);
    			v[b].pb(a);
    		}
    		for (int i = 0; i <=n; ++i)
    		{
    			sort(all(v[i]));
    			visit[i]=0;
    		}
    		visit[1]=true;
    		// x++;
    // 		ll n=1;
          	queue <int> q;
    	q.push(1);
    	while(!q.empty())
    	{
    		// cout<<"hi";
    		int y=q.front();
    		q.pop();
    		// cout<<y.first<<endl;
    		x++;
    		for (int i = 0; i < v[y].size(); ++i)
    		{
    			if(visit[v[y][i]]==false)
    			{
    				visit[v[y][i]]=1;
    				level[v[y][i]]=level[y]+1;
    				parent[v[y][i]]=y;
    				q.push(v[y][i]);
    			}
    		}

    	}
          
    		if(x!=n)
    			cout<<"No";
    		else
    		{
    			cout<<"Yes"<<endl;
    			for (int i = 2; i <=n; ++i)
    			{
    				cout<<parent[i]<<endl;
    			}
    		}
    	}
    	return 0;
    }

Measured memory_bytes: 15940
#include <iostream>

using namespace std;

int main() {
  int n, m;
  while (true) {
    cin >> n >> m;
    if (n == 0 && m == 0) break;

    int t[n], h[n], sum = 0;
    int tsum = 0, hsum = 0;
    for (int i = 0; i < n; i++) {
      cin >> t[i];
      sum += t[i];
      tsum += t[i];
    }
    for (int i = 0; i < m; i++) {
      cin >> h[i];
      sum += h[i];
      hsum += h[i];
    }

    if (sum%2 == 1) {
      std::cout << -1 << std::endl;
      continue;
    }

    int anst = -1, ansh = -1;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
	if (tsum-t[i]+h[j] == hsum-h[j]+t[i] &&
	    (anst == -1 ||
	     t[anst]+h[ansh] > t[i]+h[j])) {
	  anst = i;
	  ansh = j;
	}
      }
    }

    if (anst == -1) {
      std::cout << -1 << std::endl;
    }else {
      std::cout << t[anst] << " " << h[ansh] << std::endl;
    }
  }
}

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

int to_int(string s){
  int res;
  stringstream ss;
  ss << s;
  ss >> res;
  return res;
}

bool is_op(char c){
  return
    c == '+' ||
    c == '-' ||
    c == '*' ||
    c == '/';
}

set<int> calc_op(char op, set<int> set1, set<int> set2){
  set<int> res;
  for(auto itr1 = set1.begin(); itr1 != set1.end();++itr1){
    for(auto itr2 = set2.begin(); itr2 != set2.end();++itr2){
      if(op == '+'){
	res.insert((*itr1) + (*itr2));
      }else if(op == '-'){
	res.insert((*itr1) - (*itr2));
      }else if(op == '*'){
	res.insert((*itr1) * (*itr2));
      }else if(op == '/'){
	if((*itr2) != 0){
	  res.insert((*itr1) / (*itr2));
	}
      }	
    }
  }
  return res;
}

set<int> solve(string s){
  vector< vector<set<int>>> dp;
  vector< char > op;
  dp.resize(20);
  for(int i = 0;i < 20;++i){
    dp[i].resize(20);       
  }
  int len = (int)s.size(),size = 0,p = 0;
  while(p < len){
    if(s[p] == '('){
      int q = p+1;
      int balance = 1;
      while(1){
	if(s[q] == '('){
	  ++balance;
	}else if(s[q] == ')'){
	  --balance;
	  if(balance == 0)break;
	}
	++q;
      }
      string elem = s.substr(p+1,q-p-1);
      dp[size][size] = solve(elem);
      ++size;
      p = q;
    }else if(is_op(s[p])){
      op.push_back(s[p]);
    }else{
      int q = p+1;
      while(q < len && '0' <= s[q] && s[q] <= '9')++q;
      string elem = s.substr(p,q-p);
      int num = to_int(elem);
      dp[size][size].clear();
      dp[size][size].insert(num);
      ++size;
      p = q-1;
    }
    ++p;
  }
  for(int step = 1;step < size;++step){
    for(int i = 0;i + step < size;++i){
      int j = i + step;
      for(int k = i;k < j;++k){
	set<int> calc = calc_op(op[k],dp[i][k],dp[k+1][j]);
	for(auto elem : calc)dp[i][j].insert(elem);
      }
    }
  }
  return dp[0][size-1];
}

int main(){
  string s;
  while(cin >> s,s != "#"){
    set<int> res = solve(s);
    /*
    for(auto elem : res){
      cout << elem << " ";
    }
    cout << endl;
    */
    cout << (int)res.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 3364
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repx(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define repxeq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;

//少数点表示
//cout <<std::fixed << std::setprecision(14) <<double値
string t="";
vector<string> s;
int n;

void dfs(string d,int ch){
    if(d.size() == n){
        cout << d << "\n";
        return;
    }
    
    repeq(i,ch){
        if(i != ch){
            dfs(d + (char)('a' + i),ch);
        }else{
            dfs(d + (char)('a' + i),ch+1);
        }
    }
}

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    cin >> n;
    string t = "a";
    dfs("",0);
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<pair<ll, int>> a(n);
  for(int i=0;i<n;++i) {
    int tmp; cin >> tmp;
    a[i] = {tmp, i};
  }
  a.push_back({0, n});
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int mi = INF;
  map<int, ll> mp;
  for(int i=0;i<n;++i) {
    mi = min(mi, a[i].second);
    mp[mi] += (i+1) * (a[i].first - a[i+1].first);
  }
  for(int i=0;i<n;++i) {
    cout << mp[i] << endl;
  }
}


Measured memory_bytes: 9956
#include<bits/stdc++.h>
using namespace std;
char str[11][1003];
int main()
{
    int r, c, k;
    scanf("%d %d %d", &r, &c, &k);
    for(int i=1; i<=r; i++)
    scanf("%s", str[i]+1);
    int res= r+c-2;
    bool f= 1;
    for(int j=1; j<=c && f; j++)
    {
        int sum= 0;
        for(int i=1; i<=r; i++)
        sum+= (str[i][j]-'0');
        f= (sum<=k);
    }
    if(f)
    {
        int prev= 0, sum= 0, cuts= 0;
        for(int j=1; j<=c; j++)
        {
            for(int i=1; i<=r; i++)
            sum+= (str[i][j]-'0');
            if(sum>k)cuts++, sum-= prev;
            prev= sum;
        }
        res= cuts;
    }
    for(int mask=1; mask<(1<<(r-1)); mask++)
    {
        int p= mask|(1<<(r-1));
        int cuts= -1, sz= 0;
        int cc[11];
        for(int i=0; i<r; i++)
        if(p&(1<<(i)))cuts++, cc[sz++]= i+1;

        bool f= 1;
        for(int j=1; j<=c && f; j++)
        {
            int sum= 0;
            for(int i=1, l=0; i<=r && f; i++)
            {
                sum+= (str[i][j]-'0');
                if(cc[l]==i)f= (sum<=k), sum= 0, l++;
            }
        }

        if(f)
        {
            int ss[11];
            memset(ss, 0, sizeof ss);
            for(int j=1; j<=c; j++)
            {
                bool f= 1;
                for(int i=1, l=0; i<=r && f; i++)
                {
                    ss[l]+= (str[i][j]-'0');
                    f= (ss[l]<=k);
                    if(cc[l]==i)l++;
                }
                if(!f)
                {
                    cuts++;
                    memset(ss, 0, sizeof ss);
                    for(int i=1, l=0; i<=r; i++)
                    {
                        ss[l]+= (str[i][j]-'0');
                        if(cc[l]==i)l++;
                    }
                }
            }
            res= min(res, cuts);
        }

    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 256
n, l = list(map(int, input().split()))

abs_l = {}
taste = []
for i in range(n):
    taste.append(l+i)
taste_s = sum(taste)
for i in range(n):
    abs_l[i] = abs(taste[i])

abs_min = min(abs_l, key=abs_l.get)
print(sum(taste)-taste[abs_min])

Measured memory_bytes: 3064
n=int(input())
h=list(map(int,input().split()))
h_max=max(h)
ans=0
for i in range(1,h_max+1):
    if h[0]>=i:
        ans+=1
    for j in range(n-1):
        if h[j]<i and h[j+1]>=i:
            ans+=1
print(ans)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
  bool num[1000000] = {false};
  for(int i=2; i<1000; i++){
    if(!num[i]){
      for(int j=i*i; j<1000000; j+=i){
	num[j] = true;
      }
    }
  }
  int n;
  while(cin >>n){
    int sum = 0;
    for(int i=2; i<=n; i++){
      if(!num[i]){sum++;}
    }
    cout <<sum<<endl;
  }
  return 0;
}

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

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

    int A_start = -1;
    int Z_end = -1;
    int ans = 0;
    for(int i = 0;i < s.length();i++){
        if(s[i] == 'A' && A_start == -1){
            A_start = i;
        }
        if(s[i] == 'Z'){
            Z_end = i;
        }
    }

    ans = Z_end - A_start + 1;

    cout << ans << endl;
}

Measured memory_bytes: 640
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var a = o.l();
  var b = {};
  var pow2 = [2];
  a.sort((a,b)=>b-a);
  for(var i = 1; pow2[i-1] <= a[0]; i++)pow2[i] = pow2[i-1] * 2;
  var u = i-1;
  for(i = 0; i < n; i++){
    if(b[a[i]])b[a[i]]++;
    else b[a[i]] = 1;
  }
  ans = 0;
  for(i = 0; i < n; i++){
    b[a[i]]--;
    if(b[a[i]] < 0)continue;
    while(u > 0 && pow2[u-1] > a[i]){
      u--;
    }
    var t = pow2[u] - a[i];
    if(b[t] > 0){b[t]--; ans++;}
  }
  return ans;
}

Measured memory_bytes: 67220
import heapq

N = int(input())
A = list(map(int, input().split()))
F = A[:N]
M = A[N:2*N]
L = list(map(lambda x: -x, A[2*N:3*N]))
former = sum(F)
latter = -sum(L)
ans = [0] * (N + 1)
ans[0] = former
ans[-1] = -latter

heapq.heapify(F)
heapq.heapify(L)

for i in range(N):
    tmp = heapq.heappushpop(F, M[i])
    former = former - tmp + M[i]
    ans[i+1] += former
    tmp = heapq.heappushpop(L, -M[N-i-1])
    latter = latter + tmp + M[N-i-1]
    ans[N-i-1] -= latter

print(max(ans))

Measured memory_bytes: 38148
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = (n-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long

int main(){
    string s, t; cin >> s >> t; cout << (t + s) << endl;
}

Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <set>
using namespace std;

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


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int
int main() 
{ 
    ll n;
    cin>>n;
    ll i,j,ans = 0;
    for(i=1;i<=n;i++)
    {
    	ll t = n/i;
    	ans = ans + t*(i+n-n%i)/2;
    }
    cout<<ans;
    return 0; 
} 

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
using namespace std;
int main(){

int n;
cin>>n;
vector <tuple<string,int,int>> a;

for(int i=1;i<=n;i++){
	string s;
	int p;
	cin>>s>>p;
	p*=-1;
	a.push_back(tie(s,p,i));
}

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

for(int i=0;i<n;i++){
	cout<< get<2>(a[i]) <<endl;
}

return 0;
}

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

int main()
{

	int n, cnt, flg;
	int s[12], cs[12];

	while (cin >> n)
	{
		if (n == 0) break;
		cnt = 0;
		flg = 1;

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

		for (int i = 0; i < 12; i++)
		{
			cs[i] = 0;
		}

		while (1)
		{
			flg = 0;
			for (int i = 0; i < n; i++)
			{
				for (int j = 0; j < n; j++)
				{
					if (s[i] == s[j])       // cs[i] = s[i]???????????????
					{
						cs[i]++;
					}
				}
			}
			cnt++;
			for (int i = 0; i < n; i++)
			{
				if (s[i] != cs[i])        // s = cs ?????????????????¨??????cs?????????????????°???P
				{
					flg++;
				}
			}
			if (flg==0)
			{
				cnt--;
				break;
			}
			else
			{
				for (int i = 0; i < n; i++)
				{
					s[i] = cs[i];
					cs[i] = 0;
				}
			}
		}
		
		cout << cnt << endl;
		for (int i = 0; i < n-1; i++)
		{
			cout << cs[i] << " ";
		}
		cout << cs[n-1] << endl;
	}

	return 0;
}

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

using namespace std;

string s[10000010];
int cnt, n;

void dfs(int depth, int pm, string t) {
	if(depth == 1) {
		dfs(depth + 1, pm + 1, "a");
		return ;
	}
	if(depth == n + 1) {
		s[++cnt] = t;
		return ; 
	}
	for(register char i = 'a'; i < 'a' + pm; i++) {
		dfs(depth + 1, pm, t + i);
	}
	dfs(depth + 1, pm + 1, t + (char)('a' + pm));
}

int main() {
	cin >> n;
	dfs(1, 0, "");
	sort(s + 1, s + cnt + 1);
	for(register int i = 1; i <= cnt; i++) cout << s[i] << endl;
	return 0;
}


Measured memory_bytes: 84992
#include <stdio.h>
 
int main(void)
{
 
  long long int a, b, r, x, tmp;
  scanf("%lld", &a);
  scanf("%lld", &b);
 
  x = a * b;
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  /* 最小公倍数を出力 */
  printf("%lld\n", x/b);
 
  return 0;
}

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

#define rep(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define min_int(a,b) ((a)<(b)?(a):(b))
#define INF 100000 //2^31

using namespace std;
int h, w,V;
int cost[4000][4000];
int sign[4];//0A a> 1V 3< 
int area[40][40];
int d[4000];
bool used[4000];
void solve(int s){
	rep(i, 0, V)d[i] = INF, used[i] = false;
	d[s] = 0;
	while (true){
		int v = -1;
		rep(u, 0, V)if (!used[u] && (v == -1 || d[u]<d[v]))v = u;

		if (v == -1)break;
		used[v] = true;
		rep(u, 0, V)d[u] = min_int(d[u], d[v] + cost[v][u]);
	//	rep(i, 0, V)printf("%d/", d[i]); cout << endl;
	}
}

int calc_d(int dx,int dy){
	if (dx > 0)return(1);
	if (dx < 0)return(3);
	if (dy>0)return(2);
	return(0);
}
void inset_cost(){
	rep(i, 0, V)rep(j, 0, V){
		int dx, dy;//差
		int before_d = i % 4, after_d = j % 4;//方向 
		if (i == j)cost[i][i] = 0;
		else{
			dx = (j / 4) % w - (i / 4) % w;
			dy = (j / 4) / w - (i / 4) / w;
			if (dx*dx + dy*dy == 1){
				int temp;
				if (calc_d(dx, dy) != after_d)cost[i][j] = INF;
				else{

					cost[i][j] = sign[temp = ((after_d - before_d + 4) % 4)];
					int x = (i / 4) % w, y = (i / 4) / w;
					if (temp == area[y][x])cost[i][j] = 0;//
				}
			}
			else
				cost[i][j] = INF;

		}

	}

	//rep(i, 0, V){
	//	rep(j, 0, V)printf("x=%d,y=%d,ax=%d,ay=%d,bd=%d,ad=%d,%11d, ", (i / 4) % w, (i / 4) / w, (j / 4) % w, (j / 4) / w, i % 4, j % 4, cost[i][j]);
		//cout << endl;
	//}

}

int main(void){
	while (true){
		cin >> w >> h;
		if (h == 0)break;
		rep(i, 0, h)rep(j, 0, w)cin >> area[i][j];
		rep(i, 0, 4)cin >> sign[i];
		V = 4 * h*w;
		
		inset_cost();

		solve(1);
		int result = d[V - 1];
		for (int i = V - 2; i > V - 5; i--)
			result = min_int(result, d[i]);

		cout << result << endl;

	}




	return(0);
}

Measured memory_bytes: 58500
#include<cstdio>
#include<cstring>

#define ll long long

using namespace std;

int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	int i=1;
	while(i<=b){
		if(a*i%b==c){
			printf("YES");
			return 0;
		}
		i++;
	}
	printf("NO");
	return 0;
} 

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int dp[100005];
int Frog2(int *a, int i, int n, int k, int *dp){

    if(i == n-1){
        dp[i] = 0;
        return 0;
    }

    if(dp[i] != -1)
        return dp[i];

    int ans = INT_MAX;
    for(int m = 1; m <= k; m++){
        if(i+m < n)
            ans = min(ans, abs(a[i]-a[i+m])+Frog2(a, i+m, n, k, dp));
    }
    dp[i] = ans;
    return ans;
}
int main(){

    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    memset(dp, -1, sizeof(dp));
    cout << Frog2(a, 0, n, k, dp);
    return 0;
}


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

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


int main(){
    ll N; cin >> N;
    vector<ll> P(N); for(int i = 0; i < N; i++) cin >> P[i];
    sort(P.begin(), P.end());
    ll ans = 0;
    for(int i = 0; i <  N; i++){
        if(i == N-1) ans += P[i]/2;
        else ans += P[i];
    } 
    cout << ans << endl;
}

Measured memory_bytes: 256
def solver():
    S = list(input())
    n = len(S)
    a = (n - 1) // 2
    b = (n + 3) // 2
    s1 = S[:a]
    s3 = S[b-1:]
    if S == S[::-1]:
        if s1 == s1[::-1]:
            if s3 == s3[::-1]:
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')

if __name__ == '__main__':
    solver()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)

using namespace std;
const int MAXN = 5 + 100000;
int arr[MAXN];

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int n,x; cin >> n >> x;
    foi(i,0,n) cin >> arr[i];
    arr[n++] = x;
    sort(arr, arr + n);
    int ans = 0;
    foi(i,1,n) ans = __gcd(ans, abs(arr[i] - arr[i - 1]));
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 640
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    flg = False
    for i in s:
        if i == "C":
            flg = True

        if flg and i == "F":
            print("Yes")
            break
    else:
        print("No")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 38256
#include <cstdio>
#include <algorithm>
using namespace std;
int n, x, b[500029], r = 1, sum;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		if (b[0]) puts("No");
		else if (x >= 500020) puts("Yes");
		else {
			while (b[r]) r++;
			if (r <= x) {
				puts("Yes");
				int z = x; b[z]++, sum++;
				while (b[z] == 2) b[z] = 0, b[--z]++, sum--;
				r = min(r, z + 1);
			}
			else {
				if (sum == x) puts("Yes"), b[0] = 1;
				else puts("No");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4580
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

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

  string s, t;
  cin >> s >> t;
  ll n = s.size();

  bool flag = true;
  vector<ll> trans1(26, -1), trans2(26, -1);
  REP(i, n) {
    if(trans1[s[i]-'a'] < 0) {
      trans1[s[i]-'a'] = t[i]-'a';
    } else {
      if(trans1[s[i]-'a'] != t[i]-'a') flag = false;
    }
    if(trans2[t[i]-'a'] < 0) {
      trans2[t[i]-'a'] = s[i]-'a';
    } else {
      if(trans2[t[i]-'a'] != s[i]-'a') flag = false;
    }
    // cout << trans1 << " " << trans2 << endl;
  }

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long X;
        X = sc.nextLong();

        final Solver solver = new Solver();
        solver.solve(X);
    }
}

class Solver {
    public void solve(long X) {
        long ans = 0;
        ans += X / 500 * 1000;
        X %= 500;
        ans += X / 5 * 5;
        System.out.println(ans);
    }
}



Measured memory_bytes: 21204