akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <queue>
using namespace std;

typedef struct{
	int x;
	int y;
}point;

int main(){
	while(1){
		int w, h;
		char field[30][30];
		int visit[30][30]={0};
		int ans=0;
		int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
		point start;
		
		scanf(" %d %d", &w, &h);
		if(w==0) break;	
		for(int i=0; i<h; ++i){
			for(int j=0; j<w; ++j){
				scanf(" %c", &field[j][i]);		
				if(field[j][i] == '@'){
					start.x=j;
					start.y=i;	
				}
			}	
		}
		
		queue<point> que;
		visit[start.x][start.y]=1;
		que.push(start);
		++ans;
		
		while(!que.empty()){
			point now=que.front();
			que.pop();
			
			for(int i=0; i<4; ++i){
				int nx=now.x+dx[i], ny=now.y+dy[i];
				
				if(nx>=0 && nx<w && ny>=0 && ny<h && field[nx][ny]=='.' && visit[nx][ny]==0){
					visit[nx][ny]=1;
					++ans;
					
					point pp;
					pp.x=nx; pp.y=ny;
					que.push(	pp);
				}
			}
		}
		
		printf("%d\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 1212
N, K = list(map(int, input().split()))
S = input()

l = []
n = 0
p = '1'
for s in S:
    if s != p:
        l.append(n)
        p = s
        n = 1
    else:
        n = n + 1
l.append(n)

nw = sum(l[0:(min(K * 2 + 1, N))])
mx = nw
for j in range(2,len(l),2):
    lef = l[j - 2] + l[j - 1]
    rig = 0
    if (j + K * 2 - 1) < len(l):
        rig = rig + l[j + K * 2 - 1]
        if (j + K * 2) < len(l):
            rig = rig + l[j + K * 2]
    nw = nw - lef + rig
    mx = max(mx, nw)
print(mx)


Measured memory_bytes: 4596
#include<bits/stdc++.h>
#define ll long long
#define mo 1000000007
#define pa pair<int,int>
#define fi first
#define se second
#define pi acos(-1)
using namespace std;
int n,a[1005],b[1005],ans[1005];
bool cmp(int x,int y){
	return a[x]>a[y];
}
ll calc(int beg){
	if (beg>n) return -1e18;
	int cnt=0;
	for (int i=beg;i<=n;i+=2)
		b[++cnt]=i;
	sort(b+1,b+cnt+1,cmp);
	int r=1;
	for (;r<cnt&&a[b[r+1]]>0;r++);
	ll s=0;
	for (int i=1;i<=r;i++)
		s+=a[b[i]];
	//printf("%d %lld\n",beg,s);
	return s;
}
void print(int beg){
	int cnt=0;
	for (int i=beg;i<=n;i+=2)
		b[++cnt]=i;
	sort(b+1,b+cnt+1,cmp);
	int r=1,tot=0;
	for (;r<cnt&&a[b[r+1]]>0;r++);
	ll s=0;
	for (int i=1;i<=r;i++)
		s+=a[b[i]];
	printf("%lld\n",s);
	sort(b+1,b+r+1);
	for (int i=r-1;i>0;i--){
		int mid=(b[i]+b[i+1])/2;
		for (;mid>b[i];mid--) ans[++tot]=mid;
	}
	for (int i=1;i<b[1];i++) ans[++tot]=1;
	for (int i=n;i>b[r];i--) ans[++tot]=i-b[r]+1;
	printf("%d\n",tot);
	for (int i=1;i<=tot;i++) printf("%d\n",ans[i]);
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	if (calc(1)>calc(2)) print(1);
	else print(2);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

//char arr[57][57];
int main(){
	Lancer();
	ll n, alice = 0, bob = 0,res=0;
	cin >> n;
	vector<int>vec(n);
	for (int i = 0; i < n; i++)
		cin >> vec[i];
	sort(vec.begin(), vec.end());
	int j = n - 1;
	for (int i = 0; i < n; i++,j--){
		if (i % 2 == 0)
			alice += vec[j];
		else
			bob += vec[j];
	}
	res = alice - bob;
	cout << res;
	cout << endl;
	return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  int N,ans;
  cin>>N;
  vector <int> color(9);
  for(int i=0;i<9;i++){
    color[i]=0;
  }
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    int tmp=a/400;
    if(tmp>8)tmp=8;
    color[tmp]++;
  }
  int min=0;
  for(int i=0;i<8;i++){
    if(color[i]>0)min++;
  }
  int max=min+color[8];
  if(min==0)min++;

  cout << min << " " << max << endl;
}


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

    using namespace std;
    #define ll long long
    #define rep(i,n) for(ll i=0;i<n;i++)
    #define pb push_back
    #define in insert
    #define test   ll t;cin>>t;while(t--)
    #define bs  binary_search
    #define rep1(x,n) for(ll x=n-1;x>=0;x--) 
    
    #define SORT(x) sort(x.begin(),x.end())
    #define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
    #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
    #define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
    #define All(x) (x).begin(),(x).end()
    #define rAll(x) (x).rbegin(),(x).rend()
    #define db  double
    #define sc scanf
    #define pf printf
    const ll MAX=1e8;
    //ll d[MAX],h[MAX];
    const double pi=3.14159265358979323846;
    const ll M=2e18 +7;
    ll gcd(ll x,ll y){
    	if(x==0)return y;
    	else return gcd(y%x,x);
    }
    ll lcm(ll x,ll y){
    	return (x*y)/gcd(x,y);
    }
   
      bool isPrime(ll n) 
{  
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6){ 
        if (n % i == 0 || n % (i + 2) == 0){ 
            return false; 
        }
    }
    return true; 
} 
bool pdrome(string s){
    ll n = s.length();
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n-i-1]){
            return false;
        }
    }
    return true;
}
ll mindig(ll x){
    ll ans = 9;
    ll t = x;
    while(x){
        ans = min(ans,x%10);
        x/=10;
    }
    x = t;
    return ans;
}
ll maxdig(ll x){
    ll ans = 0;
    ll t = x;
    while(x){
        ans = max(ans,x%10);
        x/=10;
    }
    x = t;
    return ans;
}
ll modpow(ll x,ll n,ll M){
	if(n==0)return 1%M;
	ll u=modpow(x,n/2,M);
	u=(u*u)%M;
	if(n%2==1)u=(u*x)%M;
	return u;

}
ll sum(ll a) {
    ll result = 0;
    while (a > 0) {
        result += a % 10;
        a /= 10;
    }
    return result;
}


  
  
    int main() {
    	ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
      string s;
      cin>>s;
      if(s=="ABC")cout<<"ARC";
      else cout<<"ABC";
     
     
    return 0;
}
    


