akhauriyash/Code-Regression huggingface dataset:
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000+7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum, ans, dp[800][800],a[2000000], b[2000000];
string str,ss;
bool f[800][800],flag[800],tdp[800][800];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL to, cost; };
vector<LL>vec[10000];
vector<Pll>v;
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int BipartiteGraph(LL point, vector<int>&color) {
	int cnt = 0;
	function<bool(int, int, int)> dfs = [&](int u, int prev, int c) {
		color[u] = c;
		if (c == 1) cnt++;
		rep(v, n)if (v != prev && v != u && f[u][v] == 0) {
			if (color[v] == -1) {
				if (!dfs(v, u, 1 - c)) return false;
			}
			else if (color[v] != 1 - c) {
				return false;
			}
		}
		return true;
	};
	if (!dfs(point, -1, 0)) return -1;
	return cnt;
}
int main() {
	ans = INF;
	cin >> n >> m;
	rep(i, m) {
		LL x, y;
		cin >> x >> y;
		x--, y--;
		f[x][y] = 1;
		f[y][x] = 1;
	}
	rep(i, n) {
		if (flag[i] == 0) {
			vector<int> color(n, -1);
			if (BipartiteGraph(i, color) == -1) {
				cout << -1 << endl;
				return 0;
			}
			cnt = 0, sum = 0;
			rep(j, n) {
				if (color[j] != -1) {
					flag[j] = 1;
					if (color[j] == 1)
						cnt++;
					sum++;
				}
			}
			v.push_back(Pll(sum - cnt, cnt));
		}
	}
	tdp[0][0] = 1;
	rep(i, v.size()) {
		Mfor(j, n) {
			if (tdp[i][j])
				tdp[i+1][j + v[i].fir] = 1, tdp[i+1][j + v[i].sec] = 1;
		}
	}
	rep(i, n) {
		if (tdp[v.size()][i]&&i) {
			ans = min(ans, i*(i - 1) / 2 + (n - i)*(n - i - 1) / 2);
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    long long a, b;
    cin >> a >> b;
    if(a==1){
        if(b==2){
            cout << 3 << endl;
        }else{
            cout << 2 << endl;
        }
    }else if(a==2){
        if(b==1){
            cout << 3 << endl;
        }else{
            cout << 1 << endl;
        }
    }else{
        if(b==2){
            cout << 1 << endl;
        }else{
            cout << 2 << endl;
        }
    }
    return 0;
 
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, N, a, b) for(int i = a; i < N; i += b)

int main(){
	long long N, A, B;
	cin >> N >> A >> B;
	long long ans = 0;
	if ((B - A) % 2 == 0){
		ans = (B - A) / 2;
	}
	else{
		ans = min(N - B, A - 1) + 1 + (B - A - 1) / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;

int main() {
        string s;
        int k;
        cin >> s >> k;
        int n = s.size();
        set<string> sub_str;
        rep(i,26){
                char alpha = 'a' + i;
                rep(j,n){
                        if(s[j] == alpha){
                                string now = "";
                                now += alpha;
                                int cnt = 1;
                                sub_str.insert(now);
                                while(cnt < k && j+cnt < n){
                                        now += s[j+cnt];
                                        sub_str.insert(now);
                                        cnt ++;
                                }
                        }
                }
                if(sub_str.size() >= k) break;
        }

        int i = 1;
        for(string p:sub_str){
                if(i == k) {
                        cout << p << endl;
                        break;
                }
                i++;
        }
        return 0;  
}

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

int main() {
	int s, c;
long long  n, m;
	cin >> n  >> m;
	
	
	/*int sum = 0;
	int a = c / 2;
	if  (s < a) sum = s,  s = 0, c -= s*2;
	else sum = a, s -= a, c -= a*2;
	 
	sum += c / 4;
	cout << sum << endl;*/
	
	if (m >= 2 * n) cout << n + (m - 2 * n) / 4 << endl;
	else cout << m /2 << endl;
	
	return 0;
}

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

nums = [[0 for _ in range(10)] for _ in range(10)]

ans = 0

for k in range(1,N+1):
    l,r = str(k)[0],str(k)[-1]
    nums[int(l)][int(r)] += 1


ans = 0
for i in range(10):
    for j in range(10):
        ans += nums[i][j]  * nums[j][i]
print(ans)


Measured memory_bytes: 3064
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        n:usize,ss:chars
    }

    let mut ok = true;
    if n % 2 == 1 {
        ok = false;
    } else {
        let rl = n / 2;
        for l in 0..rl {
            if ss[l] != ss[l + rl] {
                ok = false;
            }
        }
    }

    println!("{}", if ok { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 1e17 + 1;

int main()
{
	int N;
	cin >> N;
	vector<ll> h(N), p(N);
	vector<P> hp(N);
	for (int i = 0; i < N; i++) {
		cin >> h[i] >> p[i];
		hp[i] = { h[i] + p[i], h[i] };
	}
	sort(hp.begin(), hp.end());
	for (int i = 0; i < N; i++) {
		h[i] = hp[i].second;
		p[i] = hp[i].first - h[i];
	}
	vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, INF));
	dp[0][0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= i; j++) {
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
			if (dp[i][j] <= h[i]) {
				dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + p[i]);
			}
		}
	}
	int res = 0;
	for (int i = 0; i <= N; i++) {
		if (dp[N][i] != INF) {
			res = i;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 195968
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut n: i64 = read();
    let mut maxv = 0;
    let mut cou = 0;

    let mut prev = -1;
    while n > 0 {
        let c = n % 10;
        n = n / 10;
        if prev == c {
            cou += 1;
        } else {
            cou = 0;
        }
        if cou > maxv {
            maxv = cou;
        }
        prev = c;
    }
    if maxv >= 2 {
        println!("Yes")
    } else {
        println!("No")
    }
}


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

#define sz 100005
#define ff first
#define ss second
#define nl printf("\n");
#define ll long long int

char f,g;
bool flag;
pair < int ,int > pi;
map < int , int > mp;
vector < pair < int , pair < int, int > > > v,va,vb;
vector < pair < int , pair < int, int > > > vp;
//vector < pair < int, int > > vp;
int arr[sz],brr[sz],crr[sz];

int digitof(int x){
    int cnt=0;
    while(x){
        x/=10;
        cnt++;
    }
    return cnt;
}

int main(){

    int n,m, i,j,k, x=0,y=0,z=0, a,b,c;

    cin>>n>>m;
    for(i=0; i<m; i++){
        cin>>a>>b;
        v.push_back({b,{a,i}});
        ///cout<<v[i].ff<<' '<<v[i].ss.ff<<' '<<v[i].ss.ss<<endl;
    }
    sort(v.begin(),v.end());

    for(i=0; i<m; i++){

       a=v[i].ss.ff;///num
       b=v[i].ss.ss;///index
       //cout<<a<<' '<<b<<
       mp[a]++;
       vp.push_back({b,{a,mp[a]}});
    }
    sort(vp.begin(),vp.end());

    for(i=0; i<m; i++){

        x=vp[i].ss.ff;
        y=6-digitof(x);

        while(y--)cout<<0;
        cout<<x;

        x=vp[i].ss.ss;
        y=6-digitof(x);

        while(y--)cout<<0;
        cout<<x<<endl;
    }

    return 0;

}

Measured memory_bytes: 10168
#include<stdio.h>

int main(void){
  int x,n,i;
  scanf("%d%d",&n,&x);
  int l[n];
  int d[n];
  d[0]=0;
  for(i=0;i<n;i++){
    scanf("%d ",&l[i]);
  }
  
  for(i=1;i<=n;i++){
    d[i]=d[i-1]+l[i-1];
  
  }
  int cout;
  
  for(i=0;i<=n;i++){
    if(d[i]<=x){
      cout++;
    
    }
  
  }
  printf("%d",cout);
  return 0;

}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main
{
	public static void main(String[] args)
    {
     	Scanner sc = new Scanner(System.in); 
      
      	long cash = sc.nextLong();
      	long result = (cash / 500) * 1000 + ((cash % 500) / 5) * 5;
      	System.out.println(result);
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define int long long
using namespace std;
char cur[3] = {'R','G','B'};
int pre[50005][500],suf[50005][500];
int ans;
 main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    for(int i =0; i<n; i++){
        for(int j = 0; j<3 && i; j++)
            pre[i][cur[j]-'A'] += pre[i-1][cur[j]-'A'];
        pre[i][s[i]-'A']++;
    }
    for(int i = n-1; i>=0; i--){
         for(int j = 0; j<3; j++)
            suf[i][cur[j]-'A'] += suf[i+1][cur[j]-'A'];
        suf[i][s[i]-'A']++;
    }
    for(int i =0; i<n-2; i++){
        for(int j =i+1; j<n-1; j++) {
            if(s[i]==s[j])continue;
            char to;
            int dis = j-i;
            for(int k =0; k<3; k++)
                if(cur[k] != s[i] && cur[k] != s[j])to = cur[k];
            ans+=suf[j+1][to-'A'];
            ans-=(s[j+dis]== to);

        }
    }
    cout<<ans<<endl;

    return 0;
}


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

Measured memory_bytes: 128
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << "\n"; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "tmp.cpp"

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

  int n;
  cin >> n;

  vector<vi> ans(n, vi(n, 0));

  int cnt = 0;
  int tmp = n;
  while (tmp) {
    cnt++;
    tmp /= 2;
  }

  REP(i, cnt) {
    REP(j, n) {
      if ((j >> i) % 2 == 1) {
        REP(k, n) {
          if ((k >> i) % 2 == 0) {
            ans[j][k] = i + 1;
            ans[k][j] = i + 1;
          }
        }
      }
    }
  }

  REP(i, n - 1) {
    FOR(j, i + 1, n) { cout << ans[i][j] << (j == n - 1 ? "\n" : " "); }
  }

  return 0;
}


Measured memory_bytes: 1536
import itertools

N, M, Q = map(int, input().split())
list_q = []
for i in range(Q):
    list_q.append(list(map(int, input().split())))
ans = 0

for A_ in itertools.combinations_with_replacement([i for i in range(1, M+1)], N):
    A = list(A_)
    tmp_ans = 0
    for i in range(Q):
        if A[list_q[i][1]-1] - A[list_q[i][0]-1] == list_q[i][2]:
            tmp_ans += list_q[i][3]
    if ans < tmp_ans:
        ans = tmp_ans

print(ans)

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

int N, M, Q;
int ans = 0;
vector<vector<int>> V;

void dfs(vector<int> A){
  if(A.size() == N+1){
    int now = 0;
    rep(i, Q){
      if (A.at(V.at(i).at(1)) - A.at(V.at(i).at(0)) == V.at(i).at(2)) now += V.at(i).at(3);
    }
    ans = max(ans, now);
    return;
  }

  A.push_back(A.back());
  while(A.back() <= M){
    dfs(A);
    A.back()++;
  }
  return;
}

int main() {

  cin >> N >> M >> Q;
  V = vector<vector<int>> (Q, vector<int>(4));
  rep(i, Q) cin >> V.at(i).at(0) >> V.at(i).at(1) >> V.at(i).at(2) >> V.at(i).at(3);

  //sort(V.begin(), V.end());

  dfs(vector<int> (1,1));
  cout << ans << endl;

}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, const char * argv[]) {
  int A,B;
  cin >> A >> B;
  if(A == 1) A += 100;
  if(B == 1) B += 100;
  if(A > B){
    cout << "Alice" << endl;
  }
  else if(A < B){
    cout << "Bob" << endl;
  }
  else cout << "Draw" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int M,D;
  scanf("%d",&M);
  scanf("%d",&D);
  int count=0;
  if(D>=22)
    for(int i=22;i<=D;i++){
      if(i%10==0||i%10==1)
      ;
      else if(i%10*(i/10)<=M)
        count++;
    }
    printf("%d",count);
  return 0;
}

Measured memory_bytes: 128
import bisect
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort()
B.sort()
#C.sort(reverse=True)
C.sort()
#2分探索を用いる
ans = 0
for i in B:
    a = bisect.bisect_left(A,i)
    b = N - bisect.bisect_right(C,i)
    ans += a*b
print(ans)

Measured memory_bytes: 22720
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001
#define MOD 1000000007

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};


int main(){
    int N, Ma, Mb;
    ll ans = INF;
    cin >> N >> Ma >> Mb;
    vector<tuple<int,int,int>> yakuhin(N);
    rep(i,N){
        int a, b, c;
        cin >> a >> b >> c;
        yakuhin[i] = {a, b, c};
    }
    vector<vector<vector<ll>>> dp(N+1, vector<vector<ll>>(401, vector<ll>(401, INF)));
    dp[0][0][0] = 0;
    rep(i,N){
        int a = get<0>(yakuhin[i]);
        int b = get<1>(yakuhin[i]);
        int c = get<2>(yakuhin[i]);
        rep(j,401)rep(k,401){
            if(j-a>=0 && k-b>=0) dp[i+1][j][k] = min(dp[i][j][k], dp[i][j-a][k-b] + c);
            else dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
        }
    }
    int d_a = Ma;
    int d_b = Mb;
    while(Ma < 401 && Mb < 401){
        ans = min(ans,dp[N][Ma][Mb]);
        Ma += d_a;
        Mb += d_b;
    }
    if(ans == INF) ans = -1;
    cout << ans << endl;
}



Measured memory_bytes: 56484
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for(int i = 0; i < N; i++) {
			A[sc.nextInt()-1] = i + 1;
		}
		StringBuilder out = new StringBuilder();
		for(int i = 0; i < N; i++) {
			out.append(A[i] + " ");
		}
		System.out.println(out);
		sc.close();
	}

}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

