akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    ll left = 0, right = 0;
    rep(i, N) {
        cin >> a[i];
        right += a[i];
    }
    ll ans = 1e18;
    rep(i, N - 1) {
        left += a[i];
        right -= a[i];
        ans = min(ans, abs(left - right));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4004
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
   int c[9]={0};
   for(int i=0;i<9;i++){
       cin>>c[i];
   }
  
    int i,j,k,x,y,z,l,m,n;
    x=c[0]-c[1];
    y=c[3]-c[4];
    z=c[6]-c[7];

    l=c[1]-c[2];
    m=c[4]-c[5];
    n=c[7]-c[8];

    i=c[2]-c[0];
    j=c[5]-c[3];
    k=c[8]-c[6];
    
    if(x==y&&y==z&&i==j&&j==k&&l==m&&m==n){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
int main()
{
    fio;
   int n;
   cin>>n;
   if(n>=400 && n<=599)
    cout<<"8\n";
    else if(n>=600 && n<=799)
    cout<<"7\n";
   else if(n>=800 && n<=999)
    cout<<"6\n";
    else if(n>=1000 && n<=1199)
    cout<<"5\n";
    else if(n>=1200 && n<=1399)
    cout<<"4\n";
    else if(n>=1400 && n<=1599)
    cout<<"3\n";
    else if(n>=1600 && n<=1799)
    cout<<"2\n";
    else if(n>=1800 && n<=1999)
    cout<<"1\n";
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1e9+7;
using P = pair<ll, ll>;
ll gcd(ll a, ll b)
{
    if(b == 0) return a;
    return gcd(b, a%b);
}
ll mod_pow(ll x, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n & 1)
        {
            res = res * x % MOD;
        }
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
    map<P, ll> ma;
    int zero = 0;
    for(int i = 0; i < n; i++)
    {
        if(a[i] < 0)
        {
            a[i] *= -1;
            b[i] *= -1;
        }
        P p;
        if(a[i] == 0 && b[i] == 0)
        {
            zero++;
            continue;
        }
        else if(a[i] == 0)
        {
            p = P(0, -1);
        }
        else
        {
            ll g = gcd(a[i], b[i]);
            p = P(a[i]/g, b[i]/g);
        }
        if(ma.find(p) == ma.end()) ma[p] = 1;
        else ma[p]++;
    }
    vector<ll> count;
    while(!ma.empty())
    {
        auto itr = ma.begin();
        P p = itr->first;
        ll c = itr->second;
        ll x = p.first;
        ll y = p.second;
        ll tx = y;
        ll ty = x;
        if(tx < 0) tx *= -1;
        else ty *= -1;
        if(ma.find(P(tx, ty)) != ma.end())
        {
            ll tc = ma[P(tx, ty)];
            count.push_back((mod_pow(2, c) + mod_pow(2, tc) - 1) % MOD);
            ma.erase(P(tx, ty));
        }
        else
        {
            count.push_back(mod_pow(2, c));
        }
        ma.erase(p);
    }
    ll ans = 1;
    for(ll c : count)
    {
        ans = ans * c % MOD;
    }
    ans = (ans + zero - 1 + MOD) % MOD;
    cout << ans << endl;
}


Measured memory_bytes: 20820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define endl '\n'
#define mod 1000000007
#define modd 998244353
#define PI 3.1415926535897932384626
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

void io() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	io();
	
	int n,k;
	cin>>n>>k;
	vector<int> v(n);
	for(auto &x:v) cin>>x;
	sort(all(v));
	int ans=0;
	for(int i=0;i<k;i++)
		ans+=v[i];
	cout<<ans;
	return 0;
}


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

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n, 0);
  
  set<int> st;
  rep(i, n) cin >> a[i];

  for (int i = n; i > 0; --i) {
    int cnt = 0;
    for (int j = i + i; j <= n; j += i) {
      cnt += b[j - 1];
    }
    if (cnt % 2 != a[i-1]) {
      b[i-1] = 1;
      st.insert(i);
    }
  }

  cout << st.size() << endl;
    if (st.size()) {
      for (auto&& itr : st) {
      cout << itr << " ";
    }
  }
  

}

