akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const int N = 2000010;
const int mod = 1000000007;
int inv[N], fact[N], ifact[N];
inline void Init() {
	inv[1] = 1;
	for (int i = 2; i < N; i++)
		inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
	fact[0] = ifact[0] = 1;
	for (int i = 1; i < N; i++) {
		fact[i] = 1ll * fact[i - 1] * i % mod;
		ifact[i] = 1ll * ifact[i - 1] * inv[i] % mod;
	}
}
inline int F(int x1, int y1, int x2, int y2) {
	return 1ll * fact[x2 + y2 - x1 - y1] * ifact[x2 - x1] % mod * ifact[y2 - y1] % mod;
}
inline int calc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
	int res = 0;
	for (int i = x3; i <= x4; i++)
		res = (res + 1ll * F(x1, y1, i, y3 - 1) * F(i, y3, x2, y2) % mod * (mod - i - y3) % mod) % mod;
	for (int j = y3; j <= y4; j++)
		res = (res + 1ll * F(x1, y1, x3 - 1, j) * F(x3, j, x2, y2) % mod * (mod - j - x3) % mod) % mod;
	for (int i = x3; i <= x4; i++)
		res = (res + 1ll * F(x1, y1, i, y4) * F(i, y4 + 1, x2, y2) % mod * (i + y4 + 1) % mod) % mod;
	for (int j = y3; j <= y4; j++)
		res = (res + 1ll * F(x1, y1, x4, j) * F(x4 + 1, j, x2, y2) % mod * (j + x4 + 1) % mod) % mod;
	return res;
}
struct Node {
	int x, y, z;
} ss[4], tt[4];
int main() {
	int x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
	Init();
	std::scanf("%d%d%d%d%d%d", &x1, &x2, &x3, &x4, &x5, &x6);
	std::scanf("%d%d%d%d%d%d", &y1, &y2, &y3, &y4, &y5, &y6);
	ss[0] = (Node){x1 - 1, y1 - 1, 1};
	ss[1] = (Node){x1 - 1, y2, mod - 1};
	ss[2] = (Node){x2, y1 - 1, mod - 1};
	ss[3] = (Node){x2, y2, 1};
	tt[0] = (Node){x6 + 1, y6 + 1, 1};
	tt[1] = (Node){x6 + 1, y5, mod - 1};
	tt[2] = (Node){x5, y6 + 1, mod - 1};
	tt[3] = (Node){x5, y5, 1};
	int ans = 0;
	for (int i = 0; i < 4; i++)
		for (int j = 0; j < 4; j++)
			ans = (ans + 1ll * calc(ss[i].x, ss[i].y, tt[j].x, tt[j].y, x3, y3, x4, y4) * ss[i].z % mod * tt[j].z % mod) % mod;
	std::printf("%d\n", ans);
	return 0;
}

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