bool conv(char a){
 return a == 'H';  
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  char a,b;
  cin >> a >> b;
  bool ba = conv(a), bb=conv(b);
  if((ba&&bb) || (!ba&&!bb))
    cout << 'H' << endl;
  else
    cout << 'D' << endl;
}

Measured memory_bytes: 256
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)  cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
// #define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 1000005
#define BLOCK 555
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 200005;
const long double epsilon = 1e-9;
ll binexp(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll modinvfermat(ll a, ll m)
{
    return binexp(a, m - 2, m);
}
void task(bool flag)
{
    if (flag)
        cout << "YES\n";
    else
        cout << "NO\n";
}
ll lcm(ll a, ll b)
{
    return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    fast
    ll n;
    cin >> n;
    vl a(n);
    ain(a, n);
    ll ans = 0;
    ll sum = 0;
    loop(i, n)   (sum += a[i]) %= MOD;
    loop(i, n)
    {
        (ans += 1LL * a[i] % MOD * sum % MOD) %= MOD;
    }
    loop(i, n)
    {
        ll val = (1LL * a[i] % MOD * a[i] % MOD) % MOD;
        ans = (ans - val + MOD) % MOD;
    }
    (ans *= 1LL * modinvfermat(2, MOD)) %= MOD;
    cout << ans << END;




// #ifndef ONLINE_JUDGE
//     cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
    return 0;
}

Measured memory_bytes: 4780
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int inf = 1000000000;

vector<bool> isPrime(int n){
  vector<bool> p(n+1, true);
  p[0] = false;
  p[1] = false;
  for(int i=2; i<=sqrt(n); i++){
    if( !p[i] ) continue;
    for(int j=i+i; j<=n; j+=i) p[j] = false;
  }
  return p;
}

int main(void) {
  vector<bool> p = isPrime(10000000);
  int n;
  while(cin >> n){
    if( n == 0 ) break;
    int l = n, r = n;
    while( !p[l] ) l--;
    while( !p[r] ) r++;
    cout << r - l << endl;
  }

  return 0;
}

// EOF

Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

#define int long long int

signed main(){

ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t=1;
//cin>>t;
while(t--){
int a,b,c,d;
cin>>a>>b>>c>>d;
int flag=0;
while(a>0&&c>0){
    if(flag==0){
        c-=b;

    }
    else a-=d;
        flag^=1;
}
if(a<=0)cout<<"No"<<endl;
else cout<<"Yes"<<endl;

}


}



Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE t(n), x(n), y(n); rep(i, n)cin >> t[i] >> x[i] >> y[i];
	rep(i, n) {
		if (t[i] >= x[i] + y[i] && t[i] % 2 == (x[i] + y[i]) % 2) {
		
		}
		else {
			cout << "No" << endl; return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		
		System.out.println((H-h)*(W-w));

	}

}


Measured memory_bytes: 23892
using namespace std; 
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define vect vector<ll>
#define maap map<ll,ll>  
#define MOD 998244353
#define mit map::iterator
#define pii pair<ll,ll>
#define rep(i,a,b)	for(ll i=a;i< b;i++)
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
typedef  long long   int  ll;
//stringstream convert; 
  //  convert << number; 
  //  string s = convert.str();
 ll fact[500005],invfact[500005]; 
 ll power(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = (z*x)%MOD;
		x = (x*x)%MOD;
		y /= 2;
	}
	return z;
}
 ll inv(ll x)
{
	return power(x,MOD-2);
}
ll divide(ll x, ll y)
{
	return (x*inv(y))%MOD;
}
ll C(ll n, ll k)
{
	if(k > n) return 0;
	return divide(fact[n], (fact[n - k]*fact[k])%MOD);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
bool isPrime(int n) {
 
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
} 
void init(){
	ll p=MOD;
	fact[0]=1;
	ll i;
	for(i=1;i<500005;i++){
		fact[i]=(i*fact[i-1])%p;
	}
	i--;
	invfact[i]=power(fact[i],p-2);
	for(i--;i>=0;i--){
		invfact[i]=(invfact[i+1]*(i+1))%p;
	}
}
priority_queue < pair<ll,ll> , vector<pair<ll,ll> >,greater<pair<ll,ll> > > gq;
void ghost()
{   
  	ll i=0,j=0,k=0,l=0,n,r=-10000000000,t=0,q=0,x,y,m;
  	string s;
  	cin>>s;
  	for(i=0;i<s.size();i++)
  	{
  		if(s[i]=='7')
  		{
  			k=1;
  			cout<<"Yes"<<endl;
  			break;
		  }
	  }
	  if(k==0)
	  cout<<"No"<<endl;
}
signed main()
{int test=1;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
fast
//cin>>test;
while(test--)
ghost();
return 0;
}

  

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

using namespace std;

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<int> ret(n);
    for (int i = 0; i < n; ++i) {
        ret[a[i] - 1] = i + 1;
    }
    for (int val : ret) {
        cout << val << ' ';
    }
    cout << '\n';

    return 0;
}