Measured memory_bytes: 8448
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		int x,y;
		do{
			x= scan.nextInt();
			y= scan.nextInt();
			if(x==0&&y==0) break;
			
			System.out.println((x>y)?(y+" "+x):(x+" "+y));
		}while(true);

	}

}

Measured memory_bytes: 27200
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma comment(linker,"/STACK:36777216")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) begin(x),end(x)
#define F(i,n) for (int i = 0; i < n; ++i)
#define F1(i,n) for (int i = 1; i <= n; ++i)
#define dbg(x) cerr << #x << " = " << x << endl
#define dbgg(x) cerr << #x << " = " << x << ' '
#define T(x) x[pool]
#define mineq(x,y) { if ((x) > (y)) (x) = (y); }
#define maxeq(x,y) { if ((x) < (y)) (x) = (y); }
#define MEOW cout << "meowwwww" << '\n'; system("pause");
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

template<typename T>
ostream& operator <<(ostream &s, const vector<T> &c)
{
	s << "[ "; for (auto it : c) s << it << " "; s << "\b]\n";
	return s;
}

template<typename T>
ostream& operator <<(ostream &s, const pair<int, T> &c)
{
	s << "[ "; cout << c.fi << " , " << c.se << " ] ";
	return s;
}

const int maxn = 123456, maxkk = 2345;
int n, k, x[maxn], y[maxn], c[maxn], diff[maxkk][maxkk], a[maxkk][maxkk];
void input()
{
	cin >> n >> k;
	F1 (i, n)
	{
		char C;
		cin >> x[i] >> y[i] >> C;
		c[i] = C == 'B'; 
	} 
}

void pre(int x, int y, int e)
{
	diff[1][1] += e;
	diff[1][y + 1] -= e;
	diff[x + 1][1] -= e;
	diff[x + 1][y + 1] += e;
} 

void add(int a, int b, int c, int d)
{
	++a, ++b, ++c, ++d;
	if (b < a || d < c) return;
	pre(a - 1, d, -1);
	pre(b, c - 1, -1);
	pre(a - 1, c - 1, 1);
	pre(b, d, 1);
}

void solve()
{
	int ans = 0;
	F1 (i, n)
	{
		vector<pii> x0, x1, y0, y1;
		
		int X = x[i] % (k + k), Y = y[i] % (k + k); 
		if (X < k)
		{
			x0.pb(mp(0, k - X - 1));
			x0.pb(mp(k + k - X, k + k - 1));
			x1.pb(mp(k - X, k + k - X - 1));
		} else
		{
			x0.pb(mp(k + k - X, k + k + k - X - 1));
			x1.pb(mp(0, k + k - X - 1));
			x1.pb(mp(k + k + k - X, k + k - 1));
		}
		if (Y < k)
		{
			y0.pb(mp(0, k - Y - 1));
			y0.pb(mp(k + k - Y, k + k - 1));
			y1.pb(mp(k - Y, k + k - Y - 1));
		} else
		{
			y0.pb(mp(k + k - Y, k + k + k - Y - 1));
			y1.pb(mp(0, k + k - Y - 1));
			y1.pb(mp(k + k + k - Y, k + k - 1));
		}
		if (c[i])
		{
			for (auto xx : x0)
				for (auto yy : y0)
					add(xx.fi, xx.se, yy.fi, yy.se);
			for (auto xx : x1)
				for (auto yy : y1)
					add(xx.fi, xx.se, yy.fi, yy.se);
		} else
		{
			for (auto xx : x0)
				for (auto yy : y1)
					add(xx.fi, xx.se, yy.fi, yy.se);
			for (auto xx : x1)
				for (auto yy : y0)
					add(xx.fi, xx.se, yy.fi, yy.se);
		}
	}
	F1 (i, k + k)
	{
		F1 (j, k + k)
		{
			a[i][j] = diff[i][j];
			a[i][j] += a[i - 1][j];
			a[i][j] += a[i][j - 1];
			a[i][j] -= a[i - 1][j - 1];
			ans = max(ans, a[i][j]);
		}
	}
	cout << ans << '\n';
}

main()
{
	input();
	solve();
}