Measured memory_bytes: 3580
#include<iostream>
#include<cmath>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<climits>
#define ll long long
using namespace std;
int main() {
	ll n, k,count=0;
	cin >> n >> k;
	vector<ll>a(n);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (ll i = k; i <= n; i += k-1) {
		if (n == i) {
			count++;
			//cout << i << endl;
			break;
		}
		count++;
		//cout << i  << endl;
		if (i + k - 1 > n) {
			count++;
			break;
		}
	}
	cout << count << endl;
	
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>//..1..2..3:Correct:Solved by F2tekkz:)
#define ll long long
#define str string
#define sonic ios_base::sync_with_stdio(0)
using namespace std;
ll n , m , k , i , j , t , q , cnt , cnt1 , cnt2 , cnt3;
ll cnt4 , cnt5 , ans , ans1 , ans2 , ans3 , sum , sum1 , sum2;
ll mini = 1e9 , maxi = -999;
int main(){
	sonic;
	str s1 , s2 , s3;
	cin >> s1;
	for(i = 0 ; i < s1.size() ; i ++){
		cout << 'x';
	}
}
//     *    *  *  ****    *    *   *
//    *	*   * *   *      * *   *   *
//   *****  **    ****  *****  *****
//   *   *  * *      *  *   *      *
//   *   *  *  *  ****  *   *  *****

//   *  *  *****  *
//   * *     *    *
//   **      *    *
//   * *     *    *
//   *  *    *    ****

//   ****  ****  *       *
//   *      **   *      * *
//   ****   **   *     *****
//      *   **   *     *   *
//   ****  ****  ****  *   *



Measured memory_bytes: 256
r=[int(input()) for _ in range(5)]
#print(r)

ans=0
rowMin=9

flag=0
for item in r:
  ans+=(((-1*item)//10)*(-10))
  if item%10 !=0 and item%10<=rowMin%10:
    rowMin=item
    flag=1
if flag==1:
  ans=ans+rowMin-(((-1*rowMin)//10)*(-10))
else:
  ans=ans
print(ans)

Measured memory_bytes: 3064
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    int m;
    cin >> m;
    vector<vector<pair<int,int>>> C(n + 1);

    for (int i = 0; i < m; ++i) {
        int p, y;
        cin >> p >> y;
        C[p].emplace_back(y, i);
    }
    
    for (auto& V : C) {
        sort(V.begin(), V.end());
    }

    vector<string> res(m);

    for (int i = 0; i <= n; ++i) {
        string pre = to_string(i);
        if (pre.length() < 6) {
            pre = string(6 - pre.length(), '0') + pre;
        }

        for (int j = 0; j < C[i].size(); ++j) {
            int x = j + 1;
            string sfx = to_string(x);
            if (sfx.length() < 6) {
                sfx = string(6 - sfx.length(), '0') + sfx;
            }
            res[C[i][j].second] = pre + sfx;
        }
    }

    for (int i = 0; i < m; ++i) {
        cout << res[i] << '\n';
    }

    return 0;
}

Measured memory_bytes: 12416
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
using namespace std;
int main()
{     int a,b,c;
      cin>>a>>b>>c;
	  if(c>=a&&c<=b)cout<<"Yes"<<endl;
	    else cout<<"No"<<endl; 
	  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define DEBUG if(0)
void solve(long long a, long long b) {
	int x = 0;
	while(a) {
		DEBUG printf(" -> %Ld\n", a);
		a /= b;
		x++;
	}
	printf("%d\n", x);
}
int main() {
  	long long n, r;
  	while(cin >> n >> r) {
  		solve(n, r);
  	}
 	return 0;
}


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

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int h = scanner.nextInt();
			int w = scanner.nextInt();
			int d = scanner.nextInt();
			Map<Integer, Point> map = new HashMap<>();
			IntStream.range(0, h)
					.forEach(i -> IntStream.range(0, w).forEach(j -> map.put(scanner.nextInt(), new Point(i, j))));
			// すべての結果を計算
			int[] result = new int[h * w + 1];
			IntStream.rangeClosed(0, d).forEach(i -> result[i] = 0);
			IntStream.rangeClosed(d + 1, h * w).forEach(i -> {
				Point now = map.get(i);
				Point prev = map.get(i - d);
				result[i] = result[i - d] + Math.abs(now.x - prev.x) + Math.abs(now.y - prev.y);
			});
			int q = scanner.nextInt();
			IntStream.range(0, q).forEach(i -> {
				int l = scanner.nextInt();
				int r = scanner.nextInt();
				System.out.println(result[r] - result[l]);
			});
		}
	}

	/**
	 * 座標データを格納するクラス
	 */
	static class Point {
		/** X座標 */
		final int x;
		/** Y座標 */
		final int y;

		Point(int x, int y) {
			this.x = x;
			this.y = y;
		}
	}
}


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

using std::cerr; 

template <class T>
inline void relax(T &x, const T &y) {
	if (x < y) x = y; 
}

const int MaxM = 6e3 + 5; 
const int MaxN = 3e3 + 5; 

int n; 
char s[MaxM]; 
std::string f[MaxN]; 

int idx[MaxM]; 
int a[MaxN], b[MaxN]; 

int main() {
#ifdef orzczk
	freopen("subsequence.in", "r", stdin); 
#endif

	scanf("%d%s", &n, s + 1); 
	for (int i = 1, cA = 0, cB = 0; i <= (n << 1); ++i) {
		if (s[i] == 'a') {
			a[idx[i] = ++cA] = i; 
		} else {
			b[idx[i] = ++cB] = i; 
		}
	}

	for (int i = n; i >= 1; --i) {
		if (a[i] < b[i]) {
			int j = i; 
			while (j <= n && a[j] <= b[i])
				++j; 
			f[i] = "ab" + f[j]; 
		} else {
			int border = a[i], maxIdx = i; 
			for (int j = b[i] + 1; j <= border; ++j)
				if (s[j] == 'b') {
					relax(border, a[idx[j]]); 
				}
			
			for (int j = b[i]; j <= border; ++j)
				if (idx[j] >= i) {
					f[i] += s[j]; 
					relax(maxIdx, idx[j]); 
				}
			
			// cerr << ": border = " << border << '\n'; 
			f[i] += f[maxIdx + 1]; 
		}

		// cerr << i << ' ' << f[i] << '\n'; 
		relax(f[i], f[i + 1]); 
	}

	std::cout << f[1] << '\n'; 

	return 0; 
}

Measured memory_bytes: 16416
#include<stdio.h>
#define MAX 100000

int partition(int a[],int p,int r){
  int x,i,j,t;
  x=a[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(a[j]<=x){
      i++;
      t=a[i];
      a[i]=a[j];
      a[j]=t;
    }
  }
  t=a[i+1];
  a[i+1]=a[r];
  a[r]=t;
  return i+1;
}

int partition(int a[],int p,int r);

int main(){
  int A[MAX],i,q,n;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  q=partition(A,0,n-1);

  for(i=0;i<n;i++){
    if(i)printf(" ");
     if(i==q)printf("[");
    printf("%d",A[i]);
    if(i==q)printf("]");
  }
  printf("\n");
  return 0;
}





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

using namespace std;

#define REP(i, n) for (ll i = 0; i < n; ++i)
#define RREP(i, n) for (ll i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define RFOR(i, m, n) for (ll i = n - 1; i >= m; --i)
#define ALL(v) (v).begin(),v).end()

#define PB(a) push_back(a)
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

    while (true)
    {
        int n;
        cin >> n;
        if (n == 0)
            break;
        int t[n + 2][n + 2];
        for (int i = 1; i <= n; i++)
            for (int j = 0; j <= n; j++)
                cin >> t[i][j];
        std::vector<int> dp((1 << n), INF);
        dp[0] = 0;
        for (int i = 0; i < (1 << n); i++)
        {
            for (int j = 0; j < n; j++)
            {
                int tmp = i & ~(1 << j); //j?????????????????????
                if (i & (1 << j))
                {
                    for (int k = 0; k < n; k++)
                    {
                        dp[i] = min(dp[i], dp[tmp] + t[j + 1][0]);
                        if (tmp & (1 << k))
                            dp[i] = min(dp[i], dp[tmp] + t[j + 1][k + 1]);
                    }
                }
            }
        }
        cout << dp[(1 << n) - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3408
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------
const ll MAXN = 8020;
int main()
{
  string s;
  cin >> s;
  int x,y;
  cin >> x >> y;

  vector<int> t;
  int cnt = 0;
//文字列を変形する
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'T'){
      if(cnt != 0) t.push_back(cnt);
      t.push_back(0);
      cnt = 0;
    }else{
      cnt++;
      if(i == s.size()-1) t.push_back(cnt);
    }
  }

  bool dp_x[MAXN][MAXN*2] = {false}, dp_y[MAXN][MAXN*2] = {false};
  dp_x[0][8000] = true;
  dp_y[0][8000] = true;

  bool flag = false;
  bool xy = true; // trueならx軸について見ている
  int cnt_x = 0,cnt_y = 0;

  for(int i = 0; i < t.size(); i++){
    if(t[i] == 0){
      xy  = !xy;
    }else if(xy){
      cnt_x++;
      for(int j = 0; j < MAXN*2; j++){
        if(dp_x[cnt_x-1][j]){
          if(j+t[i] < MAXN*2) dp_x[cnt_x][j+t[i]] = true;
          if(j-t[i] >= 0 && flag) dp_x[cnt_x][j-t[i]] = true;
        }
      }
    }else if(!xy){
      cnt_y++;
      for(int j = 0; j < MAXN*2; j++){
        if(dp_y[cnt_y-1][j]){
          if(j+t[i] < MAXN*2) dp_y[cnt_y][j+t[i]] = true;
          if(j-t[i] >= 0) dp_y[cnt_y][j-t[i]] = true;
        }
      }
    }

    if(!flag) flag = true;
  }

  cout << ((dp_x[cnt_x][x+8000] && dp_y[cnt_y][y+8000]) ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 251520
#include <stdio.h>
#include <math.h>
#define N_MAX 10000
int isprime(int x){
    if(x==2){
        return 1;
    }
    if(x<2 || x%2==0){
        return 0;
    }
    int i=3;
    while(i<=sqrt(x)){
        if(x%i==0)
        return 0;
        i=i+2;
    }
    return 1;
}

  

int main(){
    int l,x,i;
    int count=0;
    
    scanf("%d",&l);
    for(i=0;i<l;i++){
      scanf("%d",&x);
      count=count+isprime(x);
    }
    printf("%d\n",count);
    return 0;
}



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

int N;

int main() {
    cin >> N;
    bool f = false;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i*j == N) f = true;
        }
    }

    cout << (f ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 100005, MAXM = 1003, Mod = 1000000007 , MAXLog = 20;



int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;

    string s;
    cin >> s;
    set<char> st;
    for (int i = 0; i < s.size(); ++i)
        st.insert(s[i]);

    if (st.size() == 2) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 3005
using namespace std;
struct edge{
	int t,next;
}e[N*2];int ecnt,head[N];
void addedge(int f,int t){
	e[++ecnt]=(edge){t,head[f]};head[f]=ecnt;
	e[++ecnt]=(edge){f,head[t]};head[t]=ecnt;
}

int sta[N],n,val[N];

void DFS(int u,int fr){
	sta[u]=1;
	for(int i=head[u];i;i=e[i].next){
		if(e[i].t!=fr&&val[e[i].t]<val[u]){
			DFS(e[i].t,fr);
			if(sta[e[i].t]==1) sta[u]=2;
		}
	}
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&val[i]);
	for(int i=1,f,t;i<n;i++) scanf("%d%d",&f,&t),addedge(f,t);
	for(int i=1;i<=n;i++){
		memset(sta,0,sizeof(sta));
		DFS(i,0);
		if(sta[i]==2) printf("%d ",i);
	}
	return 0;
}

Measured memory_bytes: 384
# coding: utf-8
# Your code here!

from collections import deque

S, T = input(), input()
S_q, T_q = deque(list(S)), deque(list(T))
tmp = ""

for i in range(len(S)):
    if S_q == T_q:
        print("Yes")
        exit()
    else:
        tmp = S_q.pop()
        S_q.appendleft(tmp)
else:
    print("No")

Measured memory_bytes: 3316
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e16
using namespace std;
typedef pair<ll, ll> P;
ll level;
struct edge {
	ll to;
};

vector<edge>G[100010];
ll d[100010];

bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b) {
	if (a.second == b.second)return a.first < b.first;
	else return a.second > b.second;
}

void dfs(int root,vector<ll> &c) {
	d[root] = c[level];
	level--;
	for (auto itr = G[root].begin();itr != G[root].end();++itr) {
		//cout << itr->to << endl;
		if (d[itr->to] == 0)dfs(itr->to, c);
	}
	return;
}

int main(void) {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[0] + a[1] << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<queue>

using namespace std;

const int MAX_N = 100000;

void q_max ( int* arr, int size, int* max_index){
  int ii = 0;
  int max = arr[0];
  *max_index = ii;
  for( ii = 0; ii < size; ii++){
    if(arr[ii] > max ){
      *max_index = ii;
      max = arr[ii];
    }
  }

  return ;
}

int main(void){
  int N;
  int M;
  int A[MAX_N];
  long long  sum = 0;
  priority_queue<int> QQ;

  cin >> N >> M;
  for(int ii = 0; ii < N; ii++){
    cin >> A[ii];
  }


  for(int ii = 0; ii < N; ii++){
    QQ.push(A[ii]);
  }

  for(int ii = 0; ii < M; ii++){
    int temp = QQ.top();
    QQ.pop();
    temp /= 2;
    QQ.push(temp);
  }
  while(!QQ.empty()){
    sum += QQ.top();
    QQ.pop();
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, M, D;
  cin >> N >> M >> D;

  if(D == 0){
    printf("%.9f\n", (double)(M-1)/N);
  }else{
    printf("%.9f\n", (double)2*(N-D)*(M-1)/N/N);
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string a;
    string s;
    cin>>a>>s;
    a=a+a;
    if(a.find(s)==-1){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}


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

struct UnionFind{
    vector<int>par;

    UnionFind(int n):par(n){
        for(int i=0;i<n;i++)par[i] = i;
    }
    int find(int x){
        if(par[x] == x)return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x,int y){
        int rx = find(x);
        int ry = find(y);
        if(rx != ry)par[rx] = ry;
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
};

int main(){
    int n,m;
    cin >> n >> m;
    long h[n];
    for(int i=0;i<n;i++)cin >> h[i];
    vector<set<int> >ten(n);
    int a,b;
    for(int i=0;i<m;i++){
        cin >> a >> b;
        a--;
        b--;
        ten[a].insert(b);
        ten[b].insert(a);
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        bool chk = true;
        for(int j:ten[i]){
            if(h[i] <= h[j]){
                chk = false;
                break;
            }
        }
        if(chk)ans++;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 18044
N = int(input())
rlt = 0
 
lst = [2]*(N+1)
lst[1] = 1
 
for i in range(2,N//2+1):
  j = 2
  while i*j <= N:
    lst[i*j] += 1
    j += 1

for i in range(1,N+1):
  rlt += i*lst[i]
  
print(rlt)

Measured memory_bytes: 151336
// haaaaaaaaaaaaard

#include<cmath>
#include<cstdio>

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

using namespace std;

int main(){
	int n,m;
	double p; scanf("%d%d%lf",&n,&m,&p);
	p/=100;

	int e[1<<14]={}; // e[S] := ( S から V\S へ出ている辺の本数 )
	rep(i,m){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		rep(S,1<<n){
			if(S&1<<u && (S&1<<v)==0) e[S]++;
			if(S&1<<v && (S&1<<u)==0) e[S]++;
		}
	}

	// dp[S] := ( V の部分集合 S が連結になる確率 )
	// ここで、S と V-S のつながり方については気にしていない
	double dp[1<<14];
	rep(S,1<<n){
		// S に含まれる頂点(どれでもいい)を一つ固定する
		int u0;
		rep(u,n) if(S&1<<u) u0=u;

		// S を頂点集合とみた部分グラフに制限して考える。
		//   dp[S] = ( u0 を含む連結成分が S である確率 )
		// と
		//   Σ_{T \subset S, u0 \in T} ( u0 を含む連結成分が T である確率 ) = 1
		// より、移項して dp[S] についての漸化式
		//   dp[S] = 1 - Σ_{T \subset S, u0 \in T, T!=S} ( u0 を含む連結成分が T である確率 )
		// を得る。
		// さらに
		//   ( u0 を含む連結成分が T である確率 )
		// = ( T が連結になる確率 ) * p^k
		// = dp[T] * p^k, ( k は T と S\T の間にある辺の本数 )
		// なので
		//   dp[S] = 1 - Σ_{T \subset S, u0 \in T, T!=S} dp[T] * p^k
		// となる。
		dp[S]=1;
		for(int T=(S-1)&S;T>0;T=(T-1)&S) if(T&1<<u0) {
			dp[S]-=dp[T]*pow(p,(e[T]+e[S-T]-e[S])/2);
		}
	}

	printf("%.15f\n",dp[(1<<n)-1]);

	return 0;
}

Measured memory_bytes: 952
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		//input
			// each coin num
			// amount
		// pattern num
		//logic
			//1.(総当たり式)amoutから各パターン(各coinの合計)を引いて、0になったら有効なパターンとしてカウント。
				//(各コインの枚数分試行する必要があるので、三重ループ)
				//一番値が大きいcoinから決め打ちにする
				//問題
					//三重ループだと重い
			//2.
		Scanner scan = new Scanner(System.in);
		
		int num_500Coin = scan.nextInt();
		int num_100Coin = scan.nextInt();
		int num_50Coin = scan.nextInt();
		int target_amount = scan.nextInt();
		
		int n_pattern=0;
		
		//条件check
		if(num_500Coin<0 || num_500Coin > 50) return;
		if(num_100Coin<0 || num_100Coin > 50) return;
		if(num_50Coin<0 || num_50Coin > 50) return;
		if((num_500Coin + num_100Coin + num_50Coin)<1) return;
		if(target_amount<50 || target_amount>20000) return;
		if(target_amount%50 !=0) return;
		
		//caluc
		int y;
		
		for(int i = 0;i <= num_500Coin;i++) {
			y = target_amount - 500*i;
			if(y<0) continue;
			if(y==0) {//他のコインが0枚のパターン
				n_pattern++;
				continue;
			}
			
			for(int j = 0;j <= num_100Coin;j++) {
				int tmp1;
				tmp1 = y - 100*j;
				if(tmp1<0) continue;
				if(tmp1==0) {
					n_pattern++;
					continue;
				}
				
				for(int k = 0;k <= num_50Coin;k++) {
					int tmp2;
					tmp2 = tmp1 - 50*k;
					if(tmp2<0) continue;
					if(tmp2==0) {
						n_pattern++;
						continue;
					}
					
				}
			}
		}
		
		System.out.println(n_pattern);
		
		//よりスコアが高い人のロジック
		/*
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int j = 0;
		for(int i = 0;i <= a;i++) { 
			for(int s = 0;s <= b;s++) { 
				for(int q = 0;q <= c;q++) { 
					if(500 * i + 100 * s + 50 * q == x) {
						j++;
					}
				}
			}
		}
		*/
	}

}


Measured memory_bytes: 23764
#include <stdint.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

void solve(std::vector<long long> x) {
  REP(i, x.size()) {
    if (x[i] == 0) {
      cout << i + 1 << endl;
      break;
    }
  }
}

int main() {
  std::vector<long long> x(5);
  for (int i = 0; i < 5; i++) {
    scanf("%lld", &x[i]);
  }
  solve(std::move(x));
  return 0;
}


Measured memory_bytes: 3680
N,M = list(map(int, input().split()))
divi = []

for i in range(1,int(M**0.5)+1):
    if M % i == 0:
        if i >= N:
            divi.append(i)
        if i != M//i:
            if M//i >= N:
                divi.append(M//i)

print(M//min(divi))


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

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

  ll x;
  cin >> x;

  ll ans = 0;
  if(x <= 6) {
    ans = 1;
  } else if(x <= 11) {
    ans = 2;
  } else {
    ans += (x / 11) * 2;
    if(x % 11 != 0) {
      ans += x % 11 <= 6 ? 1 : 2;
    }
  }


  cout << ans << endl;

  return 0;
}

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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int n;
    cin>>n;
    vector <int> a(n);
    loop(i,0,n) cin>>a[i];
    int c=0;
    loop(i,0,n)
    {
        loop(j,i+1,n)
        {
            c+=(a[i]*a[j]);
        }
    }

    cout<<c;
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
using namespace std;
const int N=1e5+5;
const int INF=1e9+5;

int n;

struct edge{

  int v;
  int c;


};

vector <edge> nb[N];

priority_queue <pair <int,int> > pq;

long long mst=0;

struct point{

  int x;
  int y;
  int ind;

}p[N];

int cost[N];


int abs(int x)
{
    if(x<0)
        return -x;
    return x;
}


bool point_sortx(point a,point b)
{
    if(a.x!=b.x)
        return a.x<b.x;
    return a.y<b.y;
}

bool point_sorty(point a,point b)
{
    if(a.y!=b.y)
        return a.y<b.y;
    return a.x<b.x;
}

int dist[N];
bool vis[N];

void Calc_MST()
{
    int i;
    int v,d;

    for(i=1;i<=n;i++)
        dist[i]=INF;

    pq.push(make_pair(0,1));

    while(!pq.empty())
    {
        while(vis[pq.top().second])
        {
            pq.pop();
            if(pq.empty())
                break;
        }

        if(pq.empty())
            break;

        v=pq.top().second;

        d=-pq.top().first;

        mst+=d;

        vis[v]=true;
        pq.pop();

        for(i=0;i<nb[v].size();i++)
        {
            if(nb[v][i].c<dist[nb[v][i].v])
            {
                dist[nb[v][i].v]=nb[v][i].c;

                pq.push(make_pair(-nb[v][i].c,nb[v][i].v));
            }
        }


    }



}

int main()
{
   int i,j;
   edge temp;

   cin>>n;

   for(i=1;i<=n;i++)
   {
       scanf("%d%d",&p[i].x,&p[i].y);

       p[i].ind=i;

       cost[i]=INF;
   }



   sort(p+1,p+n+1,point_sortx);

   temp.v=p[2].ind;
   temp.c=p[2].x-p[1].x;

   nb[p[1].ind].push_back(temp);
   for(i=2;i<n;i++)
   {
       temp.v=p[i-1].ind;
       temp.c=p[i].x-p[i-1].x;

       nb[p[i].ind].push_back(temp);

       temp.v=p[i+1].ind;
       temp.c=p[i+1].x-p[i].x;

       nb[p[i].ind].push_back(temp);
   }

   temp.v=p[n-1].ind;
   temp.c=p[n].x-p[n-1].x;

   nb[p[n].ind].push_back(temp);




   sort(p+1,p+n+1,point_sorty);

   temp.v=p[2].ind;
   temp.c=p[2].y-p[1].y;

   nb[p[1].ind].push_back(temp);
   for(i=2;i<n;i++)
   {
       temp.v=p[i-1].ind;
       temp.c=p[i].y-p[i-1].y;

       nb[p[i].ind].push_back(temp);

       temp.v=p[i+1].ind;
       temp.c=p[i+1].y-p[i].y;

       nb[p[i].ind].push_back(temp);
   }

   temp.v=p[n-1].ind;
   temp.c=p[n].y-p[n-1].y;

   nb[p[n].ind].push_back(temp);

  /* for(i=1;i<=n;i++)
   {
       for(j=0;j<nb[i].size();j++)
        cout<<nb[i][j].v<<" - "<<nb[i][j].c<<"  ";

       cout<<endl;
   }*/

   Calc_MST();


   cout<<mst<<endl;

   return 0;
}


Measured memory_bytes: 11388
def gcd(a, b):
    while b:
        a, b = b, a % b

    return a


def lcm(a, b):
    return a * b // gcd(a, b)


while True:
    try:
        x, y = map(int, input().split())
        print(gcd(x, y), lcm(x, y))
    except:
        break



Measured memory_bytes: 5600
n = int(input())
d = list(map(int,input().split()))
d.sort()
for i,j in enumerate(d):
    if i%2==0:
        d[i] = 24-j
d.sort()
ans = d[0]
for i in range(1,n):
    tmp = d[i]-d[i-1]
    ans = min(ans,tmp)

ans = min(ans,24-d[-1])
print(ans)


Measured memory_bytes: 38460
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  cout << !!( n % k) << '\n';
} 

Measured memory_bytes: 256
FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]

####
MOD = 998244353
YES, NO, IMP = "YES", "NO", "IMPOSSIBLE"
from collections import defaultdict as ddic

def solve(N, K, A):
    dp = [0] * N
    dp[0] = 1
    windows = [0] * K
    for i in xrange(1, N):
        for k, (L, R) in enumerate(A):
            if 0 <= i - L < N:
                windows[k] += dp[i - L]
            if 0 <= i - R - 1 < N:
                windows[k] -= dp[i - R - 1]
            windows[k] %= MOD
        dp[i] += sum(windows)
        dp[i] %= MOD

    return dp[-1] % MOD
    
N, K = rrm()
A = rrmm(K)
print solve(N, K, A) % MOD


Measured memory_bytes: 75404
def get_digit(n):
    digit = 0
    while n > 0:
        n //= 10
        digit += 1
    return digit


n = int(input())
a = 1
b = n
res = float('inf')
while a * a <= n:
    if n % a == 0:
        b = n // a
        temp = max(get_digit(a), get_digit(b))
        if temp < res:
            res = temp
    a += 1
print(res)


Measured memory_bytes: 9140
def Find(x, par):
    if par[x] < 0:
        return x
    else:
        par[x] = Find(par[x], par)
        return par[x]

def Unite(x, y, par, rank):
    x = Find(x, par)
    y = Find(y, par)

    if x != y:
        if rank[x] < rank[y]:
            par[y] += par[x]
            par[x] = y
        else:
            par[x] += par[y]
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1

def Same(x, y, par):
    return Find(x, par) == Find(y, par)

def Size(x, par):
    return -par[Find(x, par)]

import sys
import io, os
#input = sys.stdin.buffer.readline
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

n, q = map(int, input().split())
par = [-1]* n
rank = [0]*n
for i in range(q):
    t, u, v = map(int, input().split())
    if t == 0:
        Unite(u, v, par, rank)
    else:
        if Same(u, v, par):
            print(1)
        else:
            print(0)        


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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
	ll n, i, k, sum = 0;
	cin >> n >> k;
	vector<ll>pre(n+2);
	rep(i,1,n+1){
		cin >> pre[i];
		pre[i] += pre[i-1];
	}
	rep(i,k,n+1){
		sum = max(sum , pre[i] - pre[i-k]);
	}
	cout << fixed << setprecision(10) << (double)(1.0 * sum + k)/(2.0) << nl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}



Measured memory_bytes: 4772
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner scn= new Scanner(System.in);
        int n =scn.nextInt();
        int a =scn.nextInt();
        String answer ="No";
        if(a>=n%500) answer="Yes";
        System.out.println(answer);
    }
}


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

const long long MOD = 1e9 + 7;
int main(void)
{
    long long n, k; cin >> n >> k;
    long long ans = 0;
    long long l, h;
    for (long long i = k; i <= n + 1; i++)
    {
        l = i * (i - 1) / 2;
        h = n * i - l;
        ans = (ans + h - l + 1) % MOD;
    }
    cout << ans << endl;
}


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

const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> D,
           long long M, std::vector<long long> T){
    map<ll, ll> s;
    REP(i, M){
        s[T.at(i)]++;
    }
    REP(i, N){
        if(s.count(D.at(i)) && s.at(D.at(i))){
            s.at(D.at(i))--;
        }
    }
    for(auto it = s.begin(); it != s.end(); ++it){
        if(it->second > 0){
            cout << NO << endl;
            return;
        }
    }
    cout << YES << endl;
    return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> D(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&D[i]);
    }
    long long M;
    scanf("%lld",&M);
    std::vector<long long> T(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&T[i]);
    }
    solve(N, std::move(D), M, std::move(T));
    return 0;
}


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