Measured memory_bytes: 1664
import numpy as np
n, k = map(int, input().split())
arr = np.array([int(_)*(int(_)+1)/(int(_)*2.0) for _ in input().split()])

max = t = sum(arr[0:k])

for i in range(1, n-k+1):
  t += arr[i+k-1]
  t -= arr[i-1]
  if max < t:
    max = t

print(max)

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

int main() {
  for (int i = 0; i < 5; i++) {
    int n, k;
    cin >> n >> k;

    // プログラム終了の合図
    if (n == 0 && k == 0) {
      return 0;
    }

    // 累積和
    vector<int> s(n + 1, 0);
    for (int i = 1; i <= n; i++) {
      int num;
      cin >> num;
      s.at(i) = s.at(i - 1) + num;
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
      int left = i;
      int right = i + k;

      if (right > n) {
        break;
      }

      int dif = s.at(right) - s.at(left);
      ans = max(ans, dif);
    }

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}

bool prime(int a){
  for(int x=2; x<sqrt(a)+10 && x < a; x++){
    if(a%x == 0){
      return false;
    }
  }
  return true;
}

int main(void){
  ll a,b;
  cin>>a>>b;
  ll c = gcd(a,b);
  vector<int> P;
  for(int p = 2; p < sqrt(c)+10; p++){
    if(!prime(p)) continue;
    if(c%p == 0){
      P.push_back(p);
      c/=p;
      p--;
    }
  }
  P.push_back(1);
  if(c > 1){
    P.push_back(c);
  }
  sort(all(P));
  ll ans = 0;
  rep(i,P.size()){
    if(i==0) {
      ans++;
      continue;
    }
    if(P[i-1] != P[i]){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int bfs(vector<vector<char>> maze, int H, int W)
{
  vector<vector<int>> already_went(H + 2, vector<int>(W + 2, 0));
  for (int i = 0; i < W + 2; ++i)
  {
    already_went.at(0).at(i) = 1;
    already_went.at(H + 1).at(i) = 1;
  }
  for (int i = 1; i < H + 1; ++i)
  {
    already_went.at(i).at(0) = 1;
    already_went.at(i).at(W + 1) = 1;
  }
  for (int i = 0; i < H; ++i)
  {
    for (int j = 0; j < W; ++j)
    {
      if (maze.at(i).at(j) == '#')
      {
        already_went.at(i + 1).at(j + 1) = 1;
      }
    }
  }
  // for (int i = 0; i < H + 2; ++i)
  // {
  //   for (int j = 0; j < W + 2; ++j)
  //   {
  //     cout << already_went.at(i).at(j) << ' ';
  //   }
  //   cout << endl;
  // }

  queue<tuple<int, int, int>> q;//h, w, cost
  tuple<int, int, int> start_tuple{1, 1, 0};
  q.push(start_tuple);
  while (!q.empty())
  {
    tuple<int, int, int> check = q.front();
    q.pop();
    if (get<0>(check) == H && get<1>(check) == W)
    {
      return get<2>(check);
    }
    if (already_went.at(get<0>(check) + 1).at(get<1>(check)) == 0)
    {
      already_went.at(get<0>(check) + 1).at(get<1>(check)) = 1;
      tuple<int, int, int> check_next{get<0>(check) + 1, get<1>(check), get<2>(check) + 1};
      q.push(check_next);
    }
    if (already_went.at(get<0>(check)).at(get<1>(check) + 1) == 0)
    {
      already_went.at(get<0>(check)).at(get<1>(check) + 1) = 1;
      tuple<int, int, int> check_next{get<0>(check), get<1>(check) + 1, get<2>(check) + 1};
      q.push(check_next);
    }
    if (already_went.at(get<0>(check) - 1).at(get<1>(check)) == 0)
    {
      already_went.at(get<0>(check) - 1).at(get<1>(check)) = 1;
      tuple<int, int, int> check_next{get<0>(check) - 1, get<1>(check), get<2>(check) + 1};
      q.push(check_next);
    }
    if (already_went.at(get<0>(check)).at(get<1>(check) - 1) == 0)
    {
      already_went.at(get<0>(check)).at(get<1>(check) - 1) = 1;
      tuple<int, int, int> check_next{get<0>(check), get<1>(check) - 1, get<2>(check) + 1};
      q.push(check_next);
    }
  }
  return -1;
}

int main()
{
  int H, W;
  cin >> H >> W;
  int alreay_black = 0;
  char gred;
  vector<vector<char>> maze(H, vector<char>(W));
  for (int i = 0; i < H; ++i)
  {
    for (int j = 0; j < W; ++j)
    {
      cin >> gred;
      if (gred == '#')
      {
        alreay_black += 1;
      }
      maze.at(i).at(j) = gred;
    }
  }
  int ans = bfs(maze, H, W);
  if (ans == -1)
  {
    cout << ans << endl;
  }
  else
  {
    cout << (H * W - (ans + alreay_black + 1)) << endl;
  }
}


Measured memory_bytes: 256
// #includes {{{
#ifdef MY_DEBUG
#include "header/header.hpp"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

template<class T>
T inf(){
	return numeric_limits<T>::has_infinity?numeric_limits<T>::infinity():(numeric_limits<T>::max()/2);
}

typedef pair<int,int> pii;

#ifdef MY_DEBUG
#include"print.hpp"
#include"debug.hpp"
#endif
// }}}

Int N;
Int K;
vector<Int> V;

void solve(){
	int ans0 = -inf<int>();
	for(int i = 0;i <= N;i++){//: 0,1,2,...,i-1
		vector<int> v;
		REP(k,i)v.push_back(V[k]);
		for(int j = i;j <= N;j++){//: j,j+1,...,N-1
			vector<int> v2(v);
			RREP(k,j,N){
				v2.push_back(V[k]);
			}
			if(v2.size()>K)continue;
			sort(ALL(v2));
			int ans = accumulate(ALL(v2),0);
			int t = K - v2.size();
			REP(k,t){
				if(k<v2.size() and v2[k]<0){
					ans -= v2[k];
				}
			}
			ans0 = max(ans,ans0);
		}
	}
	cout<<ans0<<endl;
}

//{{{ main fucnction
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> N;
    cin >> K;
    V.assign(N,Int());
    for(int i = 0 ; i < N ; i++){
        cin >> V[i];
    }
	solve();
	return 0;
}

//}}}



Measured memory_bytes: 256
n = int(input())
ans = [0 for i in range(n + 1)]
for x in range(1,int(pow(n, 0.5)+1)):
    for y in range(1,int(pow(n, 0.5)+1)):
        for z in range(1,int(pow(n, 0.5)+1)):
            if x**2 + y**2+z**2 +x*y + x*z + y*z <= n:
                ans [x**2 + y**2+z**2 +x*y + x*z + y*z] += 1
for i in range(1,n+1):
    print(ans[i])

Measured memory_bytes: 70208
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let n = read1::<usize>();
    let mut mt = 0;
    let mut ma = 0;
    for _ in 0..n {
        let ta = readn::<usize>(" ");
        let t = ta[0];
        let a = ta[1];
        let m = std::cmp::max((mt + t - 1)/ t, (ma + a - 1) / a);
        if mt == 0 && ma == 0 {
            mt = t;
            ma = a;
        } else {
            mt = t * m;
            ma = a * m;
        }
    }

    println!("{}", mt + ma);
}

Measured memory_bytes: 4352
import collections
import fractions
N, M = map(int, input().split())
S = input()
T = input()
lcm = (N*M) // fractions.gcd(N, M)
if S[0] != T[0]:
    print(-1)
elif N == M and S != T:
    print(-1)
else:
    tmp = lcm // N
    tmp2 = lcm // M
    tmp_s = collections.defaultdict(str)
    for i in range(N):
        tmp_s[tmp*i] = S[i]

    for i in range(M):
        if tmp2*i in tmp_s:
            if T[i] != tmp_s[tmp2*i]:
                print(-1)
                exit(0)
    print(lcm)


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

struct UnionFind{
  vector<int> v;
  UnionFind(int n) : v(n, -1) {}
  void init(){ for(int i = 0;i < v.size();i++)v[i]=-1; }
  int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (-v[x] < -v[y]) swap(x, y);
    v[x] += v[y]; v[y] = x;
    return true;
  }
  bool root(int x) { return v[x] < 0; }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -v[find(x)]; }
};

