akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int H, W, res = 0;  //縦・横・結果
vector<string> Mass(2010);  //マス状態
vector<vector<int>> range_Mass(2010, vector<int>(2010, -1));  //照らされるマス数

int main(){
  cin >> H >> W;
  for(int i = 0; i < H; i++) cin >> Mass[i];

  /*以下, 横連続マス数を調査  計算量O(HW)*/
  int j = 0;
  for(int i = 0; i < H; i++){
    int j = 0;
    while(j < W){
      int k = 0;
      while(j + k < W && Mass[i][j+k] != '#') k++;  //マス連続数取得
      for(int l = 0; l < k; l++) range_Mass[i][j+l] += k;  //連続数を加える
      j += k+1;
    }
  }

  /*以下,縦連続マス数を調査  計算量O(HW)*/
  for(int i = 0; i < W; i++){
    int j = 0;
    while(j < H){
      int k = 0;
      while(j + k < H && Mass[j+k][i] != '#') k++;  //マス連続数取得
      for(int l = 0; l < k; l++) range_Mass[j+l][i] += k;  //連続数を加える
      j += k+1;
    }
  }

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++) res = max(res, range_Mass[i][j]);
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 20224
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
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 long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}


int main(){
    ll a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    ll dp[3100][3100];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    ld ans=0;
  	ll anss,answ;
    for (ll i=0;i<=f;i++){
        for (ll j=0;j<=f;j++){
            if (dp[i][j]!=1)continue;
            if (i!=0 and ans<=((ld)j)/((ld)i+(ld)j) and i+j<=f){
                ans=((ld)j)/((ld)i+(ld)j);
                anss=j;
                answ=i+j;
            }
            if (i+(a*100)<=f)dp[i+(a*100)][j]=1;
            if (i+(b*100)<=f)dp[i+(b*100)][j]=1;
            ll x=j;
            while(i*e>=x*100 and i+x<=f){
                dp[i][x]=1;
              	x+=c;
            }
            x=j;
            while(i*e>=x*100 and i+x<=f){
                dp[i][x]=1;
              	x+=d;
            }
        }
    }
    cout << answ << " " << anss << endl; 
    return 0;
}


Measured memory_bytes: 78724
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        int A = sc.nextInt();
        int B = sc.nextInt();

        if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
            WriteLine("Possible");
        } else {
            WriteLine("Impossible");
        }
    }
}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 11092
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	private static final int N = 3;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			Map<Integer, Integer> map = new HashMap<>();
			IntStream.range(0, N).forEach(i -> {
				int a = scanner.nextInt();
				map.put(a, map.getOrDefault(a, 0) + 1);
			});
			System.out
					.println(map.entrySet().stream().filter(entry -> entry.getValue() == 1).findFirst().get().getKey());
		}
	}
}


Measured memory_bytes: 27208
#include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define pf push_front
#define pb push_back
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a<b&&b<c)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;


  return 0;
}

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

const int L = 32;
int n, x, ans, a, cnt[L];
bool t = 1;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a;
		cnt[__builtin_ctz(a)]++;
		x ^= a;
	}
	
	for (int i = L - 1; i >= 0; i--){
		if((x >> i) % 2 == t){
			if(cnt[i] == 0)
				return cout << -1, 0;
			t = 1 - t;
			ans++;
		}
	}
	
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n, a[2100], b[2100], x, res;
int main(void){
    // Your code here!
    cin >> n >> x;
    for (ll i = 0; i < n; i++) cin >> a[i];
    for (ll i = 0; i < n; i++) {
        ll ans = 0;
        for (ll j = 0; j < n; j++) {
            if (i == 0) {
                b[j] = a[j];
            } else {
                b[j] = min(b[j], a[(j + i) % n]);
            }
            ans += b[j];
        }
        ans += i * x;
        if (i) {
            res = min(res, ans);
        } else {
            res = ans;
        }
    }
    cout << res << endl;
}


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

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

using namespace std;

struct Color {
  int r = 0;
  int g = 0;
  int b = 0;
};

typedef struct Color Color;