#define in cin
#define out cout

#define REP(i,n) for(int i=0; i<n; i++)
#define REP2(i,s,e) for(int i=s; i<e; i++)
#define REPE(i,s,e) for(int i=s; i<=e; i++)
#define REPR(i,s,e) for(int i=s; i>=e; i--)

#define all(v) v.begin(), v.end()
#define pb push_back

#define ll long long
#define pii pair<int, int>

#define x first
#define y second
#define intINF 2147483647
#define llINF 9223372036854775807LL
#define MOD 1000000007

int main()
{
    int n, m; in >> n >> m;
    int A[101];
    REPE(i, 1, n) in >> A[i];

    ll facto[101]; facto[0] = 1LL; REPE(i, 1, 100) facto[i] = (facto[i-1] * i) % MOD;
    ll dp[101][101][256] = {0LL, };

    REPE(i, 0, n) dp[i][0][0] = 1LL;
    REPE(i, 1, n)
    {
        REPE(j, 1, n)
        {
            REPE(k, 0, 255)
            {
                dp[i][j][k] += dp[i-1][j-1][k ^ A[i]];
                dp[i][j][k] += dp[i-1][j][k];
                dp[i][j][k] %= MOD;
            }
        }
    }

    ll res = 0LL;
    REPE(i, 1, n)
    {
        res = (res + dp[n][i][m] * facto[i]) % MOD;
    }
    out << res << "\n";

    return 0;
}


