akhauriyash/Code-Regression huggingface dataset:
#define MYDEBUG
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>
#include <queue>
#include <set>
#include <cstdio>
#include <unordered_map>

#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last)
			out << ",";
	}
	out << "]";
	return out;
}

int n, m;
const int MAXN = 51;
const int MAXM = 51;
char a[MAXN][MAXN] = { };
char b[MAXM][MAXM] = { };

int check(int si, int sj) {
	for (int i = 0; i < m; ++i) {
		for (int j = 0; j < m; ++j) {
			if (si + i >= n || sj + j >= n) {
				return -1;
			}
			if (a[si + i][sj + j] != b[i][j]) {
				return -1;
			}

		}
	}
	return 1;
}

void solve() {
	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		for (int j = 0; j < n; ++j) {
			a[i][j] = s[j];
		}
	}
	for (int i = 0; i < m; ++i) {
		string s;
		cin >> s;
		for (int j = 0; j < m; ++j) {
			b[i][j] = s[j];
		}
	}

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (check(i, j) == 1) {
				cout << "Yes" << endl;
				return;
			}
		}
	}
	cout << "No" << endl;
}
int main() {
	solve();
	return 0;
}


Measured memory_bytes: 256
// ※※※ 解答不能 ※※※
// si_nian氏
// https://atcoder.jp/contests/agc040/submissions/8288235
#include <bits/stdc++.h>
using namespace std;
const int MAX = 10000000;
int N, a, b, ans;
int fac[MAX + 1], inv[MAX + 1];
const int MOD = 998244353;
int Pow(int x, int y){
    int ans = 1;
    for(; y; y >>= 1, x = 1ll * x * x % MOD) if(y & 1) ans = 1ll * ans * x % MOD;
    return ans;
}
void Pre(){
    fac[0] = 1;
    for(int i = 1; i <= MAX; i++) fac[i] = 1ll * fac[i - 1] * i % MOD;
    inv[MAX] = Pow(fac[MAX], MOD - 2);
    for(int i = MAX - 1; i >= 0; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % MOD;
}
int C(int n, int r){
    return 1ll * fac[n] * inv[r] % MOD * inv[n - r] % MOD;
}
int catalan(int x, int y){
    return((C(x + y, y) - C(x + y, y - 1)) + MOD) % MOD;
}

int main(){
    Pre();
    scanf("%d %d %d", &N, &a, &b);
    if(b == 0){
        printf("%d\n", 1);
        return 0;
    }
    for(int i = 0; i <= min(min(a, N - b), b - 1); i++){
        int tot = catalan(b - 1, i);
        if(i + b == N){
            if(a == i) (ans += tot) %= MOD;
        }else{
            int x = N - b - i - 1;
            int y = b - i - (b - a) + 1;
            (ans += 1ll * tot * C(x + y - 1, x) % MOD) %= MOD;
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

// main
int main(){
    string s; cin >> s;
    string t = "";
    for(int i = 0; i < (int)s.size(); i += 2){
        t += s[i];
    }
    cout << t << "\n";
    return 0;
}

Measured memory_bytes: 512
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  ll w;
  cin >> w;
//  string ans;
  rep(i , s.size()){
    if (i%w==0) cout << s[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Main {
    int N, M, R;
    vector<int> r;
    using T = pair<ll, int>;
    vector<vector<T>> edge;
    void input() {
        cin >> N >> M >> R;
        r.resize(R);
        edge.resize(N);
        REP(i, R) {
            cin >> r[i];
            r[i]--;
        }
        REP(i, M) {
            int a, b;
            ll c;
            cin >> a >> b >> c;
            --a;
            --b;
            edge[a].emplace_back(c, b);
            edge[b].emplace_back(c, a);
        }
    }
    void output() {
        const ll INF = 1e18;
        map<int, vector<ll>> d;
        REP(k, R) {
            d[r[k]] = vector<ll>(N, INF);
            priority_queue<T, vector<T>, greater<T>> pq;
            pq.emplace(0, r[k]);
            while (!pq.empty()) {
                ll c;
                int i;
                tie(c, i) = pq.top();
                pq.pop();
                if (c >= d[r[k]][i]) continue;
                d[r[k]][i] = c;
                for (auto &p : edge[i]) {
                    ll dc;
                    int j;
                    tie(dc, j) = p;
                    if (c + dc < d[r[k]][j]) { pq.emplace(c + dc, j); }
                }
            }
        }
        SORT(r);
        ll res = INF;
        do {
            ll sum = 0;
            REP(i, R - 1) { sum += d[r[i]][r[i + 1]]; }
            res = min(res, sum);
        } while (next_permutation(r.begin(), r.end()));
        cout << res << endl;
    }

public:
    Main() {
        input();
        output();
    }
};

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

    Main();

    return 0;
}


Measured memory_bytes: 4940
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var HWN = Sarray();
            var H = HWN[0];
            var W = HWN[1];
            var N = HWN[2];
            var bMasu = new HashSet<(long h, long w)>();
            for (var i = 0; i < N; ++i)
            {
                var ab = Sarray();
                bMasu.Add((ab[0], ab[1]));
            }
            var used = new HashSet<(long h, long w)>();
            var zah = new long[] { -1, 0, 1, -1, 0, 1, -1, 0, 1 };
            var zaw = new long[] { -1, -1, -1, 0, 0, 0, 1, 1, 1 };

            var nums = new long[10];
            foreach (var b in bMasu)
            {
                for (var i = 0; i < 9; ++i)//中心
                {
                    var ch = b.h + zah[i];
                    var cw = b.w + zaw[i];
                    if (1 < ch && ch < H && 1 < cw && cw < W && !used.Contains((ch, cw)))
                    {
                        var cnt = 0;
                        for (var j = 0; j < 9; ++j)//フィルタ
                        {
                            var h = ch + zah[j];
                            var w = cw + zaw[j];
                            if (bMasu.Contains((h, w))) ++cnt;
                        }
                        ++nums[cnt];
                    }
                    used.Add((ch, cw));
                }
            }
            var square = (H - 2) * (W - 2);
            nums[0] = square - nums.Skip(1).Sum();
            foreach (var n in nums)
                WriteLine(n);
        }
    }
}

Measured memory_bytes: 105016
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int m, d;
    cin >> m >> d;

    int ans =0;
    FOR(i,22,d+1) {
        int d1 = i % 10;
        int d10 = i / 10;
        if (d1 >= 2 && d10 >= 2) {
            FOR(j,4,m+1) {
                if (j == d1 * d10) ans++;
            }
        }
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// 二维前缀和 图的性质 连通块

/*
  对于不包含环的图,连通块数目=点数-边数（这是什么鬼。。。）
 */

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>

using namespace std;

const int N = 2010;

char mp[N][N];

int n, m, q, a[N][N], c[N][N], b[N][N];

#define plus(arr, val, i, j) arr[i][j] = arr[i][j - 1] + arr[i - 1][j] - arr[i - 1][j - 1] + (val)

int main() {
    scanf("%d%d%d", &n, &m, &q);
    for(int i = 1 ; i <= n ; ++ i) {
        scanf("%s", mp[i] + 1);
    }

    for(int i = 1 ; i <= n ; ++ i) {
        for(int j = 1 ; j <= m ; ++ j) {
            plus(a, mp[i][j] == '1', i, j);
            plus(b, mp[i][j] == '1' && mp[i][j - 1] == '1', i, j);
            plus(c, mp[i][j] == '1' && mp[i - 1][j] == '1', j, i);
        }
    }

    for(int i = 1, x, y, xx, yy ; i <= q ; ++ i) {
        scanf("%d%d%d%d", &x, &y, &xx, &yy);
        printf("%d\n",
               (a[xx][yy] - a[x - 1][yy] - a[xx][y - 1] + a[x - 1][y - 1]) -
               (b[xx][yy] - b[xx][y] - b[x - 1][yy] + b[x - 1][y]) -
               (c[yy][xx] - c[yy][x] - c[y - 1][xx] + c[y - 1][x]));
    }
}

Measured memory_bytes: 53120
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int main() {
  int n;
  scanf("%d", &n);
  int lastA = -1;
  int lastB = -1;
  ll aa = 1;
  ll bb = 1;
  while(n--) {
    int a, b;
    scanf("%d%d", &a, &b);
    if(lastA == a && lastB == b) {
      continue;
    }
    ll scale = max((aa+a-1) / a, (bb+b-1) / b);
    aa = scale * a;
    bb = scale * b;
    lastA = a;
    lastB = b;
  }
  printf("%lld\n", aa + bb);
}


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

sunuke = [0]*n;

for i in range(k) :
    d = int(input());
    a = list(map(int,input().split()));
    for j in range(d) :
        sunuke[a[j]-1] += 1;

ans = 0;
for i in range(n) :
    if sunuke[i] == 0 :
        ans += 1;

print(ans);

Measured memory_bytes: 9212
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
set<char> valid={'A', 'C', 'G', 'T'};
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int curr=0;
    int ans=0;
    for(int i=0;i<s.size();i++){
        if(valid.count(s[i])){
            curr++;
        }
        else{
            curr=0;
        }
        ans=max(ans, curr);
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define int long long
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
string s;
int n;
int dp[1000005][2];
int help(int id,int f)
{
    //cout<<id<<" "<<n<<endl;
    if(id==n)
        return 0;
        if(dp[id][f]!=-1)
            return dp[id][f];
    int op1 = INT_MAX,op2=INT_MAX;

    if(f==1)
    {
        if(id==n-1)
        {
            op1 = '9'-s[id]+1;
        }
        else
       op1 = '9'-s[id];
       int zz = min(help(id+1,1),help(id+1,0)+1);
       op1 += zz;
    }
    else
    {
        op2 = s[id]-'0';
        int zz = min(help(id+1,0),help(id+1,1)+1);
        op2+=zz;
    }
    //cout<<op1<<" "<<op2<<endl;
    int an=min(op1,op2);
    dp[id][f]=an;
    return an;
}
signed main(){
    gok

    cin>>s;
   // reverse(s.begin(),s.end());
    n=s.size();
    memset(dp,-1,sizeof(dp));
    int an = min(help(0,0),help(0,1)+1);
    cout<<an<<endl;

    return 0;
}


Measured memory_bytes: 63900
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    string S;
    cin >> N >> S;
    ll ma = 0;
    for(int i = 1; i < N; i++) {
        string X, Y;
        X = S.substr(0, i);
        Y = S.substr(i, N-i);
        set<char> s1;
        set<char> s2;
        rep(j, X.size()) s1.insert(X[j]);
        rep(j, Y.size()) s2.insert(Y[j]);
        ll cnt = 0;
        rep(j, 26) {
            if (s1.find((char)(j+'a')) != s1.end() & s2.find((char)(j+'a')) != s2.end()) {
                cnt++;
            }
        }
        ma = max(ma, cnt);
    }
    print(ma);
    return 0;
}


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

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;};

const Int MOD = 1e6;
const Int MAX = 1024;
Int n;
Int dp[5][4][2][MAX];
string ss[MAX];

Int check(Int v,string s){
  for(Int i=0;i<8;i++){
    if((s[i]!='x')&&((s[i]-'0')!=(v&1))) return 0;
    v>>=1;
  }
  return 1;
}

Int rf[5][4],mc[5][4],ms[5][4];
Int match(Int a,Int b,Int l){
  return (a>>(8-l))==(b>>(8-l));
}

Int dfs(Int len,Int i,Int y,Int p){
  if(p==n) return (len==1&&i==0&&y==1);
  Int &res=dp[len][i][y][p];
  if(~res) return res;
  res=0;
  
  for(Int bit=0;bit<256;bit++){
    if(!check(bit,ss[p])) continue;
    if(!match(bit,rf[len][i],mc[len][i])) continue;
    if(i+1==len){
      if(y){
        for(Int nxt=1;nxt<=4;nxt++){
          Int ni=0;
          Int ny=(nxt==1);
          Int np=p+1;
          res+=dfs(nxt,ni,ny,np);
          res%=MOD;
        }
      }
    }else{
      Int ni=i+1;
      Int ny=y||(ms[len][i]&bit);
      Int np=p+1;
      res+=dfs(len,ni,ny,np);
      res%=MOD;
    }
  }
  return res;
}

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

  rf[1][0]=0b00000000;
  
  rf[2][0]=0b11000000;
  rf[2][1]=0b10000000;

  rf[3][0]=0b11100000;
  rf[3][1]=0b10000000;
  rf[3][2]=0b10000000;

  rf[4][0]=0b11110000;
  rf[4][1]=0b10000000;
  rf[4][2]=0b10000000;
  rf[4][3]=0b10000000;
  
  mc[1][0]=1;
  
  mc[2][0]=3;
  mc[2][1]=2;

  mc[3][0]=4;
  mc[3][1]=2;
  mc[3][2]=2;

  mc[4][0]=5;
  mc[4][1]=2;
  mc[4][2]=2;
  mc[4][3]=2;
  
  ms[1][0]=0b00000000;
  
  ms[2][0]=0b00011110;
  ms[2][1]=0b00000000;

  ms[3][0]=0b00001111;
  ms[3][1]=0b00100000;
  ms[3][2]=0b00000000;

  ms[4][0]=0b00000111;
  ms[4][1]=0b00110000;
  ms[4][2]=0b00000000;
  ms[4][3]=0b00000000;
  
  while(cin>>n,n){
    memset(dp,-1,sizeof(dp));
    for(Int i=0;i<n;i++){
      cin>>ss[i];
      reverse(ss[i].begin(),ss[i].end());
    }
    Int ans=0;
    for(Int len=1;len<=4;len++){
      ans+=dfs(len,0,(len==1),0);
      ans%=MOD;
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3588
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

vector<ll> a;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    ll N, K;
    cin >> N >> K ;
    
    ll allsum = 0;
    rep(i, N ){
        ll inp; cin >> inp;
        a.pb(inp);
        if(inp > 0) allsum += inp;
    }

    
    ll partsum = 0;
    ll partpos = 0;
    rep(i,K){
        partsum += a[i];
        if(a[i] > 0) partpos += a[i];
    }
    
    ll ans = allsum - partpos;
    if(partsum > 0) ans += partsum;
    
    
    rep(i, N){
        if(i <= (K-1)) continue;
        
        if(a[i-K]>0) partpos-=a[i-K];
        partsum -= a[i-K];
        if(a[i] > 0) partpos += a[i];
        partsum += a[i];
        
        ll ansafter = allsum -partpos;
        if(partsum > 0) ansafter += partsum;

        ans = max(ans, ansafter);
    }
    
    
    cout << ans << endl;
    
    
    
    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
k,n=map(int,input().split())


a=list(map(int,input().split()))
max=0
a.sort()

for i in range(1,n):
    if max<abs(a[i]-a[i-1]):
        max=abs(a[i]-a[i-1])

if max<k-abs(a[0]-a[-1]):
    max=k-abs(a[0]-a[-1])

print(k-max)



Measured memory_bytes: 32236
// https://atcoder.jp/contests/abc107/tasks/abc107_b
// B - Grid Compression

#include<bits/stdc++.h>
using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    vector <string> a(H);
    vector <bool> del(W);
    int rm=0;
    for (int i=0; i<H; i++) cin >> a.at(i);
    for (int i=0; i<W; i++) del.at(i)=false;
    for (int j=0; j<W; j++) {
        bool remcol=true;
        for (int i=0; i<H; i++) {
            if (a.at(i).at(j)!='.') {
                remcol = false;
                break;
            }
        }
        if (remcol) {
            del.at(j)=true;
            rm++;
        }
    }
    for (int j=W-1; j>=0; j--) {
        if (del.at(j)) {
            for (int i=0; i<H; i++) a.at(i).erase(a.at(i).begin()+j);
        }
    }
    for (int i=0; i<H; i++) {
        for (int j=0; j<W-rm; j++) {
            if (a.at(i).at(j)!='.') {
                cout << a.at(i) + "\n";
                break;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int a=0,b=0;
  int num;
  cin>>num;
  if(num==5)
    a++;
  if(num==7)
    b++;
  cin>>num;
  if(num==5)
    a++;
  if(num==7)
    b++;
  cin>>num;
  if(num==5)
    a++;
  if(num==7)
    b++;
  if(a==2&&b==1)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
	return 0;
}

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

int main(){
    int r;cin >> r;
    cout << fixed << setprecision(15) <<  2*acos(-1)*r << endl;
}

Measured memory_bytes: 3772
import numpy as np

N = int(input())
W = list(map(int, input().split()))

ans = []

ans.append(str(sum(W) - 2 * sum([W[i] for i in range(N) if i % 2 == 1])))

for i in range(1, N):
    ans.append(str( 2*W[i-1] - int(ans[i-1])))

print(" ".join(ans))

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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<string> data(H);
  
  // 標準入力から読み込んで出力
  for (int i = 0; i < H; i++) {
    // 一行目 ##### を出力
    if (i == 0) {
      for (int j = 0; j < W+2; j++) cout << "#";
      cout << endl;
    }
    // データ出力
    cin >> data.at(i);
    cout  << "#" << data.at(i) << "#" << endl;

    // 最終行 ##### を出力
    if (i == H-1) {
      for (int j = 0; j < W+2; j++) cout << "#";
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3636
N, x = map(int, input().split())
A = list(map(int, input().split()))
num = 0
for i in range(N - 1):
    diff = A[i] + A[i + 1] - x
    if diff <= 0:
        continue
    if diff <= A[i + 1]:
        A[i + 1] -= diff
    else:
        A[i] -= (diff - A[i + 1])
        A[i + 1] = 0
    num += diff
print(num)


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

int main() {
  int K, s;
  string S, s1;
  cin >> K >> S;
  s = S.size();
    if (s<=K){
      cout << S << endl;
    }
    else {
      for (int i; i < K; i++){
        s1 += S.at(i);
      }
      cout << s1 << "..." << endl;
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

    string S;
	cin >> S;
	if(S == "ABC") cout << "ARC" << endl;
	else cout << "ABC" << endl;
}

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

const int N = 2e5 + 5, S = 2e3 + 5, MOD = 1e9 + 7;

int add(int x, int y) {
    return (x += y) >= MOD ? x - MOD : x;
}

int n, a[N], b[N], dp[S + S + 500][S + S + 500], inv[S * 5], fac[S * 5], ifac[S * 5];

int C(int x, int y) {
    return 1LL * fac[x] * ifac[y] % MOD * ifac[x - y] % MOD;
}

int main() {
    inv[0] = inv[1] = fac[0] = ifac[0] = 1;
    for (int i = 2; i <= S * 4; ++i) inv[i] = 1LL * inv[MOD % i] * (MOD - MOD / i) % MOD;
    for (int i = 1; i <= S * 4; ++i) fac[i] = 1LL * fac[i - 1] * i % MOD;
    for (int i = 1; i <= S * 4; ++i) ifac[i] = 1LL * ifac[i - 1] * inv[i] % MOD;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d%d", &a[i], &b[i]);
        dp[S - a[i]][S - b[i]]++;
    }
    for (int i = 1; i <= S + S; ++i) {
        for (int j = 1; j <= S + S; ++j) {
            dp[i][j] = add(dp[i][j], add(dp[i][j - 1], dp[i - 1][j]));
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans = add(ans, dp[S + a[i]][S + b[i]]);
        ans = add(ans, MOD - C(a[i] + a[i] + b[i] + b[i], a[i] + a[i]));
    }
    printf("%d\n", 1LL * ans * inv[2] % MOD);
    return 0;
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

template<i64 M>
struct modint {
    i64 x;

    constexpr modint(const i64 y = 0) noexcept : x(y >= 0 ? y % M : (M - (-y) % M) % M) {}

    constexpr modint operator-() const noexcept { return modint(-x); }
    constexpr modint operator+(const modint &rhs) const noexcept { return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const noexcept { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const noexcept { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const noexcept { return modint(*this) /= rhs; }

    constexpr modint &operator+=(const modint &rhs) noexcept {
        x += rhs.x;
        if (x >= M) x -= M;
        return *this;
    }

    constexpr modint &operator-=(const modint &rhs) noexcept {
        if (x < rhs.x) x += M;
        x -= rhs.x;
        return *this;
    }

    constexpr modint &operator*=(const modint &rhs) noexcept {
        x = x * rhs.x % M;
        return *this;
    }

    constexpr modint &operator/=(const modint &rhs) noexcept {
        i64 a = rhs.x, b = M, u = 1, v = 0;
        while (b > 0) {
            i64 t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        *this *= u;
        return *this;
    }

    friend ostream &operator<<(ostream &os, const modint &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, modint &a) {
        i64 t;
        is >> t;
        a = modint(t);
        return is;
    }
};

constexpr i64 MOD = 1 ? 1'000'000'007 : 998'244'353;
using m64 = modint<MOD>;
constexpr m64 operator"" _m(unsigned long long n) { return m64(n); }

void solve() {
    i64 n, k;
    cin >> n >> k;

    vector<m64> dp(k + 1);
    dp[k] = 1;
    for (i64 i = 0; i < n; i++) {
        i64 a;
        cin >> a;
        queue<m64> q;
        m64 sum = 0;
        for (i64 j = k; j >= 0; j--) {
            q.emplace(dp[j]);
            sum += dp[j];
            if ((i64) q.size() > a + 1) {
                sum -= q.front();
                q.pop();
            }
            dp[j] = sum;
        }
    }
    cout << dp[0] << endl;
}

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


Measured memory_bytes: 4916
#include<stdio.h>
int main()
{
int a,b,c,d,e,f,g,h,i,j,x;
scanf("%d%d%d%d%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f,&g,&h,&i,&j);
x=a+b+c+d+e+f+g+h+i+j;
printf("%d\n",x);
return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>
#include<queue>


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

using namespace std;


const int INF = 1<<28;


int main(){

	while(1){	
		int n,m;
		cin >> n >> m;
		if(n==0&&m==0) break;
		
		vector<vector<int>> L(n+1,vector<int>(n+1,INF));	
		vector<vector<int>> S(n+1,vector<int>(n+1,INF));

		int from,to,dist,r;string sl;	

		rep(i,m){
			cin >> from >> to >> dist >> sl;
			if(sl=="L"){
				L[from][to]=dist;
				L[to][from]=dist;
			}else{
				S[from][to]=dist;
				S[to][from]=dist;
			}
		}
	
		rep(i,n+1){
			L[i][i]=0;
			S[i][i]=0;
		}

		cin >> r;
		
		vector<int> z(r+1);
		rep(i,r) cin >> z[i];

		for(int k=0;k<n+1;++k){
			for(int i=0;i<n+1;++i){
				for(int j=0;j<n+1;++j) L[i][j] = min(L[i][j],L[i][k]+L[k][j]);
			}
		}


		for(int k=0;k<n+1;++k){
			for(int i=0;i<n+1;++i){
				for(int j=0;j<n+1;++j) S[i][j] = min(S[i][j],S[i][k]+S[k][j]);
			}
		}

		
		int dp[r][n+1]; 
		fill_n((int *)dp,sizeof(dp)/sizeof(int),INF);
		dp[0][z[0]] = 0;
		for (int i = 1; i < r; i++) {
			//????????????
			for (int j = 1; j <= n; j++) {
				if (dp[i-1][j] != INF) {
					dp[i][j] = dp[i-1][j] + L[z[i-1]][z[i]];
				} 
			}

			//?????????
			for(int j = 1; j<= n; j++){
				for(int k = 1;k<= n;k++){
					dp[i][k] = min(dp[i][k], dp[i-1][j] + L[z[i-1]][j] + S[j][k] + L[k][z[i]]);
				}
			}
		}
		 
		cout << *min_element(dp[r - 1], dp[r - 1]+n+1) << endl;
	
	}
	return 0;
}

Measured memory_bytes: 2316
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

ll H(ll a, ll b) {
	ll sum = 1;
	//b種類のやつからa個重複を許して取り出すのは(a + b - 1)!/a!(b - 1)! = a+b-1Ca通り
	for (ll i = 1; i <= a; i++) {
		sum *= (b + (i - 1));
//		sum %= (ll)MOD;
		sum /= i;
//		sum %= (ll)MOD;
	}
	return sum;
}

ll N, K;

int main() {
	cin >> N >> K;
	ll R = N - K;
	COMinit();
	for (int i = 0; i <= K - 1; i++) {
		ll Rsum = COM(R - (i - 1) + (i + 1) - 1, i + 1);
		ll Bsum = COM(K - 1, i);
//		ll Rsum = H(R - (i - 1), i + 1);
//		ll Bsum = H(K - i, i);
		ll sum = Rsum * Bsum;
		sum %= (ll)MOD;
		cout << sum << endl;
//		cout << "Rsum" << Rsum << endl;
//		cout << "Bsum" << Bsum << endl;
	}
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    using namespace std;
    using ll = long long;
    using P = pair<int,int>;
     
    int main(){
        double n;
        const double PI = (acos(-1));
        cin >> n;
        cout << fixed << setprecision(10) << 2*n*PI << endl;
        return 0;
    }

Measured memory_bytes: 3796
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int i = 100000;
    int year = 0;
    int x;
    scanf("%d",&year);
    while(year > 0){
        i = i * 1.05;
        x = i % 1000;
        if(x > 0){
            i = i + 1000 - x;
        }
        year--;
    }
    printf("%d\n",i);
    return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define pr pair<int,int>
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
    ios_base::sync_with_stdio(false);
      // #ifndef ONLINE_JUDGE
      //   freopen("input.txt", "r", stdin);
      //   freopen("output.txt", "w", stdout);
      // #endif
    int n; cin>>n;
    set<string> s;
    for(int i=0;i<n;i++){
        string x; cin>>x;
        s.insert(x);

    }
    cout<<s.size()<<"\n";
    return 0;
}

Measured memory_bytes: 19200
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static kyoupuro.Input;
using static kyoupuro.MyMath;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var a = NextInt();
            var b = NextInt();
            var t = NextInt();

            Console.WriteLine((t / a) * b);
        }
    }

    class MyMath {
        public const long mod = 1000000007;

        public static long Gcd(long a, long b) {
            return b == 0 ? a : Gcd(b, a % b);
        }

        public static List<long> Factor(long n) {
            var list = new List<long>();
            n = DivideToLimit(n, 2, list);
            n = DivideToLimit(n, 3, list);
            long sqrt = Sqrt(n);
            for (int i = 5; i <= n && i <= sqrt; i += 4) {
                n = DivideToLimit(n, i, list);
                i += 2;
                n = DivideToLimit(n, i, list);
            }
            if (n > 1) list.Add(n);
            return list;
        }

        public static long Sqrt(long n) {
            if (n < 0) return 0;
            long a = 0, tmp = 0, b = 0;
            for (int i = 62; i >= 0; i -= 2) {
                tmp = (b << 1) + 1 <= (n >> i) ? 1 : 0;
                a = a << 1 | tmp;
                n -= (((b << 1) + 1) * tmp) << i;
                b = (b << 1) + tmp + tmp;
            }
            return a;
        }

        static long DivideToLimit(long divisor, long dividend, List<long> list) {
            while (divisor % dividend == 0) {
                list.Add(dividend);
                divisor /= dividend;
            }
            return divisor;
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }
    }
}

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

int main()
{
    double n, notax, notax1, notax2;
    cin >> n;
    notax = n/1.08;
    notax1 = floor(notax);
    notax2 = ceil(notax);
    if(floor(notax1*1.08)==n){
        cout << notax1 << endl;
    }else if(floor(notax2*1.08)==n){
        cout << notax2 << endl;
    }else{
        cout << ":(" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;

// Mは使用する数字の数
const int M = 2;
// Nは出力する桁数
const int N = 10;

// bits全探索を再帰関数で実装している
// 0000000000
// 0000000001
// 0000000010
// ~
ll n, m, x;
ll MIN = INF;
vector<string> ans;

void dfs(vector<int> &A)
{
   // 終端条件
   if (A.size() == n)
   {
      string s;
      for (int i = 0; i < n; ++i)
      {
         s += A[i] + '0';
      }
      ans.pb(s);
      return;
   }

   for (int v = 0; v < 2; ++v)
   {
      A.push_back(v);
      dfs(A);
      A.pop_back();
   }
}

int main()
{
   cin.tie(0);
   ios::sync_with_stdio(false);
   cin >> n >> m >> x;
   ll c[n];
   ll a[n][m];
   for (ll j = 0; j < n; j++)
   {
      cin >> c[j];
      for (ll i = 0; i < m; i++)
      {
         cin >> a[j][i];
      }
   }
   vector<int> A;
   dfs(A);
   for (int i = 0; i < ans.size(); i++)
   {
      string s = ans[i];
      ll cnt = 0;
      ll vc[m];
      for (int k = 0; k < m; k++)
         vc[k] = 0;
      for (int j = 0; j < s.length(); j++)
      {
         if (s[j] == '0')
         {
         }
         else
         {
            cnt += c[j];
            for (int f = 0; f < m; f++)
            {
               vc[f] += a[j][f];
            }
         }
      }
      bool flag = false;
      for (int f = 0; f < m; f++)
      {
         if (vc[f] < x)
         {
            flag = true;
         }
      }
      if (!flag)
      {
         if (MIN > cnt)
            MIN = cnt;
      }
   }

   if (MIN != INF)
      cout << MIN << endl;
   else
      cout << -1 << endl;
}

Measured memory_bytes: 3796
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char suit;
  int value;
};
struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[],int n,int left,int mid,int right){
  int n1=0,n2=0,i,j,k;
  n1=mid-left;
  n2=right-mid;
  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1].value=SENTINEL;
  R[n2].value=SENTINEL;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i].value<=R[j].value){
      A[k]=L[i++];
    }
    else{
      A[k]=R[j++];
    }
  }
}

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

int partition(struct Card A[],int n, int p,int r){
  int i,j;
  struct Card t,x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}

void quickSort(struct Card A[],int n,int p,int r){
  int q;
  if(p<r){
    q=partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main(){
  int n,i,v;
  struct Card A[MAX],B[MAX];
  char S[10];
  int stable=1;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %d",S,&v);
    A[i].suit=B[i].suit=S[0];
    A[i].value=B[i].value=v;
  }
  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);
  
  for(i=0;i<n;i++){
    if(A[i].suit!=B[i].suit)stable=0;
  }
  if(stable==1)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].suit,B[i].value);
  }
  
  return 0;
}



Measured memory_bytes: 4000
#template
from collections import Counter
def inputlist(): return [int(j) for j in input().split()]
#template
N = int(input())
X = inputlist()
ans = 10**9+7
for i in range(110):
    k = 0
    for j in range(N):
        k += (X[j] - i)**2
    ans = min(ans,k)
print(ans)

Measured memory_bytes: 3316
#include<cstdio>

int main(){
    int A, B, C, X, Y;
    int AnsAllCmax, AnsAllCmin, AnsAB, Ans;
    scanf("%d%d%d%d%d", &A, &B, &C, &X, &Y);
    if(X >= Y){
        AnsAllCmax = X * C * 2;
        AnsAllCmin = Y * C * 2+ A * (X - Y);
    }else{
        AnsAllCmax = Y * C * 2;
        AnsAllCmin = X * C * 2 + B * (Y - X);
    }
    AnsAB = A * X + B * Y;
    Ans = AnsAB;
    if(AnsAllCmax < Ans) Ans = AnsAllCmax;
    if(AnsAllCmin < Ans) Ans = AnsAllCmin;
    printf("%d", Ans);
    return 0;
}

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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;


int main(){
  string s; cin>>s;
  rep(i,s.length()) s[i] = 'x';
  cout<<s<<endl;
}

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

long long n,k;
vector<long long> a;

bool C(long long x){
    long long num=0;
    for(int i=0;i<n;++i){
        num+=(a[i]+x-1)/x-1;
    }
    return num<=k;
}

int main(){
    cin>>n>>k;
    a.resize(n);
    for(long long i=0;i<n;++i) cin>>a[i];

    long long l=0,r=1e9+7;
    while(r-l>1){
        long long mid=(r+l)/2;
        (C(mid)?r:l)=mid;
    }

    cout<<r<<endl;
}

Measured memory_bytes: 4728
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

#define HMAX (300)
#define WMAX (300)
map<pair<int, int>, int> FromTo;
int ans[100000];
pair<int, int> place[HMAX * WMAX + 1];

int main()
{
	int H, W, D, A, Q, L, R;
	int total, start;
	pair<int, int> from, to;

	cin >> H >> W >> D;

	repc(i, 1, H) {
		repc(j, 1, W) {
			cin >> A;
			place[A] = make_pair(i, j);
		}
	}

	repc(i, 1, D) {
		FromTo[make_pair(i, i)] = 0;

		total = 0;
		from = place[i];

		for (int j = i + D; j <= H * W; j += D) {
			to = place[j];
			total += abs(from.first - to.first) + abs(from.second - to.second);
			FromTo[make_pair(i, j)] = total;
			from = to;
		}
	}

	cin >> Q;

	rep(i, Q) {
		cin >> L >> R;

		if (L % D == 0) start = D;
		else start = L % D;

		ans[i] = FromTo[make_pair(start, R)] - FromTo[make_pair(start, L)];
	}

	rep(i, Q) cout << ans[i] << endl;

	return 0;
}


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

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

int main(){
  int x,y,z;
  cin >> x >> y >> z;
  swap(x,y);
  swap(x,z);
  cout << x << " " << y << " " << z << endl;
  return 0;
}


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

theNumber = [-1 for x in range(n)]
valid = True
for i in range(m):
    if (valid):
        s,c = map(int, input().split())
        if (s == 1 and c == 0):
            if (n != 1):
                valid = False
        elif theNumber[s-1] != -1 and theNumber[s-1] != c:
            valid = False
        else:
            theNumber[s-1] = c
    else:
        break

if (not valid):
    print(-1)
else:
    num = list(map(lambda x: 0 if x==-1 else x, theNumber))
    if (num[0] == 0 and n != 1):
        num[0] = 1
    print(''.join(map(str, num)))
    


Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long power = 1L;
		for(int i = 1; i <= N; i++) {
			power = (long)(power * i) % 1000000007;
		}
		System.out.println(power);
	}
}


Measured memory_bytes: 23124
N = gets.to_i
A, B, C = 3.times.map { arry = gets.split.map(&:to_i); arry.unshift(2 * N) }

sum = (2 .. N).inject(B[A[1]]) do |s, j|
  i = A[j]
  i_ = A[j-1]
  b = B[i]
  c = C[i_]
  i_ + 1 == i ? s + b + c : s + b
end
puts sum

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()
#define ld long double

using namespace std;	

int main() {	
	int n, a, ans = 0;
	scanf ("%d", &n);
	rep(i, 1, n) {
		scanf ("%d", &a);
		ans += ((i & 1) & (a & 1));
	}
	printf ("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 3772
#include<stdio.h>
#include<cstdio>
#include<iostream>
using namespace std;

int s[112345];
int main()
{
	int i,n;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>s[i];
	}
	int a=0;
	int mx=0;
	for(i=n-1;i>=1;i--){
		if(s[i]>=s[i+1]){
			a++;
			mx=max(mx,a);
		}
		else{
			mx=max(mx,a);
			a=0;
		
		}
	}
	cout<<mx<<endl;
}


Measured memory_bytes: 640
import java.util.*;

class Main{
	
    public static void main(String[] args){

	Scanner sc = new Scanner(System.in);

	int P = sc.nextInt();

	int Q = sc.nextInt();

	int R = sc.nextInt();

	if(P<=R && Q<=R){

	System.out.println(P+Q);

   }

	else if (P<=Q && R<=Q){

	System.out.println(P+R);

   }

	else{

	System.out.println(Q+R);

   }

  }
 }

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


int main() {
    int N, M, A, B;
    cin >> N >> M;
    vector<pair<ll, ll>> AB;
    rep(i,N) {
        cin >> A >> B;
        AB.push_back(make_pair(A, B));
    }
    sort(AB.begin(), AB.end());
    int cnt = 0;
    ll price = 0;
    rep(i,N) {
        if (cnt + AB.at(i).second >= M) {
            price += AB.at(i).first * (M - cnt);
            cout << price << endl;
            return 0;
        } else {
            cnt += AB.at(i).second;
            price += AB.at(i).first * AB.at(i).second;
        }
    }
}


Measured memory_bytes: 5364
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

long int const MAX_N = 200001;
long int bit[MAX_N + 1];
long int n_bit;
long int n;
long int a[MAX_N];

void init(long int n){
    for (long int i = 0; i <= n; i++){
        bit[i] = 0;
    }
}


long int sum(long int i){
    long int s = 0;
    while (i > 0){
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void add(long int i, long int x){
    while (i <= n_bit){
        bit[i] += x;
        i += i & -i;
    }
}

long int f(long int s){
    return s + n + 1;
}

bool func(long int m){
    long int num = 0;
    long int b[n];
    rep(i, n){
        if (a[i] >= m) b[i] = 1;
        else b[i] = -1;
    }
    long int s[n+1];
    s[0] = 0;
    rep(i, n) s[i+1] = s[i] + b[i];
    init(n_bit);
    rep(i, n + 1){
        num += sum(f(s[i]));
        add(f(s[i]), 1);
        // cout << f(s[i]) << " " << s[i] << endl;
        // rep(i, n_bit) cout << bit[i] << " ";
        // cout << endl;
        // cout << num << endl;
    }




    long int sm = (n * (n + 1)) / 2;
    return num >= (sm / 2);
}


int main(){
    cin >> n;
    n_bit = 2 * n + 1;
    long int asort[n];
    rep(i, n) {
        cin >> a[i];
        asort[i] = a[i];
    }
    sort(asort, asort + n);
    long int l = 0;
    long int r = n - 1;
    while(l < r - 1){
        long int mid = (l + r) / 2;
        if (func(asort[mid])){
            l = mid;
        }else{
            r = mid;
        }
    }
    // cout << l << " " << r << endl;
    if (func(asort[r])){
        cout << asort[r] << endl;
    }else{
        cout << asort[l] << endl;
    }
    
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                             \
  cerr << __LINE__ << ": " << #x << " = {";          \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) { \
    cerr << ((hoge) ? "," : "") << x[hoge];          \
  }                                                  \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  cout << (S == "AAA" || S == "BBB" ? "No" : "Yes") << endl;
  return 0;
}


Measured memory_bytes: 3628
//============================================================================
// 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

//============================================================================
void sort(int *a, int *b)
{
    int c;

    if (*a<*b){
        c=*a;
        *a=*b;
        *b=c;
    }
}
//============================================================================
void enter(FILE *file)
{
    int a,b,c;

    fscanf(file, "%d", &a);
    fscanf(file, "%d", &b);
    fscanf(file, "%d", &c);
    sort(&a, &b);
    sort(&b, &c);
    sort(&a, &b);
    printf("%d %d %d\n", c, b, a);
}
//============================================================================
int main(void)
{
    enter(stdin);
    return 0;
}
//============================================================================

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

int main()
{
    int n;
    cin>>n;
    int arr[n+5];
    int frr[n+5];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        frr[i]=(-1)*arr[i];
    }
    long long dp[n+5][2];
    dp[0][0]=0;
    dp[0][1]=-999999999;
    for(int i=0;i<n;i++)
    {
        dp[i+1][0]=max(dp[i][0]+arr[i],dp[i][1]-arr[i]);
        dp[i+1][1]=max(dp[i][0]-arr[i],dp[i][1]+arr[i]);
    }
    cout<<dp[n][0]<<endl;
}


Measured memory_bytes: 2560