Measured memory_bytes: 42368
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/
 
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;
 
ll inv[MAX_N], fac[MAX_N];
 
template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }
 
typedef pair<int, pair<int, int>> edge;
 
class UnionFind {
private:
    vector<int> par;
public:
    vector<int> hen;
    UnionFind(int N) { par = vector<int>(N, -1LL); hen = vector<int>(N,0);}
    int find(int x);
    ll size(int x);
    void unite(int x, int y);
    bool same(int x, int y);
};

 
 
 
//----UnionFind-------------------------------
int UnionFind::find(int x) {
    if (par[x] < 0) return x;
    else return par[x] = find(par[x]);
}
 
ll UnionFind::size(int x) {
    return -par[find(x)];
}
 
void UnionFind::unite(int x, int y) {
    x = find(x);
    y = find(y);
    //大きい方に小さい方をくっ付ける
    if (size(x) < size(y)) swap(x, y);
    if (x == y) hen[x]++;
    else hen[x] += hen[y]+1;
    if (x == y) return;
    par[x] += par[y];
    par[y] = x;
}
 
bool UnionFind::same(int x, int y) {
    x = find(x);
    y = find(y);
    return x == y;
}

signed main() {
	int n; cin >> n;
	cout << 180 * (n-2) << endl;
}


Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main() 
{
    int i, x;
    for(i=1; i<=10000; i++)
    {
        cin >> x;
        if(x == 0)
            break;
        cout << "Case" << " " << i << ":" << " " << x << endl;
    }
}