Measured memory_bytes: 20736
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	string S;
	cin >> N >> S;
	if (N % 2 == 0 && S.substr(0, N / 2) == S.substr(N / 2)) {
		cout << "Yes\n";
	} else cout << "No\n";
}


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

using namespace std;

int main()
{
	int a,b,c,d,e,f;
	int water;
	int sugar;
	double pmax=0;//濃度の最大値
	double psup=0;
	pair<int,int> sw;//濃度最大時の水と砂糖の量
	cin>>a>>b>>c>>d>>e>>f;
	psup = (double)e/(double)(100+e);
	a*=100;
	b*=100;
	sw=make_pair(a,0);
	for(int i=0;i<f/a+1;i++)
	{
		for(int j=0;j<f/b+1;j++)
		{
			water=a*i+b*j;
			for(int x=0;x<(f-water)/c+1;x++)
			{
				for(int y=0;y<(f-water)/d+1;y++)
				{
					sugar=c*x+d*y;
					if(water>0 && water+sugar<=f)
					{
						double p=(double)sugar/(double)(sugar+water);
						if(p>pmax && p<=psup)
						{
							pmax=p;
							sw = make_pair(water,sugar);
						}
					}
				}
			}
		}
	}
	cout<<sw.first+sw.second<<" "<<sw.second<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <sstream>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
#define rei(n) for(int i=0;i<(int)n;i++)
#define rel(n) for(int l=0;l<(int)n;l++)
#define all(s) s.begin(),s.end()
#define INT_MAX 2147483647
#define debug(x) cout<<#x<<": "<<x<<endl;
#define PI 2*acos(0,0)
#define pb push_back
#define inin(x) int x; cin>>x;
#define ll long long
#define pb push_back

typedef pair<int, int> pii;
typedef pair<int, pii> pipii;

bool a[10][10000];
vector<string> b[11];
void mk(string str)
{
	b[str.size()].pb(str);
	if (str.size() == 10)return;

	mk(str + "0");
	mk(str + "1");
	return;
}

int main()
{
	string hoge = "";
	mk(hoge);
	while (1)
	{
		int ans = -1;
		inin(y); inin(x);
		if (x == 0&&y == 0)break;
		rep(i, y)
		{
			rep(l, x)
			{
				cin >> a[i][l];
			}
		}

		for (int i = 0; i < b[y].size(); i++)
		{
			int tans = 0;
			for (int l = 0; l < x; l++)
			{
				int tm = 0;
				for (int k = 0; k < y; k++)
				{
					tm+=(b[y][i][k]=='0'+a[k][l])==1;
				}
				tans += max(tm,abs(y-tm));
			}
			ans = max(ans, tans);
		}
		cout << ans << endl;


	}
}

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//切り上げ除算
long long cutup(long long a,long long b){return (a+b-1)/b;}

//累乗
template<typename t>
constexpr t my_pow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
    }
    return x;
}
#define pow my_pow

