akhauriyash/Code-Regression huggingface dataset:
///                   _ooOoo_
///                  o8888888o
///                  88" . "88
///                  (| -_- |)
///                  O\  =  /O
///               ____/`---'\____
///             .'  \\|     |//  `.
///            /  \\|||  :  |||//  \
///           /  _||||| -:- |||||-  \
///           |   | \\\  -  /// |   |
///           | \_|  ''\---/''  |   |
///           \  .-\__  `-`  ___/-. /
///         ___`. .'  /--.--\  `. . __
///      ."" '<  `.___\_<|>_/___.'  >'"".
///     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
///     \  \ `-.   \_ __\ /__ _/   .-` /  /
///======`-.____`-.___\_____/___.-`____.-'======
///                   `=---='
///^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
///
///         佛祖保佑       永无BUG
///  本模块已经经过开光处理，绝无可能再产生bug
///
///=============================================
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = j;i <= k;++i)
#define repp(i,j,k) for(int i = j;i >= k;--i)
#define rept(i,x) for(int i = linkk[x];i;i = e[i].n)
#define P pair<int,int>
#define Pil pair<int,ll>
#define Pli pair<ll,int>
#define Pll pair<ll,ll>
#define pb push_back 
#define pc putchar
#define mp make_pair
#define file(k) memset(k,0,sizeof(k)
#define ll long long
int rd()
{
	int num = 0;char c = getchar();bool flag = true;
	while(c < '0'||c > '9') {if(c == '-') flag = false;c = getchar();}
	while(c >= '0' && c <= '9') num = num*10+c-48,c = getchar();
	if(flag) return num;else return -num;
}
int n;
int x[101],y[101],h[101];
void check(int i,int j)
{
	int X = x[1],Y = y[1];
	int det = abs(X-i) + abs(Y-j);
	int H = det+h[1];
	rep(a,1,n)
	{
		X = x[a],Y = y[a];
		det = abs(X-i) + abs(Y-j);
	//	if(i == 2 && j == 2) printf("#%d %d\n",h[a],det);
		if(h[a] != 0 && det+h[a] != H) return;
	    else if(h[a] == 0 && det+h[a] < H) return; 
	}
	printf("%d %d %d\n",i,j,H);
	exit(0); 
}
int main()
{ 
    n = rd();
    rep(i,1,n) x[i] = rd(),y[i] = rd(),h[i] = rd();
    rep(i,1,n)
    	if(h[i] != 0) {swap(x[i],x[1]),swap(y[i],y[1]),swap(h[i],h[1]);break;}
    rep(x,0,100) rep(y,0,100) check(x,y);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){

  int n,m,l,k;
  scanf("%d",&n);
  m=n/500;
  l=n-(m*500);
  m=m*1000;
  k=l/5;
  k=k*5;
  printf("%d",k+m);

  return 0;
}

Measured memory_bytes: 128
N, L = map(int, input().split())
A = list(map(int, input().split()))
p = 0
for i in range(N-1):
    if A[i] + A[i+1] >= L:
        p = i
        break
else:
    print("Impossible")
    exit()
print("Possible")
for i in range(1, p+1):
    print(i)
for i in range(N-1, p, -1):
    print(i)


Measured memory_bytes: 14052
n,l=input().split()
n=int(n)
l=int(l)
taste_1=[]
for x in range(1,n+1):
    taste_1.append(l+x-1)
taste_2=[]
for x in range(n):
    if taste_1[x]<0:
        taste_2.append(-taste_1[x])
    else:
        taste_2.append(taste_1[x])
t=sorted(taste_2)
#print(taste_1)
#print(taste_2)
#print(t)
ans=0
for a in range(n):
    ans+=taste_1[a]
if t[0] in taste_1:
    ans=ans-t[0]
else:
    ans=ans+t[0]
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#define MAX 25
#define NIL -1
struct Node{int p,l,r;};
struct Node T[MAX];
void Preorder(int);
void Inorder(int);
void Postorder(int);

void Preorder(int u){
  printf(" %d",u);
  if(T[u].l!=NIL){
    Preorder(T[u].l);
  }
  if(T[u].r!=NIL){
    Preorder(T[u].r);
  }
}

void Inorder(int u){
  if(T[u].l!=NIL){
    Inorder(T[u].l);
  }
  printf(" %d",u);
  if(T[u].r!=NIL){
    Inorder(T[u].r);
  }
}

void Postorder(int u){
  if(T[u].l!=NIL){
    Postorder(T[u].l);
  }
  if(T[u].r!=NIL){
    Postorder(T[u].r);
  }
  printf(" %d",u);
}