Measured memory_bytes: 3072
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N; cin >> N;
    vector<string> vs(N);

    vector<string> XA, BA, BX, XX;
    int sum = 0;
    for(int i=0; i<N; i++) {
        string s; cin >> s;
        sum += s.size();
        if(s.front() == 'B' and s.back() == 'A') BA.push_back(s);
        else if(s.front() == 'B') BX.push_back(s);
        else if(s.back()  == 'A') XA.push_back(s);
        else XX.push_back(s);
    }

    string ans = "";
    for(auto x : XX) {
        ans += x;
        // cerr << "1 add: " << x << endl;
    }
    if(XA.size()) {
        ans += XA.front();
        // cerr << "1' add: " << XA.front() << endl;
    }
    for(auto x : BA) {
        ans += x;
        // cerr << "2 add: " << x << endl;
    }
    if(BX.size()) {
        ans += BX.front();
        // cerr << "2' add: " << BX.front() << endl;
    }

    int m = (int)min<int>(XA.size(), BX.size());
    for(int i=1; i<m; i++) {
        ans += XA[i];
        // cerr << "3 add: " << XA[i] << endl;
        ans += BX[i];
        // cerr << "4 add: " << BX[i] << endl;
    }
    for(int i=max(1LL, m); i<XA.size(); i++) {
        ans += XA[i];
        // cerr << "5 add: " << XA[i] << endl;
    }
    for(int i=max(1LL, m); i<BX.size(); i++) {
        ans += BX[i];
        // cerr << "6 add: " << BX[i] << endl;
    }

    int cnt = 0;
    // cerr << ans << endl;
    assert(ans.size() == sum);
    for(size_t i=0; i+1<ans.size(); i++) {
        if(ans[i] == 'A' and ans[i+1] == 'B') cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int a[80][80];
int b[80][80];
int c[80][80];
bool dp[80][80][25601];
int main()
{
	int h,w;
	int ans=1e8-1;
	cin>>h>>w;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
			cin>>a[i][j];
	}
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
			cin>>b[i][j];
	}
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
			c[i][j]=a[i][j]-b[i][j];
	}
	fill(dp[0][0],dp[80][0],false);
	dp[0][0][12800+c[0][0]]=true;
	dp[0][0][12800-c[0][0]]=true;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			for(int k=0;k<25601;k++)
			{
				if(dp[i][j][k])
				{
					if(i!=h-1)
					{
						dp[i+1][j][k+c[i+1][j]]=true;
						dp[i+1][j][k-c[i+1][j]]=true;
					}
					if(j!=w-1)
					{
						dp[i][j+1][k+c[i][j+1]]=true;
						dp[i][j+1][k-c[i][j+1]]=true;
					}
				}
			}
		}
	}
	for(int k=0;k<25601;k++)
	{
		if(dp[h-1][w-1][k])
		{
			//cerr<<k-12800<<endl;
			ans=min(ans,abs(k-12800));
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 160384
#include<bits/stdc++.h>
using namespace std;
string s;
int i;

bool isall_pad(string x){
	for(i=0;i<x.size();i++)
	if(x[i]!=x[x.size()-i-1])
	return false;
	
	return true;
}

bool ispart1_pad(string x){
	for(i=0;i<x.size()/2;i++)
	if(x[i]!=x[x.size()/2-i-1])
	return false;
	
	return true;
}

bool ispart2_pad(string x){
	for(i=x.size()/2+1;i<x.size();i++)
	if(x[i]!=x[x.size()-i-1])
	return false;
	
	return true;
}

int main(){
	cin>>s;
	
	if(isall_pad(s)&&ispart1_pad(s)&&ispart2_pad(s))
	cout<<"Yes";
	else cout<<"No";
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pi pair<int,int>
#define ll long long
#define rep(i,a,b) for(int i=int(a); i<=int(b);i++)
#define repv(vec,v) for(v=(vec).begin(); v!=(vec).end();v++)
#define sz(vec) (int)(vec).size()
#define PB push_back
#define F first()
#define S second()

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

ll abss(ll n){
	return n > 0 ? n : -n; 
	}

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

	ll r = n/k;
	
	n-=r*k;
	ll a = abss(n-k);
	cout << min(a,n); 
	
	return 0;
}


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

int main(){
  double w,h,x,y;
  cin >>w>>h>>x>>y;
  cout <<w*h/2<<" ";
  cout << fixed << setprecision(6);
  if(x==w/2&&y==h/2){
    cout <<1<<endl;
  }
  else{
    cout <<0<<endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int N = in.nextInt();
			int M = in.nextInt();
			int Q = in.nextInt();

			int[][] mat = new int[N+10][N+10];
			int[][] sum = new int[N+10][N+10];

			for (int i = 0; i < M; i++) {
				int l = in.nextInt();
				int r = in.nextInt();
				mat[l][r]++;
			}

			for (int i = 0; i < N+10; i++) {
				for (int j = 0; j < N+10; j++) {
					sum[i][j] = mat[i][j];
					if (j-1 >= 0) sum[i][j] += sum[i][j-1];
					if (i-1 >= 0) sum[i][j] += sum[i-1][j];
					if (i-1 >= 0 && j-1 >= 0) sum[i][j] -= sum[i-1][j-1];
				}
			}

			for (int i = 0; i < Q; i++) {
				int p = in.nextInt();
				int q = in.nextInt();

				int count = get(p, p, q, q, sum);
				out.println(count);
			}

		}

		int get(int x1, int y1, int x2, int y2, int[][] sum) {

			int res = sum[x2][y2];
			if (x1 > 0) res -= sum[x1-1][y2];
			if (y1 > 0) res -= sum[x2][y1-1];
			if (x1 > 0 && y1 > 0) res += sum[x1-1][y1-1];

			return res;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 61508
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<cctype>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    cout << min(a%2*b*c,min(b%2*a*c,c%2*a*b));
    return 0;
}

Measured memory_bytes: 256
def tax(p,x):
    return x*(100+p)//100
def solve(p1,p2,s):
    maximum = 0
    for i in range(1,s+1):
        for j in range(i,s+1):
            if tax(p1,i)+tax(p1,j)==s:
                after = tax(p2,i)+tax(p2,j)
                if after >maximum:
                    maximum = after
    return maximum
while True:
    p1,p2,s=map(int,input().split())
    if p1==0:
        break
    print(solve(p1,p2,s))



Measured memory_bytes: 5604
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define INF (1LL<<59)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int k;
	cin>>k;
	ll ans = 0;
	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=k;j++)
		{
			for(int x=1;x<=k;x++)
			ans += __gcd(__gcd(i, j), x);	
		}	
	}
	cout<<ans<<"\n";
	return;
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

// #ifndef ONLINE_JUDGE
// 	time_t time_t1, time_t2;
// 	time_t1 = clock();
// #endif

	//cin>>T;
	while(T--)
	solve(T);

// #ifndef ONLINE_JUDGE
// 	time_t2 = clock();
// 	SETF();
// 	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
// 	UNSETF();
// #endif

	return 0;
}