ll mod_pow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

int N,M;

int main(){
  while(1){
    cin>>N>>M;
    if(N==0)break;
    UnionFind uf(N);
    rep(i,M){
      int a,b;
      cin>>a>>b;
      a--;b--;
      uf.unite(a,b);
    }
    vector<bool> used(N,false);
    int sum=0;
    ll p=1;
    rep(i,N){
      if(used[uf.find(i)])continue;
      used[uf.find(i)]=true;
      if(uf.size(i)>1){
        sum+=uf.size(i);
        (p*=2)%=mod;
      }
    }
    ll res=mod_pow(2,N-sum);
    if(sum>0){
      (res*=p)%=mod;
      (res+=1)%=mod;
    }
    cout<<res<<endl;
  }
  return 0;
}



Measured memory_bytes: 3492
import sys

def main():
  input = sys.stdin.readline
  x1, y1, x2, y2 = map(int, input().split())

  x4 = -(y2 - y1) + x1
  y4 = (x2 - x1) + y1
  x3 = x2 + x4 - x1
  y3 = y2 + y4 - y1
  print('{} {} {} {}'.format(x3, y3, x4, y4))


if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
# coding:utf-8                                                                  

from collections import defaultdict

N = int(raw_input())
As = map(int, raw_input().split())

dic = defaultdict(lambda:0)
for a in As:
    dic[a] += 1