//chmin,chmax
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;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    Yes(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d));
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int a[4][4];
int main(){
    for(int i = 1; i<= 3;i++) 
        for(int j = 1;j <= 3;j ++) 
            cin>>a[i][j];
    for(int k = -1000;k <= 1000;k++) {
        int a2,a3,b1,b2,b3;
        int a1 = k;
        b1 = a[1][1] - k;
        b2 = a[1][2] - k;
        b3 = a[1][3] - k;
        a2 = a[2][1] - b1;
        a3 = a[3][1] - b1;
        bool flg = false;
        if(a[2][2] != a2 + b2) flg = true;
        if(a[2][3] != a2 + b3) flg = true;
        if(a[3][2] != a3 + b2) flg = true;
        if(a[3][3] != a3 + b3) flg = true;
        if(!flg) {
            cout<<"Yes"<<endl;return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3584
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            List<String> input = Arrays.asList(br.readLine().split(" "));
            abcSwap(input);

            StringBuilder result = new StringBuilder();
            for (int i = 0; i < input.size(); i++) {
                if (i == input.size() - 1) {
                    result.append(input.get(i));
                } else {
                    result.append(input.get(i)).append(" ");
                }
            }
            System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }

    private static void abcSwap(List<String> input) {
        String tmp = input.get(1);
        // A and B swap
        input.set(1, input.get(0));
        input.set(0, tmp);

        // A and C swap
        tmp = input.get(2);
        input.set(2, input.get(0));
        input.set(0, tmp);
    }
}

Measured memory_bytes: 19796