Measured memory_bytes: 3656
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int w = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        String result = "";
        for (int i = 0; i < s.length(); i += w) {
            result += s.charAt(i);
        }

        // 出力
        System.out.println(result);
    }
}


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

bool has_value(int a, const vector<int>& v) {
  rep(i, v.size()) {
    if(v.at(i) == a) return true;
  }
  return false;
}

int main() {
  int s; cin >> s;
  vector<int> v;
  v.push_back(s);
  while(true) {
    int last = v.back();
    int next;
    if(last%2==0) next = last/2;
    else next = 3*last + 1;
    if(has_value(next, v)) {
      v.push_back(next);
      cout << v.size() << endl;
      break;
    }
    v.push_back(next);
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    int n;
    cin >> n;
    ves w(n) ;
    map<string ,int> mp; 
    rep(i,n){
         cin >> w[i];
         mp[w[i]]++;
    }
    if(mp.size()!=n)No
    rep(i,n-1){
        if(w[i][w[i].size()-1] != w[i+1][0]) No
    }
    Yes
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD = 1000000007;
ll cnt =0,ans=0;
const int MAX = 510000;

int main(){
   ll a,b,c,k;
   cin >> a >> b >> c >> k;

   if(k <= a)cout << k << endl;
   else if( k <= a+b)cout << a << endl;
   else cout << a-(k-a-b) << endl;
   
}
       


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

int main(){
    char input[100];
    char *tp;
    int n,q,x,y,t;
    int i,j;
    int **s;
    int *start_p, *end_p;

    if(fgets(input,sizeof input, stdin)!=NULL){
        tp=strtok(input," ");
        n=atoi(tp);
        tp=strtok(NULL," ");
        q=atoi(tp);
    }

    s=malloc(sizeof(int *) * n);
    for(i=0;i<n;i++)s[i]=malloc(sizeof(int)*1000000);

    start_p=calloc(n,sizeof(int));
    end_p=calloc(n,sizeof(int));

    for(i=0;i<q;i++){
        if(fgets(input,sizeof input, stdin)!=NULL){
            tp=strtok(input," ");
            y=atoi(tp);
            tp=strtok(NULL," ");
            t=atoi(tp);
            switch(y){
                case 0: tp=strtok(NULL," ");
                        x=atoi(tp);
                        s[t][end_p[t]]=x;
                        end_p[t]++;
                    break;
                case 1:
                    if(start_p[t]<end_p[t])printf("%d\n",s[t][start_p[t]]);
                    break;
                case 2:
                    if(start_p[t]<end_p[t])start_p[t]++;
                    break;
                default: break;
            }
        }
    }

    for(i=0;i<n;i++)free(s[i]);
    free(s);
    free(start_p);
    free(end_p);
    
    return 0;
}


Measured memory_bytes: 6324
n, k = (int(x) for x in input().split())
P = list(int(x) - 1 for x in input().split())
C = list(int(x) for x in input().split())

ans = -1e18
for si in range(n):
    S = [C[si]]
    x = P[si]
    while x != si:
        S.append(S[-1] + C[x])
        x = P[x]
    m = len(S)
    if k <= m:
        tmp = max(S[:k])
    else:
        loop = k // m
        r = k % m
        tmp = max(S[-1] * (loop - 1) + max(S), max(S))
        if r != 0:
            tmp = max(tmp, S[-1] * loop + max(S[:r]))
    ans = max(ans, tmp)
print(ans)

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

ll gcd(ll a, ll b){
  return (b != 0) ? gcd(b, a%b) : a;
}

int main(){
  int n;;
  cin >> n;
  ll ans = (-1)*n;
  rep(i, n){
    int a;
    cin >> a;
    ans += a;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
#define int unsigned long long
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))
#define printArr(name,from,to) for(int x = from; x < to; x++) cout << name[x] << " ";
 
// #pragma GCC optimize ("O3")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #define _CRT_SECURE_NO_WARNINGS
 
// #ifndef ONLINE_JUDGE
// #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
// template <typename Arg1>
// void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
// template <typename Arg1, typename... Args>
// void __f(const char* names, Arg1&& arg1, Args&&... args){
// 	const char* comma = strchr(names + 1, ',');
// 	cerr.write(names, comma - names) << " : " << arg1 << "  ";
// 	__f(comma + 1, args...);}
// #else
// #define debug(...)
// #endif
 
// template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
// template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
// template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}
 
const int mod = 1e9 + 7;
const int inf = 2e18;
// const int ninf = -2e18;

const int N = 1e5 + 5;
 
int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}
 
int modinv(int a){return takemod(pow(takemod(a), mod-2,mod));}

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

	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// 	freopen("error.txt","w",stderr);
	// #endif

	time_t t1, t2;
	t1 = clock();

    int N,W,w,v;
    cin>>N>>W;
    vector<int> value;
    vector<int> weight;

    for(int i=0; i<N; i++){
        cin>>w>>v;
        value.pb(v);
        weight.pb(w);
    }

    int arr[N][1000*N+1];
    for (int i=0; i<N; i++){
        for (int j=0; j<=1000*N; j++){
            if (i==0){
				if (j==0) arr[i][j]=0;
                else if(j<=value[i]) arr[i][j]=weight[i];
                else arr[i][j]=inf;
            }
            else if (value[i]>j) arr[i][j] = arr[i-1][j];
            else arr[i][j] = min(arr[i-1][j-value[i]]+weight[i], arr[i-1][j]);

			// cout << arr[i][j] << " ";// << arr[i-1][j] << "  ";
        }
		// cout << endl;
    }
	int ans=0;
	for (int j=0; j<=1000*N; j++){
		for (int i=0; i<N; i++){
			if (arr[i][j]<=W) {
				ans = j;
				break;
			}
		}
	}


    cout << ans << endl;


	t2 = clock();
	cerr << endl << t2-t1 << endl;
	return 0;
}