int main(){
  	int i,j,k,n;
  	long long int ans = 0;
  	string s;
  	cin >> n;
  	cin >> s;
 	vector<Color> v(n);
	if (s[0]=='R'){
      v[0].r++;
    }
    else if(s[0]=='G'){
    	v[0].g++;
    }
    else{
      v[0].b++;
    }
  	for (i=1;i<n;i++){
    	v[i] = v[i-1];
     	if (s[i]=='R'){
          v[i].r++;
        }
        else if(s[i]=='G'){
            v[i].g++;
        }
        else{
          v[i].b++;
        } 
    }
  	for (i=0;i<n-2;i++){
    	for (j=i+1;j<n-1;j++){
          	if (s[i]!=s[j]){
              if (s[i]+s[j]=='R'+'G'){
              		ans += v[n-1].b - v[j].b;               	
              }
              else if (s[i]+s[j]=='R'+'B'){
              		ans += v[n-1].g - v[j].g;               	
              }
              else{
              		ans += v[n-1].r - v[j].r;               	
              }
              k = 2*j-i;
              if (k<n && s[j]!=s[k] && s[i]!=s[k]){
              	ans--;
              }
            }
        }
    }
  	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> par;
int n,m,a[310][310],vis[310];
vector<par>v[310];
bool check(int mx){
	for(int i=1;i<=m;++i)v[i].clear(),vis[i]=0;
	for(int i=1;i<=n;++i)v[a[i][1]].push_back(par(i,1));
	while(true){
		int pos=0;par P;
		for(int i=1;i<=m;++i)
			if(v[i].size()>mx)pos=i;
		if(!pos)return 1;
		vis[pos]=1;
		for(int i=0;i<v[pos].size();++i){
			par P=v[pos][i];
			while(P.second<=m&&vis[a[P.first][P.second]])P.second++;
			if(P.second>m)return 0;
			v[a[P.first][P.second]].push_back(par(P.first,P.second));
		}
			
		v[pos].clear();
	}
	return 0;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			scanf("%d",&a[i][j]);
	int l=1,r=n,ans=n;
	while(l<=r){
		int mid=l+r>>1;
		if(check(mid))ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%d",ans);
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;


int main(){
  ll n;
  st s;
  cin >> n >> s;
  ll ans = 0;
  rep(i, 0, n - 2) if(s.at(i)== 'A' && s.at(i + 1) == 'B' && s.at(i + 2) == 'C') ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int short int
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 101;
int n, m;
string a[N];
int dp[N][N][N][N];
void upd(int &a, int b) {
    a = max(a, b);
}   

int pref[N][N];

int lx_, ly_, rx_, ry_;

int sum(int x1, int y1, int x2, int y2) {

    x1 = max(x1, lx_);
    y1 = max(y1, ly_);
    x2 = min(x2, rx_);
    y2 = min(y2, ry_);

    if (x2 < x1 || y2 < y1)
        return 0;

    return pref[x2 + 1][y2 + 1] - pref[x2 + 1][y1] - pref[x1][y2 + 1] + pref[x1][y1];
}   

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n >> m;
    int Ex, Ey;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        for (int j = 0; j < m; ++j) {
            if (a[i][j] == 'E') {   
                Ex = i;
                Ey = j;
            }
        }   
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            pref[i + 1][j + 1] = pref[i + 1][j] + pref[i][j + 1] - pref[i][j] + (a[i][j] == 'o');
        }   
    }   
    int ans = 0;
    for (int lx = n - 1; lx >= 0; --lx) {
        for (int ly = m - 1; ly >= 0; --ly) {
            for (int rx = lx; rx < n; ++rx) {
                for (int ry = ly; ry < m; ++ry) {

                    lx_ = rx - Ex;
                    ly_ = ry - Ey;
                    rx_ = lx + (n - 1 - Ex);
                    ry_ = ly + (m - 1 - Ey);

                    int cur = dp[lx][ly][rx][ry];
                    upd(ans, cur);
                    if (lx) {
                        int cnt = sum(lx - 1, ly, lx - 1, ry);
                        upd(dp[lx - 1][ly][rx][ry], cur + cnt);
                    }   
                    if (ly) {
                        int cnt = sum(lx, ly - 1, rx, ly - 1);
                        upd(dp[lx][ly - 1][rx][ry], cur + cnt);
                    }   
                    if (rx + 1 < n) {
                        int cnt = sum(rx + 1, ly, rx + 1, ry);
                        upd(dp[lx][ly][rx + 1][ry], cur + cnt);
                    }   
                    if (ry + 1 < m) {
                        int cnt = sum(lx, ry + 1, rx, ry + 1);
                        upd(dp[lx][ly][rx][ry + 1], cur + cnt);
                    }   
                }   
            }   
        }   
    }   
    cout << ans << endl;
}


Measured memory_bytes: 203008
#include <bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<long long> vc;
    vc.push_back(2);
    vc.push_back(1);
    for (int i = 0; i < n - 1; i++)
    {
        vc.push_back(vc[i]+vc[i+1]);
    }
    cout << vc[n] << endl;
}

Measured memory_bytes: 256
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a=[0]
b=[0]
for i in range(len(A)):
	a.append(a[i]+A[i])

for i in range(len(B)):
	b.append(b[i]+B[i])


ans,j=0,m
for i in range(n+1):
	if a[i]>k:
		break
	while b[j]>k-a[i]:
		j-=1
	ans=max(ans,i+j)