count = 0
for k, v in dic.items():
    if k > v:
        count += v
    else:
        count += v-k

print count

Measured memory_bytes: 19904
#include<iostream>
using namespace std;
int main(){
    
    int H,W;
    
    while(1){
        cin >> H >> W;
        if(H==0 && W==0) break;
        
        for(int i=1; i<=H; i+=1){
            for(int j=1; j<=W; j+=1){
                if( ((i+j)%2) == 0){
                    cout << "#";
                } else {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
using ll = long long;
int main(void){
    ll n;
    int k;
    cin >> n >> k;
    vector<int> d(k);
    for(int i=0;i<k;i++){
        cin >> d[i];
    }
    int ans=0;
    bool flag;
    for(int i=0;i<n*10;i++){
        flag=true;
        if(i>=n){
            for(int j=0;j<k;j++){
                if(to_string(i).find(to_string(d[j]))!=std::string::npos){
                    flag=false;
                }
            }
        
        if(flag==true){
            ans = i;
            break;
        }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n;
	cin >> n;
	long long int a[n];
	long long sum=0;
	set <long long int> min;
	for(int i=0;i<n;i++){
		cin >> a[i];
		sum+=a[i];
	}
	long long int  mae=0;
	if(n==2)
		cout << abs(a[1]-a[0]) << endl;
	else{
	for(int i=0;i<n-1;i++){
		mae+=a[i];
		min.insert(abs(mae-sum+mae));
	}
	cout << *min.begin() << endl;
	}
}


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

int main(void)
{
    ll n, m, ans = 0;
    cin >> n >> m;
    vector<ll> p(0), a(m), b(m); 

    for(ll i = 0; i < m; i++) {
        cin >> a.at(i) >> b.at(i);
    }

    for(ll i = 1; i <= n; i++) {
        p.push_back(i);
    }

    do {
        if(p.at(0) == 2)
            break;
        
        bool exist = true;
        for(ll i = 0; i < n - 1; i++) {
            bool root_exist = false;
            for(ll j = 0; j < m; j++) {
                if( ( p.at(i) == a.at(j) && p.at(i + 1) == b.at(j) ) || ( p.at(i) == b.at(j) && p.at(i + 1) == a.at(j) ))
                    root_exist = true;
            }

            if(root_exist == false)
                exist = false;
        }

        if(exist)
            ans++;

    } while ( next_permutation(p.begin(), p.end()) );

    cout << ans;
    return 0;
}

Measured memory_bytes: 3580
N, Y = map(int, input().split())

# for i in range(N):
#     for j in range(N):
#         for k in range(N):
#             x = 10000 * i + 5000 * j + 1000 * k
#             if x == Y:
#                 ans = True

ans = [-1,-1,-1]
for i in range(N+1):
    for j in range(N+1):
        tmp_sum = 10000 * i + 5000 * j
        x = Y - tmp_sum
        if x >= 0:
            k = int(x//1000)
            if i + j + k == N:
                ans = [i, j, k]
        # print(i, j)


print(" ".join([str(i) for i in ans]))


Measured memory_bytes: 41068
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int __int128

const int mod=1e9+7;
const int N=1e5+5;
int n,k,ans,pre[N],a[N],fac[N],inv[N];

int calc(int l,int r){
	return pre[r]-pre[l-1];
}

int C(int n,int m){
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}

int fpow(int x,int y){
	int res=1;
	for(;y;y>>=1,x=x*x%mod) if(y&1) res=res*x%mod;
	return res;
}

signed main(){
	read(n);read(k);
	for(int i=1;i<=n;i++)
		read(a[i]);
	if(k==1){
		write(0);
		return 0;
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++) pre[i]=pre[i-1]+a[i];
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
	inv[n]=fpow(fac[n],mod-2);
	for(int i=n-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	for(int i=k;i<=n;i++)
		ans=(ans+C(i-2,k-2)*(calc(i,n)-calc(1,n-i+1))%mod)%mod;
	write(ans);
}


Measured memory_bytes: 6528
#include <iostream>


using namespace std;


int main()
{
  long long w, a, b;

  cin >> w >> a >> b;
  if (a+w < b) cout << b-a-w << endl;
  else if (b+w < a) cout << a-b-w << endl;
  else cout << 0 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
using ll = long long;

int main() {
    ll A, B, N; cin >> A >> B >> N;
    ll x = (N >= B) ? B - 1 : N;
    cout << floor(A * x / B) - A * floor(x / B) << endl;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
#include<string>
    
using namespace std;
            
    #define ll long long
    #define do long double
    #define ff first
    #define ss second
    #define pb push_back
    #define mp make_pair
    #define inf LONG_LONG_MAX
    #define mod 998244353
    #define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


void solve()
{
	ll n,m,i,j,k;
	cin>>n>>m;
	ll x=n*m;
	x/=__gcd(n,m);
	cout<<x;

	
}



int main()
{
    FAST
    ll n,m,i,j;
    ll q;
    q=1;

    while(q--)
    	solve();
	

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
    int key;
    Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
    Node *cur = nil->next;
    while(cur != nil && cur->key != key){
        cur = cur->next;
    }
    return cur;
}

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->prev = nil;
    nil->next = nil;
}

void printList(){
    Node *cur = nil->next;
    int isf = 0;
    while(1){
        if(cur == nil){
            break;
        }
        if(isf++ > 0){
            printf(" ");
        }
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

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

}

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

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

void deleteKey(int key){
    deleteNode(listSearch(key));
}

void insert(int key){
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main(){
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;

    scanf("%d", &n);
    init();
    for(i = 0; i < n; i++){
        scanf("%s%d", com, &key);
        
        if(com[0] == 'i'){
            insert(key);
            np++;
            size++;
            
        }else if(com[0] == 'd'){
            if(strlen(com) > 6){
                
                if(com[6] == 'F'){
                     deleteFirst();
                }else if(com[6] == 'L'){
                    deleteLast();
                }
            }else{
                deleteKey(key);
                nd++;
            }
            size--;
            
        } 

    }
    printList();
    return 0;
}




Measured memory_bytes: 33836