Measured memory_bytes: 78336
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		
		int k = Integer.parseInt(br.readLine());
		String s = br.readLine();
		
		if(s.length() > k) {
			bw.write(s.substring(0, k) + "...\n");
		} else {
			bw.write(s + "\n");
		}
		
		bw.flush();
	}

}


Measured memory_bytes: 36508
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;
int n, q;
vector<int> go; //ゴーレムiの位置: go[i]
vector<char> t, d;
string s;

// 最後の位置
int posi(int ind) {
    vector<int> l_go = vector<int>(go);
    for(size_t i = 0; i < q; i++)
    {
        if(l_go[ind] < 0) {
            return -1;
        } else if(l_go[ind] > n-1) {
            return n;
        }
        if(s[l_go[ind]] == t[i]) {
            if(d[i] == 'R') l_go[ind] += 1;
            else l_go[ind] -= 1;
        }
    }
    return l_go[ind];
}

// 0以上の境界 first <= index < last
int binsearch_zero(int first, int last) {
    while (first < last) { //lastは次を指すので重ならない
        int mid = (first+last)/2;
        int p = posi(mid);
        if(p == 0) { //一致は決定するのでさっさと除いた方がわかりやすい。
            return mid;
        } else if (p > 0) {
            // lastは探索範囲の1つ外。
            last = mid;
        } else {
            first = mid + 1; //範囲を1つ進められるのはpをはじめにのぞいているからand firstが含まれるから
        }
    }
    return first;
}

// n-1以下になる最大のもの
int binsearch_n(int first, int last) {
    if(first == last) return first-1;
    int mid = (first+last)/2;
    int p = posi(mid);
    if(p == n-1) {
        return mid;
    } else if(p > n-1) {
        return binsearch_n(first, mid);
    } else {
        return binsearch_n(mid + 1, last);
    }
}

