akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int N,K;
    cin>>N>>K;
    string S;
    cin>>S;
    S[K-1]+='a'-'A';
    cout<<S<<endl;
}


Measured memory_bytes: 256
/*input
2
1 2 3
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
vector<int> v;

bool check(){
	int n=(SZ(v))/2;

	int idx=-1;
	for(int i=1;i<SZ(v)-1;i++){
		if(v[i]!=v[i+1]&&v[i]!=v[i-1]) continue;
		if(abs(i-n)<abs(idx-n)) idx=i;
	}
	if(idx==-1){
		return v[0];
	}
	return v[idx];
}

int a[maxn];
int main()
{
	IOS;
	int n;
	cin>>n;
	REP(i,n+n-1) cin>>a[i];

	int l=1,r=2*n;
	while(l!=r-1){
		int mid=(l+r)/2;
		v.clear();
		REP(i,n+n-1) v.pb((a[i]<mid));
		// REP(i,SZ(v)) cout<<v[i]<<" \n"[i==SZ(v)-1];
		if(check()) r=mid;
		else l=mid;
		// cout<<check()<<'\n';
	}
	cout<<l<<'\n';
	return 0;
}


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

struct Data{

    int y,x,c;

    Data(int ny, int nx, int nc):y(ny),x(nx),c(nc){}    
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h,w; cin >> h >> w;
    int ch, cw, dh, dw; cin >> ch >> cw >> dh >> dw;
    --ch; --cw; --dh; --dw;
    vector<string> s(h);
    rep(i,h) cin >> s[i];

    queue<Data> que, que2;
    vector<vector<int>> v(h, vector<int>(w, -1));
    
    int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
    que.emplace(ch,cw,0);
    while(!que.empty()){
        // bfs
        while(!que.empty()){
            Data now = que.front();
            
            que.pop();
            int y = now.y, x = now.x, c = now.c;
            if((v[y][x] != -1 && v[y][x] <= c) || s[y][x] == '#') continue;
            que2.emplace(y, x, c);
            v[y][x] = c;
            rep(i,4){
                int ny = y + dy[i], nx = x + dx[i];
                if(ny < 0 || ny >= h || nx < 0 || nx >= w || s[ny][nx] == '#' || (v[ny][nx] != -1 && v[ny][nx] <= c) || s[ny][nx] == '#') continue;
                que.emplace(ny, nx, c);
            }
        }
        
        // 列挙
        while(!que2.empty()){
            Data now = que2.front();
            int y = now.y, x = now.x, c = now.c;
            que2.pop();
            for(int i = -2; i <= 2; ++i){
                for(int j = -2; j <= 2; ++j){
                    int ny = y + i, nx = x + j;
                    if(ny < 0 || ny >= h || nx < 0 || nx >= w || s[ny][nx] == '#' || (v[ny][nx] != -1 && v[ny][nx] <= c+1) || s[ny][nx] == '#') continue;
                    que.emplace(ny, nx, c+1);
                }
            }
        }
    }
    cout << v[dh][dw] << endl;
}

Measured memory_bytes: 8760
#include <bits/stdc++.h>
using namespace std;
int n,m,fa[200005],s[200005];
int get(int x){if(x==fa[x])return x;return fa[x]=get(fa[x]);}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		fa[i]=i;s[i]=1;
	}
	for(int i=1;i<=m;i++)
	{
		int x,y;
		cin>>x>>y;
		int gx=get(x),gy=get(y);
		if(gx==gy)continue;
		s[gy]+=s[gx];
		fa[gx]=gy;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans=max(s[i],ans);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5168
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;
 
 int dp[10][10];
 int kk[10];
 int mp[202][202];

 int main()
 {
   int n,m;
   while(cin>>n>>m)
   {
     int sum=0;
     for(int i=0;i<10;i++) for(int j=0;j<10;j++) cin>>dp[i][j];
     for(int k=0;k<10;k++)
     {
       for(int i=0;i<10;i++)
       {
         for(int j=0;j<10;j++)
         {
           if(dp[i][j]>(dp[i][k]+dp[k][j])) dp[i][j]=dp[i][k]+dp[k][j];        
         }        
       }        
     }  
     for(int i=0;i<10;i++) kk[i]=dp[i][1]; 
     for(int i=0;i<n;i++)
     {
       for(int j=0;j<m;j++)
       {
         cin>>mp[i][j];
         if(mp[i][j]==-1) sum=sum;
         else sum=sum+dp[mp[i][j]][1];
       }        
     }
     cout<<sum<<endl;
   }
   return 0;
 }
 

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
int main(){
    int N, count = 0;
    cin >> N;
    vector<int> a(N);
    vector<int> b(N);
    vector<int> c(N);
    rep(i,N){
        cin >> a[i];
    };
    rep(i,N){
        cin >> b[i];
    };
    rep(i,N - 1){
        cin >> c[i];
    }
    c[N - 1] = 0;
   rep(i,N){
       if(a[i] == a[i - 1] + 1){
           count += (b[a[i] - 1 ] + c[a[i] - 2]);
       }
       else
       {
        count += b[a[i] - 1];
       }  
   };
   cout << count << endl;
}

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

public class Main{
	
	static long mod=(long)1e9+7;
	
	public static void main(String[] args) throws IOException {
		Writer out=new Writer(System.out);
		Reader in=new Reader(System.in);
		int ts=1;
		
		outer: while(ts-->0) {	
			int n=in.nextInt(); int k=in.nextInt();
			Set<Integer> set=new HashSet<>();
			for(int i=1; i<=n; i++) set.add(i);
			for(int i=0; i<k; i++) {
				int d=in.nextInt();
				int a[]=in.readArray(d);
				for(int j: a) if(set.contains(j)) set.remove(j);
			}
			out.println(set.size());
		}
		out.close();		
		
	}

	static boolean tri(int a, int b, int c) {
		if(c<a+b && c>abs(a-b)) return true;
		return false;
	}
	
	
/*********************************** UTILITY CODE BELOW **************************************/	
		
	static int abs(int a) {
		return a>0 ? a : -a;
	}
	
	static int max(int a, int b) {
		return a>b ? a : b;
	}
	
	static int pow(int n, int m) {
		if(m==0) return 1;
		int temp=pow(n,m/2);
		long res=(((long)temp*temp)%mod);
		if(m%2==0) return (int)res;
		return (int)((res*n)%mod);
	}
	
	static class Pair{
		int u, v;
		
		Pair(int u, int v){this.u=u; this.v=v;}
		
		static void sort(Pair [] coll) {		
			List<Pair> al=new ArrayList<>(Arrays.asList(coll));
			Collections.sort(al,new Comparator<Pair>() {
				public int compare(Pair p1, Pair p2) {
					return p1.u-p2.u;
				}	
			});
			for(int i=0; i<al.size(); i++) {
				coll[i]=al.get(i);
			}
		}
		
	}
	
	static void sort(int[] a) {
		ArrayList<Integer> list=new ArrayList<>();
		for (int i:a) list.add(i);
		Collections.sort(list);
		for (int i=0; i<a.length; i++) a[i]=list.get(i);
	}
	
	static void sort(long a[]) {
		ArrayList<Long> list=new ArrayList<>();
		for(long i: a) list.add(i);
		Collections.sort(list);
		for(int i=0; i<a.length; i++) a[i]=list.get(i);
	}
	
	static int [] array(int n, int value) {	
		int a[]=new int[n];
		for(int i=0; i<n; i++) a[i]=value;
		return a;
	}
	
	static class Reader{
		
		BufferedReader br;
		StringTokenizer to;
		
		Reader(InputStream stream){
			br=new BufferedReader(new InputStreamReader(stream));
			to=new StringTokenizer("");
		}
		
		String next() {
			while(!to.hasMoreTokens()) {
				try {
					to=new StringTokenizer(br.readLine());	
				}catch(IOException e) {}
				
			}
			return to.nextToken();
			
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int [] readArray(int n) {
			int a[]=new int[n];
			for(int i=0; i<n ;i++) a[i]=nextInt();
			return a;
		}
		long [] readLongArray(int n) {
			long a[]=new long[n];
			for(int i=0; i<n ;i++) a[i]=nextLong();
			return a;
		}
		
	}
	
	static class Writer extends PrintWriter{
		Writer(OutputStream stream){
			super(stream);
		}
		void println(int [] array) {
			for(int i=0; i<array.length; i++) {
				print(array[i]+" ");
			}
			println();
		}
		void println(long [] array) {
			for(int i=0; i<array.length; i++) {
				print(array[i]+" ");
			}
			println();
		}
	}
	
}

