akhauriyash/Code-Regression huggingface dataset:
h, w = map(int, input().split())
table = [list(input()) for _ in range(h)]
visited = [["." for _ in range(w)] for _ in range(h)]

mx = [0, 1, 0, -1]
my = [1, 0, -1, 0]
for i in range(h):
  for  j in range(w):
    if table[i][j] == "#":
      for k in range(4):
        tx, ty = j + mx[k], i + my[k]
        if 0 <= tx < w and 0 <= ty < h and table[ty][tx] == "#":
          visited[i][j] = visited[ty][tx] = "#"

for i in range(h):
  for  j in range(w):
    if table[i][j] != visited[i][j]:
      print("No")
      exit(0)
print("Yes")

Measured memory_bytes: 3064
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner stdin = new Scanner(System.in);

		int redHat = 0;

		int N = stdin.nextInt();
		stdin.nextLine();
		String s = stdin.nextLine();

		for(int i = 0; i < s.length(); i++){
			if(s.charAt(i) == 'R')
				redHat++;
		}

		if(redHat > N-redHat){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


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

int main() {
  int n;
  cin>>n;
  vector<int>t(n),x(n),y(n);
  for(int i=0;i<n;i++)cin>>t[i]>>x[i]>>y[i];
  int tmp_t=0;
  int tmp_x=0;
  int tmp_y=0;
  for(int i=0;i<n;i++){  
    if(t[i]-tmp_t<abs(x[i]+y[i]-tmp_x-tmp_y)){
      cout<<"No"<<endl;
      return 0;
    }
    if((t[i]-x[i]-y[i])%2==1){
      cout<<"No"<<endl;
      return 0;
    }
    tmp_t=t[i];
    tmp_x=x[i];
    tmp_y=y[i];
  }
  cout<<"Yes"<<endl;
  return 0;
}

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

int main(){
  int a, b, c, count = 1;
  cin >> a >> b >> c;
  if(a == b && b == c){  
  }
  else if((a == b && b != c) || (a != b && b == c) || (a == c && b != c)){
    count++;
  }
  else if(a != b && b != c && c != a){
    count++;
    count++;
  }
  
  cout << count << endl;
}


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

int main() {
  int n;
  string s;
  int ans = 1;
  cin >> n >>  s;

  for (int i = 0;i + 1<s.size();i++) {
    if(s[i] != s[i+1]) ans++;
  }

  cout << ans << endl;

  return 0;
 }


Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
int main() {
	string S;
	int N;
	int max = 0;

	cin >> N >> S;

	for (int n = 1;n < N;n++) {
		int t1[26] = {0};
		int t2[26] = { 0 };
		int cnt = 0;
		for (int i = 0; i <= n; i++)
		{
			t1[S[i] - 'a']++;
		}
		for (int i = n+1; i < N; i++)
		{
			t2[S[i] - 'a']++;
		}
		for (int i = 0; i < 26; i++)
		{
			if (t1[i] != 0 && t2[i] != 0)
				cnt++;
		}
		if (max < cnt)
			max = cnt;
	}

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
import itertools
h,w,k = map(int, input().split())
c = []
for i in range(h):
    a = input()
    for j in range(w):
        if a[j] == '#':
            c.append((i,j))

ans = 0

sel = ['h'+str(i) for i in range(h)]
sel += ['w'+str(i) for i in range(w)]
for m in range(h+w):
    for v in  itertools.combinations(sel,m):
        count = [1 for kk in range(len(c))]
        for vv in v:
            if vv[0]=='h':
                for e,(i,j) in enumerate(c):
                    if i == int(vv[1]):
                        count[e] = 0
            if vv[0]=='w':
                for e,(i,j) in enumerate(c):
                    if j == int(vv[1]):
                        count[e] = 0
        if sum(count) == k:
            ans += 1


print(ans)

Measured memory_bytes: 9128
/*
g++ -std=c++11 -o2 -Wall ABC105A.cpp -o ./out/ABC105A.out
./out/ABC105A.out
*/

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

typedef long long ll;

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  int ans = n % k;
  cout << min(ans, 1) << "\n";
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    int x[5];
    int select;
    for(int i=0;i<5;i++){
        cin >> x[i];
    }
    for(int i=0;i<5;i++){
        if(x[i] == 0)select = i + 1;
    }
    cout << select;

    
    return 0;
    
}

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

if n < 3:
    print(0)
    exit()

L = sorted([int(x) for x in input().split()])

count = 0

for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if L[i] != L[j] and L[j] != L[k] and L[i] != L[k] and L[i] + L[j] > L[k]:
                count += 1

print(count)


Measured memory_bytes: 9036
#include <cstdio>

int main()
{
	int h,n,sum=0; scanf("%d%d",&h,&n);
	for(int i=1; i<=n; i++)
	{
		int x; scanf("%d",&x); sum+=x;
	}
	if(sum>=h) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1000000000;

int main() {
    ll N;
    cin >> N;
    vector<ll>A(N);
    for (int i=0; i<N; i++)cin >> A[i];
    for (int i=0; i<N; i++){
        if (A[i] == 0){
            cout << 0 << endl;
            exit(0);
        }
    }

    ll ans = 1;
    for (int i=0; i<N; i++){
        ll emer = INF*INF / ans + 1;
        ans *= A[i];
        if (ans > INF*INF || A[i] > emer){
            cout << -1 << endl;
            exit(0);
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 4408
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll X, Y;

int main() {
	cin >> X >> Y;
	if (abs(X - Y) <= 1)cout << "Brown" << endl;
	else cout << "Alice" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S,T;
  cin >> S >> T;
  int a=0,b;
  b=S.size();
  for(int i=0;i<b;i++){
   if(S.at(i)==T.at(i))
   {
   }
    else{
    a=1;
    }
  }
  if(a==0){
   cout << "Yes" << endl;
  }
  else{
   cout << "No" << endl;
  }
  
  
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;


int32_t main(){
	ios::sync_with_stdio(false);
    int x, y;
    cin>>x>>y;
    if(abs(x-y)<=1){
        cout<<"Brown\n";
    }
    else{
        cout<<"Alice\n";
    }



	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

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;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  string s;
  cin>>n>>s;
  if(n%2==0){
	  string a,b;
	  rep(i,n/2){
		  a.push_back(s[i]);
	  }
	  FOR(i,n/2,n){
		  b.push_back(s[i]);
	  }
	  if(a==b){
		  cout<<"Yes"<<endl;
		  return 0;
	  }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <vector>

#define REP(a, b) for (int a = 0; a < b; a++)
#define FORU(a, b, c) for (int a = b; a <= c; a++)
#define FORD(a, b, c) for (int a = b; a >= c; a--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;

int main() {
	int N;
	long long K, bil[100005];

	scanf("%d %lldd", &N, &K);

	REP(i, N) {
		scanf("%lld", &bil[i]);
	}

	int maks = 0;

	while (K >= (1LL << maks)) {
		++maks;
	}

	if (K != 0LL)
		--maks;

	long long curr = 0LL;

	FORD(i, maks, 0) {
		long long two = 1LL << i;
		int cnt = 0;

		REP(j, N) {
			if (bil[j] & two) {
				++cnt;
			}
		}

		if (cnt < (N - cnt)) {
			if ((curr | two) <= K) {
				curr |= two;
			}
		}
	}

	long long ans = 0;

	REP(i, N) {
		ans += bil[i] ^ curr;
	}

	printf("%lld\n", ans);

	return 0;	
}


Measured memory_bytes: 896
#include <stdio.h>

int main(void)
{
	int i,n;
	int num[40];
	int check[40];
	for(i=0;i<40;i++){
		check[i]=0;
	}
	for(i=0;i<28;i++){
		scanf("%d",&num[i]);
		n=num[i];
		check[n-1]=1;
	}
	for(i=0;i<30;i++){
		if(check[i]==0){
			printf("%d\n",i+1);
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main(){long n;unsigned long long z=0;cin>>n;
     vector<long>s(n+1,0);for(long i=1;i<n+1;i++)
     {long j=i;while(j<=n){s.at(j)+=1;j+=i;}}
for(long i=1;i<n+1;i++)z+=i*s.at(i);
           cout<<z<<endl;}

Measured memory_bytes: 81328
import sys
import itertools
read = sys.stdin.buffer.read #全てまとめて文字列として格納
readline = sys.stdin.buffer.readline # 一行読む
readlines = sys.stdin.buffer.readlines # 全行リストに格納

H,N = map(int, readline().split())
A = list(map(int, readline().split()))

if sum(A) >= H:
  print('Yes')
  exit()
else:
  print('No')
  exit()

Measured memory_bytes: 12488
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var hwk = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
            var h = hwk[0];
            var w = hwk[1];
            var k = hwk[2];

            var board = new char[h, w];

            for (var i = 0; i < h; i++)
            {
                var line = Console.ReadLine().ToArray();
                for (var j = 0; j < w; j++)
                {
                    board[i, j] = line[j];
                }
            }

            var deletedRowsSet = new List<HashSet<int>>();
            DigRows(0, new HashSet<int>());
            var result = 0;
            deletedRowsSet.ForEach(rowSet => DigColumns(0, rowSet, new HashSet<int>()));

            Console.WriteLine(result);

            void DigColumns(int current, HashSet<int> deletedRows, HashSet<int> deletedColumns)
            {
                if (current == w)
                {
                    if (SearchBlacks(deletedRows, deletedColumns) == k) result++;
                    return;
                }
                DigColumns(current + 1, deletedRows, deletedColumns.ToHashSet());
                deletedColumns.Add(current);
                DigColumns(current + 1, deletedRows, deletedColumns.ToHashSet());
            }

            void DigRows(int current, HashSet<int> deletedRows)
            {

                if (current == h)
                {
                    if (SearchBlacks(deletedRows, new HashSet<int>()) >= k)
                        deletedRowsSet.Add(deletedRows);

                    return;
                }

                DigRows(current + 1, deletedRows.ToHashSet());
                deletedRows.Add(current);
                DigRows(current + 1, deletedRows.ToHashSet());
            }

            int SearchBlacks(HashSet<int> rows, HashSet<int> columns)
            {
                var result = 0;
                for (var i = 0; i < h; i++)
                {
                    if (!rows.Contains(i))
                    {
                        for (var j = 0; j < w; j++)
                        {
                            if (!columns.Contains(j) && board[i, j] == '#') result++;
                        }
                    }
                }
                return result;
            }
        }
    }
}

Measured memory_bytes: 29720
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  priority_queue<pair<int, int>> pq;
  int n, m;
  cin >> n >> m;
  for(int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    pq.emplace(-a, b);
  }
  ll ans = 0;
  while(pq.size()) {
    int a, b;
    tie(a, b) = pq.top();
    a *= -1;
    pq.pop();
    int use = min(m, b);
    b -= use;
    m -= use;
    ans += (ll) use * a;
    if(m == 0) break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1400
object Main extends App {
  import scala.io.StdIn.readLine
  val Array(a, b, c) = readLine().split(' ').map(_.toInt)
  val Array(k) = readLine().split(' ').map(_.toInt)

  val values = (0 until k).foldLeft(Array(a,b,c)) { case (values, _ ) =>
    val (maximum, maximumIdx) = values.zipWithIndex.maxBy(_._1)
    values.update(maximumIdx, maximum * 2)
    values
  }

  println(values.sum)
}


Measured memory_bytes: 54860
N = int(input())
ans = 0
lst = list(map(int, input().split()))
slice_lst = lst[:int(N / 2)]
for i,k in enumerate(reversed(slice_lst)):
  sub_lst = lst[len(slice_lst)-i-1:len(lst):len(slice_lst)-i]
  if (k != sum(sub_lst) % 2):
    if (k == 0):
      lst[len(slice_lst)-i-1] = 1
    else:
      lst[len(slice_lst)-i-1] = 0

if (ans == -1):
  print(ans)
else:
  ans_lst = []
  for i,k in enumerate(lst):
    if (k == 1):
      ans_lst.append(str(i+1))
  print(len(ans_lst))
  result = ' '.join(ans_lst)
  print(result)

Measured memory_bytes: 18740
#include<stdio.h>
int main(){
    int a,b,c;
    int i,n;
    scanf("%d%d%d",&a,&b,&c);
    for(i=a;i<=b;i++){
        if(c%i == 0) n++;
    }
    printf("%d\n",n);
    return 0;
}


Measured memory_bytes: 2148
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		scan.close();
		int check[]=new int[s.length()];
		for(int i=0;i<s.length();i++) {
			if(s.charAt(i)=='B') {
				check[i]=-1;
				for(int j=i-1;j>=0;j--) {
					if(check[j]==0) {
						check[j]=-1;
						break;
					}
				}
			}
			else check[i]=0;
		}
		for(int i=0;i<s.length();i++) {
			if(check[i]==0)System.out.print(s.charAt(i));
		}
		System.out.println();
	}
}

Measured memory_bytes: 21844
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
//USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN THE RESPECTIVE DATA STRUCTURE
//NOTE THAT MEMSET CANNOT ASSIGN A VALUE OF 10^18 IT WILL ASSIGN A LOWER VALUE THAN THAT!!!
//NOTE THAT MEMSET CANT FILL THE DOUBLE VALUES;
//ACCUMULATE DOES NOT WORK PROPERLY IF VALUES START SUMMING BEYOND 1E9...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 2000000000000000005
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
 #define ll long long
 #define int long long

 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>

 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){int g = gcd(a, m); { return power(a, m-2, m);}}

ll dp[505][505];
bool vis[505][505];
ll n;
ll x[]={1,-1,0,0};
ll y[]={0,0,1,-1};

void dfs(ll xx,ll yy)
{
    ll z = dp[xx][yy]+vis[xx][yy];
    for(ll k=0;k<4;k++)
    {
      //  if((x[k]+xx<=n) && (x[k]+xx>0) && (y[k]+yy<=n) && (y[k]+yy>0))
        {
            if((dp[x[k]+xx][y[k]+yy]>z) )
            {
                dp[x[k]+xx][y[k]+yy]=z;
                dfs(x[k]+xx,y[k]+yy);
            }
        }
    }
    
}
void solve()
{
    cin>>n;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            dp[i][j] = min(min(j-1,n-j),min(i-1,n-i));
        }
    }
    memset(vis,true ,sizeof vis);ll ans=0;
    for(ll i=0;i<n*n;i++)
    {
        ll where;cin>>where;
        ll whx=(where+n-1)/n;
        ll why = where%n;
        if(!why)why+=n;
        ans+=dp[whx][why];
        vis[whx][why]=false;
        dfs(whx,why);
//        if(where==9)
//            cout<<dp[3][2]<<" DD"<<endl;
//        cout<<dp[whx][why]<<" "<<where<<endl;
    }
    cout<<ans<<endl;
}
signed main()
{
   
    Need_for_speed(activated);
//satisfy
//    {
//   solve();
//   }
   
    solve();
    return 0;
}


Measured memory_bytes: 20988
#include<cstdio>
#include<algorithm>
using namespace std;
struct node{long long xx1,xx2,yy1,yy2;};
node b[13001];
struct pt{long long x;int y;};
pt d[211];
int n;
long long a[211],k,s1,s2,mo,c[211],h,cnt,r,s,mi[211],v,sta,sto,ans;
bool cmp(pt aa,pt bb){return(aa.x<bb.x);}
bool cmp1(node aa,node bb){return((aa.xx1<bb.xx1)||((aa.xx1==bb.xx1)&&(aa.xx2<bb.xx2))||((aa.xx1==bb.xx1)&&(aa.xx2==bb.xx2)&&(aa.yy1>bb.yy1)));}
long long ask(long long aa,long long bb)
{
	long long tt=s,w=0;
	if(aa==-1) return(0); 
	while(tt!=0)
	{
		if(bb/tt==1)
		{
			if(aa/tt==0) return(w+1);
			else w++;
		}
		bb=bb%tt;
		aa=aa%tt;
		tt=tt/2;
	}
}
int main()
{
	scanf("%d%lld",&n,&k);
	mo=1000000007;
	h=103;
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	s1=0;
	s2=0;
	r=a[1];
	mi[0]=1;
	for(int i=1;i<=n;i++)mi[i]=(mi[i-1]*h)%mo;
	for(int i=2;i<=n;i++) 
	{
		s1=s1+a[i]-a[i-1];
		s2=(s2*k+a[i]-a[i-1])%mo;
		if(r>a[i]) r=a[i];
	}
	cnt=1;
	b[1].xx1=s1;
	b[1].xx2=(s2+mo)%mo;
	b[1].yy1=r;
	if(r>=k) b[1].yy2=k;
	else b[1].yy2=r;
	s=1;
	for(long long j=1;j<=61;j++) if(j<=k)
	{
		for(int i=1;i<=n;i++)
		{
			c[i]=(a[i]%2)*s+c[i];
			a[i]=a[i]/2;
			d[i].x=c[i];
			d[i].y=i;
		} 
		sort(d+1,d+1+n,cmp); 
		d[0].x=-1;
		s1=0;
		s2=0;
		r=a[1];
		for(int i=2;i<=n;i++)
		{
			s1=s1+a[i]-a[i-1];
			s2=(s2*h+a[i]-a[i-1])%mo;
			if(r>a[i]) r=a[i];
		}
		for(int i=1;i<=n;i++) 
		{
			if(d[i].x!=d[i-1].x)
			{
				v=j+ask(d[i-1].x,d[i].x);
				if(v<=k)
				{
					cnt++;
					b[cnt].xx1=s1;
					b[cnt].xx2=(s2+mo)%mo;
					b[cnt].yy1=r;
					if(r>=k-v) b[cnt].yy2=k-v;
					else b[cnt].yy2=r;
				}
			}
			if(a[d[i].y]==0) break;
			if(d[i].y!=1) s2=(s2-mi[n-d[i].y])%mo;
			else s1++;
			if(d[i].y!=n) s2=(s2+mi[n-d[i].y-1])%mo;
			else s1--;
			if(a[d[i].y]-1<r) r=a[d[i].y]-1;
		}
		s=s*2;
	}
	else break;
	sort(b+1,b+1+cnt,cmp1);
	sta=b[1].yy1;
	sto=sta-b[1].yy2; 
	ans=0;
	for(int i=2;i<=cnt;i++)if((b[i].xx1==b[i-1].xx1)&&(b[i].xx2==b[i-1].xx2))
	{
		if(b[i].yy1>=sto)
		{
			if(b[i].yy1-b[i].yy2<sto) sto=b[i].yy1-b[i].yy2;
		}
		else 
		{
			ans=(ans+sta-sto+1)%mo;
			sta=b[i].yy1;
			sto=sta-b[i].yy2;
		}
	}
	else
	{
		ans=(ans+sta-sto+1)%mo;
		sta=b[i].yy1;
		sto=sta-b[i].yy2;
	}
	ans=(ans+sta-sto+1)%mo;
	printf("%lld\n",ans);
} 

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int64_t MAXN = 100010;
int64_t N, A, B;
vector<int64_t> H(MAXN);

bool ok(int64_t n)
{
  int64_t a = 0;
  for (int i = 0; i < N; i++)
  {
    if (B * n >= H[i])
      continue;
    a += ((H[i] - B * n) + (A - B - 1)) / (A - B);
  }
  return a <= n;
}

int main()
{
  int64_t mx = 0;
  cin >> N >> A >> B;
  for (int i = 0; i < N; i++)
  {
    cin >> H.at(i);
    mx = max(H.at(i), mx);
  }
  int64_t l = -1, r = (mx + (B - 1)) / B;
  while (r - l > 1)
  {
    int64_t m = (r + l) / 2;
    if (ok(m))
      r = m;
    else
      l = m;
  }
  cout << r << endl;
}


Measured memory_bytes: 3856
import sys
input = sys.stdin.readline
from fractions import gcd
 
N=int(input())
a_list = list(map(int, input().split()))
MOD = 10**9+7

def cal_lcm(a, b):
  return int(a*b//gcd(a,b))
 
lcm = 1
ans = 0
for i in range(N):
  lcm_ = cal_lcm(lcm, a_list[i])
  ans = ans*(lcm_//lcm)
  ans = (ans + (lcm_//a_list[i]))
  lcm = lcm_

print(ans%MOD)

Measured memory_bytes: 6200
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

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

    for (int i=1; i<=n; i++) {
        if (m <= 0) break;
        m--;
        cout << i + (n%2==0 && n-2*i+1<=n/2) << " " << n-i+1 << endl;
    }
}

Measured memory_bytes: 3152
N = int(input())
A = list(map(int,input().split()))

A.sort(reverse = True)

Ans = []
for a in A[1:-1]:
    if a >= 0:
        Ans.append([A[-1],a])
        A[-1] -= a
    else:
        Ans.append([A[0],a])
        A[0] -= a
ans = [A[0],A[-1]]
Ans.append(ans)
print(ans[0] - ans[1])
for answ in Ans:
    print(*answ, sep = " ")

Measured memory_bytes: 24468
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

zahyo = [a,b,c,d,e]

def ite(zahyo):
    for z in zahyo:
        for z_ in zahyo:
            if z==z_ or z > z_ :
                continue
            else:
                if z_ - z > k:
                    print(":(")
                    return None
    print("Yay!")
    return None
ite(zahyo)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String [] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		double P = Math.PI;
		//???????????????
		double  radius = sc.nextDouble();
		//????????¢??? ?????????????? ???????¨???
		double area = radius * radius * P;
		//?????¨????????? ??´??????????¨???
		double circumference = (radius + radius) * P;
		//?°???°???
		String strArea = String.format("%.5f", area);
		//???????????¨???
		System.out.println(strArea +" "+ circumference);
	}
}

Measured memory_bytes: 28012
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

int cnt[10];
signed main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  int m;
  cin >> m;
  int c[m], d[m];
  for (int i = 0; i < m; i++) {
    cin >> d[i] >> c[i];
    cnt[d[i]] += c[i];
  }
  int ans = 0;
  while (true) {
    bool to_cont = false;
    for (int i = 0; i < 10; i++) {
      if (cnt[i] > 1) {
        to_cont = true;
        int t = cnt[i] / 2;
        cnt[i] -= 2 * t;
        ans += t;
        int sum = (2 * i / 10) + (2 * i % 10);
        cnt[sum] += t;
        if (i > 4) {
          ans += t;
        }
      }
    }
    if (!to_cont) break;
  }
  vector<int> v;
  for (int i = 9; i >= 0; i--) {
    if (cnt[i]) {
      v.push_back(i);
    }
  }
  while (sz(v) > 1) {
    ans++;
    int a = v.back();
    v.pop_back();
    int b = v.back();
    v.pop_back();
    int sum = a + b;
    if (sum > 9) {
      v.push_back(sum / 10);
      v.push_back(sum % 10);
    } else {
      v.push_back(sum);
    }
  }
  cout << ans << "\n";
}



Measured memory_bytes: 3328
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back


int MOD=1000000007;
int N,M;
int A[100005];int B[100005];
vector<int> date_to_in[100005];

int ans=0;


signed main(){
    scanf("%lld %lld",&N,&M);
    rep(i,N){
        scanf("%lld %lld",&A[i],&B[i]);
        date_to_in[A[i]].pb(B[i]);
    }
    priority_queue<int> que;
    for(int i=M-1;i>=0;i--){
        rep(j,date_to_in[M-i].size()){
            que.push(date_to_in[M-i][j]);
        }
        if(!que.empty()){ans+=que.top();que.pop();}
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 7168
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef float f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int powm(int a, int b, int mod) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int a[200005];
int b[200005];
void solve() {
	int n;
	cin>>n;
	fr(i,1,n)
		cin>>a[i];
	vi ans;
	for(int i=n; i>0; i--) {
		int te=a[i];
		for(int j=i; j<=n; j+=i)
			te^=b[j];
		b[i]=te;
		if(b[i])
			ans.pb(i);
	}
	cout<<sz(ans)<<endl;
	for(int i:ans)
		cout<<i<<endl;
}
 
signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	fr(i,1,t) {
		solve();
	}
#ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 5108
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
struct UnionFind {
    VI d;
    UnionFind(int n = 0): d(n,-1) {}
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x,int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};
int deg[100005];
VI to[100005];

struct mint {
  LL x; // typedef long long ll;
  mint(LL x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
    if(n == 0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2 == 1) x *= 2;
    return x;
}

mint choose(int n,int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}

int main() {
    string s;
    int k;
    cin >> k;
    cin >> s;
    if(s.length() <= k) {
      cout << s << endl;
      return 0;
    } else {
      rep(i,k) {
        cout << s[i];
      }
      cout << "..." << endl;
    }
}


Measured memory_bytes: 5972
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int64_t INF = 1LL << 60;

int main() {
 int N;
 cin>>N;
 vector<int>a(N);
 map<int,int64_t>k;
 for(int i=0;i<N;i++){
	 cin>>a[i];
	 k[a[i]]++;
 }
 map<int64_t,int64_t>d;
 int64_t sum=0;
 for(auto h:k){
	 int64_t x=h.first;
	 int64_t y=h.second;
	 d[x]=y*(y-1)/2;
	 sum+=d[x];
 }
 for(int i=0;i<N;i++){
	 k[a[i]]--;
	 int64_t t=k[a[i]]*(k[a[i]]-1)/2;
	 k[a[i]]++;
     cout<<sum-d[a[i]]+t<<endl;
 }
  return 0;
}

Measured memory_bytes: 18176
#include <iostream>
#include <string>
#include <algorithm>
 
using namespace std;
 
int main()
{
	int a, b, k;
	cin >> a >> b >> k;
 
	if (a + k > b - k) {
		for (int i = a; i <= b; i++) {
			cout << i << endl;
		}
	}
	else {
		for (int i = a; i < a + k; i++) {
			cout << i << endl;
		}
		for (int i = b - k + 1; i <= b; i++) {
			cout << i << endl;
		}
	}
 
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(ll i = a;i < b;i++)

using namespace std;

ll n,m;

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n >> m;

    ll ans = 1;

    rep(i,1,1000000)
    {
        if(i > m)
            break;

        if(m%i == 0 && m/i >= n)
        {
            ans = max(ans,i);
        }

        if(m%i == 0 && i >= n)
        {
            ans = max(ans,m/i);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

int parent[100005];
int length[100005];

void init(){
  for (int i=0; i<100005; i++){
    parent[i]=i;
    length[i]=1;
  }
  return;
}

int getroot(int n){
  while(parent[n]!=n){
    n=parent[n];
  }
  return n;
}

bool samegroup(int n, int m){
  int nroot=getroot(n);
  int mroot=getroot(m);
  return nroot==mroot;
}

bool unite(int n, int m){
  if (samegroup(n, m)){
    return false;
  } else {
    int nroot=getroot(n);
    int mroot=getroot(m);
    if (length[nroot]==length[mroot]){
      parent[nroot]=mroot;
      length[mroot]++;
    } else if (length[nroot]>length[mroot]){
      parent[mroot]=nroot;
      length[nroot]++;
    } else {
      parent[nroot]=mroot;
      length[mroot]++;
    }
    return true;
  }
}

int main(){
  int N, M;
  scanf("%d", &N);
  scanf("%d", &M);
  std::vector<int > X(M), Y(M), Z(M);
  for (int i=0; i<M; i++){
    scanf("%d", &X[i]);
    scanf("%d", &Y[i]);
    scanf("%d", &Z[i]);
    X[i]--;
    Y[i]--;
  }

  init();
  for (int i=0; i<M; i++){
    unite(X[i], Y[i]);
  }
  std::set<int > leader;
  for (int i=0; i<N; i++){
    leader.insert(getroot(i));
  }
  std::cout << leader.size() << std::endl;
  return 0;
}

Measured memory_bytes: 6912
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

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

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

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

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

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

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

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

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

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    s: String,
  }
  let n = s.len();
  if s.matches("hi").count() * 2 == n {
    puts!("Yes\n");
  } else {
    puts!("No\n");
  }
}


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

using namespace std;

typedef long long LL;

#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define LEN(a) int((a).size())
#define SORT(a) sort((a).begin(), (a).end())
#define CLR(a) memset((a), 0, sizeof(a))

const double EPS = 1e-10;
const double PI = acos(-1.0);

int main() {
    int n;
    cin >> n;
    vector<vector<int>> t(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        t[a].PB(b);
        t[b].PB(a);
    }
    vector<int> c(n);
    for (int i = 0; i < n; i++) cin >> c[i];
    sort(ALL(c), greater<int>());

    int idx = 0;
    int sum = 0;
    queue<int> q;
    vector<int> r(n);
    vector<bool> v(n, false);
    q.push(0);
    while (!q.empty()) {
        int x = q.front();
        q.pop();
        r[x] = c[idx];
        if (idx != 0) sum += c[idx];
        idx++;
        v[x] = true;
        for (int i = 0; i < LEN(t[x]); i++) {
            if (!v[t[x][i]]) q.push(t[x][i]);
        }
    }

    cout << sum << endl;
    for (int i = 0; i < n; i++) cout << r[i] << " ";
    cout << endl;

    return 0;
}


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

int main(){
  int n;
  int flag = 0;
  cin >> n;
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if (i * j == n){
        flag = 1;
      }
    }
  }
  if (flag==1){
    cout << "Yes" << endl;
  } 
  else{
    cout << "No" << endl;
  }
}

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

using namespace std;

long long int score[2001][2001];
long long int const INF = 1000000000000000;

int main(){
	
	int N;
	
	cin >> N;
	
	for(int i = 0; i <= 2000; i++){
		for(int j = 0; j <= 2000; j++){
			score[i][j] = -INF;
		}
	}
	
	for(int i = 0; i < N; i++){
		cin >> score[0][i];
	}
	
	for(int i = 1; i < N; i++){
		if(i % 2 == 0){
			for(int j = 0; j < N; j++){
				score[i][j] = max(score[i - 1][j] + score[0][(j + i) % N], score[i - 1][(j + 1) % N] + score[0][j]);
			}
		}else{
			for(int j = 0; j < N; j++){
				if(score[0][j] < score[0][(j + i + 1) % N]){
					score[i][(j + 1) % N] = max(score[i][(j + 1) % N], score[i - 1][(j + 1) % N]);
				}else{
					score[i][j] = max(score[i][j], score[i - 1][(j + 1) % N]);
				}
			}
		}
	}
	/*
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			cout << score[i][j] << " ";
		}
		cout << endl;
	}
	*/
	
	long long int ans = 0;
	
	for(int i = 0; i < N; i++){
		ans = max(ans, score[N - 1][i]);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 34388
N, X, Y = [int(n) for n in input().split(' ')]

cnt = [0]*N

for i in range(1, N):  # 1~N-1
    for j in range(i+1, N+1):  # 2~N
        if i <= X:
            if j >= Y:
                p = min(X-i + j-Y + 1, j - i)
            else:
                p = min(X-i + Y-j + 1, j - i)
        else:
            if j >= Y:
                p = min(i-X + j-Y + 1, j - i)
            else:
                p = min(i-X + Y-j + 1, j - i)
        cnt[p] += 1


for i in range(1, N):
    print(cnt[i])


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define int ll

#define _GLIBCXX_DEBUG

#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPD(i,n) for (int i = (n-1); i >= 0; --i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'
#define hyphen() cerr << "--\n"

#define ALL(vec) (vec).begin(), (vec).end()
#define REVALL(vec) (vec).rbegin(), (vec).rend()

#define fst first
#define pb push_back

const int MOD = (int)1e9 + 7;
const int INF = numeric_limits<int>::max();

signed main() {
    int N, M;

    cin >> N >> M;

    map<int, bool> mp;
    REP(i, M) {
        int A;
        cin >> A;
        mp[A] = true;
    }

    vector<int> ans(N+1);
    ans.at(0) = 1;
    if (mp.count(1)) {
        ans.at(1) = 0;
    } else {
        ans.at(1) = 1;
    }

    FORE(i, 2, N) {
        if (mp.count(i)) {
            ans[i] = 0;
            continue;
        }

        ans.at(i) = (ans.at(i-1) + ans.at(i-2)) % MOD;
    }

    cout << ans.at(N) << endl;
}


Measured memory_bytes: 7296
#include <iostream>

using namespace std;

int main() {
  
  int N, K;
  while(cin >> N >> K && (N|K)) {
    int S[100];
    for(int i=0; i<K; i++) {
      cin >> S[i];
    }
    int B[100][100];
    for(int i=0; i<N; i++) {
      for(int j=0; j<K; j++) {
	cin >> B[i][j];
      }
    }
    for(int i=0; i<K; i++) {
      int sum = 0;
      for(int j=0; j<N; j++) {
	sum += B[j][i];
      }
      if(S[i] < sum) {
	cout << "No" << endl;
	goto EXIT;
      }
    }
    cout << "Yes" << endl;
    
  EXIT:;
  }
  
  return 0;
}

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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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

int N,K;
int p[1001];

signed main(){
    cin>>N>>K;
    for(int i=0;i<N;++i)cin>>p[i];
    sort(p,p+N);
    int ans=0;
    for(int i=0;i<K;++i)ans+=p[i];
    cout<<ans<<endl;
}

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

int N, M, Q;
vector<int> a;
vector<int> b;
vector<int> c;
vector<int> d;

long long calc( deque<int> &n )
{
	long long res = 0;
	for( int k = 0; k < Q; k++ ) {
		if( n[ b[k] ] - n[ a[k] ] == c[k] ) res += d[k];
	}
	return res;
}
long long dfs( int i, int mi, deque<int> &n )
{
	long long res = 0;
	for( int k = mi; k <= M; k++ ) {
		deque<int> nn = n;
		nn.push_back( k );
		if( i == 0 ) {
			long long ret = calc( nn );
			res = max( res, ret );
		}
		else {
			long long ret = dfs( i - 1, k, nn );
			res = max( res, ret );
		}
	}
	return res;
}

int main()
{
	cin >> N >> M >> Q;
	a = vector<int>( Q );
	b = vector<int>( Q );
	c = vector<int>( Q );
	d = vector<int>( Q );
	for( int i = 0; i < Q; i++ ) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--;
		b[i]--;
	}

	deque<int> n;
	long long ans = dfs( N, 1, n );

	cout << ans << endl;
}


Measured memory_bytes: 3640
#include <stdio.h>

int main(void) {

    int s, m, h;

    scanf("%d", &s);

    h = (int)(s / 3600);
    m = s % 3600;
    m = (int)(m / 60);
    s = s % 60;

    printf("%d:%d:%d\n", h, m, s);

    return 0;

}

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

a_list = []
person_list = []
syogen_list = []
ans = 0

for i in range(0, n):
    w = []
    v = []
    a = int(input())
    for j in range(0, a):
        x,y = map(int,input().split())
        w.append(x)
        v.append(y)
    person_list.append(w)
    syogen_list.append(v)
#print(person_list)
#print(syogen_list)

for bit in range(1 << n):
    break_flag = 0
    bit_1_cnt = 0
    for i in range(n):
        if break_flag:
            break
        if (bit >> i) & 1: #人iが正直
            for j in range(len(syogen_list[i])):
                if syogen_list[i][j] != ((bit>>(person_list[i][j]-1))&1): #矛盾　：　正直としているのに証言が食い違えばbreak
                    break_flag = 1
                    break
            bit_1_cnt += 1
        if break_flag==0 and i==n-1:
            ans = max(ans, bit_1_cnt)
print(ans)


Measured memory_bytes: 9156
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl
#define F first
#define S second
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

const int dy[] = {-1, 0, 1, 0}, dx[] = {0, -1, 0, 1};
int h, w, s, sy, sx, gy, gx;
bool v[50][50][2][1 << 10], two[50][50][1 << 10];
int move[50][50];
string in[50], ins[10][50];

int main(){
	cin >> w >> h;
	rep(i, h){
		cin >> in[i];
		rep(j, w){
			if(in[i][j] == '%') sy = i, sx = j;
			if(in[i][j] == '&') gy = i, gx = j;
		}
	}
	cin >> s;
	rep(i, s) rep(j, h) cin >> ins[i][j];
	
	rep(k, s) rep(i, h) rep(j, w) if(ins[k][i][j] == '*') move[i][j] |= 1 << k;
	rep(i, h) rep(j, w){
		if(in[i][j] == '#' || in[i][j] == '|') continue;
		bool first = 1;
		if(isalpha(in[i][j]) && isupper(in[i][j]) ||
			in[i][j] == '^') first = 0;
		rep(k, 1 << s) two[i][j][k] = __builtin_popcount(k & move[i][j]) % 2 == first;
	}
	
	deque<pair<pi, int> > q;
	q.pb(mp(mp(0, sy * w + sx), 0));
	while(!q.empty()){
		int y = q.front().F.S / w, x = q.front().F.S % w, c = q.front().F.F;
		int bit = q.front().S % (1 << s), f = q.front().S / (1 << s);
		q.pop_front();
		if(v[y][x][f][bit]) continue;
		v[y][x][f][bit] = 1;
		
		if(y == gy && x == gx){
			cout << c << endl;
			return 0;
		}
		rep(d, 4){
			int ny = y + dy[d], nx = x + dx[d];
			if(ny < 0 || nx < 0 || ny >= h || nx >= w || in[ny][nx] == '#') continue;
			if(in[ny][nx] != '|' && two[ny][nx][bit] != f || v[ny][nx][f][bit]) continue;
			
			q.pb(mp(mp(c + 1, ny * w + nx), f * (1 << s) + bit));
		}
		if(isalpha(in[y][x])){
			int k = tolower(in[y][x]) - 'a';
			int nbit = bit ^ 1 << k, nf = f;
			if(move[y][x] & 1 << k) nf ^= 1;
			if(!v[y][x][nf][nbit]) q.pb(mp(mp(c + 1, y * w + x), nf * (1 << s) + nbit));
		}
		if(in[y][x] == '|'){
			f ^= 1;
			if(!v[y][x][f][bit]) q.pb(mp(mp(c + 1, y * w + x), f * (1 << s) + bit));
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 9628