int main() {
    int sum = 0;
    cin >> n >> q >> s;
    vector<int> l_go(n);
    vector<char> l_t(q), l_d(q);
    for(size_t i = 0; i < n; i++)
    {
        l_go[i] = i;
    }
    go = l_go;
    for(size_t i = 0; i < q; i++)
    {
        cin >> l_t[i] >> l_d[i];
    }
    t = l_t;
    d = l_d;
    int b_z = binsearch_zero(0, n);
    int b_n = binsearch_n(0, n);
    cout << b_n - b_z + 1 << endl;
}


Measured memory_bytes: 3716
n = int(input())
b = list(map(int, input().split()))
a = [0 for _ in range(n)]
for i in range(n):
    if i == 0:
        a[i] = b[i]
    elif i == n-1:
        a[i] = b[i-1]
    else:
        a[i] = min(b[i], b[i-1])
print(sum(a))

Measured memory_bytes: 3064
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    string s;
    cin >> s;
    ll ans = 0;
    int l =0,r = 1;

    while(r < sz(s)){
	if(s[l] == 'B'){
	    while(r < sz(s) && s[r] == 'B')r++;
	    if(r < sz(s)){
		ans += r - l;
		s[r] = 'B';
		s[l] = 'W';

		l++;
	    }
	}else{
	    l++;
	    if(l >= r)r = l+1;
	}
	//PS(s);PS(ans);PS(l);P(r);
    }
    P(ans);
    return  0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll h,w;
     cin>>h>>w;
     ll g=h*w;
     ll f=(h-1ll)*w;
  if(h==1 || w==1)
  { cout<<1;
   return 0;
  }
  if(g%2==0)
    cout<<g/2ll;
  else
    cout<<((f/2ll)+(w/2)+1ll);
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

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

bool hoge(vector<string>& s) {
	int H = s.size(), W = s[0].size();
	bool flag = false;
	for (int y = 0; y < H; y++)
		for (int x = 0; x < W; x++)
			if (s[y][x] == '.')
				for (int k = 0; k < 4; k++) {
					int _x = x + dx[k], _y = y + dy[k];
					if (_x >= 0 && _y >= 0 && _x < W && _y < H && s[_y][_x] == '@') {
						s[y][x] = '@';
						flag = true;
					}
				}
	return flag;
}

int main() {
	for (;;) {
		int W, H; cin >> W >> H;
		if (W == 0 && H == 0) break;
		vector<string> s(H);
		for (int i = 0; i < H; i++) cin >> s[i];
		while (hoge(s));
		int cnt = 0;
		for (int y = 0; y < H; y++)
			for (int x = 0; x < W; x++)
				if (s[y][x] == '@') cnt++;
		cout << cnt << endl;
	}
}

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

typedef long long ll;


int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	ll res = 0;
	for(int i = 0 ; i <= N-1 ; i++){
		res += A[i]/2;
		if (i+1 <= N-1 && A[i]%2 == 1 && A[i+1] > 0) {
			res++;
			A[i+1]--;
		}
	}
	cout << res << endl;
	return 0;
}



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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//----------------------------------------------------------------
ll dist(ll x, ll y){
  return x*x + y*y;
}

int main(void) {
  int k;
  cin >> k;
  int ans=0;
  int tmp=0;
  vecb exist(k+1, false);
  while(1){
    ans++;
    tmp *= 10;
    tmp += 7;
    tmp %= k;
    if(tmp==0){
      prt(ans);
      return 0;
    } else {
      if(exist[tmp]){
        prt(-1);
        return 0;
      }
      exist[tmp] = true;
    }
  }
}


Measured memory_bytes: 3748
while(True):
    n, x = map(int, input().split())
    if(n == x == 0):
        break
    ans = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            if(j < x - i - j < n + 1):
                ans += 1
    print(ans)


Measured memory_bytes: 5596
// Aizu Vol0 0007: Debt Hell
// 2017.7.28

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

int main()
{
	int n;
	int a = 100000;

	scanf("%d", &n);
	while (n-- > 0) {
		a = a + (a * 5) / 100;
		a = ((a - 1) / 1000 + 1) * 1000;   // 1000?????????????????????
	}
	printf("%d\n", a);
	return 0;
}

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

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

print(str.lower(num2alpha(n)))

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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

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

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

using uint=unsigned;
using ull=unsigned long long;