Measured memory_bytes: 35420
A,B,C,D = map(int,input().split())

def gcd(a,b):
    if a%b == 0:
        return b
    else:
        return gcd(b,a%b)

def num(N,c,d):
    lcm = (c*d)//gcd(c,d)
    return N - (N//c) - (N//d) +  N//lcm

print(num(B,C,D)-num(A-1,C,D))

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

int main() {
  int n;
  cin >>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  long long kotae=a[0];
  for(int i=1;i<n;i++){
    if(a[i]-a[i-1]>0)kotae+=a[i]-a[i-1];
  }
  cout<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double t = abs(360 / 12 * (H + M / 60)- 360 / 60 * M);
    if (t > 180) t = 360 - t;
    double ans = sqrt(A * A + B * B - 2 * A * B * cos(acos(-1) * t / 180));
    printf("%.9f\n", ans);
    return 0;
}

Measured memory_bytes: 4164
N = gets.to_i
s = N.times.map { gets.chomp }
M = gets.to_i
t = M.times.map { gets.chomp }

m = s.inject({}) {|acc, str|
  acc[str] ||= 0
  acc[str] += 1
  acc
}

m = t.inject(m) {|acc, str|
  acc[str] ||= 0
  acc[str] -= 1
  acc
}

puts [m.values.max, 0].max


Measured memory_bytes: 14316
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_11_D: Connected Components

#include <algorithm>
#include <climits>
#include <cstdio>
#include <vector>

using uint = unsigned int;

class Graph {
  std::vector<std::vector<uint>> g_;
  std::vector<uint> root_;
  
public:
  Graph(uint n)
  {
    g_.resize(n);
    root_.resize(n);
  }

  void add(uint from, uint to)
  {
    g_[from].push_back(to);
    g_[to].push_back(from);
  }

  void setup()
  {
    std::fill(root_.begin(), root_.end(), UINT_MAX);
    for (auto i = 0u; i < g_.size(); ++i ) {
      dfs(i, i);
    }
  }

  bool reachable(uint from, uint to) const
  {
    return root_[from] == root_[to];
  }

private:
  void dfs(uint i, uint root)
  {
    if (root_[i] != UINT_MAX) return;
    root_[i] = root;
    for (auto j = 0u; j < g_[i].size(); ++j) {
      dfs(g_[i][j], root);
    }
  }
  
};

int main()
{
  uint n, m;
  std::scanf("%u %u", &n, &m);

  Graph g(n);

  uint s, t;
  for (auto i = 0u; i < m; ++i) {
    std::scanf("%u %u", &s, &t);
    g.add(s, t);
  }
  g.setup();

  uint q;
  std::scanf("%u", &q);
  for (auto i = 0u; i < q; ++i) {
    std::scanf("%u %u", &s, &t);
    std::puts(g.reachable(s, t) ? "yes" : "no");
  }
}

// eof

Measured memory_bytes: 10108
#include <iostream>
#include <algorithm>

using namespace std;
using ll = long long;


int binary_search(int *a, int v, int b, int e){
  int m = (e+b)/2;
  if(v == a[m]) return m;
  return v < a[m] ? binary_search(a, v, b, m-1) : binary_search(a, v, m+1, e);
}

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

  int idx = 0;
  for(int i=0; i<s.size(); i++){
    if(i%w == 0){
      cout << s[i] ;
    }    
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

char output(int a){
    if(a < 10){
        return '0' + a;
    }else{
        return 'A' + (a - 10);
    }
}

int main(){
    int n, m, q;
    while(cin >> n >> m >> q, n||m||q){
        int d[40][1001];
        rep(i,40) rep(j,1001) d[i][j] = -1;
        string before;
        rep(i,m) before+='0';

        rep(i,q){
            bool swi[40] = {0};
            bool bul[1001] = {0};
            string s, b;

            cin >> s >> b;
            rep(j,n) if(s[j] == '1') swi[j] = 1;
            rep(j,m) if(b[j] != before[j]) bul[j] = 1;

            bool x, y;
            rep(j,n){
                if(swi[j] == 1) x = true;
                else x = false;
                rep(k,m){
                    if(bul[k] == 1) y = true;
                    else y = false;

                    if(x && y){
                        if(d[j][k] == -1) d[j][k] = 1;
                    }else if( (x && !y) || (!x && y) ){
                        d[j][k] = 0;
                    }
                }
            }
            before = b;
        }
        //rep(j,n){ rep(k,m){ cout << d[j][k] << ' '; } cout << endl; }
        if(n == 1){
            rep(j,m) cout << 0 << endl;
            continue;
        }

        rep(j,m){
            int isNotZero = 0;
            int out;
            rep(i,n){
                if(d[i][j] != 0){
                    isNotZero++;
                    out = i;
                }
            }
            if(isNotZero == 1){
                cout << output(out);
            }else{
                cout << '?';
            }
        }
        cout << endl;
        /*
        bool swi[40] = {0};
        rep(j,m){
            int cnt = -1;
            int num = 0;
            rep(i,n){
                if(swi[i]) num++;
                if(d[i][j] == 1 && cnt > 0){
                    cnt = -1;
                }else if(d[i][j] == 1){
                    cnt = i;
                }
            }
            if(cnt != -1){
                if(cnt < 10) cout << cnt;
                else cout << static_cast<char>('A' + (cnt - 10));
                swi[cnt] = 1;
            }else if(num == n - 1){
                rep(k,n){
                    if(not swi[k]){
                        if(k < 10) cout << k;
                        else cout << static_cast<char>('A' + (k - 10));
                        break;
                    }
                }
            }else cout << '?';
        }
        cout << endl;
        */
    }
}

Measured memory_bytes: 3336
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main() {
	string s;
	cin >> s;
	string mae = s.substr(0, 2);
	string usiro = s.substr(2, 2);
	if (mae >= "13"&&mae <= "99"&&usiro >="01" && usiro <= "12") {
		cout << "YYMM" << endl;
	}
	else if (mae == "00"&&usiro >= "01"&&usiro <= "12") {
		cout << "YYMM" << endl;
	}
	else if (mae >= "01"&&mae <= "12"&&usiro >= "01" && usiro <= "12") {
		cout << "AMBIGUOUS" << endl;
	}
	else if (mae >= "01"&&mae <= "12"&&usiro >= "00" && usiro <= "99") {
		cout << "MMYY" << endl;
	}
	else {
		cout << "NA" << endl;
	}
	

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>

using namespace std;
using ll = long long;

#define rep(i, n)      for (int i = 0; i < (n); i++)
#define repr(i, n)     for (int i = (n) - 1; i >= 0; i--)
#define repe(i, l, r)  for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r) - 1; i >= (l); i--)
#define repi(i, l, r)  for (int i = (l); i <= (r); i++)
#define repir(i, l, r) for (int i = (r); i >= (l); i--)
#define range(a) a.begin(), a.end()
void init_io() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

struct unionfind {
  vector<int> dat;

  unionfind(int n) : dat(n, -1) {}

  int find(int x) {
    if (dat[x] < 0) return x;
    return dat[x] = find(dat[x]);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (dat[x] > dat[y]) swap(x, y);
    dat[x] += dat[y];
    dat[y] = x;
  }

  int size(int x) {
    return -dat[find(x)];
  }
};

bool solve() {
  int N; cin >> N;
  vector<int> A(N); rep(i, N) cin >> A[i];
  vector<int> B(N); rep(i, N) cin >> B[i];
  vector<int> tmpA(A);
  vector<int> tmpB(B);
  sort(range(tmpA));
  sort(range(tmpB));
  rep(i, N) {
    if (tmpA[i] > tmpB[i]) return false;
  }
  rep(i, N) {
    int cnt = upper_bound(range(tmpA), tmpB[i]) - tmpA.begin();
    if (cnt >= i + 2) return true;    
  }
  unionfind uf(N);
  vector<int> ordA(N); rep(i, N) ordA[i] = i;
  vector<int> ordB(N); rep(i, N) ordB[i] = i;
  sort(range(ordA), [&](int i, int j) { return A[i] < A[j]; });
  sort(range(ordB), [&](int i, int j) { return B[i] < B[j]; });
  rep(i, N) {
    uf.unite(ordA[i], ordB[i]);
  }
  int roots = 0;
  rep(i, N) {
    if (uf.find(i) == i) roots++;
  }
  return roots != 1;
}

int main() { init_io();
  cout << (solve() ? "Yes" : "No") << endl;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    int sum_of_palindrome = 0;
    {
        int i1, i2, i4, i5;
        for (int i = a; i <= b; ++i) {
            i1 = i % 10, i5 = i / 10000 % 10;
            i2 = i / 10 % 10, i4 = i / 1000 % 10;
            if (i1 == i5 && i2 == i4) sum_of_palindrome++;
        }
    }
    cout << sum_of_palindrome << endl;
}


Measured memory_bytes: 3596
from sys import stdin
input=lambda : stdin.readline().strip()
from math import ceil,sqrt,factorial,gcd
from collections import deque
from bisect import bisect_left,bisect_right
n,m=map(int,input().split())
graph={i:set() for i in range(1,n+1)}
for i in range(m):
	a,b=map(int,input().split())
	graph[a].add(b)
	graph[b].add(a)
v=set()
z=[]
def dfs(x):
	st=[x]
	while st:
		x=st.pop()
		if x not in v:
			z[-1]+=1
			for i in graph[x]:
				if i not in v:
					st.append(i)
			v.add(x)
for i in range(1,n+1):
	if i not in v:
		z.append(0)
		dfs(i)
print(max(z))

Measured memory_bytes: 168724
import collections


def solve():
    N, X, Y = map(int, input().split())

    inf = 10**9

    # 頂点=v 距離=d
    def pus(v, d, dist, q):
        if dist[v] == inf:
            dist[v] = d
            q.append(v)
        return 0

    ans = [0]*N

    for i in range(N):
        dist = [inf]*N
        q = collections.deque()
        pus(i, 0, dist, q)
        while len(q) != 0:
            v = q.popleft()
            d = dist[v]
            if (v-1 >= 0):
                pus(v-1, d+1, dist, q)
            if (v+1 < N):
                pus(v+1, d+1, dist, q)
            if v == X-1:
                pus(Y-1, d+1, dist, q)
            if v == Y-1:
                pus(X-1, d+1, dist, q)
        for i in range(N):
            ans[dist[i]] = ans[dist[i]]+1
    for i in range(1, N):
        print(ans[i]//2)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 50908
#include<stdio.h>
#include<stdlib.h>
int flag1(int x,int y,int a,int b,int c){
  int ans;
  if(x>y){
    ans=y*c*2+(x-y)*a;
    if(x*c*2<ans){
      ans=x*c*2;
    }
  }
  else{
    ans=x*c*2+(y-x)*b;
    if(y*c*2<ans){
      ans=y*c*2;
    }
  }
  return ans;
}


int main(){
  int a,b,c,x,y;
  scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
  int flag;
  if((a+b)>2*c){
    flag=1;//Cを優先に買うべきパターン
  }else{
    flag=2;//Cを優先すべきでないパターン
  }
  if(flag==1){
    printf("%d",flag1(x,y,a,b,c));
  }
  else{
    printf("%d",x*a+y*b);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define tam 5000
#define offset 320000
#define se second
#define fi first
#define pitem item*
#define forr(i,p,n) for(int i=p;i<n;i++)
using namespace std;
typedef long long ll;
const ll MOD=1000000007 ;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef  double lld;
string go(int x,int y,int xf,int yf)
{
    string txt;
    while(y>yf)
        txt+="D",y--;
    while(y<yf)
        txt+="U",y++;
    while(x>xf)
        txt+="L",x--;
    while(x<xf)
        txt+="R",x++;
    return txt;
}
int main()
{
    string txt1,txt2;
    
    //cout<<txt1.size()<<endl;
    int x,y,xf,yf;
    cin>>x>>y>>xf>>yf;
    txt1=go(x,y,xf,yf);
    txt2=go(xf,yf,x,y);
    cout<<txt1+txt2+"LU"+txt1+"RDRD"+txt2+"LU"<<endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        long c = Long.parseLong(sc.next());
        if (c - a - b > 0 && (4 * a * b < (c - a - b) * (c - a - b))) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <time.h>
#include <unordered_map>

using namespace std;

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++)
  {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    g[a[i]].push_back(b[i]);
    g[b[i]].push_back(a[i]);
  }

  vector<int> v(n, -1);
  v[0] = 0;
  vector<bool> seen(n, false);
  seen[0] = true;
  vector<int> prev;
  vector<int> next = {0};

  for (int i = 0; i < n; i++)
  {
    prev = next;
    next = {};
    for (int j : prev)
    {
      for (int k : g[j])
      {
        if (!seen[k])
        {
          v[k] = j;
          next.push_back(k);
          seen[k] = true;
        }
      }
    }
  }

  cout << "Yes" << endl;
  for (int i = 1; i < n; i++)
  {
    cout << v[i] + 1 << endl;
  }
}


Measured memory_bytes: 12140
#include <iostream>
#include <string>
#include <sstream>
#include <climits>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif

    int n;
    cin >> n;
    vector<pair<string, int>> v{{"AC", 0}, {"WA", 0}, {"TLE", 0}, {"RE", 0}};
    for(int i = 0; i < n; ++i) {
        string str;
        cin >> str;
        if(str == "AC") {
            v[0].se++;
        }
        else if(str == "WA") {
            v[1].se++;
        }
        else if(str == "TLE") {
            v[2].se++;
        }
        else {
            v[3].se++;
        }
    }
    for(int i = 0; i < (int) v.size(); ++i) {
        cout << v[i].fi << " x " << v[i].se << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
//
// Created by Myabu on 2020/01/26.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;


int main(void){
    int N,K;
    string S;
    cin>>N>>K;
    cin>>S;

    S[K-1] = S[K-1]+32;

//    cout<<(int)'A'-'a'<<endl;

    cout<<S<<endl;


    return 0;
}

Measured memory_bytes: 256
//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define forn(f,n) for(int i=f;i<f+n;i++)
#define rforn(l,n) for(int i=l;i>l-n;i--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int i=f;i<f+n;i++) cin>>V[i];
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 1e9+7,MAX = 1005;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
//////////////////Sieve////////////////////



int main()
{
	int n;
	cin>>n;
	map<string,int> M;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		M[s]++;
	}
	int ma=0;
	vector<string> V;
	for(auto m:M)
	{
		ma=max(ma,m.second);
	}
	for(auto m:M)
	{
		if(m.second==ma)
		{
			V.push_back(m.first);
		}
	}
	sort(all(V));
	for(auto x:V)
	{
		cout<<x<<endl;
	}


}		

Measured memory_bytes: 26868
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            total = 500*i + 100*j + 50*k
            if total == x:
                count = count + 1
print(count)


Measured memory_bytes: 2940
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush


def solve():
    n, p = MI()

    def prime_factorization(n):
        res = []
        for i in range(2, int(pow(n, 0.5)) + 1):
            if n % i: continue
            ex = 0
            while n % i == 0:
                n = n // i
                ex += 1
            res.append((i, ex))
        if n != 1:
            res.append((n, 1))
        return res

    fact = prime_factorization(p)
    # print(fact)

    ans = 1
    for (num, ex) in fact:
        # print(num, ex)
        while ex >= n:
            ans *= num
            ex -= n
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 4084
#if __has_include("../library/Basic/Debug.hpp")

#include "../library/Basic/Debug.hpp"

#else

/* ----- Header Files ----- */
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>
#include <cstdint>


/* ----- Type Alias ----- */
using Bool = bool;
using Int = long long int;
using Real = long double;
using Char = char;
using String = std::string;
template <class T, class U>
using Pair = std::pair<T, U>;
template <class... Ts>
using Tuple = std::tuple<Ts...>;

template <class T>
using Vector = std::vector<T>;
template <size_t N>
using Bits = std::bitset<N>;
template <class T>
using Queue = std::queue<T>;
template <class T>
using Stack = std::stack<T>;
template <class T>
using Deque = std::deque<T>;

template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T>
using Set = std::set<T>;
template <class T, class U>
using Map = std::map<T, U>;

template <class T, class... Us>
using Func = std::function<T(Us...)>;

template <class T>
T genv(T v) { return v; }

template <class T, class... Ts>
auto genv(size_t l, Ts... ts) {
    return Vector<decltype(genv<T>(ts...))>(l, genv<T>(ts...));
}

template <class Cost = Int>
struct Edge {
    Int src, dst;
    Cost cost;
    Edge(Int src = -1, Int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = Int>
using Edges = Vector<Edge<Cost>>;
template <class Cost = Int>
using Graph = Vector<Vector<Edge<Cost>>>;

#endif

/* ----- Misc ----- */
void fastio() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

struct Fout {
    Int precision;
    Fout(Int precision) : precision(precision) {}
};
std::ostream& operator<<(std::ostream& os, const Fout& fio) {
    os << std::fixed << std::setprecision(fio.precision);
    return os;
}


/* ----- Constants ----- */
// constexpr Int INF = std::numeric_limits<Int>::max() / 3;
// constexpr Int MOD = 1000000007;
// constexpr Real PI = acos(-1);
// constexpr Real EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));

int main() {
    Int n;
    std::cin >> n;
    std::cout << n * n * n << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;

#define st              first
#define nd              second
#define pb              push_back
#define pf              push_front
#define all(a)          (a).begin(), (a).end()
#define lwb             lower_bound
#define upb             upper_bound
#define vvll            vector<vector<ll> >
#define Mset(s, n)      memset(s, n, sizeof(s))
#define Sz(a)           int((a).size())
#define Max(a, b, c)    max(max((ll)(a), (ll)(b)), (ll)(c))
#define Min(a, b, c)    min(min((ll)(a), (ll)(b)), (ll)(c))
#define Unique(a)       sort(all(a)); (a).resize(unique(all(a)) - (a).begin())

typedef long double ld;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

const ll MOD = 1e9 + 7;
const int oo = 2e9;
const ld PI = acos((ld) -1);
int Getbit(ll x, int k){return (x >> (k - 1)) & 1;}
ll Lcm(ll a, ll b) {return a / __gcd(a, b) * b;}
bool isPrime(ll n){for(ll i = 2; i * i <= n; i++){if(n % i == 0) return 0;} return (n > 1) ? 1 : 0;}
ll Powmod(ll n, ll k, ll p = MOD) {ll r = 1; for(; k; k /= 2, n = n * n % p){if(k & 1) r = r * n % p;} return r;}

const int N = 2e5 + 5;

ll n, m, query;

ll a[N];
int d[10];
double sum = 0;
double ans;
pair<int, int> p[N];

double dist(int i, int j){
    int x1 = p[i].st, y1 = p[i].nd;
    int x2 = p[j].st, y2 = p[j].nd;
    return (double) sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

void Try(int i, int k){
    d[i] = 1;
    for(int j = 1; j <= n; j++){
        if(!d[j]){
            sum += dist(i, j);
            if(k == n - 1){
                ans += sum;
            }
            else Try(j, k + 1);
            sum -= dist(i, j);
        }
    }
    d[i] = 0;
}
void Solve(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> p[i].st;
        cin >> p[i].nd;
    }
    for(int i = 1; i <= n; i++) Try(i, 1);
    int k = 1;
    for(int i = 1; i <= n; i++){
        k *= i;
    }
    printf("%.10lf", ans / k);
}

int main(){
    Speed;
    int query = 1; // cin >> query;
    while(query--){
        Solve();
    }
}






Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, K;
  cin >> N >> K;
  ll ans = K * pow(K - 1, N - 1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4004
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using vvint = vector<vint>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

ll pow2(ll x) { return x * x; }

double dist(ll x1, ll y1, ll x2, ll y2) {
    return sqrt(pow2(x2 - x1) + pow2(y2 - y1));
}

void solve(long long N, std::vector<long long> x, std::vector<long long> y){
    vint seq(N);
    iota(all(seq), 0);

    double sum = 0;
    do {
        rep(i, N-1) {
            sum += dist(x[seq[i]], y[seq[i]], x[seq[i+1]], y[seq[i+1]]);
        }
    } while(next_permutation(all(seq)));

    double frac_n = 1;
    rep(i, N) frac_n *= i+1;

    printf("%.7f\n", sum / frac_n);
}

// Generated by atcoder-tools ver.1.1.6
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
        x[i] += 1000;
        y[i] += 1000;
    }
    solve(N, std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 256
s = list(input())
ls = [0]
j = 1
k = 0
n = 0

for i in range(len(s)):
    if j == len(s)+1:
        break
    if "".join(s[k:j]) != ls[n]:
        ls.append("".join(s[k:j]))
        k = j
        j += 1
        n += 1
    else:
        j += 1
                    
print(len(ls)-1)
            

Measured memory_bytes: 9348
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(n), b(n);
    for (auto &e : a) std::cin >> e;
    for (auto &e : b) std::cin >> e;
    for (int i = 0; i < n; i++) {
        if (b[i] && b[i] * 2 >= a[i] && b[i] != a[i]) {
            std::cout << -1 << std::endl;
            return 0;
        }
    }

    i64 ret = 0;
    constexpr int inf = 100000;
    for (int i = 50; i > 0; i--) {
        std::vector<std::vector<int>> dist(51, std::vector<int>(51, inf));
        i64 bi = (1ll << i) - 1 + ret;
        for (int j = 0; j < 51; j++) dist[j][j] = 0;
        for (int k = 1; k < 51; k++) {
            if (((1ll << k) & bi) == 0) continue;
            for (int j = k; j < 51; j++) {
                dist[j][j % k] = 0;
            }
        }
        for (int k = 0; k < 51; k++) for (int i = 0; i < 51; i++) for (int j = 0; j < 51; j++) {
            dist[i][j] = std::min(dist[i][j], dist[i][k] + dist[k][j]);
        }

        bool flg = false;
        for (int j = 0; !flg && j < n; j++) {
            if (dist[a[j]][b[j]]) flg = true;
        }

        if (flg) ret += 1ll << i;
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 384
K,A,B = map(int,input().split())
ans = 1+K

rem = K-(A-1)
if rem <= 1:
    print(ans)
else:
    ans2 = A
    d,m = divmod(rem,2)
    ans2 += (B-A)*d
    ans2 += m
    print(max(ans, ans2))

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

console.log(main());
function main(){
  var k = o.a();
  var x = o.a();
  var ans = [];
  for(var i = x-k+1; i < x+k; i++){
    ans.push(i);
  }
  return ans.join(" ");
}


Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> void vdebug(vector<T> v){ cout << "vdebug" << endl; for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ cout << "adebug" << endl; reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
template<typename T1, typename T2> void mdebug(map<T1, T2> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebug(multimap<T1, T2> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mdebugr(map<T1, T2, greater<T1>> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebugr(multimap<T1, T2, greater<T1>> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


bool comp(const pair<int, int> p1, const pair<int, int> p2){
    if(p1.first == p2.first){
        return p1.second > p2.second;
    }
    return p1.first < p2.first;
}

ll dp[3010][3010];

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

    int n, t, a, b;
    vector<pair<int, int>> ab;
    cin >> n >> t;
    rep(i, n){
        cin >> a >> b;
        ab.push_back(make_pair(a, b));
    }

    sort(all(ab));

    ll res = 0;
    rep(i, n){
        dp[i][t-1] = 0;
    }
    rep(i, n){
        rep(j, t){
            if(j + ab[i].first < t){
                chmax(dp[i+1][j + ab[i].first], dp[i][j] + ab[i].second);
            }
            chmax(dp[i+1][j], dp[i][j]);
            chmax(res, dp[i][j] + ab[i].second);
        }
    }

    cout << res << endl;

    // for(auto const& e : ab){
    //     cout << e.first sp e.second << endl;
    // }

    return 0;
}


Measured memory_bytes: 70912
# -*- coding: utf-8 -*-


def main():
    n, m, q = map(int, input().split())
    summed = [[0 for _ in range(n + 1)] for _ in range(n + 1)]

    for _ in range(m):
        li, ri = map(int, input().split())
        summed[li][ri] += 1

    for i in range(1, n + 1):
        for j in range(1, n + 1):
            summed[i][j] += summed[i - 1][j]
            summed[i][j] += summed[i][j - 1]
            summed[i][j] -= summed[i - 1][j - 1]

    for _ in range(q):
        pi, qi = map(int, input().split())
        count = summed[qi][qi] - summed[pi - 1][qi] - summed[qi][pi - 1] + summed[pi - 1][pi - 1]
        print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 13472
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

int main (int argc, char* argv[]) {
	long long n, m, c;
	cin >> n >> m >> c;
	vector<long long> bb(m);
	for (long long i = 0; i < m; i++) {
		cin >> bb[i];
	}
	long long res = 0;
	for (long long i = 0; i < n; i++) {
		long long t = c;
		for (int j = 0; j < m; j++) {
			long long a;
			cin >> a;
			t += a * bb[j];
		}
		if (t  > 0) {
			res++;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void){
    int a,i,x;
    scanf("%d",&a);
    for(i=3;i<=a;i++){
        x = i;  
        if(x%3==0)
            printf(" %d",x);
        else{for( ; ;x/=10){
            if(x<1)
                break;
            if(x%10==3){
                printf(" %d",i);
                break;}
        }}
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 1828
#include<stdio.h>

int main()
{
   int A,B,i=1;
   while(1){
   scanf("%d",&A);
   if(A == 0){break;}
   if(A != 0)
    {
        printf("Case %d: %d\n",i,A);
    }
    i++;
   }
    return 0;
}



Measured memory_bytes: 2660
sx,sy,tx,ty=map(int,input().split())
ans=""
ans+="R"*(tx-sx)
ans+="U"*(ty-sy)
ans+="L"*(tx-sx)
ans+="D"*(ty-sy+1)
ans+="R"*(tx-sx+1)
ans+="U"*(ty-sy+1)
ans+="L"
ans+="U"
ans+="L"*(tx-sx+1)
ans+="D"*(ty-sy+1)
ans+="R"
print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys

def solve(N: int):
    if N%2 == 1:
        print(0)
    else:
        i = 1
        answer  = 0
        while 2*5**i <= N:
            answer += N//(2*5**i)
            i += 1
        print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M; cin >> N >> M;
  int card[100100];
  rep(i, N + 2) {
      card[i] = 0;
  }
  rep(i, M) {
      int L, R;
      cin >> L >> R;
      card[L] ++;
      card[R + 1] --;
  }
  rep(i, N + 2) {
      card[i + 1] = card[i + 1] + card[i];
  }
  int ans = 0;
  rep(i, N + 2) {
      if(card[i] == M) ans ++;
  }
  cout << ans << endl;
  return 0;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ls (rt << 1)
#define rs (rt << 1 | 1)
const ll mod = 998244353;
const int maxn = 200000 + 10;
ll p[10][maxn], base[maxn];
int cov[maxn << 2];
int len[maxn << 2];
ll T[maxn << 2];
void pushup(int rt)
{
	T[rt] = (T[ls] * base[len[rs]] % mod + T[rs]) % mod;
}
void build(int rt, int l, int r)
{
	len[rt] = r - l + 1;
	T[rt] = p[1][len[rt]];
	if(l == r) return;
	int mid = l + r >> 1;
	build(ls, l, mid); build(rs, mid + 1, r);
}
void lazy(int rt, int d)
{
	cov[rt] = d;
	T[rt] = p[d][len[rt]];
}
void pushdown(int rt)
{
	if(cov[rt])
	{
		lazy(ls, cov[rt]);
		lazy(rs, cov[rt]);
		cov[rt] = 0;
	}
}
void update(int rt, int l, int r, int a, int b, int d)
{
	if(a <= l && r <= b)
	{
		lazy(rt, d);
		return;
	}
	int mid = l + r >> 1;
	pushdown(rt);
	if(a <= mid) update(ls, l, mid, a, b, d);
	if(b > mid) update(rs, mid + 1, r, a, b, d);
	pushup(rt);
}
int main()
{
	for(int i = 1; i <= 9; ++i) 
		for(int j = 1; j < maxn; ++j)
			p[i][j] = (p[i][j - 1] * 10 + i) % mod;
	base[0] = 1;
	for(int j = 1; j < maxn; ++j)
		base[j] = base[j - 1] * 10 % mod;
	int n, q;
	scanf("%d%d", &n, &q);
	build(1, 1, n);
	while(q--)
	{
		int l, r, d;
		scanf("%d%d%d", &l, &r, &d);
		update(1, 1, n, l, r, d);
		printf("%lld\n", T[1]);
	}
	return 0;
}
		
	 

Measured memory_bytes: 27620
#include <stdio.h>

int main(){
	int N;
	int calc = 0;
	int X1;
	scanf("%d",&N);
	long int A[N];
	for(int i = 0;i < N;i++){
		scanf("%ld",&A[i]);
		calc += A[i];
		if(i % 2 != 0)
			calc -= A[i]*2;
	}

	X1 = calc;

	for(int i = 0;i < N;i++){
		printf("%ld ",X1);
		X1 = A[i]*2-X1;
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 2048
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;
list<long long int> Prime(int M) {
	list<long long int>P;
	P.push_back(2);
	P.push_back(3);
	for (int i = 5; i <= M; i += 6) {
		bool flag = true;
		for (auto j : P) {
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i);
		flag = true;
		for (auto j : P) {
			if ((i + 2) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i + 2);
	}
	return P;
}
long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H;
long long int ans;

int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M;
	bool flag[500][500] = {};
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			if (i != j)flag[i][j] = true;
		}
	}
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		if (flag[a][b]) {
			flag[a][b] = false;
			flag[b][a] = false;
			for (int j = 1; j <= N; j++) {
				if (!flag[j][a])flag[j][b] = false;
				if (!flag[b][j])flag[a][j] = false;
			}
			for (int j = 1; j <= N; j++) {
				if (!flag[a][j])flag[b][j] = false;
				if (!flag[j][b])flag[j][a] = false;
			}
		}
		else {
			for (int j = 1; j <= N; j++) {
				flag[j][a] = false;
				flag[j][b] = false;
				flag[a][j] = false;
				flag[b][j] = false;
			}
		}
	}
	for (int i = 1; i <= N; i++) {
		for (int j = i+1; j <= N; j++) {
			if (flag[i][j]) {
		//		cout << i << " " << j << endl;
				ans++;
			}
		}
	}
	cout << ans  << endl;
	return 0;
}

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

#define LL long long

LL q, h, s, d, n;

int main(){
	cin>>q>>h>>s>>d>>n;
	h = min(h,q*2);
	s = min(s,h*2);
	d = min(d,s*2);
	LL ans = 0;
	ans = n/2;
	ans *= d;
	if(n&1) ans += s;
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256