int main(){
    int N;
    scanf("%d", &N);
    int ans = 0;
    for(int i=1; i<N; ++i){
        if(N%i == 0){
            ans += (N/i-1);
        } else{
            ans += N/i;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3824
#include "bits/stdc++.h"

//region Template
#include "ext/pb_ds/assoc_container.hpp"

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int MOD = 1000000007;
using namespace std;
#define finish(x) cout << x; exit(0);
#define fastIO cin.tie(0); cin.sync_with_stdio(false);

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

//const string USCAO_TAG = "mountains";
void usaco(const string& USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); }
/*
template<typename... Args>
void print(Args... args) {
	#ifdef LOCAL
	((std::cout << args << " "), ...);
	cout << endl;
	#endif
}
 */
//endregion

/* Notes:
 * Farah </3
 */

const int MAXN = 1e5 + 5;
const int INF = 2e9;
ll dp[101][5][2];


ll get(string n, int k){
    dp[0][1][0] = max(0, (n[0] - '0') - 1 );
    dp[0][0][0] = 1;
    int cnt = 0;
    for(int i = 0; i < n.size(); i++){
        cnt += (n[i] - '0') != 0;
        if(cnt <= k)
            dp[i][cnt][1] = 1;
    }
    for(int i = 1; i < n.size(); i++){
        for(int j = 0; j <= k; j++){
            if(j != 0)
                dp[i][j][0] = dp[i - 1][j - 1][0] * 9 + max(0, n[i] - '0' - 1) * dp[i - 1][j - 1][1]
            + dp[i - 1][j][0] + dp[i - 1][j][1] * (n[i] > '0');
            else
                dp[i][j][0]  = dp[i - 1][j][0] + dp[i - 1][j][1] * (n[i] > '0');

        }
    }

    return dp[(int)n.size() - 1][k][0] + dp[(int)n.size() - 1][k][1];
}

int main() {
    //usaco("milkvisits");

#ifdef LOCAL
    //setIn("in.txt");
    //setOut("out.txt");
#endif


    string n;
    int k;

    cin >> n >> k;
    cout << get(n , k) << endl;

   /* ll ans = 0, ans2 = 0;
    *//*for(int i = 0; i < n.size() - 1; i++){
        ans += get(string(i + 1, '9'), k);
    }
    ans += get(n, k);

    multiset<char> s(n.begin(), n.end());*//*

    for(int i = 1; i <= atoi(n.c_str()); i++){
        string str = to_string(i);
        //cout << str << endl;
        multiset<char> s(str.begin(), str.end());

        if(str.size() - s.count('0') == k) ans2++;
    }
    cout << ans2;*/
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  ll res = 0;
  for(int i = 1;i <= n;i++){
    ll end = (n / i) * i;
    res += (i + end) * (n / i) / 2;
  }
  cout << res << endl;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int a,b,c;cin>>a>>b>>c;){
		if(a+b==2 || c==1)
			cout<<"Open"<<endl;
		else
			cout<<"Close"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <iostream>
using namespace std;
long long fin_cd(long long a,long long b)
{
    return b==0?a:fin_cd(b,a%b);
}
long long nu(long long a,long long b)
{
    if(a%b==0) return a;
    else if(a<b) return b;
    else return a+b-a%b;
}
int main()
{
    long long a,b,c,d;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    long long num=b-a+1,t=c*d/fin_cd(c,d);
    long long numc=b-nu(a,c),numd=b-nu(a,d),numcd=b-nu(a,t);
    long long numcc=numc/c+1,numdd=numd/d+1,numcdcd=numcd/t+1;
    if(t>b) numcdcd=0;
    if(c>b) numcc=0;
    if(d>b) numdd=0;
    printf("%lld\n",num-numcc-numdd+numcdcd);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
template<class T>
void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>
void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,l,r;
	while(cin>>n>>l>>r,n){
		vi a(n);
		rep(i,n)cin>>a[i];
		int ans=0;
		range(i,l,r+1){
			rep(j,n){
				if(i%a[j]==0){
					if(j%2==0)ans++;
					break;
				}
				if(j==n-1 and n%2==0)ans++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3164
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int N;
    vector<string> S(100010);
    cin >> N;
    for (int i=0;i<N;i++) cin >> S[i];
    vector<ll> X(5,0);
    for (int i=0;i<N;i++) {
        switch (S[i][0]) {
            case 'M':
                X[0]++;
                break;
            case 'A':
                X[1]++;
                break;
            case 'R':
                X[2]++;
                break;
            case 'C':
                X[3]++;
                break;
            case 'H':
                X[4]++;
                break;
            default:
                break;
        }
    }
    ll res = 0;
    for (int i=0;i<5;i++) for (int j=i+1;j<5;j++) for (int k=j+1;k<5;k++) {
        if (i==j || j==k || k==i) continue;
        res += X[i]*X[j]*X[k];
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll N, A, B;
    cin >> N >> A >> B;

    ll ct = N / (A + B);
    ll ans = A * ct;
    N -= (A + B) * ct;
    ans += min(A, N);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

#define EPS 1e-7

class Point{
public:
  double x,y;
  Point(double x = 0.0,double y = 0.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(x*a, y*a); }
  Point operator / (double a){ return Point(x/a, y/a); }
  double abs(){ return sqrt(norm()); }
  double norm(){ return x*x + y*y; }
};

typedef Point Vector;
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;
}

class Segment{
public:
  Vector t,s;
  Segment(Vector t,Vector s) : t(t),s(s) {}
};

class Circle{
public:
  double x,y,r;
  Circle(double x = 0.0,double y = 0.0,double r = 0.0) : x(x),y(y),r(r) {}
};

Point point[3];
Circle ci;

int ccw(Point p0,Point p1,Point p2){
  Vector a = p1 - p0;
  Vector b = p2 - p0;
  if(cross(a,b) > EPS) return 1;
  if(cross(a,b) < -EPS) return -1;
  if(dot(a,b) < -EPS) return 2;
  if(a.norm() < b.norm()) return -2;
  return 0;
}

bool check(){
  Point cp = Point(ci.x,ci.y);
  int c1 = ccw(point[0],point[1],cp);
  int c2 = ccw(point[1],point[2],cp);
  int c3 = ccw(point[2],point[0],cp);
  return (c1 == c2 && c2 == c3);
}

typedef Segment Line;
double getDistanceLP(Line l,Point p){
  return abs(cross(l.s-l.t,p-l.t)/(l.s-l.t).abs());
}

double getDistanceSP(Segment seg,Point p){
  if(dot(seg.s-seg.t,p-seg.t) < 0.0) return (p-seg.t).abs();
  if(dot(seg.t-seg.s,p-seg.s) < 0.0) return (p-seg.s).abs(); 
  return getDistanceLP(seg,p);
}

int getStateCS(Circle c,Segment seg){
  Point cp = Point(c.x,c.y);
  if(getDistanceSP(seg,cp) >= c.r){
    return 1;
  }
  return 3;
}

bool isCross(){
  Point cp = Point(ci.x,ci.y);

  Segment seg[3] = {
    Segment(point[0],point[1]),
    Segment(point[1],point[2]),
    Segment(point[2],point[0])
  };
  int cnt = 0;
  for(int i = 0 ; i < 3 ; i++){
    if(getDistanceSP(seg[i],cp) > ci.r){
      cnt++;
    }
  }

  if(cnt == 3 && !check()) return false;
  return true;
}

void judge(){
  Segment seg[3] = {
    Segment(point[0],point[1]),
    Segment(point[1],point[2]),
    Segment(point[2],point[0])
  };
  Point cp = Point(ci.x,ci.y);
  int TinC = 0;
  for(int i = 0 ; i < 3 ; i++,TinC++){
    if((point[i]-cp).abs() > ci.r){
      break;
    }
  }

  if(TinC == 3){
    cout << 'b' << endl;
    return;
  }

  int CinT = 0;
  for(int i = 0 ; i < 3 ; i++){
    if(getStateCS(ci,seg[i]) == 1){
      CinT++;
    }
  }

  if(CinT == 3 && check()){
    cout << 'a' << endl;
  }else{
    if(isCross()){
      cout << 'c' << endl;
    }else{
      cout << 'd' << endl;
    }
  }
}

int main(){
  while(true){
    cin >> point[0].x >> point[0].y;
    if(!point[0].x && !point[0].y) break;
    for(int i = 0 ; i < 2 ; i++){
      cin >> point[i+1].x >> point[i+1].y;
    }
    cin >> ci.x >> ci.y >> ci.r;
    judge();
  }

  return 0;
}

Measured memory_bytes: 1216
#include<stdio.h>
int main(void){
    int masu[30][30]={{0}},x,y,c,siro=0,koyui=0,i,j;
    while(scanf("%d,%d,%d",&x,&y,&c)!=EOF){
        x=x+10;
        y=y+10;
        masu[x-1][y]++;
        masu[x][y]++;
        masu[x+1][y]++;
        masu[x][y-1]++;
        masu[x][y+1]++;

        if(c>1){
            masu[x-1][y-1]++;
            masu[x+1][y-1]++;
            masu[x-1][y+1]++;
            masu[x+1][y+1]++;
        }
        if(c>2){
            masu[x-2][y]++;
            masu[x+2][y]++;
            masu[x][y-2]++;
            masu[x][y+2]++;
        }


    }
    for(i=10;i<20;i++){
        for(j=10;j<20;j++){
            if(masu[i][j]==0)siro++;
            if(koyui<masu[i][j])koyui=masu[i][j];
        }
    }
    printf("%d\n%d\n",siro,koyui);
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, m;
    string s;
    vector<int> res;
    cin>>n>>m>>s;
    reverse(all(s));
    int now = 0, tmp;
    while(1) {
        tmp = now;
        now += m;
        now = min(now, n);
        if(now == n) {
            res.push_back(now - tmp);
            break;        
        }
        while(s[now] == '1') {
            now--;
            if(now == tmp) {
                cout<<-1<<endl;
                return 0;
            }
        }
        res.push_back(now - tmp);
    }
    reverse(all(res));
    each(i, res) {
        cout<<i<<' ';
    }
}


Measured memory_bytes: 1480
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll MAX = 1e+18;

int main()
{
    ll X, Y;
    cin >> X >> Y;

    if (X % Y == 0) {
        cout << -1 << endl;
        return 0;
    }

    for (ll i = 1; i <= MAX; ++i) {
        ll ans = i * X;

        if (ans % Y != 0) {
            cout << ans << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
n=int(raw_input())
s=raw_input()
res=0
for i in xrange(len(s)):
 s1=s[:i]
 s2=s[i:]
 t1=set(list(s1))
 t2=set(list(s2))
 t3=t1 & t2
 res=max(res,len(t3))
print res


Measured memory_bytes: 2568
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2100000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

vvl G(202020);
vl c(202020,0);
vl ans(202020,0);
void dfs(ll u, ll count, ll p){
	count += c[u];
	ans[u] = count;
	for(auto v : G[u]){
		if(v==p) continue;
		dfs(v,count,u);
	}
}

int main(){
	ll n,q; cin >> n >> q;
	rep(i,n-1){
		ll a,b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	rep(i,q){
		ll p,x; cin >> p >> x; p--;
		c[p] += x;
	}
	dfs(0,0,-1);
	rep(i,n) cout << ans[i] << " ";
	cout << endl;
}

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

namespace atcoder
{
	class Program
	{
		static void Main(string[] args)
		{
			//var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			var input = Console.ReadLine();
			if (input.Length > 3 && input.Substring(0, 4) == "YAKI") Console.WriteLine("Yes");
			else Console.WriteLine("No");
			//Console.ReadLine();
		}
	}
}

Measured memory_bytes: 11092
from sys import stdin
readline = stdin.buffer.readline
def r_map(): return map(int, readline().rstrip().split())
def r_list(): return list(r_map())

def main():
    N = int(readline().rstrip())
    A = r_list()
    M = 10**6
    d = [0] * (M + 1)
    g = True
    for a in A:
        d[a] += 1
    for i in range(2, M + 1):
        c = sum(d[i::i])
        if c == N:
            print("not coprime")
            exit()
        elif c > 1:
            g = False
    if g:
        print('pairwise coprime')
    else:
        print('setwise coprime')

if __name__ == "__main__":
    main()


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

#define N 100010
#define ll long long
int n;
ll arr[N], res, tmp, a, b; 
int l, r;

void work(int cnt)
{
	for (; ; cnt ^= 1)
	{
		if (l > r) return;
		if (l == r) 
		{
			tmp += max(abs(arr[l] - a), abs(arr[l] - b));
			return;
		}
		if (cnt == 0)
		{
			tmp += abs(arr[l] + arr[l + 1] - a - b);
			a = arr[l], b = arr[l + 1]; 
			l += 2;
		}
		else
		{
			tmp += abs(arr[r] + arr[r - 1] - a - b);
			a = arr[r], b = arr[r - 1];
			r -= 2;
		}
	}
}

int main()
{
	while (scanf("%d", &n) != EOF)
	{	
		res = 0;
		for (int i = 1; i <= n; ++i) scanf("%lld", arr + i);
		if (n == 1) puts("0");
		else if (n == 2) printf("%lld\n", abs(arr[1] - arr[2]));
		else
		{
			sort(arr + 1, arr + 1 + n);
			tmp = arr[n - 1] + arr[n] - 2 * arr[1];
			a = arr[n - 1], b = arr[n];
			l = 2, r = n - 2; 	
			work(0); 
			res = max(res, tmp); 
			tmp = 2 * arr[n] - arr[1] - arr[2];
			a = arr[1], b = arr[2];
			l = 3, r = n - 1;
			work(1);
			res = max(res, tmp);
			printf("%lld\n", res);
		
		}
	}
	return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N;
	cin>>N;
	vector<vector<int> > G=vector<vector<int> >(2,vector<int>(N,0));
	vector<vector<int> > DP=vector<vector<int> >(2,vector<int>(N,0));
	for(int i=0;i<2;i++)
		for(int j=0;j<N;j++)
		{
			int t;
			cin>>t;
			G[i][j]=t;
		}
	DP[0][0]=G[0][0];
	DP[1][0]=DP[0][0]+G[1][0];
	for(int i=1;i<N;i++)
	{
		DP[0][i]=DP[0][i-1]+G[0][i];
		DP[1][i]=max(DP[0][i],DP[1][i-1])+G[1][i];
	}
	cout<<DP[1][N-1]<<endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

int main () {
    int n, z, w; cin >> n >> z >> w;
    V<int> a(n); rep(i, n) cin >> a[i];
    int ans = abs(a[n-1] - w);
    if (n >= 2) chmax(ans, abs(a[n-1] - a[n-2]));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3612
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Text.RegularExpressions;

namespace Yuzuki
{
    class Yukari
    {
        static int n, m, x;
        static int[] cs;
        static int[,] As;
        public static void Main(string[] args)
        {
            input();
            int ans = int.MaxValue;
            for (int s = 1; s < 1<<n; s++)
            {
                int res = 0;
                int[] ac = new int[m];
                for (int i = 0; i < m; i++)
                {
                    ac[i] = 0;
                }
                for (int i = 0; i < n; i++)
                {
                    if ((s >> i & 1) == 1)
                    {
                        res += cs[i];
                        for (int j = 0; j < m; j++)
                        {
                            ac[j] += As[i, j];
                        }
                    }
                }
                if (ac.All(x => Yukari.x <= x))
                {
                    ans = Min(ans, res);
                }
            }
            if (ans == int.MaxValue)
            {
                ans = -1;
            }
            Console.WriteLine(ans);
        }
        public static void input()
        {
            string[] buf = Console.ReadLine().Split();
            n = int.Parse(buf[0]);
            m = int.Parse(buf[1]);
            x = int.Parse(buf[2]);
            cs = new int[n];
            As = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                buf = Console.ReadLine().Split();
                cs[i] = int.Parse(buf[0]);
                for (int j = 0; j < m; j++)
                {
                    As[i,j] = int.Parse(buf[j+1]);
                }
            }
        }

    }
}

Measured memory_bytes: 28164
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val p = sc.nextInt()
    println(problem128a(a, p))
}

fun problem128a(a: Int, p: Int): Int {
    return (a * 3 + p) / 2
}

Measured memory_bytes: 29592
x, y = [], []

for _ in range(3000):
    i, j = map(int, input().split())
    if i == 0 and j == 0:
        break
    else:
        x.append(i)
        y.append(j)
        
for k in range(len(x)):
    if x[k] < y[k]:
        print(x[k], y[k])
    else:
        print(y[k], x[k])


Measured memory_bytes: 6124
from itertools import accumulate,chain
from collections import defaultdict


def solve(N,P,S):
    S = list(map(int,S))

    if P == 2:
        cnt = 0
        for i,n in enumerate(S):
            if n%2 == 0:
                cnt += i+1
        return cnt
    elif P == 5:
        cnt = 0
        for i,n in enumerate(S):
            if n%5 == 0:
                cnt += i+1
        return cnt


    n = 1
    T = [None]*N
    for i in reversed(range(N)):
        T[i] = (n*S[i])%P
        n *= 10
        n %= P
    T = tuple(chain((0,),accumulate(T, lambda a,b: (a+b)%P)))



    cnt = 0
    c = defaultdict(int)
    for t in T:
        cnt += c[t]
        c[t] += 1
    return cnt

if __name__ == '__main__':

    N,P = map(int,input().split())
    S = input()
    print(solve(N,P,S))

Measured memory_bytes: 20208
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
using namespace std;

long long ans=-1e18-345;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	ans=max(ans,a*c);
	ans=max(ans,a*d);
	ans=max(ans,b*c);
	ans=max(ans,b*d);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)



void adder(vll& ans, vector<vll> v,vll cnt, ll root,ll x) {
	rep(i, 0, cnt[root]) {
		ans[v[root][i]] += x;
		adder(ans,v, cnt, v[root][i], x);
	}
}

int main() {
	ll mode;
	vll c(2), tmp(2);
	vector<vll> x(2, vll(2));
	vector<char> h(2), v(2);
	map<vll, ll> m;
	bool flg;
	vector<vector<char>> d(2, vector<char>(2));
	d[0][0] = 'R';
	d[0][1] = 'L';
	d[1][0] = 'U';
	d[1][1] = 'D';


	in(x[0][0]);
	in(x[0][1]);
	in(x[1][0]);
	in(x[1][1]);

	vector<char> str(4*(abs(x[1][0] - x[0][0]) + abs(x[1][1] - x[0][1])) + 10);
	ll strCnt = 0;

	c = x[0];

	rep (i, 0, 4) {
		mode = (i+1) % 2;
		while (c != x[mode]) {
			flg = false;
			rep(j, 0, 2) {
				rep(k, 0, 2) {
					tmp = c;
					if (j == 1 && x[mode][(k + 1) % 2] == tmp[(k + 1) % 2]) {
						continue;
					}
					if (x[mode][k] > tmp[k]) {
						tmp[k] += 1 - 2 * (j);
						str[strCnt] = d[k][j];
					}
					else if (x[mode][k] < tmp[k]) {
						tmp[k] += 1 - 2 * ((j + 1) % 2);
						str[strCnt] = d[k][(j+1)%2];
					}
					if (m[tmp] == 0 && tmp != x[i%2]) {
						if (tmp != x[0] && tmp != x[1]) {
							m[tmp] = 1;
						}
						strCnt++;
						flg=true;
					}
					if (flg) {
						break;
					}
				}
				if (flg) {
					break;
				}
			}

			if (!flg) {
				rep(i, 0, 2) {
					rep(j,0,2){
						tmp = c;
						if (x[mode][i] == tmp[i]) {
							tmp[i] += 1 - (2 * j);
							str[strCnt] = d[i][j];
							if (m[tmp] == 0 && tmp != x[i % 2]) {
								if (tmp != x[0] && tmp != x[1]) {
									m[tmp] = 1;
								}
								strCnt++;
								flg = true;
							}
						}

						if (flg) {
							break;
						}
					}

					if (flg) {
						break;
					}
				}
			}

			c = tmp;

		}
	}
	rep(i, 0, strCnt) {
		out(str[i]);
	}
	outn("");

	return 0;

}


Measured memory_bytes: 2048
n,m=map(int,input().split())
# Union FInd
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n
  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]
  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x == y:
      return
    if self.parents[x] > self.parents[y]:
      x, y = y, x
    self.parents[x] += self.parents[y]
    self.parents[y] = x
  def size(self, x):
    return -self.parents[self.find(x)]
  def same(self, x, y):
    return self.find(x) == self.find(y)
  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]
  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]
  def group_count(self):
    return len(self.roots())
  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}
  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
uf=UnionFind(n)
for _ in range(m):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  uf.union(a,b)
print(uf.group_count()-1)

Measured memory_bytes: 75028
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

const int N = 1005, M = 2005, MOD = 1E9 + 7;

struct SEdge
{
    int u, v, w;
} ed[M];
int n, m, a, b, c = 1, dsu[N], chk[M];
long long x;

int trace(int u)
{
    return (dsu[u] < 0 ? u : dsu[u] = trace(dsu[u]));
}

bool unity(int u, int v)
{
    if ((u = trace(u)) == (v = trace(v)))
        return false;
    if (dsu[u] > dsu[v])
        swap(u, v);
    dsu[u] += dsu[v];
    dsu[v] = u;
    return true;
}

int pw(int u)
{
    if (u == 0)
        return 1;
    long long ret = pw(u >> 1);
    (ret *= ret) %= MOD;
    if (u & 1)
        (ret <<= 1) %= MOD;
    return ret;
}

int solve(int u)
{
    long long ret = 0;
    fill(dsu + 1, dsu + n + 1, -1);
    ret += ed[u].w;
    unity(ed[u].u, ed[u].v);
    for (int i = 1; i <= m; i++)
        if (unity(ed[i].u, ed[i].v))
            ret += ed[i].w;
    if (ret < x)
        return -1;
    else if (ret == x)
        return 0;
    else
        return 1;
}

int main()
{
    scanf("%d%d%lld", &n, &m, &x);
    for (int i = 1; i <= m; i++)
        scanf("%d%d%d", &ed[i].u, &ed[i].v, &ed[i].w);
    sort(ed + 1, ed + m + 1, [](const SEdge &a, const SEdge &b) { return a.w < b.w; });
    for (int i = 1; i <= m; i++)
    {
        c *= (chk[i] = solve(i));
        a += (chk[i] == -1);
        b += (chk[i] <= 0);
    }
    if (c != 0)
        printf("0\n");
    else
        printf("%d\n", (pw(min(m, m + 1 - a)) - pw(min(m, m + 1 - b)) + MOD) % MOD);
}

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

using namespace std;


int main() {
  
    int l;
    scanf("%d",&l);
    double sum=l;
    double a,b,c;
    a=sum/3;
    
    sum-=a;
    b=sum/2;
    
    sum-=b;
    c=sum;
    
    double ans=(a*b*c);
    printf("%0.12lf\n",ans);
    

    
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
int a[100001];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	int l = 1; 
	int r = 100000;
	while (l <= r) {
		int mid = (l + r) / 2;
		int x = 0, y = 0;
		rep(i, n) {
			if (a[i] >= mid)x += 1;
			else y += 1;
		}
		if (x >= y) {
			l = mid + 1; 
		}
		else r = mid - 1;
	}
	int ans = r;
	l = 1;
	r = 100000;
	while (l <= r) {
		int mid = (l + r) / 2;
		int x = 0, y = 0;
		rep(i, n) {
			if (a[i] >= mid)x += 1;
			else y += 1;
		}
		if (x > y) {
			l = mid + 1;
		}
		else r = mid - 1;
	}
	cout << ans - l + 1 << '\n';


}

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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

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


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

    ll ans = 0;

    for (int i = 1; i < n + 1; i++) {
        if ((i % 3) && (i % 5)) ans += i;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3660
N,M = list(map(int,input().split(' ')))
 
if M % N == 0:
	print(M//N)
	exit()

ans = 1
for i in range(2,100000+1):
	k = M % i
	if k == 0:
		j = M//i
		if i >= N and j >= N:
			ans = max(ans,i,j)
		elif i >= N:
			ans = max(ans,j)
		elif j >= N:
			ans = max(ans,i)
print(ans)


Measured memory_bytes: 3316
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
 */
//入力終了→Ctrl+D
import java.time.Year;
import java.util.*;
import java.awt.*;
import java.awt.Graphics.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        int m=1000000000;
        int ans=-1000000000;
        for (int i = 0; i < n; i++) {
            int r=sc.nextInt();
            if(i>0)ans=max(ans,r-m);
            m=min(m,r);
        }
        out.println(ans);
    }
}


Measured memory_bytes: 99236
def main():
    N, M = (int(i) for i in input().split())
    par = [i for i in range(N)]
    rank = [0 for i in range(N)]

    def find_root(x):
        if par[x] == x:
            return x
        else:
            par[x] = find_root(par[x])
            return par[x]

    def is_same_group(x, y):
        return find_root(x) == find_root(y)

    def unite(x, y):
        x = find_root(x)
        y = find_root(y)
        if x == y:
            return
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1
    P = [int(i)-1 for i in input().split()]
    for i in range(M):
        x, y = (int(i)-1 for i in input().split())
        unite(x, y)
    ans = 0
    for i, p in enumerate(P):
        if is_same_group(i, p):
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 97220
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int count;
	if (a == b) {
		if (b == c) count = 1;
		else count = 2;
	}
	else if (b == c) count = 2;
	else if (a == c) count = 2;
	else count = 3;
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3580
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long A = scan.nextLong();
        long B = scan.nextLong();
        long C = scan.nextLong();
        long D = scan.nextLong();
        boolean found = false;
        for (int i = 0; i < N; i++) {
            long min = A + i * C - (N - 1 - i) * D;
            long max = A + i * D - (N - 1 - i) * C;
            if (min <= B && B <= max) {
                found = true;
                break;
            }
        }
        System.out.println(found?"YES":"NO");
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/*---------------------template----------------------*/
/*----------------------end--------------------------*/
/* --------------------ライブラリ--------------------*/
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
/*---------------------臨時関数----------------------*/
/*----------------------end-------------------------*/
signed main(){
  int s;cin>>s;
  vector<int>A;
  A.pb(s);
  for(int i=0;;i++){
    int push=A[i]%2==0?A[i]/2:A[i]*3+1;
    auto B=A;
    sort(all(B));
    if(binary_search(all(B),push)){
      cout<<i+2<<endl;
      break;
    }
    else {
      A.pb(push);
    }
  }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long

#define TASKNAME ""

using namespace std;

const int INF = 1e9 + 7;
const int MAXN = 1e6 + 7;
const double EPS = 1e-8;

int main() {
    #ifdef MY
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #else
        //freopen(TASKNAME".in", "r", stdin);
        //freopen(TASKNAME".out", "w", stdout);
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // MY
    int n, m;
    cin >> n >> m;
    vector <vector <char> > a(n, vector <char> (m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    vector <vector <int> > d1(n + m, vector <int> (n + 1, 0));
    vector <vector <int> > d2(n + m, vector <int> (n + 1, 0));
    for (int sum = 0; sum < n + m; sum++) {
        for (int i = 0; i < n; i++) {
            int j = sum - i;
            d1[sum][i + 1] += d1[sum][i];
            if (j < 0 || j >= m) continue;
            if (a[i][j] == '#') {
                d1[sum][i + 1]++;
            }
        }
    }
    for (int sum = 0; sum < n + m; sum++) {
        for (int i = 0; i < n; i++) {
            int j = m + i - sum;
            d2[sum][i + 1] += d2[sum][i];
            if (j < 0 || j >= m) continue;
            if (a[i][j] == '#') {
                d2[sum][i + 1]++;
            }
        }
    }
    ll res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            int sum = i + j;
            if (a[i][j] == '.') continue;
            for (int i1 = i + 1; i1 < n; i1++) {
                int j1 = sum - i1;
                if (j1 < 0 || j1 > m || a[i1][j1] == '.') continue;
                int sum1 = 2 * (i1 - i);
                if (sum + sum1 < n + m) {
                    res += d1[sum + sum1][min(n, i1 + i1 - i)] - d1[sum + sum1][min(n, i + i1 - i + 1)];
                }
                if (sum - sum1 >= 0) {
                    res += d1[sum - sum1][max(0, i1 - (i1 - i))] - d1[sum - sum1][max(0, i - (i1 - i) + 1)];
                }
                //cout << "case1 " << i << " " << j << " " << i1 << " " << j1 << " " << res << "\n";
            }
            sum = i - j + m;
            for (int i1 = i + 1; i1 < n; i1++) {
                int j1 = m + i1 - sum;
                if (j1 < 0 || j1 >= m || a[i1][j1] == '.') continue;
                int sum1 = 2 * (i1 - i);
                if (sum + sum1 < n + m) {
                    res += d2[sum + sum1][min(n, i1 + i1 - i + 1)] - d2[sum + sum1][min(n, i + i1 - i)];
                }
                if (sum - sum1 >= 0) {
                    res += d2[sum - sum1][max(0, i1 - (i1 - i) + 1)] - d2[sum - sum1][max(0, i - (i1 - i))];
                }
                //cout << "case2 " << sum << " " << sum1 << " " << i << " " << j << " " << i1 << " " << j1 << " " << res << "\n";
            }
        }
    }
    cout << res;
}


Measured memory_bytes: 1792
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	string str;
	cin>>str;
	cin.ignore();
	int q;
	cin>>q;
	int x,y,start,end;
	vector<char> v(600005);
	start = 200005;
    end = 200004;
    for(int i=0;i<(int)str.size();i++){
        v[++end]=str[i];
    }
	char ch;
	while(q--){
		cin>>x;
		if(x==1){
			int c = start;
			start = end;
			end = c;
		} else {
			cin>>y;
			cin>>ch;
			if(y==1){
				if(start<=end){
					--start;
				} else {
					++start;
				}
				v[start]=ch;
			} else {
				if(start<=end){
					++end;
				} else {
					--end;
				}
				v[end]=ch;
			}
		}
	}
	if(start<=end){
		for(int i=start;i<=end;i++){
			cout<<v[i];
		}
	} else {
		for(int i=start;i>=end;i--){
			cout<<v[i];
		}
	}
	return 0;
}

Measured memory_bytes: 1360
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll n,i,j,a,b;
            cin>>n;
            vector<ll> v,v2;
            for(i=1;i<=n;++i)
            {   
                cin>>a>>b;
                v.pb(a-b);
                v2.pb(a+b);
            }
            sort(v.begin(),v.end());
            sort(v2.begin(),v2.end());
            ll ans = max(v.back()-v[0],v2.back()-v2[0]);
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 6756
# ABC096C - Grid Repainting 2
def main():
    # check all black grids' 4-dxy
    H, W, *S = open(0).read().split()
    H, W = int(H), int(W)
    dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    for x, s in enumerate(S):
        for y, a in enumerate(s):
            if a == "#":
                for dx, dy in dxy:
                    nx, ny = x + dx, y + dy
                    if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == "#":
                        break
                else:
                    print("No")
                    return
    print("Yes")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
// CPP program to check if an array can be sorted 
// with at-most one swap 
#include <bits/stdc++.h> 
using namespace std; 

bool checkSorted(int n, int arr[]) 
{ 
	// Create a sorted copy of original array 
	int b[n]; 
	for (int i = 0; i < n; i++) 
		b[i] = arr[i]; 
	sort(b, b + n); 

	// Check if 0 or 1 swap required to 
	// get the sorted array 
	int ct = 0; 
	for (int i = 0; i < n; i++) 
		if (arr[i] != b[i]) 
			ct++; 
	if (ct == 0 || ct == 2) 
		return true; 
	else
		return false; 
} 

// Driver Program to test above function 
int main() 
{ 	int n; 
 	cin>>n;
 
	int arr[n];  
 	for(int i=0;i<n;++i)cin>>arr[i];
 
	if (checkSorted(n, arr)) 
		cout << "YES"; 
	else
		cout << "NO"; 
	return 0; 
} 


Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val s = List.fill(n)(sc.next())
  val res = List("AC", "WA", "TLE", "RE")
  for(r <- res) {
    println(s"$r x ${s.count(_ == r)}")
  }
}

Measured memory_bytes: 64456
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

ll f(ll b, ll n){
    if(b < 2) return LINF;
    ll res = 0;
    while(n > 0){
        res += n % b;
        n /= b;
    }
    return res;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, s;
    cin >> n >> s;
    if(n == s){
        cout << n + 1 << endl;
        return 0;
    }
    ll ans = LINF;
    for(int b=2;b<sqrt(n)+1;b++) if(f(b,n) == s) chmin(ans, (ll)b);
    for(int p = 1;p<sqrt(n);p++){
        ll b = (n - s) / p + 1;
        if(f(b,n) == s) chmin(ans, b);
    }
    if(ans == LINF) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 256