//initfact();
const uint mod=998244353;
//const uint mod=1000000007;
//uint mod=1;
struct mint{
	uint v;
	mint(ll vv=0){s(vv%mod+mod);}
	mint& s(uint vv){
		v=vv<mod?vv:vv-mod;
		return *this;
	}
	mint operator-()const{return mint()-*this;}
	mint& operator+=(const mint&rhs){return s(v+rhs.v);}
	mint&operator-=(const mint&rhs){return s(v+mod-rhs.v);}
	mint&operator*=(const mint&rhs){
		v=ull(v)*rhs.v%mod;
		return *this;
	}
	mint&operator/=(const mint&rhs){return *this*=rhs.inv();}
	mint operator+(const mint&rhs)const{return mint(*this)+=rhs;}
	mint operator-(const mint&rhs)const{return mint(*this)-=rhs;}
	mint operator*(const mint&rhs)const{return mint(*this)*=rhs;}
	mint operator/(const mint&rhs)const{return mint(*this)/=rhs;}
	mint pow(int n)const{
		mint res(1),x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}
	mint inv()const{return pow(mod-2);}
	/*mint inv()const{
		int x,y;
		int g=extgcd(v,mod,x,y);
		assert(g==1);
		if(x<0)x+=mod;
		return mint(x);
	}*/
	friend ostream& operator<<(ostream&os,const mint&m){
		return os<<m.v;
	}
	bool operator<(const mint&r)const{return v<r.v;}
	bool operator==(const mint&r)const{return v==r.v;}
};

const int vmax=10000010;
mint fact[vmax],finv[vmax],invs[vmax];
void initfact(){
	fact[0]=1;
	rng(i,1,vmax){
		fact[i]=fact[i-1]*i;
	}
	finv[vmax-1]=fact[vmax-1].inv();
	for(int i=vmax-2;i>=0;i--){
		finv[i]=finv[i+1]*(i+1);
	}
	for(int i=vmax-1;i>=1;i--){
		invs[i]=finv[i]*fact[i-1];
	}
}
mint choose(int n,int k){
	return fact[n]*finv[n-k]*finv[k];
}
mint binom(int a,int b){
	return fact[a+b]*finv[a]*finv[b];
}
mint catalan(int n){
	return binom(n,n)-(n-1>=0?binom(n-1,n+1):0);
}

mint sub(int x,int y){
	assert(y<=x);
	mint ans=binom(x,y);
	if(y>0)ans-=binom(x+1,y-1);
	return ans;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	initfact();
	
	int n,a,b;cin>>n>>a>>b;
	
	mint ans=0;
	if(b==0){
		ans=1;
	}else{
		rep(i,min({a,n-b,b-1})+1){
			mint w=sub(b-1,i);
			if(i+b==n){
				if(a==i)
					ans+=w;
			}else{
				int x=n-b-i-1;
				int y=b-i-(b-a)+1;
				ans+=w*binom(x,y-1);
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 117504
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);

ll mod=1000000007LL;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
 //   clog << "|";
    return u;
}
//include modinv

//find nCk, com[i]=nCi
vector<long long> com(100000009, 1LL);
long long COM(long long n,long long k,long long mod=(1LL<<(62))){
    long long b = mod, u = 1, v = 0;
   // chmin(k,n-k);
  // clog<<mod<<endl;
    for(int i=1;i<k+2;i++){
        com[i]=(com[i-1]*(n-i+1)%mod);
        if (mod == (1LL << (62))){
            com[i]=com[i]/i;
        }else{
            com[i] = com[i] *modinv(i,mod) % mod;
        }
      //  clog<<com[i]<<"  ";
    }
 //   clog<<"-"<<com[k]<<" ";
    return com[k];
}
int main(){
    int x,y;
    ll ans=0LL;
    cin >>x>>y;
    int c=0;
    int sum=x+y;
    c = (abs(x - y));
    if(sum%3==0 and sum/3>=c){
        
        sum /= 3;
        clog << sum << " " << c << endl;
        ans = COM(sum,(sum-c)/2 , mod);
        // a + (a+c)=sum
        // 306868 132419 -> c:  sum:146429
        }
    cout<<ans<<endl;
}

Measured memory_bytes: 781568