akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;

void one(int num)
{
	switch (num % 5)
	{
	case 1: cout << ".";
		break;
	case 2: cout << ",";
		break;
	case 3: cout << "!";
		break;
	case 4: cout << "?";
		break;
	case 0:cout << " ";
		break;
	}
}
void two(int num)
{
	switch (num % 3)
	{
	case 1: cout << "a";
		break;
	case 2: cout << "b";
		break;
	case 0: cout << "c";
		break;
	}
}
void three(int num)
{
	switch (num % 3)
	{
	case 1: cout << "d";
		break;
	case 2: cout << "e";
		break;
	case 0: cout << "f";
		break;
	}
}
void four(int num)
{
	switch (num % 3)
	{
	case 1: cout << "g";
		break;
	case 2: cout << "h";
		break;
	case 0: cout << "i";
		break;
	}
}
void five(int num)
{
	switch (num % 3)
	{
	case 1: cout << "j";
		break;
	case 2: cout << "k";
		break;
	case 0: cout << "l";
		break;
	}
}
void six(int num)
{
	switch (num % 3)
	{
	case 1: cout << "m";
		break;
	case 2: cout << "n";
		break;
	case 0: cout << "o";
		break;
	}
}
void seven(int num)
{
	switch (num % 4)
	{
	case 1: cout << "p";
		break;
	case 2: cout << "q";
		break;
	case 3: cout << "r";
		break;
	case 0: cout << "s";
		break;
	}
}
void eight(int num)
{
	switch (num % 3)
	{
	case 1: cout << "t";
		break;
	case 2: cout << "u";
		break;
	case 0: cout << "v";
		break;
	}
}
void nine(int num)
{
	switch (num % 4)
	{
	case 1: cout << "w";
		break;
	case 2: cout << "x";
		break;
	case 3:cout << "y";
		break;
	case 0: cout << "z";
	}
}
void clear(int a, int aa, int aaa, int b, int bb, int bbb, int c, int cc, int ccc)
{
	a = 0; aa = 0; aaa = 0;
	b = 0; bb = 0; bbb = 0;
	c = 0; cc = 0; ccc = 0;
}
int main(void)
{
	long long int n,a,aa,aaa,b,bb,bbb,c,cc,ccc;
	string str;
	cin >> n;
	a = 0; aa = 0; aaa = 0;
	b = 0; bb = 0; bbb = 0;
	c = 0; cc = 0; ccc = 0;
	long long int i,t;
	for (i = 0; i < n; i++)
	{
		cin >> str;
		clear(a, aa, aaa, b, bb, bbb, c, cc, ccc);
		int length = str.length();
		for (t = 0; t < length; t++)
		{
			switch (str[t])
			{
			case '0': 
				if (a > 0)
				{
					one(a);
				}
				else if (aa > 0)
				{
					two(aa);
				}
				else if (aaa > 0)
				{
					three(aaa);
				}
				else if (b > 0)
				{
					four(b);
				}
				else if (bb > 0)
				{
					five(bb);
				}
				else if (bbb > 0)
				{
					six(bbb);
				}
				else if (c > 0)
				{
					seven(c);
				}
				else if (cc > 0)
				{
					eight(cc);
				}
				else if (ccc > 0)
				{
					nine(ccc);
				}
				a = 0; aa = 0; aaa = 0;
				b = 0; bb = 0; bbb = 0;
				c = 0; cc = 0; ccc = 0;
				break;

			case '1': a++;
				break;
			case '2': aa++;
				break;
			case '3': aaa++;
				break;
			case '4': b++;
				break;
			case '5': bb++;
				break;
			case '6': bbb++;
				break;
			case '7': c++;
				break;
			case '8': cc++;
				break;
			case '9': ccc++;
				break;
			}
	
		}
		cout << endl;
	}

	return 0;

}



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

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try{
	    String st;
	    int sum = 0;
	    while((st = sc.readLine())!=null){
		for(int i=0; i<st.length(); i++){
		    char c = st.charAt(i);
		    if(Character.isDigit(c)){
			int x = c - '0';
			for(i=i+1; i<st.length(); i++){
			    c = st.charAt(i);
			    if(!Character.isDigit(c))
				break;
			    x*=10;
			    x+=c-'0';
			}
			sum+=x;
		    }
		}
	    }
	    
	    System.out.println(sum);
	}catch (Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 10000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll C = 1e9+7; //10の9乗

ll F(ll A, ll B) {
    return max(log10(A)+1, log10(B)+1);
}

int main(){
    int n;
    cin >> n;
    vector<string> S(n);
    //ソートした各要素を配列にいれる
    for(int i=0; i<n; i++) {
        string ss;
        cin >> ss;
        sort(ss.begin(), ss.end());
        S[i] = ss;
    }

    for(char c='a'; c<='z'; c++) {
        int m = 1000;
        for(int j=0; j<n; j++) {
            int x = count(S[j].begin(), S[j].end(), c);
            m = min(m, x);
        }

        for(int i=0; i<m; i++) cout << c;
    }
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  const int shift = 10e5;
  int N, M;
  cin >> N >> M;

  vector<int> X(M);
  rep(i, M)
  {
    int x;
    cin >> x;
    X[i] = x + shift;
  }

  if (N >= M)
  {
    cout << 0 << endl;
    return 0;
  }

  std::sort(X.begin(), X.end());

  int sum = 0;
  vector<int> diff(M - 1);
  rep(i, M - 1)
  {
    diff[i] = X[i + 1] - X[i];
  }
  sum = X[M - 1] - X[0];

  std::sort(diff.begin(), diff.end());
  rep(i, N - 1)
  {
    sum -= diff[M - 2 - i];
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int n;

void dfs(string &s,char mx){
  if((int)s.size()==n){
    cout << s << endl;
    return ;
  }
  for(char c='a';c<=mx+1;c++){
    string t=s+c;
    dfs(t,max(mx,c));
  }
}
  

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  cin >> n;
  string s="";
  dfs(s,'a'-1);
  return 0;     
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


signed main() {
    int n, k;
    cin >> n >> k;
    cout << n - k + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
    ll N, A, B; cin >> N >> A >> B;
    ll ans = (N - 2) * (B - A) + 1;
    cout << max((ll)0,ans) << endl;
}


Measured memory_bytes: 256
n = int(input())

testimony = [[-1] * n for _ in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        testimony[i][x-1] = y


def check(i):
    honests = []
    for j in range(n):
        if (i >> j) & 1:
            honests.append(j)

    for j in honests:
        for k in range(len(testimony[j])):
            if testimony[j][k] == 1 and k not in honests:
                return False
            if testimony[j][k] == 0 and k in honests:
                return False

    return True


ans = 0
for i in range(1, 2 << (n-1)):
    if check(i):
        count = 0
        for j in range(n):
            if (i >> j) & 1:
                count += 1
        ans = max(ans, count)

print(ans)


Measured memory_bytes: 45148
#include <iostream>
using namespace std;
 
int main() 
{
  int n;
  cin >> n;
  int a[n];
  int i;
  for(i = 0;i < n;i++){
    cin >> a[i];
  }
  int b[n];
  for(i = 0;i < n;i++){
    b[i] = a[n-1-i];
    if(i != n-1){
      cout << b[i] << " ";
    }else{
      cout << b[i] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3044
#include<bits/stdc++.h>
  using namespace std;
  #define       M                        1000000007
  #define       ll                       long long
  #define       FIO                      ios_base::sync_with_stdio(false);cin.tie(NULL)
  #define       ifor(st,lim)             for(int i=st;i<lim;i++)
  #define       jfor(stt,llim)           for(int j=stt;j<llim;j++)
  #define       eifor(st,lim)            for(int i=st;i<=lim;i++)
  #define       ejfor(stt,llim)          for(int j=stt;j<=llim;j++)
  #define       blank                    cout<<'\n' 

  void solve()
  { 
      string s; cin>>s;
      int sum = 0;
      for(char c : s) sum+=c-'0';
      if(sum%9 == 0) cout<<"Yes";
      else cout<<"No";
  } 

  int main()
  {
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
  int t=1; 
    while(t--){
      solve();
     } 
  }

Measured memory_bytes: 3668
/**
*    created: 08.05.2020 08:00:40
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf =1000000000;
vector<ll> A;
ll n;
void dfs(ll cur,int use,ll &an){
    if(cur>n){
        return;
    }
    if (use==0b111){
        an++;
    }
    //cur=357,537,753,3357,3537,3753,...
    //cur>=nでストップ,
    dfs(10 * cur + 7, use | 0b001, an);
    dfs(10 * cur + 5, use | 0b010, an);
    dfs(10 * cur + 3, use | 0b100, an);
}

int main() {
    cin >> n;
    ll ans=0;
    dfs(0, 0,ans);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>


int main() {
  int notice_num;
  int building, floor, room, persons;
  std::string building_deli = "####################";
  char deli = ' ';
  int tenants[4][3][10] = {0};

  std::cin >> notice_num;
  for (int i = 0; i < notice_num; i ++) {
    std::cin >> building >> floor >> room >> persons;
    tenants[building - 1][floor - 1][room - 1] += persons;
  }

  for (int i = 0; i < 4; i ++) {
    for (int j = 0; j < 3; j ++) {
      for (int k = 0; k < 10; k ++) {
        std::cout << deli << tenants[i][j][k];
      }
      std::cout << std::endl;
    }
    if (i != 3) {
      std::cout << building_deli << std::endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a;scanf("%d",&a);
  int L=a/100;
  int R=a%100;
  if(1<=L&&L<=12){
    if(1<=R&&R<=12)printf("AMBIGUOUS\n");
    else printf("MMYY\n");
  }else{
    if(1<=R&&R<=12)printf("YYMM\n");
    else printf("NA\n");
  }
}

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



int main(){
	int w,h,x,y;
	cin>>w>>h>>x>>y;

	double ans=(double)w*h/2;
	char ans2='0';

	if(w%2==0 && h%2==0){
		if(w/2==x && h/2==y){
			ans2='1';
		}
	}

	cout<<ans<<" "<<ans2;
}


Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
using namespace std;

int N,M;
vector<long> card;
vector<pair<int,long>> oparation;

long long int ans = 0;

bool compare_by_b(pair<int, long> a, pair<int, long> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first > b.first;
    }
}

void print_card(){
	cout << "---------" << endl;
	for(int i=0;i<N;i++){
		cout << card[i] << " ";
	}
	cout << endl;
	cout << "---------" << endl;
}

void solve(){
	sort(card.begin(),card.end());//昇順にならべかえ
	sort(oparation.begin(),oparation.end(),compare_by_b);//Cに関して降順にならべかえ
	//print_card();
	int bottom = 0;//カードの配列をindex=0から見た時どこまで書き換え済みか
	for(int i=0;i<M;i++){
		int new_number = oparation[i].second;
		int limit = oparation[i].first;
		if(bottom>=N) break;
		//cout << oparation[i].first << " " << oparation[i].second << endl;
		for(int k=bottom;k<bottom+limit;k++){
			//cout << k << " " << new_number << " " << card[k] << endl;
			if(k>=N) break;
			if(new_number>card[k]) card[k] = new_number;
			else{
				bottom = k;
				break;
			}
			if(k==bottom+limit-1){
				bottom = k+1;
				break;
			}
		}
		//print_card();
	}
	for(int i=0;i<N;i++){
		ans += card[i];
	}
}
 
int main(){
	cin >> N >> M;
	for(int i=0;i<N;i++){
		long a;
		cin >> a;
		card.push_back(a);
	}
	for(int i=0;i<M;i++){
		int b;
		long c;
		cin >> b >> c;
		oparation.push_back(make_pair(b,c));
	}
 
	solve();
 
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>a>>b;
	--a;
	--b;
	if (b%a==0) cout<<b/a;
	else cout<<b/a+1;
	return 0;
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ln             PIC X(30).
01 X              PIC 9(10).
01 Y              PIC 9(10).
01 Z              PIC 9(10).
01 ans            PIC X(30).
01 zx             PIC Z(9)9.
01 zy             PIC Z(9)9.
01 zz             PIC Z(9)9.

PROCEDURE DIVISION.
  ACCEPT ln.
  UNSTRING ln DELIMITED BY SPACE INTO X Y Z.
  MOVE X TO zx.
  MOVE Y TO zy.
  MOVE Z TO zz.
  STRING
      FUNCTION TRIM(zz)
      SPACE
      FUNCTION TRIM(zx)
      SPACE
      FUNCTION TRIM(zy)
  INTO ans.
  DISPLAY FUNCTION TRIM(ans).
  STOP RUN.


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

int main() {
  int a[5];
  for (int i = 0; i < 5; i++) {
    std::cin >> a[i];
  }
  int k;
  std::cin >> k;

  int count = 0;

  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      if (a[j] - a[i] <= k) {
        count++;
      }
    }
  }

  if (count != 10) {
    std::cout << ":(" << std::endl;
  } else {
    std::cout << "Yay!" << std::endl;
  }
  return 0;
}

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

int main(){
  
  long long a, b, c;
  cin>>a>>b>>c;
  
  cout<<min(abs(a/2*b*c-(a-a/2)*b*c),
	    min(abs(b/2*a*c-(b-b/2)*a*c),
		abs(c/2*a*b-(c-c/2)*a*b)))<<endl;
  
  return 0;
}


Measured memory_bytes: 256
// 2011/10/02 Tazoe

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

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

	for(int i=0; i<n; i++){
		string str;
		cin >> str;
		str[2] = ' ';

		istringstream is(str);
		int hh, mm;
		is >> hh >> mm;

		double L = mm*6.0;
		double S = hh*30.0+mm/2.0;

		if(L<S){
			double tmp = L;
			L = S;
			S = tmp;
		}

		double A;
		if(L-S>180.0)
			A = (S+360.0)-L;
		else
			A = L-S;

		if(A>=0.0&&A<30)
			cout << "alert" << endl;
		else if(A>=90.0&&A<=180.0)
			cout << "safe" << endl;
		else
			cout << "warning" << endl;
	}

	return 0;
}

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

typedef struct {
  int tnum;
  int num;
  int pen;
  int wro[15];
} rec;

int t, p, r;
string s;

bool asc(const rec l, const rec r) {
  if(l.num > r.num)
    return 1;
  else if(l.num == r.num && l.pen < r.pen)
    return 1; /*if(l.pen < r.pen)
return 1;
else if(l.pen == r.pen && l.tnum < r.tnum)
return 1;*/
  else if(l.num == r.num && l.pen == r.pen && l.tnum < r.tnum)
    return 1;

  else
    return 0;
}

int main() {
  int i, j, ti, pi, time;
  rec dummy;
  dummy.tnum = 0;
  dummy.num = 0;
  dummy.pen = 0;
  for(i = 0; i < 15; ++i) dummy.wro[i] = 0;
  while(1) {
    cin >> t >> p >> r;
    if(t + p + r == 0) break;
    vector<rec> memo;
    for(i = 0; i < t; ++i) {
      memo.push_back(dummy);
      memo[i].tnum = i + 1;
    }
    for(i = 0; i < r; ++i) {
      cin >> ti >> pi >> time >> s;
      if(s == "CORRECT" && memo[ti - 1].wro[pi] != -1) {
        ++memo[ti - 1].num;
        memo[ti - 1].pen += memo[ti - 1].wro[pi] * 1200 + time;
      }
      else
        ++memo[ti - 1].wro[pi];
    }
    /*for(i = 0; i < memo.size(); ++i)
      cout << memo[i].tnum << " " << memo[i].num << " " << memo[i].pen << " "
           << endl;*/

    sort(memo.begin(), memo.end(), asc);
    for(i = 0; i < memo.size(); ++i)
      cout << memo[i].tnum << " " << memo[i].num << " " << memo[i].pen << endl;
  }
  return 0;
}



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

int main()
{
	ll N;
	scanf("%d",&N);
	printf("%ld\n",((1+N)*N)/2);
	return 0;
}


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

int main()
{
	int r;
	cin>>r;
	if(r<1200)
	{
		cout<<"ABC";
	}
	else if(r<2800)
	{
		cout<<"ARC";
	}
	else
		cout<<"AGC";

	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;

using namespace std;

int main() {
	//#define int ll
	cin.tie(0); ios::sync_with_stdio(false);

	string s; cin >> s;

	int cl = 0;
	int fl = 0;
	for (int i = 0; i < s.size(); i++) {
		for (int j = i + 1; j < s.size(); j++) {
			if (i < j && s[i] == 'C' && s[j] == 'F') {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}	



Measured memory_bytes: 256
sx, sy, tx, ty = gets.split.map(&:to_i)
s = ''
(ty - sy).times do
  s << 'U'
end
(tx - sx).times do
  s << 'R'
end
(ty - sy).times do
  s << 'D'
end
(tx - sx).times do
  s << 'L'
end
s << 'L'
(ty - sy + 1).times do
  s << 'U'
end
(tx - sx + 1).times do
  s << 'R'
end
s << 'DR'
(ty - sy + 1).times do
  s << 'D'
end
(tx - sx + 1).times do
  s << 'L'
end
s << 'U'
puts s

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

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> l(m,0);
    for (int i = 0; i < m; i++)
    {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++)
        {
            int s;
            cin >> s;
            s--;
            l[i] |= (1 << s);
        }
    }
    vector<int> p(m);
    for (int i = 0; i < m; i++)
    {
        cin >> p[i];
    }
    int ans = 0;
    for (int bit = 0; bit < (1 << n); bit++)
    {
        //全探索
        bool flag = true;
        for (int i = 0; i < m; i++)
        {
            int cnt = 0;
            cnt = __builtin_popcount(bit&l[i]);

            if(cnt%2 == p[i])
            {
                //ok
                
            }
            else
            {
                //ng
                flag = false;
                break;
            }
        }    
        if(flag)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <math.h>
using namespace std;

int main(){

    int D, N;

    cin >> D >> N;

    int S = 1; for (int i = 0; i < D; i++) S *= 100;

    if (N < 100) {
        cout << S * N << endl;
    }
    else if (N == 100){
        cout << S * (N+1) << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    bool isreverse = false;
    string S1, S2;
    while(Q--)
    {
        int Ti;
        cin >> Ti;
        if(Ti == 1)
        {
            if(isreverse) isreverse = false;
            else isreverse = true;
        }
        else if(Ti == 2)
        {
            int Fi;
            char Ci;
            cin >> Fi >> Ci;
            if(isreverse){
                if(Fi == 1) S2 += Ci;
                else S1 += Ci;
            }
            else{
                if(Fi == 1) S1 += Ci;
                else S2 += Ci;
            }
        }
    }
    if(isreverse)
    {
        reverse(S.begin(), S.end());
        reverse(S2.begin(), S2.end());
        cout << S2 + S + S1 << endl;
    }
    else
    {
        reverse(S1.begin(), S1.end());
        cout << S1 + S + S2 << endl;
    }
}


Measured memory_bytes: 1348
import math
import itertools
N=int(input())
kai=math.factorial(N)
li=[list(map(int,input().split())) for _ in range(N)]
a=0
for v in itertools.permutations(li,2):
    x=(v[0][0]-v[1][0])**2
    y=(v[0][1]-v[1][1])**2
    a+=math.sqrt(x+y)
print(a/N)
  
  


Measured memory_bytes: 3060
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int a = 0, b = 0;
	scanf("%d %d", &a, &b);
	if ((a*b) & 1) {
		printf("Odd\n");
	} else {
		printf("Even\n");
	}
    return 0;
}


Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const double PI=3.14159265358979323846;
const in MOD = 998244353;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};
using T=tuple<int,int,int>;

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

    int n,q;
    cin>>n>>q;
    vector<P> cng(q);
    vector<int> num(q);
    rep(i,q){
        cin>>cng[i].first>>cng[i].second>>num[i];
        cng[i].first--;
        cng[i].second--;
    }

    set<T> a;
    a.emplace(n-1,0,1);
    int x=0,y,z;

    using mint=modint998244353;
    vector<mint> mo(n,0);
    mint ten=1;
    mo[n-1]=1;
    for(int i=n-2;i>=0;i--){
        ten *= 10;
        mo[i]=mo[i+1]+ten;
    }
    mo.emplace_back(0);

    mint sum=mo[0];
    int s,t,u;
    T w;
    auto v=a.lower_bound(T(x,0,0));

    rep(i,q){
        tie(x,y)=cng[i];
        z=num[i];

        v=a.lower_bound(T(x,0,0));
        if(v==a.end()){
            t=inf;
        }
        else{
            w=*v;
            tie(s,t,u)=(w); 
        }

        while(y>=t){
            
            if(y>=s){
                a.erase(v);
                if(t>=x) sum -= u*(mo[t]-mo[s+1]);
                if(t<x){
                    a.emplace(x-1,t,u);
                    sum -= u*(mo[x]-mo[s+1]);
                }
            }
            else{
                a.erase(v);
                a.emplace(s,y+1,u);
                if(t>=x) sum -= u*(mo[t]-mo[y+1]);
                if(t<x){
                    sum -= u*(mo[x]-mo[y+1]);
                    a.emplace(x-1,t,u);
                }
            }
            v=a.lower_bound(T(x,0,0));
            if(v==a.end()){break;}
            else{
                w=*v;
                tie(s,t,u)=(w);
            }
        }

        a.emplace(y,x,z);
        sum += z*(mo[x]-mo[y+1]);
        int out=sum.val();
        cout<<out<<endl;
    }
}/*
./problem.exe
*/

Measured memory_bytes: 18960
n,m = map(int,input().split())
switch = [(i+1) for i in range(n)]
ks = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))
pattern = [bin(i)[2:].zfill(n) for i in range(2**n)]

ans = 0

for i in pattern:
    on = []
    light = 0
    for j in range(n):
        if i[j] == '1':
            on.append(switch[j])
    for k in range(m):
        count = 0
        for l in range(1,ks[k][0]+1):
            if ks[k][l] in on:
                count += 1
        if count % 2 == p[k]:
            light += 1
    if light == m:
        ans += 1
            
print(ans)

Measured memory_bytes: 3188
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 1000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int a, b; cin >> a >> b;
  if(a <= 5) cout << 0 << endl;
  else if(a < 13) cout << b/2 << endl;
  else cout << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    int s,n,m;cin>>s;
    vint d(1101010, 0);
    int cou = 1;
    while(1){
        if(d[s] == 1){
            cout << cou << endl;
            return 0;
        }
        d[s] = 1;
        if(s%2==0)s/=2;
        else s = 3*s+1;
        
        cou++;
    }
    return 0;
}


Measured memory_bytes: 4608
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (long long i = (a); i < (n); i++)
#define REP(i, n) for(long long i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
using namespace std;
typedef long long ll;

long long gcd(long long a, long long b)
{
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}

	return b ? gcd(b, a % b) : a;
}

long long lcm(long long a, long long b)
{
	return a * b / gcd(a, b);
}

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

	int A, B;
	cin >> A >> B;

	cout << lcm(A, B) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll A,B,K;
	while(cin>>A>>B>>K) {
		VI cs;
		RANGE(i, 1, min(A, B)+1) {
			if(A%i==0 && B%i==0) cs.PB(i);
		}
		cout<<cs[cs.size()-K]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
  int N, M;
  std::cin >> N >> M;
  std::vector<int> A(N);
  for(int i = 0; i < N; ++i){
    std::cin >> A[i];
  }
  std::sort(A.begin(), A.end(), [](int a, int b){return a>=b;});
  int sum = 0;
  for(int i = 0; i < N; ++i){
    sum += A[i];
  }
  for(int i = 0; i < M; ++i){
    if(A[i] < ((sum+4*M-1)/(4*M))){
      std::cout << "No" << std::endl;
      return 0;
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}

Measured memory_bytes: 256
/*
Author: Babin Dutta
*/
 
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define inf 1e18
#define mm 998244353
 
ll power(ll x, ll y, ll p)
{
    ll res = 1;  
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; 
        x = (x*x) % p;  
    }
    return res;
}
ll modInverse(ll A,ll M)
{
    return power(A,M-2,M);
}

vector<ll> a(1,0), b(1,0);

int find(ll sum){
	int low = 0, high = b.size() - 1;
	int mid, ans = 0;
	while(low <= high){
		mid = low + (high-low)/2;
		if(b[mid] <= sum){
			ans = mid;
			low = mid+1;
		}
		else high = mid-1;
	}
	return ans;
}

int find1(ll sum){
	int low = 0, high = a.size() - 1;
	int mid, ans = 0;
	while(low <= high){
		mid = low + (high-low)/2;
		if(a[mid] <= sum){
			ans = mid;
			low = mid+1;
		}
		else high = mid-1;
	}
	return ans;
}

void solve(){
    int n,m; cin>>n>>m;
    ll sum; cin>>sum;
    ll r;
    for(int i=1;i<=n;i++){
    	cin>>r;
    	a.pb(r);
	}
    for(int i=1;i<=m;i++){
    	cin>>r;
    	b.pb(r);
	}
    for(int i=2;i<=n;i++) a[i] += a[i-1];
    for(int i=2;i<=m;i++) b[i] += b[i-1];
    int ans = 0;
    for(int i=0;i<=n;i++){
    	if(a[i] > sum) break;
    	int j = find(sum - a[i]);
    	ans = max(ans, i+j);
	}
	cout<<ans<<endl;
}
 
int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}
void _main();
int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); return 0;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

void _main(){
  string s; cin >> s ;
  int x,y; cin >> x >> y ;
  vvi dxy(2);
  int now = 0;
  dxy[0].pb(0);
  rep(i,s.size()){
    if(s[i]=='T'){
      now ^= 1;
      dxy[now].pb(0);
    }else{
      dxy[now].back()++;
    }
  }
  bitset<16004> dp1,dp2;
  dp1[8000+dxy[0][0]] = 1;
  dp2[8000] = 1;
  rep(i,dxy[0].size()){
    if(i==0) continue;
    dp1 = (dp1<<dxy[0][i]) | (dp1>>dxy[0][i]);
  }
  rep(i,dxy[1].size()) dp2 = (dp2<<dxy[1][i]) | (dp2>>dxy[1][i]);
  cout << (dp1[8000+x]==1 && dp2[8000+y]==1 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

#define FOR(i, j, k) for(int i=j ; i<k ; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    int N, M; cin >> N >> M;
    vi A(N + 1, 0);
    REP(i, N) {
        cin >> A[i + 1];
        A[i + 1] %= M;
        A[i + 1] = (A[i + 1] + A[i]) % M;
    }

    ll ans = 0;
    map<int, int> m;
    m[0] = 1;
    for (int i = N; i > 0; i--) {
        ans += m[A[i]]++;
        // cout << i << " " << A[i - 1] << " " << ans << endl;
    }

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


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define ll long long
#define ld long double
ld tot = 0;
using namespace std;
ld dp[305][305][305];
ld sushi(int t,int s,int o){
	if(t == 0 && s == 0 && o ==0){
		return 0;
	}
	else if(t < 0 || s < 0 || o < 0){
		return 0;
	}
	if(dp[t][s][o] != -1){
		return dp[t][s][o];
	}

	return dp[t][s][o] = (tot / (1.0 * (t + s + o))) * ((t / (1.0 * tot)) * sushi(t-1,s+1,o) + (s / (1.0 * tot)) * sushi(t,s-1,o+1) + (o / (1.0 * tot)) * sushi(t,s,o-1) + 1.0);
}

int main(){
	int n;
	cin>>n;
	int t = 0,s = 0,o = 0;
	for(int i=1;i<=n;i++){
		int a;
		cin>>a;
		if(a == 3){
			t++;
		}
		else if(a == 2){
			s++;
		}
		else{
			o++;
		}
	}
	for(int i=0;i<305;i++)
		for(int j=0;j<305;j++)
			for(int k=0;k<305;k++)
				dp[i][j][k] = -1;
	tot = t + s + o;
	cout<<setprecision(13)<<sushi(t,s,o)<<endl;
}

Measured memory_bytes: 443648
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main() {
	
	int n;
	cin >> n;
	int ans = 0;
	REP(i, n) {
		int a, b;
		cin >> a >> b;
		ans += b - a + 1;
	}

	ANS(ans);

	return 0;
}



Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
N = int(input())
count = 0

for i in range (a+1):
    for j in range (b+1):
        for k in range (c+1):
            if i*500 + j*100 + k*50 == N:
                count += 1
                #print("{} = 500:{} 100:{} 50:{}".format(N, i, j, k))
                

print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
int saiki(int a, int b);
char  mas[8][8];
int main(){
  int a,b,c,i,j,n;
  cin >> n;
  for(c=1;c<=n;c++){
    for(i=0;i<8;i++){
      for(j=0;j<8;j++){
	cin >> mas[i][j];   
      }
    }
    cin >> a >> b;
    saiki(b-1,a-1);
    cout << "Data " << c << ':' << endl;
    for(i=0;i<8;i++){
      for(j=0;j<8;j++){
	cout << mas[i][j];
      }
      cout << endl;
    }
  }
}

int saiki(int a,int b){
  int t,r,i,j;
  mas[a][b]='0';
  for(i=-3;i<=3;i++){
    if(mas[a+i][b]=='1' && a+i<=7 && a+i>=0){
      saiki(a+i,b);
    }
    if(mas[a][b+i]=='1' && b+i<=7 && b+i>=0){
      saiki(a,b+i);
    }
  }
}

Measured memory_bytes: 1164
import sys
import numpy as np

ri = lambda: int(sys.stdin.readline())
rl = lambda: list(map(int, sys.stdin.readline().split()))

D = ri()
c = np.array(rl())
s = np.array([np.array(rl()) for _ in range(D)])
li = np.zeros(26)
li_one = np.ones(26)
c_sum = sum(c)
for lis in s:
  idx_list = np.argsort(lis/c)[:-21:-1]
  li += li_one
  max_idx = 0
  max_score = -10**10
  for i in idx_list:
    tmp = li
    li[i] = 0
    sum_c_li = np.sum(c*li)
    score = lis[i] - sum_c_li
    if score >= max_score:
      max_idx = i
      max_score = score
    li = tmp
  print(max_idx + 1)


  

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

using namespace std;
int dp[3003][3003];
int main() {
  string s, t;
  getline(cin, s);
  getline(cin, t);

  for (int i = 0; i < (int)s.size(); ++i) {
    for (int j = 0; j < (int)t.size(); ++j) {
      if (s[i] == t[j]) {
	dp[i + 1][j + 1] = dp[i][j] + 1;
      } else {
	dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
      }
    }
  }
  
  int i = (int)s.size(), j = (int)t.size();
  string ans;
  while (i > 0 && j > 0) {
    if (dp[i][j] == dp[i - 1][j]) {
      --i;
    } else if (dp[i][j] == dp[i][j - 1]) {
      --j;
    } else {
      ans = s[i -1] + ans;
      --i; --j;
    }
  }
 
  printf("%s\n", ans.c_str());
  return 0;
}



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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
#define tc ll t; cin >> t; while (t--)
#define sz(c) (ll) (c).size()
#define trav(x,c) for(auto &x : c)
#define all(c) (c).begin(), (c).end()
#define rll(c) (c).rbegin(), (c).rend()
#define _for(i,a,n) for(ll i = a ; i < n; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) trav(x,c) cout << x << " "; cout << endl;
#define godspeed ios::sync_with_stdio(0); cin.tie(0);

vector<pair<ll,ll>> mp;
int main() {
    godspeed;
    ll n, m; cin >> n >> m;
    mp.resize(n+1);

    string ac = "AC", wa = "WA";

    ll q; string s;
    while(m--) {
        cin >> q >> s;
        if(mp[q].f) continue;
        if(s == wa) mp[q].s++;
        if(s == ac) mp[q].f = 1;
    }

    ll a = 0, b = 0;
    trav(x,mp) {
        if(x.f) a++, b+= x.s; 
    }

    cout << a <<  " " << b;
}

Measured memory_bytes: 4764
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;


class UF
{
private:
    long         num;
    vector<long> par;
    vector<long> rank;
public:
    vector<long> sz;
public:
    UF(long n): num(n) {
        par.resize(n);
        rank.resize(n);
        sz.resize(n);
        long i;
        for(i=0; i<n; i++) {
            par[i]=i;  rank[i]=1; sz[i]=1;
        }
    }
	
    long find(long x) {
        if(x==par[x]) return x;
        return par[x] = find(par[x]);
    }

    void unite(long x, long y) {
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]) {
            par[x]=y;
            sz[y]=sz[x]+sz[y];
        }
        else {
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
            sz[x]=sz[x]+sz[y];
        }
    }

    bool same(long x, long y) {
        return find(x)==find(y);
    }

    long ngroup( vector<long>& size ) {
        long count=0;
        long i;
        for(i=0; i<num; i++) {
            if(par[i]==i) {
                size.push_back(sz[i]);
                count++;
            }
        }
        return count;
    }
};

int main(int argc, char* argv[])
{
    long n,m;
    scanf("%ld%ld", &n, &m);

    vector<long> a(m);
    vector<long> b(m);
    long i;
    for(i=0; i<m; i++) {
        scanf("%ld%ld", &a[i], &b[i]);
    }

    UF uf(n);
    vector<ll> ans(m+1);
    ll total = (ll)n*(n-1)/2;
    ans[m]=total;
    for(i=m-1; i>0; i--) {
        ans[i]=ans[i+1];
        if(uf.find(a[i]-1)!=uf.find(b[i]-1)) {
            ans[i]=ans[i+1]-uf.sz[uf.find(a[i]-1)]*uf.sz[uf.find(b[i]-1)];
        }
        uf.unite(a[i]-1, b[i]-1);
    }

    for(i=1; i<=m; i++) {
        printf("%lld\n", ans[i]);
    }
    return 0;
}



Measured memory_bytes: 6016
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

template<typename T>
void cout_mat(vector<vector<T>  > &mat){
    for(int i=0; i<mat.size(); i++){
        vector<T> vec = mat[i];
        cout_vec(mat[i]);
    }
}

int N;
long long calc(vector<long long> &A1, vector<long long> &A2){
    vector<vector<long long> > dp(4,vector<long long>(N+1,0));
    dp[0][N]=N;

    for(ll i=0; i<3; i++){
        for(ll j=0; j<=N; j++){
            for(ll k=0; k<=j; k++){
                dp[i+1][j-k]=max(dp[i+1][j-k], dp[i][j]+k/A1[i]*A2[i]-k);
            }
        }
    }
    ll ans=0;
    for(int i=0; i<=N; i++){
        ans=max(ans, dp[3][i]);
    }
    //cout_mat(dp);
    return ans;
}

ll calc2(vector<ll> &A1, vector<ll> &A2){
    ll ans=0;
    for(int i=0; i<3; i++){
        if(A1[i]<A2[i]){
            N=N/A1[i]*A2[i]+N%A1[i];
        }
    }
    //cout << N << endl;;
    ans=N;
    for(int i=0; i<=N; i++){
        ll tmp=0;
        ll rest=i;
        for(int j=0; j<3; j++){
            if(A1[j]>A2[j]){
                tmp+=rest/A2[j]*A1[j]+rest%A2[j];
                rest=N-i;
            }
        }
        //cout << i << ' ' << tmp << endl;
        ans=max(ans,tmp);
    }
    return ans;
}

ll calc3(vector<ll> &A1, vector<ll> &A2){
    ll ans=0;
    for(int i=0; i<=N; i++){
        ll tmp=0;
        ll rest=i;
        for(int j=0; j<3; j++){
            if(A1[j]<A2[j]){
                tmp+=rest/A1[j]*A2[j]+rest%A1[j];
                rest=N-i;
            }
        }
        //cout << i << ' ' << tmp << endl;
        ans=max(ans,tmp);
    }
    //cout << ans << endl;
    ll tmp=ans;
    for(int i=0; i<3; i++){
        if(A1[i]>A2[i]){
            ans=max(ans,tmp/A2[i]*A1[i]+tmp%A2[i]);
        }
    }
    return ans;
}

int main(){
    cin >> N;
    vector<vector<long long> > gsb(2,vector<long long>(3,0));
    for(auto &ab: gsb){
        for(auto &x:ab){
            cin >> x;
        }
    }

    int cnt=0;
    for(int i=0; i<3; i++){
        if(gsb[0][i]<gsb[1][i]){
            cnt++;
        }
    }
    //cout << cnt << endl;

    ll ans=0;
    if(cnt==3){
        ans=calc(gsb[0], gsb[1]);
    }else if(cnt==0){
        ans=calc(gsb[1], gsb[0]);
    }else if(cnt==1){
        ans=calc2(gsb[0],gsb[1]);
    }else if(cnt==2){
        ans=calc3(gsb[0],gsb[1]);
    }
    cout << ans << endl;
}

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

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


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

typedef long long ll;


#define all(c) (c).begin(),(c).end()
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,a,q) for(int i = a; q > i; i++)
#define pb push_back
#define MAX 1000000000
#define mod 1000000007
/*
確認ポイント
to_string() はC++11以降の実装;
length(),size()に括弧をつけ忘れてないか;
大文字小文字間違えてないか
*/
int main() { 
    int N,M,X,Y;
    cin >> N >> M >> X >> Y;
    vector<int> x;
    int tm;
    loop(N){
      cin >> tm;
      x.pb(tm);
    }
    vector<int> y;
    loop(M){
      cin >> tm;
      y.pb(tm);
    }
    sort(all(x));sort(all(y));

    if(x[N-1] < y[0]){
      if(y[0] > X && x[N-1] < Y){
        cout << "No War" << endl;
      } else {
        cout << "War" << endl;
      }
    } else {
      cout << "War" << endl;
    }
    return 0; 
} 

Measured memory_bytes: 256