main(){
  int n,i,v,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=T[i].l=T[i].r=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    if(l!=NIL){
      T[l].p=v;
    }
    if(r!=NIL){
      T[r].p=v;
    }
    T[v].l = l;
    T[v].r = r;
  } 
  printf("Preorder\n");
  for ( i = 0; i < n; i++ ){
    if(T[i].p==NIL){
      Preorder(i);
      printf("\n");
      printf("Inorder\n");
      Inorder(i);
      printf("\n");
      printf("Postorder\n");
      Postorder(i);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 616
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        x: u64,
        y: u64,
        z: u64,
    }

    println!("{}", x*y/2);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using P = pair<int, int>;
using MATRIX = vector< vector<ll> >;

int main() {
  int X;
  cin >> X;
  int key = 1;
  while(true) {
    if(pow(key, 4) > X) {
      break;
    }
    key++;
  }

  rep(i, key+1) {
    rep(j, key+1) {
      if(pow(i, 5)-pow(j, 5) == X) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }

  rep(i, 100) {
    rep(j, 100) {
      if(pow(i, 5) + pow(j, 5) == X) {
        cout << i << " " << -j << endl;
        return 0;
      }
    }
  }

  return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/12/04  Problem: codefestival2017_team_relay G / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL L;

string ans ="";

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

	cin >> L ;
	string s,t;
	cin>>s>>t;
	LL ssize = SZ(s);
	LL tsize = SZ(t);
	if(s + t > t + s )swap(s,t); // sのほうがちいさい
	ssize= SZ(s);
	tsize= SZ(t);
	FORR(i,L,0-1){
		LL left = ssize * i;
		if((L-left)>=0&&(L-left)%tsize==0){
			FOR(k,0,i)ans+=s;
			FOR(k,0,(L-left)/tsize)ans+=t;
			break;
		}
	}
	assert(L==SZ(ans));
	
	cout << ans << "\n";

	return 0;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

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

  vi h(n);
  rep(i, 0, n) cin >> h[i];

  cout << ([&](){
    h[0]--; 
    rep(i, 1, n){
      if(h[i-1] < h[i]) h[i]--;
      if(h[i-1] > h[i]) return false;
    }
    return true;
  }() ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 1024
L,R=map(int,input().split())
MOD=2019
ans=10**9
for i in range(L,R):
    for j in range(i+1,R+1):
        flag=i*j%MOD
        if flag==0:
            print(0)
            exit()
        ans=min(ans,flag)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (((ll)1<<31)-1)
#define eps LDBL_EPSILON
#define moder (1000000007)
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
#define ggr getchar();getchar();return 0;
using namespace std;
signed main(){
    double a,b;
	double now=0;
	double nx=0,ny=0;
	while(true){
		scanf("%lf,%lf",&a,&b);
		if(a==0&&b==0){
            cout<<(int)nx<<endl<<(int)ny<<endl;
            ggr;
        }
		nx+=a*sin(now/180*pie);
		ny+=a*cos(now/180*pie);
		now+=b;
	}
    ggr;
}


Measured memory_bytes: 3480
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    n %= 10;
    if(n == 3){
    	cout << "bon" << endl;
    }else if(n == 0 || n == 1 || n == 6 || n == 8){
    	cout << "pon" << endl;
    }else{
    	cout << "hon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctype.h>
#include <math.h>
using namespace std;

int main(){
    int k,s;
    cin>>k>>s;
    int count=0;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            if(0<=s-x-y&&s-x-y<=k){
                count++;
            }
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <string.h>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

string bit[] = {"0", "1"};
int main() {
	int c = 0, q;
	string	sb[16];
	REP(i, 2)REP(j, 2)REP(k, 2)REP(l, 2){
		sb[c++] = bit[i] + bit[j] + bit[k] + bit[l];
	}
	cin >> q;
	char ins[10];
	REP(i, q){
		long long i_ans = 0;
		double d_ans = 0.0;
		scanf("%s", ins);
		string str("");
		REP(j, 8){
			char s = ins[j];
			int n;
			if(s >= 'a' && s <= 'f')
				n = s - '0' - 39;
			else
				n = s - '0';
			str += sb[n];
				//printf("%c\n", s);
		/*	REP(k, 4){
				char ch = sb[n][k];
				int b = ch - '0';
				if(k == 0 && j == 0){
					u = b;
					continue;
				}
				if((j == 6 && k >= 1) || j == 7)
					ans += pow(0.5,  (j - 6) * 4 + k) * b;
				else
					ans += pow(2, (8 - j) * 4 - k - 8) * b;
			}
		*/
		}
		reverse(str.begin(), str.end());
		FOR(i, 7, 31){
			if(str[i] - '0' == 1)
				i_ans += pow(2, i - 7);
		}
		for(int i = 6; i >= 0; --i){
			if(str[i] - '0' == 1)
				d_ans += pow(0.5, (7 - i));
		}
		/*int r = ans;
		double tmp = ans - r;*/
		int v = d_ans * pow(10, 7); //tmp * pow(10, 8);
		
		
		while(v % 10 == 0 && v > 0){
			v /= 10;
		}
		int cnt = 0;
		while(d_ans < 1 && d_ans != 0){
			d_ans = d_ans * 10;
			cnt++;
		}
		//cout << d_ans << endl;
		if(str[31] - '0' == 1)
			printf("-");
		printf("%lld.", i_ans);
		if(v == 0)
			printf("0\n");
		else{
			REP(i, cnt - 1)
				printf("0");
			printf("%d\n", v);
		}
	}
	return 0;
}

Measured memory_bytes: 1292
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+10;
int n, a[MAXN];

int main() {
    scanf("%d", &n);
    for(int i=0;i<n;i++) {
        scanf("%d", &a[i]); 
    }

    int ans = 1;
    int cur = a[0];
    int trend = 0;

    for(int i=1;i<n;i++) {
        if(a[i] == cur) continue;
        if(a[i] > cur) {
            if(trend == -1) {
                trend = 0;
                ans++;
            } else trend = 1;
        } else if(a[i] < cur) {
            if(trend == 1) {
                trend = 0;
                ans++;
            } else trend = -1;
        } else {
            trend = 0;
            ans++;
        }
        cur = a[i];
    }

    printf("%d\n", ans);
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
	int psy[5],h[3],g=0,i,j,tmp;
	for(i=0;i<4;i++)scanf("%d",&psy[i]);
	for(i=0;i<2;i++)scanf("%d",&h[i]);
	for(i=0;i<4;i++){
		for(j=i+1;j<4;j++){
			if(psy[i]<psy[j]){
				tmp=psy[i];
				psy[i]=psy[j];
				psy[j]=tmp;
			}
		}
	}
	g=psy[0]+psy[1]+psy[2];
	if(h[0]>h[1])g=g+h[0];
	else g=g+h[1];
	printf("%d\n",g);
	return 0;
}



Measured memory_bytes: 2104
while 1:
 n=int(input())
 if n==0:break
 d={}
 for _ in[0]*n:
  k,v=input().strip().split()
  d[k]=v
 for _ in[0]*int(input()):
  e=input().strip()
  print(d[e]if e in d else e,end='')
 print()


Measured memory_bytes: 6472
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  map<int, int> mp;
  for(int i = 0; i < 3; i++){
    int a; cin >> a;
    mp[a]++;
  }
  for(auto p : mp){
    if(p.second == 2){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


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

int main(){
    string s; int q; cin >> s >> q;
    s.reserve(200000);
    bool flag = false;
    int t, f;
    char c;
    for (int i = 0; i < q; i++)
    {
        cin >> t;
        if (t == 1){
            flag = !flag;
        }else{
            cin >> f >> c;
            if (f == 1){
                if (!flag) s.insert(s.begin(), c);
                else s.insert(s.end(), c);
            }else{
                if (!flag) s.insert(s.end(), c);
                else s.insert(s.begin(), c);
            }
        }
    }
    if (flag) reverse(s.begin(), s.end());
    cout << s << endl;
}

Measured memory_bytes: 1052
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll Nagaemon1;
void swap(ll i,ll j){
  Nagaemon1=i;
  i=j;
  j=Nagaemon1;
}
int main(){
  ll a=1,n;
  cin >> n;
  rep(i,n){
    a=a*(i+1)%1000000007;
  }
  cout << a;
}

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

#define DEBUG

#ifndef TZNLOCAL
#undef DEBUG
#endif

#ifdef DEBUG
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) ;
#endif

#define maxn 111111
typedef long long ll;
int n,p;
int a[maxn],b[maxn];
int c[40];
ll ans;

int main()
{
	int n;
	cin>>n>>p;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i];
	}
	int mx=0,lim=0;
	for(int i=0;i<30;i++)
	{
		if (p&(1<<i))
		{
			mx=i;
			lim=(1<<i);
		}
	}
	for(int k=mx;k>=0;k--)
	{
		for(int i=0;i<30;i++)
		{
			if (p&(1<<i)) c[i]=1;
			else c[i]=0;
		}
		if (!c[k]) continue;
		c[k]=0;
		ll cur=0;
		for(int i=1;i<=n;i++)
		{
			bool ok=1;
			for(int j=k;j<30;j++)
			{
				if ((a[i]&(1<<j)) && !c[j])
				{
					ok=0;
				}
			}
			if (ok) cur+=b[i];
		}
		ans=max(ans,cur);
	}
	{
		for(int i=0;i<30;i++)
		{
			if (p&(1<<i)) c[i]=1;
			else c[i]=0;
		}
		ll cur=0;
		for(int i=1;i<=n;i++)
		{
			bool ok=1;
			for(int j=0;j<30;j++)
			{
				if ((a[i]&(1<<j)) && !c[j])
				{
					ok=0;
				}
			}
			if (ok) cur+=b[i];
		}
		ans=max(ans,cur);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;

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

    if(N == 1){
        cout << "Hello World" << endl;
    }else if(N == 2){
        int A,B;
        cin >> A >> B;
        cout << A + B << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define MAX_N 300

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

  ll a[MAX_N][MAX_N];

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

  int flag = 0;
  ll ans = 0;

  if(n == 1){
    cout << 0 << endl;
    return 0;
  }else if(n == 2){
    cout << a[0][1] << endl;
    return 0;
  }

  /*
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cout << a[i][j] << " ";
    }
    cout << endl;
  }
  */

  int temp = 0;
  for(int i=0 ; i<n-1 ; i++){
    for(int j=i+1 ; j<n ; j++){
      flag = 0;
      for(int k=0 ; k<n ; k++){
        if(k != i && k != j){
          temp = a[i][k] + a[k][j];
          if(temp < a[i][j]){
            cout << -1 << endl;
            return 0;
          }else if(temp == a[i][j]){
            flag = 1;
            break;
          }
        }
      }
      if(flag == 0){
        ans += a[i][j];
      }
    }
  }

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

Measured memory_bytes: 896
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

int dx[] = { -1, 0, 1, 0, -1, -1, 1, 1};
int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};


long long  f(long long  x, long long  y, long long  z) {
	return x * x + y * y + z * z + x * y + y * z + z * x;
}

int main() {

	long long  n; cin >> n;
	map<long long , long long > ans;

	for (long long  x = 1; x <= 101; x++) {
		for (long long  y = 1; y <= 101; y++) {
			for (long long  z = 1; z <= 101; z++) ans[f(x, y, z)]++;
		}
	}

	for (long long  i = 1; i <= n; i++) cout << ans[i] << "\n";

	return 0;
}

Measured memory_bytes: 5560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

ll D, c[33], s[444][33], t[444], last[33] = {};
set<ll> s1[33], s2[33];

// vector<ll> score(ll t[]) {
//     ll i, j, sc = 0;
//     vector<ll> v;
//     v.pb(0);
//     for (i = 1; i <= D; i++){
//         sc += s[i][t[i]];
//         last[t[i]] = i;
//         for (j = 1; j <= 26;j++)
//             sc -= c[j] * (i - last[j]);
//         v.pb(sc);
//     }
//     return v;
// }

ll cost(ll k, ll dis){
    return k * dis * (dis - 1) / 2;
}

ll eval(ll d, ll q){
    ll bq = t[d];
    ll b = *s1[bq].upper_bound(d);
    ll a = *s2[bq].upper_bound(-d);
    ll sc = 0;
    sc -= s[d][bq];
    sc += s[d][q];
    ll l = d + a, r = b - d;
    sc += cost(c[bq], l);
    sc += cost(c[bq], r);
    sc -= cost(c[bq], l + r);
    b = *s1[q].upper_bound(d);
    a = *s2[q].upper_bound(-d);
    l = d + a, r = b - d;
    sc -= cost(c[q], l);
    sc -= cost(c[q], r);
    sc += cost(c[q], l + r);
    return sc;
}

int main(){
    ll i, j;
    cin >> D;
    for (i = 1; i <= 26;i++)
        cin >> c[i];
    for (i = 1; i <= D;i++)
        for (j = 1; j <= 26;j++)
            cin >> s[i][j];
    for (i = 1; i <= 26; i++){
        s1[i].insert(D + 1);
        s2[i].insert(0);
    }
    for (i = 1; i <= D;i++){
        ll ma = -1e15, p;
        for (j = 1; j <= 26; j++){
            if(c[j]*(i-last[j])+s[i][j]>ma){
                ma = c[j] * (i - last[j]) + s[i][j];
                p = j;
            }
        }
        t[i] = p;
        last[p] = i;
    }
    for (i = 1; i <= D;i++){
        s1[t[i]].insert(i);
        s2[t[i]].insert(-i);
    }
    random_device rnd;
    mt19937 mt(rnd());
    uniform_int_distribution<> rand365(1, 365);
    ll INF = 1e9;
    double start_temp = 30000, end_temp = 0;
    ll turn = 500000;
    for (i = 0; i < turn; i++){
        ll ma = -1e15, p;
        ll d = rand365(mt);
        for (j = 1; j <= 26; j++){
            if(j!=t[d]){
                ll sc = eval(d, j);
                if(sc > ma){
                    ma = sc;
                    p = j;
                }
            }
        }
        double temp = start_temp + (end_temp - start_temp) * i / turn;
        double prob = exp(ma / temp);
        if (prob > (rand() % INF) / (double)INF){
            s1[t[d]].erase(d);
            s2[t[d]].erase(-d);
            s1[p].insert(d);
            s2[p].insert(-d);
            t[d] = p;
        }
    }
    for (i = 1; i <= D;i++)
        cout << t[i] << endl;
}

Measured memory_bytes: 4376
import java.util.*;
public class Main {
	//0224 start
	//0300 stop
	//2300 restart
	int t, num,len;
	String numstr;
	int [] ansarray,work;
	int ans;
	boolean rejected;

	private void dfs(int deep, int index){
		if(index == len-1){
			int res = calc(work);
			if(res <= t && res > ans){
				ans = res;
				ansarray = work.clone();
				rejected= false;
			}
			else if(res == ans){
				rejected = true;
			}
		}

		for(int i = index + 1; i < len; i++){

			work[deep] = i;
			dfs(deep + 1, i);
			work[deep] = -1;
		}
	}


	private int calc(int[] a) {
		int start = -1;
		int i = 0;
		int end = a[i++];
		int sum = 0;
		//System.out.println("b = " + Arrays.toString(a));
		while(start != len - 1){
			//System.out.println("start = " + start + " " + end);
			String temp = numstr.substring(start + 1, end + 1);
			//System.out.println("temp= " + temp + "start = " + start + " end= " + end);
			sum += Integer.parseInt(temp);
			start = end;
			end = a[i++];
		}
		//System.out.println("a = " + Arrays.toString(a) + " " + sum);
		//System.out.println();
		return sum;
	}


	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			t = sc.nextInt();
			num = sc.nextInt();
			if((t|num) == 0) break;
			numstr = num + "";
			len = numstr.length();
			ansarray = new int[len + 1];
			work = new int[len + 1];
			Arrays.fill(work, -1);
			ans = -1;
			rejected = false;
			dfs(0,-1);
			if(rejected){
				System.out.println("rejected");
//				System.out.println("ans = " + ans);
//				System.out.println("array = " + Arrays.toString(ansarray));
			}
			else if(ans == -1){
				System.out.println("error");
			}
			else{
				System.out.print(ans);
				int start = -1, end = ansarray[0];
				for(int i = 0; i < ansarray.length - 1; i++){
					if(ansarray[i] == -1) break;
					String temp = numstr.substring(start + 1, end + 1);
					System.out.print(" " + temp);
					start = end;
					end = ansarray[i + 1];
				}
				System.out.println();
			}

		}
	}

	public static void main(String [] args){
		new Main().doit();
	}
}

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

#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    
    if(s[2] == s[3] && s[4] == s[5])
    cout << "Yes" << endl;
    else cout << "No" << endl;



}

Measured memory_bytes: 256
//$ darklife_12
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <cstring>
#include <bits/stdc++.h>
#include <iostream>
#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based
#define enterarray(a,n) for(int i=0;i<(int)(n);++i)cin>>a[i];
#define ins insert
const int MOD =998244353;
const int MX = int(2e6+9);
using namespace std;
int even(ll num){
    if(num%2==0)return 1;
    else return 0;
}
void printvector(vector<int> v){
    int i;
    for0(i,v.size())cout<<v[i]<<" ";
}
void solve()              
{
    ll n,m,i,j,k;
    long long a[200005],b[200005];
    ll ans=0,res;
    bool flag=true;
    vector<int> v;
    string s1,s2;
    set<int> s;
    cin>>n>>m;
    for0(i,n){
        ll x,y;
        cin>>x>>y;
        double d=sqrt(pow(x,2)+pow(y,2));
       // cout<<d;
        if(d<=m)ans++;
    }
    cout<<ans;
}
 
int main()
{
    FAST;
   int t;
    t=1;
    while(t--)
    {
        solve();
       cout<<"\n";
    }
}

Measured memory_bytes: 3672
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
last = [-1]*26

ans = 0
for d in range(D):
    stack = []
    for i in range(26):
        if (d-last[i])*c[i]<0:
            stack.append(i)
    if stack:
        tmp, res = 0, 0
        for i in stack:
            if tmp<s[d][i]:
                tmp, res = s[d][i], i
        last[res] = d
        print(res+1)
    else:
        tmp, res = 0, 0
        for i in range(26):
            if tmp<s[d][i]:
                tmp, res = s[d][i], i
        last[res] = d
        print(res+1)

Measured memory_bytes: 9400
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    for (int i = 0; i < S.length()-1; i++) {
      if (S.charAt(i) == 'A' && S.charAt(i+1) == 'C') {
        System.out.println("Yes");
        return;
      }
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int X,A,B;cin >> X >> A >> B;
  cout << (X-A)%B << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

static const ll MOD = 1e9 + 7;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m, r;

    cin >> n >> m >> r;

    long N[n][n];
    int R[r];
    int a, b;
    long c, sum, ans = LONG_MAX;

    int i, j, k;

    for (i = 0; i < n; i++) for (j = 0; j < n; j++) N[i][j] = LONG_MAX / 2L;

    for (i = 0; i < r; i++) {
        cin >> a;

        a--;

        R[i] = a;
    }

    sort(R, R + r);

    for (i = 0; i < m; i++) {
        cin >> a >> b >> c;

        a--;
        b--;

        if (c < N[a][b]) N[a][b] = N[b][a] = c;
    }

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

    do {
        sum = 0L;

        for (i = 1; i < r; i++) sum += N[R[i - 1]][R[i]];

        ans = min(ans, sum);
    } while (std::next_permutation(R, R + r));

    cout << ans << endl;

    return 0;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  ll n,a,b;
  cin>>n>>a>>b;

  ll c = a+b;
  ll ans = n/c*a;
  ans += min((n%c),a);
  cout<<(ans)<<endl;

}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
char mem[114514];
char t[114514];
char c[114514];
string s[114514];
int a[214514],b[114514];
signed main(){
	ic(n) ic(x) 
	int sum=0;
	rep(0,i,n)cin>>a[i];
	sort(a,a+n);
	rep(0,i,n-x)sum+=a[i];
	c(sum)
}		


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    ll n,ans = 0;
    cin >> n;
    vector<ll> a(n + 1),b(n);
    rep0(i, n + 1)cin >> a[i];
    rep0(i, n)cin >> b[i];
    rep0(i, n){
        if(a[i] >= b[i])ans += b[i];
        else{
            ans += a[i];
            b[i] -= a[i];
            if(a[i + 1] <= b[i])b[i] = a[i + 1];
            a[i + 1] -= b[i];
            ans += b[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1920
import sys
import itertools
sys.setrecursionlimit(10**9)
X = int(input())

ITEM = [100, 101, 102, 103, 104, 105]
def restricted_part_sum(a,A):
  #初期化
  N=len(a)
  dp=[[-1 for i in range(A+1)] for j in range(N+1)]
  dp[0][0]=0

  #DP
  for i in range(N):
    for j in range(A+1):
      if dp[i][j]>=0:
          dp[i+1][j]=1000000
      elif j<a[i] or dp[i+1][j-a[i]]<=0:
          dp[i+1][j]=-1
      else:
          dp[i+1][j]=dp[i+1][j-a[i]]-1
  return int(dp[N][A]>=0)


ret = restricted_part_sum(ITEM, X)
print(ret)

Measured memory_bytes: 81776
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
int ans,a,b,n;

int f(int a,int b){
	int r=0;
	while(a)r+=a%10,a/=10;
	while(b)r+=b%10,b/=10;
	return r;

}
int main(){
	cin>>n;
	ans=1000000000;
	for(int i=1;i<=n-1;i++){
		ans=min(ans,f(i,n-i));
	}
	cout<<ans<<endl;
	

	return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {

        int n = int.Parse(Console.ReadLine());

        double price = 100000;
        for (int i = 0; i < n; i++)
        {
            price = price * 1.05;

            price = price / 1000;
            double tmp = Math.Ceiling(price);
            price = tmp * 1000;

        }

        Console.WriteLine(price);
    }
}


Measured memory_bytes: 9016
N = int(input())
lst_num = input().rstrip().split()

lst_rec = []
for i in range(N):
  target = int(lst_num[i])
  lstCnt = i + 1
      
  while True:
    if N  <= lstCnt : break
    
    diff = abs(target - int(lst_num[lstCnt]))
    lst_rec.append(diff)
    lstCnt += 1

print(max(lst_rec))

Measured memory_bytes: 3188
h,w=map(int,input().split())
t=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
for i in range(h):
    a=list(input().split())
    if "snuke" in a:
        print("{}{}".format(t[a.index("snuke")],i+1))
        break

Measured memory_bytes: 3064
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N,K=get_i
ans=0
if K.zero?
    ans+=N**2
else
  ans+=(N-K)*(N-K+1)/2
end
if K.nonzero? and (N/K>2  or(N/K==2 and N%K>=1))
    (K+1).upto(N-K) do|b|
        if N%b>=K
            ans+=((N/b)-1)*(b-K)+(N%b-K)+1
        else
            ans+=((N/b)-1)*(b-K)
        end
    end
end
puts ans

Measured memory_bytes: 1788
n,w=map(int,input().split())
wi=[]
vi=[]

for i in range(n):
  a,b=map(int,input().split())
  wi+=[a]
  vi+=[b]
  
dp=[[0]*(w+1) for i in range(n+1)]

for i in range(n):
  for j in range(w+1):
    if j<wi[i]:
      dp[i+1][j]=dp[i][j]
      
    else:
      dp[i+1][j]=max(dp[i][j],dp[i][j-wi[i]]+vi[i])
      
print(dp[n][w])

Measured memory_bytes: 147168
import sys
import os

def file_input():
    f = open('ARC067/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    N=int(input())

    p=10**9+7

    arr = dict()

    for j in range(N):
        tmp = j+1
        # print("tmp="+str(tmp))
        for i in range(2,int(-(-N**0.5//1))+1):
            if tmp%i==0:
                cnt=0
                while tmp%i==0:
                    cnt+=1
                    tmp//=i
                # print("i="+str(i)+" c="+str(cnt))
                if i in arr:
                    arr[i]+=cnt
                else:
                    arr[i]=cnt

        if tmp!=1:
            # print("i="+str(tmp)+" c=1")
            if tmp in arr:
                arr[tmp]+=1
            else:
                arr[tmp]=1

    # print(arr)
    out=1
    for i in arr.values():
        out*=i+1
        out%=p


    print(out)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/*input
10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3
*/

#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main()
{

	int W, H, N;

	cin >> W >> H >> N;

	// cout << W << H << N << endl;

	vector<vector<int>> field;
	field.resize(H);
	for(int i=0;i<H;i++){
		field[i].resize(W);
	}

	vector<int> x(N);
	vector<int> y(N);
	vector<int> a(N);

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

	// fill
	for(int i=0;i<N;i++){
		if(a[i] == 1){
			for(int j=0;j<H;j++){
				for(int k=0;k<W;k++){
					if(k < x[i]) field[j][k] = 1;
				}
			}
		}else if(a[i] == 2){
			for(int j=0;j<H;j++){
				for(int k=0;k<W;k++){
					if(k >= x[i]) field[j][k] = 1;
				}
			}	
		}else if(a[i] == 3){
			for(int j=0;j<H;j++){
				for(int k=0;k<W;k++){
					if(j < y[i]) field[j][k] = 1;
				}
			}	
		}else{
			for(int j=0;j<H;j++){
				for(int k=0;k<W;k++){
					if(j >= y[i]) field[j][k] = 1;
				}
			}	
		}
	}

	// count
	int count = 0;
	for(int i=0;i<H;i++){
		count += accumulate(field[i].begin(), field[i].end(), 0);
	}
	
	cout << (W*H - count) << endl;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

const ll mod = 998244353LL;

// aのb乗を求める.
ll modpow(ll a, ll b) {
	if (a > mod) a %= mod;
	if (b == 0LL) return 1LL;
	ll tmp = modpow(a, b / 2);
	if (b & 1LL)
		return tmp * tmp % mod * a % mod;
	return tmp * tmp % mod;
}

int A, B, C, D;

void input(void){ cin >> A >> B >> C >> D; }

int main(void){
    input();

    if (B == D){
        cout << modpow(B, C - A) << endl;
        return 0;
    }

    vector<vector<ll>> dp(D - B, vector<ll>(C + 1, 0LL));

    // 初期化
    for (int h = 0; h <= C; ++h){
        if (h == A) dp[0][h] = A;
        else if (h > A) dp[0][h] = modpow(B, h - A);
    }

    // 遷移
    for (int i = 1; i < D - B; ++i){
        for (int h = 1; h <= C; ++h){
            ll tmp = (dp[i][h - 1] - (h - 1) * dp[i - 1][h - 1] % mod + mod) % mod;
            tmp = (tmp + dp[i - 1][h - 1]) % mod;
            tmp = tmp * (B + i) % mod;
            dp[i][h] = (tmp + h * dp[i - 1][h] % mod) % mod;
        }
    }

/*
    for (int h = C; h >= 0; --h){
        for (int i = 0; i < D - B; ++i)
            cout << dp[i][h] << " ";
        cout << endl;
    }
*/

    // 答えの計算
    ll res = 0LL;
    for (int h = 0; h <= C; ++h){
        ll tmp = dp[D - B - 1][h] * modpow(D, C - h) % mod;
        res = (res + tmp) % mod;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 73580
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <set>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1010101010
#define MOD 1000000007
#define LL long long
using Coord = pair<int, int>;

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

    cout << (n + 1) * n / 2 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main() {
	char S[101], *point;
	int i, flag = 0;
	scanf("%s", S);
	if ((point = strchr(S, 'C')) == NULL) {
		printf("No\n");
		return 0;
	} else {
		for (i = point - S; i < strlen(S); i++) {
			if (S[i] == 'F') {
				flag = 1;
				break;
			}
		}
	}	
	if (flag == 1) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(200000)

N = int(input())
MOD = 10 ** 9 + 7

to = [[] for _ in range(N)]
for _ in range(N-1):
    x, y = map(int, input().split())
    to[x-1].append(y-1)
    to[y-1].append(x-1)

def dfs(n,p):
    w = 1
    b = 1
    for i in to[n]:
        if i != p:
            rw, rb = dfs(i, n)
            w *= (rw + rb)
            w %= MOD
            b *= rw
            b %= MOD
    return (w,b)

ans = dfs(0, -1)
print((ans[0] + ans[1]) % MOD)

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

typedef struct Node {
    int key;
    struct Node *prev;
    struct Node *next;
}node;

node *nil;

void init();
void insert(int);
void delete(node *);
void deleteFirst();
void deleteLast();
void printnode();
node *liserch(int);

int main(){
    int n,i,k;
    char c[12];

    scanf("%d",&n);

    init();

    for(i=0;i<n;i++){
        scanf("%s",c);
        
        if(strcmp("insert",c)==0){
          scanf("%d",&k);
          insert(k);  
        }

        else if(strcmp("delete",c)==0){
            scanf("%d",&k);
            delete(liserch(k));
        }

        else if(strcmp("deleteLast",c)==0){
            deleteLast();
        }

        else if(strcmp("deleteFirst",c)==0){
            deleteFirst();
        }
    }
    printnode();
    return 0;
}


void init(){

    nil=(node *)malloc(sizeof(node));
    nil->next=nil;
    nil->prev=nil;
}


void insert(int k){
    node *x;

    x=(node *)malloc(sizeof(node));
    x->key=k;
    x->next=nil->next;
    x->prev=nil;
    nil->next->prev=x;
    nil->next=x;
}


void delete(node *t){
    if(t==nil)return;
    t->next->prev=t->prev;
    t->prev->next=t->next;
    free(t);
}


node *liserch(int k){
    node *cur;

    cur=nil->next;
    
    while (cur->key!=k && cur!=nil){
        cur=cur->next;
    }
    return cur;
}


void deleteLast(){
    delete(nil->prev);
}


void deleteFirst(){
    delete(nil->next);
}


void printnode(){
    node *cur;

    cur=nil->next;
    
    while (cur!=nil){
        if(cur!=nil->next)printf(" ");
        printf("%d",cur->key);
        cur=cur->next;
    }
    printf("\n");
}


Measured memory_bytes: 33000
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
using namespace std;

int main(){
  int h,w;
  cin >> h >> w;
  char s[h][w];
  REP(i,h){
    REP(j,w){
      cin >> s[i][j];
    }
  }
  REP(i,h){
    REP(j,w){
      if(s[i][j]=='#'){
        if((i!=0&&s[i-1][j]=='#')||(i!=h-1&&s[i+1][j]=='#')||(j!=0&&s[i][j-1]=='#')||(j!=w-1&&s[i][j+1]=='#')){
        }else{
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
}


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

#define NDEBUG
#ifdef DEBUG
#include "cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))


int solve(int n, vector<string>& s){
    vector<vector<char>> w(n*2, vector<char>(n*2));
    rep(i,n) rep(j,n){
        char ch = s[i][j];
        rep(a,2) rep(b,2) {
            w[i+n*a][j+n*b] = ch;
        }
    }
    int ans = 0;
    rep(of,n) {
        int neq = 0;
        repC2(i,j,n){
            if (w[of+i][j] != w[of+j][i]) ++neq;
        }
        if (neq == 0) ++ans;
    }
    return ans * n;
}

int main() {
    int n; cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    cout << solve(n, s) << endl;
    return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int n; cin >> n;
	string s; cin >> s;
	int pre = 0, post = 0;
	for (char c: s) {
		if (c == ')') --post;
		else ++post;
		if (post < 0) {
			++pre;
			post = 0;
		}
	}
	debug(pre); debug(post);
	for (int i = 0; i < pre; ++i) cout << '(';
	cout << s;
	for (int i = 0; i < post; ++i) cout << ')';
	
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256