print(ans)



Measured memory_bytes: 134260
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 105
#define maxM 2005
#define oo 1000000000000000007LL
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

ll add(ll &a, const ll &b) {a = min(a+b, oo);}

ll mul(const ll &a, const ll &b) {
    if (a == 0) return 0;
    ll x = a*b;
    if (x/a != b) return oo;
    return min(oo, x);
}

int n, m, z[maxM][maxN];
ll id, cnt[maxM], dp[maxM];
string s[maxN];

int main () {
    scanf("%d%d%lld", &n, &m, &id);
    fto(i, 0, n-1) cin >> s[i];

    cnt[0] = 1;
    fto(i, 1, m) {
        fto(j, 0, n-1) {
            if (i >= sz(s[j])) add(cnt[i], cnt[i-sz(s[j])]);
        }
    }

    dp[0] = 1;
    string ans;
    fto(i, 1, m) {
        vector<ll> sum(26, 0);
        fto(j, 0, n-1) {
            fto(p, max(1, i-sz(s[j])+1), min(i, m-sz(s[j])+1)) {
                if (z[p][j] == i-p) 
                    add(sum[s[j][z[p][j]]-'a'], mul(dp[p-1], cnt[m-(p+sz(s[j])-1)]));                
            }
        }

        fto(c, 'a', 'z') {
            if (sum[c-'a'] >= id) {
                ans += c;
                fto(j, 0, n-1) {
                    fto(p, max(1, i-sz(s[j])+1), i) {
                        if (z[p][j] == i-p && s[j][z[p][j]] == c) ++z[p][j];
                    }
                    if (i >= sz(s[j]) && z[i-sz(s[j])+1][j] == sz(s[j]))
                        add(dp[i], dp[i-sz(s[j])]);
                }

                break;
            } else id -= sum[c-'a'];
        }

        if (sz(ans) != i) {
            puts("-");
            return 0;
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 4168
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main(){
    string a;
    int seq[500005], n, x=-1;
    long long final=0;
    cin >> a;
    n=a.size();
    seq[0]=0;
    memset(seq, 0, sizeof(seq));
    for(int i=0; i<n; i++){
        if(a[i]=='<'){
            seq[i+1]=seq[i]+1;
        }
    }
    
    for(int i=n-1; i>=0; i--){
        if(a[i]=='>'){
            if(seq[i]<=seq[i+1]){
                seq[i]=seq[i+1]+1;
            }
        }
    }
    for(int i=0; i<=n; i++){
        final+=seq[i];
    }
    cout << final << endl;
    return 0;
}

Measured memory_bytes: 5788
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

string replace_all(string &s, string from, string to) {
  int pos = s.find(from);
  int toLen = to.size();

  if (from.empty())
    return s;

  while ((pos = s.find(from, pos)) != string::npos) {
    s.replace(pos, from.size(), to);
    pos += toLen;
  }
  return s;
}

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

  string s;
  cin >> s;
  replace_all(s, "eraser", "");
  replace_all(s, "erase", "");
  replace_all(s, "dreamer", "");
  replace_all(s, "dream", "");
  if (s.size() == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#define MAX_N 100005
#define INF 1000000000

using namespace std;

int n,m,ans=0;
int a[MAX_N];
int t[MAX_N];
int par[MAX_N];
vector<int> vec[MAX_N];

int find(int x)
{
	return par[x]==x ? x : par[x]=find(par[x]);
}

void unite(int x,int y)
{
	int px=find(x),py=find(y);
	if(px==py) return;
	par[px]=py;
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) par[i]=i;
	int x,y;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		unite(x,y);
	}
	for(int i=1;i<=n;i++) vec[find(i)].push_back(i);
	for(int k=1;k<=n;k++)
	{
		if(find(k)==k)
		{
			vector<int> &v=vec[k];
			int tot=v.size();
			for(int i=0;i<tot;i++) t[i]=a[v[i]];
			sort(v.begin(),v.end());
			sort(t,t+tot);
			v.push_back(INF),t[tot]=INF;
			for(int i=0,j=0,k=0;k<tot*2;k++)
			{
				if(v[i]<t[j]) i++;
				else if(t[j]<v[i]) j++;
				else ans++,i++;
			}
		}
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

void solve(){
  int n; cin >> n;
  int maxp = 0, ans = 0;
  for(int i = 0; i < n; i++){
    int p; cin >> p;
    if(p > maxp){
      ans += maxp;
      maxp = p;
    }
    else ans += p;
  }
  cout << ans + maxp / 2 << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;

 
int main() {
	
	int x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	if(x1>x2){
    //cout<<<<" "<<<<" "<<<<" "<<<<" "<<<<endl;
    cout<<x2-(y2-y1)<<" "<<y2+(x2-x1)<<" "<<x1-(y2-y1)<<" "<<y1+(x2-x1)<<endl;
	}else if(x1==x2){
		cout<<x2-(y2-y1)<<" "<<y2+(x2-x1)<<" "<<x1-(y2-y1)<<" "<<y1+(x2-x1)<<endl;
		
	}else{
		
		cout<<x2-(y2-y1)<<" "<<y2+(x2-x1)<<" "<<x1-(y2-y1)<<" "<<y1+(x2-x1)<<endl;
		
	}
}

Measured memory_bytes: 256
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;
int main(){
    int a,b,c,ans=0;
    cin >> a >> b >> c;
    for(int i=a; i<=b; i++){
        if(c%i==0) ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3096
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int min(int a,int b);

int main(void){
  int N,a[105],b[105],sum,i;
  char str[10000],*p;
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  b[0]=atoi(p);
  for(i=1;i<N-1;i++){
    p=strtok(NULL," \n");
  	b[i]=atoi(p);
    
  }
  
  a[0]=b[0];
  
  for(i=1;i<N-1;i++){
    a[i]=min(b[i-1],b[i]);
  }
  a[N-1]=b[N-2];
  
  for(i=0,sum=0;i<N;i++){
    sum+=a[i];
  }
  
  printf("%d\n",sum);
  
  return 0;
}

int min(int a,int b){
 if(a<=b){
   return a;
 }else{
   return b;
 }
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
	int i,n;
	scanf("%d",&n);
	int array[100];
	for(i=0;i<n;i++){
		scanf("%d",&array[i]);
	}
	for(i=n-1;i>=0;i--){
		if(i==0){
			printf("%d\n",array[i]);
		}else {printf("%d ",array[i]);
		}
	}
	
	return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           ((ll)x.size())
#define hell            (1000000007)
#define inf             ((ll)5e18 + 5)
#define PI              ((double)3.14159265358979323844)
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    ll x;
    cin>>x;
    (x==1)?cout<<0<<endl:cout<<1<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
int main(){
	char a[1001];
	int sum=0;
	while(1){
		scanf("%s",a);
		if(a[0]=='0') break;
		int i;
		for(i=0;a[i]!='\0';i++){
			sum+=a[i]-48;
		}
		printf("%d\n",sum);
		sum=0;
	}
	return 0;
}



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



int main(){
  int N,M,P;

  
  while(true){
    cin >> N >> M >> P;

    if(N + M + P == 0) break;
    
    int a,X, sum=0;

    for(int i=0;i<N;++i){
      cin >> a;
      sum += a;
      
      if(i == M-1){
	X = a;
      }
    }
    
    sum = sum*(100 - P);
    if(X==0){cout<<0<<endl; continue;}
    
    cout << sum/X << endl;
      
  }
  
  return 0;
}



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

int main(){
	double a, b;
	cin >> a >> b;

	rep(item, 10001){
		if(item*8/100 == a && item*10/100 == b){
			cout << item << endl;
			return 0;
		}
	}

	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int D = sc.nextInt();
        long G = sc.nextLong();
        int[] P = new int[D];
        int[] C = new int[D];
        for (int i = 0; i < D;i++) {
            P[i] = sc.nextInt();
            C[i] = sc.nextInt();
        }
        int res = Integer.MAX_VALUE;
        int score = 0;
        int num = 0;
        // Find case whether we get all question of specific point or none of them
        for (int bit = 0; bit < (1<<D); bit++) {
            score = 0;
            num = 0;
            for(int i = 0; i < D; i++) {
                if ((bit & (1<<i)) != 0) {
                    score += 100 * P[i] * (i + 1) + C[i];
                    num += P[i];
                }
            }
            if(score < G) {
                for (int i = D - 1; i >= 0; i--) {
                    if ((bit & (1<<i)) == 0) {
                        for(int j = 0; j < P[i] - 1; j++) {
                            score +=  100* (i + 1);
                            num += 1;
                            if (score >= G) {
                                break;
                            }
                        }
                    }
                    if (score >= G) {
                        break;
                    }
                }
            }
            if (score >= G) {
                res = Math.min(res, num);
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 23764
import operator
operator = {"+": operator.add, "-": operator.sub, "*": operator.mul}

def initialize():
    top = 0

def empty_or_not():
    return top == 0

def full_or_not():
    return top >= len(s) - 1

def push(x):
    global top
    if full_or_not():
        raise ValueError("Error: stack is full!")
    top += 1
    s[top] = x

def pop():
    global top
    if empty_or_not():
        raise ValueError("Error: stack is empty!")
    top -= 1
    return s[top+1]



s = [None] * 10**3
top = 0

rpn = list(input().split())

for i in range(len(rpn)):
    if rpn[i] == "+" or rpn[i] == "-" or rpn[i] == "*":
        b = int(pop())
        a = int(pop())
        
        a_ops_b = operator[rpn[i]](a, b)
        #print(f"ops: {a} {rpn[i]} {b} = {a_ops_b}")
        push(a_ops_b)
        #print(f"top: {top}")
        #print(s)
    else:
        #print(f"push: {rpn[i]}")
        push(rpn[i])
        #print(f"top: {top}")
        #print(s)
        
print(s[top])


    


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

int main(){
    int N; cin >> N;
    vii ids(N);
    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        ids[a].push_back(i);
        ids[b].push_back(i);
    }
    vi color(N-1, -1);
    int dm=0;
    for(int i=0; i<N; i++){
        dm=max(dm, (int)ids[i].size());
    }
    for(int i=0; i<N; i++){
        vector<bool> ng(dm+1, 0);
        for(auto &e : ids[i]){
            if(color[e] != -1){
                ng[color[e]]=1;
            }
        }
        int c=1;
        for(auto &e : ids[i]){
            if(color[e] != -1) continue;
            if(ng[c]){
                while(ng[c]){
                    c++;
                }
                color[e]=c;
            }
            else{
                color[e]=c;
            }
            c++;
        }
    }
    cout << dm << endl;
    for(int i=0; i<N-1; i++) cout << color[i] << endl;
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  
  vector<bool> app(26);
  for (int i = 0; i < 26; i++) {
    app.at(i) = false;
  }
  
  for (int i = 0; i < S.size(); i++) {
    app.at(S.at(i) -'a') = true;
  }
  
  bool no = true;
  for (int i = 0; i < 26; i++) {
    if (app.at(i) == false) {
      cout << (char)(i+'a') << endl;
      no = false;
      break;
    }
  }
  if (no) cout << "None" << endl;
}
  
    
  

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int lst[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int K; cin>>K;
	cout<<lst[K-1]<<"\n";
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<stack>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;
#define LATTE 1000000000

int main(){
	int dp[2][5002][2];
	int N,t[10001]={};
	fill(dp[0][0],dp[0][0]+2*5002*2,LATTE);
	cin>>N;
	for(int i=1;i<=N-1;i++){
		cin>>t[i];
	}
	dp[0][0][0]=0;
	for(int i=0;i<N;i++){
		for(int j=0;j<=N/2;j++){
			dp[(i+1)&1][j+1][0] = min(dp[i&1][j][0],dp[i&1][j][1]+t[i+1]);
			dp[(i+1)&1][j][1] = min(dp[i&1][j][1],dp[i&1][j][0]+t[i+1]);
			dp[i&1][j][0]=dp[i&1][j][1]=LATTE;
		}
	}
	printf("%d\n",dp[N&1][N/2][0]);
	return 0;
}

Measured memory_bytes: 1268
#include <stdio.h>

int main()
{
  char W[7][3] = { "SUN","MON","TUE","WED","THU","FRI","SAT"};
  char S[4];
  scanf("%s",&S);
  int i = 0;
  while (i < 7)
  {
    int k = 0;
    while (S[k] == W[i][k])
    {
      if (S[k] == '\0')
      {
        printf("%d",7-i);
        return(0);
      }
      k++;
    }
    i++;
  }
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define pb push_back
#define pii pair<int, int>
#define mp make_pair

int n;

int find(vec<vec<int>> edge, int k, int s)
{
	vec<int> dp(n, 0);
	queue<pii> keep;
	keep.push(mp(s, 0));
	int ans = 0;
	while(!keep.empty()) {
		pii get = keep.front();
		keep.pop();
		if (dp[get.first]) continue;
		if (get.second > k) break;
		ans++;
		dp[get.first] = 1;
		if (get.second == k) continue;
		rep(i, edge[get.first].size()) {
			keep.push(mp(edge[get.first][i], get.second + 1));
		}
	}
	return ans;
}


int find1(vec<vec<int>> edge, int k, int s)
{
	vec<int> dp(n, 0);
	queue<pii> keep;
	vec<int> check(n, 0);
	int max_check = 0;
	keep.push(mp(s, 0));
	vec<int> count(n, 0);
	int ans = 0;
	while(!keep.empty()) {
		pii get = keep.front();
		keep.pop();
		if (dp[get.first]) continue;
		if (get.second > k) break;
		dp[get.first] = 1;
		if (get.second == k) {
			count[check[get.first]]++;
			continue;
		}
		ans++;
		rep(i, edge[get.first].size()) {
			keep.push(mp(edge[get.first][i], get.second + 1));
			if (get.second == 0) {
				check[edge[get.first][i]] = max_check;
				max_check++;
			} else {
				check[edge[get.first][i]] = check[get.first];
			}
		}
	}
	int ret = 0;
	rep(i, max_check) ret = max(ret, count[i]);
	ans += ret;
	return ans;
}

int main(void)
{
	int k;
	cin >> n >> k;
	vec<vec<int>> edge(n);
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		edge[a].pb(b);
		edge[b].pb(a);
	}

	int ans = 0;
	rep(i, n) {
		if (k % 2) {
			ans = max(ans, find(edge, k / 2, i));
			ans = max(ans, find1(edge, k / 2 + 1, i));
		} else {
			ans = max(ans, find(edge, k / 2, i));
		}
	}
	cout << n - ans << endl;
	return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;
    auto get_num = [](char ch) -> int {
        if(ch == 'U')   return 0;
        else if(ch == 'R')  return 1;
        else if(ch == 'D')  return 2;
        else    return 3;   // ch == 'L'
    };
    vector<int> X(N), Y(N), dir(N);
    for(int i = 0; i < N; ++i){
        char ch;
        cin >> X[i] >> Y[i] >> ch;
        dir[i] = get_num(ch);
    }
    int ans = INF;
    for(int loop = 0; loop < 4; ++loop){
        map<int, vector<P>> mp, manhattan_mp;
        for(int i = 0; i < N; ++i){
            if(~dir[i] & 1) mp[X[i]].emplace_back(Y[i], dir[i]);
            if(dir[i] < 2)  manhattan_mp[X[i] + Y[i]].emplace_back(Y[i], dir[i]);
        }
        for(auto it : mp){
            vector<P> table = it.second;
            sort(table.begin(), table.end());
            int prev_u = -1;
            for(auto& p : table){
                if(!p.second)   prev_u = p.first;
                else if(prev_u != -1)   chmin(ans, (p.first - prev_u) * 5);
            }
        }
        for(auto it : manhattan_mp){
            vector<P> table = it.second;
            sort(table.begin(), table.end());
            int prev_u = -1;
            for(auto& p : table){
                if(!p.second)   prev_u = p.first;
                else if(prev_u != -1)   chmin(ans, (p.first - prev_u) * 10);
            }
        }
        swap(X, Y);
        for(int i = 0; i < N; ++i){
            Y[i] = -Y[i];
            if(++dir[i] == 4)   dir[i] = 0;
        }
    }
    if(ans == INF)  cout << "SAFE\n";
    else    cout << ans << '\n';
}

Measured memory_bytes: 48804
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define sz(a) int(a.size())
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
#define lson l,mid,p<<1
#define ll long long
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const double eps=1e-8;
const int mod=1e9+7;
const int N=5e5+10;
const int inf=1e9;
int n,m;
ll f[N],inv[N];
ll ksm(ll a,ll b){
	ll ret=1;
	while(b){
		if(b&1) ret=ret*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ret;
}
ll cal(int x){
	return f[m]*inv[m-x]%mod;
}
ll cal1(int y,int x){
	return f[m-y]*inv[m-x-y]%mod*f[m-y]%mod*inv[m-x-y]%mod;
}
ll C(ll n,ll m){
	return f[n]*inv[n-m]%mod*inv[m]%mod;
}
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	f[0]=1;
	rep(i,1,N-1) f[i]=f[i-1]*i%mod;
	inv[N-1]=ksm(f[N-1],mod-2);
	for(int i=N-2;i>=0;--i) inv[i]=inv[i+1]*(i+1)%mod;
	cin>>n>>m;
	if(m<n){
		cout<<0<<endl;
		return 0;
	}
	int o=1;
	ll ans=0;
	rep(i,0,n){
		if(o) ans=(ans+1ll*C(n,i)*f[m-i]%mod*inv[m-n]%mod)%mod;
		else ans=(ans-1ll*C(n,i)*f[m-i]%mod*inv[m-n]%mod)%mod;
		o^=1;
	}
	ans=(ans*f[m]%mod*inv[m-n]%mod);
	ans=(ans%mod+mod)%mod;
	cout<<ans<<endl;
	//cout<<f[m]*inv[m-n]%mod*f[m-1]%mod*inv[max(0,m-n-1)]%mod<<endl;
	return 0;
}
/*36
3*2*2
3*2
2 1
m m-1 m-2
m-1 m-1 m-3
1 2
3 1

2*3*3

1 2


*/

Measured memory_bytes: 11444
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_vec::<usize>()[0];

    let s = read_as_string();
    if s.chars().any(|c| c == 'Y'){
        println!("Four");
    }else{
        println!("Three");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int R;cin>>R;
    if(R<1200)cout<<"ABC"<<endl;
    else if(R>=1200 && R<2800)cout<<"ARC"<<endl;
    else cout<<"AGC"<<endl;
}

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


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

	int n2=n,sum=0;

	while(n){
		sum+=n%10;
		n/=10;
	}

	if(n2%sum==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

const MOD = 10^^9 + 7;

int[int] fac(int n) {
    int[int] ps;
    while (n % 2 == 0) {
        ps[2]++;
        n /= 2;
    }
    for (int i = 3; i * i <= n; i += 2) {
        while (n % i == 0) {
            ps[i]++;
            n /= i;
        }
    }
    if (n > 1) ps[n]++;
    return ps;
}

long calc(int n, int m) {
    long ans = 1;
    foreach (v; fac(m).values) {
        // v 個の素因数と n - 1 個の仕切りの並べ方
        ans = (ans * nck(v + n - 1, n - 1)) % MOD;
    }
    return ans;
}

void main() {
    initFactTable(210000);

    int n, m; scan(n, m);
    writeln(calc(n, m));
}

long[] fact; // 階乗
long[] factInv; // 階乗の逆元

void initFactTable(int n) {
    fact = new long[n + 1];
    fact[0] = 1;
    for (int i = 1; i <= n; i++)
        fact[i] = i * fact[i - 1] % MOD;

    factInv = new long[n + 1];
    factInv[n] = modPow(fact[n], MOD - 2, MOD);
    for (int i = n - 1; i >= 0; i--)
        factInv[i] = factInv[i + 1] * (i + 1) % MOD;
}

long modPow(long x, long k, long m) {
    if (k == 0) return 1;
    if (k % 2 == 0) return modPow(x * x % m, k / 2, m);
    return x * modPow(x, k - 1, m) % m;
}

long nck(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return (fact[n] * factInv[k] % MOD) * factInv[n - k] % MOD;
}


Measured memory_bytes: 4348
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
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (A, B, K) = Slice3<long>();
            var lst = new List<long>();
            for (var i = 0; i < K; ++i)
            {
                lst.Add(Min(A + i, B));
                lst.Add(Max(A, B - i));
            }
            foreach (var l in lst.Distinct().OrderBy(l => l))
                WriteLine(l);
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28428
#include<bits/stdc++.h>
using namespace std;
int n,q;
int A[300000];
void update(int x,int y){
  x+=n-1;
  A[x]+=y;
  while(x){
    x=(x-1)/2;
    A[x]=A[x*2+1]+A[x*2+2];
  }
}

int getsum(int s,int t,int k,int l,int r){
  if(l>=t || r<=s) return 0;
  if(s<=l && r<=t) return A[k];

  int al=getsum(s,t,k*2+1,l,(l+r)/2);
  int ar=getsum(s,t,k*2+2,(l+r)/2,r);

  return al+ar;
}
int main(){
  int com,x,y;
  cin>>n>>q;
  int ra=1;
  while(ra<=n){
    ra*=2;
  }
  n=ra;
  for(int i=0;i<q;i++){
    cin>>com>>x>>y;
    if(com==0) update(x,y);
    else if(com==1) cout<<getsum(x,y+1,0,0,n)<<endl;
  }

  return 0;
}



Measured memory_bytes: 3892
#include <stdio.h>
#define FREE 0
#define N_FREE 1
#define Q 2
#define N 8

int board[N][N];
int row[N],col[N],dneg[2*N-1],dpos[2*N-1];

void printboard(){
  int i, j;
 
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(board[i][j] == N_FREE && row[i] != j)
	return;
    }
  }
 
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(row[i] == j)
	printf("Q");
      else
	printf(".");
    }
    printf("\n");
  }
};

void putQueen(int i){
  int j;
  
  //  printf("i = %d\n",i);
  
  if(i==N){  
    printboard();
    return;
  }

  for(j=0;j<N;j++){
    if(col[j]==N_FREE || dpos[i+j]==N_FREE || dneg[i-j+N-1]==N_FREE){ //?????????????????¨???
      continue;
    }

    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = N_FREE; //1

    //    printf("i2 = %d\n",i);

    //    printf("putQueen\n");
    putQueen(i+1);
    
    //    printf("i3 = %d\n",i);
  
    col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
    
    /*
      printf("*****\n");
      printf("*Back tracking\n");
      printf("*row[]:");
      for(i=0;i<N;i++) printf(" %d",row[i]);
      printf("\n*col[]:");
      for(i=0;i<N;i++) printf(" %d",col[i]);
      printf("\n*dneg[]:");
      for(i=0;i<2*N-1;i++) printf(" %d",dneg[i]);
      printf("\n*dpos[]:");
      for(i=0;i<2*N-1;i++) printf(" %d",dpos[i]);
      printf("\n*****\n");    
    */
  }
};

int main(){
  int k,r,c;
  int i;
 
    
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d",&r);
    scanf("%d",&c);
    board[r][c] = N_FREE; //1
  }
  
  putQueen(0);
     
  return 0;
}

Measured memory_bytes: 572
/* *****fireice**** */

#include<bits/stdc++.h>

#define ll long long int
#define vi vector<int>
#define vc vector<char>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define pii pair<int,int>
#define pb push_back
#define el '\n'
#define N 1000000007
#define re return
#define F first
#define S second
#define L length
#define mp make_pair
#define PI 3.14159265
#define all(a) (a).begin(),(a).end()
#define forup(i,n) for(int i=0;i<n;i++)
#define forf(i,x,n) for(int i=x;i<n;i++)
#define ford(i,n) for(int (i)=(n)-1;i>=0;(i)--)
#define take(a,n) forup(i,n) cin>>a[i];
using namespace std;

int gcdExtended(int a, int b, int *x, int *y)
{
    // Base Case
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    int x1, y1; // To store results of recursive call
    int gcd = gcdExtended(b%a, a, &x1, &y1);

    // Update x and y using results of recursive
    // call
    *x = y1 - (b/a) * x1;
    *y = x1;

    return gcd;
}

ll modInverse(int a, int m)
{
    int x, y;
    int g = gcdExtended(a, m, &x, &y);
        // m is added to handle negative x
    ll res = ((ll)x%m + (ll)m) % m;

    return res;
}

ll poww(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return poww(x*x,n/2);
    else                             //n is odd
        return x*poww(x*x,(n-1)/2);
}

ll modularExponentiation(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}

inline ll max(ll a, ll b)
{
  if(a>b) re a;
  else re b;
}

inline ll min(ll a, ll b)
{
  if(a>b) re b;
  else re a;
}

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

    if (a == b)
        return a;

    if (a > b)
        return gcd(a-b, b);
    else return gcd(a, b-a);
}

ll ncr(int n,int r)
{
  ll ans=1;
  r=min(r,n-r);
  forup(i,r)
  {
    ans=(ans*(n-i)/(i+1))%N;
  }
  re ans;
}

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

  int t=1;
  //cin>>t;
  while(t--)
  {
    long double n,m,k;
    cin>>n;
    long double a,b,c,ans;
    cout<<fixed<<setprecision(9);
    a=n/3;
    b=n/3;
    c=n-(a+b);
    cout<<a*b*c;

  }


  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	int hito, place, wk, max;
	int anc[128];

	while(cin >> hito >> place)
	{
		if(hito == 0 && place == 0) break;
		fill(anc, anc+128, 0);

		for(int i = 0; i < hito; i++)
		{
			for(int j = 0; j < place; j++)
			{
				cin >> wk;
				anc[j] += wk;
			}
		}

		for(int i = 0; i < place; i++)
		{
			max = 0;
			for(int j = 0; j < place; j++)
			{
				if(max < anc[j])
				{
					max = anc[j];
					wk = j;
				}
			}
			printf("%d%s", wk + 1, (i == place-1)?"\n":" ");
			anc[wk] = -1;
		}
	}
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int s,i,j;
long long int mod=1e9+7;
cin>>s;
long long int dp[s+1];
dp[0]=0;
dp[1]=0;
dp[2]=0;
for ( i = 3; i <=s; ++i)
{dp[i]=0;
   for (j = 3; j <=i; ++j)
   {
       dp[i]=(dp[i]+dp[i-j])%mod;
      
   }
   dp[i]=(dp[i]+1)%mod;
}
cout<<dp[s]<<endl;

return 0;
}



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

typedef long long ll;

ll mod_pow(ll a, ll n, ll p)
{
    if(n == 1){
        return a%p;
    }else if(n%2 == 1){
        return a*mod_pow(a,n-1,p)%p;
    }else{
        ll t = mod_pow(a,n/2,p);
        return t*t%p;
    }
}

int main()
{
    int n,a,b;
    cin >> n >> a >> b;
    int mod = 1e9 + 7;
    if(n == 2){
        cout << 0 << endl;
        return 0;
    }
    ll ans = mod_pow(2,n,mod) - 1;

    vector<ll> inv(max(a,b)+1,0);
    inv.at(0) = 1;
    inv.at(1) = 1;
    int i;
    for(i = 2;i <= max(a,b);++i){
        inv.at(i) = mod - inv.at(mod%i)*(mod/i)%mod;
    }

    vector<ll> com(max(a,b)+1,1);
    com.at(0) = 1;
    com.at(1) = n;

    for(i = 2;i <= max(a,b);++i){
        com.at(i) = com.at(i-1)*(n-i+1)%mod;
        com.at(i) = com.at(i)*inv.at(i)%mod;
    }

    ans += (mod - com.at(a)) + (mod - com.at(b));
    ans %= mod;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3328